Skip to content
This repository was archived by the owner on Dec 5, 2021. It is now read-only.

Commit 1609211

Browse files
committed
Merge remote-tracking branch 'origin/master'
Former-commit-id: f8081e9
2 parents 22884b0 + 46b509d commit 1609211

5 files changed

Lines changed: 194 additions & 4 deletions

File tree

pom.xml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@
183183
<id>reserve-repo</id>
184184
<url>https://dl.bintray.com/theneweconomy/java/</url>
185185
</repository>
186+
<!-- PlotSquared -->
187+
<repository>
188+
<id>IntellectualSites</id>
189+
<url>https://mvn.intellectualsites.com/content/groups/public/</url>
190+
</repository>
186191
</repositories>
187192

188193
<dependencies>
@@ -378,9 +383,59 @@
378383
</exclusion>
379384
</exclusions>
380385
</dependency>
386+
<!--PlotSquared 5-->
381387
<dependency>
382388
<groupId>com.plotsquared</groupId>
383389
<artifactId>PlotSquared</artifactId>
390+
<version>5.1</version>
391+
<scope>provided</scope>
392+
<exclusions>
393+
<exclusion>
394+
<artifactId>worldedit-core</artifactId>
395+
<groupId>com.sk89q.worldedit</groupId>
396+
</exclusion>
397+
<exclusion>
398+
<artifactId>snakeyaml</artifactId>
399+
<groupId>org.yaml</groupId>
400+
</exclusion>
401+
<exclusion>
402+
<artifactId>Jenkins4J</artifactId>
403+
<groupId>com.github.Sauilitired</groupId>
404+
</exclusion>
405+
<exclusion>
406+
<artifactId>okhttp</artifactId>
407+
<groupId>com.squareup.okhttp3</groupId>
408+
</exclusion>
409+
<exclusion>
410+
<artifactId>okio</artifactId>
411+
<groupId>com.squareup.okio</groupId>
412+
</exclusion>
413+
<exclusion>
414+
<artifactId>kotlin-stdlib</artifactId>
415+
<groupId>org.jetbrains.kotlin</groupId>
416+
</exclusion>
417+
<exclusion>
418+
<artifactId>guava</artifactId>
419+
<groupId>com.google.guava</groupId>
420+
</exclusion>
421+
<exclusion>
422+
<artifactId>text-serializer-gson</artifactId>
423+
<groupId>net.kyori</groupId>
424+
</exclusion>
425+
<exclusion>
426+
<artifactId>gson</artifactId>
427+
<groupId>com.google.code.gson</groupId>
428+
</exclusion>
429+
<exclusion>
430+
<artifactId>lombok</artifactId>
431+
<groupId>org.projectlombok</groupId>
432+
</exclusion>
433+
</exclusions>
434+
</dependency>
435+
<!--PlotSquared 4-->
436+
<dependency>
437+
<groupId>com.github.intellectualsite</groupId>
438+
<artifactId>PlotSquared</artifactId>
384439
<version>4</version>
385440
<scope>system</scope>
386441
<systemPath>${project.basedir}/lib/PlotSquared-Bukkit.jar</systemPath>

