From 87ac93e08c7fa3218f9a3313df2901dd5ab203a5 Mon Sep 17 00:00:00 2001 From: SergeyDertan Date: Wed, 15 May 2019 18:57:07 +0300 Subject: [PATCH] Frame item drop flag --- .../SRegionProtector/Event/RegionEventsHandler.java | 6 ++++++ .../SRegionProtector/Main/SRegionProtectorMain.java | 3 ++- .../SRegionProtector/Region/Flags/RegionFlags.java | 4 +++- .../SRegionProtector/Region/RegionManager.java | 6 ++++-- .../SRegionProtector/UI/Chest/Page/FlagsPage.java | 1 + .../SRegionProtector/UI/Form/Type/FlagsForm.java | 1 + src/main/resources/config.yml | 2 ++ src/main/resources/lang/eng.yml | 1 + src/main/resources/lang/rus.yml | 1 + src/main/resources/plugin.yml | 2 ++ src/main/resources/region-settings.yml | 2 ++ 11 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/main/java/Sergey_Dertan/SRegionProtector/Event/RegionEventsHandler.java b/src/main/java/Sergey_Dertan/SRegionProtector/Event/RegionEventsHandler.java index 46b4d54..8614f74 100644 --- a/src/main/java/Sergey_Dertan/SRegionProtector/Event/RegionEventsHandler.java +++ b/src/main/java/Sergey_Dertan/SRegionProtector/Event/RegionEventsHandler.java @@ -418,6 +418,12 @@ public void levelLoad(LevelLoadEvent e) { } } + //frame item drop flag + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void itemFrameDropItem(ItemFrameDropItemEvent e) { + this.handleEvent(RegionFlags.FLAG_FRAME_ITEM_DROP, e.getBlock(), e.getPlayer(), e); + } + //prevent nether portal from spawning in region @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void entityPortalEnter(EntityPortalEnterEvent e) { diff --git a/src/main/java/Sergey_Dertan/SRegionProtector/Main/SRegionProtectorMain.java b/src/main/java/Sergey_Dertan/SRegionProtector/Main/SRegionProtectorMain.java index 73762a4..1516ddd 100644 --- a/src/main/java/Sergey_Dertan/SRegionProtector/Main/SRegionProtectorMain.java +++ b/src/main/java/Sergey_Dertan/SRegionProtector/Main/SRegionProtectorMain.java @@ -373,7 +373,8 @@ private void shutdownExecutors() { } private void registerPlaceholders() { - if (this.getServer().getPluginManager().getPlugin("PlaceholderAPI") == null || this.getServer().getPluginManager().getPlugin("KotlinLib") == null) return; + if (this.getServer().getPluginManager().getPlugin("PlaceholderAPI") == null || this.getServer().getPluginManager().getPlugin("KotlinLib") == null) + return; try { Class.forName("Sergey_Dertan.SRegionProtector.Utils.PlaceholdersLoader"); } catch (Exception ignore) { diff --git a/src/main/java/Sergey_Dertan/SRegionProtector/Region/Flags/RegionFlags.java b/src/main/java/Sergey_Dertan/SRegionProtector/Region/Flags/RegionFlags.java index 1ef871b..a2aebad 100644 --- a/src/main/java/Sergey_Dertan/SRegionProtector/Region/Flags/RegionFlags.java +++ b/src/main/java/Sergey_Dertan/SRegionProtector/Region/Flags/RegionFlags.java @@ -59,8 +59,9 @@ public abstract class RegionFlags { public static final int FLAG_MINEFARM = 32; public static final int FLAG_FALL_DAMAGE = 33; public static final int FLAG_NETHER_PORTAL = 34; + public static final int FLAG_FRAME_ITEM_DROP = 35; - public static final int FLAG_AMOUNT = 35; + public static final int FLAG_AMOUNT = 36; public static final RegionFlag[] defaults = new RegionFlag[FLAG_AMOUNT]; public static final Permission[] permissions = new Permission[FLAG_AMOUNT]; @@ -106,6 +107,7 @@ public abstract class RegionFlags { flagList.put(FLAG_MINEFARM, "minefarm"); flagList.put(FLAG_FALL_DAMAGE, "fall-damage"); flagList.put(FLAG_NETHER_PORTAL, "nether-portal"); + flagList.put(FLAG_FRAME_ITEM_DROP, "frame-item-drop"); flags = ImmutableBiMap.copyOf(flagList); Map aAliases = new HashMap<>(FLAG_AMOUNT); diff --git a/src/main/java/Sergey_Dertan/SRegionProtector/Region/RegionManager.java b/src/main/java/Sergey_Dertan/SRegionProtector/Region/RegionManager.java index e4cb63b..c69a827 100644 --- a/src/main/java/Sergey_Dertan/SRegionProtector/Region/RegionManager.java +++ b/src/main/java/Sergey_Dertan/SRegionProtector/Region/RegionManager.java @@ -87,9 +87,11 @@ public void init(boolean saveNewFlags) { this.regions.put(region.name, region); - for (String user : region.getOwners()) this.owners.computeIfAbsent(user, (usr) -> new ObjectArraySet<>()).add(region); + for (String user : region.getOwners()) + this.owners.computeIfAbsent(user, (usr) -> new ObjectArraySet<>()).add(region); - for (String user : region.getMembers()) this.members.computeIfAbsent(user, (usr) -> new ObjectArraySet<>()).add(region); + for (String user : region.getMembers()) + this.members.computeIfAbsent(user, (usr) -> new ObjectArraySet<>()).add(region); this.owners.computeIfAbsent(region.getCreator(), (usr) -> new ObjectArraySet<>()).add(region); diff --git a/src/main/java/Sergey_Dertan/SRegionProtector/UI/Chest/Page/FlagsPage.java b/src/main/java/Sergey_Dertan/SRegionProtector/UI/Chest/Page/FlagsPage.java index 08a4806..5225709 100644 --- a/src/main/java/Sergey_Dertan/SRegionProtector/UI/Chest/Page/FlagsPage.java +++ b/src/main/java/Sergey_Dertan/SRegionProtector/UI/Chest/Page/FlagsPage.java @@ -52,6 +52,7 @@ public final class FlagsPage implements Page { this.flagToBlock[RegionFlags.FLAG_HEAL] = ItemID.GOLDEN_APPLE; this.flagToBlock[RegionFlags.FLAG_NETHER_PORTAL] = BlockID.NETHER_PORTAL; this.flagToBlock[RegionFlags.FLAG_SELL] = ItemID.EMERALD; + this.flagToBlock[RegionFlags.FLAG_FRAME_ITEM_DROP] = ItemID.ITEM_FRAME; } @Override diff --git a/src/main/java/Sergey_Dertan/SRegionProtector/UI/Form/Type/FlagsForm.java b/src/main/java/Sergey_Dertan/SRegionProtector/UI/Form/Type/FlagsForm.java index 1ae9091..8655fcd 100644 --- a/src/main/java/Sergey_Dertan/SRegionProtector/UI/Form/Type/FlagsForm.java +++ b/src/main/java/Sergey_Dertan/SRegionProtector/UI/Form/Type/FlagsForm.java @@ -42,6 +42,7 @@ final class FlagsForm extends FormWindowSimple implements UIForm { ICONS[RegionFlags.FLAG_SELL] = "textures/items/emerald.png"; ICONS[RegionFlags.FLAG_SEND_CHAT] = "textures/ui/betaIcon.png"; ICONS[RegionFlags.FLAG_RECEIVE_CHAT] = "textures/ui/betaIcon.png"; + ICONS[RegionFlags.FLAG_FRAME_ITEM_DROP] = "textures/items/item_frame.png"; } private final transient Region region; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index f4cee84..5828beb 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -58,6 +58,7 @@ active-flags: minefarm: true fall-damage: true nether-portal: true + frame-item-drop: true display: place: true break: true @@ -92,6 +93,7 @@ display: minefarm: true fall-damage: true nether-portal: true + frame-item-drop: true # players need no permission to create regions with this size & amount # to let player create more regions with greater size give him permissions # "sregionprotector.region.size.DESIRED_MAX_SIZE", and diff --git a/src/main/resources/lang/eng.yml b/src/main/resources/lang/eng.yml index 94d8591..78b06e2 100644 --- a/src/main/resources/lang/eng.yml +++ b/src/main/resources/lang/eng.yml @@ -55,6 +55,7 @@ region.protected.sleep: "You can`t use bed in this region" region.protected.fire: "You can`t ignite blocks in this region" region.protected.fall-damage: "You can`t take fall damage in this region" region.protected.nether-portal: "Nether portal can`t be created in region" +region.protected.frame-item-drop: "You cant break frames in this region" region.selection.pos1: "First pos set" region.selection.pos2: "Second pos set" diff --git a/src/main/resources/lang/rus.yml b/src/main/resources/lang/rus.yml index 8b81940..05b5ea6 100644 --- a/src/main/resources/lang/rus.yml +++ b/src/main/resources/lang/rus.yml @@ -55,6 +55,7 @@ region.protected.sleep: "Вы не можете использовать кро region.protected.fire: "Вы не можете поджигать в этом регионе" region.protected.fall-damage: "Вы не можете получать урон от падения в этом регионе" region.protected.nether-portal: "Портал не может быть создан в этом регионе" +region.protected.frame-item-drop: "Вы не можете делать это в этом регионе" region.selection.pos1: "Первая точка установлена" region.selection.pos2: "Вторая точка установлена" diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 26d03fa..9cf8fcb 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -168,3 +168,5 @@ permissions: default: op sregionprotector.region.flag.nether_portal: default: op + sregionprotector.region.flag.frame_item_drop: + default: op diff --git a/src/main/resources/region-settings.yml b/src/main/resources/region-settings.yml index 803d7ae..d993daa 100644 --- a/src/main/resources/region-settings.yml +++ b/src/main/resources/region-settings.yml @@ -33,6 +33,7 @@ default-flags: minefarm: false fall-damage: false nether-portal: true + frame-item-drop: true need-message: move: false place: true @@ -57,6 +58,7 @@ need-message: minefarm: false fall-damage: false nether-portal: true + frame-item-drop: true max-region-name-length: 10 min-region-name-length: 3 # 1 second = 20 ticks