Skip to content

Commit

Permalink
prevents creating double chests with a lootchest around only if ches …
Browse files Browse the repository at this point in the history
…has a protection time
  • Loading branch information
Guarmanda committed Jul 3, 2024
1 parent dba87f9 commit b07aae5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ public void tick() {
}
else if (this.world.getBlockAt(LocationUtils.offset(((Entity) this.blocky).getLocation(), 0.0, -1.0, 0.0)).getType() == Material.AIR) {
++this.counter;
Main.getInstance().getParticles().get("SMOKE_NORMAL").display((float)0.1, (float)0.1, (float)0.1, (float)0.1, 1, goodLocation(), (float)50.0);
if(Main.getVersion() >= 206)
Main.getInstance().getParticles().get("SMOKE").display((float)0.1, (float)0.1, (float)0.1, (float)0.1, 1, goodLocation(), (float)50.0);
else
Main.getInstance().getParticles().get("SMOKE_NORMAL").display((float)0.1, (float)0.1, (float)0.1, (float)0.1, 1, goodLocation(), (float)50.0);

if (((Entity) this.blocky).isDead()) {
final Location oldLoc = ((Entity) this.blocky).getLocation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class DeleteListener implements Listener {


private static HashMap<Player, Location> openInvs = new HashMap<>();
//g§re la destruction d'un coffre au niveau des hologrames
//gre la destruction d'un coffre au niveau des hologrames



Expand Down Expand Up @@ -127,7 +127,7 @@ public void oncloseInventory(InventoryCloseEvent e) {
}
if(keys.getTake_msg()&&!keys.getTaken()){
keys.setTaken(true);
String msg = Main.getInstance().getConfigFiles().getLang().getString("playerTookChest").replace("[Player]", p.getName()).replace("[Chest]", keys.getHolo()).replace("&", "§");
String msg = Main.getInstance().getConfigFiles().getLang().getString("playerTookChest").replace("[Player]", p.getName()).replace("[Chest]", keys.getHolo()).replace("&", "");
if(Main.configs.NOTE_bungee_broadcast) {
BungeeChannel.bungeeBroadcast(msg);
}
Expand Down Expand Up @@ -190,7 +190,7 @@ public void onchestbreak(BlockBreakEvent e) {
Player p = e.getPlayer();
if(keys.getTake_msg() && !keys.getTaken()){
keys.setTaken(true);
String msg = Main.getInstance().getConfigFiles().getLang().getString("playerTookChest").replace("[Player]", p.getName()).replace("[Chest]", keys.getHolo()).replace("&", "§");
String msg = Main.getInstance().getConfigFiles().getLang().getString("playerTookChest").replace("[Player]", p.getName()).replace("[Chest]", keys.getHolo()).replace("&", "");
if(Main.configs.NOTE_bungee_broadcast) {
BungeeChannel.bungeeBroadcast(msg);
}
Expand Down Expand Up @@ -293,4 +293,27 @@ public void hopperPistonGrab(BlockPistonRetractEvent e) {
}
}

// if a chest is placed around a lootchest, the event has to be canceled
@EventHandler
public void onBlockPlace(BlockPlaceEvent e) {
Block block = e.getBlock();
if (Mat.isALootChestBlock(block)) {
for (int x = -1; x <= 1; x++) {
for (int y = -1; y <= 1; y++) {
for (int z = -1; z <= 1; z++) {
Block b = block.getRelative(x, y, z);
Lootchest lc = Utils.isLootChest(b.getLocation());
if (lc != null && !(x==0 && z==0)) {
if(lc.getProtectionTime() != 0) {
e.setCancelled(true);
return;
}
}
}
}
}
}
}


}
3 changes: 2 additions & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: LootChest
main: fr.black_eyes.lootchest.Main
version: 2.4.1
version: 2.4.2
author: Black_Eyes
api-version: 1.13
softdepend: [MultiWorld, Multiverse-Core, FabledSkyBlock, MultiverseCore, GriefPrevention, Residence, WorldGuard, Factions, FactionsX, Towny]
description: >
Expand Down

0 comments on commit b07aae5

Please sign in to comment.