Fixed some reward bugs

This commit is contained in:
Daniel Saukel 2016-04-29 21:11:00 +02:00
parent 5e2c9ff601
commit 394080da34
6 changed files with 120 additions and 15 deletions

View File

@ -189,15 +189,19 @@ public class GameChest {
if (itemStack.getItemMeta().hasDisplayName()) { if (itemStack.getItemMeta().hasDisplayName()) {
name = itemStack.getItemMeta().getDisplayName(); name = itemStack.getItemMeta().getDisplayName();
} }
} }
if (name == null && Bukkit.getPluginManager().getPlugin("Vault") != null) { if (name == null) {
ItemInfo itemInfo = Items.itemByStack(itemStack); if (Bukkit.getPluginManager().getPlugin("Vault") != null) {
if (itemInfo != null) { ItemInfo itemInfo = Items.itemByStack(itemStack);
name = itemInfo.getName(); if (itemInfo != null) {
name = itemInfo.getName();
} else {
name = itemStack.getType().name();
}
} else { } 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)); 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))); MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.PLAYER_LOOT_ADDED, plugin.getEconomyProvider().format(moneyReward)));
} }
if (levelReward != 0) { if (levelReward != 0) {

View File

@ -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 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(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) { && 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()); inventory.setTime(System.currentTimeMillis());
} }
} }

View File

@ -492,6 +492,9 @@ public class DPlayer extends DGlobalPlayer {
savePlayer.reset(false); savePlayer.reset(false);
} }
GameWorld gameWorld = GameWorld.getByWorld(world);
DGroup dGroup = DGroup.getByPlayer(getPlayer());
if (editing) { if (editing) {
EditWorld editWorld = EditWorld.getByWorld(world); EditWorld editWorld = EditWorld.getByWorld(world);
if (editWorld != null) { if (editWorld != null) {
@ -499,16 +502,15 @@ public class DPlayer extends DGlobalPlayer {
} }
} else { } else {
GameWorld gameWorld = GameWorld.getByWorld(world); Game game = Game.getByGameWorld(gameWorld);
DGroup dGroup = DGroup.getByPlayer(getPlayer());
if (dGroup != null) { if (dGroup != null) {
dGroup.removePlayer(getPlayer()); dGroup.removePlayer(getPlayer());
} }
// Belohnung // Belohnung
if (gameWorld.getGame() != null) { if (game != null) {
if (finished) { if (finished) {
if (gameWorld.getGame().getType().hasRewards()) { if (game.getType().hasRewards()) {
for (Reward reward : gameWorld.getConfig().getRewards()) { for (Reward reward : gameWorld.getConfig().getRewards()) {
reward.giveTo(getPlayer()); reward.giveTo(getPlayer());
} }

View File

@ -99,8 +99,7 @@ public class DSavePlayer {
} }
/** /**
* @return * @return the uuid
* the uuid
*/ */
public UUID getUniqueId() { public UUID getUniqueId() {
return UUID.fromString(uuid); return UUID.fromString(uuid);
@ -113,6 +112,14 @@ public class DSavePlayer {
return oldLocation; return oldLocation;
} }
/**
* @param location
* the location to set
*/
public void setOldLocation(Location location) {
oldLocation = location;
}
/** /**
* @return the items in the old inventory * @return the items in the old inventory
*/ */
@ -120,6 +127,14 @@ public class DSavePlayer {
return oldInventory; return oldInventory;
} }
/**
* @param inventory
* the inventory to set
*/
public void setOldInventory(List<ItemStack> inventory) {
oldInventory = inventory;
}
/** /**
* @return the items in the old armor slots * @return the items in the old armor slots
*/ */
@ -127,6 +142,14 @@ public class DSavePlayer {
return oldArmor; return oldArmor;
} }
/**
* @param inventory
* the inventory to set
*/
public void setOldArmor(List<ItemStack> inventory) {
oldArmor = inventory;
}
/** /**
* @return the items in the old off-hand slot * @return the items in the old off-hand slot
*/ */
@ -134,6 +157,14 @@ public class DSavePlayer {
return oldOffHand; return oldOffHand;
} }
/**
* @param offHand
* the off hand item to set
*/
public void setOldOffHand(ItemStack offHand) {
oldOffHand = offHand;
}
/** /**
* @return the old level * @return the old level
*/ */
@ -141,6 +172,14 @@ public class DSavePlayer {
return oldLvl; return oldLvl;
} }
/**
* @param level
* the level to set
*/
public void setOldLevel(int level) {
oldLvl = level;
}
/** /**
* @return the old exp * @return the old exp
*/ */
@ -148,6 +187,14 @@ public class DSavePlayer {
return oldExp; return oldExp;
} }
/**
* @param exp
* the amount of exp to set
*/
public void setOldExp(int exp) {
oldExp = exp;
}
/** /**
* @return the old health * @return the old health
*/ */
@ -155,6 +202,14 @@ public class DSavePlayer {
return oldHealth; return oldHealth;
} }
/**
* @param health
* the health to set
*/
public void setOldHealth(int health) {
oldHealth = health;
}
/** /**
* @return the old food level * @return the old food level
*/ */
@ -162,6 +217,14 @@ public class DSavePlayer {
return oldFoodLevel; return oldFoodLevel;
} }
/**
* @param foodLevel
* the food level to set
*/
public void setOldFoodLevel(int foodLevel) {
oldFoodLevel = foodLevel;
}
/** /**
* @return the old fire ticks * @return the old fire ticks
*/ */
@ -169,6 +232,14 @@ public class DSavePlayer {
return oldFireTicks; return oldFireTicks;
} }
/**
* @param fireTicks
* the fire ticks to set
*/
public void setFireTicks(int fireTicks) {
oldFireTicks = fireTicks;
}
/** /**
* @return the old GameMode * @return the old GameMode
*/ */
@ -176,6 +247,14 @@ public class DSavePlayer {
return oldGameMode; return oldGameMode;
} }
/**
* @param gameMode
* the GameMode to set
*/
public void setOldGameMode(GameMode gameMode) {
oldGameMode = gameMode;
}
/** /**
* @return the old potion effects * @return the old potion effects
*/ */
@ -183,6 +262,14 @@ public class DSavePlayer {
return oldPotionEffects; return oldPotionEffects;
} }
/**
* @param potionEffects
* the potion effects to set
*/
public void setOldPotionEffects(Collection<PotionEffect> potionEffects) {
oldPotionEffects = potionEffects;
}
/* Actions */ /* Actions */
public void reset(boolean keepInventory) { public void reset(boolean keepInventory) {
Player player = plugin.getServer().getPlayer(name); Player player = plugin.getServer().getPlayer(name);

View File

@ -18,6 +18,8 @@ package io.github.dre2n.dungeonsxl.requirement;
import io.github.dre2n.commons.util.messageutil.MessageUtil; import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.config.DMessages; 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; import org.bukkit.entity.Player;
/** /**
@ -51,7 +53,13 @@ public class FeeLevelRequirement extends Requirement {
@Override @Override
public void demand(Player player) { 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")); MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.REQUIREMENT_FEE, fee + " levels"));
} }

View File

@ -54,6 +54,10 @@ public class LevelReward extends Reward {
@Override @Override
public void giveTo(Player player) { public void giveTo(Player player) {
if (levels == 0) {
return;
}
player.setLevel(player.getLevel() + levels); player.setLevel(player.getLevel() + levels);
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.REWARD_GENERAL, levels + " levels")); MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.REWARD_GENERAL, levels + " levels"));
} }