mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-10 04:31:06 +00:00
Only permitted players can remove admin shops
+ Changed permission "shopchest.removeOther" to "shopchest.remove.other" Closes #36
This commit is contained in:
parent
f233c626e1
commit
2951ef8349
@ -653,6 +653,7 @@ public class LanguageUtils {
|
||||
itemNames.add(new ItemName(Material.SHULKER_SHELL, langConfig.getString("item.shulkerShell.name", "Shulker Shell")));
|
||||
|
||||
if (Utils.getRevision() >= 2 || Utils.getMajorVersion() > 11) {
|
||||
// Add Item Name of 1.11.2
|
||||
itemNames.add(new ItemName(Material.IRON_NUGGET, langConfig.getString("item.ironNugget.name", "Iron Nugget")));
|
||||
}
|
||||
}
|
||||
@ -696,6 +697,7 @@ public class LanguageUtils {
|
||||
enchantmentNames.add(new EnchantmentName(Enchantment.VANISHING_CURSE, langConfig.getString("enchantment.vanishing_curse", "Curse of Vanishing")));
|
||||
|
||||
if (Utils.getRevision() >= 2 || Utils.getMajorVersion() > 11) {
|
||||
// Add Enchantment Name of 1.11.2
|
||||
enchantmentNames.add(new EnchantmentName(Enchantment.SWEEPING_EDGE, langConfig.getString("enchantment.sweeping", "Sweeping Edge")));
|
||||
}
|
||||
}
|
||||
@ -974,6 +976,7 @@ public class LanguageUtils {
|
||||
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_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.")));
|
||||
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_UPDATE, langConfig.getString("message.noPermission.update", "&cYou don't have permission to check for updates.")));
|
||||
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_CONFIG, langConfig.getString("message.noPermission.config", "&cYou don't have permission to change configuration values.")));
|
||||
|
@ -111,6 +111,7 @@ public class LocalizedMessage {
|
||||
NO_PERMISSION_WG_BUY,
|
||||
NO_PERMISSION_WG_SELL,
|
||||
NO_PERMISSION_REMOVE_OTHERS,
|
||||
NO_PERMISSION_REMOVE_ADMIN,
|
||||
NO_PERMISSION_RELOAD,
|
||||
NO_PERMISSION_UPDATE,
|
||||
NO_PERMISSION_CONFIG,
|
||||
|
@ -44,6 +44,34 @@ public class ChestProtectListener implements Listener {
|
||||
this.worldGuard = worldGuard;
|
||||
}
|
||||
|
||||
private void remove(final Shop shop, final Block b, Player p) {
|
||||
shopUtils.removeShop(shop, true);
|
||||
|
||||
if (shop.getInventoryHolder() instanceof DoubleChest) {
|
||||
DoubleChest dc = (DoubleChest) shop.getInventoryHolder();
|
||||
final Chest l = (Chest) dc.getLeftSide();
|
||||
final Chest r = (Chest) dc.getRightSide();
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Shop newShop = null;
|
||||
|
||||
if (b.getLocation().equals(l.getLocation()))
|
||||
newShop = new Shop(shop.getID(), plugin, shop.getVendor(), shop.getProduct(), r.getLocation(), shop.getBuyPrice(), shop.getSellPrice(), shop.getShopType());
|
||||
else if (b.getLocation().equals(r.getLocation()))
|
||||
newShop = new Shop(shop.getID(), plugin, shop.getVendor(), shop.getProduct(), l.getLocation(), shop.getBuyPrice(), shop.getSellPrice(), shop.getShopType());
|
||||
|
||||
shopUtils.addShop(newShop, true);
|
||||
}
|
||||
}, 1L);
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.debug(String.format("%s broke %s's shop (#%d)", p.getName(), shop.getVendor().getName(), shop.getID()));
|
||||
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_REMOVED));
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent e) {
|
||||
final Block b = e.getBlock();
|
||||
@ -55,33 +83,16 @@ public class ChestProtectListener implements Listener {
|
||||
if (p.isSneaking()) {
|
||||
plugin.debug(String.format("%s tries to break %s's shop (#%d)", p.getName(), shop.getVendor().getName(), shop.getID()));
|
||||
|
||||
if (shop.getVendor().getUniqueId().equals(p.getUniqueId()) || p.hasPermission(Permissions.REMOVE_OTHER)) {
|
||||
shopUtils.removeShop(shop, true);
|
||||
|
||||
if (shop.getInventoryHolder() instanceof DoubleChest) {
|
||||
DoubleChest dc = (DoubleChest) shop.getInventoryHolder();
|
||||
final Chest l = (Chest) dc.getLeftSide();
|
||||
final Chest r = (Chest) dc.getRightSide();
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Shop newShop = null;
|
||||
|
||||
if (b.getLocation().equals(l.getLocation()))
|
||||
newShop = new Shop(shop.getID(), plugin, shop.getVendor(), shop.getProduct(), r.getLocation(), shop.getBuyPrice(), shop.getSellPrice(), shop.getShopType());
|
||||
else if (b.getLocation().equals(r.getLocation()))
|
||||
newShop = new Shop(shop.getID(), plugin, shop.getVendor(), shop.getProduct(), l.getLocation(), shop.getBuyPrice(), shop.getSellPrice(), shop.getShopType());
|
||||
|
||||
shopUtils.addShop(newShop, true);
|
||||
}
|
||||
}, 1L);
|
||||
if (shop.getShopType() == Shop.ShopType.ADMIN) {
|
||||
if (p.hasPermission(Permissions.REMOVE_ADMIN)) {
|
||||
remove(shop, b, p);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (shop.getVendor().getUniqueId().equals(p.getUniqueId()) || p.hasPermission(Permissions.REMOVE_OTHER)) {
|
||||
remove(shop, b, p);
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.debug(String.format("%s broke %s's shop (#%d)", p.getName(), shop.getVendor().getName(), shop.getID()));
|
||||
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_REMOVED));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,13 +181,21 @@ public class ShopInteractListener implements Listener {
|
||||
if (shopUtils.isShop(b.getLocation())) {
|
||||
Shop shop = shopUtils.getShop(b.getLocation());
|
||||
|
||||
if (shop.getVendor().getUniqueId().equals(p.getUniqueId()) || p.hasPermission(Permissions.REMOVE_OTHER)) {
|
||||
remove(p, shop);
|
||||
if (shop.getShopType() == ShopType.ADMIN) {
|
||||
if (p.hasPermission(Permissions.REMOVE_ADMIN)) {
|
||||
remove(p, shop);
|
||||
} else {
|
||||
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_REMOVE_ADMIN));
|
||||
plugin.debug(p.getName() + " is not permitted to remove an admin shop");
|
||||
}
|
||||
} else {
|
||||
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_REMOVE_OTHERS));
|
||||
plugin.debug(p.getName() + " is not permitted to remove another player's shop");
|
||||
if (shop.getVendor().getUniqueId().equals(p.getUniqueId()) || p.hasPermission(Permissions.REMOVE_OTHER)) {
|
||||
remove(p, shop);
|
||||
} else {
|
||||
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_REMOVE_OTHERS));
|
||||
plugin.debug(p.getName() + " is not permitted to remove another player's shop");
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CHEST_NO_SHOP));
|
||||
plugin.debug("Chest is not a shop");
|
||||
|
@ -5,7 +5,8 @@ public class Permissions {
|
||||
public static final String CREATE = "shopchest.create";
|
||||
public static final String CREATE_ADMIN = "shopchest.create.admin";
|
||||
public static final String CREATE_PROTECTED = "shopchest.create.protected";
|
||||
public static final String REMOVE_OTHER = "shopchest.removeOther";
|
||||
public static final String REMOVE_OTHER = "shopchest.remove.other";
|
||||
public static final String REMOVE_ADMIN = "shopchest.remove.admin";
|
||||
public static final String BUY = "shopchest.buy";
|
||||
public static final String SELL = "shopchest.sell";
|
||||
public static final String OPEN_OTHER = "shopchest.openOther";
|
||||
|
@ -67,6 +67,7 @@ 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.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.
|
||||
message.noPermission.update=&cDu hast keine Berechtigung nach Aktualisierungen zu suchen.
|
||||
message.noPermission.config=&cDu hast keine Berechtigung Konfigurationswerte zu verändern.
|
||||
|
@ -235,6 +235,9 @@ message.noPermission.worldguard-sell=&cYou don't have permission to sell somethi
|
||||
# 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.
|
||||
|
||||
# Set the message when a not permitted player tries to remove an admin shop.
|
||||
message.noPermission.remove-others=&cYou don't have permission to remove an admin shop.
|
||||
|
||||
# Set the message when a not permitted player tries to reload the shops.
|
||||
message.noPermission.reload=&cYou don't have permission to reload the shops.
|
||||
|
||||
|
@ -15,7 +15,8 @@ permissions:
|
||||
shopchest.create: true
|
||||
shopchest.create.admin: true
|
||||
shopchest.create.protected: true
|
||||
shopchest.removeOther: true
|
||||
shopchest.remove.other: true
|
||||
shopchest.remove.admin: true
|
||||
shopchest.buy: true
|
||||
shopchest.openOther: true
|
||||
shopchest.notification.update: true
|
||||
@ -39,9 +40,12 @@ permissions:
|
||||
children:
|
||||
shopchest.create: true
|
||||
default: op
|
||||
shopchest.removeOther:
|
||||
shopchest.remove.other:
|
||||
description: Allows you to remove other players' shops.
|
||||
default: op
|
||||
shopchest.remove.admin:
|
||||
description: Allows you to remove admin shops.
|
||||
default: op
|
||||
shopchest.buy:
|
||||
description: Allows you to buy something.
|
||||
default: true
|
||||
|
Loading…
Reference in New Issue
Block a user