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

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
Former-commit-id: f8081e9
  • Loading branch information
Ghost-chu committed May 15, 2020
2 parents 22884b0 + 46b509d commit 1609211
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 4 deletions.
55 changes: 55 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@
<id>reserve-repo</id>
<url>https://dl.bintray.com/theneweconomy/java/</url>
</repository>
<!-- PlotSquared -->
<repository>
<id>IntellectualSites</id>
<url>https://mvn.intellectualsites.com/content/groups/public/</url>
</repository>
</repositories>

<dependencies>
Expand Down Expand Up @@ -378,9 +383,59 @@
</exclusion>
</exclusions>
</dependency>
<!--PlotSquared 5-->
<dependency>
<groupId>com.plotsquared</groupId>
<artifactId>PlotSquared</artifactId>
<version>5.1</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>worldedit-core</artifactId>
<groupId>com.sk89q.worldedit</groupId>
</exclusion>
<exclusion>
<artifactId>snakeyaml</artifactId>
<groupId>org.yaml</groupId>
</exclusion>
<exclusion>
<artifactId>Jenkins4J</artifactId>
<groupId>com.github.Sauilitired</groupId>
</exclusion>
<exclusion>
<artifactId>okhttp</artifactId>
<groupId>com.squareup.okhttp3</groupId>
</exclusion>
<exclusion>
<artifactId>okio</artifactId>
<groupId>com.squareup.okio</groupId>
</exclusion>
<exclusion>
<artifactId>kotlin-stdlib</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
</exclusion>
<exclusion>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
</exclusion>
<exclusion>
<artifactId>text-serializer-gson</artifactId>
<groupId>net.kyori</groupId>
</exclusion>
<exclusion>
<artifactId>gson</artifactId>
<groupId>com.google.code.gson</groupId>
</exclusion>
<exclusion>
<artifactId>lombok</artifactId>
<groupId>org.projectlombok</groupId>
</exclusion>
</exclusions>
</dependency>
<!--PlotSquared 4-->
<dependency>
<groupId>com.github.intellectualsite</groupId>
<artifactId>PlotSquared</artifactId>
<version>4</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/PlotSquared-Bukkit.jar</systemPath>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/maxgamer/quickshop/QuickShop.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import org.maxgamer.quickshop.economy.*;
import org.maxgamer.quickshop.integration.IntegrateStage;
import org.maxgamer.quickshop.integration.factionsuuid.FactionsUUIDIntegration;
import org.maxgamer.quickshop.integration.plotsquared.PlotSquaredIntegration;
import org.maxgamer.quickshop.integration.plotsquared.PlotSquaredIntegrationHolder;
import org.maxgamer.quickshop.integration.residence.ResidenceIntegration;
import org.maxgamer.quickshop.integration.towny.TownyIntegration;
import org.maxgamer.quickshop.integration.worldguard.WorldGuardIntegration;
Expand Down Expand Up @@ -781,7 +781,7 @@ private void registerIntegrations() {
if (getConfig().getBoolean("integration.plotsquared.enable")) {
Plugin plotSquared = Bukkit.getPluginManager().getPlugin("PlotSquared");
if (plotSquared != null && plotSquared.isEnabled()) {
this.integrationHelper.register(new PlotSquaredIntegration(this));
this.integrationHelper.register(PlotSquaredIntegrationHolder.getPlotSquaredIntegration(this));
}
}
if (getConfig().getBoolean("integration.residence.enable")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.maxgamer.quickshop.integration.plotsquared;

import org.bukkit.Bukkit;
import org.maxgamer.quickshop.QuickShop;
import org.maxgamer.quickshop.integration.IntegratedPlugin;

public class PlotSquaredIntegrationHolder {
private static IntegratedPlugin plotSquared;

public static IntegratedPlugin getPlotSquaredIntegration(QuickShop instance) {
if (plotSquared == null) {
if (Bukkit.getPluginManager().getPlugin("PlotSquared").getClass().getPackage().getName().contains("intellectualsite")) {
plotSquared = new PlotSquaredIntegrationV4(instance);
} else {
plotSquared = new PlotSquaredIntegrationV5(instance);
}
}
return plotSquared;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@

@SuppressWarnings("DuplicatedCode")
@IntegrationStage(loadStage = IntegrateStage.onEnableAfter)
public class PlotSquaredIntegration implements IntegratedPlugin {
public class PlotSquaredIntegrationV4 implements IntegratedPlugin {
private final QuickShop plugin;

private BooleanFlag createFlag;

private BooleanFlag tradeFlag;

private final boolean whiteList;
public PlotSquaredIntegration(QuickShop plugin) {

public PlotSquaredIntegrationV4(QuickShop plugin) {
this.plugin = plugin;
this.whiteList = plugin.getConfig().getBoolean("integration.plotsquared.whitelist-mode");
// PlotAPI plotAPI = new PlotAPI();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package org.maxgamer.quickshop.integration.plotsquared;

import com.plotsquared.core.configuration.Caption;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.GlobalFlagContainer;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.maxgamer.quickshop.QuickShop;
import org.maxgamer.quickshop.integration.IntegrateStage;
import org.maxgamer.quickshop.integration.IntegratedPlugin;
import org.maxgamer.quickshop.integration.IntegrationStage;
import org.maxgamer.quickshop.util.Util;

import java.util.Arrays;

@SuppressWarnings("DuplicatedCode")
@IntegrationStage(loadStage = IntegrateStage.onEnableAfter)
public class PlotSquaredIntegrationV5 implements IntegratedPlugin {
private final QuickShop plugin;
private final boolean whiteList;
private QuickshopCreateFlag createFlag;
private QuickshopTradeFlag tradeFlag;

public PlotSquaredIntegrationV5(QuickShop plugin) {
this.plugin = plugin;
this.whiteList = plugin.getConfig().getBoolean("integration.plotsquared.whitelist-mode");
}

@Override
public @NotNull String getName() {
return "PlotSquared";
}

@Override
public boolean canCreateShopHere(@NotNull Player player, @NotNull Location location) {
com.plotsquared.core.location.Location pLocation =
new com.plotsquared.core.location.Location(
location.getWorld().getName(),
location.getBlockX(),
location.getBlockY(),
location.getBlockZ());
Plot plot = pLocation.getPlot();
if (plot == null) {
return !whiteList;
}
return plot.getFlag(createFlag);
}

@Override
public boolean canTradeShopHere(@NotNull Player player, @NotNull Location location) {
com.plotsquared.core.location.Location pLocation =
new com.plotsquared.core.location.Location(
location.getWorld().getName(),
location.getBlockX(),
location.getBlockY(),
location.getBlockZ());
Plot plot = pLocation.getPlot();
if (plot == null) {
return !whiteList;
}
return plot.getFlag(tradeFlag);
}

@Override
public void load() {
this.createFlag = new QuickshopCreateFlag();
this.tradeFlag = new QuickshopTradeFlag();
GlobalFlagContainer.getInstance().addAll(Arrays.asList(createFlag, tradeFlag));
plugin.getLogger().info(ChatColor.GREEN + getName() + " flags register successfully.");
Util.debugLog("Success register " + getName() + " flags.");
}

@Override
public void unload() {
}

static class QuickshopCreateFlag extends BooleanFlag<QuickshopCreateFlag> {

protected QuickshopCreateFlag(boolean value, Caption description) {
super(value, description);
}

public QuickshopCreateFlag() {
super(true, Captions.FLAG_CATEGORY_BOOLEAN);
}

@Override
protected QuickshopCreateFlag flagOf(@NotNull Boolean aBoolean) {
return new QuickshopCreateFlag(aBoolean, Captions.FLAG_CATEGORY_BOOLEAN);
}
}

static class QuickshopTradeFlag extends BooleanFlag<QuickshopTradeFlag> {

protected QuickshopTradeFlag(boolean value, Caption description) {
super(value, description);
}

public QuickshopTradeFlag() {
super(true, Captions.FLAG_CATEGORY_BOOLEAN);
}

@Override
protected QuickshopTradeFlag flagOf(@NotNull Boolean aBoolean) {
return new QuickshopTradeFlag(aBoolean, Captions.FLAG_CATEGORY_BOOLEAN);
}
}

}

0 comments on commit 1609211

Please sign in to comment.