n'egger
This commit is contained in:
parent
0aa91add8a
commit
a45ce796ac
3 changed files with 37 additions and 19 deletions
|
@ -11,7 +11,7 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
@ -21,5 +21,12 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
|
9
pom.xml
9
pom.xml
|
@ -2,7 +2,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>giants</groupId>
|
||||
<artifactId>giants</artifactId>
|
||||
<version>22.2.4</version>
|
||||
<version>22.9.0</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
|
@ -20,13 +20,13 @@
|
|||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.18.1-R0.1-SNAPSHOT</version>
|
||||
<version>1.19.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<version>3.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -42,12 +42,11 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>3.4.0</version>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<!-- Replace this with your package! -->
|
||||
<shadedPattern>pl.minecon724.giants</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
|
|
|
@ -9,7 +9,6 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bstats.charts.SimplePie;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -71,10 +70,10 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
|
|||
attackDamage = config.getDouble("attackDamage", 1.0D);
|
||||
attackReach = config.getDouble("attackReach", 2D);
|
||||
expandUp = config.getDouble("expandUp", 0D);
|
||||
for (Object s : config.getList("effects", new ArrayList<Object>())) {
|
||||
for (Object o : config.getList("effects", new ArrayList<Object>())) {
|
||||
try {
|
||||
String[] parts = ((String) s).split(":");
|
||||
if (!(StringUtils.isNumeric(parts[1]))) {
|
||||
String[] parts = ((String) o).split(":");
|
||||
if (!isNumeric(parts[1])) {
|
||||
throw new IllegalArgumentException(parts[1] + " is not a number");
|
||||
}
|
||||
PotionEffectType effectType = PotionEffectType.getByName(parts[0]);
|
||||
|
@ -84,20 +83,19 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
|
|||
Integer duration = Integer.valueOf(parts[1]);
|
||||
effects.put(effectType, duration);
|
||||
} catch (Exception e) {
|
||||
Bukkit.getLogger().severe("Exception while parsing " + s);
|
||||
Bukkit.getLogger().severe("Exception while parsing " + o);
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
for (Object s : config.getList("drops", new ArrayList<Object>())) {
|
||||
for (Object o : config.getList("drops", new ArrayList<Object>())) {
|
||||
try {
|
||||
String[] parts = ((String) s).split(":");
|
||||
/*
|
||||
TODO find a better way to do this
|
||||
if (!(StringUtils.isNumeric(parts[1]))) {
|
||||
throw new IllegalArgumentException(parts[1] + " is not a number");
|
||||
String[] parts = ((String) o).split(":");
|
||||
for (String s : parts) {
|
||||
if (!isNumeric(s)) {
|
||||
throw new IllegalArgumentException(parts[1] + " is not a number");
|
||||
}
|
||||
}
|
||||
*/
|
||||
Material material = Material.getMaterial(parts[0]);
|
||||
if (material == null) {
|
||||
throw new IllegalArgumentException(parts[0] + " is not a Material");
|
||||
|
@ -108,7 +106,7 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
|
|||
data.add(Integer.parseInt(parts[3]));
|
||||
drops.put(material, data);
|
||||
} catch (Exception e) {
|
||||
Bukkit.getLogger().severe("Exception while parsing " + s);
|
||||
Bukkit.getLogger().severe("Exception while parsing " + o);
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
|
@ -198,6 +196,7 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
|
|||
passenger.setInvulnerable(true);
|
||||
passenger.setPersistent(true);
|
||||
passenger.setMetadata("giant", new FixedMetadataValue(this, "y"));
|
||||
passenger.setHealth(Integer.MAX_VALUE);
|
||||
entity.addPassenger(passenger);
|
||||
}
|
||||
for (Entry<PotionEffectType, Integer> t : effects.entrySet()) {
|
||||
|
@ -207,4 +206,17 @@ public class Main extends JavaPlugin implements Listener, CommandExecutor {
|
|||
giants.add(entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
// sorry
|
||||
public static boolean isNumeric(String strNum) {
|
||||
if (strNum == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
double d = Double.parseDouble(strNum);
|
||||
} catch (NumberFormatException nfe) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue