Fix loot module NPE

This commit is contained in:
Sam 2017-04-05 21:14:12 +01:00
parent b85214c7f0
commit 4552fc2e9b
2 changed files with 47 additions and 44 deletions

View File

@ -535,10 +535,7 @@ public class LootModule extends MiniPlugin
String key = metadataSplit[0];
String[] values = new String[metadataSplit.length - 1];
for (int i = 1; i < metadataSplit.length; i++)
{
values[i - 1] = metadataSplit[i];
}
System.arraycopy(metadataSplit, 1, values, 0, metadataSplit.length - 1);
switch (key)
{
@ -568,8 +565,11 @@ public class LootModule extends MiniPlugin
_itemRewards.add(reward);
}
if (reward != null)
{
reward.collectItem(player);
}
}
public void addItemReward(LootItemReward reward)
{

View File

@ -24,11 +24,7 @@ import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.*;
import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.plugin.java.JavaPlugin;
@ -52,7 +48,8 @@ public class WorldListeners implements Listener
@EventHandler
public void deletePlayerData(PlayerQuitEvent event)
{
_plugin.getServer().getScheduler().runTaskLater(_plugin, () -> {
_plugin.getServer().getScheduler().runTaskLater(_plugin, () ->
{
World world = event.getPlayer().getWorld();
UUID uuid = event.getPlayer().getUniqueId();
String path = world.getWorldFolder().getPath();
@ -213,6 +210,12 @@ public class WorldListeners implements Listener
}
}
@EventHandler
public void bucketEmpty(PlayerBucketEmptyEvent event)
{
event.setCancelled(true);
}
public boolean shouldBlock(Player player)
{
return player.getGameMode() != GameMode.CREATIVE;