From c98dae2854b4b1600fa55139d443e14af5b7618f Mon Sep 17 00:00:00 2001 From: dragontamerfred Date: Tue, 8 Oct 2019 20:34:29 +0200 Subject: [PATCH] Add lily pad growing. Fix some warnings. Bump version number. --- README.md | 3 +++ gradle.properties | 2 +- .../ToggleTrample/TrampleHandler.java | 4 +++- .../vanillatweaks/VanillaTweaks.java | 12 ++++++------ .../java/nl/kallestruik/vanillatweaks/c.java | 1 + .../nl/kallestruik/vanillatweaks/config.java | 4 ++++ .../java/nl/kallestruik/vanillatweaks/util.java | 17 +++++++++++++++++ src/main/resources/config.yml | 5 ++++- 8 files changed, 39 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 7363385..a9defbe 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,9 @@ Instantly dry wet sponges when they are placed in the nether. ### Hoe harvesting When breaking crops with a hoe you break a range around them. This drastically speeds up manual harvesting of crop farms. +### Lily pad growing +When right-clicking a lily pad with bone meal it wil grow new lily pads around the one that was clicked. + ## Planned tweaks - Dynamite - Sign editing diff --git a/gradle.properties b/gradle.properties index f6446db..ae863f7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ pluginGroup=nl.kallestruik -pluginVersion=1.0 +pluginVersion=1.1 diff --git a/src/main/java/nl/kallestruik/vanillatweaks/ToggleTrample/TrampleHandler.java b/src/main/java/nl/kallestruik/vanillatweaks/ToggleTrample/TrampleHandler.java index 9767aff..e2b2452 100644 --- a/src/main/java/nl/kallestruik/vanillatweaks/ToggleTrample/TrampleHandler.java +++ b/src/main/java/nl/kallestruik/vanillatweaks/ToggleTrample/TrampleHandler.java @@ -19,7 +19,7 @@ import java.util.UUID; public class TrampleHandler implements Listener { - public static HashSet trampleEnabled = new HashSet<>(); + static HashSet trampleEnabled = new HashSet<>(); @EventHandler public void onBlockBreak(EntityChangeBlockEvent event) { @@ -43,6 +43,7 @@ public class TrampleHandler implements Listener { event.setCancelled(true); } + @SuppressWarnings("ResultOfMethodCallIgnored") public static void loadTrampleEnabled(File file) throws IOException, InvalidConfigurationException { file.getParentFile().mkdirs(); file.createNewFile(); @@ -55,6 +56,7 @@ public class TrampleHandler implements Listener { } + @SuppressWarnings("ResultOfMethodCallIgnored") public static void saveTrampleEnabled(File file) throws IOException, InvalidConfigurationException { file.getParentFile().mkdirs(); file.createNewFile(); diff --git a/src/main/java/nl/kallestruik/vanillatweaks/VanillaTweaks.java b/src/main/java/nl/kallestruik/vanillatweaks/VanillaTweaks.java index 109704b..52f2a47 100644 --- a/src/main/java/nl/kallestruik/vanillatweaks/VanillaTweaks.java +++ b/src/main/java/nl/kallestruik/vanillatweaks/VanillaTweaks.java @@ -3,6 +3,7 @@ package nl.kallestruik.vanillatweaks; import nl.kallestruik.vanillatweaks.ArmorStandSwapping.ArmorStandSwappingHandler; import nl.kallestruik.vanillatweaks.CraftingTweaks.CraftingTweaks; import nl.kallestruik.vanillatweaks.HoeHarvesting.HoeHarvestingHandler; +import nl.kallestruik.vanillatweaks.LilypadGrowing.LilypadGrowingHandler; import nl.kallestruik.vanillatweaks.NetherSpongeDrying.NetherSpongeHandler; import nl.kallestruik.vanillatweaks.SeedDropPlanting.SeedDropPlanting; import nl.kallestruik.vanillatweaks.ToggleTrample.CommandToggletrample; @@ -12,6 +13,7 @@ import org.bukkit.plugin.java.JavaPlugin; import java.io.*; +@SuppressWarnings("ConstantConditions") public final class VanillaTweaks extends JavaPlugin { @Override @@ -30,12 +32,6 @@ public final class VanillaTweaks extends JavaPlugin { CraftingTweaks.init(this); } - /** - * Dynamite - * - * Throwable tnt with a smaller explosion. - */ - if (config.SEED_DROP_PLANTING_ENABLED) { SeedDropPlanting.init(this); } @@ -52,6 +48,10 @@ public final class VanillaTweaks extends JavaPlugin { getServer().getPluginManager().registerEvents(new HoeHarvestingHandler(), this); } + if (config.LILYPAD_GROWING_ENABLED) { + getServer().getPluginManager().registerEvents(new LilypadGrowingHandler(), this); + } + } catch (IOException | InvalidConfigurationException | NullPointerException e) { diff --git a/src/main/java/nl/kallestruik/vanillatweaks/c.java b/src/main/java/nl/kallestruik/vanillatweaks/c.java index baba27b..47ced53 100644 --- a/src/main/java/nl/kallestruik/vanillatweaks/c.java +++ b/src/main/java/nl/kallestruik/vanillatweaks/c.java @@ -1,5 +1,6 @@ package nl.kallestruik.vanillatweaks; +@SuppressWarnings("WeakerAccess") public class c { public static final String CONFIG_FILE_NAME = "config.yml"; public static String TRAMPLE_ENABLED_FILE_NAME = "tramplestore.yml"; diff --git a/src/main/java/nl/kallestruik/vanillatweaks/config.java b/src/main/java/nl/kallestruik/vanillatweaks/config.java index e9e23db..681aca3 100644 --- a/src/main/java/nl/kallestruik/vanillatweaks/config.java +++ b/src/main/java/nl/kallestruik/vanillatweaks/config.java @@ -6,6 +6,7 @@ import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; import java.io.IOException; +@SuppressWarnings({"WeakerAccess", "ResultOfMethodCallIgnored"}) public class config { public static boolean TOGGLE_TRAMPLE_ENABLED; @@ -33,6 +34,8 @@ public class config { public static int HOE_HARVESTING_RANGE_GOLD; public static int HOE_HARVESTING_RANGE_DIAMOND; + public static boolean LILYPAD_GROWING_ENABLED; + public static void load(File file) throws IOException, InvalidConfigurationException { if (!file.getParentFile().exists()) file.getParentFile().mkdirs(); @@ -66,6 +69,7 @@ public class config { HOE_HARVESTING_RANGE_GOLD = config.getInt("hoe-harvesting.ranges.gold"); HOE_HARVESTING_RANGE_DIAMOND = config.getInt("hoe-harvesting.ranges.diamond"); + LILYPAD_GROWING_ENABLED = config.getBoolean("lilypad-growing.enabled"); } } diff --git a/src/main/java/nl/kallestruik/vanillatweaks/util.java b/src/main/java/nl/kallestruik/vanillatweaks/util.java index d07ceea..5427301 100644 --- a/src/main/java/nl/kallestruik/vanillatweaks/util.java +++ b/src/main/java/nl/kallestruik/vanillatweaks/util.java @@ -1,12 +1,18 @@ package nl.kallestruik.vanillatweaks; +import org.bukkit.util.Vector; + import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; +import java.util.Random; +@SuppressWarnings("WeakerAccess") public class util { + private static final Random random = new Random(); + public static void printException(Exception e) { System.err.println("-------------------------------------------------------------------------------------"); System.err.println("An error seems to have occurred. A detailed stacktrace of the error is printed below."); @@ -29,4 +35,15 @@ public class util { util.printException(ex); } } + + public static Vector getRandomLocationOffset(int min, int max, boolean height) { + Vector vec; + if (height) + vec = new Vector(min + random.nextInt(max - min), min + random.nextInt(max - min), min + random.nextInt(max - min)); + else + vec = new Vector(min + random.nextInt(max - min), 0, min + random.nextInt(max - min)); + + vec.multiply(new Vector(random.nextBoolean() ? -1 : 1, random.nextBoolean() ? -1 : 1, random.nextBoolean() ? -1 : 1)); + return vec; + } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index e255953..9b3ca78 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -28,4 +28,7 @@ hoe-harvesting: stone: 1 iron: 1 gold: 1 - diamond: 2 \ No newline at end of file + diamond: 2 + +lilypad-growing: + enabled: true \ No newline at end of file