couple null pointer exceptions, and updating enchantments to use modern

equivalents... i think...
This commit is contained in:
Famous Longwing 2025-03-31 13:28:59 -04:00
parent 86a58764f6
commit 0b4e69f226
4 changed files with 82 additions and 85 deletions

View File

@ -1,40 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="HolographicDisplaysAPI-2.3.3-SNAPSHOT.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="Vault.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="D:/My Documents/Minecraft Stuff/1.18 Plugin Tester/bundler/libraries/spigot-api-1.18.1-R0.1-SNAPSHOT.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="D:/My Documents/Minecraft Stuff/1.18 Plugin Tester/bundler/libraries/commons-io-2.11.0.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="D:/My Documents/Minecraft Stuff/1.18 Plugin Tester/bundler/libraries/gson-2.8.8.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="D:/My Documents/Minecraft Stuff/1.18 Plugin Tester/bundler/libraries/snakeyaml-1.28.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="/home/phil/.m2/repository/org/spigotmc/spigot-api/1.21.4-R0.1-SNAPSHOT/spigot-api-1.21.4-R0.1-SNAPSHOT.jar" sourcepath="/home/phil/.m2/repository/org/spigotmc/spigot-api/1.21.4-R0.1-SNAPSHOT/spigot-api-1.21.4-R0.1-SNAPSHOT-sources.jar">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="maven.groupId" value="org.spigotmc"/>
<attribute name="maven.artifactId" value="spigot-api"/>
<attribute name="maven.version" value="1.21.4-R0.1-SNAPSHOT"/>
<attribute name="maven.scope" value="provided"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="/home/phil/.m2/repository/net/milkbowl/vault/VaultAPI/1.7/VaultAPI-1.7.jar" sourcepath="/home/phil/.m2/repository/net/milkbowl/vault/VaultAPI/1.7/VaultAPI-1.7-sources.jar">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="maven.groupId" value="net.milkbowl.vault"/>
<attribute name="maven.artifactId" value="VaultAPI"/>
<attribute name="maven.version" value="1.7"/>
<attribute name="maven.scope" value="provided"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="/home/phil/.m2/repository/org/apache/commons/commons-io-2.18.0-bin/commons-io-2.18.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -188,6 +188,7 @@ public class BankStorage {
public void save() {
pf.set("inventory", null);
for(int i = 0;i < items.size();i++) {
if(items.get(i) == null) {continue;}
pf.set("inventory." + i, items.get(i));
}
pf.set("unlockedPages", unlockedPages);
@ -220,6 +221,9 @@ public class BankStorage {
}
//Second check for same items
if(items.get(i) ==null) {
continue;
}
if(items.get(i).isSimilar(pItem)) { //If there is empty space in the bank
ItemStack bItem = items.get(i);
int bAmount = bItem.getAmount();
@ -338,7 +342,10 @@ public class BankStorage {
this.itemIdentifiers = new ArrayList<Integer>();
for(int i = 0;i < items.size();i++) {
ItemStack item = items.get(i);
if(item == null)
{
continue;
}
if(itemIdentifiers.size() < 54) {
boolean found = false;

View File

@ -51,34 +51,34 @@ public class ItemCreator implements Listener{
for(String enchantmentString : enchantmentStrings){
String enchantment = enchantmentString.split(":")[0];
int level = Integer.valueOf(enchantmentString.split(":")[1]);
if(enchantment.equalsIgnoreCase("arrowdamage")){
item.addEnchantment(Enchantment.ARROW_DAMAGE, level);
}else if(enchantment.equalsIgnoreCase("arrowfire")){
item.addUnsafeEnchantment(Enchantment.ARROW_FIRE, level);
}else if(enchantment.equalsIgnoreCase("arrowinfinite")){
item.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, level);
}else if(enchantment.equalsIgnoreCase("arrowknockback")){
item.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, level);
if(enchantment.equalsIgnoreCase("power")){
item.addEnchantment(Enchantment.POWER, level);
}else if(enchantment.equalsIgnoreCase("flame")){
item.addUnsafeEnchantment(Enchantment.FLAME, level);
}else if(enchantment.equalsIgnoreCase("infinity")){
item.addUnsafeEnchantment(Enchantment.INFINITY, level);
}else if(enchantment.equalsIgnoreCase("punch")){
item.addUnsafeEnchantment(Enchantment.PUNCH, level);
}else if(enchantment.equalsIgnoreCase("damage")){
item.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, level);
}else if(enchantment.equalsIgnoreCase("digspeed")){
item.addUnsafeEnchantment(Enchantment.DIG_SPEED, level);
}else if(enchantment.equalsIgnoreCase("durability")){
item.addUnsafeEnchantment(Enchantment.DURABILITY, level);
item.addUnsafeEnchantment(Enchantment.SHARPNESS, level);
}else if(enchantment.equalsIgnoreCase("efficiency")){
item.addUnsafeEnchantment(Enchantment.EFFICIENCY, level);
}else if(enchantment.equalsIgnoreCase("unbreaking")){
item.addUnsafeEnchantment(Enchantment.UNBREAKING, level);
}else if(enchantment.equalsIgnoreCase("fireaspect")){
item.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, level);
}else if(enchantment.equalsIgnoreCase("knockback")){
item.addUnsafeEnchantment(Enchantment.KNOCKBACK, level);
}else if(enchantment.equalsIgnoreCase("lootbonusblock")){
item.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, level);
}else if(enchantment.equalsIgnoreCase("lootbonusmob")){
item.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, level);
}else if(enchantment.equalsIgnoreCase("luck")){
item.addUnsafeEnchantment(Enchantment.LUCK, level);
}else if(enchantment.equalsIgnoreCase("fortune")){
item.addUnsafeEnchantment(Enchantment.FORTUNE, level);
}else if(enchantment.equalsIgnoreCase("looting")){
item.addUnsafeEnchantment(Enchantment.LOOTING, level);
}else if(enchantment.equalsIgnoreCase("luckofthesea")){
item.addUnsafeEnchantment(Enchantment.LUCK_OF_THE_SEA, level);
}else if(enchantment.equalsIgnoreCase("protectionfall")){
item.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, level);
item.addUnsafeEnchantment(Enchantment.FEATHER_FALLING, level);
}else if(enchantment.equalsIgnoreCase("protectionfire")){
item.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, level);
item.addUnsafeEnchantment(Enchantment.FIRE_PROTECTION, level);
}else if(enchantment.equalsIgnoreCase("silktouch")){
item.addUnsafeEnchantment(Enchantment.SILK_TOUCH, level);
}

