1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-17 21:51:20 +01:00

Fix NPE related to MythicMobs display name

Fixes #1015
This commit is contained in:
montlikadani 2020-12-05 14:04:52 +01:00
parent b4c52835e6
commit 580ce6d555
3 changed files with 8 additions and 22 deletions

View File

@ -60,8 +60,8 @@ public class MythicMobs4 implements MythicMobInterface {
MythicMob mm = MMAPI.getMythicMob(id);
try {
if (mm != null)
return mm.getDisplayName().toString();
if (mm != null && mm.getDisplayName() != null)
return mm.getDisplayName().get();
} catch (Throwable e) {
if (!failed) {
failed = true;

View File

@ -1576,8 +1576,7 @@ public class JobsPaymentListener implements Listener {
if (Jobs.getGCManager().useBlockProtection && block.getState().hasMetadata(BlockMetadata))
return;
BlockActionInfo bInfo = new BlockActionInfo(block, ActionType.TNTBREAK);
Jobs.action(jPlayer, bInfo, block);
Jobs.action(jPlayer, new BlockActionInfo(block, ActionType.TNTBREAK), block);
}
}
@ -1592,8 +1591,7 @@ public class JobsPaymentListener implements Listener {
return;
CMIMaterial cmat = CMIMaterial.get(block);
final JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(p);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(p);
Material hand = Jobs.getNms().getItemInMainHand(p).getType();
if (Version.isCurrentEqualOrHigher(Version.v1_14_R1) && event.useInteractedBlock() != org.bukkit.event.Event.Result.DENY
@ -1657,21 +1655,18 @@ public class JobsPaymentListener implements Listener {
}
} else if (Version.isCurrentEqualOrHigher(Version.v1_13_R1) &&
block.getType().toString().startsWith("STRIPPED_") &&
event.getAction() == Action.RIGHT_CLICK_BLOCK && jPlayer != null) {
ItemStack iih = Jobs.getNms().getItemInMainHand(p);
if (iih.getType().toString().endsWith("_AXE")) {
event.getAction() == Action.RIGHT_CLICK_BLOCK && jPlayer != null && hand.toString().endsWith("_AXE")) {
// check if player is riding
if (Jobs.getGCManager().disablePaymentIfRiding && p.isInsideVehicle())
return;
// Prevent item durability loss
if (!Jobs.getGCManager().payItemDurabilityLoss && iih.getType().getMaxDurability()
- Jobs.getNms().getDurability(iih) != iih.getType().getMaxDurability())
if (!Jobs.getGCManager().payItemDurabilityLoss && hand.getMaxDurability()
- Jobs.getNms().getDurability(Jobs.getNms().getItemInMainHand(p)) != hand.getMaxDurability())
return;
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () ->
Jobs.action(jPlayer, new BlockActionInfo(block, ActionType.STRIPLOGS), block), 1);
}
}
}
@ -1734,9 +1729,8 @@ public class JobsPaymentListener implements Listener {
return true;
ItemStack hand = Jobs.getNms().getItemInMainHand(p);
CMIMaterial cmat = CMIMaterial.get(hand);
HashMap<Enchantment, Integer> got = Jobs.getGCManager().whiteListedItems.get(cmat);
HashMap<Enchantment, Integer> got = Jobs.getGCManager().whiteListedItems.get(CMIMaterial.get(hand));
if (got == null)
return false;

View File

@ -9,7 +9,6 @@ import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.UUID;
@ -53,13 +52,6 @@ public class Util {
return item;
}
public static void toLowerCase(List<String> strings) {
ListIterator<String> iterator = strings.listIterator();
while (iterator.hasNext()) {
iterator.set(iterator.next().toLowerCase());
}
}
public static World getWorld(String name) {
World w = Bukkit.getWorld(name);
if (w != null)