mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-24 19:45:43 +01:00
Merge pull request #53 from DRE2N/protections-and-players
Protections and players [WIP]
This commit is contained in:
commit
8aedb982fb
4
pom.xml
4
pom.xml
@ -55,7 +55,7 @@
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.9-R0.1-SNAPSHOT</version>
|
||||
<version>1.9.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -67,7 +67,7 @@
|
||||
<dependency>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
<artifactId>commons</artifactId>
|
||||
<version>0.1</version>
|
||||
<version>0.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.dre2n</groupId>
|
||||
|
@ -22,6 +22,7 @@ import io.github.dre2n.commons.javaplugin.BRPlugin;
|
||||
import io.github.dre2n.commons.javaplugin.BRPluginSettings;
|
||||
import io.github.dre2n.commons.util.FileUtil;
|
||||
import io.github.dre2n.dungeonsxl.command.*;
|
||||
import io.github.dre2n.dungeonsxl.config.DataConfig;
|
||||
import io.github.dre2n.dungeonsxl.config.MainConfig;
|
||||
import io.github.dre2n.dungeonsxl.config.MessageConfig;
|
||||
import io.github.dre2n.dungeonsxl.config.WorldConfig;
|
||||
@ -31,10 +32,7 @@ import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
|
||||
import io.github.dre2n.dungeonsxl.game.Game;
|
||||
import io.github.dre2n.dungeonsxl.game.GameTypes;
|
||||
import io.github.dre2n.dungeonsxl.game.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.global.DPortal;
|
||||
import io.github.dre2n.dungeonsxl.global.GameSign;
|
||||
import io.github.dre2n.dungeonsxl.global.GroupSign;
|
||||
import io.github.dre2n.dungeonsxl.global.LeaveSign;
|
||||
import io.github.dre2n.dungeonsxl.global.GlobalProtections;
|
||||
import io.github.dre2n.dungeonsxl.listener.BlockListener;
|
||||
import io.github.dre2n.dungeonsxl.listener.EntityListener;
|
||||
import io.github.dre2n.dungeonsxl.listener.HangingListener;
|
||||
@ -42,6 +40,7 @@ import io.github.dre2n.dungeonsxl.listener.PlayerListener;
|
||||
import io.github.dre2n.dungeonsxl.listener.WorldListener;
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DPlayers;
|
||||
import io.github.dre2n.dungeonsxl.player.DSavePlayer;
|
||||
import io.github.dre2n.dungeonsxl.requirement.RequirementTypes;
|
||||
import io.github.dre2n.dungeonsxl.reward.RewardTypes;
|
||||
@ -51,11 +50,7 @@ import io.github.dre2n.dungeonsxl.task.UpdateTask;
|
||||
import io.github.dre2n.dungeonsxl.task.WorldUnloadTask;
|
||||
import io.github.dre2n.dungeonsxl.trigger.Triggers;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
@ -68,6 +63,7 @@ public class DungeonsXL extends BRPlugin {
|
||||
|
||||
public static final String[] EXCLUDED_FILES = {"config.yml", "uid.dat", "DXLData.data"};
|
||||
|
||||
private DataConfig dataConfig;
|
||||
private MainConfig mainConfig;
|
||||
private MessageConfig messageConfig;
|
||||
|
||||
@ -78,23 +74,18 @@ public class DungeonsXL extends BRPlugin {
|
||||
private RewardTypes rewardTypes;
|
||||
private Triggers triggers;
|
||||
private Dungeons dungeons;
|
||||
private GlobalProtections protections;
|
||||
private DPlayers dPlayers;
|
||||
|
||||
private BukkitTask worldUnloadTask;
|
||||
private BukkitTask lazyUpdateTask;
|
||||
private BukkitTask updateTask;
|
||||
|
||||
private CopyOnWriteArrayList<Player> inBreakMode = new CopyOnWriteArrayList<>();
|
||||
private CopyOnWriteArrayList<Player> chatSpyers = new CopyOnWriteArrayList<>();
|
||||
private CopyOnWriteArrayList<DLootInventory> dLootInventories = new CopyOnWriteArrayList<>();
|
||||
private CopyOnWriteArrayList<EditWorld> editWorlds = new CopyOnWriteArrayList<>();
|
||||
private CopyOnWriteArrayList<GameWorld> gameWorlds = new CopyOnWriteArrayList<>();
|
||||
private CopyOnWriteArrayList<GameSign> gameSigns = new CopyOnWriteArrayList<>();
|
||||
private CopyOnWriteArrayList<GroupSign> groupSigns = new CopyOnWriteArrayList<>();
|
||||
private CopyOnWriteArrayList<LeaveSign> leaveSigns = new CopyOnWriteArrayList<>();
|
||||
private CopyOnWriteArrayList<DPortal> dPortals = new CopyOnWriteArrayList<>();
|
||||
private CopyOnWriteArrayList<Game> games = new CopyOnWriteArrayList<>();
|
||||
private CopyOnWriteArrayList<DGroup> dGroups = new CopyOnWriteArrayList<>();
|
||||
private CopyOnWriteArrayList<DPlayer> dPlayers = new CopyOnWriteArrayList<>();
|
||||
|
||||
public DungeonsXL() {
|
||||
/*
|
||||
@ -124,6 +115,7 @@ public class DungeonsXL extends BRPlugin {
|
||||
// Load Language
|
||||
loadMessageConfig(new File(getDataFolder(), "languages/en.yml"));
|
||||
// Load Config
|
||||
loadDataConfig(new File(getDataFolder(), "data.yml"));
|
||||
loadMainConfig(new File(getDataFolder(), "config.yml"));
|
||||
// Load Language 2
|
||||
loadMessageConfig(new File(getDataFolder(), "languages/" + mainConfig.getLanguage() + ".yml"));
|
||||
@ -134,6 +126,8 @@ public class DungeonsXL extends BRPlugin {
|
||||
loadTriggers();
|
||||
loadDSigns();
|
||||
loadDungeons();
|
||||
loadGlobalProtections();
|
||||
loadDPlayers();
|
||||
|
||||
manager.registerEvents(new EntityListener(), this);
|
||||
manager.registerEvents(new PlayerListener(), this);
|
||||
@ -157,18 +151,13 @@ public class DungeonsXL extends BRPlugin {
|
||||
messageConfig.save();
|
||||
|
||||
// DPlayer leaves World
|
||||
for (DPlayer dPlayer : dPlayers) {
|
||||
for (DPlayer dPlayer : dPlayers.getDPlayers()) {
|
||||
dPlayer.leave();
|
||||
}
|
||||
|
||||
// Delete all Data
|
||||
chatSpyers.clear();
|
||||
dLootInventories.clear();
|
||||
groupSigns.clear();
|
||||
leaveSigns.clear();
|
||||
dPortals.clear();
|
||||
dGroups.clear();
|
||||
dPlayers.clear();
|
||||
|
||||
// Delete Worlds
|
||||
GameWorld.deleteAll();
|
||||
@ -205,36 +194,19 @@ public class DungeonsXL extends BRPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
// Save and Load
|
||||
// Save and load
|
||||
public void saveData() {
|
||||
File file = new File(getDataFolder(), "data.yml");
|
||||
FileConfiguration configFile = new YamlConfiguration();
|
||||
|
||||
DPortal.save(configFile);
|
||||
GroupSign.save(configFile);
|
||||
LeaveSign.save(configFile);
|
||||
|
||||
try {
|
||||
configFile.save(file);
|
||||
|
||||
} catch (IOException exception) {
|
||||
exception.printStackTrace();
|
||||
protections.saveAll();
|
||||
DSavePlayer.save();
|
||||
for (EditWorld editWorld : editWorlds) {
|
||||
editWorld.save();
|
||||
}
|
||||
}
|
||||
|
||||
public void loadAll() {
|
||||
// Load world data
|
||||
File file = new File(getDataFolder(), "data.yml");
|
||||
FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);
|
||||
|
||||
DPortal.load(configFile);
|
||||
GroupSign.load(configFile);
|
||||
LeaveSign.load(configFile);
|
||||
|
||||
// Load saved players
|
||||
protections.loadAll();
|
||||
dPlayers.loadAll();
|
||||
DSavePlayer.load();
|
||||
|
||||
// Check Worlds
|
||||
checkWorlds();
|
||||
}
|
||||
|
||||
@ -267,6 +239,20 @@ public class DungeonsXL extends BRPlugin {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the loaded instance of DataConfig
|
||||
*/
|
||||
public DataConfig getDataConfig() {
|
||||
return dataConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* load / reload a new instance of MainConfig
|
||||
*/
|
||||
public void loadDataConfig(File file) {
|
||||
dataConfig = new DataConfig(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the loaded instance of MainConfig
|
||||
*/
|
||||
@ -421,6 +407,34 @@ public class DungeonsXL extends BRPlugin {
|
||||
dungeons = new Dungeons();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the loaded instance of GlobalProtections
|
||||
*/
|
||||
public GlobalProtections getGlobalProtections() {
|
||||
return protections;
|
||||
}
|
||||
|
||||
/**
|
||||
* load / reload a new instance of GlobalProtections
|
||||
*/
|
||||
public void loadGlobalProtections() {
|
||||
protections = new GlobalProtections();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the loaded instance of DPlayers
|
||||
*/
|
||||
public DPlayers getDPlayers() {
|
||||
return dPlayers;
|
||||
}
|
||||
|
||||
/**
|
||||
* load / reload a new instance of DPlayers
|
||||
*/
|
||||
public void loadDPlayers() {
|
||||
dPlayers = new DPlayers();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the worldUnloadTask
|
||||
*/
|
||||
@ -463,20 +477,6 @@ public class DungeonsXL extends BRPlugin {
|
||||
updateTask = new UpdateTask().runTaskTimer(this, 0L, period);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the inBreakMode
|
||||
*/
|
||||
public CopyOnWriteArrayList<Player> getInBreakMode() {
|
||||
return inBreakMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the chatSpyers
|
||||
*/
|
||||
public CopyOnWriteArrayList<Player> getChatSpyers() {
|
||||
return chatSpyers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dLootInventories
|
||||
*/
|
||||
@ -505,34 +505,6 @@ public class DungeonsXL extends BRPlugin {
|
||||
return gameWorlds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the gameSigns
|
||||
*/
|
||||
public CopyOnWriteArrayList<GameSign> getGameSigns() {
|
||||
return gameSigns;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the groupSigns
|
||||
*/
|
||||
public CopyOnWriteArrayList<GroupSign> getGroupSigns() {
|
||||
return groupSigns;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dPortals
|
||||
*/
|
||||
public CopyOnWriteArrayList<DPortal> getDPortals() {
|
||||
return dPortals;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the leaveSigns
|
||||
*/
|
||||
public CopyOnWriteArrayList<LeaveSign> getLeaveSigns() {
|
||||
return leaveSigns;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the games
|
||||
*/
|
||||
@ -547,11 +519,4 @@ public class DungeonsXL extends BRPlugin {
|
||||
return dGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dPlayers
|
||||
*/
|
||||
public CopyOnWriteArrayList<DPlayer> getDPlayers() {
|
||||
return dPlayers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.config.MessageConfig;
|
||||
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
|
||||
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -44,13 +45,15 @@ public class BreakCommand extends BRCommand {
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
if (!plugin.getInBreakMode().contains(player)) {
|
||||
plugin.getInBreakMode().add(player);
|
||||
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.CMD_BREAK_BREAK_MODE));
|
||||
DGlobalPlayer dGlobalPlayer = plugin.getDPlayers().getByPlayer(player);
|
||||
|
||||
if (dGlobalPlayer.isInBreakMode()) {
|
||||
dGlobalPlayer.setInBreakMode(false);
|
||||
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.CMD_BREAK_PROTECTED_MODE));
|
||||
|
||||
} else {
|
||||
plugin.getInBreakMode().remove(player);
|
||||
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.CMD_BREAK_PROTECTED_MODE));
|
||||
dGlobalPlayer.setInBreakMode(true);
|
||||
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.CMD_BREAK_BREAK_MODE));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.config.MessageConfig;
|
||||
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
|
||||
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -44,13 +45,14 @@ public class ChatSpyCommand extends BRCommand {
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
DGlobalPlayer dGlobalPlayer = plugin.getDPlayers().getByPlayer(player);
|
||||
|
||||
if (plugin.getChatSpyers().contains(player)) {
|
||||
plugin.getChatSpyers().remove(player);
|
||||
if (dGlobalPlayer.isInChatSpyMode()) {
|
||||
dGlobalPlayer.setInChatSpyMode(false);
|
||||
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.CMD_CHATSPY_STOPPED));
|
||||
|
||||
} else {
|
||||
plugin.getChatSpyers().add(player);
|
||||
dGlobalPlayer.setInChatSpyMode(true);
|
||||
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.CMD_CHATSPY_START));
|
||||
}
|
||||
}
|
||||
|
@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2016 Frank Baumann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.command;
|
||||
|
||||
import io.github.dre2n.commons.command.BRCommand;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class DCommands {
|
||||
|
||||
private CopyOnWriteArrayList<BRCommand> dCommands = new CopyOnWriteArrayList<>();
|
||||
|
||||
// Methods
|
||||
public DCommands() {
|
||||
// Add Commands
|
||||
dCommands.add(new HelpCommand());
|
||||
dCommands.add(new BreakCommand());
|
||||
dCommands.add(new ChatCommand());
|
||||
dCommands.add(new ChatSpyCommand());
|
||||
dCommands.add(new CreateCommand());
|
||||
dCommands.add(new EditCommand());
|
||||
dCommands.add(new EscapeCommand());
|
||||
dCommands.add(new GameCommand());
|
||||
dCommands.add(new GroupCommand());
|
||||
dCommands.add(new InviteCommand());
|
||||
dCommands.add(new LeaveCommand());
|
||||
dCommands.add(new ListCommand());
|
||||
dCommands.add(new LivesCommand());
|
||||
dCommands.add(new MainCommand());
|
||||
dCommands.add(new UninviteCommand());
|
||||
dCommands.add(new MsgCommand());
|
||||
dCommands.add(new PlayCommand());
|
||||
dCommands.add(new PortalCommand());
|
||||
dCommands.add(new DeletePortalCommand());
|
||||
dCommands.add(new ReloadCommand());
|
||||
dCommands.add(new SaveCommand());
|
||||
dCommands.add(new TestCommand());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param command
|
||||
* usually the first command variable
|
||||
*/
|
||||
public BRCommand getDCommand(String command) {
|
||||
for (BRCommand dCommand : dCommands) {
|
||||
if (dCommand.getCommand().equals(command)) {
|
||||
return dCommand;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dCommands
|
||||
*/
|
||||
public List<BRCommand> getDCommands() {
|
||||
return dCommands;
|
||||
}
|
||||
|
||||
}
|
@ -114,7 +114,7 @@ public class GroupCommand extends BRCommand {
|
||||
DGroupCreateEvent event = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.COMMAND);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
plugin.getDGroups().remove(dGroup);
|
||||
dGroup.delete();
|
||||
dGroup = null;
|
||||
|
||||
} else {
|
||||
@ -131,7 +131,7 @@ public class GroupCommand extends BRCommand {
|
||||
DGroupDisbandEvent event = new DGroupDisbandEvent(dGroup, player, DGroupDisbandEvent.Cause.COMMAND);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
plugin.getDGroups().remove(dGroup);
|
||||
dGroup.delete();
|
||||
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.GROUP_DISBANDED, sender.getName(), dGroup.getName()));
|
||||
dGroup = null;
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.config.MessageConfig;
|
||||
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
|
||||
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerEscapeEvent;
|
||||
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerLeaveDGroupEvent;
|
||||
import io.github.dre2n.dungeonsxl.game.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||
@ -58,9 +59,12 @@ public class LeaveCommand extends BRCommand {
|
||||
}
|
||||
|
||||
if (dPlayer != null) {
|
||||
DPlayerEscapeEvent event = new DPlayerEscapeEvent(dPlayer);
|
||||
DGroup dGroup = DGroup.getByPlayer(player);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
DPlayerEscapeEvent dPlayerEscapeEvent = new DPlayerEscapeEvent(dPlayer);
|
||||
DPlayerLeaveDGroupEvent dPlayerLeaveDGroupEvent = new DPlayerLeaveDGroupEvent(dPlayer, dGroup);
|
||||
|
||||
if (dPlayerEscapeEvent.isCancelled() || dPlayerLeaveDGroupEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class MainCommand extends BRCommand {
|
||||
int maps = new File(plugin.getDataFolder() + "/maps").listFiles().length;
|
||||
int dungeons = new File(plugin.getDataFolder() + "/dungeons").listFiles().length;
|
||||
int loaded = plugin.getEditWorlds().size() + plugin.getGameWorlds().size();
|
||||
int players = plugin.getDPlayers().size();
|
||||
int players = plugin.getDPlayers().getDPlayers().size();
|
||||
Internals internals = CompatibilityHandler.getInstance().getInternals();
|
||||
String vault = "";
|
||||
if (plugins.getPlugin("Vault") != null) {
|
||||
|
@ -160,7 +160,7 @@ public class PlayCommand extends BRCommand {
|
||||
|
||||
if (dGroup.getGameWorld() == null) {
|
||||
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_NOT_SAVED, DGroup.getByPlayer(player).getMapName()));
|
||||
dGroup.remove();
|
||||
dGroup.delete();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.config.MessageConfig;
|
||||
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
|
||||
import io.github.dre2n.dungeonsxl.global.DPortal;
|
||||
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -48,23 +49,25 @@ public class PortalCommand extends BRCommand {
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
DPlayer dPlayer = DPlayer.getByPlayer(player);
|
||||
DGlobalPlayer dGlobalPlayer = plugin.getDPlayers().getByPlayer(player);
|
||||
|
||||
if (dPlayer != null) {
|
||||
if (dGlobalPlayer instanceof DPlayer) {
|
||||
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_LEAVE_DUNGEON));
|
||||
return;
|
||||
}
|
||||
|
||||
DPortal dPortal = DPortal.getByPlayer(player);
|
||||
DPortal dPortal = dGlobalPlayer.getPortal();
|
||||
|
||||
if (dPortal == null) {
|
||||
dPortal = new DPortal(false);
|
||||
dPortal.setPlayer(player);
|
||||
dPortal = new DPortal(plugin.getGlobalProtections().generateId(DPortal.class, player.getWorld()), player.getWorld(), false);
|
||||
dGlobalPlayer.setCreatingPortal(dPortal);
|
||||
dPortal.setWorld(player.getWorld());
|
||||
player.getInventory().setItemInHand(new ItemStack(Material.WOOD_SWORD));
|
||||
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.PLAYER_PORTAL_INTRODUCTION));
|
||||
|
||||
} else {
|
||||
plugin.getDPortals().remove(dPortal);
|
||||
dPortal.delete();
|
||||
dGlobalPlayer.setCreatingPortal(null);
|
||||
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.PLAYER_PORTAL_ABORT));
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class ReloadCommand extends BRCommand {
|
||||
int maps = new File(plugin.getDataFolder() + "/maps").listFiles().length;
|
||||
int dungeons = new File(plugin.getDataFolder() + "/dungeons").listFiles().length;
|
||||
int loaded = plugin.getEditWorlds().size() + plugin.getGameWorlds().size();
|
||||
int players = plugin.getDPlayers().size();
|
||||
int players = plugin.getDPlayers().getDPlayers().size();
|
||||
Internals internals = CompatibilityHandler.getInstance().getInternals();
|
||||
String vault = "";
|
||||
if (plugins.getPlugin("Vault") != null) {
|
||||
@ -72,6 +72,7 @@ public class ReloadCommand extends BRCommand {
|
||||
// Load Language
|
||||
plugin.loadMessageConfig(new File(plugin.getDataFolder(), "languages/en.yml"));
|
||||
// Load Config
|
||||
plugin.loadDataConfig(new File(plugin.getDataFolder(), "data.yml"));
|
||||
plugin.loadMainConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
// Load Language 2
|
||||
plugin.loadMessageConfig(new File(plugin.getDataFolder(), "languages/" + plugin.getMainConfig().getLanguage() + ".yml"));
|
||||
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2016 Frank Baumann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.config;
|
||||
|
||||
import io.github.dre2n.commons.config.BRConfig;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class DataConfig extends BRConfig {
|
||||
|
||||
public static final int CONFIG_VERSION = 1;
|
||||
|
||||
public DataConfig(File file) {
|
||||
super(file, CONFIG_VERSION);
|
||||
|
||||
if (initialize) {
|
||||
initialize();
|
||||
}
|
||||
load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
// Load?
|
||||
}
|
||||
|
||||
}
|
@ -30,6 +30,7 @@ public class DGroupDisbandEvent extends DGroupEvent implements Cancellable {
|
||||
|
||||
COMMAND,
|
||||
DUNGEON_FINISHED,
|
||||
GROUP_IS_EMPTY,
|
||||
CUSTOM
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Daniel Saukel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.event.dplayer;
|
||||
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class DPlayerLeaveDGroupEvent extends DPlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
|
||||
private DGroup dGroup;
|
||||
|
||||
public DPlayerLeaveDGroupEvent(DPlayer dPlayer, DGroup dGroup) {
|
||||
super(dPlayer);
|
||||
this.dGroup = dGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dGroup
|
||||
*/
|
||||
public DGroup getDGroup() {
|
||||
return dGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
}
|
@ -648,6 +648,7 @@ public class GameWorld {
|
||||
|
||||
if (bestTime == 0) {
|
||||
return false;
|
||||
|
||||
} else if (worldConfig.getTimeLastPlayed() != 0) {
|
||||
if (System.currentTimeMillis() - bestTime > worldConfig.getTimeLastPlayed() * (long) 3600000) {
|
||||
return false;
|
||||
|
@ -16,12 +16,14 @@
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.global;
|
||||
|
||||
import io.github.dre2n.commons.util.BlockUtil;
|
||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
|
||||
import io.github.dre2n.dungeonsxl.game.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||
import java.util.Set;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@ -32,34 +34,27 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* @author Frank Baumann, Daniel Saukel
|
||||
*/
|
||||
public class DPortal {
|
||||
public class DPortal extends GlobalProtection {
|
||||
|
||||
protected static DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
protected static GlobalProtections protections = plugin.getGlobalProtections();
|
||||
|
||||
private World world;
|
||||
private Block block1;
|
||||
private Block block2;
|
||||
private boolean active;
|
||||
private Player player;
|
||||
private Set<Block> blocks;
|
||||
|
||||
public DPortal(boolean active) {
|
||||
plugin.getDPortals().add(this);
|
||||
public DPortal(int id, World world, boolean active) {
|
||||
super(world, id);
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the world
|
||||
*/
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
public DPortal(int id, Block block1, Block block2, boolean active) {
|
||||
super(block1.getWorld(), id);
|
||||
|
||||
/**
|
||||
* @param world
|
||||
* the world to set
|
||||
*/
|
||||
public void setWorld(World world) {
|
||||
this.world = world;
|
||||
this.block1 = block1;
|
||||
this.block2 = block2;
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -108,25 +103,11 @@ public class DPortal {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the player
|
||||
* Create a new DPortal
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* the player to set
|
||||
*/
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public void create() {
|
||||
player = null;
|
||||
|
||||
if (block1 == null || block2 == null) {
|
||||
plugin.getDPortals().remove(this);
|
||||
delete();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -158,12 +139,12 @@ public class DPortal {
|
||||
int zz = z1;
|
||||
|
||||
do {
|
||||
Material type = world.getBlockAt(xx, yy, zz).getType();
|
||||
Material type = getWorld().getBlockAt(xx, yy, zz).getType();
|
||||
if (type == Material.AIR || type == Material.WATER || type == Material.STATIONARY_WATER || type == Material.LAVA || type == Material.STATIONARY_LAVA || type == Material.SAPLING
|
||||
|| type == Material.WEB || type == Material.LONG_GRASS || type == Material.DEAD_BUSH || type == Material.PISTON_EXTENSION || type == Material.YELLOW_FLOWER
|
||||
|| type == Material.RED_ROSE || type == Material.BROWN_MUSHROOM || type == Material.RED_MUSHROOM || type == Material.TORCH || type == Material.FIRE
|
||||
|| type == Material.CROPS || type == Material.REDSTONE_WIRE || type == Material.REDSTONE_TORCH_OFF || type == Material.SNOW || type == Material.REDSTONE_TORCH_ON) {
|
||||
world.getBlockAt(xx, yy, zz).setType(Material.PORTAL);
|
||||
getWorld().getBlockAt(xx, yy, zz).setType(Material.PORTAL);
|
||||
}
|
||||
|
||||
zz = zz + zcount;
|
||||
@ -176,6 +157,10 @@ public class DPortal {
|
||||
} while (xx != x2 + xcount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* the player to teleport into his dungeon
|
||||
*/
|
||||
public void teleport(Player player) {
|
||||
DGroup dgroup = DGroup.getByPlayer(player);
|
||||
|
||||
@ -201,8 +186,35 @@ public class DPortal {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Block> getBlocks() {
|
||||
if (blocks == null) {
|
||||
blocks = BlockUtil.getBlocksBetween(block1, block2);
|
||||
}
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(FileConfiguration configFile) {
|
||||
if (!active) {
|
||||
return;
|
||||
}
|
||||
|
||||
String preString = "portal." + getWorld().getName() + "." + getId();
|
||||
// Location1
|
||||
configFile.set(preString + ".loc1.x", block1.getX());
|
||||
configFile.set(preString + ".loc1.y", block1.getY());
|
||||
configFile.set(preString + ".loc1.z", block1.getZ());
|
||||
// Location1
|
||||
configFile.set(preString + ".loc2.x", block2.getX());
|
||||
configFile.set(preString + ".loc2.y", block2.getY());
|
||||
configFile.set(preString + ".loc2.z", block2.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
plugin.getDPortals().remove(this);
|
||||
protections.removeProtection(this);
|
||||
|
||||
int x1 = block1.getX(), y1 = block1.getY(), z1 = block1.getZ();
|
||||
int x2 = block2.getX(), y2 = block2.getY(), z2 = block2.getZ();
|
||||
@ -232,10 +244,10 @@ public class DPortal {
|
||||
do {
|
||||
int zz = z1;
|
||||
do {
|
||||
Material type = world.getBlockAt(xx, yy, zz).getType();
|
||||
Material type = getWorld().getBlockAt(xx, yy, zz).getType();
|
||||
|
||||
if (type == Material.PORTAL) {
|
||||
world.getBlockAt(xx, yy, zz).setType(Material.AIR);
|
||||
getWorld().getBlockAt(xx, yy, zz).setType(Material.AIR);
|
||||
}
|
||||
|
||||
zz = zz + zcount;
|
||||
@ -249,12 +261,21 @@ public class DPortal {
|
||||
}
|
||||
|
||||
/* Statics */
|
||||
/**
|
||||
* @param location
|
||||
* a location covered by the returned portal
|
||||
*/
|
||||
public static DPortal getByLocation(Location location) {
|
||||
return getByBlock(location.getBlock());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param block
|
||||
* a block covered by the returned portal
|
||||
*/
|
||||
public static DPortal getByBlock(Block block) {
|
||||
for (DPortal portal : plugin.getDPortals()) {
|
||||
for (GlobalProtection protection : protections.getProtections(DPortal.class)) {
|
||||
DPortal portal = (DPortal) protection;
|
||||
int x1 = portal.block1.getX(), y1 = portal.block1.getY(), z1 = portal.block1.getZ();
|
||||
int x2 = portal.block2.getX(), y2 = portal.block2.getY(), z2 = portal.block2.getZ();
|
||||
int x3 = block.getX(), y3 = block.getY(), z3 = block.getZ();
|
||||
@ -291,60 +312,4 @@ public class DPortal {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static DPortal getByPlayer(Player player) {
|
||||
for (DPortal portal : plugin.getDPortals()) {
|
||||
if (portal.player == player) {
|
||||
return portal;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Save and Load
|
||||
public static void save(FileConfiguration configFile) {
|
||||
int id = 0;
|
||||
for (DPortal dPortal : plugin.getDPortals()) {
|
||||
id++;
|
||||
|
||||
if (!dPortal.active) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String preString = "portal." + dPortal.world.getName() + "." + id;
|
||||
// Location1
|
||||
configFile.set(preString + ".loc1.x", dPortal.block1.getX());
|
||||
configFile.set(preString + ".loc1.y", dPortal.block1.getY());
|
||||
configFile.set(preString + ".loc1.z", dPortal.block1.getZ());
|
||||
// Location1
|
||||
configFile.set(preString + ".loc2.x", dPortal.block2.getX());
|
||||
configFile.set(preString + ".loc2.y", dPortal.block2.getY());
|
||||
configFile.set(preString + ".loc2.z", dPortal.block2.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
public static void load(FileConfiguration configFile) {
|
||||
for (World world : plugin.getServer().getWorlds()) {
|
||||
if (!configFile.contains("portal." + world.getName())) {
|
||||
return;
|
||||
}
|
||||
|
||||
int id = 0;
|
||||
String preString;
|
||||
do {
|
||||
id++;
|
||||
preString = "portal." + world.getName() + "." + id + ".";
|
||||
|
||||
if (configFile.contains(preString)) {
|
||||
DPortal dPortal = new DPortal(true);
|
||||
dPortal.world = world;
|
||||
dPortal.block1 = world.getBlockAt(configFile.getInt(preString + "loc1.x"), configFile.getInt(preString + "loc1.y"), configFile.getInt(preString + "loc1.z"));
|
||||
dPortal.block2 = world.getBlockAt(configFile.getInt(preString + "loc2.x"), configFile.getInt(preString + "loc2.y"), configFile.getInt(preString + "loc2.z"));
|
||||
dPortal.create();
|
||||
}
|
||||
|
||||
} while (configFile.contains(preString));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.global;
|
||||
|
||||
import io.github.dre2n.commons.util.BlockUtil;
|
||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
|
||||
@ -25,6 +26,8 @@ import io.github.dre2n.dungeonsxl.game.Game;
|
||||
import io.github.dre2n.dungeonsxl.game.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -37,15 +40,16 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
||||
*/
|
||||
public class GameSign {
|
||||
public class GameSign extends GlobalProtection {
|
||||
|
||||
protected static DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
protected static GlobalProtections protections = plugin.getGlobalProtections();
|
||||
|
||||
// Sign Labels
|
||||
public static final String IS_PLAYING = ChatColor.DARK_RED + "Is Playing";
|
||||
public static final String FULL = ChatColor.DARK_RED + "Full";
|
||||
public static final String JOIN_GROUP = ChatColor.DARK_GREEN + "Join Game";
|
||||
public static final String NEW_GROUP = ChatColor.DARK_GREEN + "New Game";
|
||||
public static final String JOIN_GAME = ChatColor.DARK_GREEN + "Join Game";
|
||||
public static final String NEW_GAME = ChatColor.DARK_GREEN + "New Game";
|
||||
|
||||
// Variables
|
||||
private Game[] games;
|
||||
@ -56,9 +60,10 @@ public class GameSign {
|
||||
private Block startSign;
|
||||
private int directionX = 0, directionZ = 0;
|
||||
private int verticalSigns;
|
||||
private Set<Block> blocks;
|
||||
|
||||
public GameSign(Block startSign, String identifier, int maxGames, int maxGroupsPerGame, boolean multiFloor) {
|
||||
plugin.getGameSigns().add(this);
|
||||
public GameSign(int id, Block startSign, String identifier, int maxGames, int maxGroupsPerGame, boolean multiFloor) {
|
||||
super(startSign.getWorld(), id);
|
||||
|
||||
this.startSign = startSign;
|
||||
games = new Game[maxGames];
|
||||
@ -84,6 +89,36 @@ public class GameSign {
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the games
|
||||
*/
|
||||
public Game[] getGames() {
|
||||
return games;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param games
|
||||
* the games to set
|
||||
*/
|
||||
public void setGames(Game[] games) {
|
||||
this.games = games;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the multiFloor
|
||||
*/
|
||||
public boolean isMultiFloor() {
|
||||
return multiFloor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param multiFloor
|
||||
* the multiFloor to set
|
||||
*/
|
||||
public void setMultiFloor(boolean multiFloor) {
|
||||
this.multiFloor = multiFloor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dungeonName
|
||||
*/
|
||||
@ -115,24 +150,23 @@ public class GameSign {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the multiFloor
|
||||
* @return the maximum player count per group
|
||||
*/
|
||||
public boolean isMultiFloor() {
|
||||
return multiFloor;
|
||||
public int getMaxGroupsPerGame() {
|
||||
return maxGroupsPerGame;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param multiFloor
|
||||
* the multiFloor to set
|
||||
* @param maxGroupsPerGame
|
||||
* the maximum player count per group to set
|
||||
*/
|
||||
public void setMultiFloor(boolean multiFloor) {
|
||||
this.multiFloor = multiFloor;
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
plugin.getGameSigns().remove(this);
|
||||
public void setMaxGroupsPerGame(int maxGroupsPerGame) {
|
||||
this.maxGroupsPerGame = maxGroupsPerGame;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update this game sign to show the game(s) correctly.
|
||||
*/
|
||||
public void update() {
|
||||
int i = 0;
|
||||
for (Game game : games) {
|
||||
@ -169,7 +203,7 @@ public class GameSign {
|
||||
sign.setLine(0, FULL);
|
||||
|
||||
} else {
|
||||
sign.setLine(0, JOIN_GROUP);
|
||||
sign.setLine(0, JOIN_GAME);
|
||||
}
|
||||
|
||||
int j = 1;
|
||||
@ -190,7 +224,7 @@ public class GameSign {
|
||||
}
|
||||
|
||||
} else {
|
||||
sign.setLine(0, NEW_GROUP);
|
||||
sign.setLine(0, NEW_GAME);
|
||||
}
|
||||
|
||||
sign.update();
|
||||
@ -199,7 +233,121 @@ public class GameSign {
|
||||
}
|
||||
}
|
||||
|
||||
// Static
|
||||
@Override
|
||||
public Set<Block> getBlocks() {
|
||||
if (blocks == null) {
|
||||
blocks = new HashSet<>();
|
||||
|
||||
int i = games.length;
|
||||
do {
|
||||
i--;
|
||||
|
||||
blocks.add(startSign.getRelative(i * directionX, 0, i * directionZ));
|
||||
|
||||
} while (i >= 0);
|
||||
|
||||
HashSet<Block> toAdd = new HashSet<>();
|
||||
for (Block block : blocks) {
|
||||
i = verticalSigns;
|
||||
do {
|
||||
i--;
|
||||
|
||||
Block beneath = block.getLocation().add(0, -1 * i, 0).getBlock();
|
||||
toAdd.add(beneath);
|
||||
toAdd.add(BlockUtil.getAttachedBlock(beneath));
|
||||
|
||||
} while (i >= 0);
|
||||
}
|
||||
blocks.addAll(toAdd);
|
||||
}
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(FileConfiguration config) {
|
||||
String preString = "gamesign." + getWorld().getName() + "." + getId();
|
||||
|
||||
config.set(preString + ".x", startSign.getX());
|
||||
config.set(preString + ".y", startSign.getY());
|
||||
config.set(preString + ".z", startSign.getZ());
|
||||
|
||||
if (isMultiFloor()) {
|
||||
config.set(preString + ".dungeon", dungeonName);
|
||||
|
||||
} else {
|
||||
config.set(preString + ".dungeon", mapName);
|
||||
}
|
||||
|
||||
config.set(preString + ".maxGames", games.length);
|
||||
config.set(preString + ".maxGroupsPerGame", maxGroupsPerGame);
|
||||
config.set(preString + ".multiFloor", isMultiFloor());
|
||||
}
|
||||
|
||||
/* Statics */
|
||||
/**
|
||||
* @param block
|
||||
* a block which is protected by the returned GameSign
|
||||
*/
|
||||
public static GameSign getByBlock(Block block) {
|
||||
if (!(block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int x = block.getX(), y = block.getY(), z = block.getZ();
|
||||
for (GlobalProtection protection : protections.getProtections(GameSign.class)) {
|
||||
GameSign gameSign = (GameSign) protection;
|
||||
|
||||
int sx1 = gameSign.startSign.getX(), sy1 = gameSign.startSign.getY(), sz1 = gameSign.startSign.getZ();
|
||||
int sx2 = sx1 + (gameSign.games.length - 1) * gameSign.directionX;
|
||||
int sy2 = sy1 - gameSign.verticalSigns + 1;
|
||||
int sz2 = sz1 + (gameSign.games.length - 1) * gameSign.directionZ;
|
||||
|
||||
if (sx1 > sx2) {
|
||||
if (x < sx2 || x > sx1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if (sx1 < sx2) {
|
||||
if (x > sx2 || x < sx1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if (x != sx1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sy1 > sy2) {
|
||||
if (y < sy2 || y > sy1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if (y != sy1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sz1 > sz2) {
|
||||
if (z < sz2 || z > sz1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if (sz1 < sz2) {
|
||||
if (z > sz2 || z < sz1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if (z != sz1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return gameSign;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/* SUBJECT TO CHANGE*/
|
||||
@Deprecated
|
||||
public static GameSign tryToCreate(Block startSign, String mapName, int maxGames, int maxGroupsPerGame, boolean multiFloor) {
|
||||
World world = startSign.getWorld();
|
||||
int direction = startSign.getData();
|
||||
@ -296,94 +444,15 @@ public class GameSign {
|
||||
block.setTypeIdAndData(68, startSign.getData(), true);
|
||||
}
|
||||
|
||||
GameSign sign = new GameSign(startSign, mapName, maxGames, maxGroupsPerGame, multiFloor);
|
||||
GameSign sign = new GameSign(protections.generateId(GameSign.class, world), startSign, mapName, maxGames, maxGroupsPerGame, multiFloor);
|
||||
|
||||
return sign;
|
||||
}
|
||||
|
||||
public static boolean isRelativeSign(Block block, int x, int z) {
|
||||
GameSign gameSign = getSign(block.getRelative(x, 0, z));
|
||||
if (gameSign == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (x == -1 && gameSign.startSign.getData() == 4) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (x == 1 && gameSign.startSign.getData() == 5) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (z == -1 && gameSign.startSign.getData() == 2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (z == 1 && gameSign.startSign.getData() == 3) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static GameSign getSign(Block block) {
|
||||
if (!(block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int x = block.getX(), y = block.getY(), z = block.getZ();
|
||||
for (GameSign gameSign : plugin.getGameSigns()) {
|
||||
int sx1 = gameSign.startSign.getX(), sy1 = gameSign.startSign.getY(), sz1 = gameSign.startSign.getZ();
|
||||
int sx2 = sx1 + (gameSign.games.length - 1) * gameSign.directionX;
|
||||
int sy2 = sy1 - gameSign.verticalSigns + 1;
|
||||
int sz2 = sz1 + (gameSign.games.length - 1) * gameSign.directionZ;
|
||||
|
||||
if (sx1 > sx2) {
|
||||
if (x < sx2 || x > sx1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if (sx1 < sx2) {
|
||||
if (x > sx2 || x < sx1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if (x != sx1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sy1 > sy2) {
|
||||
if (y < sy2 || y > sy1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if (y != sy1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sz1 > sz2) {
|
||||
if (z < sz2 || z > sz1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if (sz1 < sz2) {
|
||||
if (z > sz2 || z < sz1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if (z != sz1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return gameSign;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean playerInteract(Block block, Player player) {
|
||||
int x = block.getX(), y = block.getY(), z = block.getZ();
|
||||
GameSign gameSign = getSign(block);
|
||||
GameSign gameSign = getByBlock(block);
|
||||
|
||||
if (gameSign == null) {
|
||||
return false;
|
||||
@ -391,6 +460,11 @@ public class GameSign {
|
||||
|
||||
DGroup dGroup = DGroup.getByPlayer(player);
|
||||
|
||||
if (dGroup == null) {
|
||||
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.ERROR_JOIN_GROUP));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!dGroup.getCaptain().equals(player)) {
|
||||
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.ERROR_NOT_CAPTAIN));
|
||||
return true;
|
||||
@ -436,11 +510,11 @@ public class GameSign {
|
||||
|
||||
Sign topSign = (Sign) topBlock.getState();
|
||||
|
||||
if (topSign.getLine(0).equals(NEW_GROUP)) {
|
||||
if (topSign.getLine(0).equals(NEW_GAME)) {
|
||||
gameSign.games[column] = new Game(dGroup);
|
||||
gameSign.update();
|
||||
|
||||
} else if (topSign.getLine(0).equals(JOIN_GROUP)) {
|
||||
} else if (topSign.getLine(0).equals(JOIN_GAME)) {
|
||||
gameSign.games[column].addDGroup(dGroup);
|
||||
gameSign.update();
|
||||
}
|
||||
@ -448,9 +522,11 @@ public class GameSign {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void updatePerGame(Game gameSearch) {
|
||||
for (GlobalProtection protection : protections.getProtections(GameSign.class)) {
|
||||
GameSign gameSign = (GameSign) protection;
|
||||
|
||||
for (GameSign gameSign : plugin.getGameSigns()) {
|
||||
int i = 0;
|
||||
for (Game game : gameSign.games) {
|
||||
if (game == null) {
|
||||
@ -469,6 +545,7 @@ public class GameSign {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static int[] getDirection(byte data) {
|
||||
int[] direction = new int[2];
|
||||
|
||||
@ -492,58 +569,4 @@ public class GameSign {
|
||||
return direction;
|
||||
}
|
||||
|
||||
// Save and Load
|
||||
public static void save(FileConfiguration configFile) {
|
||||
int id = 0;
|
||||
|
||||
for (GameSign gameSign : plugin.getGameSigns()) {
|
||||
id++;
|
||||
String preString = "gamesign." + gameSign.startSign.getWorld().getName() + "." + id;
|
||||
|
||||
// Location
|
||||
configFile.set(preString + ".x", gameSign.startSign.getX());
|
||||
configFile.set(preString + ".y", gameSign.startSign.getY());
|
||||
configFile.set(preString + ".z", gameSign.startSign.getZ());
|
||||
|
||||
// Etc.
|
||||
if (gameSign.isMultiFloor()) {
|
||||
configFile.set(preString + ".dungeon", gameSign.dungeonName);
|
||||
|
||||
} else {
|
||||
configFile.set(preString + ".dungeon", gameSign.mapName);
|
||||
}
|
||||
|
||||
configFile.set(preString + ".maxGames", gameSign.games.length);
|
||||
configFile.set(preString + ".maxGroupsPerGame", gameSign.maxGroupsPerGame);
|
||||
configFile.set(preString + ".multiFloor", gameSign.isMultiFloor());
|
||||
}
|
||||
}
|
||||
|
||||
public static void load(FileConfiguration configFile) {
|
||||
for (World world : plugin.getServer().getWorlds()) {
|
||||
if (!configFile.contains("gamesign." + world.getName())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int id = 0;
|
||||
String preString;
|
||||
do {
|
||||
id++;
|
||||
preString = "gamesign." + world.getName() + "." + id + ".";
|
||||
if (configFile.contains(preString)) {
|
||||
String mapName = configFile.getString(preString + ".dungeon");
|
||||
int maxGames = configFile.getInt(preString + ".maxGames");
|
||||
int maxGroupsPerGame = configFile.getInt(preString + ".maxGroupsPerGame");
|
||||
boolean multiFloor = false;
|
||||
if (configFile.contains(preString + ".multiFloor")) {
|
||||
multiFloor = configFile.getBoolean(preString + ".multiFloor");
|
||||
}
|
||||
Block startSign = world.getBlockAt(configFile.getInt(preString + ".x"), configFile.getInt(preString + ".y"), configFile.getInt(preString + ".z"));
|
||||
|
||||
new GameSign(startSign, mapName, maxGames, maxGroupsPerGame, multiFloor);
|
||||
}
|
||||
} while (configFile.contains(preString));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.global;
|
||||
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public abstract class GlobalProtection {
|
||||
|
||||
protected static DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
protected static FileConfiguration config = plugin.getDataConfig().getConfig();
|
||||
protected static GlobalProtections protections = plugin.getGlobalProtections();
|
||||
|
||||
private World world;
|
||||
private int id;
|
||||
|
||||
protected GlobalProtection(World world, int id) {
|
||||
this.world = world;
|
||||
this.id = id;
|
||||
|
||||
protections.addProtection(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the world
|
||||
*/
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param world
|
||||
* the world to set
|
||||
*/
|
||||
public void setWorld(World world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete this protection.
|
||||
*/
|
||||
public void delete() {
|
||||
protections.removeProtection(this);
|
||||
}
|
||||
|
||||
/* Abstracts */
|
||||
/**
|
||||
* Save the data to the default file
|
||||
*/
|
||||
public void save() {
|
||||
save(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param file
|
||||
* the file to save the protection to
|
||||
*/
|
||||
public void save(File file) {
|
||||
save(YamlConfiguration.loadConfiguration(file));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param config
|
||||
* the config to save the protection to
|
||||
*/
|
||||
public abstract void save(FileConfiguration config);
|
||||
|
||||
/**
|
||||
* @return a collection of all blocks covered by this protection
|
||||
*/
|
||||
public abstract Collection<Block> getBlocks();
|
||||
|
||||
}
|
@ -0,0 +1,236 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.global;
|
||||
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class GlobalProtections {
|
||||
|
||||
protected static DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
|
||||
private Set<GlobalProtection> protections = new HashSet<>();
|
||||
|
||||
/**
|
||||
* @return the protection which covers this location
|
||||
*/
|
||||
public GlobalProtection getByLocation(Location location) {
|
||||
return getByBlock(location.getBlock());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the protection which covers this block
|
||||
*/
|
||||
public GlobalProtection getByBlock(Block block) {
|
||||
for (GlobalProtection protection : protections) {
|
||||
if (protection.getBlocks().contains(block)) {
|
||||
return protection;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the protections
|
||||
*/
|
||||
public Set<GlobalProtection> getProtections() {
|
||||
return protections;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* All protections which are an instance of it will be returned.
|
||||
*/
|
||||
public Set<GlobalProtection> getProtections(Class<? extends GlobalProtection> type) {
|
||||
Set<GlobalProtection> protectionsOfType = new HashSet<>();
|
||||
for (GlobalProtection protection : protections) {
|
||||
if (protection.getClass() == type) {
|
||||
protectionsOfType.add(protection);
|
||||
}
|
||||
}
|
||||
return protectionsOfType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param protection
|
||||
* the protection type to add
|
||||
*/
|
||||
public void addProtection(GlobalProtection protection) {
|
||||
protections.add(protection);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param protection
|
||||
* the protection to remove
|
||||
*/
|
||||
public void removeProtection(GlobalProtection protection) {
|
||||
protections.remove(protection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save all protections to the default file
|
||||
*/
|
||||
public void saveAll() {
|
||||
saveAll(plugin.getDataConfig().getConfig());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param file
|
||||
* the file to save all protections to
|
||||
*/
|
||||
public void saveAll(File file) {
|
||||
saveAll(YamlConfiguration.loadConfiguration(file));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param config
|
||||
* the config to save all protections to
|
||||
*/
|
||||
public void saveAll(FileConfiguration config) {
|
||||
for (GlobalProtection protection : protections) {
|
||||
protection.save(config);
|
||||
}
|
||||
|
||||
plugin.getDataConfig().save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* Each type is stored seperately.
|
||||
* @param world
|
||||
* Each world has its own IDs.
|
||||
* @return an unused ID number for a new protection
|
||||
*/
|
||||
public int generateId(Class<? extends GlobalProtection> type, World world) {
|
||||
int id = 1;
|
||||
for (GlobalProtection protection : protections) {
|
||||
if (protection.getClass() == type) {
|
||||
id++;
|
||||
}
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param block
|
||||
* the block to check
|
||||
*/
|
||||
public boolean isProtectedBlock(Block block) {
|
||||
for (GlobalProtection protection : protections) {
|
||||
if (protection.getBlocks().contains(block)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* SUBJECT TO CHANGE */
|
||||
@Deprecated
|
||||
public void loadAll() {
|
||||
FileConfiguration data = plugin.getDataConfig().getConfig();
|
||||
|
||||
for (World world : plugin.getServer().getWorlds()) {
|
||||
// GameSigns
|
||||
if (data.contains("gamesign." + world.getName())) {
|
||||
int id = 0;
|
||||
String preString;
|
||||
|
||||
do {
|
||||
id++;
|
||||
preString = "gamesign." + world.getName() + "." + id + ".";
|
||||
if (data.contains(preString)) {
|
||||
String mapName = data.getString(preString + ".dungeon");
|
||||
int maxGames = data.getInt(preString + ".maxGames");
|
||||
int maxGroupsPerGame = data.getInt(preString + ".maxGroupsPerGame");
|
||||
boolean multiFloor = false;
|
||||
if (data.contains(preString + ".multiFloor")) {
|
||||
multiFloor = data.getBoolean(preString + ".multiFloor");
|
||||
}
|
||||
Block startSign = world.getBlockAt(data.getInt(preString + ".x"), data.getInt(preString + ".y"), data.getInt(preString + ".z"));
|
||||
|
||||
new GameSign(id, startSign, mapName, maxGames, maxGroupsPerGame, multiFloor);
|
||||
}
|
||||
|
||||
} while (data.contains(preString));
|
||||
}
|
||||
|
||||
// GroupSigns
|
||||
if (data.contains("groupsign." + world.getName())) {
|
||||
int id = 0;
|
||||
String preString;
|
||||
|
||||
do {
|
||||
id++;
|
||||
preString = "groupsign." + world.getName() + "." + id + ".";
|
||||
if (data.contains(preString)) {
|
||||
String mapName = data.getString(preString + ".dungeon");
|
||||
int maxGroups = data.getInt(preString + ".maxGroups");
|
||||
int maxPlayersPerGroup = data.getInt(preString + ".maxPlayersPerGroup");
|
||||
boolean multiFloor = false;
|
||||
if (data.contains(preString + ".multiFloor")) {
|
||||
multiFloor = data.getBoolean(preString + ".multiFloor");
|
||||
}
|
||||
Block startSign = world.getBlockAt(data.getInt(preString + ".x"), data.getInt(preString + ".y"), data.getInt(preString + ".z"));
|
||||
|
||||
new GroupSign(id, startSign, mapName, maxGroups, maxPlayersPerGroup, multiFloor);
|
||||
}
|
||||
} while (data.contains(preString));
|
||||
}
|
||||
|
||||
if (data.contains("leavesign." + world.getName())) {
|
||||
|
||||
int id = 0;
|
||||
String preString;
|
||||
|
||||
do {
|
||||
id++;
|
||||
preString = "leavesign." + world.getName() + "." + id + ".";
|
||||
if (data.contains(preString)) {
|
||||
Block block = world.getBlockAt(data.getInt(preString + ".x"), data.getInt(preString + ".y"), data.getInt(preString + ".z"));
|
||||
if (block.getState() instanceof Sign) {
|
||||
Sign sign = (Sign) block.getState();
|
||||
new LeaveSign(id, sign);
|
||||
}
|
||||
}
|
||||
|
||||
} while (data.contains(preString));
|
||||
}
|
||||
|
||||
// DPortals
|
||||
if (data.contains("portal." + world.getName())) {
|
||||
int id = 0;
|
||||
String preString;
|
||||
|
||||
do {
|
||||
id++;
|
||||
preString = "portal." + world.getName() + "." + id + ".";
|
||||
|
||||
if (data.contains(preString)) {
|
||||
Block block1 = world.getBlockAt(data.getInt(preString + "loc1.x"), data.getInt(preString + "loc1.y"), data.getInt(preString + "loc1.z"));
|
||||
Block block2 = world.getBlockAt(data.getInt(preString + "loc2.x"), data.getInt(preString + "loc2.y"), data.getInt(preString + "loc2.z"));
|
||||
DPortal dPortal = new DPortal(id, block1, block2, true);
|
||||
dPortal.create();
|
||||
}
|
||||
|
||||
} while (data.contains(preString));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.global;
|
||||
|
||||
import io.github.dre2n.commons.util.BlockUtil;
|
||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
|
||||
@ -24,6 +25,8 @@ import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
||||
import io.github.dre2n.dungeonsxl.game.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -36,9 +39,10 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* @author Frank Baumann, Milan Albrecht, Daniel Saukel
|
||||
*/
|
||||
public class GroupSign {
|
||||
public class GroupSign extends GlobalProtection {
|
||||
|
||||
protected static DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
protected static GlobalProtections protections = plugin.getGlobalProtections();
|
||||
|
||||
// Sign Labels
|
||||
public static final String IS_PLAYING = ChatColor.DARK_RED + "Is Playing";
|
||||
@ -55,9 +59,10 @@ public class GroupSign {
|
||||
private Block startSign;
|
||||
private int directionX = 0, directionZ = 0;
|
||||
private int verticalSigns;
|
||||
private Set<Block> blocks;
|
||||
|
||||
public GroupSign(Block startSign, String identifier, int maxGroups, int maxPlayersPerGroup, boolean multiFloor) {
|
||||
plugin.getGroupSigns().add(this);
|
||||
public GroupSign(int id, Block startSign, String identifier, int maxGroups, int maxPlayersPerGroup, boolean multiFloor) {
|
||||
super(startSign.getWorld(), id);
|
||||
|
||||
this.startSign = startSign;
|
||||
dGroups = new DGroup[maxGroups];
|
||||
@ -83,6 +88,36 @@ public class GroupSign {
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dGroups
|
||||
*/
|
||||
public DGroup[] getDGroups() {
|
||||
return dGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dGroups
|
||||
* the dGroups to set
|
||||
*/
|
||||
public void setDGroups(DGroup[] dGroups) {
|
||||
this.dGroups = dGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the multiFloor
|
||||
*/
|
||||
public boolean isMultiFloor() {
|
||||
return multiFloor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param multiFloor
|
||||
* the multiFloor to set
|
||||
*/
|
||||
public void setMultiFloor(boolean multiFloor) {
|
||||
this.multiFloor = multiFloor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dungeonName
|
||||
*/
|
||||
@ -114,24 +149,23 @@ public class GroupSign {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the multiFloor
|
||||
* @return the maximum player count per group
|
||||
*/
|
||||
public boolean isMultiFloor() {
|
||||
return multiFloor;
|
||||
public int getMaxPlayersPerGroup() {
|
||||
return maxPlayersPerGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param multiFloor
|
||||
* the multiFloor to set
|
||||
* @param maxPlayersPerGroup
|
||||
* the maximum player count per group to set
|
||||
*/
|
||||
public void setMultiFloor(boolean multiFloor) {
|
||||
this.multiFloor = multiFloor;
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
plugin.getGroupSigns().remove(this);
|
||||
public void setMaxPlayerPerGroup(int maxPlayersPerGroup) {
|
||||
this.maxPlayersPerGroup = maxPlayersPerGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update this group sign to show the group(s) correctly.
|
||||
*/
|
||||
public void update() {
|
||||
int i = 0;
|
||||
for (DGroup dGroup : dGroups) {
|
||||
@ -198,7 +232,121 @@ public class GroupSign {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Block> getBlocks() {
|
||||
if (blocks == null) {
|
||||
blocks = new HashSet<>();
|
||||
|
||||
int i = dGroups.length;
|
||||
do {
|
||||
i--;
|
||||
|
||||
blocks.add(startSign.getRelative(i * directionX, 0, i * directionZ));
|
||||
|
||||
} while (i >= 0);
|
||||
|
||||
HashSet<Block> toAdd = new HashSet<>();
|
||||
for (Block block : blocks) {
|
||||
i = verticalSigns;
|
||||
do {
|
||||
i--;
|
||||
|
||||
Block beneath = block.getLocation().add(0, -1 * i, 0).getBlock();
|
||||
toAdd.add(beneath);
|
||||
toAdd.add(BlockUtil.getAttachedBlock(beneath));
|
||||
|
||||
} while (i >= 0);
|
||||
}
|
||||
blocks.addAll(toAdd);
|
||||
}
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(FileConfiguration config) {
|
||||
String preString = "groupsign." + getWorld().getName() + "." + getId();
|
||||
|
||||
config.set(preString + ".x", startSign.getX());
|
||||
config.set(preString + ".y", startSign.getY());
|
||||
config.set(preString + ".z", startSign.getZ());
|
||||
|
||||
if (isMultiFloor()) {
|
||||
config.set(preString + ".dungeon", dungeonName);
|
||||
|
||||
} else {
|
||||
config.set(preString + ".dungeon", mapName);
|
||||
}
|
||||
|
||||
config.set(preString + ".maxGroups", dGroups.length);
|
||||
config.set(preString + ".maxPlayersPerGroup", maxPlayersPerGroup);
|
||||
config.set(preString + ".multiFloor", isMultiFloor());
|
||||
}
|
||||
|
||||
/* Statics */
|
||||
/**
|
||||
* @param block
|
||||
* a block which is protected by the returned GroupSign
|
||||
*/
|
||||
public static GroupSign getByBlock(Block block) {
|
||||
if (!(block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int x = block.getX(), y = block.getY(), z = block.getZ();
|
||||
for (GlobalProtection protection : protections.getProtections(GroupSign.class)) {
|
||||
GroupSign groupSign = (GroupSign) protection;
|
||||
|
||||
int sx1 = groupSign.startSign.getX(), sy1 = groupSign.startSign.getY(), sz1 = groupSign.startSign.getZ();
|
||||
int sx2 = sx1 + (groupSign.dGroups.length - 1) * groupSign.directionX;
|
||||
int sy2 = sy1 - groupSign.verticalSigns + 1;
|
||||
int sz2 = sz1 + (groupSign.dGroups.length - 1) * groupSign.directionZ;
|
||||
|
||||
if (sx1 > sx2) {
|
||||
if (x < sx2 || x > sx1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if (sx1 < sx2) {
|
||||
if (x > sx2 || x < sx1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if (x != sx1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sy1 > sy2) {
|
||||
if (y < sy2 || y > sy1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if (y != sy1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sz1 > sz2) {
|
||||
if (z < sz2 || z > sz1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if (sz1 < sz2) {
|
||||
if (z > sz2 || z < sz1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if (z != sz1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return groupSign;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/* SUBJECT TO CHANGE */
|
||||
@Deprecated
|
||||
public static GroupSign tryToCreate(Block startSign, String mapName, int maxGroups, int maxPlayersPerGroup, boolean multiFloor) {
|
||||
World world = startSign.getWorld();
|
||||
int direction = startSign.getData();
|
||||
@ -295,94 +443,15 @@ public class GroupSign {
|
||||
block.setTypeIdAndData(68, startSign.getData(), true);
|
||||
}
|
||||
|
||||
GroupSign sign = new GroupSign(startSign, mapName, maxGroups, maxPlayersPerGroup, multiFloor);
|
||||
GroupSign sign = new GroupSign(protections.generateId(GroupSign.class, world), startSign, mapName, maxGroups, maxPlayersPerGroup, multiFloor);
|
||||
|
||||
return sign;
|
||||
}
|
||||
|
||||
public static boolean isRelativeSign(Block block, int x, int z) {
|
||||
GroupSign groupSign = getSign(block.getRelative(x, 0, z));
|
||||
if (groupSign == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (x == -1 && groupSign.startSign.getData() == 4) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (x == 1 && groupSign.startSign.getData() == 5) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (z == -1 && groupSign.startSign.getData() == 2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (z == 1 && groupSign.startSign.getData() == 3) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static GroupSign getSign(Block block) {
|
||||
if (!(block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int x = block.getX(), y = block.getY(), z = block.getZ();
|
||||
for (GroupSign groupSign : plugin.getGroupSigns()) {
|
||||
int sx1 = groupSign.startSign.getX(), sy1 = groupSign.startSign.getY(), sz1 = groupSign.startSign.getZ();
|
||||
int sx2 = sx1 + (groupSign.dGroups.length - 1) * groupSign.directionX;
|
||||
int sy2 = sy1 - groupSign.verticalSigns + 1;
|
||||
int sz2 = sz1 + (groupSign.dGroups.length - 1) * groupSign.directionZ;
|
||||
|
||||
if (sx1 > sx2) {
|
||||
if (x < sx2 || x > sx1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if (sx1 < sx2) {
|
||||
if (x > sx2 || x < sx1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if (x != sx1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sy1 > sy2) {
|
||||
if (y < sy2 || y > sy1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if (y != sy1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sz1 > sz2) {
|
||||
if (z < sz2 || z > sz1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if (sz1 < sz2) {
|
||||
if (z > sz2 || z < sz1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if (z != sz1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return groupSign;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean playerInteract(Block block, Player player) {
|
||||
int x = block.getX(), y = block.getY(), z = block.getZ();
|
||||
GroupSign groupSign = getSign(block);
|
||||
GroupSign groupSign = getByBlock(block);
|
||||
|
||||
if (groupSign == null) {
|
||||
return false;
|
||||
@ -445,9 +514,11 @@ public class GroupSign {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void updatePerGroup(DGroup dGroupSearch) {
|
||||
for (GlobalProtection protection : protections.getProtections(GroupSign.class)) {
|
||||
GroupSign groupSign = (GroupSign) protection;
|
||||
|
||||
for (GroupSign groupSign : plugin.getGroupSigns()) {
|
||||
int i = 0;
|
||||
for (DGroup dGroup : groupSign.dGroups) {
|
||||
if (dGroup == null) {
|
||||
@ -466,6 +537,7 @@ public class GroupSign {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static int[] getDirection(byte data) {
|
||||
int[] direction = new int[2];
|
||||
|
||||
@ -489,58 +561,4 @@ public class GroupSign {
|
||||
return direction;
|
||||
}
|
||||
|
||||
// Save and Load
|
||||
public static void save(FileConfiguration configFile) {
|
||||
int id = 0;
|
||||
|
||||
for (GroupSign groupSign : plugin.getGroupSigns()) {
|
||||
id++;
|
||||
String preString = "groupsign." + groupSign.startSign.getWorld().getName() + "." + id;
|
||||
|
||||
// Location
|
||||
configFile.set(preString + ".x", groupSign.startSign.getX());
|
||||
configFile.set(preString + ".y", groupSign.startSign.getY());
|
||||
configFile.set(preString + ".z", groupSign.startSign.getZ());
|
||||
|
||||
// Etc.
|
||||
if (groupSign.isMultiFloor()) {
|
||||
configFile.set(preString + ".dungeon", groupSign.dungeonName);
|
||||
|
||||
} else {
|
||||
configFile.set(preString + ".dungeon", groupSign.mapName);
|
||||
}
|
||||
|
||||
configFile.set(preString + ".maxGroups", groupSign.dGroups.length);
|
||||
configFile.set(preString + ".maxPlayersPerGroup", groupSign.maxPlayersPerGroup);
|
||||
configFile.set(preString + ".multiFloor", groupSign.isMultiFloor());
|
||||
}
|
||||
}
|
||||
|
||||
public static void load(FileConfiguration configFile) {
|
||||
for (World world : plugin.getServer().getWorlds()) {
|
||||
if (!configFile.contains("groupsign." + world.getName())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int id = 0;
|
||||
String preString;
|
||||
do {
|
||||
id++;
|
||||
preString = "groupsign." + world.getName() + "." + id + ".";
|
||||
if (configFile.contains(preString)) {
|
||||
String mapName = configFile.getString(preString + ".dungeon");
|
||||
int maxGroups = configFile.getInt(preString + ".maxGroups");
|
||||
int maxPlayersPerGroup = configFile.getInt(preString + ".maxPlayersPerGroup");
|
||||
boolean multiFloor = false;
|
||||
if (configFile.contains(preString + ".multiFloor")) {
|
||||
multiFloor = configFile.getBoolean(preString + ".multiFloor");
|
||||
}
|
||||
Block startSign = world.getBlockAt(configFile.getInt(preString + ".x"), configFile.getInt(preString + ".y"), configFile.getInt(preString + ".z"));
|
||||
|
||||
new GroupSign(startSign, mapName, maxGroups, maxPlayersPerGroup, multiFloor);
|
||||
}
|
||||
} while (configFile.contains(preString));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,14 +16,15 @@
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.global;
|
||||
|
||||
import io.github.dre2n.commons.util.BlockUtil;
|
||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -32,14 +33,15 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* @author Frank Baumann
|
||||
*/
|
||||
public class LeaveSign {
|
||||
public class LeaveSign extends GlobalProtection {
|
||||
|
||||
protected static DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
|
||||
private Sign sign;
|
||||
private Set<Block> blocks;
|
||||
|
||||
public LeaveSign(Sign sign) {
|
||||
plugin.getLeaveSigns().add(this);
|
||||
public LeaveSign(int id, Sign sign) {
|
||||
super(sign.getWorld(), id);
|
||||
|
||||
this.sign = sign;
|
||||
setText();
|
||||
@ -53,13 +55,48 @@ public class LeaveSign {
|
||||
sign.update();
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
plugin.getLeaveSigns().remove(this);
|
||||
@Override
|
||||
public Set<Block> getBlocks() {
|
||||
if (blocks == null) {
|
||||
blocks = new HashSet<>();
|
||||
|
||||
blocks.add(sign.getBlock());
|
||||
blocks.add(BlockUtil.getAttachedBlock(sign.getBlock()));
|
||||
}
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(FileConfiguration config) {
|
||||
String preString = "leavesign." + sign.getWorld().getName() + "." + getId();
|
||||
config.set(preString + ".x", sign.getX());
|
||||
config.set(preString + ".y", sign.getY());
|
||||
config.set(preString + ".z", sign.getZ());
|
||||
}
|
||||
|
||||
/* Statics */
|
||||
/**
|
||||
* @param block
|
||||
* a block which is protected by the returned LeaveSign
|
||||
*/
|
||||
public static LeaveSign getByBlock(Block block) {
|
||||
for (GlobalProtection protection : plugin.getGlobalProtections().getProtections(LeaveSign.class)) {
|
||||
LeaveSign leaveSign = (LeaveSign) protection;
|
||||
|
||||
if (leaveSign.getBlocks().contains(block)) {
|
||||
return leaveSign;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/* SUBJECT TO CHANGE */
|
||||
@Deprecated
|
||||
public static boolean playerInteract(Block block, Player player) {
|
||||
|
||||
LeaveSign leaveSign = getSign(block);
|
||||
LeaveSign leaveSign = getByBlock(block);
|
||||
|
||||
if (leaveSign == null) {
|
||||
return false;
|
||||
@ -75,7 +112,7 @@ public class LeaveSign {
|
||||
DGroup dgroup = DGroup.getByPlayer(player);
|
||||
if (dgroup != null) {
|
||||
dgroup.removePlayer(player);
|
||||
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.PLAYER_LEAVE_GROUP));// ChatColor.YELLOW+"Du hast deine Gruppe erfolgreich verlassen!");
|
||||
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.PLAYER_LEAVE_GROUP));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -83,83 +120,4 @@ public class LeaveSign {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isRelativeSign(Block block, int x, int z) {
|
||||
LeaveSign leaveSign = getSign(block.getRelative(x, 0, z));
|
||||
if (leaveSign == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (x == -1 && leaveSign.sign.getData().getData() == 4) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (x == 1 && leaveSign.sign.getData().getData() == 5) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (z == -1 && leaveSign.sign.getData().getData() == 2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (z == 1 && leaveSign.sign.getData().getData() == 3) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static LeaveSign getSign(Block block) {
|
||||
if (!(block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (LeaveSign leavesign : plugin.getLeaveSigns()) {
|
||||
if (block.getWorld() != leavesign.sign.getWorld()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (block.getLocation().distance(leavesign.sign.getBlock().getLocation()) < 1) {
|
||||
return leavesign;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Save and Load
|
||||
public static void save(FileConfiguration configFile) {
|
||||
int id = 0;
|
||||
for (LeaveSign leaveSign : plugin.getLeaveSigns()) {
|
||||
id++;
|
||||
String preString = "leavesign." + leaveSign.sign.getWorld().getName() + "." + id;
|
||||
configFile.set(preString + ".x", leaveSign.sign.getX());
|
||||
configFile.set(preString + ".y", leaveSign.sign.getY());
|
||||
configFile.set(preString + ".z", leaveSign.sign.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
public static void load(FileConfiguration configFile) {
|
||||
for (World world : plugin.getServer().getWorlds()) {
|
||||
if (!configFile.contains("leavesign." + world.getName())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int id = 0;
|
||||
String preString;
|
||||
|
||||
do {
|
||||
id++;
|
||||
preString = "leavesign." + world.getName() + "." + id + ".";
|
||||
if (configFile.contains(preString)) {
|
||||
Block block = world.getBlockAt(configFile.getInt(preString + ".x"), configFile.getInt(preString + ".y"), configFile.getInt(preString + ".z"));
|
||||
if (block.getState() instanceof Sign) {
|
||||
Sign sign = (Sign) block.getState();
|
||||
new LeaveSign(sign);
|
||||
}
|
||||
}
|
||||
|
||||
} while (configFile.contains(preString));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,8 +26,12 @@ import io.github.dre2n.dungeonsxl.game.GameType;
|
||||
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
||||
import io.github.dre2n.dungeonsxl.game.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.global.DPortal;
|
||||
import io.github.dre2n.dungeonsxl.global.GameSign;
|
||||
import io.github.dre2n.dungeonsxl.global.GlobalProtection;
|
||||
import io.github.dre2n.dungeonsxl.global.GroupSign;
|
||||
import io.github.dre2n.dungeonsxl.global.LeaveSign;
|
||||
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DPlayers;
|
||||
import io.github.dre2n.dungeonsxl.sign.DSign;
|
||||
import io.github.dre2n.dungeonsxl.task.RedstoneEventTask;
|
||||
import org.bukkit.Location;
|
||||
@ -51,6 +55,7 @@ import org.bukkit.event.block.SignChangeEvent;
|
||||
public class BlockListener implements Listener {
|
||||
|
||||
protected static DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
protected static DPlayers dPlayers = plugin.getDPlayers();
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPhysics(BlockPhysicsEvent event) {
|
||||
@ -67,16 +72,15 @@ public class BlockListener implements Listener {
|
||||
public void onBreak(BlockBreakEvent event) {
|
||||
Block block = event.getBlock();
|
||||
Player player = event.getPlayer();
|
||||
DGlobalPlayer dGlobalPlayer = dPlayers.getByPlayer(player);
|
||||
|
||||
// Deny DPortal destroying
|
||||
if (block.getType() == Material.PORTAL) {
|
||||
DPortal dPortal = DPortal.getByBlock(event.getBlock());
|
||||
if (dPortal != null) {
|
||||
if (plugin.getInBreakMode().contains(player)) {
|
||||
dPortal.delete();
|
||||
GlobalProtection protection = plugin.getGlobalProtections().getByBlock(event.getBlock());
|
||||
if (protection != null) {
|
||||
if (dGlobalPlayer.isInBreakMode()) {
|
||||
protection.delete();
|
||||
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.PLAYER_PROTECTED_BLOCK_DELETED));
|
||||
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.CMD_BREAK_PROTECTED_MODE));
|
||||
plugin.getInBreakMode().remove(player);
|
||||
dGlobalPlayer.setInBreakMode(false);
|
||||
|
||||
} else {
|
||||
event.setCancelled(true);
|
||||
@ -84,51 +88,6 @@ public class BlockListener implements Listener {
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Delete GroupSign
|
||||
GroupSign groupSign = GroupSign.getSign(block);
|
||||
if (groupSign != null) {
|
||||
if (plugin.getInBreakMode().contains(player)) {
|
||||
groupSign.delete();
|
||||
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.PLAYER_PROTECTED_BLOCK_DELETED));
|
||||
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.CMD_BREAK_PROTECTED_MODE));
|
||||
plugin.getInBreakMode().remove(player);
|
||||
|
||||
} else {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Deny DGSignblocks destroying
|
||||
if (GroupSign.isRelativeSign(block, 1, 0) || GroupSign.isRelativeSign(block, -1, 0) || GroupSign.isRelativeSign(block, 0, 1) || GroupSign.isRelativeSign(block, 0, -1)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Delete LeaveSign
|
||||
LeaveSign leaveSign = LeaveSign.getSign(block);
|
||||
if (leaveSign != null) {
|
||||
if (plugin.getInBreakMode().contains(player)) {
|
||||
leaveSign.delete();
|
||||
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.PLAYER_PROTECTED_BLOCK_DELETED));
|
||||
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.CMD_BREAK_PROTECTED_MODE));
|
||||
plugin.getInBreakMode().remove(player);
|
||||
|
||||
} else {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Deny LeaveSignblocks destroying
|
||||
if (LeaveSign.isRelativeSign(block, 1, 0) || LeaveSign.isRelativeSign(block, -1, 0) || LeaveSign.isRelativeSign(block, 0, 1) || LeaveSign.isRelativeSign(block, 0, -1)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Editworld Signs
|
||||
EditWorld editWorld = EditWorld.getByWorld(block.getWorld());
|
||||
@ -155,7 +114,6 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
@ -184,6 +142,7 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@ -204,13 +163,13 @@ public class BlockListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (lines[1].equalsIgnoreCase("Group")) {
|
||||
if (lines[1].equalsIgnoreCase("Game") || lines[1].equalsIgnoreCase("Group")) {
|
||||
String dungeonName = lines[2];
|
||||
|
||||
String[] data = lines[3].split("\\,");
|
||||
if (data.length >= 2 && data.length <= 3) {
|
||||
int maxGroups = NumberUtil.parseInt(data[0]);
|
||||
int maxPlayersPerGroup = NumberUtil.parseInt(data[1]);
|
||||
int maxObjects = NumberUtil.parseInt(data[0]);
|
||||
int maxMembersPerObject = NumberUtil.parseInt(data[1]);
|
||||
boolean multiFloor = false;
|
||||
if (data.length == 3) {
|
||||
if (data[2].equals("+")) {
|
||||
@ -218,17 +177,24 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (maxGroups > 0 && maxPlayersPerGroup > 0) {
|
||||
if (GroupSign.tryToCreate(event.getBlock(), dungeonName, maxGroups, maxPlayersPerGroup, multiFloor) != null) {
|
||||
if (maxObjects > 0 && maxMembersPerObject > 0) {
|
||||
if (lines[1].equalsIgnoreCase("Game")) {
|
||||
if (GameSign.tryToCreate(event.getBlock(), dungeonName, maxObjects, maxMembersPerObject, multiFloor) != null) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
} else if (lines[1].equalsIgnoreCase("Group")) {
|
||||
if (GroupSign.tryToCreate(event.getBlock(), dungeonName, maxObjects, maxMembersPerObject, multiFloor) != null) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (lines[1].equalsIgnoreCase("Leave")) {
|
||||
if (block.getState() instanceof Sign) {
|
||||
Sign sign = (Sign) block.getState();
|
||||
new LeaveSign(sign);
|
||||
new LeaveSign(plugin.getGlobalProtections().generateId(LeaveSign.class, sign.getWorld()), sign);
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
@ -283,7 +249,6 @@ public class BlockListener implements Listener {
|
||||
if (editWorld != null) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
|
@ -16,19 +16,17 @@
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.listener;
|
||||
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.config.WorldConfig;
|
||||
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
|
||||
import io.github.dre2n.dungeonsxl.game.Game;
|
||||
import io.github.dre2n.dungeonsxl.game.GameType;
|
||||
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
||||
import io.github.dre2n.dungeonsxl.game.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.global.DPortal;
|
||||
import io.github.dre2n.dungeonsxl.global.GroupSign;
|
||||
import io.github.dre2n.dungeonsxl.mob.DMob;
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||
import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
@ -166,7 +164,6 @@ public class EntityListener implements Listener {
|
||||
|
||||
if (attackerDGroup != null && attackedDGroup != null) {
|
||||
if (!friendlyFire && attackerDGroup.equals(attackedDGroup)) {
|
||||
Bukkit.broadcastMessage("ff cancel");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -246,7 +243,7 @@ public class EntityListener implements Listener {
|
||||
|
||||
if (gameWorld != null) {
|
||||
if (event.getEntity() instanceof LivingEntity) {
|
||||
// Disable Creeper explosions in gameditWorlds
|
||||
// Disable Creeper explosions in gameWorlds
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
||||
@ -254,26 +251,13 @@ public class EntityListener implements Listener {
|
||||
// Disable drops from TNT
|
||||
event.setYield(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Prevent Portal and Sign Destroying
|
||||
// Prevent GlobalProtection destroying
|
||||
List<Block> blocklist = event.blockList();
|
||||
for (Block block : blocklist) {
|
||||
// Portals
|
||||
if (block.getType() == Material.PORTAL) {
|
||||
if (DPortal.getByBlock(block) != null) {
|
||||
if (DungeonsXL.getInstance().getGlobalProtections().isProtectedBlock(block)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Signs
|
||||
if (block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST) {
|
||||
if (GroupSign.getSign(block) != null) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,10 +30,13 @@ import io.github.dre2n.dungeonsxl.game.GameChest;
|
||||
import io.github.dre2n.dungeonsxl.game.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.global.DPortal;
|
||||
import io.github.dre2n.dungeonsxl.global.GameSign;
|
||||
import io.github.dre2n.dungeonsxl.global.GlobalProtection;
|
||||
import io.github.dre2n.dungeonsxl.global.GroupSign;
|
||||
import io.github.dre2n.dungeonsxl.global.LeaveSign;
|
||||
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DPlayers;
|
||||
import io.github.dre2n.dungeonsxl.task.RespawnTask;
|
||||
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
|
||||
import io.github.dre2n.dungeonsxl.trigger.UseItemTrigger;
|
||||
@ -71,6 +74,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
protected static DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
protected static MessageConfig messageConfig = plugin.getMessageConfig();
|
||||
protected static DPlayers dPlayers = plugin.getDPlayers();
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onDeath(PlayerDeathEvent event) {
|
||||
@ -104,21 +108,6 @@ public class PlayerListener implements Listener {
|
||||
|
||||
dPlayer.setLives(dPlayer.getLives() - dPlayerDeathEvent.getLostLives());
|
||||
|
||||
if (dPlayer.getLives() == 0 && dPlayer.isReady()) {
|
||||
DPlayerKickEvent dPlayerKickEvent = new DPlayerKickEvent(dPlayer, DPlayerKickEvent.Cause.DEATH);
|
||||
|
||||
if (!dPlayerKickEvent.isCancelled()) {
|
||||
MessageUtil.broadcastMessage(messageConfig.getMessage(Messages.PLAYER_DEATH_KICK, player.getName()));
|
||||
|
||||
// TODO: This Runnable is a workaround for a bug I couldn't find, yet...
|
||||
new org.bukkit.scheduler.BukkitRunnable() {
|
||||
public void run() {
|
||||
dPlayer.leave();
|
||||
}
|
||||
}.runTaskLater(plugin, 1L);
|
||||
}
|
||||
}
|
||||
|
||||
if (dPlayer.getLives() != -1) {
|
||||
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.PLAYER_DEATH, String.valueOf(dPlayer.getLives())));
|
||||
|
||||
@ -127,20 +116,34 @@ public class PlayerListener implements Listener {
|
||||
dPlayer.setRespawnInventory(event.getEntity().getInventory().getContents());
|
||||
dPlayer.setRespawnArmor(event.getEntity().getInventory().getArmorContents());
|
||||
// Delete all drops
|
||||
for (ItemStack istack : event.getDrops()) {
|
||||
istack.setType(Material.AIR);
|
||||
for (ItemStack item : event.getDrops()) {
|
||||
item.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dPlayer.getLives() == 0 && dPlayer.isReady()) {
|
||||
DPlayerKickEvent dPlayerKickEvent = new DPlayerKickEvent(dPlayer, DPlayerKickEvent.Cause.DEATH);
|
||||
|
||||
if (!dPlayerKickEvent.isCancelled()) {
|
||||
MessageUtil.broadcastMessage(messageConfig.getMessage(Messages.PLAYER_DEATH_KICK, player.getName()));
|
||||
dPlayer.leave();
|
||||
if (gameWorld.getConfig().getKeepInventoryOnEscape()) {
|
||||
/*new org.bukkit.scheduler.BukkitRunnable() {public void run(){*/
|
||||
dPlayer.applyRespawnInventory();/*}}.runTaskLater(plugin, 1);*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
DGlobalPlayer dGlobalPlayer = dPlayers.getByPlayer(player);
|
||||
Block clickedBlock = event.getClickedBlock();
|
||||
|
||||
if (plugin.getInBreakMode().contains(player)) {
|
||||
if (dGlobalPlayer.isInBreakMode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -179,19 +182,22 @@ public class PlayerListener implements Listener {
|
||||
// Check Portals
|
||||
if (event.getItem() != null) {
|
||||
ItemStack item = event.getItem();
|
||||
|
||||
if (dGlobalPlayer.isCreatingPortal()) {
|
||||
if (item.getType() == Material.WOOD_SWORD) {
|
||||
if (clickedBlock != null) {
|
||||
for (DPortal dportal : plugin.getDPortals()) {
|
||||
if (!dportal.isActive()) {
|
||||
if (dportal.getPlayer() == player) {
|
||||
if (dportal.getBlock1() == null) {
|
||||
dportal.setBlock1(event.getClickedBlock());
|
||||
for (GlobalProtection protection : plugin.getGlobalProtections().getProtections(DPortal.class)) {
|
||||
DPortal dPortal = (DPortal) protection;
|
||||
if (!dPortal.isActive()) {
|
||||
if (dPortal == dGlobalPlayer.getPortal()) {
|
||||
if (dPortal.getBlock1() == null) {
|
||||
dPortal.setBlock1(event.getClickedBlock());
|
||||
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.PLAYER_PORTAL_PROGRESS));
|
||||
|
||||
} else if (dportal.getBlock2() == null) {
|
||||
dportal.setBlock2(event.getClickedBlock());
|
||||
dportal.setActive(true);
|
||||
dportal.create();
|
||||
} else if (dPortal.getBlock2() == null) {
|
||||
dPortal.setBlock2(event.getClickedBlock());
|
||||
dPortal.setActive(true);
|
||||
dPortal.create();
|
||||
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.PLAYER_PORTAL_CREATED));
|
||||
}
|
||||
event.setCancelled(true);
|
||||
@ -200,6 +206,7 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Copy/Paste a Sign and Block-info
|
||||
if (EditWorld.getByWorld(player.getWorld()) != null) {
|
||||
@ -339,6 +346,8 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onRespawn(PlayerRespawnEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
plugin.getDPlayers().getByPlayer(player).applyRespawnInventory();
|
||||
|
||||
DPlayer dPlayer = DPlayer.getByPlayer(player);
|
||||
if (dPlayer == null) {
|
||||
return;
|
||||
@ -397,11 +406,11 @@ public class PlayerListener implements Listener {
|
||||
public void onPortal(PlayerPortalEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Location location = event.getFrom();
|
||||
DPortal dportal = DPortal.getByLocation(location);
|
||||
DPortal dPortal = DPortal.getByLocation(location);
|
||||
|
||||
if (dportal != null) {
|
||||
if (dPortal != null) {
|
||||
event.setCancelled(true);
|
||||
dportal.teleport(player);
|
||||
dPortal.teleport(player);
|
||||
}
|
||||
}
|
||||
|
||||
@ -443,6 +452,7 @@ public class PlayerListener implements Listener {
|
||||
DPlayer dPlayer = DPlayer.getByPlayer(player);
|
||||
|
||||
if (dPlayer == null) {
|
||||
dPlayers.removePlayer(dPlayer);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -473,6 +483,8 @@ public class PlayerListener implements Listener {
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
new DGlobalPlayer(player);
|
||||
|
||||
// Check dPlayers
|
||||
DPlayer dPlayer = DPlayer.getByName(player.getName());
|
||||
if (dPlayer != null) {
|
||||
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Daniel Saukel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.player;
|
||||
|
||||
/**
|
||||
* Represents a player in an EditWorld.
|
||||
*
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class DEditPlayer extends DGlobalPlayer {
|
||||
|
||||
public DEditPlayer(DGlobalPlayer player) {
|
||||
super(player.getPlayer());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,160 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Daniel Saukel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.player;
|
||||
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.global.DPortal;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Represents a player in the non-DXL worlds of the server.
|
||||
*
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class DGlobalPlayer {
|
||||
|
||||
protected Player player;
|
||||
|
||||
private boolean breakMode;
|
||||
private boolean chatSpyMode;
|
||||
private DPortal creatingPortal;
|
||||
|
||||
private ItemStack[] respawnInventory;
|
||||
private ItemStack[] respawnArmor;
|
||||
|
||||
public DGlobalPlayer(Player player) {
|
||||
this.player = player;
|
||||
|
||||
DungeonsXL.getInstance().getDPlayers().addPlayer(this);
|
||||
}
|
||||
|
||||
public DGlobalPlayer(DGlobalPlayer dPlayer) {
|
||||
player = dPlayer.getPlayer();
|
||||
breakMode = dPlayer.isInBreakMode();
|
||||
chatSpyMode = dPlayer.isInChatSpyMode();
|
||||
creatingPortal = dPlayer.getPortal();
|
||||
respawnInventory = dPlayer.getRespawnInventory();
|
||||
respawnArmor = dPlayer.getRespawnArmor();
|
||||
|
||||
DungeonsXL.getInstance().getDPlayers().addPlayer(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Bukkit player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if the player is in break mode
|
||||
*/
|
||||
public boolean isInBreakMode() {
|
||||
return breakMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param breakMode
|
||||
* sets if the player is in break mode
|
||||
*/
|
||||
public void setInBreakMode(boolean breakMode) {
|
||||
this.breakMode = breakMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if the player spies the DXL chat channels
|
||||
*/
|
||||
public boolean isInChatSpyMode() {
|
||||
return chatSpyMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param chatSpyMode
|
||||
* sets if the player is in chat spy mode
|
||||
*/
|
||||
public void setInChatSpyMode(boolean chatSpyMode) {
|
||||
this.chatSpyMode = chatSpyMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if the player is creating a DPortal
|
||||
*/
|
||||
public boolean isCreatingPortal() {
|
||||
return creatingPortal != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the portal the player is creating
|
||||
*/
|
||||
public DPortal getPortal() {
|
||||
return creatingPortal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dPortal
|
||||
* the portal to create
|
||||
*/
|
||||
public void setCreatingPortal(DPortal dPortal) {
|
||||
creatingPortal = dPortal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the respawnInventory
|
||||
*/
|
||||
public ItemStack[] getRespawnInventory() {
|
||||
return respawnInventory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param respawnInventory
|
||||
* the respawnInventory to set
|
||||
*/
|
||||
public void setRespawnInventory(ItemStack[] respawnInventory) {
|
||||
this.respawnInventory = respawnInventory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the saved respawn inventory to the player
|
||||
*/
|
||||
public void applyRespawnInventory() {
|
||||
if (respawnInventory == null || respawnArmor == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.getInventory().setContents(respawnInventory);
|
||||
player.getInventory().setArmorContents(respawnArmor);
|
||||
respawnInventory = null;
|
||||
respawnArmor = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the respawnArmor
|
||||
*/
|
||||
public ItemStack[] getRespawnArmor() {
|
||||
return respawnArmor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param respawnArmor
|
||||
* the respawnArmor to set
|
||||
*/
|
||||
public void setRespawnArmor(ItemStack[] respawnArmor) {
|
||||
this.respawnArmor = respawnArmor;
|
||||
}
|
||||
|
||||
}
|
@ -23,6 +23,7 @@ import io.github.dre2n.dungeonsxl.config.MessageConfig;
|
||||
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
|
||||
import io.github.dre2n.dungeonsxl.config.WorldConfig;
|
||||
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
||||
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupDisbandEvent;
|
||||
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupStartFloorEvent;
|
||||
import io.github.dre2n.dungeonsxl.event.requirement.RequirementDemandEvent;
|
||||
import io.github.dre2n.dungeonsxl.event.reward.RewardAdditionEvent;
|
||||
@ -30,6 +31,7 @@ import io.github.dre2n.dungeonsxl.game.Game;
|
||||
import io.github.dre2n.dungeonsxl.game.GameType;
|
||||
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
||||
import io.github.dre2n.dungeonsxl.game.GameWorld;
|
||||
import io.github.dre2n.dungeonsxl.global.GameSign;
|
||||
import io.github.dre2n.dungeonsxl.global.GroupSign;
|
||||
import io.github.dre2n.dungeonsxl.requirement.Requirement;
|
||||
import io.github.dre2n.dungeonsxl.reward.Reward;
|
||||
@ -195,7 +197,11 @@ public class DGroup {
|
||||
|
||||
// Check group
|
||||
if (isEmpty()) {
|
||||
remove();
|
||||
DGroupDisbandEvent event = new DGroupDisbandEvent(this, player, DGroupDisbandEvent.Cause.GROUP_IS_EMPTY);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -451,8 +457,15 @@ public class DGroup {
|
||||
return players.isEmpty();
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
/**
|
||||
* Remove the group from the List
|
||||
*/
|
||||
public void delete() {
|
||||
plugin.getDGroups().remove(this);
|
||||
if (Game.getByDGroup(this) != null){
|
||||
Game.getByDGroup(this).removeDGroup(this);
|
||||
}
|
||||
GameSign.updatePerGame(Game.getByDGroup(this));
|
||||
GroupSign.updatePerGroup(this);
|
||||
}
|
||||
|
||||
|
@ -61,15 +61,16 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
/**
|
||||
* Represents a player in a GameWorld.
|
||||
*
|
||||
* @author Frank Baumann, Tobias Schmitz, Milan Albrecht, Daniel Saukel
|
||||
*/
|
||||
public class DPlayer {
|
||||
public class DPlayer extends DGlobalPlayer {
|
||||
|
||||
protected static DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
protected static MessageConfig messageConfig = plugin.getMessageConfig();
|
||||
|
||||
// Variables
|
||||
private Player player;
|
||||
private World world;
|
||||
|
||||
private DSavePlayer savePlayer;
|
||||
@ -84,8 +85,6 @@ public class DPlayer {
|
||||
private Wolf wolf;
|
||||
private int wolfRespawnTime = 30;
|
||||
private long offlineTime;
|
||||
private ItemStack[] respawnInventory;
|
||||
private ItemStack[] respawnArmor;
|
||||
private String[] linesCopy;
|
||||
|
||||
private Inventory treasureInv = plugin.getServer().createInventory(getPlayer(), 45, messageConfig.getMessage(Messages.PLAYER_TREASURES));
|
||||
@ -94,14 +93,13 @@ public class DPlayer {
|
||||
private int lives;
|
||||
|
||||
public DPlayer(Player player, World world, Location teleport, boolean editing) {
|
||||
plugin.getDPlayers().add(this);
|
||||
super(player);
|
||||
|
||||
this.setPlayer(player);
|
||||
this.world = world;
|
||||
|
||||
double health = ((Damageable) player).getHealth();
|
||||
|
||||
if (CompatibilityHandler.getInstance().getVersion() != Version.MC1_9) {
|
||||
if (!Version.andHigher(Version.MC1_9).contains(CompatibilityHandler.getInstance().getVersion())) {
|
||||
savePlayer = new DSavePlayer(player.getName(), player.getUniqueId(), player.getLocation(), player.getInventory().getContents(), player.getInventory().getArmorContents(), null, player.getLevel(),
|
||||
player.getTotalExperience(), (int) health, player.getFoodLevel(), player.getFireTicks(), player.getGameMode(), player.getActivePotionEffects());
|
||||
|
||||
@ -143,14 +141,7 @@ public class DPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
// Getters and setters
|
||||
/**
|
||||
* @return the player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/* Getters and setters */
|
||||
/**
|
||||
* @param player
|
||||
* the player to set
|
||||
@ -193,7 +184,7 @@ public class DPlayer {
|
||||
* @return if the player is in test mode
|
||||
*/
|
||||
public boolean isInTestMode() {
|
||||
DGroup dGroup = DGroup.getByPlayer(player);
|
||||
DGroup dGroup = DGroup.getByPlayer(getPlayer());
|
||||
if (dGroup == null) {
|
||||
return false;
|
||||
}
|
||||
@ -216,17 +207,12 @@ public class DPlayer {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the editing
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isEditing() {
|
||||
return editing;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param editing
|
||||
* the editing to set
|
||||
*/
|
||||
@Deprecated
|
||||
public void setEditing(boolean editing) {
|
||||
this.editing = editing;
|
||||
}
|
||||
@ -414,36 +400,6 @@ public class DPlayer {
|
||||
this.offlineTime = offlineTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the respawnInventory
|
||||
*/
|
||||
public ItemStack[] getRespawnInventory() {
|
||||
return respawnInventory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param respawnInventory
|
||||
* the respawnInventory to set
|
||||
*/
|
||||
public void setRespawnInventory(ItemStack[] respawnInventory) {
|
||||
this.respawnInventory = respawnInventory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the respawnArmor
|
||||
*/
|
||||
public ItemStack[] getRespawnArmor() {
|
||||
return respawnArmor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param respawnArmor
|
||||
* the respawnArmor to set
|
||||
*/
|
||||
public void setRespawnArmor(ItemStack[] respawnArmor) {
|
||||
this.respawnArmor = respawnArmor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the linesCopy
|
||||
*/
|
||||
@ -506,12 +462,13 @@ public class DPlayer {
|
||||
|
||||
// ...
|
||||
public void escape() {
|
||||
remove(this);
|
||||
delete();
|
||||
savePlayer.reset(false);
|
||||
}
|
||||
|
||||
public void leave() {
|
||||
remove(this);
|
||||
delete();
|
||||
|
||||
if (!editing) {
|
||||
WorldConfig dConfig = GameWorld.getByWorld(world).getConfig();
|
||||
if (finished) {
|
||||
@ -543,7 +500,7 @@ public class DPlayer {
|
||||
if (finished) {
|
||||
if (gameWorld.getGame() != null) {
|
||||
for (Reward reward : gameWorld.getConfig().getRewards()) {
|
||||
reward.giveTo(player);
|
||||
reward.giveTo(getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@ -607,7 +564,7 @@ public class DPlayer {
|
||||
} while (groupPlayer == null);
|
||||
}
|
||||
|
||||
if (dGroup.getCaptain().equals(player) && dGroup.getPlayers().size() > 0) {
|
||||
if (dGroup.getCaptain().equals(getPlayer()) && dGroup.getPlayers().size() > 0) {
|
||||
// Captain here!
|
||||
Player newCaptain = dGroup.getPlayers().get(0);
|
||||
dGroup.setCaptain(newCaptain);
|
||||
@ -665,13 +622,7 @@ public class DPlayer {
|
||||
|
||||
// Respawn Items
|
||||
if (GameWorld.getByWorld(world).getConfig().getKeepInventoryOnDeath()) {
|
||||
if (respawnInventory != null || respawnArmor != null) {
|
||||
getPlayer().getInventory().setContents(respawnInventory);
|
||||
getPlayer().getInventory().setArmorContents(respawnArmor);
|
||||
respawnInventory = null;
|
||||
respawnArmor = null;
|
||||
}
|
||||
// P.plugin.updateInventory(this.player);
|
||||
applyRespawnInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@ -808,18 +759,22 @@ public class DPlayer {
|
||||
if (editing) {
|
||||
EditWorld editWorld = EditWorld.getByWorld(world);
|
||||
editWorld.sendMessage(message);
|
||||
for (Player player : plugin.getChatSpyers()) {
|
||||
if (!editWorld.getWorld().getPlayers().contains(player)) {
|
||||
MessageUtil.sendMessage(player, ChatColor.GREEN + "[Chatspy] " + ChatColor.WHITE + message);
|
||||
for (DGlobalPlayer player : plugin.getDPlayers().getPlayers()) {
|
||||
if (player.isInChatSpyMode()) {
|
||||
if (!editWorld.getWorld().getPlayers().contains(player.getPlayer())) {
|
||||
MessageUtil.sendMessage(player.getPlayer(), ChatColor.GREEN + "[Chatspy] " + ChatColor.WHITE + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
GameWorld gameWorld = GameWorld.getByWorld(world);
|
||||
gameWorld.sendMessage(message);
|
||||
for (Player player : plugin.getChatSpyers()) {
|
||||
if (!gameWorld.getWorld().getPlayers().contains(player)) {
|
||||
MessageUtil.sendMessage(player, ChatColor.GREEN + "[Chatspy] " + ChatColor.WHITE + message);
|
||||
for (DGlobalPlayer player : plugin.getDPlayers().getPlayers()) {
|
||||
if (player.isInChatSpyMode()) {
|
||||
if (!gameWorld.getWorld().getPlayers().contains(player.getPlayer())) {
|
||||
MessageUtil.sendMessage(player.getPlayer(), ChatColor.GREEN + "[Chatspy] " + ChatColor.WHITE + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -944,10 +899,7 @@ public class DPlayer {
|
||||
}
|
||||
|
||||
if (respawnInventory) {
|
||||
getPlayer().getInventory().setContents(getRespawnInventory());
|
||||
getPlayer().getInventory().setArmorContents(getRespawnArmor());
|
||||
setRespawnInventory(null);
|
||||
setRespawnArmor(null);
|
||||
applyRespawnInventory();
|
||||
}
|
||||
|
||||
if (kick) {
|
||||
@ -963,13 +915,22 @@ public class DPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
/* Statics */
|
||||
public static void remove(DPlayer player) {
|
||||
plugin.getDPlayers().remove(player);
|
||||
/**
|
||||
* Delete this DPlayer. Creates a DGlobalPlayer to replace it!
|
||||
*/
|
||||
public void delete() {
|
||||
if (player.isOnline()) {
|
||||
// Create a new DGlobalPlayer (outside a dungeon)
|
||||
new DGlobalPlayer(this);
|
||||
|
||||
} else {
|
||||
plugin.getDPlayers().removePlayer(this);
|
||||
}
|
||||
}
|
||||
|
||||
/* Statics */
|
||||
public static DPlayer getByPlayer(Player player) {
|
||||
for (DPlayer dPlayer : plugin.getDPlayers()) {
|
||||
for (DPlayer dPlayer : plugin.getDPlayers().getDPlayers()) {
|
||||
if (dPlayer.getPlayer().equals(player)) {
|
||||
return dPlayer;
|
||||
}
|
||||
@ -978,7 +939,7 @@ public class DPlayer {
|
||||
}
|
||||
|
||||
public static DPlayer getByName(String name) {
|
||||
for (DPlayer dPlayer : plugin.getDPlayers()) {
|
||||
for (DPlayer dPlayer : plugin.getDPlayers().getDPlayers()) {
|
||||
if (dPlayer.getPlayer().getName().equalsIgnoreCase(name)) {
|
||||
return dPlayer;
|
||||
}
|
||||
@ -989,7 +950,7 @@ public class DPlayer {
|
||||
public static CopyOnWriteArrayList<DPlayer> getByWorld(World world) {
|
||||
CopyOnWriteArrayList<DPlayer> dPlayers = new CopyOnWriteArrayList<>();
|
||||
|
||||
for (DPlayer dPlayer : plugin.getDPlayers()) {
|
||||
for (DPlayer dPlayer : plugin.getDPlayers().getDPlayers()) {
|
||||
if (dPlayer.world == world) {
|
||||
dPlayers.add(dPlayer);
|
||||
}
|
||||
|
132
src/main/java/io/github/dre2n/dungeonsxl/player/DPlayers.java
Normal file
132
src/main/java/io/github/dre2n/dungeonsxl/player/DPlayers.java
Normal file
@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Daniel Saukel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class DPlayers {
|
||||
|
||||
private List<DGlobalPlayer> dGlobalPlayers = new CopyOnWriteArrayList<>();
|
||||
private List<DSavePlayer> dSavePlayers = new CopyOnWriteArrayList<>();
|
||||
|
||||
/**
|
||||
* @return the DGlobalPlayer which represents the player
|
||||
*/
|
||||
public DGlobalPlayer getByPlayer(Player player) {
|
||||
for (DGlobalPlayer dGlobalPlayer : dGlobalPlayers) {
|
||||
if (dGlobalPlayer.getPlayer() == player) {
|
||||
return dGlobalPlayer;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dGlobalPlayers
|
||||
*/
|
||||
public List<DGlobalPlayer> getPlayers() {
|
||||
return dGlobalPlayers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dGlobalPlayers that are an instance of DPlayer
|
||||
*/
|
||||
public List<DPlayer> getDPlayers() {
|
||||
List<DPlayer> dPlayers = new CopyOnWriteArrayList<>();
|
||||
for (DGlobalPlayer player : dGlobalPlayers) {
|
||||
if (player instanceof DPlayer) {
|
||||
dPlayers.add((DPlayer) player);
|
||||
}
|
||||
}
|
||||
return dPlayers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dGlobalPlayers that are an instance of DEditPlayer
|
||||
*/
|
||||
public List<DEditPlayer> getDEditPlayers() {
|
||||
List<DEditPlayer> dEditPlayers = new CopyOnWriteArrayList<>();
|
||||
for (DGlobalPlayer player : dGlobalPlayers) {
|
||||
if (player instanceof DEditPlayer) {
|
||||
dEditPlayers.add((DEditPlayer) player);
|
||||
}
|
||||
}
|
||||
return dEditPlayers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* an instance of DGlobalPlayer to add
|
||||
*/
|
||||
public void addPlayer(DGlobalPlayer player) {
|
||||
for (DGlobalPlayer dGlobalPlayer : dGlobalPlayers) {
|
||||
if (dGlobalPlayer.getPlayer().equals(player.getPlayer())) {
|
||||
dGlobalPlayers.remove(dGlobalPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
dGlobalPlayers.add(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* an instance of DGlobalPlayer to remove
|
||||
*/
|
||||
public void removePlayer(DGlobalPlayer player) {
|
||||
dGlobalPlayers.remove(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dSavePlayers
|
||||
*/
|
||||
public List<DSavePlayer> getDSavePlayers() {
|
||||
return dSavePlayers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dSavePlayer
|
||||
* the dSavePlayer to add
|
||||
*/
|
||||
public void addDSavePlayer(DSavePlayer dSavePlayer) {
|
||||
dSavePlayers.add(dSavePlayer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dSavePlayer
|
||||
* the dSavePlayer to remove
|
||||
*/
|
||||
public void removeDSavePlayer(DSavePlayer dSavePlayer) {
|
||||
dSavePlayers.remove(dSavePlayer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all players
|
||||
*/
|
||||
public void loadAll() {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
new DGlobalPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -27,7 +27,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@ -38,13 +37,14 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
/**
|
||||
* Represents a player in a GameWorld who went offline.
|
||||
*
|
||||
* @author Frank Baumann, Tobias Schmitz, Milan Albrecht, Daniel Saukel
|
||||
*/
|
||||
public class DSavePlayer {
|
||||
|
||||
protected static DungeonsXL plugin = DungeonsXL.getInstance();
|
||||
|
||||
private static CopyOnWriteArrayList<DSavePlayer> savePlayers = new CopyOnWriteArrayList<>();
|
||||
protected static DPlayers dPlayers = plugin.getDPlayers();
|
||||
|
||||
// Variables
|
||||
private String playerName;
|
||||
@ -64,8 +64,6 @@ public class DSavePlayer {
|
||||
|
||||
public DSavePlayer(String playerName, UUID uuid, Location oldLocation, ArrayList<ItemStack> oldInventory, ArrayList<ItemStack> oldArmor, ItemStack oldOffHand, int oldLvl, int oldExp, int oldHealth, int oldFoodLevel, int oldFireTicks,
|
||||
GameMode oldGameMode, Collection<PotionEffect> oldPotionEffects) {
|
||||
savePlayers.add(this);
|
||||
|
||||
this.playerName = playerName;
|
||||
this.uuid = uuid.toString();
|
||||
|
||||
@ -82,28 +80,12 @@ public class DSavePlayer {
|
||||
this.oldPotionEffects = oldPotionEffects;
|
||||
|
||||
save();
|
||||
dPlayers.addDSavePlayer(this);
|
||||
}
|
||||
|
||||
public DSavePlayer(String playerName, UUID uuid, Location oldLocation, ItemStack[] oldInventory, ItemStack[] oldArmor, ItemStack oldOffHand, int oldLvl, int oldExp, int oldHealth, int oldFoodLevel, int oldFireTicks,
|
||||
GameMode oldGameMode, Collection<PotionEffect> oldPotionEffects) {
|
||||
savePlayers.add(this);
|
||||
|
||||
this.playerName = playerName;
|
||||
this.uuid = uuid.toString();
|
||||
|
||||
this.oldLocation = oldLocation;
|
||||
this.oldInventory = new ArrayList<>(Arrays.asList(oldInventory));
|
||||
this.oldArmor = new ArrayList<>(Arrays.asList(oldArmor));
|
||||
this.oldOffHand = oldOffHand;
|
||||
this.oldExp = oldExp;
|
||||
this.oldHealth = oldHealth;
|
||||
this.oldFoodLevel = oldFoodLevel;
|
||||
this.oldGameMode = oldGameMode;
|
||||
this.oldLvl = oldLvl;
|
||||
this.oldFireTicks = oldFireTicks;
|
||||
this.oldPotionEffects = oldPotionEffects;
|
||||
|
||||
save();
|
||||
this(playerName, uuid, oldLocation, new ArrayList<>(Arrays.asList(oldInventory)), new ArrayList<>(Arrays.asList(oldArmor)), oldOffHand, oldLvl, oldExp, oldHealth, oldFoodLevel, oldFireTicks, oldGameMode, oldPotionEffects);
|
||||
}
|
||||
|
||||
public void reset(boolean keepInventory) {
|
||||
@ -124,7 +106,7 @@ public class DSavePlayer {
|
||||
}
|
||||
player.getInventory().setContents(oldInventory.toArray(new ItemStack[36]));
|
||||
player.getInventory().setArmorContents(oldArmor.toArray(new ItemStack[4]));
|
||||
if (CompatibilityHandler.getInstance().getVersion() == Version.MC1_9) {
|
||||
if (Version.andHigher(Version.MC1_9).contains(CompatibilityHandler.getInstance().getVersion())) {
|
||||
player.getInventory().setItemInOffHand(oldOffHand);
|
||||
}
|
||||
player.setTotalExperience(oldExp);
|
||||
@ -153,15 +135,16 @@ public class DSavePlayer {
|
||||
plugin.getLogger().info("Corrupted playerdata detected and removed!");
|
||||
}
|
||||
|
||||
savePlayers.remove(this);
|
||||
save();
|
||||
dPlayers.removeDSavePlayer(this);
|
||||
}
|
||||
|
||||
/* Statics */
|
||||
@Deprecated
|
||||
public static void save() {
|
||||
FileConfiguration configFile = new YamlConfiguration();
|
||||
|
||||
for (DSavePlayer savePlayer : savePlayers) {
|
||||
for (DSavePlayer savePlayer : dPlayers.getDSavePlayers()) {
|
||||
configFile.set(savePlayer.playerName + ".uuid", savePlayer.uuid);
|
||||
configFile.set(savePlayer.playerName + ".oldGameMode", savePlayer.oldGameMode.toString());
|
||||
configFile.set(savePlayer.playerName + ".oldFireTicks", savePlayer.oldFireTicks);
|
||||
@ -188,6 +171,7 @@ public class DSavePlayer {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void load() {
|
||||
FileConfiguration configFile = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), "savePlayers.yml"));
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class EndSign extends DSign {
|
||||
|
||||
@Override
|
||||
public void onTrigger() {
|
||||
for (DPlayer dPlayer : plugin.getDPlayers()) {
|
||||
for (DPlayer dPlayer : plugin.getDPlayers().getDPlayers()) {
|
||||
dPlayer.finish();
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public class FloorSign extends DSign {
|
||||
|
||||
@Override
|
||||
public void onTrigger() {
|
||||
for (DPlayer dPlayer : plugin.getDPlayers()) {
|
||||
for (DPlayer dPlayer : plugin.getDPlayers().getDPlayers()) {
|
||||
dPlayer.finish();
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public class LeaveSign extends DSign {
|
||||
|
||||
@Override
|
||||
public void onTrigger() {
|
||||
for (DPlayer dPlayer : plugin.getDPlayers()) {
|
||||
for (DPlayer dPlayer : plugin.getDPlayers().getDPlayers()) {
|
||||
DPlayerEscapeEvent event = new DPlayerEscapeEvent(dPlayer);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
|
@ -96,7 +96,7 @@ public class ReadySign extends DSign {
|
||||
|
||||
@Override
|
||||
public void onTrigger() {
|
||||
for (DPlayer dPlayer : plugin.getDPlayers()) {
|
||||
for (DPlayer dPlayer : plugin.getDPlayers().getDPlayers()) {
|
||||
ready(dPlayer);
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class LazyUpdateTask extends BukkitRunnable {
|
||||
gameWorld.update();
|
||||
}
|
||||
|
||||
for (DPlayer dPlayer : plugin.getDPlayers()) {
|
||||
for (DPlayer dPlayer : plugin.getDPlayers().getDPlayers()) {
|
||||
dPlayer.update(true);
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,8 @@
|
||||
package io.github.dre2n.dungeonsxl.task;
|
||||
|
||||
import io.github.dre2n.commons.util.playerutil.PlayerUtil;
|
||||
import io.github.dre2n.dungeonsxl.player.DPlayer;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@ -41,19 +42,13 @@ public class RespawnTask extends BukkitRunnable {
|
||||
PlayerUtil.secureTeleport(player, location);
|
||||
}
|
||||
|
||||
DPlayer dPlayer = DPlayer.getByPlayer(player);
|
||||
DGlobalPlayer dPlayer = DungeonsXL.getInstance().getDPlayers().getByPlayer(player);
|
||||
|
||||
if (dPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Respawn Items
|
||||
if (dPlayer.getRespawnInventory() != null || dPlayer.getRespawnArmor() != null) {
|
||||
player.getInventory().setContents(dPlayer.getRespawnInventory());
|
||||
player.getInventory().setArmorContents(dPlayer.getRespawnArmor());
|
||||
dPlayer.setRespawnInventory(null);
|
||||
dPlayer.setRespawnArmor(null);
|
||||
}
|
||||
dPlayer.applyRespawnInventory();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class UpdateTask extends BukkitRunnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (DPlayer dPlayer : DungeonsXL.getInstance().getDPlayers()) {
|
||||
for (DPlayer dPlayer : DungeonsXL.getInstance().getDPlayers().getDPlayers()) {
|
||||
dPlayer.update(false);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user