Skip to content

Commit

Permalink
Frame item drop flag
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyDertan committed May 15, 2019
1 parent 8796e78 commit 87ac93e
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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<String, Integer> aAliases = new HashMap<>(FLAG_AMOUNT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ active-flags:
minefarm: true
fall-damage: true
nether-portal: true
frame-item-drop: true
display:
place: true
break: true
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/lang/eng.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/lang/rus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: "Вторая точка установлена"
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,5 @@ permissions:
default: op
sregionprotector.region.flag.nether_portal:
default: op
sregionprotector.region.flag.frame_item_drop:
default: op
2 changes: 2 additions & 0 deletions src/main/resources/region-settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ default-flags:
minefarm: false
fall-damage: false
nether-portal: true
frame-item-drop: true
need-message:
move: false
place: true
Expand All @@ -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
Expand Down

0 comments on commit 87ac93e

Please sign in to comment.