From fabfcc8b561bed76e515424a7641d0f311514e3b Mon Sep 17 00:00:00 2001 From: Poslovitch Date: Sun, 30 Oct 2016 12:13:29 +0100 Subject: [PATCH 01/11] Added config options for MagicCobbleGen --- config.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/config.yml b/config.yml index f2ff36fa6..ebdba93d1 100644 --- a/config.yml +++ b/config.yml @@ -580,6 +580,22 @@ general: # Recommendation is to keep this false. islandtopteninchat: false + # Toggle Magic Cobblestone Generator + # If set to true, a cobble generator will not just generate cobblestone, but + # also blocks you have specified. + # Default is false, because it highly changes the gameplay. + usemagiccobblegen: false + + # This won't be considered if usemagiccobblegen is set to false. + # You can add, remove a block or modify its probability to be generated. + magiccobblegenchances: + COBBLESTONE: 75.0 + STONE: 10.0 + COAL_ORE: 7.5 + IRON_ORE: 5.0 + DIAMOND_ORE: 2.0 + EMERALD_ORE: 0.5 + # Config.yml version. DO NOT EDIT. This number only changes if the latest # plugin config has been updated. If a new config is detected, it will be # auto-saved to config.new.yml. From 31e863e5b00d303c25a7188165debe52cc704559 Mon Sep 17 00:00:00 2001 From: Poslovitch Date: Sun, 30 Oct 2016 12:15:13 +0100 Subject: [PATCH 02/11] Added Settings for MagicCobbleGen --- src/com/wasteofplastic/askyblock/Settings.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/com/wasteofplastic/askyblock/Settings.java b/src/com/wasteofplastic/askyblock/Settings.java index 940291959..bfc046030 100644 --- a/src/com/wasteofplastic/askyblock/Settings.java +++ b/src/com/wasteofplastic/askyblock/Settings.java @@ -237,6 +237,10 @@ public enum GameType { // Need a certain amount of island levels to create a warp sign public static int warpLevelsRestriction; + // Magic Cobble Generator + public static boolean useMagicCobbleGen; + public static HashMap magicCobbleGenChances; + // Falling blocked commands public static List fallingCommandBlockList; public static List leaveCommands; From 94d2af7ca5f99d5d0fb83713be1b9c619b9328b6 Mon Sep 17 00:00:00 2001 From: Poslovitch Date: Sun, 30 Oct 2016 12:17:10 +0100 Subject: [PATCH 03/11] Load magiccobblegen settings --- src/com/wasteofplastic/askyblock/ASkyBlock.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/com/wasteofplastic/askyblock/ASkyBlock.java b/src/com/wasteofplastic/askyblock/ASkyBlock.java index bb2dc9082..fe342b69b 100644 --- a/src/com/wasteofplastic/askyblock/ASkyBlock.java +++ b/src/com/wasteofplastic/askyblock/ASkyBlock.java @@ -1474,6 +1474,15 @@ public boolean loadPluginConfig() { } if (Settings.minNameLength > Settings.maxNameLength) { Settings.minNameLength = Settings.maxNameLength; + } + // Magic Cobble Generator + Settings.useMagicCobbleGen = getConfig().getBoolean("general.usemagiccobblegen", false); + if(Settings.useMagicCobbleGen && getConfig().isSet("general.magiccobblegenchances")){ + for(String block : getConfig().getConfigurationSection("general.magiccobblegenchances").getKeys(false)){ + double chance = getConfig().getDouble("general.magiccobblegenchances." + block, 0D); + if(chance < 0) chance = 0; + if(Material.getMaterial(block).isBlock()) Settings.magicCobbleGenChances.put(Material.getMaterial(block), chance); + } } // All done return true; From 09270a3f4f95673ff845e0ec6d9ff0692a6ea93f Mon Sep 17 00:00:00 2001 From: Poslovitch Date: Sun, 30 Oct 2016 13:52:35 +0100 Subject: [PATCH 04/11] Added Listener for MagicCobbleGenerator --- .../askyblock/listeners/LavaCheck.java | 432 ++++++++++-------- 1 file changed, 243 insertions(+), 189 deletions(-) diff --git a/src/com/wasteofplastic/askyblock/listeners/LavaCheck.java b/src/com/wasteofplastic/askyblock/listeners/LavaCheck.java index 834001218..adf6038a9 100644 --- a/src/com/wasteofplastic/askyblock/listeners/LavaCheck.java +++ b/src/com/wasteofplastic/askyblock/listeners/LavaCheck.java @@ -16,9 +16,13 @@ *******************************************************************************/ package com.wasteofplastic.askyblock.listeners; +import java.util.Map.Entry; +import java.util.Random; + import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -33,196 +37,246 @@ * */ public class LavaCheck implements Listener { - BukkitTask task; - private final ASkyBlock plugin; - private final static boolean DEBUG = false; + BukkitTask task; + private final ASkyBlock plugin; + private final static boolean DEBUG = false; + + public LavaCheck(ASkyBlock aSkyBlock) { + plugin = aSkyBlock; + } + + /** + * Removes stone generated by lava pouring onto water + * + * @param e + */ + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onCleanstoneGen(BlockFromToEvent e) { + // Only do this in ASkyBlock world + if (!e.getBlock().getWorld().getName().equalsIgnoreCase(Settings.worldName)) { + return; + } + // Do nothing if a new island is being created + if (plugin.isNewIsland()) + return; + final Block to = e.getToBlock(); + // plugin.getLogger().info("From material is " + from.toString()); + // plugin.getLogger().info("To material is " + to.getType().toString()); + // plugin.getLogger().info("---------------------------------"); + if (Settings.acidDamage > 0) { + if (DEBUG) + plugin.getLogger().info("DEBUG: cleanstone gen " + e.getEventName()); + + final Material prev = to.getType(); + // plugin.getLogger().info("To material was " + + // to.getType().toString()); + plugin.getServer().getScheduler().runTask(plugin, new Runnable() { + @Override + public void run() { + // plugin.getLogger().info("To material is after 1 tick " + + // to.getType().toString()); + if ((prev.equals(Material.WATER) || prev.equals(Material.STATIONARY_WATER)) && to.getType().equals(Material.STONE)) { + to.setType(prev); + if (plugin.getServer().getVersion().contains("(MC: 1.8") || plugin.getServer().getVersion().contains("(MC: 1.7")) { + to.getWorld().playSound(to.getLocation(), Sound.valueOf("FIZZ"), 1F, 2F); + } else { + to.getWorld().playSound(to.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1F, 2F); + } + } + } + }); + } + } + + /** + * Magic Cobble Generator + * @param e + */ + @SuppressWarnings("deprecation") + @EventHandler + public void onCobbleGen(BlockFromToEvent e){ + // If magic cobble gen isnt used + if(!Settings.useMagicCobbleGen) return; + // Only do this in ASkyBlock world + if (!e.getBlock().getWorld().getName().equalsIgnoreCase(Settings.worldName)) return; - public LavaCheck(ASkyBlock aSkyBlock) { - plugin = aSkyBlock; - } + int id = e.getBlock().getTypeId(); + if ((id >= 8) && (id <= 11)) { + Block b = e.getToBlock(); + int toID = b.getTypeId(); + if ((toID == 0) && (generatesCobble(id, b))){ + Material change = null; + if(!Settings.magicCobbleGenChances.isEmpty()){ + for(Entry entry : Settings.magicCobbleGenChances.entrySet()){ + Random random = new Random(); + double d = random.nextDouble() * 100.0D; + if(d - entry.getValue() < 0.0D) change = entry.getKey(); + } + } + if (change == null) return; + b.setTypeIdAndData(change.getId(), (byte) 0, true); + } + } + } - /** - * Removes stone generated by lava pouring onto water - * - * @param e - */ - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public void onCleanstoneGen(BlockFromToEvent e) { - // Only do this in ASkyBlock world - if (!e.getBlock().getWorld().getName().equalsIgnoreCase(Settings.worldName)) { - return; - } - // Do nothing if a new island is being created - if (plugin.isNewIsland()) - return; - final Block to = e.getToBlock(); - // plugin.getLogger().info("From material is " + from.toString()); - // plugin.getLogger().info("To material is " + to.getType().toString()); - // plugin.getLogger().info("---------------------------------"); - if (Settings.acidDamage > 0) { - if (DEBUG) - plugin.getLogger().info("DEBUG: cleanstone gen " + e.getEventName()); + private final BlockFace[] faces = { BlockFace.SELF, BlockFace.UP, BlockFace.DOWN, BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST }; - final Material prev = to.getType(); - // plugin.getLogger().info("To material was " + - // to.getType().toString()); - plugin.getServer().getScheduler().runTask(plugin, new Runnable() { - @Override - public void run() { - // plugin.getLogger().info("To material is after 1 tick " + - // to.getType().toString()); - if ((prev.equals(Material.WATER) || prev.equals(Material.STATIONARY_WATER)) && to.getType().equals(Material.STONE)) { - to.setType(prev); - if (plugin.getServer().getVersion().contains("(MC: 1.8") || plugin.getServer().getVersion().contains("(MC: 1.7")) { - to.getWorld().playSound(to.getLocation(), Sound.valueOf("FIZZ"), 1F, 2F); - } else { - to.getWorld().playSound(to.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1F, 2F); - } - } - } - }); - } - } + @SuppressWarnings("deprecation") + public boolean generatesCobble(int id, Block b){ + int mirrorID1 = (id == 8) || (id == 9) ? 10 : 8; + int mirrorID2 = (id == 8) || (id == 9) ? 11 : 9; + BlockFace[] arrayOfBlockFace; + int j = (arrayOfBlockFace = this.faces).length; + for (int i = 0; i < j; i++) + { + BlockFace face = arrayOfBlockFace[i]; + Block r = b.getRelative(face, 1); + if ((r.getTypeId() == mirrorID1) || (r.getTypeId() == mirrorID2)) { + return true; + } + } + return false; + } +} - // Failed attempts - remember the pain - // Not this event - /* - * @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - * public void onStone(BlockFormEvent e) { - * plugin.getLogger().info(e.getEventName()); - * } - */ - /* - * @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - * public void onStone(BlockPhysicsEvent e) { - * plugin.getLogger().info(e.getEventName()); - * plugin.getLogger().info("DEBUG: block physics " + - * e.getBlock().getType()); - * plugin.getLogger().info("DEBUG: block physics changed " + - * e.getChangedType()); - * plugin.getLogger().info("---------------------------------"); - * if (e.getChangedType().equals(Material.WATER) || - * e.getChangedType().equals(Material.STATIONARY_WATER) - * && e.getBlock().getType().equals(Material.STONE)) { - * e.getBlock().setType(Material.WATER); - * e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.FIZZ, - * 1F, 1F); - * } - * } - */ - /* - * @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - * public void onStone(BlockSpreadEvent e) { - * plugin.getLogger().info(e.getEventName()); - * } - */ - /* - * if ((from.equals(Material.STATIONARY_WATER) && - * to.getType().equals(Material.STONE)) - * || (from.equals(Material.STATIONARY_LAVA) && - * to.getType().equals(Material.STATIONARY_WATER)) - * || (from.equals(Material.LAVA) && - * to.getType().equals(Material.STATIONARY_WATER))) { - * // plugin.getLogger().info("from sw to st cancelled"); - * // to.setType(Material.FIRE); - * to.setType(Material.STATIONARY_WATER); - * e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.FIZZ, - * 1F, 1F); - * e.setCancelled(true); - * //return; - * } - * // Get the from block - * Block fromBlock = to.getRelative(oppositeFace(e.getFace())); - * plugin.getLogger().info("DEBUG: From block " + fromBlock.getType() + - * " location " + fromBlock.getX() + "," + fromBlock.getZ()); - * plugin.getLogger().info("To material before " + to.getType().toString()); - * final Material prev = to.getType(); - * plugin.getServer().getScheduler().runTask(plugin, new Runnable() { - * @Override - * public void run() { - * plugin.getLogger().info("To material is after 1 tick " + - * to.getType().toString()); - * if ((prev.equals(Material.WATER) || - * prev.equals(Material.STATIONARY_WATER)) && - * to.getType().equals(Material.STONE)) { - * to.setType(prev); - * to.getWorld().playSound(to.getLocation(), Sound.FIZZ, 1F, 1F); - * } - * }}); - * if ((from.equals(Material.STATIONARY_WATER) || - * from.equals(Material.WATER))) { - * // Look around the from block - * for (BlockFace bf: BlockFace.values()) { - * switch (bf) { - * case DOWN: - * case EAST: - * case NORTH: - * case NORTH_EAST: - * case NORTH_WEST: - * case SOUTH: - * case SOUTH_EAST: - * case SOUTH_WEST: - * case UP: - * case WEST: - * Block adjacent = fromBlock.getRelative(bf); - * if (adjacent.getType().equals(Material.STONE)) { - * adjacent.setType(Material.AIR); - * adjacent.getWorld().playSound(e.getBlock().getLocation(), Sound.FIZZ, 1F, - * 1F); - * plugin.getLogger().info("DEBUG: Melting block " + adjacent.getType() + - * " location " + adjacent.getX() + "," + adjacent.getZ()); - * } - * break; - * default: - * break; - * } - * } - * } - */ - /* - * private BlockFace oppositeFace(BlockFace face) { - * switch (face) { - * case DOWN: - * return BlockFace.UP; - * case EAST: - * return BlockFace.WEST; - * case EAST_NORTH_EAST: - * return BlockFace.WEST_SOUTH_WEST; - * case EAST_SOUTH_EAST: - * return BlockFace.WEST_NORTH_WEST; - * case NORTH: - * return BlockFace.SOUTH; - * case NORTH_EAST: - * return BlockFace.SOUTH_WEST; - * case NORTH_NORTH_EAST: - * return BlockFace.SOUTH_SOUTH_WEST; - * case NORTH_NORTH_WEST: - * return BlockFace.SOUTH_SOUTH_EAST; - * case NORTH_WEST: - * return BlockFace.SOUTH_EAST; - * case SELF: - * return BlockFace.SELF; - * case SOUTH: - * return BlockFace.NORTH; - * case SOUTH_EAST: - * return BlockFace.NORTH_WEST; - * case SOUTH_SOUTH_EAST: - * return BlockFace.NORTH_NORTH_WEST; - * case SOUTH_SOUTH_WEST: - * return BlockFace.NORTH_NORTH_EAST; - * case SOUTH_WEST: - * return BlockFace.NORTH_EAST; - * case UP: - * return BlockFace.DOWN; - * case WEST: - * return BlockFace.EAST; - * case WEST_NORTH_WEST: - * return BlockFace.EAST_SOUTH_EAST; - * case WEST_SOUTH_WEST: - * return BlockFace.EAST_NORTH_EAST; - * default: - * return BlockFace.SELF; - * } - * } - */ -} \ No newline at end of file +// Failed attempts - remember the pain +// Not this event +/* + * @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + * public void onStone(BlockFormEvent e) { + * plugin.getLogger().info(e.getEventName()); + * } + */ +/* + * @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + * public void onStone(BlockPhysicsEvent e) { + * plugin.getLogger().info(e.getEventName()); + * plugin.getLogger().info("DEBUG: block physics " + + * e.getBlock().getType()); + * plugin.getLogger().info("DEBUG: block physics changed " + + * e.getChangedType()); + * plugin.getLogger().info("---------------------------------"); + * if (e.getChangedType().equals(Material.WATER) || + * e.getChangedType().equals(Material.STATIONARY_WATER) + * && e.getBlock().getType().equals(Material.STONE)) { + * e.getBlock().setType(Material.WATER); + * e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.FIZZ, + * 1F, 1F); + * } + * } + */ +/* + * @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + * public void onStone(BlockSpreadEvent e) { + * plugin.getLogger().info(e.getEventName()); + * } + */ +/* + * if ((from.equals(Material.STATIONARY_WATER) && + * to.getType().equals(Material.STONE)) + * || (from.equals(Material.STATIONARY_LAVA) && + * to.getType().equals(Material.STATIONARY_WATER)) + * || (from.equals(Material.LAVA) && + * to.getType().equals(Material.STATIONARY_WATER))) { + * // plugin.getLogger().info("from sw to st cancelled"); + * // to.setType(Material.FIRE); + * to.setType(Material.STATIONARY_WATER); + * e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.FIZZ, + * 1F, 1F); + * e.setCancelled(true); + * //return; + * } + * // Get the from block + * Block fromBlock = to.getRelative(oppositeFace(e.getFace())); + * plugin.getLogger().info("DEBUG: From block " + fromBlock.getType() + + * " location " + fromBlock.getX() + "," + fromBlock.getZ()); + * plugin.getLogger().info("To material before " + to.getType().toString()); + * final Material prev = to.getType(); + * plugin.getServer().getScheduler().runTask(plugin, new Runnable() { + * @Override + * public void run() { + * plugin.getLogger().info("To material is after 1 tick " + + * to.getType().toString()); + * if ((prev.equals(Material.WATER) || + * prev.equals(Material.STATIONARY_WATER)) && + * to.getType().equals(Material.STONE)) { + * to.setType(prev); + * to.getWorld().playSound(to.getLocation(), Sound.FIZZ, 1F, 1F); + * } + * }}); + * if ((from.equals(Material.STATIONARY_WATER) || + * from.equals(Material.WATER))) { + * // Look around the from block + * for (BlockFace bf: BlockFace.values()) { + * switch (bf) { + * case DOWN: + * case EAST: + * case NORTH: + * case NORTH_EAST: + * case NORTH_WEST: + * case SOUTH: + * case SOUTH_EAST: + * case SOUTH_WEST: + * case UP: + * case WEST: + * Block adjacent = fromBlock.getRelative(bf); + * if (adjacent.getType().equals(Material.STONE)) { + * adjacent.setType(Material.AIR); + * adjacent.getWorld().playSound(e.getBlock().getLocation(), Sound.FIZZ, 1F, + * 1F); + * plugin.getLogger().info("DEBUG: Melting block " + adjacent.getType() + + * " location " + adjacent.getX() + "," + adjacent.getZ()); + * } + * break; + * default: + * break; + * } + * } + * } + */ +/* + * private BlockFace oppositeFace(BlockFace face) { + * switch (face) { + * case DOWN: + * return BlockFace.UP; + * case EAST: + * return BlockFace.WEST; + * case EAST_NORTH_EAST: + * return BlockFace.WEST_SOUTH_WEST; + * case EAST_SOUTH_EAST: + * return BlockFace.WEST_NORTH_WEST; + * case NORTH: + * return BlockFace.SOUTH; + * case NORTH_EAST: + * return BlockFace.SOUTH_WEST; + * case NORTH_NORTH_EAST: + * return BlockFace.SOUTH_SOUTH_WEST; + * case NORTH_NORTH_WEST: + * return BlockFace.SOUTH_SOUTH_EAST; + * case NORTH_WEST: + * return BlockFace.SOUTH_EAST; + * case SELF: + * return BlockFace.SELF; + * case SOUTH: + * return BlockFace.NORTH; + * case SOUTH_EAST: + * return BlockFace.NORTH_WEST; + * case SOUTH_SOUTH_EAST: + * return BlockFace.NORTH_NORTH_WEST; + * case SOUTH_SOUTH_WEST: + * return BlockFace.NORTH_NORTH_EAST; + * case SOUTH_WEST: + * return BlockFace.NORTH_EAST; + * case UP: + * return BlockFace.DOWN; + * case WEST: + * return BlockFace.EAST; + * case WEST_NORTH_WEST: + * return BlockFace.EAST_SOUTH_EAST; + * case WEST_SOUTH_WEST: + * return BlockFace.EAST_NORTH_EAST; + * default: + * return BlockFace.SELF; + * } + * } + */ \ No newline at end of file From 189e70e041e4e1abd35f85ae16f1244f30b9c115 Mon Sep 17 00:00:00 2001 From: Poslovitch Date: Sun, 30 Oct 2016 13:57:39 +0100 Subject: [PATCH 05/11] Fixed a forgotten import --- src/com/wasteofplastic/askyblock/Settings.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/com/wasteofplastic/askyblock/Settings.java b/src/com/wasteofplastic/askyblock/Settings.java index bfc046030..92de02ffb 100644 --- a/src/com/wasteofplastic/askyblock/Settings.java +++ b/src/com/wasteofplastic/askyblock/Settings.java @@ -21,6 +21,7 @@ import java.util.List; import java.util.Set; +import org.bukkit.Material; import org.bukkit.block.Biome; import org.bukkit.entity.EntityType; import org.bukkit.inventory.ItemStack; From e7451d22a45412e51c93086443a305bca2467d5f Mon Sep 17 00:00:00 2001 From: Poslovitch Date: Sun, 30 Oct 2016 14:29:09 +0100 Subject: [PATCH 06/11] Bug fixes. --- src/com/wasteofplastic/askyblock/listeners/LavaCheck.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/com/wasteofplastic/askyblock/listeners/LavaCheck.java b/src/com/wasteofplastic/askyblock/listeners/LavaCheck.java index adf6038a9..fe626ca23 100644 --- a/src/com/wasteofplastic/askyblock/listeners/LavaCheck.java +++ b/src/com/wasteofplastic/askyblock/listeners/LavaCheck.java @@ -97,8 +97,6 @@ public void run() { public void onCobbleGen(BlockFromToEvent e){ // If magic cobble gen isnt used if(!Settings.useMagicCobbleGen) return; - // Only do this in ASkyBlock world - if (!e.getBlock().getWorld().getName().equalsIgnoreCase(Settings.worldName)) return; int id = e.getBlock().getTypeId(); if ((id >= 8) && (id <= 11)) { @@ -279,4 +277,4 @@ public boolean generatesCobble(int id, Block b){ * return BlockFace.SELF; * } * } - */ \ No newline at end of file + */ From 2288cad034e029be66e2a04173a157fd390b84f7 Mon Sep 17 00:00:00 2001 From: Poslovitch Date: Sun, 30 Oct 2016 14:32:01 +0100 Subject: [PATCH 07/11] Fixed NPE while loading MagicCobbleGen config --- src/com/wasteofplastic/askyblock/ASkyBlock.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/wasteofplastic/askyblock/ASkyBlock.java b/src/com/wasteofplastic/askyblock/ASkyBlock.java index fe342b69b..9f6911345 100644 --- a/src/com/wasteofplastic/askyblock/ASkyBlock.java +++ b/src/com/wasteofplastic/askyblock/ASkyBlock.java @@ -1478,10 +1478,11 @@ public boolean loadPluginConfig() { // Magic Cobble Generator Settings.useMagicCobbleGen = getConfig().getBoolean("general.usemagiccobblegen", false); if(Settings.useMagicCobbleGen && getConfig().isSet("general.magiccobblegenchances")){ + Settings.magicCobbleGenChances = new HashMap(); for(String block : getConfig().getConfigurationSection("general.magiccobblegenchances").getKeys(false)){ double chance = getConfig().getDouble("general.magiccobblegenchances." + block, 0D); if(chance < 0) chance = 0; - if(Material.getMaterial(block).isBlock()) Settings.magicCobbleGenChances.put(Material.getMaterial(block), chance); + if(Material.getMaterial(block) != null && Material.getMaterial(block).isBlock()) Settings.magicCobbleGenChances.put(Material.getMaterial(block), chance); } } // All done From 2ea350b988412fb1abf933e944351c394f3c355f Mon Sep 17 00:00:00 2001 From: kanoxx Date: Fri, 4 Nov 2016 20:56:24 +0100 Subject: [PATCH 08/11] Fixed JavaDoc --- src/com/wasteofplastic/askyblock/CoopPlay.java | 5 ++--- src/com/wasteofplastic/askyblock/commands/IslandCmd.java | 5 ++--- .../wasteofplastic/askyblock/listeners/ChatListener.java | 3 ++- .../askyblock/listeners/FlyingMobEvents.java | 2 +- src/com/wasteofplastic/askyblock/nms/NMSAbstraction.java | 4 ++-- .../wasteofplastic/askyblock/schematics/EntityObject.java | 8 ++++---- src/com/wasteofplastic/askyblock/util/Util.java | 2 +- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/com/wasteofplastic/askyblock/CoopPlay.java b/src/com/wasteofplastic/askyblock/CoopPlay.java index b00b21fd6..a634ff5b1 100644 --- a/src/com/wasteofplastic/askyblock/CoopPlay.java +++ b/src/com/wasteofplastic/askyblock/CoopPlay.java @@ -55,7 +55,7 @@ public class CoopPlay { private ASkyBlock plugin; /** - * @param instance + * @param plugin */ private CoopPlay(ASkyBlock plugin) { this.plugin = plugin; @@ -278,7 +278,6 @@ private void setMyCoops(UUID playerUUID, List coops) { * Can be used when clearer logs out or when they are kicked or leave a team * * @param clearer - * @param target */ public void clearMyInvitedCoops(Player clearer) { //plugin.getLogger().info("DEBUG: clear my invited coops - clearing coops that were invited by " + clearer.getName()); @@ -311,7 +310,7 @@ public void clearMyInvitedCoops(Player clearer) { /** * Removes all coop players from an island - used when doing an island reset * - * @param player + * @param island */ public void clearAllIslandCoops(Location island) { if (island == null) { diff --git a/src/com/wasteofplastic/askyblock/commands/IslandCmd.java b/src/com/wasteofplastic/askyblock/commands/IslandCmd.java index ba6f8a488..f068e3964 100644 --- a/src/com/wasteofplastic/askyblock/commands/IslandCmd.java +++ b/src/com/wasteofplastic/askyblock/commands/IslandCmd.java @@ -881,8 +881,7 @@ public void pasteSchematic(final Schematic schematic, final Location loc, final /** * Get the location of next free island spot - * @param player - * + * @param playerUUID * @return Location of island spot */ private Location getNextIsland(UUID playerUUID) { @@ -1013,7 +1012,7 @@ private Location nextGridLocation(final Location lastIsland) { /** * Calculates the island level * - * @param asker + * @param sender * - Player object of player who is asking * @param targetPlayer * - UUID of the player's island that is being requested diff --git a/src/com/wasteofplastic/askyblock/listeners/ChatListener.java b/src/com/wasteofplastic/askyblock/listeners/ChatListener.java index ab07ea4f7..ce916249a 100644 --- a/src/com/wasteofplastic/askyblock/listeners/ChatListener.java +++ b/src/com/wasteofplastic/askyblock/listeners/ChatListener.java @@ -150,7 +150,8 @@ private void teamChat(final AsyncPlayerChatEvent event, String message) { } /** - * @param Adds player to team chat + * Adds player to team chat + * @param playerUUID */ public void setPlayer(UUID playerUUID) { this.teamChatUsers.put(playerUUID,true); diff --git a/src/com/wasteofplastic/askyblock/listeners/FlyingMobEvents.java b/src/com/wasteofplastic/askyblock/listeners/FlyingMobEvents.java index 0fd26861d..ec1186964 100644 --- a/src/com/wasteofplastic/askyblock/listeners/FlyingMobEvents.java +++ b/src/com/wasteofplastic/askyblock/listeners/FlyingMobEvents.java @@ -91,7 +91,7 @@ public void run() { /** * Track where the mob was created. This will determine its allowable movement zone. - * @param event + * @param e */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void mobSpawn(CreatureSpawnEvent e) { diff --git a/src/com/wasteofplastic/askyblock/nms/NMSAbstraction.java b/src/com/wasteofplastic/askyblock/nms/NMSAbstraction.java index 848e82007..8cd22dfff 100644 --- a/src/com/wasteofplastic/askyblock/nms/NMSAbstraction.java +++ b/src/com/wasteofplastic/askyblock/nms/NMSAbstraction.java @@ -50,8 +50,8 @@ public interface NMSAbstraction { /** * Returns a potion ItemStack * @param itemMaterial - * @param chestItem - * @param item + * @param itemTag + * @param chestItem * @return */ public ItemStack setPotion(Material itemMaterial, Tag itemTag, ItemStack chestItem); diff --git a/src/com/wasteofplastic/askyblock/schematics/EntityObject.java b/src/com/wasteofplastic/askyblock/schematics/EntityObject.java index ed0d99c99..6f0aa45b4 100644 --- a/src/com/wasteofplastic/askyblock/schematics/EntityObject.java +++ b/src/com/wasteofplastic/askyblock/schematics/EntityObject.java @@ -271,7 +271,7 @@ public float getItemDropChance() { return itemDropChance; } /** - * @param itemDropCance the itemDropChance to set + * @param itemDropChance the itemDropChance to set */ public void setItemDropChance(float itemDropChance) { this.itemDropChance = itemDropChance; @@ -307,7 +307,7 @@ public Double getTileY() { return tileY; } /** - * @param tileX the tileX to set + * @param tileY the tileY to set */ public void setTileY(Double tileY) { this.tileY = tileY; @@ -319,7 +319,7 @@ public Double getTileZ() { return tileZ; } /** - * @param tileX the tileX to set + * @param tileZ the tileZ to set */ public void setTileZ(Double tileZ) { this.tileZ = tileZ; @@ -332,7 +332,7 @@ public Byte getCount() { } /** - * @param cout the count to set + * @param count the count to set */ public void setCount(Byte count) { this.count = count; diff --git a/src/com/wasteofplastic/askyblock/util/Util.java b/src/com/wasteofplastic/askyblock/util/Util.java index 84fa7fd8f..992589fc1 100644 --- a/src/com/wasteofplastic/askyblock/util/Util.java +++ b/src/com/wasteofplastic/askyblock/util/Util.java @@ -257,7 +257,7 @@ static public Location getLocationString(final String s) { * Converts a location to a simple string representation * If location is null, returns empty string * - * @param l + * @param location * @return String of location */ static public String getStringLocation(final Location location) { From b708144abac2339b70ff4549987d32df1a6e01a5 Mon Sep 17 00:00:00 2001 From: Poslovitch Date: Sat, 12 Nov 2016 09:44:24 +0100 Subject: [PATCH 09/11] Use minecraft:title to prevent issue with overrides --- src/com/wasteofplastic/askyblock/commands/IslandCmd.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/wasteofplastic/askyblock/commands/IslandCmd.java b/src/com/wasteofplastic/askyblock/commands/IslandCmd.java index f068e3964..9446ff398 100644 --- a/src/com/wasteofplastic/askyblock/commands/IslandCmd.java +++ b/src/com/wasteofplastic/askyblock/commands/IslandCmd.java @@ -821,19 +821,19 @@ public void run() { if (!plugin.myLocale(player.getUniqueId()).islandSubTitle.isEmpty()) { //plugin.getLogger().info("DEBUG: title " + player.getName() + " subtitle {\"text\":\"" + plugin.myLocale(player.getUniqueId()).islandSubTitle + "\", \"color\":\"" + plugin.myLocale(player.getUniqueId()).islandSubTitleColor + "\"}"); plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), - "title " + player.getName() + " subtitle {\"text\":\"" + plugin.myLocale(player.getUniqueId()).islandSubTitle + "\", \"color\":\"" + plugin.myLocale(player.getUniqueId()).islandSubTitleColor + "\"}"); + "minecraft:title " + player.getName() + " subtitle {\"text\":\"" + plugin.myLocale(player.getUniqueId()).islandSubTitle + "\", \"color\":\"" + plugin.myLocale(player.getUniqueId()).islandSubTitleColor + "\"}"); } if (!plugin.myLocale(player.getUniqueId()).islandTitle.isEmpty()) { //plugin.getLogger().info("DEBUG: title " + player.getName() + " title {\"text\":\"" + plugin.myLocale(player.getUniqueId()).islandTitle + "\", \"color\":\"" + plugin.myLocale(player.getUniqueId()).islandTitleColor + "\"}"); plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), - "title " + player.getName() + " title {\"text\":\"" + plugin.myLocale(player.getUniqueId()).islandTitle + "\", \"color\":\"" + plugin.myLocale(player.getUniqueId()).islandTitleColor + "\"}"); + "minecraft:title " + player.getName() + " title {\"text\":\"" + plugin.myLocale(player.getUniqueId()).islandTitle + "\", \"color\":\"" + plugin.myLocale(player.getUniqueId()).islandTitleColor + "\"}"); } if (!plugin.myLocale(player.getUniqueId()).islandDonate.isEmpty() && !plugin.myLocale(player.getUniqueId()).islandURL.isEmpty()) { //plugin.getLogger().info("DEBUG: tellraw " + player.getName() + " {\"text\":\"" + plugin.myLocale(player.getUniqueId()).islandDonate + "\",\"color\":\"" + plugin.myLocale(player.getUniqueId()).islandDonateColor + "\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"" // + plugin.myLocale(player.getUniqueId()).islandURL + "\"}}"); plugin.getServer().dispatchCommand( plugin.getServer().getConsoleSender(), - "tellraw " + player.getName() + " {\"text\":\"" + plugin.myLocale(player.getUniqueId()).islandDonate + "\",\"color\":\"" + plugin.myLocale(player.getUniqueId()).islandDonateColor + "\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"" + "minecraft:tellraw " + player.getName() + " {\"text\":\"" + plugin.myLocale(player.getUniqueId()).islandDonate + "\",\"color\":\"" + plugin.myLocale(player.getUniqueId()).islandDonateColor + "\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"" + plugin.myLocale(player.getUniqueId()).islandURL + "\"}}"); } } From 00b0b3feb281e416f88a00b1b70556846d8a265f Mon Sep 17 00:00:00 2001 From: Poslovitch Date: Sat, 12 Nov 2016 09:46:59 +0100 Subject: [PATCH 10/11] Use final Random to prevent numerous generated ones Got from https://github.com/tastybento/askyblock/issues/352 --- src/com/wasteofplastic/askyblock/listeners/LavaCheck.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/wasteofplastic/askyblock/listeners/LavaCheck.java b/src/com/wasteofplastic/askyblock/listeners/LavaCheck.java index fe626ca23..d7c5bece8 100644 --- a/src/com/wasteofplastic/askyblock/listeners/LavaCheck.java +++ b/src/com/wasteofplastic/askyblock/listeners/LavaCheck.java @@ -40,9 +40,11 @@ public class LavaCheck implements Listener { BukkitTask task; private final ASkyBlock plugin; private final static boolean DEBUG = false; + private final Random random; public LavaCheck(ASkyBlock aSkyBlock) { plugin = aSkyBlock; + random = new Random(); } /** @@ -106,7 +108,6 @@ public void onCobbleGen(BlockFromToEvent e){ Material change = null; if(!Settings.magicCobbleGenChances.isEmpty()){ for(Entry entry : Settings.magicCobbleGenChances.entrySet()){ - Random random = new Random(); double d = random.nextDouble() * 100.0D; if(d - entry.getValue() < 0.0D) change = entry.getKey(); } From 9251536495cb9ab5693c379f055798d84c833e71 Mon Sep 17 00:00:00 2001 From: Poslovitch Date: Sat, 12 Nov 2016 10:08:24 +0100 Subject: [PATCH 11/11] Added useMinishop config option Idea got from https://github.com/tastybento/askyblock/issues/282 --- config.yml | 3 +++ src/com/wasteofplastic/askyblock/ASLocale.java | 4 +++- src/com/wasteofplastic/askyblock/ASkyBlock.java | 2 ++ src/com/wasteofplastic/askyblock/Settings.java | 3 +++ src/com/wasteofplastic/askyblock/commands/IslandCmd.java | 5 ++++- 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/config.yml b/config.yml index ebdba93d1..372ee9db1 100644 --- a/config.yml +++ b/config.yml @@ -437,6 +437,9 @@ general: # Recommendation is that this is set to true, but if you run multi-worlds # make sure your economy handles multi-worlds too. resetmoney: false + + # Use the minishop or not + useminishop: true # Starting money - this is how much money new players will have as their # balance at the start of an island. diff --git a/src/com/wasteofplastic/askyblock/ASLocale.java b/src/com/wasteofplastic/askyblock/ASLocale.java index 525c55915..e854bee3e 100644 --- a/src/com/wasteofplastic/askyblock/ASLocale.java +++ b/src/com/wasteofplastic/askyblock/ASLocale.java @@ -369,7 +369,8 @@ public class ASLocale { public String minishopYouSold; public String minishopBuyProblem; public String minishopYouCannotAfford; - + public String errorMinishopDisabled; + // Sign public String signLine1; public String signLine2; @@ -754,6 +755,7 @@ public void loadLocale() { errorUnknownCommand = ChatColor.translateAlternateColorCodes('&', locale.getString("error.unknownCommand", "Unknown command.")); errorNoTeam = ChatColor.translateAlternateColorCodes('&', locale.getString("error.noTeam", "That player is not in a team.")); errorWrongWorld = ChatColor.translateAlternateColorCodes('&', locale.getString("error.wrongWorld", "You cannot do that in this world.")); + errorMinishopDisabled = ChatColor.translateAlternateColorCodes('&', locale.getString("error.minishopDisabled", "Minishop is disabled.")); islandProtected = ChatColor.translateAlternateColorCodes('&', locale.getString("islandProtected", "Island protected.")); targetInNoPVPArea = ChatColor.translateAlternateColorCodes('&', locale.getString("targetInPVPArea", "Target is in a no-PVP area!")); igsTitle = ChatColor.translateAlternateColorCodes('&', locale.getString("islandguardsettings.title", "Island Guard Settings")); diff --git a/src/com/wasteofplastic/askyblock/ASkyBlock.java b/src/com/wasteofplastic/askyblock/ASkyBlock.java index 9f6911345..5512c8e90 100644 --- a/src/com/wasteofplastic/askyblock/ASkyBlock.java +++ b/src/com/wasteofplastic/askyblock/ASkyBlock.java @@ -858,6 +858,8 @@ public boolean loadPluginConfig() { // Use economy or not // In future expand to include internal economy Settings.useEconomy = getConfig().getBoolean("general.useeconomy", true); + // Use the minishop or not + Settings.useMinishop = getConfig().getBoolean("general.useminishop", true); // Check for updates Settings.updateCheck = getConfig().getBoolean("general.checkupdates", true); // Island reset commands diff --git a/src/com/wasteofplastic/askyblock/Settings.java b/src/com/wasteofplastic/askyblock/Settings.java index 92de02ffb..2bcb2fb8e 100644 --- a/src/com/wasteofplastic/askyblock/Settings.java +++ b/src/com/wasteofplastic/askyblock/Settings.java @@ -225,6 +225,9 @@ public enum GameType { // Use Economy public static boolean useEconomy; + + // Use Minishop + public static boolean useMinishop; // Wait between being invited to same team island public static int inviteWait; diff --git a/src/com/wasteofplastic/askyblock/commands/IslandCmd.java b/src/com/wasteofplastic/askyblock/commands/IslandCmd.java index 9446ff398..c98583f01 100644 --- a/src/com/wasteofplastic/askyblock/commands/IslandCmd.java +++ b/src/com/wasteofplastic/askyblock/commands/IslandCmd.java @@ -1417,7 +1417,7 @@ public boolean onCommand(final CommandSender sender, final Command command, fina } if (split[0].equalsIgnoreCase("minishop") || split[0].equalsIgnoreCase("ms")) { - if (Settings.useEconomy) { + if (Settings.useEconomy && Settings.useMinishop) { // Check island if (plugin.getGrid().getIsland(player.getUniqueId()) == null) { player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland); @@ -1433,6 +1433,9 @@ public boolean onCommand(final CommandSender sender, final Command command, fina return true; } } + else{ + player.sendMessage(ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorMinishopDisabled); + } } // /island if (split[0].equalsIgnoreCase("warp")) {