From 3ced411b102a23f7a4c8f0b644a850869d0019b5 Mon Sep 17 00:00:00 2001 From: EpiCanard Date: Thu, 16 Jul 2020 01:12:36 +0200 Subject: [PATCH] Add support of ancient debris --- pom.xml | 52 +++---------------- .../be/bendem/bukkit/orebroadcast/Config.java | 12 +++-- .../orebroadcast/commands/CommandHandler.java | 2 +- .../orebroadcast/commands/HelpCommand.java | 11 +++- src/main/resources/config.yml | 30 ++++++----- src/main/resources/plugin.yml | 7 +-- 6 files changed, 47 insertions(+), 67 deletions(-) diff --git a/pom.xml b/pom.xml index 1487b45..d213995 100644 --- a/pom.xml +++ b/pom.xml @@ -5,15 +5,14 @@ 4.0.0 be.bendem.bukkit OreBroadcast - 3.0.1 + 3.1.0 jar - Ore Broadcaster - https://github.com/graywolf336/OreBroadcast + OreBroadcast + https://github.com/FreebuildFR/OreBroadcast UTF-8 - 0 @@ -27,25 +26,11 @@ org.spigotmc spigot-api - 1.13.2-R0.1-SNAPSHOT + 1.16.1-R0.1-SNAPSHOT provided - - - jenkins - - - env.BUILD_NUMBER - - - - ${env.BUILD_NUMBER} - - - - target target/classes @@ -74,30 +59,6 @@ - - - com.google.code.maven-replacer-plugin - maven-replacer-plugin - 1.3.8 - - - prepare-package - - replace - - - - - target/classes/plugin.yml - - - maven-version-number - ${project.version}-b${project.build.number} - - - - - org.apache.maven.plugins @@ -106,8 +67,9 @@ - graywolf336 - + FreebuildFR + ${project.version} + diff --git a/src/main/java/be/bendem/bukkit/orebroadcast/Config.java b/src/main/java/be/bendem/bukkit/orebroadcast/Config.java index 6a9f7f0..962dab1 100644 --- a/src/main/java/be/bendem/bukkit/orebroadcast/Config.java +++ b/src/main/java/be/bendem/bukkit/orebroadcast/Config.java @@ -7,18 +7,17 @@ import java.util.Set; public class Config { - private final OreBroadcast plugin; private final Set broadcastBlacklist = new HashSet<>(); private final Set blocksToBroadcast = new HashSet<>(); private final Set worldWhitelist = new HashSet<>(); private boolean worldWhitelistActive = false; - + protected Config(OreBroadcast plugin) { this.plugin = plugin; plugin.saveDefaultConfig(); } - + protected void loadConfig() { plugin.reloadConfig(); // Create the list of materials to broadcast from the file @@ -26,7 +25,7 @@ protected void loadConfig() { blocksToBroadcast.clear(); for (String item : configList) { - Material material = Material.getMaterial(item.toUpperCase() + "_ORE"); + Material material = this.getMaterial(item.toUpperCase()); blocksToBroadcast.add(material); } @@ -53,4 +52,9 @@ protected Set getWorldWhitelist() { protected boolean isWorldWhitelistActive() { return worldWhitelistActive; } + + private Material getMaterial(final String materialName) { + final Material material = Material.getMaterial(materialName + "_ORE"); + return (material == null) ? Material.getMaterial(materialName) : material; + } } diff --git a/src/main/java/be/bendem/bukkit/orebroadcast/commands/CommandHandler.java b/src/main/java/be/bendem/bukkit/orebroadcast/commands/CommandHandler.java index e9bc4f5..6675331 100644 --- a/src/main/java/be/bendem/bukkit/orebroadcast/commands/CommandHandler.java +++ b/src/main/java/be/bendem/bukkit/orebroadcast/commands/CommandHandler.java @@ -24,7 +24,7 @@ public CommandHandler(JavaPlugin plugin, String command) { plugin.getCommand(cmdName).setExecutor(this); plugin.getCommand(cmdName).setTabCompleter(this); - register(new HelpCommand(this)); + register(new HelpCommand(this, plugin)); } public void register(Command cmd) { diff --git a/src/main/java/be/bendem/bukkit/orebroadcast/commands/HelpCommand.java b/src/main/java/be/bendem/bukkit/orebroadcast/commands/HelpCommand.java index f6389b4..1067d8b 100644 --- a/src/main/java/be/bendem/bukkit/orebroadcast/commands/HelpCommand.java +++ b/src/main/java/be/bendem/bukkit/orebroadcast/commands/HelpCommand.java @@ -2,6 +2,7 @@ import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; +import org.bukkit.plugin.java.JavaPlugin; import java.util.List; @@ -11,15 +12,21 @@ public class HelpCommand extends Command { private final CommandHandler handler; + private final String pluginFullName; - protected HelpCommand(CommandHandler handler) { + protected HelpCommand(CommandHandler handler, JavaPlugin plugin) { super("help", "Displays the commands you can use", null); this.handler = handler; + this.pluginFullName = plugin.getDescription().getFullName(); } @Override public void execute(CommandSender sender, List args) { - StringBuilder builder = new StringBuilder("OreBroadcast commands: \n"); + StringBuilder builder = new StringBuilder() + .append(ChatColor.GOLD) + .append(this.pluginFullName) + .append(ChatColor.RESET) + .append("\nCommands: \n"); for (Command command : handler.getCommands().values()) { if (command.hasPermission(sender)) { builder.append("- ").append(ChatColor.BLUE).append(command.getName()).append(ChatColor.RESET); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 6813656..bf55c02 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,13 +1,14 @@ # A list of the ores which will be broadcasted when found. ores: - - coal - - iron - - gold - - lapis - - redstone - - quartz +# - coal +# - iron +# - gold +# - lapis +# - redstone +# - quartz +# - emerald - diamond - - emerald + - ancient_debris # The colors to use to color the ores in the broadcast message. # See the end of the file for a list of available colors. @@ -20,6 +21,7 @@ colors: quartz: white diamond: aqua emerald: green + ancient_debris: dark_aqua # The message to be broadcasted (you can use the tags {player_name}, {real_player_name}, # {count}, {plural}, {ore}, {ore_color} and {world}). @@ -28,7 +30,8 @@ colors: # + The {ore} tag will be replaced by {ore_color}{ore}. # + The "player_name" tag is the name of the player as it is set by different plugins, # "real_player_name" is the real pseudo of the player. -message: "&7[&eO&bR&aE&fS&7] &l{player_name}&r just found &l{count}&r block{plural} of {ore}!" +#message: "&7[&eO&bR&aE&fS&7] &l{player_name}&r just found &l{count}&r block{plural} of {ore}!" +message: "&6[ATTENTION] &l{player_name}&r &l{count}&r [&l&k{ore}&r]" # The text to add when more than one ore is found (Will be used to replace the {plural} tag). plural: s @@ -43,15 +46,18 @@ ore-translations: quartz: quartz diamond: diamond emerald: emerald + ancient_debris: "ancient debris" # Set this to true to only activate OreBroadcast in listed worlds. -active-per-worlds: false +active-per-worlds: true # List of worlds where OreBroadcast is active. # This has no effect if `active-per-world` is set to false! -#active-worlds: -# - world -# - world_nether +active-worlds: + - world + - world_overworld + - world_overworld2 + - ressources_overworld # Max size of a vein. If the size is greater, the vein is ignored, preventing server from freezing # (i.e. if mining a big structure made of a block to broadcast). diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 357eea0..d0b2a66 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,7 +1,8 @@ -name: OreBroadcaster +name: ${project.name} main: be.bendem.bukkit.orebroadcast.OreBroadcast -version: maven-version-number -authors: [bendem, graywolf336] +version: ${project.version} +author: bendem +authors: [graywolf336, EpiCanard] description: Send messages to other players when you find ores. api-version: 1.13