Skip to content

Commit

Permalink
Add support of ancient debris
Browse files Browse the repository at this point in the history
  • Loading branch information
EpiCanard committed Jul 15, 2020
1 parent 62d8b71 commit 3ced411
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 67 deletions.
52 changes: 7 additions & 45 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
<modelVersion>4.0.0</modelVersion>
<groupId>be.bendem.bukkit</groupId>
<artifactId>OreBroadcast</artifactId>
<version>3.0.1</version>
<version>3.1.0</version>
<packaging>jar</packaging>

<name>Ore Broadcaster</name>
<url>https://github.com/graywolf336/OreBroadcast</url>
<name>OreBroadcast</name>
<url>https://github.com/FreebuildFR/OreBroadcast</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.number>0</project.build.number>
</properties>

<repositories>
Expand All @@ -27,25 +26,11 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.13.2-R0.1-SNAPSHOT</version>
<version>1.16.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>

<profiles>
<profile>
<id>jenkins</id>
<activation>
<property>
<name>env.BUILD_NUMBER</name>
</property>
</activation>
<properties>
<project.build.number>${env.BUILD_NUMBER}</project.build.number>
</properties>
</profile>
</profiles>

<build>
<directory>target</directory>
<outputDirectory>target/classes</outputDirectory>
Expand Down Expand Up @@ -74,30 +59,6 @@
</configuration>
</plugin>

<!-- Token replacement plugin -->
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<version>1.3.8</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>target/classes/plugin.yml</file>
<replacements>
<replacement>
<token>maven-version-number</token>
<value>${project.version}-b${project.build.number}</value>
</replacement>
</replacements>
</configuration>
</plugin>

<!-- Jar plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -106,8 +67,9 @@
<configuration>
<archive>
<manifestEntries>
<Built-By>graywolf336</Built-By>
</manifestEntries>
<Built-By>FreebuildFR</Built-By>
<Project-Version>${project.version}</Project-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/be/bendem/bukkit/orebroadcast/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,25 @@
import java.util.Set;

public class Config {

private final OreBroadcast plugin;
private final Set<SafeBlock> broadcastBlacklist = new HashSet<>();
private final Set<Material> blocksToBroadcast = new HashSet<>();
private final Set<String> 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
List<String> configList = plugin.getConfig().getStringList("ores");
blocksToBroadcast.clear();

for (String item : configList) {
Material material = Material.getMaterial(item.toUpperCase() + "_ORE");
Material material = this.getMaterial(item.toUpperCase());
blocksToBroadcast.add(material);
}

Expand All @@ -53,4 +52,9 @@ protected Set<String> 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.List;

Expand All @@ -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<String> 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);
Expand Down
30 changes: 18 additions & 12 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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}).
Expand All @@ -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
Expand All @@ -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).
Expand Down
7 changes: 4 additions & 3 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 3ced411

Please sign in to comment.