src/main/java/org/maxgamer/quickshop/QuickShop.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import org.maxgamer.quickshop.economy.*;
4545
import org.maxgamer.quickshop.integration.IntegrateStage;
4646
import org.maxgamer.quickshop.integration.factionsuuid.FactionsUUIDIntegration;
47-
import org.maxgamer.quickshop.integration.plotsquared.PlotSquaredIntegration;
47+
import org.maxgamer.quickshop.integration.plotsquared.PlotSquaredIntegrationHolder;
4848
import org.maxgamer.quickshop.integration.residence.ResidenceIntegration;
4949
import org.maxgamer.quickshop.integration.towny.TownyIntegration;
5050
import org.maxgamer.quickshop.integration.worldguard.WorldGuardIntegration;
@@ -781,7 +781,7 @@ private void registerIntegrations() {
781781
if (getConfig().getBoolean("integration.plotsquared.enable")) {
782782
Plugin plotSquared = Bukkit.getPluginManager().getPlugin("PlotSquared");
783783
if (plotSquared != null && plotSquared.isEnabled()) {
784-
this.integrationHelper.register(new PlotSquaredIntegration(this));
784+
this.integrationHelper.register(PlotSquaredIntegrationHolder.getPlotSquaredIntegration(this));
785785
}
786786
}
787787
if (getConfig().getBoolean("integration.residence.enable")) {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.maxgamer.quickshop.integration.plotsquared;
2+
3+
import org.bukkit.Bukkit;
4+
import org.maxgamer.quickshop.QuickShop;
5+
import org.maxgamer.quickshop.integration.IntegratedPlugin;
6+
7+
public class PlotSquaredIntegrationHolder {
8+
private static IntegratedPlugin plotSquared;
9+
10+
public static IntegratedPlugin getPlotSquaredIntegration(QuickShop instance) {
11+
if (plotSquared == null) {
12+
if (Bukkit.getPluginManager().getPlugin("PlotSquared").getClass().getPackage().getName().contains("intellectualsite")) {
13+
plotSquared = new PlotSquaredIntegrationV4(instance);
14+
} else {
15+
plotSquared = new PlotSquaredIntegrationV5(instance);
16+
}
17+
}
18+
return plotSquared;
19+
}
20+
}

src/main/java/org/maxgamer/quickshop/integration/plotsquared/PlotSquaredIntegration.java renamed to src/main/java/org/maxgamer/quickshop/integration/plotsquared/PlotSquaredIntegrationV4.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,16 @@
3434

3535
@SuppressWarnings("DuplicatedCode")
3636
@IntegrationStage(loadStage = IntegrateStage.onEnableAfter)
37-
public class PlotSquaredIntegration implements IntegratedPlugin {
37+
public class PlotSquaredIntegrationV4 implements IntegratedPlugin {
3838
private final QuickShop plugin;
3939

4040
private BooleanFlag createFlag;
4141

4242
private BooleanFlag tradeFlag;
4343

4444
private final boolean whiteList;
45-
public PlotSquaredIntegration(QuickShop plugin) {
45+
46+
public PlotSquaredIntegrationV4(QuickShop plugin) {
4647
this.plugin = plugin;
4748
this.whiteList = plugin.getConfig().getBoolean("integration.plotsquared.whitelist-mode");
4849
// PlotAPI plotAPI = new PlotAPI();
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
package org.maxgamer.quickshop.integration.plotsquared;
2+
3+
import com.plotsquared.core.configuration.Caption;
4+
import com.plotsquared.core.configuration.Captions;
5+
import com.plotsquared.core.plot.Plot;
6+
import com.plotsquared.core.plot.flag.GlobalFlagContainer;
7+
import com.plotsquared.core.plot.flag.types.BooleanFlag;
8+
import org.bukkit.ChatColor;
9+
import org.bukkit.Location;
10+
import org.bukkit.entity.Player;
11+
import org.jetbrains.annotations.NotNull;
12+
import org.maxgamer.quickshop.QuickShop;
13+
import org.maxgamer.quickshop.integration.IntegrateStage;
14+
import org.maxgamer.quickshop.integration.IntegratedPlugin;
15+
import org.maxgamer.quickshop.integration.IntegrationStage;
16+
import org.maxgamer.quickshop.util.Util;
17+
18+
import java.util.Arrays;
19+
20+
@SuppressWarnings("DuplicatedCode")
21+
@IntegrationStage(loadStage = IntegrateStage.onEnableAfter)
22+
public class PlotSquaredIntegrationV5 implements IntegratedPlugin {
23+
private final QuickShop plugin;
24+
private final boolean whiteList;
25+
private QuickshopCreateFlag createFlag;
26+
private QuickshopTradeFlag tradeFlag;
27+
28+
public PlotSquaredIntegrationV5(QuickShop plugin) {
29+
this.plugin = plugin;
30+
this.whiteList = plugin.getConfig().getBoolean("integration.plotsquared.whitelist-mode");
31+
}
32+
33+
@Override
34+
public @NotNull String getName() {
35+
return "PlotSquared";
36+
}
37+
38+
@Override
39+
public boolean canCreateShopHere(@NotNull Player player, @NotNull Location location) {
40+
com.plotsquared.core.location.Location pLocation =
41+
new com.plotsquared.core.location.Location(
42+
location.getWorld().getName(),
43+
location.getBlockX(),
44+
location.getBlockY(),
45+
location.getBlockZ());
46+
Plot plot = pLocation.getPlot();
47+
if (plot == null) {
48+
return !whiteList;
49+
}
50+
return plot.getFlag(createFlag);
51+
}
52+
53+
@Override
54+
public boolean canTradeShopHere(@NotNull Player player, @NotNull Location location) {
55+
com.plotsquared.core.location.Location pLocation =
56+
new com.plotsquared.core.location.Location(
57+
location.getWorld().getName(),
58+
location.getBlockX(),
59+
location.getBlockY(),
60+
location.getBlockZ());
61+
Plot plot = pLocation.getPlot();
62+
if (plot == null) {
63+
return !whiteList;
64+
}
65+
return plot.getFlag(tradeFlag);
66+
}
67+
68+
@Override
69+
public void load() {
70+
this.createFlag = new QuickshopCreateFlag();
71+
this.tradeFlag = new QuickshopTradeFlag();
72+
GlobalFlagContainer.getInstance().addAll(Arrays.asList(createFlag, tradeFlag));
73+
plugin.getLogger().info(ChatColor.GREEN + getName() + " flags register successfully.");
74+
Util.debugLog("Success register " + getName() + " flags.");
75+
}
76+
77+
@Override
78+
public void unload() {
79+
}
80+
81+
static class QuickshopCreateFlag extends BooleanFlag<QuickshopCreateFlag> {
82+
83+
protected QuickshopCreateFlag(boolean value, Caption description) {
84+
super(value, description);
85+
}
86+
87+
public QuickshopCreateFlag() {
88+
super(true, Captions.FLAG_CATEGORY_BOOLEAN);
89+
}
90+
91+
@Override
92+
protected QuickshopCreateFlag flagOf(@NotNull Boolean aBoolean) {
93+
return new QuickshopCreateFlag(aBoolean, Captions.FLAG_CATEGORY_BOOLEAN);
94+
}
95+
}
96+
97+
static class QuickshopTradeFlag extends BooleanFlag<QuickshopTradeFlag> {
98+
99+
protected QuickshopTradeFlag(boolean value, Caption description) {
100+
super(value, description);
101+
}
102+
103+
public QuickshopTradeFlag() {
104+
super(true, Captions.FLAG_CATEGORY_BOOLEAN);
105+
}
106+
107+
@Override
108+
protected QuickshopTradeFlag flagOf(@NotNull Boolean aBoolean) {
109+
return new QuickshopTradeFlag(aBoolean, Captions.FLAG_CATEGORY_BOOLEAN);
110+
}
111+
}
112+
113+
}
114+

0 commit comments

Comments
 (0)