View File

@ -87,26 +87,26 @@ public class LoadItemstackFromConfig {
String enchantmentName = enchantmentString.split(":")[0];
int enchantmentLevel = Integer.valueOf(enchantmentString.split(":")[1]);
switch(enchantmentName) {
case "arrowdamage":
meta.addEnchant(Enchantment.ARROW_DAMAGE, enchantmentLevel, true);
case "power":
meta.addEnchant(Enchantment.POWER, enchantmentLevel, true);
break;
case "arrowfire":
meta.addEnchant(Enchantment.ARROW_FIRE, enchantmentLevel, true);
case "flame":
meta.addEnchant(Enchantment.FLAME, enchantmentLevel, true);
break;
case "arrowinfinite":
meta.addEnchant(Enchantment.ARROW_INFINITE, enchantmentLevel, true);
case "infinity":
meta.addEnchant(Enchantment.INFINITY, enchantmentLevel, true);
break;
case "arrowknockback":
meta.addEnchant(Enchantment.ARROW_KNOCKBACK, enchantmentLevel, true);
case "punch":
meta.addEnchant(Enchantment.PUNCH, enchantmentLevel, true);
break;
case "damage":
meta.addEnchant(Enchantment.DAMAGE_ALL, enchantmentLevel, true);
case "sharpness":
meta.addEnchant(Enchantment.SHARPNESS, enchantmentLevel, true);
break;
case "digspeed":
meta.addEnchant(Enchantment.DIG_SPEED, enchantmentLevel, true);
case "efficiency":
meta.addEnchant(Enchantment.EFFICIENCY, enchantmentLevel, true);
break;
case "durability":
meta.addEnchant(Enchantment.DURABILITY, enchantmentLevel, true);
case "unbreaking":
meta.addEnchant(Enchantment.UNBREAKING, enchantmentLevel, true);
break;
case "fireaspect":
meta.addEnchant(Enchantment.FIRE_ASPECT, enchantmentLevel, true);
@ -114,20 +114,20 @@ public class LoadItemstackFromConfig {
case "knockback":
meta.addEnchant(Enchantment.KNOCKBACK, enchantmentLevel, true);
break;
case "lootbonusblock":
meta.addEnchant(Enchantment.LOOT_BONUS_BLOCKS, enchantmentLevel, true);
case "fortune":
meta.addEnchant(Enchantment.FORTUNE, enchantmentLevel, true);
break;
case "lootbonusmob":
meta.addEnchant(Enchantment.LOOT_BONUS_MOBS, enchantmentLevel, true);
case "looting":
meta.addEnchant(Enchantment.LOOTING, enchantmentLevel, true);
break;
case "luck":
meta.addEnchant(Enchantment.LUCK, enchantmentLevel, true);
case "luckofthesea":
meta.addEnchant(Enchantment.LUCK_OF_THE_SEA, enchantmentLevel, true);
break;
case "protectionfall":
meta.addEnchant(Enchantment.PROTECTION_FALL, enchantmentLevel, true);
case "featherfall":
meta.addEnchant(Enchantment.FEATHER_FALLING, enchantmentLevel, true);
break;
case "protectionfire":
meta.addEnchant(Enchantment.PROTECTION_FALL, enchantmentLevel, true);
meta.addEnchant(Enchantment.FIRE_PROTECTION, enchantmentLevel, true);
break;
case "silktouch":
meta.addEnchant(Enchantment.SILK_TOUCH, enchantmentLevel, true);