Added support for PlotSquared

Three new custom flags will be available for every plot to set:
- create-shop
- use-shop
- use-admin-shop

These flags can be set to the following values
to allow the flag to that group. If you set the group to
members, trusted members and owners are also allowed the flag:
- owners
- trusted
- members
- everyone
- none

The default value for the flags will be 'none', so be sure to
change it in order to create or use shops!

The flag 'create-shop' can be bypassed by granting the permission
'shopchest.create.protected' (which is not recommended), and the
other flags can be bypassed by granting the permission
'shopchest.external.bypass'.

This closes #87
This commit is contained in:
Eric 2017-03-28 14:37:12 +02:00
parent d9a76ba09c
commit 4a7202df6f
16 changed files with 248 additions and 59 deletions

10
pom.xml
View File

@ -114,6 +114,10 @@
<id>sk89q-repo</id>
<url>http://maven.sk89q.com/artifactory/repo/</url>
</repository>
<repository>
<id>athion-reop</id>
<url>http://ci.athion.net/job/PlotSquared/ws/mvn/</url>
</repository>
</repositories>
<dependencies>
@ -152,6 +156,12 @@
<version>5.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.plotsquared</groupId>
<artifactId>plotsquared-api</artifactId>
<version>latest</version>
<scope>provided</scope>
</dependency>
</dependencies>
<distributionManagement>

View File

