diff --git a/plugin.yml b/plugin.yml
deleted file mode 100644
index 2f475c5..0000000
--- a/plugin.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-name: Floristics
-main: land.jay.floristics.Floristics
-version: 2.5.1
-api-version: 1.15
-softdepend: [GriefPrevention, WorldGuard, RedProtect, Towny]
-commands:
- floristics:
- aliases: flo
- description: enable or disable growth in GriefPrevention claims or Towny towns
- usage: /floristics ...
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..f5c4c3c
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,77 @@
+
+
+ 4.0.0
+
+ land.jay.floristics
+ Floristics
+ 1.0-SNAPSHOT
+ jar
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.9.0
+
+
+ compile
+ compile
+
+ compile
+
+
+
+ testCompile
+ test-compile
+
+ testCompile
+
+
+
+
+ 17
+ 17
+
+
+
+
+
+ src/main/resources
+ true
+
+
+
+
+
+
+
+ papermc
+ https://papermc.io/repo/repository/maven-public/
+
+
+ jitpack.io
+ https://jitpack.io
+
+
+
+
+
+ io.papermc.paper
+ paper-api
+ 1.18.2-R0.1-SNAPSHOT
+ provided
+
+
+ com.github.TownyAdvanced
+ Towny
+ 0.98.2.0
+ provided
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/land/jay/floristics/compat/GriefPreventionWrapper.java b/src/land/jay/floristics/compat/GriefPreventionWrapper.java
deleted file mode 100644
index e8380a7..0000000
--- a/src/land/jay/floristics/compat/GriefPreventionWrapper.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/** Copyright (C) 2019 Jay Avery */
-package land.jay.floristics.compat;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.List;
-import java.util.Set;
-import java.util.logging.Level;
-import org.bukkit.Bukkit;
-import org.bukkit.Location;
-import org.bukkit.command.CommandSender;
-import org.bukkit.configuration.file.YamlConfiguration;
-import org.bukkit.entity.Player;
-import com.google.common.base.Charsets;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import land.jay.floristics.Floristics;
-import me.ryanhamshire.GriefPrevention.Claim;
-import me.ryanhamshire.GriefPrevention.GriefPrevention;
-
-/** Wrapper class for GriefPrevention API calls. */
-public class GriefPreventionWrapper {
-
- /** File to store claims. */
- private static File claimsFile;
- /** Config to interact with claims. */
- private static YamlConfiguration claimsConfig;
- /** Set of claims with growth enabled. */
- private static Set enabledClaims = Sets.newHashSet();
-
- /** @return Whether compatibility was successfully set up. */
- public static boolean onEnable() {
-
- Floristics.info("GriefPrevention is present, preparing gp.yml.");
-
- claimsFile = new File(Floristics.instance.getDataFolder(), "gp.yml");
- if (!claimsFile.exists()) {
- Floristics.instance.saveResource("gp.yml", false);
- }
-
- InputStream stream = Floristics.instance.getResource("gp.yml");
- claimsConfig = YamlConfiguration.loadConfiguration(claimsFile);
- claimsConfig.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(stream, Charsets.UTF_8)));
- List list = claimsConfig.getLongList("gp");
- enabledClaims.addAll(list);
- return true;
- }
-
- public static boolean canGrow(Location location) {
-
- Claim claim = GriefPrevention.instance.dataStore.getClaimAt(location, true, null);
- return claim == null || enabledClaims.contains(claim.getID());
- }
-
- public static void handleCommand(CommandSender sender, String[] args) {
-
- boolean validInfo = args.length == 1;
- boolean validChange = args.length == 2 && (args[1].equals("enable") || args[1].equals("disable"));
-
- if (!(sender instanceof Player)) {
- sender.sendMessage("You must be a player to use this command.");
- return;
- }
-
- Player player = (Player) sender;
-
- if (!validInfo && !validChange) {
- player.sendMessage("Unknown command or invalid arguments. Valid uses:\n" +
- "/floristics gp - display whether growth is enabled in this GriefPrevention claim\n" +
- "/floristics gp - enable or disable growth in this GriefPrevention claim\n" +
- "Or replace /floristics with /flo for convenience.");
- return;
- }
-
- Claim claim = GriefPrevention.instance.dataStore.getClaimAt(player.getLocation(), true, null);
-
- if (claim == null || claim.allowEdit(player) != null) {
- player.sendMessage("You are not in one of your claims.");
- return;
- }
-
- Long id = claim.getID();
-
- if (validChange) {
- if (args[1].equals("enable")) {
- enabledClaims.add(id);
- player.sendMessage("Growth enabled in this claim.");
- } else if (args[1].equals("disable")) {
- enabledClaims.remove(id);
- player.sendMessage("Growth disabled in this claim.");
- }
- claimsConfig.set("gp", Lists.newArrayList(enabledClaims));
-
- try {
- claimsConfig.save(claimsFile);
- } catch (IOException ex) {
- Floristics.error("Error saving gp.yml!", ex);
- }
-
- } else {
- player.sendMessage("Growth in this claim is currently " + (enabledClaims.contains(id) ? "enabled." : "disabled."));
- }
- }
-}
diff --git a/src/land/jay/floristics/compat/RedProtectWrapper.java b/src/land/jay/floristics/compat/RedProtectWrapper.java
deleted file mode 100644
index 14245bb..0000000
--- a/src/land/jay/floristics/compat/RedProtectWrapper.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/** Copyright (C) 2019 Jay Avery */
-package land.jay.floristics.compat;
-
-import org.bukkit.Bukkit;
-import org.bukkit.Location;
-import br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect;
-import br.net.fabiozumbi12.RedProtect.Bukkit.Region;
-import land.jay.floristics.Floristics;
-
-/** Wrapper class for RedProtect API calls. */
-public class RedProtectWrapper {
-
- /** @return Whether compatibility was successfully set up. */
- public static boolean onEnable() {
-
- try {
- Floristics.info("RedProtect is present, adding flag to API.");
- RedProtect.get().getAPI().addFlag("floristics", false, false);
- return true;
- } catch (Exception ex) {
- Floristics.error("Something went wrong integrating with RedProtect, this should never happen!\n" +
- "RedProtect compatibility will be DISABLED.", ex);
- return false;
- }
- }
-
- public static boolean canGrow(Location location) {
-
- Region region = RedProtect.get().getAPI().getRegion(location);
- return region == null || region.getFlagBool("floristics");
- }
-}
diff --git a/src/land/jay/floristics/compat/WorldGuardWrapper.java b/src/land/jay/floristics/compat/WorldGuardWrapper.java
deleted file mode 100644
index bb4fe6b..0000000
--- a/src/land/jay/floristics/compat/WorldGuardWrapper.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/** Copyright (C) 2019 Jay Avery */
-package land.jay.floristics.compat;
-
-import org.bukkit.Location;
-import com.sk89q.worldedit.bukkit.BukkitAdapter;
-import com.sk89q.worldguard.WorldGuard;
-import com.sk89q.worldguard.protection.flags.StateFlag;
-import com.sk89q.worldguard.protection.flags.StateFlag.State;
-import com.sk89q.worldguard.protection.flags.registry.FlagConflictException;
-import com.sk89q.worldguard.protection.regions.RegionQuery;
-import land.jay.floristics.Floristics;
-
-/** Wrapper class for WorldGuard API calls. */
-public class WorldGuardWrapper {
-
- /** Custom flag for growth permission. */
- private static StateFlag FLAG = new StateFlag("floristics", false);
-
- /** @return Whether compatibility was successfully set up. */
- public static boolean onLoad() {
-
- Floristics.info("WorldGuard is present, adding flag to registry.");
- try {
- WorldGuard.getInstance().getFlagRegistry().register(FLAG);
- return true;
- } catch (FlagConflictException ex) {
- Floristics.error("Someone has already registered a floristics flag for WorldGuard, this should never happen!\n" +
- "WorldGuard compatibility will be DISABLED.", ex);
- return false;
- }
- }
-
- public static boolean canGrow(Location location) {
-
- RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
- State result = query.getApplicableRegions(BukkitAdapter.adapt(location)).queryValue(null, FLAG);
- return result == null || result == State.ALLOW;
- }
-}
diff --git a/src/land/jay/floristics/BiomeGrower.java b/src/main/java/land/jay/floristics/BiomeGrower.java
similarity index 94%
rename from src/land/jay/floristics/BiomeGrower.java
rename to src/main/java/land/jay/floristics/BiomeGrower.java
index d29f1e7..8dfa84c 100644
--- a/src/land/jay/floristics/BiomeGrower.java
+++ b/src/main/java/land/jay/floristics/BiomeGrower.java
@@ -80,7 +80,7 @@ public enum BiomeGrower {
this.add(new MushroomGrower(Material.RED_MUSHROOM, 0.01, 0.12, true));
this.add(new SugarcaneGrower(0.4, 0.25));
}},
- MOUNTAINS {{
+ MOUNTAIN {{
this.add(new BushGrower(Material.GRASS, false, 0.15, SurfaceType.DIRT, 0.13));
this.add(new BushGrower(Material.DANDELION, false, 0.02, SurfaceType.DIRT, 0.01));
this.add(new BushGrower(Material.POPPY, false, 0.02, SurfaceType.DIRT, 0.01));
@@ -373,56 +373,54 @@ public static void handleGrowth(World world, int x, int z) {
/** @return The appropriate BiomeGrower for the given Biome. */
private static BiomeGrower get(Biome biome) {
-
+
switch (biome) {
-
- case PLAINS:
+
+ case PLAINS: case MEADOW:
return PLAINS;
case SUNFLOWER_PLAINS:
return SUNFLOWER_PLAINS;
case OCEAN: case DEEP_OCEAN: case COLD_OCEAN: case DEEP_COLD_OCEAN: case LUKEWARM_OCEAN: case DEEP_LUKEWARM_OCEAN:
return COOL_OCEAN;
- case WARM_OCEAN: case DEEP_WARM_OCEAN:
+ case WARM_OCEAN:
return WARM_OCEAN;
- case DESERT: case DESERT_HILLS: case DESERT_LAKES:
+ case DESERT:
return DESERT;
- case MOUNTAINS: case MOUNTAIN_EDGE: case GRAVELLY_MOUNTAINS: case MODIFIED_GRAVELLY_MOUNTAINS:
- return MOUNTAINS;
- case WOODED_MOUNTAINS:
- return WOODED_MOUNTAINS;
- case FOREST: case WOODED_HILLS:
+ case STONY_PEAKS:
+ return MOUNTAIN;
+ case FOREST:
return FOREST;
- case TAIGA: case TAIGA_HILLS: case TAIGA_MOUNTAINS:
+ case TAIGA:
return TAIGA;
- case SNOWY_TAIGA: case SNOWY_TAIGA_HILLS: case SNOWY_TAIGA_MOUNTAINS:
+ case SNOWY_TAIGA: case GROVE:
return SNOWY_TAIGA;
- case GIANT_TREE_TAIGA: case GIANT_TREE_TAIGA_HILLS: case GIANT_SPRUCE_TAIGA: case GIANT_SPRUCE_TAIGA_HILLS:
+ case OLD_GROWTH_PINE_TAIGA: case OLD_GROWTH_SPRUCE_TAIGA:
return MEGA_TAIGA;
- case SWAMP: case SWAMP_HILLS:
+ case SWAMP:
return SWAMP;
- case SNOWY_TUNDRA: case SNOWY_MOUNTAINS:
+ case SNOWY_PLAINS: case SNOWY_SLOPES: case JAGGED_PEAKS: case FROZEN_PEAKS:
return TUNDRA;
- case MUSHROOM_FIELDS: case MUSHROOM_FIELD_SHORE:
+ case MUSHROOM_FIELDS:
return MUSHROOM;
- case JUNGLE: case JUNGLE_HILLS: case MODIFIED_JUNGLE:
+ case JUNGLE:
return JUNGLE;
- case JUNGLE_EDGE: case MODIFIED_JUNGLE_EDGE:
+ case SPARSE_JUNGLE:
return JUNGLE_EDGE;
- case BAMBOO_JUNGLE: case BAMBOO_JUNGLE_HILLS:
+ case BAMBOO_JUNGLE:
return BAMBOO_JUNGLE;
- case SAVANNA: case SAVANNA_PLATEAU: case SHATTERED_SAVANNA: case SHATTERED_SAVANNA_PLATEAU:
+ case SAVANNA: case SAVANNA_PLATEAU: case WINDSWEPT_SAVANNA:
return SAVANNA;
- case BADLANDS: case BADLANDS_PLATEAU: case MODIFIED_BADLANDS_PLATEAU: case ERODED_BADLANDS:
+ case BADLANDS: case ERODED_BADLANDS:
return BADLANDS;
- case WOODED_BADLANDS_PLATEAU: case MODIFIED_WOODED_BADLANDS_PLATEAU:
+ case WOODED_BADLANDS:
return WOODED_BADLANDS;
- case DARK_FOREST: case DARK_FOREST_HILLS:
+ case DARK_FOREST:
return DARK_FOREST;
case FLOWER_FOREST:
return FLOWER_FOREST;
- case BIRCH_FOREST: case BIRCH_FOREST_HILLS:
+ case BIRCH_FOREST:
return BIRCH_FOREST;
- case TALL_BIRCH_FOREST: case TALL_BIRCH_HILLS:
+ case OLD_GROWTH_BIRCH_FOREST:
return TALL_BIRCH;
case RIVER:
return RIVER;
@@ -430,9 +428,9 @@ private static BiomeGrower get(Biome biome) {
return END;
case BEACH:
return BEACH;
- case NETHER:
+ case BASALT_DELTAS: case NETHER_WASTES: case WARPED_FOREST: case CRIMSON_FOREST: case SOUL_SAND_VALLEY:
return NETHER;
- case FROZEN_OCEAN: case DEEP_FROZEN_OCEAN: case THE_END: case FROZEN_RIVER: case STONE_SHORE: case SNOWY_BEACH: case SMALL_END_ISLANDS: case END_MIDLANDS: case END_BARRENS: case THE_VOID: case ICE_SPIKES:
+ case FROZEN_OCEAN: case DEEP_FROZEN_OCEAN: case THE_END: case FROZEN_RIVER: case STONY_SHORE: case SNOWY_BEACH: case SMALL_END_ISLANDS: case END_MIDLANDS: case END_BARRENS: case THE_VOID: case ICE_SPIKES:
default:
return BARREN;
}
diff --git a/src/land/jay/floristics/Floristics.java b/src/main/java/land/jay/floristics/Floristics.java
similarity index 65%
rename from src/land/jay/floristics/Floristics.java
rename to src/main/java/land/jay/floristics/Floristics.java
index 833fd32..c44a3c5 100644
--- a/src/land/jay/floristics/Floristics.java
+++ b/src/main/java/land/jay/floristics/Floristics.java
@@ -2,6 +2,7 @@
package land.jay.floristics;
import java.io.File;
+import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import java.util.logging.Level;
@@ -10,15 +11,14 @@
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
+import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import com.google.common.collect.Sets;
-import land.jay.floristics.compat.GriefPreventionWrapper;
-import land.jay.floristics.compat.RedProtectWrapper;
import land.jay.floristics.compat.TownyWrapper;
-import land.jay.floristics.compat.WorldGuardWrapper;
public class Floristics extends JavaPlugin {
@@ -33,19 +33,15 @@ public class Floristics extends JavaPlugin {
/** Config growth attempts per cycle. */
private static int growths = 1;
/** Config worlds to grow in. */
- private static Set worlds = Sets.newHashSet();
+ private static final Set worlds = new HashSet<>();
/** Config plants to grow. */
- private static Set plants = Sets.newHashSet();
-
- /** Whether GriefPrevention is present. */
- private static boolean hasGp = false;
- /** Whether WorldGuard is present. */
- private static boolean hasWg = false;
- /** Whether RedProtect is present. */
- private static boolean hasRp = false;
+ private static final Set plants = new HashSet<>();
/** Whether Towny is present. */
private static boolean hasTy = false;
+ /** CCNet - max MSPT for growth */
+ private static int maxMSPT = 40;
+
@Override
public void onLoad() {
@@ -62,6 +58,7 @@ public void onLoad() {
delay = this.getConfig().getInt("delay");
growths = this.getConfig().getInt("growths");
+ maxMSPT = this.getConfig().getInt("max-mspt");
worlds.addAll(this.getConfig().getStringList("worlds"));
ConfigurationSection section = this.getConfig().getConfigurationSection("plants");
for (String key : section.getKeys(false)) {
@@ -70,12 +67,7 @@ public void onLoad() {
}
}
- hasGp = Bukkit.getPluginManager().getPlugin("GriefPrevention") != null;
- hasWg = Bukkit.getPluginManager().getPlugin("WorldGuard") != null;
- hasRp = Bukkit.getPluginManager().getPlugin("RedProtect") != null;
hasTy = Bukkit.getPluginManager().getPlugin("Towny") != null;
-
- if (hasWg) { hasWg = WorldGuardWrapper.onLoad(); }
if (hasTy) { hasTy = TownyWrapper.onLoad(); }
}
@@ -83,22 +75,43 @@ public void onLoad() {
public void onEnable() {
this.getCommand("floristics").setExecutor(this);
-
- if (hasGp) { hasGp = GriefPreventionWrapper.onEnable(); }
- if (hasRp) { hasRp = RedProtectWrapper.onEnable(); }
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this,
() -> this.growCycle(), delay, delay);
}
-
+
/** Attempts growth in each enabled world. */
private void growCycle() {
-
+ // Skip if average MSPT is greater than growth MSPT limit
+ if (Bukkit.getServer().getAverageTickTime() > maxMSPT) {
+ return;
+ }
+
+ for (Player player: Bukkit.getOnlinePlayers()) {
+ World world = player.getWorld();
+ if (!worlds.contains(world.getName())) {
+ continue;
+ }
+
+ int x = RAND.nextInt(player.getViewDistance() * 16);
+ int z = RAND.nextInt(player.getViewDistance() * 16);
+
+ Block block = world.getBlockAt(x, 64, z);
+ if (!block.getLocation().isChunkLoaded()) {
+ world.getChunkAtAsync(block.getLocation()).thenAccept(chunk -> BiomeGrower.handleGrowth(world, chunk.getX(), chunk.getZ()));
+ }
+ else {
+ Chunk chunk = block.getChunk();
+ BiomeGrower.handleGrowth(world, chunk.getX(), chunk.getZ());
+ }
+ }
+
+ /*
for (World world : Bukkit.getWorlds()) {
if (worlds.contains(world.getName())) {
Chunk[] chunks = world.getLoadedChunks();
if (chunks.length > 0) {
- for (int i = 0; i < growths; i++) {
+ for (int i = 0; i < Bukkit.getServer().getOnlinePlayers().size(); i++) {
Chunk chunk = chunks[RAND.nextInt(chunks.length)];
int x = (chunk.getX() * 16) + RAND.nextInt(16);
int z = (chunk.getZ() * 16) + RAND.nextInt(16);
@@ -107,6 +120,7 @@ private void growCycle() {
}
}
}
+ */
}
/** @return Whether growth of this plant is enabled. */
@@ -116,42 +130,21 @@ public static boolean isEnabled(Material material) {
/** @return Whether growth is allowed at this location. */
public static boolean hasPermission(Location location) {
-
- boolean result = true;
- result = hasGp ? result && GriefPreventionWrapper.canGrow(location) : result;
- result = hasWg ? result && WorldGuardWrapper.canGrow(location) : result;
- result = hasRp ? result && RedProtectWrapper.canGrow(location) : result;
- result = hasTy ? result && TownyWrapper.canGrow(location) : result;
- return result;
+ return TownyWrapper.canGrow(location);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- if (!hasGp && !hasTy) {
+ if (!hasTy) {
sender.sendMessage("This command is only for use with GriefPrevention or Towny.");
return true;
}
-
- if (args.length > 0 && args[0].equals("gp")) {
- if (hasGp) {
- GriefPreventionWrapper.handleCommand(sender, args);
- } else {
- sender.sendMessage("This command is only for use with GriefPrevention.");
- }
- } else if (args.length > 0 && args[0].equals("towny")) {
+
+ if (args.length > 0 && args[0].equals("towny")) {
if (hasTy) {
TownyWrapper.handleCommand(sender, args);
} else {
- sender.sendMessage("This command is only for use with Towny.");
- }
- } else {
- if (hasGp && hasTy) {
- sender.sendMessage("Use /floristics gp [enable|disable] for GriefPrevention permissions.\n" +
- "or /floristics towny [enable|disable] for Towny permissions.");
- } else if (hasGp) {
- sender.sendMessage("Use /floristics gp [enable|disable] for GriefPrevention permissions.");
- } else if (hasTy) {
sender.sendMessage("Use /floristics towny [enable|disable] for Towny permissions.");
}
}
diff --git a/src/land/jay/floristics/compat/TownyWrapper.java b/src/main/java/land/jay/floristics/compat/TownyWrapper.java
similarity index 77%
rename from src/land/jay/floristics/compat/TownyWrapper.java
rename to src/main/java/land/jay/floristics/compat/TownyWrapper.java
index 09234f1..bfad1aa 100644
--- a/src/land/jay/floristics/compat/TownyWrapper.java
+++ b/src/main/java/land/jay/floristics/compat/TownyWrapper.java
@@ -1,6 +1,8 @@
/** Copyright (C) 2019 Jay Avery */
package land.jay.floristics.compat;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -29,36 +31,30 @@ public static boolean onLoad() {
} catch (KeyAlreadyRegisteredException ex) {
Floristics.error("Someone has already registered a floristics field for Towny, this should never happen!\n" +
"Towny compatibility will be DISABLED.", ex);
- return false;
+ return true;
}
}
public static boolean canGrow(Location location) {
-
- Town town;
- try {
- TownBlock block = TownyAPI.getInstance().getTownBlock(location);
- town = block == null ? null : block.getTown();
- } catch (NotRegisteredException ex) {
- Floristics.error("Something went wrong in the Towny API, this should never happen!", ex);
- return false;
- }
-
- if (town == null) {
- return true;
- }
+
+ return TownyAPI.getInstance().isWilderness(location);
+
+ /*
if (!town.hasMeta() || !town.getMetadata().contains(FIELD)) {
town.addMetaData(FIELD);
}
+
BooleanDataField field = null;
for (CustomDataField metadata : town.getMetadata()) {
if (metadata.equals(FIELD)) {
field = (BooleanDataField) metadata;
}
}
-
+
return field.getValue();
+
+ */
}
public static void handleCommand(CommandSender sender, String[] args) {
@@ -81,25 +77,21 @@ public static void handleCommand(CommandSender sender, String[] args) {
return;
}
- Resident resident;
- Town town;
- try {
- resident = TownyAPI.getInstance().getDataSource().getResident(player.getName());
- TownBlock block = TownyAPI.getInstance().getTownBlock(player.getLocation());
- town = block == null ? null : block.getTown();
- } catch (NotRegisteredException ex) {
- Floristics.error("Something went wrong in the Towny API, this should never happen!", ex);
+ Resident resident = TownyAPI.getInstance().getResident(player.getUniqueId());
+ if (resident == null) {
+ player.sendMessage(Component.text("Error: could not find your resident data!", NamedTextColor.RED));
return;
}
-
- if (town == null || !town.isMayor(resident)) {
- player.sendMessage("You are not in a Town you own.");
- return;
+
+ Town town = TownyAPI.getInstance().getResidentTownOrNull(resident);
+ if (!resident.isMayor() || town == null) {
+ player.sendMessage(Component.text("You are not a town mayor.", NamedTextColor.RED));
}
if (!town.getMetadata().contains(FIELD)) {
town.addMetaData(FIELD);
}
+
BooleanDataField field = null;
for (CustomDataField metadata : town.getMetadata()) {
if (metadata.equals(FIELD)) {
diff --git a/src/land/jay/floristics/plants/BeeGrower.java b/src/main/java/land/jay/floristics/plants/BeeGrower.java
similarity index 100%
rename from src/land/jay/floristics/plants/BeeGrower.java
rename to src/main/java/land/jay/floristics/plants/BeeGrower.java
diff --git a/src/land/jay/floristics/plants/BushGrower.java b/src/main/java/land/jay/floristics/plants/BushGrower.java
similarity index 100%
rename from src/land/jay/floristics/plants/BushGrower.java
rename to src/main/java/land/jay/floristics/plants/BushGrower.java
diff --git a/src/land/jay/floristics/plants/CactusGrower.java b/src/main/java/land/jay/floristics/plants/CactusGrower.java
similarity index 100%
rename from src/land/jay/floristics/plants/CactusGrower.java
rename to src/main/java/land/jay/floristics/plants/CactusGrower.java
diff --git a/src/land/jay/floristics/plants/MushroomGrower.java b/src/main/java/land/jay/floristics/plants/MushroomGrower.java
similarity index 100%
rename from src/land/jay/floristics/plants/MushroomGrower.java
rename to src/main/java/land/jay/floristics/plants/MushroomGrower.java
diff --git a/src/land/jay/floristics/plants/PlantGrower.java b/src/main/java/land/jay/floristics/plants/PlantGrower.java
similarity index 93%
rename from src/land/jay/floristics/plants/PlantGrower.java
rename to src/main/java/land/jay/floristics/plants/PlantGrower.java
index f930784..0e87a30 100644
--- a/src/land/jay/floristics/plants/PlantGrower.java
+++ b/src/main/java/land/jay/floristics/plants/PlantGrower.java
@@ -33,10 +33,9 @@ protected boolean isPresent(World world, int x, int z) {
int chunkX = x >> 4;
int chunkZ = z >> 4;
Random random = new Random(world.getSeed() +
- (this.material.ordinal() * chunkX * 0x4c1906) + (chunkX * 0x5ac0db) +
- (this.material.ordinal() * 0x4307a7L) + (chunkZ * 0x5f24f) ^ 0x3ad8025f);
- boolean result = random.nextFloat() < this.chance;
- return result;
+ ((long) this.material.ordinal() * chunkX * 0x4c1906) + (chunkX * 0x5ac0dbL) +
+ (this.material.ordinal() * 0x4307a7L) + (chunkZ * 0x5f24fL) ^ 0x3ad8025f);
+ return random.nextFloat() < this.chance;
}
/** Attempts to grow this plant. */
diff --git a/src/land/jay/floristics/plants/SugarcaneGrower.java b/src/main/java/land/jay/floristics/plants/SugarcaneGrower.java
similarity index 100%
rename from src/land/jay/floristics/plants/SugarcaneGrower.java
rename to src/main/java/land/jay/floristics/plants/SugarcaneGrower.java
diff --git a/src/land/jay/floristics/plants/TreeGrower.java b/src/main/java/land/jay/floristics/plants/TreeGrower.java
similarity index 94%
rename from src/land/jay/floristics/plants/TreeGrower.java
rename to src/main/java/land/jay/floristics/plants/TreeGrower.java
index 232f8a8..660d7cf 100644
--- a/src/land/jay/floristics/plants/TreeGrower.java
+++ b/src/main/java/land/jay/floristics/plants/TreeGrower.java
@@ -2,6 +2,8 @@
package land.jay.floristics.plants;
import java.util.Set;
+
+import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.TreeType;
import org.bukkit.World;
@@ -42,8 +44,13 @@ public void grow(World world, int x, int z) {
/** Attempts to place this tree at the location. */
protected void placeTree(World world, int x, int z) {
- Block placeBlock = world.getHighestBlockAt(x, z);
+ Block placeBlock = world.getHighestBlockAt(x, z).getRelative(BlockFace.UP);
+
Block surfaceBlock = placeBlock.getRelative(BlockFace.DOWN);
+ if (surfaceBlock.isLiquid()) {
+ return;
+ }
+
Material surfaceMaterial = surfaceBlock.getType();
while (SEARCH_DOWN.contains(surfaceMaterial)) {
diff --git a/config.yml b/src/main/resources/config.yml
similarity index 95%
rename from config.yml
rename to src/main/resources/config.yml
index 18b50b7..89fb664 100644
--- a/config.yml
+++ b/src/main/resources/config.yml
@@ -1,6 +1,7 @@
config-version: 5 # Do not edit! Used for internal checks
delay: 1 # Number of ticks between growth cycles
growths: 1 # Number of growth attempts per cycle
+max-mspt: 40 # MSPT above which to stop growing
worlds: # List of worlds growth should happen in
- world
- world_the_end
@@ -41,7 +42,7 @@ plants: # Whether each plant should grow
COCOA: true # Jungle tree with cocoa beans
SPRUCE_LOG: true # Spruce tree
DARK_OAK_LOG: true # Dark oak tree
- ACACIA_LOG: true # Acacia tree
+ ACACIA_LOG: false # Acacia tree
LILY_PAD: true # Lily pad
SEAGRASS: true # Single-height seagrass
TALL_SEAGRASS: true # Double-height seagrass
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
new file mode 100644
index 0000000..4065b5b
--- /dev/null
+++ b/src/main/resources/plugin.yml
@@ -0,0 +1,10 @@
+name: Floristics
+main: land.jay.floristics.Floristics
+version: 2.6
+api-version: 1.18
+softdepend: [Towny]
+commands:
+ floristics:
+ aliases: flo
+ description: enable or disable growth in Towny towns
+ usage: /floristics ...