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()) {
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) {

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
&& 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());
}
}

View File

@ -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());
}

View File

@ -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<ItemStack> 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<ItemStack> 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<PotionEffect> potionEffects) {
oldPotionEffects = potionEffects;
}
/* Actions */
public void reset(boolean keepInventory) {
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.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"));
}

View File

@ -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"));
}