mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-07 03:00:29 +01:00
Fix Sponges increasing level
This commit is contained in:
parent
495e433c43
commit
7ee069fee5
@ -336,6 +336,28 @@ public class Block implements Listener {
|
||||
&& event.getPlayer().getItemInHand().getType() == CompatibleMaterial.ENDER_EYE.getMaterial()) return;
|
||||
|
||||
islandLevelManager.updateLevel(island, blockLoc);
|
||||
|
||||
// Sponge level dupe fix
|
||||
if(ServerVersion.isServerVersionBelow(ServerVersion.V1_13) &&
|
||||
block.getType().equals(CompatibleMaterial.SPONGE.getBlockMaterial())) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
if(blockLoc.getBlock().getType().equals(CompatibleMaterial.WET_SPONGE.getBlockMaterial())) {
|
||||
IslandLevel level = island.getLevel();
|
||||
CompatibleMaterial material = CompatibleMaterial.SPONGE;
|
||||
if (level.hasMaterial(material.name())) {
|
||||
long materialAmount = level.getMaterialAmount(material.name());
|
||||
|
||||
if (materialAmount - 1 <= 0) {
|
||||
level.removeMaterial(material.name());
|
||||
} else {
|
||||
level.setMaterialAmount(material.name(), materialAmount - 1);
|
||||
}
|
||||
|
||||
islandLevelManager.updateLevel(island, blockLoc);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -792,7 +814,48 @@ public class Block implements Listener {
|
||||
return false;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onSponge(SpongeAbsorbEvent event) {
|
||||
IslandLevelManager islandLevelManager = plugin.getLevellingManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
StackableManager stackableManager = plugin.getStackableManager();
|
||||
WorldManager worldManager = plugin.getWorldManager();
|
||||
|
||||
org.bukkit.block.Block block = event.getBlock();
|
||||
|
||||
if (worldManager.isIslandWorld(block.getWorld())) {
|
||||
Location blockLocation = block.getLocation();
|
||||
|
||||
Island island = islandManager.getIslandAtLocation(blockLocation);
|
||||
if (island != null) {
|
||||
if (plugin.getPermissionManager().processPermission(event, island) && !event.isCancelled()) {
|
||||
if (stackableManager == null || !stackableManager.isStacked(blockLocation)) {
|
||||
IslandLevel level = island.getLevel();
|
||||
|
||||
CompatibleMaterial material = CompatibleMaterial.SPONGE;
|
||||
if (level.hasMaterial(material.name())) {
|
||||
long materialAmount = level.getMaterialAmount(material.name());
|
||||
|
||||
if (materialAmount - 1 <= 0) {
|
||||
level.removeMaterial(material.name());
|
||||
} else {
|
||||
level.setMaterialAmount(material.name(), materialAmount - 1);
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, () -> islandLevelManager.updateLevel(island, blockLocation));
|
||||
}
|
||||
} else {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onBlockBurn(BlockBurnEvent event) {
|
||||
org.bukkit.block.Block block = event.getBlock();
|
||||
WorldManager worldManager = plugin.getWorldManager();
|
||||
|
Loading…
Reference in New Issue
Block a user