@ -1,10 +1,12 @@
package de.epiceric.shopchest;
import com.intellectualcrafters.plot.PS;
import com.palmergames.bukkit.towny.Towny;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.config.Regex;
import de.epiceric.shopchest.event.ShopReloadEvent;
import de.epiceric.shopchest.external.PlotSquaredShopFlag;
import de.epiceric.shopchest.language.LanguageUtils;
import de.epiceric.shopchest.language.LocalizedMessage;
import de.epiceric.shopchest.listeners.*;
@ -16,7 +18,7 @@ import de.epiceric.shopchest.sql.MySQL;
import de.epiceric.shopchest.sql.SQLite;
import de.epiceric.shopchest.utils.*;
import de.epiceric.shopchest.utils.UpdateChecker.UpdateCheckerResult;
import de.epiceric.shopchest.worldguard.ShopFlag;
import de.epiceric.shopchest.external.WorldGuardShopFlag;
import fr.xephi.authme.AuthMe;
import net.milkbowl.vault.economy.Economy;
import org.bstats.Metrics;
@ -30,7 +32,6 @@ import org.bukkit.scheduler.BukkitRunnable;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
@ -100,7 +101,7 @@ public class ShopChest extends JavaPlugin {
Plugin worldGuardPlugin = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
if (worldGuardPlugin instanceof WorldGuardPlugin) {
worldGuard = (WorldGuardPlugin) worldGuardPlugin;
ShopFlag.init(this, true);
WorldGuardShopFlag.register(this, true);
}
}
@ -138,8 +139,8 @@ public class ShopChest extends JavaPlugin {
getLogger().warning("Plugin may still work, but more errors are expected!");
}
if (worldGuard != null && !ShopFlag.isLoaded()) {
ShopFlag.init(this, false);
if (worldGuard != null && !WorldGuardShopFlag.isLoaded()) {
WorldGuardShopFlag.register(this, false);
try {
// Reload WorldGuard regions, so that custom flags are applied
@ -163,6 +164,10 @@ public class ShopChest extends JavaPlugin {
authMe = (AuthMe) authMePlugin;
}
if (hasPlotSquared()) {
new PlotSquaredShopFlag().register(this);
}
debug("Loading utils and extras...");
LanguageUtils.load();
@ -427,6 +432,13 @@ public class ShopChest extends JavaPlugin {
this.updater = updater;
}
/**
* @return Whether the plugin 'PlotSquared' is enabled
*/
public boolean hasPlotSquared() {
return getServer().getPluginManager().getPlugin("PlotSquared") != null;
}
/**
* @return Whether the plugin 'AuthMe' is enabled
*/

View File

@ -104,6 +104,9 @@ public class Config {
/** Whether AuthMe integration should be enabled **/
public boolean enable_authme_integration;
/** Whether PlotSquared integration should be enabled **/
public boolean enable_plotsquared_integration;
/** Whether the vendor of the shop should get messages about buys and sells **/
public boolean enable_vendor_messages;
@ -342,6 +345,7 @@ public class Config {
enable_worldguard_integration = plugin.getConfig().getBoolean("enable-worldguard-integration");
enable_towny_integration = plugin.getConfig().getBoolean("enable-towny-integration");
enable_authme_integration = plugin.getConfig().getBoolean("enable-authme-integration");
enable_plotsquared_integration = plugin.getConfig().getBoolean("enable-plotsquared-integration");
enable_vendor_messages = plugin.getConfig().getBoolean("enable-vendor-messages");
explosion_protection = plugin.getConfig().getBoolean("explosion-protection");
only_show_shops_in_sight = plugin.getConfig().getBoolean("only-show-shops-in-sight");

View File

@ -0,0 +1,87 @@
package de.epiceric.shopchest.external;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.Flags;
import de.epiceric.shopchest.ShopChest;
import java.util.Locale;
public class PlotSquaredShopFlag {
private static boolean registered = false;
public enum Group {
OWNERS, MEMBERS, TRUSTED, EVERYONE, NONE
}
public static Flag CREATE_SHOP;
public static Flag USE_SHOP;
public static Flag USE_ADMIN_SHOP;
private GroupFlag createShop = new GroupFlag("create-shop");
private GroupFlag useShop = new GroupFlag("use-shop");
private GroupFlag useAdminShop = new GroupFlag("use-admin-shop");
public void register(ShopChest plugin) {
if (registered) return;
CREATE_SHOP = createShop;
USE_SHOP = useShop;
USE_ADMIN_SHOP = useAdminShop;
Flags.registerFlag(createShop);
Flags.registerFlag(useShop);
Flags.registerFlag(useAdminShop);
registered = true;
plugin.debug("Registered custom PlotSquared flags");
}
public class GroupFlag extends Flag<Group> {
public GroupFlag(String name) {
super(name);
}
@Override
public String valueToString(Object value) {
return String.valueOf(value);
}
@Override
public Group parseValue(String s) {
String val = s.toLowerCase(Locale.ENGLISH);
switch (val) {
case "owners":
case "owner":
return Group.OWNERS;
case "members":
case "member":
case "helpers":
case "helper":
return Group.MEMBERS;
case "trusted":
return Group.TRUSTED;
case "everyone":
case "all":
return Group.EVERYONE;
case "deny":
case "false":
case "no":
case "0":
case "none":
case "noone":
return Group.NONE;
}
return null;
}
@Override
public String getValueDescription() {
return "Flag value must be a group: 'owner' , 'members', 'trusted', 'everyone' or 'none'";
}
}
}

View File

@ -1,4 +1,4 @@
package de.epiceric.shopchest.worldguard;
package de.epiceric.shopchest.external;
import com.google.common.collect.Lists;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
@ -9,7 +9,7 @@ import de.epiceric.shopchest.ShopChest;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
public class ShopFlag {
public class WorldGuardShopFlag {
private static Flag<?>[] customFlagList;
private static boolean loaded = false;
@ -30,7 +30,7 @@ public class ShopFlag {
return loaded;
}
public static void init(final ShopChest plugin, boolean onLoad) {
public static void register(final ShopChest plugin, boolean onLoad) {
String worldGuardVersion = plugin.getWorldGuard().getDescription().getVersion();
int majorVersion = 0;

View File

@ -978,8 +978,8 @@ public class LanguageUtils {
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_OPEN_OTHERS, langConfig.getString("message.noPermission.open-others", "&cYou don't have permission to open this chest.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_BUY, langConfig.getString("message.noPermission.buy", "&cYou don't have permission to buy something.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_SELL, langConfig.getString("message.noPermission.sell", "&cYou don't have permission to sell something.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_WG_BUY, langConfig.getString("message.noPermission.worldguard-buy", "&cYou don't have permission to buy something here.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_WG_SELL, langConfig.getString("message.noPermission.worldguard-sell", "&cYou don't have permission to sell something here.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_BUY_HERE, langConfig.getString("message.noPermission.buy-here", "&cYou don't have permission to buy something here.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_SELL_HERE, langConfig.getString("message.noPermission.sell-here", "&cYou don't have permission to sell something here.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_REMOVE_OTHERS, langConfig.getString("message.noPermission.remove-others", "&cYou don't have permission to remove this shop.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_REMOVE_ADMIN, langConfig.getString("message.noPermission.remove-admin", "&cYou don't have permission to remove an admin shop.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_RELOAD, langConfig.getString("message.noPermission.reload", "&cYou don't have permission to reload the shops.")));

View File

@ -113,8 +113,8 @@ public class LocalizedMessage {
NO_PERMISSION_OPEN_OTHERS,
NO_PERMISSION_BUY,
NO_PERMISSION_SELL,
NO_PERMISSION_WG_BUY,
NO_PERMISSION_WG_SELL,
NO_PERMISSION_BUY_HERE,
NO_PERMISSION_SELL_HERE,
NO_PERMISSION_REMOVE_OTHERS,
NO_PERMISSION_REMOVE_ADMIN,
NO_PERMISSION_RELOAD,

View File

@ -7,6 +7,7 @@ import com.sk89q.worldguard.bukkit.RegionContainer;
import com.sk89q.worldguard.bukkit.RegionQuery;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.external.PlotSquaredShopFlag;
import de.epiceric.shopchest.language.LanguageUtils;
import de.epiceric.shopchest.language.LocalizedMessage;
import de.epiceric.shopchest.nms.Hologram;
@ -14,7 +15,7 @@ import de.epiceric.shopchest.shop.Shop;
import de.epiceric.shopchest.utils.Permissions;
import de.epiceric.shopchest.utils.ShopUtils;
import de.epiceric.shopchest.utils.Utils;
import de.epiceric.shopchest.worldguard.ShopFlag;
import de.epiceric.shopchest.external.WorldGuardShopFlag;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -34,11 +35,8 @@ import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class ChestProtectListener implements Listener {
@ -153,7 +151,7 @@ public class ChestProtectListener implements Listener {
if (plugin.hasWorldGuard() && plugin.getShopChestConfig().enable_worldguard_integration) {
RegionContainer container = worldGuard.getRegionContainer();
RegionQuery query = container.createQuery();
externalPluginsAllowed = query.testState(b.getLocation(), p, ShopFlag.CREATE_SHOP);
externalPluginsAllowed = query.testState(b.getLocation(), p, WorldGuardShopFlag.CREATE_SHOP);
}
if (plugin.hasTowny() && plugin.getShopChestConfig().enable_towny_integration) {
@ -161,6 +159,13 @@ public class ChestProtectListener implements Listener {
externalPluginsAllowed &= (townBlock != null && townBlock.getType() == TownBlockType.COMMERCIAL);
}
if (plugin.hasPlotSquared() && plugin.getShopChestConfig().enable_plotsquared_integration) {
com.intellectualcrafters.plot.object.Location loc =
new com.intellectualcrafters.plot.object.Location(b.getWorld().getName(), b.getX(), b.getY(), b.getZ());
externalPluginsAllowed &= Utils.isFlagAllowedOnPlot(loc.getOwnedPlot(), PlotSquaredShopFlag.CREATE_SHOP, p);
}
if (externalPluginsAllowed || p.hasPermission(Permissions.EXTEND_PROTECTED)) {
if (shop.getVendor().getUniqueId().equals(p.getUniqueId()) || p.hasPermission(Permissions.EXTEND_OTHER)) {

View File

@ -1,5 +1,7 @@
package de.epiceric.shopchest.listeners;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.object.Plot;
import com.palmergames.bukkit.towny.object.TownBlock;
import com.palmergames.bukkit.towny.object.TownBlockType;
import com.palmergames.bukkit.towny.object.TownyUniverse;
@ -11,6 +13,8 @@ import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.config.Regex;
import de.epiceric.shopchest.event.*;
import de.epiceric.shopchest.external.PlotSquaredShopFlag;
import de.epiceric.shopchest.external.WorldGuardShopFlag;
import de.epiceric.shopchest.language.LanguageUtils;
import de.epiceric.shopchest.language.LocalizedMessage;
import de.epiceric.shopchest.nms.Hologram;
@ -21,7 +25,6 @@ import de.epiceric.shopchest.utils.ClickType;
import de.epiceric.shopchest.utils.Permissions;
import de.epiceric.shopchest.utils.ShopUtils;
import de.epiceric.shopchest.utils.Utils;
import de.epiceric.shopchest.worldguard.ShopFlag;
import fr.xephi.authme.AuthMe;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
@ -111,7 +114,7 @@ public class ShopInteractListener implements Listener {
for (Location loc : chestLocations) {
if (loc != null) {
externalPluginsAllowed &= query.testState(loc, p, ShopFlag.CREATE_SHOP);
externalPluginsAllowed &= query.testState(loc, p, WorldGuardShopFlag.CREATE_SHOP);
}
}
}
@ -125,6 +128,19 @@ public class ShopInteractListener implements Listener {
}
}
if (plugin.hasPlotSquared() && config.enable_plotsquared_integration) {
for (Location loc : chestLocations) {
if (loc != null) {
com.intellectualcrafters.plot.object.Location plotLocation = new com.intellectualcrafters.plot.object.Location(
loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
Plot plot = plotLocation.getOwnedPlot();
externalPluginsAllowed &= Utils.isFlagAllowedOnPlot(plot, PlotSquaredShopFlag.CREATE_SHOP, p);
}
}
}
if ((e.isCancelled() || !externalPluginsAllowed) && !p.hasPermission(Permissions.CREATE_PROTECTED)) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_CREATE_PROTECTED));
ClickType.removePlayerClickType(p);
@ -259,29 +275,34 @@ public class ShopInteractListener implements Listener {
if (shop.getBuyPrice() > 0) {
if (p.hasPermission(Permissions.BUY)) {
boolean worldGuardAllowed = true;
boolean externalPluginsAllowed = true;
if (plugin.hasPlotSquared() && config.enable_plotsquared_integration) {
com.intellectualcrafters.plot.object.Location plotLocation =
new com.intellectualcrafters.plot.object.Location(b.getWorld().getName(), b.getX(), b.getY(), b.getZ());
Plot plot = plotLocation.getOwnedPlot();
Flag flag = (shop.getShopType() == Shop.ShopType.ADMIN ? PlotSquaredShopFlag.USE_ADMIN_SHOP : PlotSquaredShopFlag.USE_SHOP);
externalPluginsAllowed &= Utils.isFlagAllowedOnPlot(plot, flag, p);
}
if (plugin.hasWorldGuard() && config.enable_worldguard_integration) {
StateFlag flag = (shop.getShopType() == ShopType.ADMIN ? WorldGuardShopFlag.USE_ADMIN_SHOP : WorldGuardShopFlag.USE_SHOP);
RegionContainer container = worldGuard.getRegionContainer();
RegionQuery query = container.createQuery();
externalPluginsAllowed &= query.testState(b.getLocation(), p, flag);
}
if (shop.getShopType() == ShopType.ADMIN) {
if (plugin.hasWorldGuard() && config.enable_worldguard_integration) {
RegionContainer container = worldGuard.getRegionContainer();
RegionQuery query = container.createQuery();
worldGuardAllowed = query.testState(b.getLocation(), p, ShopFlag.USE_ADMIN_SHOP);
}
if (worldGuardAllowed || p.hasPermission(Permissions.WORLDGUARD_BYPASS)) {
if (externalPluginsAllowed || p.hasPermission(Permissions.BYPASS_EXTERNAL_PLUGIN)) {
buy(p, shop, p.isSneaking());
} else {
plugin.debug(p.getName() + " doesn't have worldguard permission");
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_WG_BUY));
plugin.debug(p.getName() + " doesn't have external plugin's permission");
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_BUY_HERE));
}
} else {
if (plugin.hasWorldGuard() && config.enable_worldguard_integration) {
RegionContainer container = worldGuard.getRegionContainer();
RegionQuery query = container.createQuery();
worldGuardAllowed = query.testState(b.getLocation(), p, ShopFlag.USE_SHOP);
}
if (worldGuardAllowed || p.hasPermission(Permissions.WORLDGUARD_BYPASS)) {
if (externalPluginsAllowed || p.hasPermission(Permissions.BYPASS_EXTERNAL_PLUGIN)) {
Chest c = (Chest) b.getState();
if (Utils.getAmount(c.getInventory(), shop.getProduct()) >= shop.getProduct().getAmount()) {
buy(p, shop, p.isSneaking());
@ -299,8 +320,8 @@ public class ShopInteractListener implements Listener {
}
}
} else {
plugin.debug(p.getName() + " doesn't have worldguard permission");
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_WG_BUY));
plugin.debug(p.getName() + " doesn't have external plugin's permission");
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_BUY_HERE));
}
}
} else {
@ -321,17 +342,27 @@ public class ShopInteractListener implements Listener {
if (shop.getSellPrice() > 0) {
if (p.hasPermission(Permissions.SELL)) {
boolean worldGuardAllowed = true;
boolean externalPluginsAllowed = true;
if (plugin.hasPlotSquared() && config.enable_plotsquared_integration) {
com.intellectualcrafters.plot.object.Location plotLocation =
new com.intellectualcrafters.plot.object.Location(b.getWorld().getName(), b.getX(), b.getY(), b.getZ());
Plot plot = plotLocation.getOwnedPlot();
Flag flag = (shop.getShopType() == Shop.ShopType.ADMIN ? PlotSquaredShopFlag.USE_ADMIN_SHOP : PlotSquaredShopFlag.USE_SHOP);
externalPluginsAllowed &= Utils.isFlagAllowedOnPlot(plot, flag, p);
}
if (plugin.hasWorldGuard() && config.enable_worldguard_integration) {
RegionContainer container = worldGuard.getRegionContainer();
RegionQuery query = container.createQuery();
StateFlag flag = (shop.getShopType() == ShopType.ADMIN ? ShopFlag.USE_ADMIN_SHOP : ShopFlag.USE_SHOP);
worldGuardAllowed = query.testState(b.getLocation(), p, flag);
StateFlag flag = (shop.getShopType() == ShopType.ADMIN ? WorldGuardShopFlag.USE_ADMIN_SHOP : WorldGuardShopFlag.USE_SHOP);
externalPluginsAllowed &= query.testState(b.getLocation(), p, flag);
}
if (worldGuardAllowed || p.hasPermission(Permissions.WORLDGUARD_BYPASS)) {
if (externalPluginsAllowed || p.hasPermission(Permissions.BYPASS_EXTERNAL_PLUGIN)) {
if (Utils.getAmount(p.getInventory(), shop.getProduct()) >= shop.getProduct().getAmount()) {
sell(p, shop, p.isSneaking() && !Utils.hasAxeInHand(p));
} else {
@ -343,8 +374,8 @@ public class ShopInteractListener implements Listener {
}
}
} else {
plugin.debug(p.getName() + " doesn't have worldguard permission");
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_WG_SELL));
plugin.debug(p.getName() + " doesn't have external plugin's permission");
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_SELL_HERE));
}
} else {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_SELL));

View File

@ -13,7 +13,7 @@ import de.epiceric.shopchest.nms.Hologram;
import de.epiceric.shopchest.shop.Shop;
import de.epiceric.shopchest.utils.ClickType;
import de.epiceric.shopchest.utils.Permissions;
import de.epiceric.shopchest.worldguard.ShopFlag;
import de.epiceric.shopchest.external.WorldGuardShopFlag;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Chest;
@ -60,14 +60,14 @@ public class WorldGuardListener implements Listener {
if (ClickType.getPlayerClickType(player) != null) {
switch (ClickType.getPlayerClickType(player).getClickType()) {
case CREATE:
return query.testState(location, localPlayer, ShopFlag.CREATE_SHOP);
return query.testState(location, localPlayer, WorldGuardShopFlag.CREATE_SHOP);
case REMOVE:
case INFO:
return true;
}
} else {
if (shop != null) {
StateFlag flag = (shop.getShopType() == Shop.ShopType.NORMAL ? ShopFlag.USE_SHOP : ShopFlag.USE_ADMIN_SHOP);
StateFlag flag = (shop.getShopType() == Shop.ShopType.NORMAL ? WorldGuardShopFlag.USE_SHOP : WorldGuardShopFlag.USE_ADMIN_SHOP);
return query.testState(location, localPlayer, flag);
}

View File

@ -17,6 +17,6 @@ public class Permissions {
public static final String CONFIG = "shopchest.config";
public static final String EXTEND_OTHER = "shopchest.extend.other";
public static final String EXTEND_PROTECTED = "shopchest.extend.protected";
public static final String WORLDGUARD_BYPASS = "shopchest.worldguard.bypass";
public static final String BYPASS_EXTERNAL_PLUGIN = "shopchest.external.bypass";
}

View File

@ -1,7 +1,11 @@
package de.epiceric.shopchest.utils;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.object.Plot;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.external.PlotSquaredShopFlag;
import de.epiceric.shopchest.nms.CustomBookMeta;
import de.epiceric.shopchest.shop.Shop;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.configuration.InvalidConfigurationException;
@ -234,6 +238,38 @@ public class Utils {
return item != null && axes.contains(item.getType());
}
/**
* Check if a flag is allowed for a player on a plot from PlotSquared
* @param plot Plot from PlotSquared
* @param flag Flag to check
* @param p Player to check
* @return Whether the flag is allowed for the player
*/
public static boolean isFlagAllowedOnPlot(Plot plot, Flag flag, Player p) {
if (flag != null) {
Object o = plot.getFlag(flag, PlotSquaredShopFlag.Group.NONE);
if (o instanceof PlotSquaredShopFlag.Group) {
PlotSquaredShopFlag.Group group = (PlotSquaredShopFlag.Group) o;
switch (group) {
case OWNERS:
return plot.getOwners().contains(p.getUniqueId());
case TRUSTED:
return plot.getOwners().contains(p.getUniqueId()) || plot.getTrusted().contains(p.getUniqueId());
case MEMBERS:
return plot.getOwners().contains(p.getUniqueId()) || plot.getTrusted().contains(p.getUniqueId()) || plot.getMembers().contains(p.getUniqueId());
case EVERYONE:
return true;
case NONE:
return false;
}
}
}
return false;
}
/**
* @param className Name of the class
* @return Class in {@code net.minecraft.server.[VERSION]} package with the specified name or {@code null} if the class was not found

View File

@ -45,6 +45,10 @@ enable-towny-integration: true
# Of course, this only works if AuthMe is installed
enable-authme-integration: true
# Set whether PlotSquared integration should be enabled
# Of course, this only works if AuthMe is installed
enable-plotsquared-integration: true
# Set whether the vendor of a shop should get messages when players
# buy or sell something from/to his shop or if his shop is out of stock
enable-vendor-messages: true

View File

@ -69,8 +69,8 @@ message.noPermission.create-protected=&cDu hast keine Berechtigung hier einen Sh
message.noPermission.open-others=&cDu hast keine Berechtigung diesen Shop zu öffnen.
message.noPermission.buy=&cDu hast keine Berechtigung etwas zu kaufen.
message.noPermission.sell=&cDu hast keine Berechtigung etwas zu verkaufen.
message.noPermission.worldguard-buy=&cDu hast keine Berechtigung hier etwas zu kaufen.
message.noPermission.worldguard-sell=&cDu hast keine Berechtigung hier etwas zu verkaufen.
message.noPermission.buy-here=&cDu hast keine Berechtigung hier etwas zu kaufen.
message.noPermission.sell-here=&cDu hast keine Berechtigung hier etwas zu verkaufen.
message.noPermission.remove-others=&cDu hast keine Berechtigung diesen Shop zu entfernen.
message.noPermission.remove-admin=&cDu hast keine Berechtigung einen Admin Shop zu entfernen.
message.noPermission.reload=&cDu hast keine Berechtigung die Shops neu zu laden.

View File

@ -245,11 +245,11 @@ message.noPermission.buy=&cYou don't have permission to buy something.
# Set the message when a not permitted player tries to sell something.
message.noPermission.sell=&cYou don't have permission to sell something.
# Set the message when a player tries to buy something in a WorldGuard region that denied shop use.
message.noPermission.worldguard-buy=&cYou don't have permission to buy something here.
# Set the message when a player tries to buy something in a region/plot that denied shop use.
message.noPermission.buy-here=&cYou don't have permission to buy something here.
# Set the message when a player tries to sell something in a WorldGuard region that denied shop use.
message.noPermission.worldguard-sell=&cYou don't have permission to sell something here.
# Set the message when a player tries to sell something in a region/plot region that denied shop use.
message.noPermission.sell-here=&cYou don't have permission to sell something here.
# Set the message when a not permitted player tries to remove another player's shop.
message.noPermission.remove-others=&cYou don't have permission to remove this shop.
@ -269,7 +269,7 @@ message.noPermission.config=&cYou don't have permission to change configuration
# Set the message when a not permitted player tries to extend another player's shop's chest.
message.noPermission.extend-others=&cYou don't have permission to extend this chest.
# Set the message when a not permitted player tries to extend a chest into a protected region (e.g. WorldGuard/Towny).
# Set the message when a not permitted player tries to extend a chest into a protected region/plot (e.g. WorldGuard/Towny).
message.noPermission.extend-protected=&cYou don't have permission to extend this chest to here.
# Set the command description message for '/shop create' when you type '/shop'.

View File

@ -5,7 +5,7 @@ main: de.epiceric.shopchest.ShopChest
version: ${project.version}
author: EpicEric
website: ${project.url}
softdepend: [WorldGuard, Towny]
softdepend: [WorldGuard, Towny, PlotSquared]
depend: [Vault]
permissions:
@ -26,7 +26,7 @@ permissions:
shopchest.config: true
shopchest.extend.other: true
shopchest.extend.protected: true
shopchest.worldguard.bypass: true
shopchest.external.bypass: true
shopchest.create:
description: Allows you to create a shop.
default: true
@ -75,6 +75,6 @@ permissions:
shopchest.extend.protected:
description: Allows you to extend shops into a protected region.
default: op
shopchest.worlguard.bypass:
description: Allows you to to use shops in WorldGuard regions that deny shop use.
shopchest.external.bypass:
description: Allows you to to use shops regions/plots that deny shop use.
default: op