mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-09-29 23:17:26 +02:00
Count ore generation towards island level.
This commit is contained in:
parent
252f34bf0e
commit
c90d13836a
@ -265,40 +265,7 @@ public class Block implements Listener {
|
|||||||
if (event.getBlock().getType() == CompatibleMaterial.END_PORTAL_FRAME.getMaterial()
|
if (event.getBlock().getType() == CompatibleMaterial.END_PORTAL_FRAME.getMaterial()
|
||||||
&& event.getPlayer().getItemInHand().getType() == CompatibleMaterial.ENDER_EYE.getMaterial()) return;
|
&& event.getPlayer().getItemInHand().getType() == CompatibleMaterial.ENDER_EYE.getMaterial()) return;
|
||||||
|
|
||||||
// Fix a bug in Paper 1.8.8 when using ViaVersion on a 1.12.2 client.
|
updateLevel(island, blockLoc);
|
||||||
// BUG: Player can infinitely increase their level by placing a block at their
|
|
||||||
// feet.
|
|
||||||
// It doesn't take the block away but still increments the level.
|
|
||||||
// This doesn't happen in Spigot, but does happen in PaperSpigot due to a
|
|
||||||
// BlockPlaceEvent being incorrectly fired.
|
|
||||||
// The solution is to wait a tick to make sure that the block was actually
|
|
||||||
// placed.
|
|
||||||
// This shouldn't cause any issues besides the task number being increased
|
|
||||||
// insanely fast.
|
|
||||||
Bukkit.getScheduler().runTask(skyblock, () -> {
|
|
||||||
CompatibleMaterial material = CompatibleMaterial.getMaterial(block.getType());
|
|
||||||
|
|
||||||
if (material == null || material == CompatibleMaterial.AIR) return;
|
|
||||||
|
|
||||||
if (material == CompatibleMaterial.SPAWNER) {
|
|
||||||
if (Bukkit.getPluginManager().isPluginEnabled("EpicSpawners") || Bukkit.getPluginManager().isPluginEnabled("WildStacker"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
CompatibleSpawners spawner = CompatibleSpawners.getSpawner(((CreatureSpawner) block.getState()).getSpawnedType());
|
|
||||||
|
|
||||||
if (spawner != null)
|
|
||||||
material = CompatibleMaterial.getBlockMaterial(spawner.getMaterial());
|
|
||||||
}
|
|
||||||
|
|
||||||
long materialAmount = 0;
|
|
||||||
IslandLevel level = island.getLevel();
|
|
||||||
|
|
||||||
if (level.hasMaterial(material.name())) {
|
|
||||||
materialAmount = level.getMaterialAmount(material.name());
|
|
||||||
}
|
|
||||||
|
|
||||||
level.setMaterialAmount(material.name(), materialAmount + 1);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -363,6 +330,7 @@ public class Block implements Listener {
|
|||||||
toBlockState.setData(genState.getData());
|
toBlockState.setData(genState.getData());
|
||||||
toBlockState.setType(genState.getType());
|
toBlockState.setType(genState.getType());
|
||||||
toBlockState.update();
|
toBlockState.update();
|
||||||
|
updateLevel(island, genState.getLocation());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -588,6 +556,7 @@ public class Block implements Listener {
|
|||||||
state.setType(genState.getType());
|
state.setType(genState.getType());
|
||||||
|
|
||||||
if (NMSUtil.getVersionNumber() < 13) state.setData(genState.getData());
|
if (NMSUtil.getVersionNumber() < 13) state.setData(genState.getData());
|
||||||
|
updateLevel(island, genState.getLocation());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -672,4 +641,41 @@ public class Block implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateLevel(Island island, Location location) {
|
||||||
|
// Fix a bug in Paper 1.8.8 when using ViaVersion on a 1.12.2 client.
|
||||||
|
// BUG: Player can infinitely increase their level by placing a block at their
|
||||||
|
// feet.
|
||||||
|
// It doesn't take the block away but still increments the level.
|
||||||
|
// This doesn't happen in Spigot, but does happen in PaperSpigot due to a
|
||||||
|
// BlockPlaceEvent being incorrectly fired.
|
||||||
|
// The solution is to wait a tick to make sure that the block was actually
|
||||||
|
// placed.
|
||||||
|
// This shouldn't cause any issues besides the task number being increased
|
||||||
|
// insanely fast.
|
||||||
|
Bukkit.getScheduler().runTask(skyblock, () -> {
|
||||||
|
org.bukkit.block.Block block = location.getBlock();
|
||||||
|
CompatibleMaterial material = CompatibleMaterial.getMaterial(block);
|
||||||
|
|
||||||
|
if (material == null || material == CompatibleMaterial.AIR) return;
|
||||||
|
|
||||||
|
if (material == CompatibleMaterial.SPAWNER) {
|
||||||
|
if (Bukkit.getPluginManager().isPluginEnabled("EpicSpawners") || Bukkit.getPluginManager().isPluginEnabled("WildStacker"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
CompatibleSpawners spawner = CompatibleSpawners.getSpawner(((CreatureSpawner) block.getState()).getSpawnedType());
|
||||||
|
|
||||||
|
if (spawner != null)
|
||||||
|
material = CompatibleMaterial.getBlockMaterial(spawner.getMaterial());
|
||||||
|
}
|
||||||
|
|
||||||
|
long materialAmount = 0;
|
||||||
|
IslandLevel level = island.getLevel();
|
||||||
|
|
||||||
|
if (level.hasMaterial(material.name()))
|
||||||
|
materialAmount = level.getMaterialAmount(material.name());
|
||||||
|
|
||||||
|
level.setMaterialAmount(material.name(), materialAmount + 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user