fix drops

This commit is contained in:
Minecon724 2022-10-23 11:24:05 +02:00
parent 62dd5554eb
commit 8bb25e1021
2 changed files with 7 additions and 5 deletions

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>giants</groupId> <groupId>giants</groupId>
<artifactId>giants</artifactId> <artifactId>giants</artifactId>
<version>22.10.0</version> <version>22.10.1</version>
<properties> <properties>
<maven.compiler.source>17</maven.compiler.source> <maven.compiler.source>17</maven.compiler.source>

View File

@ -2,6 +2,7 @@ package pl.minecon724.giants;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -93,9 +94,10 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
for (Object o : config.getList("drops", new ArrayList<Object>())) { for (Object o : config.getList("drops", new ArrayList<Object>())) {
try { try {
String[] parts = ((String) o).split(":"); String[] parts = ((String) o).split(":");
for (String s : parts) { getLogger().info(Arrays.asList(parts).subList(1, parts.length).toString());
for (String s : Arrays.asList(parts).subList(1, parts.length)) {
if (!isNumeric(s)) { if (!isNumeric(s)) {
throw new IllegalArgumentException(parts[1] + " is not a number"); throw new IllegalArgumentException(s + " is not a number");
} }
} }
Material material = Material.getMaterial(parts[0]); Material material = Material.getMaterial(parts[0]);
@ -177,8 +179,8 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
if (entity.getType() == EntityType.GIANT) { if (entity.getType() == EntityType.GIANT) {
giants.remove(entity); giants.remove(entity);
for (Entry<Material, List<Integer>> d : drops.entrySet()) { for (Entry<Material, List<Integer>> d : drops.entrySet()) {
int max = d.getValue().get(0); int min = d.getValue().get(0);
int min = d.getValue().get(1); int max = d.getValue().get(1);
ItemStack is = new ItemStack(d.getKey(), rnd.nextInt((max - min) + 1) + min); ItemStack is = new ItemStack(d.getKey(), rnd.nextInt((max - min) + 1) + min);
if (rnd.nextInt(100) < d.getValue().get(2)) { if (rnd.nextInt(100) < d.getValue().get(2)) {
entity.getWorld().dropItemNaturally(entity.getLocation(), is); entity.getWorld().dropItemNaturally(entity.getLocation(), is);