diff --git a/README.md b/README.md
index ed153e9..3267468 100644
--- a/README.md
+++ b/README.md
@@ -17,4 +17,13 @@ openssl x509 -inform pem -in cert.cer -pubkey -noout > public_key.pem
When using `mvn`, override with `-Djarsigner.`
```
mvn clean package -Djarsigner.keystore=/home/user/mykeystore.jks -Djarsigner.alias=mykey
-```
\ No newline at end of file
+```
+
+### Color scheme
+The following color scheme is used for chat messages:
+- Errors: RED
+- "Soft errors" (like no permission): GRAY
+- Status messages: GRAY
+- Notice / call for action: YELLOW (optionally also BOLD)
+- Information: GOLD
+- Highlight: AQUA (TODO do that)
\ No newline at end of file
diff --git a/src/main/java/eu/m724/giants/Drop.java b/src/main/java/eu/m724/giants/Drop.java
index d5884ca..ad51803 100644
--- a/src/main/java/eu/m724/giants/Drop.java
+++ b/src/main/java/eu/m724/giants/Drop.java
@@ -1,25 +1,34 @@
package eu.m724.giants;
+import org.bukkit.Location;
import org.bukkit.inventory.ItemStack;
import java.util.concurrent.ThreadLocalRandom;
-public class Drop {
- public final ItemStack itemStack;
- public final int min, max;
- public final double chance;
-
- public Drop(ItemStack itemStack, int min, int max, double chance) {
- this.itemStack = itemStack;
- this.min = min;
- this.max = max;
- this.chance = chance;
- }
-
- public ItemStack generateItemStack() {
+public record Drop(ItemStack itemStack, int min, int max, double chance) {
+ /**
+ * Randomizes quantity and returns {@link ItemStack}.
+ * This should be called every drop.
+ *
+ * @return A {@link ItemStack} with randomized quantity
+ */
+ private ItemStack generate() {
int amount = ThreadLocalRandom.current().nextInt(min, max + 1);
+
ItemStack itemStack = this.itemStack.clone();
itemStack.setAmount(amount);
return itemStack;
}
+
+ /**
+ * Drops the item at {@code location} taking into account quantity and chance.
+ *
+ * @param location The location to drop the drop at
+ */
+ public void dropAt(Location location) {
+ if (chance > ThreadLocalRandom.current().nextDouble()) {
+ ItemStack itemStack = generate();
+ location.getWorld().dropItemNaturally(location, itemStack);
+ }
+ }
}
diff --git a/src/main/java/eu/m724/giants/GiantProcessor.java b/src/main/java/eu/m724/giants/GiantProcessor.java
index 017d336..4a5bdba 100644
--- a/src/main/java/eu/m724/giants/GiantProcessor.java
+++ b/src/main/java/eu/m724/giants/GiantProcessor.java
@@ -8,7 +8,6 @@ import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.world.ChunkLoadEvent;
-import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
@@ -30,7 +29,6 @@ public class GiantProcessor implements Listener {
final Configuration configuration;
private final Logger logger;
- // private final Set trackedGiants = new HashSet<>();
final Set trackedHusks = new HashSet<>();
final Map giantLocationMap = new HashMap<>();
@@ -85,7 +83,6 @@ public class GiantProcessor implements Listener {
if (giant instanceof Giant) {
trackedHusks.add(husk);
- //trackedGiants.add((Giant) giant);
logger.fine("Tracking a loaded Giant at " + giant.getLocation());
} else {
@@ -148,14 +145,9 @@ public class GiantProcessor implements Listener {
logger.fine("A Giant died at " + location);
for (Drop drop : configuration.drops) {
- logger.fine("Rolling a drop");
+ logger.fine("Rolling a drop: " + drop.itemStack().toString());
- if (drop.chance > random.nextDouble()) {
- ItemStack is = drop.generateItemStack();
- entity.getWorld().dropItemNaturally(location, is);
-
- logger.fine("Dropped " + is);
- }
+ drop.dropAt(location);
}
for (Entity passenger : entity.getPassengers()) {
diff --git a/src/main/java/eu/m724/giants/GiantsCommand.java b/src/main/java/eu/m724/giants/GiantsCommand.java
index 36c690b..d7bfa35 100644
--- a/src/main/java/eu/m724/giants/GiantsCommand.java
+++ b/src/main/java/eu/m724/giants/GiantsCommand.java
@@ -1,6 +1,8 @@
package eu.m724.giants;
import eu.m724.giants.updater.UpdateCommand;
+import net.md_5.bungee.api.ChatColor;
+import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -30,64 +32,78 @@ public class GiantsCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 0) {
- sender.sendMessage("Giants " + plugin.getDescription().getVersion());
+ sender.sendMessage(ChatColor.GRAY + "Giants " + plugin.getDescription().getVersion());
return true;
}
String action = args[0];
if (!sender.hasPermission("giants.command." + action)) {
- sender.sendMessage("You don't have permission to use this command, or it doesn't exist.");
+ sender.sendMessage(ChatColor.GRAY + "You don't have permission to use this command, or it doesn't exist.");
return true;
}
- Player player = sender instanceof Player ? (Player) sender : null;
-
if (action.equals("serialize")) {
- if (player != null) {
- ItemStack itemStack = player.getInventory().getItemInMainHand();
-
- List