Skip to content

Commit 87ac93e

Browse files
committed
Frame item drop flag
1 parent 8796e78 commit 87ac93e

File tree

11 files changed

+25
-4
lines changed

11 files changed

+25
-4
lines changed

src/main/java/Sergey_Dertan/SRegionProtector/Event/RegionEventsHandler.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,12 @@ public void levelLoad(LevelLoadEvent e) {
418418
}
419419
}
420420

421+
//frame item drop flag
422+
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
423+
public void itemFrameDropItem(ItemFrameDropItemEvent e) {
424+
this.handleEvent(RegionFlags.FLAG_FRAME_ITEM_DROP, e.getBlock(), e.getPlayer(), e);
425+
}
426+
421427
//prevent nether portal from spawning in region
422428
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
423429
public void entityPortalEnter(EntityPortalEnterEvent e) {

src/main/java/Sergey_Dertan/SRegionProtector/Main/SRegionProtectorMain.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,8 @@ private void shutdownExecutors() {
373373
}
374374

375375
private void registerPlaceholders() {
376-
if (this.getServer().getPluginManager().getPlugin("PlaceholderAPI") == null || this.getServer().getPluginManager().getPlugin("KotlinLib") == null) return;
376+
if (this.getServer().getPluginManager().getPlugin("PlaceholderAPI") == null || this.getServer().getPluginManager().getPlugin("KotlinLib") == null)
377+
return;
377378
try {
378379
Class.forName("Sergey_Dertan.SRegionProtector.Utils.PlaceholdersLoader");
379380
} catch (Exception ignore) {

src/main/java/Sergey_Dertan/SRegionProtector/Region/Flags/RegionFlags.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ public abstract class RegionFlags {
5959
public static final int FLAG_MINEFARM = 32;
6060
public static final int FLAG_FALL_DAMAGE = 33;
6161
public static final int FLAG_NETHER_PORTAL = 34;
62+
public static final int FLAG_FRAME_ITEM_DROP = 35;
6263

63-
public static final int FLAG_AMOUNT = 35;
64+
public static final int FLAG_AMOUNT = 36;
6465

6566
public static final RegionFlag[] defaults = new RegionFlag[FLAG_AMOUNT];
6667
public static final Permission[] permissions = new Permission[FLAG_AMOUNT];
@@ -106,6 +107,7 @@ public abstract class RegionFlags {
106107
flagList.put(FLAG_MINEFARM, "minefarm");
107108
flagList.put(FLAG_FALL_DAMAGE, "fall-damage");
108109
flagList.put(FLAG_NETHER_PORTAL, "nether-portal");
110+
flagList.put(FLAG_FRAME_ITEM_DROP, "frame-item-drop");
109111
flags = ImmutableBiMap.copyOf(flagList);
110112

111113
Map<String, Integer> aAliases = new HashMap<>(FLAG_AMOUNT);

src/main/java/Sergey_Dertan/SRegionProtector/Region/RegionManager.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ public void init(boolean saveNewFlags) {
8787

8888
this.regions.put(region.name, region);
8989

90-
for (String user : region.getOwners()) this.owners.computeIfAbsent(user, (usr) -> new ObjectArraySet<>()).add(region);
90+
for (String user : region.getOwners())
91+
this.owners.computeIfAbsent(user, (usr) -> new ObjectArraySet<>()).add(region);
9192

92-
for (String user : region.getMembers()) this.members.computeIfAbsent(user, (usr) -> new ObjectArraySet<>()).add(region);
93+
for (String user : region.getMembers())
94+
this.members.computeIfAbsent(user, (usr) -> new ObjectArraySet<>()).add(region);
9395

9496
this.owners.computeIfAbsent(region.getCreator(), (usr) -> new ObjectArraySet<>()).add(region);
9597

src/main/java/Sergey_Dertan/SRegionProtector/UI/Chest/Page/FlagsPage.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public final class FlagsPage implements Page {
5252
this.flagToBlock[RegionFlags.FLAG_HEAL] = ItemID.GOLDEN_APPLE;
5353
this.flagToBlock[RegionFlags.FLAG_NETHER_PORTAL] = BlockID.NETHER_PORTAL;
5454
this.flagToBlock[RegionFlags.FLAG_SELL] = ItemID.EMERALD;
55+
this.flagToBlock[RegionFlags.FLAG_FRAME_ITEM_DROP] = ItemID.ITEM_FRAME;
5556
}
5657

5758
@Override

src/main/java/Sergey_Dertan/SRegionProtector/UI/Form/Type/FlagsForm.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ final class FlagsForm extends FormWindowSimple implements UIForm {
4242
ICONS[RegionFlags.FLAG_SELL] = "textures/items/emerald.png";
4343
ICONS[RegionFlags.FLAG_SEND_CHAT] = "textures/ui/betaIcon.png";
4444
ICONS[RegionFlags.FLAG_RECEIVE_CHAT] = "textures/ui/betaIcon.png";
45+
ICONS[RegionFlags.FLAG_FRAME_ITEM_DROP] = "textures/items/item_frame.png";
4546
}
4647

4748
private final transient Region region;

src/main/resources/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ active-flags:
5858
minefarm: true
5959
fall-damage: true
6060
nether-portal: true
61+
frame-item-drop: true
6162
display:
6263
place: true
6364
break: true
@@ -92,6 +93,7 @@ display:
9293
minefarm: true
9394
fall-damage: true
9495
nether-portal: true
96+
frame-item-drop: true
9597
# players need no permission to create regions with this size & amount
9698
# to let player create more regions with greater size give him permissions
9799
# "sregionprotector.region.size.DESIRED_MAX_SIZE", and

src/main/resources/lang/eng.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ region.protected.sleep: "You can`t use bed in this region"
5555
region.protected.fire: "You can`t ignite blocks in this region"
5656
region.protected.fall-damage: "You can`t take fall damage in this region"
5757
region.protected.nether-portal: "Nether portal can`t be created in region"
58+
region.protected.frame-item-drop: "You cant break frames in this region"
5859

5960
region.selection.pos1: "First pos set"
6061
region.selection.pos2: "Second pos set"

src/main/resources/lang/rus.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ region.protected.sleep: "Вы не можете использовать кро
5555
region.protected.fire: "Вы не можете поджигать в этом регионе"
5656
region.protected.fall-damage: "Вы не можете получать урон от падения в этом регионе"
5757
region.protected.nether-portal: "Портал не может быть создан в этом регионе"
58+
region.protected.frame-item-drop: "Вы не можете делать это в этом регионе"
5859

5960
region.selection.pos1: "Первая точка установлена"
6061
region.selection.pos2: "Вторая точка установлена"

src/main/resources/plugin.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,5 @@ permissions:
168168
default: op
169169
sregionprotector.region.flag.nether_portal:
170170
default: op
171+
sregionprotector.region.flag.frame_item_drop:
172+
default: op

src/main/resources/region-settings.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ default-flags:
3333
minefarm: false
3434
fall-damage: false
3535
nether-portal: true
36+
frame-item-drop: true
3637
need-message:
3738
move: false
3839
place: true
@@ -57,6 +58,7 @@ need-message:
5758
minefarm: false
5859
fall-damage: false
5960
nether-portal: true
61+
frame-item-drop: true
6062
max-region-name-length: 10
6163
min-region-name-length: 3
6264
# 1 second = 20 ticks

0 commit comments

Comments
 (0)