diff --git a/src/main/java/io/github/dre2n/dungeonsxl/game/GameChest.java b/src/main/java/io/github/dre2n/dungeonsxl/game/GameChest.java index 3040359d..1c4ad832 100644 --- a/src/main/java/io/github/dre2n/dungeonsxl/game/GameChest.java +++ b/src/main/java/io/github/dre2n/dungeonsxl/game/GameChest.java @@ -189,15 +189,19 @@ public class GameChest { if (itemStack.getItemMeta().hasDisplayName()) { name = itemStack.getItemMeta().getDisplayName(); } - } - if (name == null && Bukkit.getPluginManager().getPlugin("Vault") != null) { - ItemInfo itemInfo = Items.itemByStack(itemStack); - if (itemInfo != null) { - name = itemInfo.getName(); + if (name == null) { + if (Bukkit.getPluginManager().getPlugin("Vault") != null) { + ItemInfo itemInfo = Items.itemByStack(itemStack); + if (itemInfo != null) { + name = itemInfo.getName(); + } else { + name = itemStack.getType().name(); + } + } else { - name = itemStack.getType().name(); + name = itemStack.getType().toString(); } } @@ -209,7 +213,7 @@ public class GameChest { } MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.PLAYER_LOOT_ADDED, msg)); - if (moneyReward != 0) { + if (moneyReward != 0 && plugin.getEconomyProvider() != null) { MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.PLAYER_LOOT_ADDED, plugin.getEconomyProvider().format(moneyReward))); } if (levelReward != 0) { diff --git a/src/main/java/io/github/dre2n/dungeonsxl/listener/PlayerListener.java b/src/main/java/io/github/dre2n/dungeonsxl/listener/PlayerListener.java index 91c7bdd0..b2c40323 100644 --- a/src/main/java/io/github/dre2n/dungeonsxl/listener/PlayerListener.java +++ b/src/main/java/io/github/dre2n/dungeonsxl/listener/PlayerListener.java @@ -666,7 +666,7 @@ public class PlayerListener implements Listener { if (player.getLocation().getBlock().getRelative(0, 1, 0).getType() != Material.PORTAL && player.getLocation().getBlock().getRelative(0, -1, 0).getType() != Material.PORTAL && player.getLocation().getBlock().getRelative(1, 0, 0).getType() != Material.PORTAL && player.getLocation().getBlock().getRelative(-1, 0, 0).getType() != Material.PORTAL && player.getLocation().getBlock().getRelative(0, 0, 1).getType() != Material.PORTAL && player.getLocation().getBlock().getRelative(0, 0, -1).getType() != Material.PORTAL) { - inventory.setInventoryView(inventory.getPlayer().openInventory(inventory.getInventory())); + inventory.setInventoryView(player.openInventory(inventory.getInventory())); inventory.setTime(System.currentTimeMillis()); } } diff --git a/src/main/java/io/github/dre2n/dungeonsxl/player/DPlayer.java b/src/main/java/io/github/dre2n/dungeonsxl/player/DPlayer.java index 37bc08ee..e2f9ca85 100644 --- a/src/main/java/io/github/dre2n/dungeonsxl/player/DPlayer.java +++ b/src/main/java/io/github/dre2n/dungeonsxl/player/DPlayer.java @@ -492,6 +492,9 @@ public class DPlayer extends DGlobalPlayer { savePlayer.reset(false); } + GameWorld gameWorld = GameWorld.getByWorld(world); + DGroup dGroup = DGroup.getByPlayer(getPlayer()); + if (editing) { EditWorld editWorld = EditWorld.getByWorld(world); if (editWorld != null) { @@ -499,16 +502,15 @@ public class DPlayer extends DGlobalPlayer { } } else { - GameWorld gameWorld = GameWorld.getByWorld(world); - DGroup dGroup = DGroup.getByPlayer(getPlayer()); + Game game = Game.getByGameWorld(gameWorld); if (dGroup != null) { dGroup.removePlayer(getPlayer()); } // Belohnung - if (gameWorld.getGame() != null) { + if (game != null) { if (finished) { - if (gameWorld.getGame().getType().hasRewards()) { + if (game.getType().hasRewards()) { for (Reward reward : gameWorld.getConfig().getRewards()) { reward.giveTo(getPlayer()); } diff --git a/src/main/java/io/github/dre2n/dungeonsxl/player/DSavePlayer.java b/src/main/java/io/github/dre2n/dungeonsxl/player/DSavePlayer.java index 397b5c6a..94141417 100644 --- a/src/main/java/io/github/dre2n/dungeonsxl/player/DSavePlayer.java +++ b/src/main/java/io/github/dre2n/dungeonsxl/player/DSavePlayer.java @@ -99,8 +99,7 @@ public class DSavePlayer { } /** - * @return - * the uuid + * @return the uuid */ public UUID getUniqueId() { return UUID.fromString(uuid); @@ -113,6 +112,14 @@ public class DSavePlayer { return oldLocation; } + /** + * @param location + * the location to set + */ + public void setOldLocation(Location location) { + oldLocation = location; + } + /** * @return the items in the old inventory */ @@ -120,6 +127,14 @@ public class DSavePlayer { return oldInventory; } + /** + * @param inventory + * the inventory to set + */ + public void setOldInventory(List inventory) { + oldInventory = inventory; + } + /** * @return the items in the old armor slots */ @@ -127,6 +142,14 @@ public class DSavePlayer { return oldArmor; } + /** + * @param inventory + * the inventory to set + */ + public void setOldArmor(List inventory) { + oldArmor = inventory; + } + /** * @return the items in the old off-hand slot */ @@ -134,6 +157,14 @@ public class DSavePlayer { return oldOffHand; } + /** + * @param offHand + * the off hand item to set + */ + public void setOldOffHand(ItemStack offHand) { + oldOffHand = offHand; + } + /** * @return the old level */ @@ -141,6 +172,14 @@ public class DSavePlayer { return oldLvl; } + /** + * @param level + * the level to set + */ + public void setOldLevel(int level) { + oldLvl = level; + } + /** * @return the old exp */ @@ -148,6 +187,14 @@ public class DSavePlayer { return oldExp; } + /** + * @param exp + * the amount of exp to set + */ + public void setOldExp(int exp) { + oldExp = exp; + } + /** * @return the old health */ @@ -155,6 +202,14 @@ public class DSavePlayer { return oldHealth; } + /** + * @param health + * the health to set + */ + public void setOldHealth(int health) { + oldHealth = health; + } + /** * @return the old food level */ @@ -162,6 +217,14 @@ public class DSavePlayer { return oldFoodLevel; } + /** + * @param foodLevel + * the food level to set + */ + public void setOldFoodLevel(int foodLevel) { + oldFoodLevel = foodLevel; + } + /** * @return the old fire ticks */ @@ -169,6 +232,14 @@ public class DSavePlayer { return oldFireTicks; } + /** + * @param fireTicks + * the fire ticks to set + */ + public void setFireTicks(int fireTicks) { + oldFireTicks = fireTicks; + } + /** * @return the old GameMode */ @@ -176,6 +247,14 @@ public class DSavePlayer { return oldGameMode; } + /** + * @param gameMode + * the GameMode to set + */ + public void setOldGameMode(GameMode gameMode) { + oldGameMode = gameMode; + } + /** * @return the old potion effects */ @@ -183,6 +262,14 @@ public class DSavePlayer { return oldPotionEffects; } + /** + * @param potionEffects + * the potion effects to set + */ + public void setOldPotionEffects(Collection potionEffects) { + oldPotionEffects = potionEffects; + } + /* Actions */ public void reset(boolean keepInventory) { Player player = plugin.getServer().getPlayer(name); diff --git a/src/main/java/io/github/dre2n/dungeonsxl/requirement/FeeLevelRequirement.java b/src/main/java/io/github/dre2n/dungeonsxl/requirement/FeeLevelRequirement.java index 7721529b..3cda8ecd 100644 --- a/src/main/java/io/github/dre2n/dungeonsxl/requirement/FeeLevelRequirement.java +++ b/src/main/java/io/github/dre2n/dungeonsxl/requirement/FeeLevelRequirement.java @@ -18,6 +18,8 @@ package io.github.dre2n.dungeonsxl.requirement; import io.github.dre2n.commons.util.messageutil.MessageUtil; import io.github.dre2n.dungeonsxl.config.DMessages; +import io.github.dre2n.dungeonsxl.player.DPlayer; +import io.github.dre2n.dungeonsxl.player.DSavePlayer; import org.bukkit.entity.Player; /** @@ -51,7 +53,13 @@ public class FeeLevelRequirement extends Requirement { @Override public void demand(Player player) { - player.setLevel(player.getLevel() - fee); + DPlayer dPlayer = DPlayer.getByPlayer(player); + if (dPlayer == null) { + return; + } + DSavePlayer dSavePlayer = dPlayer.getSavePlayer(); + dSavePlayer.setOldLevel(dSavePlayer.getOldLevel() - fee); + MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.REQUIREMENT_FEE, fee + " levels")); } diff --git a/src/main/java/io/github/dre2n/dungeonsxl/reward/LevelReward.java b/src/main/java/io/github/dre2n/dungeonsxl/reward/LevelReward.java index 03402966..e22a6df1 100644 --- a/src/main/java/io/github/dre2n/dungeonsxl/reward/LevelReward.java +++ b/src/main/java/io/github/dre2n/dungeonsxl/reward/LevelReward.java @@ -54,6 +54,10 @@ public class LevelReward extends Reward { @Override public void giveTo(Player player) { + if (levels == 0) { + return; + } + player.setLevel(player.getLevel() + levels); MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.REWARD_GENERAL, levels + " levels")); }