mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-27 20:56:05 +01:00
Fixed a NoSuchMethodError on versions pre 1.13
This commit is contained in:
parent
24c60dd35d
commit
ed9126d278
@ -36,14 +36,15 @@ public class Grow implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks that a structure like a tree is not growing outside or into another island.
|
* Checks that a structure like a tree is not growing outside or into another
|
||||||
|
* island.
|
||||||
|
*
|
||||||
* @author LimeGlass
|
* @author LimeGlass
|
||||||
*/
|
*/
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onStructureGrow(StructureGrowEvent event) {
|
public void onStructureGrow(StructureGrowEvent event) {
|
||||||
WorldManager worldManager = skyblock.getWorldManager();
|
WorldManager worldManager = skyblock.getWorldManager();
|
||||||
if (!worldManager.isIslandWorld(event.getWorld()))
|
if (!worldManager.isIslandWorld(event.getWorld())) return;
|
||||||
return;
|
|
||||||
|
|
||||||
IslandManager islandManager = skyblock.getIslandManager();
|
IslandManager islandManager = skyblock.getIslandManager();
|
||||||
Island origin = islandManager.getIslandAtLocation(event.getLocation());
|
Island origin = islandManager.getIslandAtLocation(event.getLocation());
|
||||||
@ -51,8 +52,7 @@ public class Grow implements Listener {
|
|||||||
BlockState state = it.next();
|
BlockState state = it.next();
|
||||||
Island growingTo = islandManager.getIslandAtLocation(state.getLocation());
|
Island growingTo = islandManager.getIslandAtLocation(state.getLocation());
|
||||||
// This block is ok to continue as it's not related to Skyblock islands.
|
// This block is ok to continue as it's not related to Skyblock islands.
|
||||||
if (origin == null && growingTo == null)
|
if (origin == null && growingTo == null) continue;
|
||||||
continue;
|
|
||||||
// A block from the structure is outside/inside that it's not suppose to.
|
// A block from the structure is outside/inside that it's not suppose to.
|
||||||
if (origin == null || growingTo == null) {
|
if (origin == null || growingTo == null) {
|
||||||
it.remove();
|
it.remove();
|
||||||
@ -70,13 +70,11 @@ public class Grow implements Listener {
|
|||||||
public void onCropUpgrade(BlockGrowEvent event) {
|
public void onCropUpgrade(BlockGrowEvent event) {
|
||||||
org.bukkit.block.Block block = event.getBlock();
|
org.bukkit.block.Block block = event.getBlock();
|
||||||
WorldManager worldManager = skyblock.getWorldManager();
|
WorldManager worldManager = skyblock.getWorldManager();
|
||||||
if (!skyblock.getWorldManager().isIslandWorld(block.getWorld()))
|
if (!skyblock.getWorldManager().isIslandWorld(block.getWorld())) return;
|
||||||
return;
|
|
||||||
|
|
||||||
IslandManager islandManager = skyblock.getIslandManager();
|
IslandManager islandManager = skyblock.getIslandManager();
|
||||||
Island island = islandManager.getIslandAtLocation(block.getLocation());
|
Island island = islandManager.getIslandAtLocation(block.getLocation());
|
||||||
if (island == null)
|
if (island == null) return;
|
||||||
return;
|
|
||||||
|
|
||||||
// Check spawn block protection
|
// Check spawn block protection
|
||||||
IslandWorld world = worldManager.getIslandWorld(block.getWorld());
|
IslandWorld world = worldManager.getIslandWorld(block.getWorld());
|
||||||
@ -88,8 +86,7 @@ public class Grow implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Upgrade> upgrades = skyblock.getUpgradeManager().getUpgrades(Upgrade.Type.Crop);
|
List<Upgrade> upgrades = skyblock.getUpgradeManager().getUpgrades(Upgrade.Type.Crop);
|
||||||
if (upgrades == null || upgrades.size() == 0 || !upgrades.get(0).isEnabled() || !island.isUpgrade(Upgrade.Type.Crop))
|
if (upgrades == null || upgrades.size() == 0 || !upgrades.get(0).isEnabled() || !island.isUpgrade(Upgrade.Type.Crop)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (NMSUtil.getVersionNumber() > 12) {
|
if (NMSUtil.getVersionNumber() > 12) {
|
||||||
try {
|
try {
|
||||||
@ -97,26 +94,18 @@ public class Grow implements Listener {
|
|||||||
if (blockData instanceof org.bukkit.block.data.Ageable) {
|
if (blockData instanceof org.bukkit.block.data.Ageable) {
|
||||||
org.bukkit.block.data.Ageable ageable = (org.bukkit.block.data.Ageable) blockData;
|
org.bukkit.block.data.Ageable ageable = (org.bukkit.block.data.Ageable) blockData;
|
||||||
ageable.setAge(ageable.getAge() + 1);
|
ageable.setAge(ageable.getAge() + 1);
|
||||||
block.getClass()
|
block.getClass().getMethod("setBlockData", Class.forName("org.bukkit.block.data.BlockData")).invoke(block, ageable);
|
||||||
.getMethod("setBlockData", Class.forName("org.bukkit.block.data.BlockData"))
|
|
||||||
.invoke(block, ageable);
|
|
||||||
}
|
}
|
||||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
|
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | ClassNotFoundException e) {
|
||||||
| NoSuchMethodException | SecurityException | ClassNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Material type = block.getType();
|
Material type = block.getType();
|
||||||
if (block.getState().getData() instanceof Crops
|
if (block.getState().getData() instanceof Crops || type.name().equals("BEETROOT_BLOCK") || type.name().equals("CARROT") || type.name().equals("POTATO")
|
||||||
|| type.name().equals("BEETROOT_BLOCK")
|
|| type.name().equals("WHEAT") || type.name().equals("CROPS")) {
|
||||||
|| type.name().equals("CARROT")
|
|
||||||
|| type.name().equals("POTATO")
|
|
||||||
|| type.name().equals("WHEAT")
|
|
||||||
|| type.name().equals("CROPS")) {
|
|
||||||
try {
|
try {
|
||||||
block.getClass().getMethod("setData", byte.class).invoke(block, (byte) (block.getData() + 1));
|
block.getClass().getMethod("setData", byte.class).invoke(block, (byte) (block.getData() + 1));
|
||||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
|
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||||
| NoSuchMethodException | SecurityException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,24 +113,23 @@ public class Grow implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks that a block like a pumpkins and melons are not growing outside or into another island.
|
* Checks that a block like a pumpkins and melons are not growing outside or
|
||||||
|
* into another island.
|
||||||
|
*
|
||||||
* @author LimeGlass
|
* @author LimeGlass
|
||||||
*/
|
*/
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onBlockGrow(BlockGrowEvent event) {
|
public void onBlockGrow(BlockGrowEvent event) {
|
||||||
WorldManager worldManager = skyblock.getWorldManager();
|
WorldManager worldManager = skyblock.getWorldManager();
|
||||||
BlockState state = event.getNewState();
|
BlockState state = event.getNewState();
|
||||||
if (!worldManager.isIslandWorld(state.getWorld()))
|
if (!worldManager.isIslandWorld(state.getWorld())) return;
|
||||||
return;
|
if (state.getType() != Materials.PUMPKIN.parseMaterial() && state.getType() != Materials.MELON.parseMaterial()) return;
|
||||||
if (state.getType() != Materials.PUMPKIN.parseMaterial() && state.getType() != Materials.MELON.parseMaterial())
|
|
||||||
return;
|
|
||||||
|
|
||||||
IslandManager islandManager = skyblock.getIslandManager();
|
IslandManager islandManager = skyblock.getIslandManager();
|
||||||
Island origin = islandManager.getIslandAtLocation(event.getBlock().getLocation());
|
Island origin = islandManager.getIslandAtLocation(event.getBlock().getLocation());
|
||||||
Island growingTo = islandManager.getIslandAtLocation(state.getLocation());
|
Island growingTo = islandManager.getIslandAtLocation(state.getLocation());
|
||||||
// This block is ok to continue as it's not related to Skyblock islands.
|
// This block is ok to continue as it's not related to Skyblock islands.
|
||||||
if (origin == null && growingTo == null)
|
if (origin == null && growingTo == null) return;
|
||||||
return;
|
|
||||||
// The growing block is outside/inside that it's not suppose to.
|
// The growing block is outside/inside that it's not suppose to.
|
||||||
if (origin == null || growingTo == null) {
|
if (origin == null || growingTo == null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -155,22 +143,20 @@ public class Grow implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks that a structure growing like a tree, does not impact spawn location of the island.
|
* Checks that a structure growing like a tree, does not impact spawn location
|
||||||
|
* of the island.
|
||||||
*/
|
*/
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onStructureCreate(StructureGrowEvent event) {
|
public void onStructureCreate(StructureGrowEvent event) {
|
||||||
if (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection"))
|
if (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) return;
|
||||||
return;
|
|
||||||
|
|
||||||
List<BlockState> blocks = event.getBlocks();
|
List<BlockState> blocks = event.getBlocks();
|
||||||
if (blocks.isEmpty())
|
if (blocks.isEmpty()) return;
|
||||||
return;
|
|
||||||
|
|
||||||
WorldManager worldManager = skyblock.getWorldManager();
|
WorldManager worldManager = skyblock.getWorldManager();
|
||||||
IslandManager islandManager = skyblock.getIslandManager();
|
IslandManager islandManager = skyblock.getIslandManager();
|
||||||
Island island = islandManager.getIslandAtLocation(event.getLocation());
|
Island island = islandManager.getIslandAtLocation(event.getLocation());
|
||||||
if (island == null)
|
if (island == null) return;
|
||||||
return;
|
|
||||||
|
|
||||||
// Check spawn block protection
|
// Check spawn block protection
|
||||||
IslandWorld world = worldManager.getIslandWorld(blocks.get(0).getWorld());
|
IslandWorld world = worldManager.getIslandWorld(blocks.get(0).getWorld());
|
||||||
@ -184,27 +170,22 @@ public class Grow implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onFireSpread(BlockSpreadEvent event) {
|
public void onFireSpread(BlockSpreadEvent event) {
|
||||||
if (event.getSource().getType() != Material.FIRE)
|
if (event.getSource().getType() != Material.FIRE) return;
|
||||||
return;
|
|
||||||
|
|
||||||
org.bukkit.block.Block block = event.getBlock();
|
org.bukkit.block.Block block = event.getBlock();
|
||||||
if (!skyblock.getWorldManager().isIslandWorld(block.getWorld()))
|
if (!skyblock.getWorldManager().isIslandWorld(block.getWorld())) return;
|
||||||
return;
|
|
||||||
|
|
||||||
IslandManager islandManager = skyblock.getIslandManager();
|
IslandManager islandManager = skyblock.getIslandManager();
|
||||||
if (!islandManager.hasSetting(block.getLocation(), IslandRole.Owner, "FireSpread"))
|
if (!islandManager.hasSetting(block.getLocation(), IslandRole.Owner, "FireSpread")) event.setCancelled(true);
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onLeavesDecay(LeavesDecayEvent event) {
|
public void onLeavesDecay(LeavesDecayEvent event) {
|
||||||
org.bukkit.block.Block block = event.getBlock();
|
org.bukkit.block.Block block = event.getBlock();
|
||||||
if (!skyblock.getWorldManager().isIslandWorld(block.getWorld()))
|
if (!skyblock.getWorldManager().isIslandWorld(block.getWorld())) return;
|
||||||
return;
|
|
||||||
|
|
||||||
IslandManager islandManager = skyblock.getIslandManager();
|
IslandManager islandManager = skyblock.getIslandManager();
|
||||||
if (!islandManager.hasSetting(block.getLocation(), IslandRole.Owner, "LeafDecay"))
|
if (!islandManager.hasSetting(block.getLocation(), IslandRole.Owner, "LeafDecay")) event.setCancelled(true);
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ public class ScoreboardManager extends BukkitRunnable {
|
|||||||
|
|
||||||
obj.setDisplayName(primaryObjective.getDisplayName());
|
obj.setDisplayName(primaryObjective.getDisplayName());
|
||||||
obj.setDisplaySlot(primaryObjective.getDisplaySlot());
|
obj.setDisplaySlot(primaryObjective.getDisplaySlot());
|
||||||
obj.setRenderType(primaryObjective.getRenderType());
|
if (VERSION > 12) obj.setRenderType(primaryObjective.getRenderType());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Team primaryTeam : teams) {
|
for (Team primaryTeam : teams) {
|
||||||
|
Loading…
Reference in New Issue
Block a user