mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 13:36:33 +01:00
Move game.GameChest => reward.RewardChest
This commit is contained in:
parent
7cbe7f44bb
commit
02317cc208
@ -24,7 +24,6 @@ import io.github.dre2n.dungeonsxl.config.WorldConfig;
|
|||||||
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
|
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
|
||||||
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerDeathEvent;
|
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerDeathEvent;
|
||||||
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerKickEvent;
|
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerKickEvent;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameChest;
|
|
||||||
import io.github.dre2n.dungeonsxl.global.DPortal;
|
import io.github.dre2n.dungeonsxl.global.DPortal;
|
||||||
import io.github.dre2n.dungeonsxl.global.GameSign;
|
import io.github.dre2n.dungeonsxl.global.GameSign;
|
||||||
import io.github.dre2n.dungeonsxl.global.GlobalProtection;
|
import io.github.dre2n.dungeonsxl.global.GlobalProtection;
|
||||||
@ -37,6 +36,7 @@ import io.github.dre2n.dungeonsxl.player.DPlayer;
|
|||||||
import io.github.dre2n.dungeonsxl.player.DPlayers;
|
import io.github.dre2n.dungeonsxl.player.DPlayers;
|
||||||
import io.github.dre2n.dungeonsxl.player.DSavePlayer;
|
import io.github.dre2n.dungeonsxl.player.DSavePlayer;
|
||||||
import io.github.dre2n.dungeonsxl.reward.DLootInventory;
|
import io.github.dre2n.dungeonsxl.reward.DLootInventory;
|
||||||
|
import io.github.dre2n.dungeonsxl.reward.RewardChest;
|
||||||
import io.github.dre2n.dungeonsxl.task.RespawnTask;
|
import io.github.dre2n.dungeonsxl.task.RespawnTask;
|
||||||
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
||||||
import io.github.dre2n.dungeonsxl.trigger.UseItemTrigger;
|
import io.github.dre2n.dungeonsxl.trigger.UseItemTrigger;
|
||||||
@ -613,7 +613,7 @@ public class PlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameChest.onOpenInventory(event);
|
RewardChest.onOpenInventory(event);
|
||||||
|
|
||||||
if (!plugin.getMainConfig().getOpenInventories() && !DPermissions.hasPermission(event.getPlayer(), DPermissions.INSECURE)) {
|
if (!plugin.getMainConfig().getOpenInventories() && !DPermissions.hasPermission(event.getPlayer(), DPermissions.INSECURE)) {
|
||||||
World world = event.getPlayer().getWorld();
|
World world = event.getPlayer().getWorld();
|
||||||
|
@ -14,17 +14,13 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package io.github.dre2n.dungeonsxl.game;
|
package io.github.dre2n.dungeonsxl.reward;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
import io.github.dre2n.dungeonsxl.reward.LevelReward;
|
|
||||||
import io.github.dre2n.dungeonsxl.reward.MoneyReward;
|
|
||||||
import io.github.dre2n.dungeonsxl.reward.Reward;
|
|
||||||
import io.github.dre2n.dungeonsxl.reward.RewardTypeDefault;
|
|
||||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||||
import net.milkbowl.vault.item.ItemInfo;
|
import net.milkbowl.vault.item.ItemInfo;
|
||||||
import net.milkbowl.vault.item.Items;
|
import net.milkbowl.vault.item.Items;
|
||||||
@ -40,7 +36,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
/**
|
/**
|
||||||
* @author Frank Baumann, Daniel Saukel
|
* @author Frank Baumann, Daniel Saukel
|
||||||
*/
|
*/
|
||||||
public class GameChest {
|
public class RewardChest {
|
||||||
|
|
||||||
protected static DungeonsXL plugin = DungeonsXL.getInstance();
|
protected static DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
|
||||||
@ -51,7 +47,7 @@ public class GameChest {
|
|||||||
private double moneyReward;
|
private double moneyReward;
|
||||||
private int levelReward;
|
private int levelReward;
|
||||||
|
|
||||||
public GameChest(Block chest, GameWorld gameWorld, double moneyReward, int levelReward) {
|
public RewardChest(Block chest, GameWorld gameWorld, double moneyReward, int levelReward) {
|
||||||
if (!(chest.getState() instanceof Chest)) {
|
if (!(chest.getState() instanceof Chest)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -61,11 +57,11 @@ public class GameChest {
|
|||||||
this.moneyReward = moneyReward;
|
this.moneyReward = moneyReward;
|
||||||
this.levelReward = levelReward;
|
this.levelReward = levelReward;
|
||||||
|
|
||||||
gameWorld.getGameChests().add(this);
|
gameWorld.getRewardChests().add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return if the GameChest is used
|
* @return if the RewardChest is used
|
||||||
*/
|
*/
|
||||||
public boolean isUsed() {
|
public boolean isUsed() {
|
||||||
return used;
|
return used;
|
||||||
@ -243,20 +239,20 @@ public class GameChest {
|
|||||||
|
|
||||||
Chest chest = (Chest) inventory.getTopInventory().getHolder();
|
Chest chest = (Chest) inventory.getTopInventory().getHolder();
|
||||||
|
|
||||||
for (GameChest gameChest : gameWorld.getGameChests()) {
|
for (RewardChest rewardChest : gameWorld.getRewardChests()) {
|
||||||
if (!gameChest.chest.equals(chest)) {
|
if (!rewardChest.chest.equals(chest)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gameChest.used) {
|
if (rewardChest.used) {
|
||||||
MessageUtil.sendMessage(plugin.getServer().getPlayer(event.getPlayer().getUniqueId()), plugin.getMessageConfig().getMessage(DMessages.ERROR_CHEST_IS_OPENED));
|
MessageUtil.sendMessage(plugin.getServer().getPlayer(event.getPlayer().getUniqueId()), plugin.getMessageConfig().getMessage(DMessages.ERROR_CHEST_IS_OPENED));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gameChest.chest.getLocation().distance(chest.getLocation()) < 1) {
|
if (rewardChest.chest.getLocation().distance(chest.getLocation()) < 1) {
|
||||||
gameChest.addTreasure(DGroup.getByPlayer((Player) event.getPlayer()));
|
rewardChest.addTreasure(DGroup.getByPlayer((Player) event.getPlayer()));
|
||||||
gameChest.used = true;
|
rewardChest.used = true;
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,7 +17,7 @@
|
|||||||
package io.github.dre2n.dungeonsxl.sign;
|
package io.github.dre2n.dungeonsxl.sign;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.NumberUtil;
|
import io.github.dre2n.commons.util.NumberUtil;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameChest;
|
import io.github.dre2n.dungeonsxl.reward.RewardChest;
|
||||||
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
import io.github.dre2n.dungeonsxl.world.GameWorld;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
@ -57,15 +57,15 @@ public class ChestSign extends DSign {
|
|||||||
|
|
||||||
for (int i = -1; i <= 1; i++) {
|
for (int i = -1; i <= 1; i++) {
|
||||||
if (getSign().getBlock().getRelative(i, 0, 0).getType() == Material.CHEST) {
|
if (getSign().getBlock().getRelative(i, 0, 0).getType() == Material.CHEST) {
|
||||||
new GameChest(getSign().getBlock().getRelative(i, 0, 0), getGameWorld(), moneyReward, levelReward);
|
new RewardChest(getSign().getBlock().getRelative(i, 0, 0), getGameWorld(), moneyReward, levelReward);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getSign().getBlock().getRelative(0, 0, i).getType() == Material.CHEST) {
|
if (getSign().getBlock().getRelative(0, 0, i).getType() == Material.CHEST) {
|
||||||
new GameChest(getSign().getBlock().getRelative(0, 0, i), getGameWorld(), moneyReward, levelReward);
|
new RewardChest(getSign().getBlock().getRelative(0, 0, i), getGameWorld(), moneyReward, levelReward);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getSign().getBlock().getRelative(0, i, 0).getType() == Material.CHEST) {
|
if (getSign().getBlock().getRelative(0, i, 0).getType() == Material.CHEST) {
|
||||||
new GameChest(getSign().getBlock().getRelative(0, i, 0), getGameWorld(), moneyReward, levelReward);
|
new RewardChest(getSign().getBlock().getRelative(0, i, 0), getGameWorld(), moneyReward, levelReward);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,13 +27,13 @@ import io.github.dre2n.dungeonsxl.event.gameworld.GameWorldStartGameEvent;
|
|||||||
import io.github.dre2n.dungeonsxl.event.gameworld.GameWorldUnloadEvent;
|
import io.github.dre2n.dungeonsxl.event.gameworld.GameWorldUnloadEvent;
|
||||||
import io.github.dre2n.dungeonsxl.event.requirement.RequirementCheckEvent;
|
import io.github.dre2n.dungeonsxl.event.requirement.RequirementCheckEvent;
|
||||||
import io.github.dre2n.dungeonsxl.game.Game;
|
import io.github.dre2n.dungeonsxl.game.Game;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameChest;
|
|
||||||
import io.github.dre2n.dungeonsxl.game.GamePlaceableBlock;
|
import io.github.dre2n.dungeonsxl.game.GamePlaceableBlock;
|
||||||
import io.github.dre2n.dungeonsxl.mob.DMob;
|
import io.github.dre2n.dungeonsxl.mob.DMob;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||||
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||||
import io.github.dre2n.dungeonsxl.requirement.Requirement;
|
import io.github.dre2n.dungeonsxl.requirement.Requirement;
|
||||||
|
import io.github.dre2n.dungeonsxl.reward.RewardChest;
|
||||||
import io.github.dre2n.dungeonsxl.sign.DSign;
|
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||||
import io.github.dre2n.dungeonsxl.sign.MobSign;
|
import io.github.dre2n.dungeonsxl.sign.MobSign;
|
||||||
import io.github.dre2n.dungeonsxl.trigger.RedstoneTrigger;
|
import io.github.dre2n.dungeonsxl.trigger.RedstoneTrigger;
|
||||||
@ -82,7 +82,7 @@ public class GameWorld {
|
|||||||
private CopyOnWriteArrayList<Sign> signClass = new CopyOnWriteArrayList<>();
|
private CopyOnWriteArrayList<Sign> signClass = new CopyOnWriteArrayList<>();
|
||||||
private CopyOnWriteArrayList<DMob> dMobs = new CopyOnWriteArrayList<>();
|
private CopyOnWriteArrayList<DMob> dMobs = new CopyOnWriteArrayList<>();
|
||||||
// TODO: Killed mobs
|
// TODO: Killed mobs
|
||||||
private CopyOnWriteArrayList<GameChest> gameChests = new CopyOnWriteArrayList<>();
|
private CopyOnWriteArrayList<RewardChest> rewardChests = new CopyOnWriteArrayList<>();
|
||||||
private CopyOnWriteArrayList<DSign> dSigns = new CopyOnWriteArrayList<>();
|
private CopyOnWriteArrayList<DSign> dSigns = new CopyOnWriteArrayList<>();
|
||||||
private WorldConfig worldConfig;
|
private WorldConfig worldConfig;
|
||||||
|
|
||||||
@ -310,18 +310,18 @@ public class GameWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the gameChests
|
* @return the rewardChests
|
||||||
*/
|
*/
|
||||||
public CopyOnWriteArrayList<GameChest> getGameChests() {
|
public CopyOnWriteArrayList<RewardChest> getRewardChests() {
|
||||||
return gameChests;
|
return rewardChests;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param gameChests
|
* @param rewardChests
|
||||||
* the gameChests to set
|
* the rewardChests to set
|
||||||
*/
|
*/
|
||||||
public void setGameChests(CopyOnWriteArrayList<GameChest> gameChests) {
|
public void setRewardChests(CopyOnWriteArrayList<RewardChest> rewardChests) {
|
||||||
this.gameChests = gameChests;
|
this.rewardChests = rewardChests;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user