Merge pull request #32 from DRE2N/New-structure

New structure / advanced groups
This commit is contained in:
Daniel Saukel 2016-01-27 20:21:59 +01:00
commit f641c9d4c7
76 changed files with 2977 additions and 1914 deletions

View File

@ -1,13 +1,13 @@
package io.github.dre2n.dungeonsxl;
import io.github.dre2n.dungeonsxl.command.DCommands;
import io.github.dre2n.dungeonsxl.config.MainConfig;
import io.github.dre2n.dungeonsxl.config.MessageConfig;
import io.github.dre2n.dungeonsxl.config.WorldConfig;
import io.github.dre2n.dungeonsxl.dungeon.DLootInventory;
import io.github.dre2n.dungeonsxl.dungeon.Dungeons;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.dungeon.WorldConfig;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.file.DMessages;
import io.github.dre2n.dungeonsxl.file.MainConfig;
import io.github.dre2n.dungeonsxl.global.DPortal;
import io.github.dre2n.dungeonsxl.global.GroupSign;
import io.github.dre2n.dungeonsxl.global.LeaveSign;
@ -23,6 +23,9 @@ import io.github.dre2n.dungeonsxl.player.DSavePlayer;
import io.github.dre2n.dungeonsxl.requirement.Requirements;
import io.github.dre2n.dungeonsxl.reward.Rewards;
import io.github.dre2n.dungeonsxl.sign.DSigns;
import io.github.dre2n.dungeonsxl.task.LazyUpdateTask;
import io.github.dre2n.dungeonsxl.task.UpdateTask;
import io.github.dre2n.dungeonsxl.task.WorldUnloadTask;
import io.github.dre2n.dungeonsxl.trigger.Triggers;
import io.github.dre2n.dungeonsxl.util.FileUtil;
import io.github.dre2n.dungeonsxl.util.VersionUtil;
@ -41,6 +44,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
public class DungeonsXL extends JavaPlugin {
@ -49,8 +53,10 @@ public class DungeonsXL extends JavaPlugin {
private Permission permissionProvider;
private MainConfig mainConfig;
private DMessages dMessages;
private MessageConfig messageConfig;
private VersionUtil versionUtil;
private DCommands dCommands;
private DSigns dSigns;
private Requirements requirements;
@ -58,6 +64,10 @@ public class DungeonsXL extends JavaPlugin {
private Triggers triggers;
private Dungeons dungeons;
private BukkitTask worldUnloadTask;
private BukkitTask lazyUpdateTask;
private BukkitTask updateTask;
private CopyOnWriteArrayList<Player> inBreakMode = new CopyOnWriteArrayList<Player>();
private CopyOnWriteArrayList<Player> chatSpyers = new CopyOnWriteArrayList<Player>();
private CopyOnWriteArrayList<DLootInventory> dLootInventories = new CopyOnWriteArrayList<DLootInventory>();
@ -72,17 +82,16 @@ public class DungeonsXL extends JavaPlugin {
@Override
public void onEnable() {
plugin = this;
getDataFolder().mkdir();
// InitFolders
initFolders();
// Load Language
loadDMessages(new File(plugin.getDataFolder(), "languages/en.yml"));
loadMessageConfig(new File(plugin.getDataFolder(), "languages/en.yml"));
// Load Config
loadMainConfig(new File(plugin.getDataFolder(), "config.yml"));
// Load Language 2
loadDMessages(new File(plugin.getDataFolder(), "languages/" + mainConfig.getLanguage() + ".yml"));
loadMessageConfig(new File(plugin.getDataFolder(), "languages/" + mainConfig.getLanguage() + ".yml"));
loadVersionUtil();
loadDCommands();
loadRequirements();
@ -107,8 +116,10 @@ public class DungeonsXL extends JavaPlugin {
// Load All
loadAll();
// Scheduler
initSchedulers();
// Tasks
startWorldUnloadTask(1200L);
startLazyUpdateTask(20L);
startUpdateTask(20L);
// MSG
getLogger().info("DungeonsXL " + getDescription().getVersion() + " for Spigot 1.8.8 loaded succesfully!");
@ -121,7 +132,7 @@ public class DungeonsXL extends JavaPlugin {
public void onDisable() {
// Save
saveData();
dMessages.save();
messageConfig.save();
// DPlayer leaves World
for (DPlayer dplayer : dPlayers) {
@ -172,41 +183,6 @@ public class DungeonsXL extends JavaPlugin {
}
}
public void initSchedulers() {
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override
public void run() {
for (GameWorld gameWorld : gameWorlds) {
if (gameWorld.getWorld().getPlayers().isEmpty()) {
if (DPlayer.getByWorld(gameWorld.getWorld()).isEmpty()) {
gameWorld.delete();
}
}
}
for (EditWorld editWorld : editWorlds) {
if (editWorld.getWorld().getPlayers().isEmpty()) {
editWorld.delete();
}
}
}
}, 0L, 1200L);
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override
public void run() {
GameWorld.update();
DPlayer.update(true);
}
}, 0L, 20L);
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override
public void run() {
DPlayer.update(false);
}
}, 0L, 2L);
}
// Save and Load
public void saveData() {
File file = new File(getDataFolder(), "data.yml");
@ -359,17 +335,17 @@ public class DungeonsXL extends JavaPlugin {
}
/**
* @return the loaded instance of DMessages
* @return the loaded instance of MessageConfig
*/
public DMessages getDMessages() {
return dMessages;
public MessageConfig getMessageConfig() {
return messageConfig;
}
/**
* load / reload a new instance of DMessages
* load / reload a new instance of MessageConfig
*/
public void loadDMessages(File file) {
dMessages = new DMessages(file);
public void loadMessageConfig(File file) {
messageConfig = new MessageConfig(file);
}
/**
@ -456,6 +432,48 @@ public class DungeonsXL extends JavaPlugin {
dungeons = new Dungeons();
}
/**
* @return the worldUnloadTask
*/
public BukkitTask getWorldUnloadTask() {
return worldUnloadTask;
}
/**
* start a new WorldUnloadTask
*/
public void startWorldUnloadTask(long period) {
worldUnloadTask = new WorldUnloadTask().runTaskTimer(this, 0L, period);
}
/**
* @return the lazyUpdateTask
*/
public BukkitTask getLazyUpdateTask() {
return lazyUpdateTask;
}
/**
* start a new LazyUpdateTask
*/
public void startLazyUpdateTask(long period) {
lazyUpdateTask = new LazyUpdateTask().runTaskTimer(this, 0L, period);
}
/**
* @return the updateTask
*/
public BukkitTask getUpdateTask() {
return updateTask;
}
/**
* start a new LazyUpdateTask
*/
public void startUpdateTask(long period) {
updateTask = new UpdateTask().runTaskTimer(this, 0L, period);
}
/**
* @return the inBreakMode
*/

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
import org.bukkit.command.CommandSender;
@ -12,7 +12,7 @@ public class BreakCommand extends DCommand {
setCommand("break");
setMinArgs(0);
setMaxArgs(0);
setHelp(dMessages.getMessage(Messages.HELP_CMD_BREAK));
setHelp(messageConfig.getMessage(Messages.HELP_CMD_BREAK));
setPermission("dxl.break");
setPlayerCommand(true);
}
@ -22,11 +22,11 @@ public class BreakCommand extends DCommand {
Player player = (Player) sender;
if ( !plugin.getInBreakMode().contains(player)) {
plugin.getInBreakMode().add(player);
MessageUtil.sendMessage(sender, dMessages.getMessage(Messages.CMD_BREAK_BREAK_MODE));
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.CMD_BREAK_BREAK_MODE));
} else {
plugin.getInBreakMode().remove(player);
MessageUtil.sendMessage(sender, dMessages.getMessage(Messages.CMD_BREAK_PROTECTED_MODE));
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.CMD_BREAK_PROTECTED_MODE));
}
}

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
@ -13,7 +13,7 @@ public class ChatCommand extends DCommand {
setCommand("chat");
setMinArgs(0);
setMaxArgs(0);
setHelp(dMessages.getMessage(Messages.HELP_CMD_CHAT));
setHelp(messageConfig.getMessage(Messages.HELP_CMD_CHAT));
setPermission("dxl.chat");
setPlayerCommand(true);
}
@ -24,17 +24,17 @@ public class ChatCommand extends DCommand {
DPlayer dplayer = DPlayer.getByPlayer(player);
if (dplayer == null) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NOT_IN_GROUP));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_JOIN_GROUP));
return;
}
if (dplayer.isInDungeonChat()) {
dplayer.setInDungeonChat(false);
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_CHAT_NORMAL_CHAT));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.CMD_CHAT_NORMAL_CHAT));
} else {
dplayer.setInDungeonChat(true);
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_CHAT_DUNGEON_CHAT));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.CMD_CHAT_DUNGEON_CHAT));
}
}

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
import org.bukkit.command.CommandSender;
@ -12,7 +12,7 @@ public class ChatSpyCommand extends DCommand {
setCommand("chatspy");
setMinArgs(0);
setMaxArgs(0);
setHelp(dMessages.getMessage(Messages.HELP_CMD_CHATSPY));
setHelp(messageConfig.getMessage(Messages.HELP_CMD_CHATSPY));
setPermission("dxl.chatspy");
setPlayerCommand(true);
}
@ -23,11 +23,11 @@ public class ChatSpyCommand extends DCommand {
if (plugin.getChatSpyers().contains(player)) {
plugin.getChatSpyers().remove(player);
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_CHATSPY_STOPPED));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.CMD_CHATSPY_STOPPED));
} else {
plugin.getChatSpyers().add(player);
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_CHATSPY_START));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.CMD_CHATSPY_START));
}
}

View File

@ -1,7 +1,7 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
@ -15,7 +15,7 @@ public class CreateCommand extends DCommand {
setMinArgs(1);
setMaxArgs(1);
setCommand("create");
setHelp(dMessages.getMessage(Messages.HELP_CMD_CREATE));
setHelp(messageConfig.getMessage(Messages.HELP_CMD_CREATE));
setPermission("dxl.create");
setPlayerCommand(true);
setConsoleCommand(true);
@ -28,8 +28,8 @@ public class CreateCommand extends DCommand {
if (sender instanceof ConsoleCommandSender) {
if (name.length() <= 15) {
// Msg create
plugin.getLogger().info(dMessages.getMessage(Messages.LOG_NEW_DUNGEON));
plugin.getLogger().info(dMessages.getMessage(Messages.LOG_GENERATE_NEW_WORLD));
plugin.getLogger().info(messageConfig.getMessage(Messages.LOG_NEW_DUNGEON));
plugin.getLogger().info(messageConfig.getMessage(Messages.LOG_GENERATE_NEW_WORLD));
// Create World
EditWorld editWorld = new EditWorld();
@ -39,24 +39,24 @@ public class CreateCommand extends DCommand {
editWorld.delete();
// MSG Done
plugin.getLogger().info(dMessages.getMessage(Messages.LOG_WORLD_GENERATION_FINISHED));
plugin.getLogger().info(messageConfig.getMessage(Messages.LOG_WORLD_GENERATION_FINISHED));
} else {
MessageUtil.sendMessage(sender, dMessages.getMessage(Messages.ERROR_NAME_TO_LONG));
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_NAME_TO_LONG));
}
} else if (sender instanceof Player) {
Player player = (Player) sender;
if (DPlayer.getByPlayer(player) != null) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_LEAVE_DUNGEON));
return;
}
if (name.length() <= 15) {
// Msg create
plugin.getLogger().info(dMessages.getMessage(Messages.LOG_NEW_DUNGEON));
plugin.getLogger().info(dMessages.getMessage(Messages.LOG_GENERATE_NEW_WORLD));
plugin.getLogger().info(messageConfig.getMessage(Messages.LOG_NEW_DUNGEON));
plugin.getLogger().info(messageConfig.getMessage(Messages.LOG_GENERATE_NEW_WORLD));
// Create World
EditWorld editWorld = new EditWorld();
@ -64,7 +64,7 @@ public class CreateCommand extends DCommand {
editWorld.setMapName(name);
// MSG Done
plugin.getLogger().info(dMessages.getMessage(Messages.LOG_WORLD_GENERATION_FINISHED));
plugin.getLogger().info(messageConfig.getMessage(Messages.LOG_WORLD_GENERATION_FINISHED));
// Tp Player
if (editWorld.getLobby() == null) {
@ -75,7 +75,7 @@ public class CreateCommand extends DCommand {
}
} else {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NAME_TO_LONG));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_NAME_TO_LONG));
}
}
}

View File

@ -1,7 +1,7 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.file.DMessages;
import io.github.dre2n.dungeonsxl.config.MessageConfig;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
import org.bukkit.ChatColor;
@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
public abstract class DCommand {
static DungeonsXL plugin = DungeonsXL.getPlugin();
DMessages dMessages = plugin.getDMessages();
MessageConfig messageConfig = plugin.getMessageConfig();
public boolean costsMoney;
private String command;

View File

@ -17,6 +17,7 @@ public class DCommands {
dCommands.add(new CreateCommand());
dCommands.add(new EditCommand());
dCommands.add(new EscapeCommand());
dCommands.add(new GroupCommand());
dCommands.add(new InviteCommand());
dCommands.add(new LeaveCommand());
dCommands.add(new ListCommand());

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.global.DPortal;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
@ -29,10 +29,10 @@ public class DeletePortalCommand extends DCommand {
if (dPortal != null) {
dPortal.delete();
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.PLAYER_PROTECTED_BLOCK_DELETED));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.PLAYER_PROTECTED_BLOCK_DELETED));
} else {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NO_PROTECTED_BLOCK));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_NO_PROTECTED_BLOCK));
}
}

View File

@ -1,7 +1,7 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
@ -15,7 +15,7 @@ public class EditCommand extends DCommand {
setCommand("edit");
setMinArgs(1);
setMaxArgs(1);
setHelp(dMessages.getMessage(Messages.HELP_CMD_EDIT));
setHelp(messageConfig.getMessage(Messages.HELP_CMD_EDIT));
setPlayerCommand(true);
}
@ -29,22 +29,22 @@ public class EditCommand extends DCommand {
DPlayer dPlayer = DPlayer.getByPlayer(player);
if ( !(EditWorld.isInvitedPlayer(mapName, player.getUniqueId(), player.getName()) || player.hasPermission("dxl.edit"))) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NO_PERMISSIONS));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_NO_PERMISSIONS));
return;
}
if (dPlayer != null) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_LEAVE_DUNGEON));
return;
}
if (dGroup != null) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_GROUP));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_LEAVE_GROUP));
return;
}
if (editWorld == null) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, mapName));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, mapName));
return;
}

View File

@ -1,7 +1,7 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
@ -15,7 +15,7 @@ public class EscapeCommand extends DCommand {
setCommand("escape");
setMinArgs(0);
setMaxArgs(0);
setHelp(dMessages.getMessage(Messages.HELP_CMD_ESCAPE));
setHelp(messageConfig.getMessage(Messages.HELP_CMD_ESCAPE));
setPermission("dxl.escape");
setPlayerCommand(true);
}
@ -27,7 +27,7 @@ public class EscapeCommand extends DCommand {
if (dPlayer != null) {
if ( !dPlayer.isEditing()) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_LEAVE_DUNGEON));
return;
}
@ -46,10 +46,10 @@ public class EscapeCommand extends DCommand {
DGroup dGroup = DGroup.getByPlayer(player);
if (dGroup != null) {
dGroup.removePlayer(player);
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_LEAVE_SUCCESS));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.CMD_LEAVE_SUCCESS));
return;
}
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NOT_IN_DUNGEON));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_NOT_IN_DUNGEON));
}
}

View File

@ -0,0 +1,247 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupDisbandEvent;
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerKickEvent;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class GroupCommand extends DCommand {
public GroupCommand() {
setCommand("group");
setMinArgs(0);
setMaxArgs(2);
setHelp(messageConfig.getMessage(Messages.HELP_CMD_GROUP));
setPermission("dxl.group");
setPlayerCommand(true);
}
private CommandSender sender;
private Player player;
private String[] args;
@Override
public void onExecute(String[] args, CommandSender sender) {
this.sender = sender;
this.player = (Player) sender;
this.args = args;
DGroup dGroup = DGroup.getByPlayer(player);
if (args.length == 2) {
if (args[1].equalsIgnoreCase("disband")) {
disbandGroup(dGroup);
return;
} else if (args[1].equalsIgnoreCase("show")) {
showGroup(dGroup);
return;
}
} else if (args.length >= 3) {
if (args[1].equalsIgnoreCase("kick")) {
kickPlayer(dGroup);
return;
} else if (args[1].equalsIgnoreCase("invite")) {
invitePlayer(dGroup);
return;
} else if (args[1].equalsIgnoreCase("uninvite")) {
uninvitePlayer(dGroup);
return;
} else if (args[1].equalsIgnoreCase("help")) {
showHelp(args[2]);
return;
} else if (args[1].equalsIgnoreCase("create")) {
createGroup();
return;
} else if (args[1].equalsIgnoreCase("disband") && sender.hasPermission("dxl.group.admin")) {
disbandGroup(DGroup.getByName(args[2]));
return;
} else if (args[1].equalsIgnoreCase("join")) {
joinGroup(DGroup.getByName(args[2]));
return;
} else if (args[1].equalsIgnoreCase("show") && sender.hasPermission("dxl.group.admin")) {
showGroup(DGroup.getByName(args[2]));
return;
}
}
showHelp("1");
}
public void createGroup() {
if (DGroup.getByPlayer(player) == null && DGroup.getByName(args[2]) == null) {
DGroup dGroup = new DGroup(args[2], player);
DGroupCreateEvent event = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.COMMAND);
if (event.isCancelled()) {
plugin.getDGroups().remove(dGroup);
dGroup = null;
} else {
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.GROUP_CREATED, sender.getName(), args[2]));
}
} else {
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_LEAVE_GROUP));
}
}
public void disbandGroup(DGroup dGroup) {
if (dGroup != null) {
DGroupDisbandEvent event = new DGroupDisbandEvent(dGroup, player, DGroupDisbandEvent.Cause.COMMAND);
if ( !event.isCancelled()) {
plugin.getDGroups().remove(dGroup);
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.GROUP_DISBANDED, sender.getName(), dGroup.getName()));
dGroup = null;
}
} else {
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_NO_SUCH_GROUP));
}
}
public void invitePlayer(DGroup dGroup) {
if (dGroup == null) {
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_JOIN_GROUP));
return;
}
Player toInvite = plugin.getServer().getPlayer(args[2]);
if (toInvite != null) {
dGroup.addInvitedPlayer(toInvite, false);
} else {
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_NO_SUCH_PLAYER, args[2]));
}
}
public void uninvitePlayer(DGroup dGroup) {
if (dGroup == null) {
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_JOIN_GROUP));
return;
}
dGroup.clearOfflineInvitedPlayers();
Player toUninvite = plugin.getServer().getPlayer(args[2]);
if (toUninvite != null) {
if (dGroup.getInvitedPlayers().contains(toUninvite)) {
dGroup.removeInvitedPlayer(toUninvite, false);
} else {
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_NOT_IN_GROUP, args[2]));
}
} else {
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_NO_SUCH_PLAYER, args[2]));
}
}
public void joinGroup(DGroup dGroup) {
if (dGroup == null) {
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_NO_SUCH_GROUP, args[2]));
return;
}
for (DGroup anyDGroup : plugin.getDGroups()) {
if (anyDGroup.getPlayers().contains(player)) {
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_LEAVE_GROUP));
}
}
if ( !dGroup.getInvitedPlayers().contains(player) && !player.hasPermission("dxl.bypass")) {
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_NOT_INVITED, args[2]));
return;
}
dGroup.addPlayer(player);
dGroup.removeInvitedPlayer(player, true);
}
public void kickPlayer(DGroup dGroup) {
if (dGroup == null) {
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_JOIN_GROUP));
}
Player toKick = plugin.getServer().getPlayer(args[2]);
if (toKick != null) {
DPlayerKickEvent event = new DPlayerKickEvent(DPlayer.getByPlayer(toKick.getPlayer()), DPlayerKickEvent.Cause.COMMAND);
if ( !event.isCancelled()) {
if (dGroup.getPlayers().contains(toKick)) {
dGroup.removePlayer(toKick);
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.GROUP_KICKED_PLAYER, sender.getName(), args[2], dGroup.getName()));
} else {
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_NOT_IN_GROUP, args[2], dGroup.getName()));
}
}
} else {
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_NO_SUCH_PLAYER, args[2]));
}
}
public void showGroup(DGroup dGroup) {
if (dGroup == null) {
if (args.length == 3) {
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_NO_SUCH_GROUP, args[2]));
} else if (args.length == 2) {
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_JOIN_GROUP));
}
return;
}
MessageUtil.sendCenteredMessage(sender, "&4&l[ &6" + dGroup.getName() + " &4&l]");
MessageUtil.sendMessage(sender, "&bCaptain: &e" + dGroup.getCaptain().getName());
String players = "&e";
for (Player player : dGroup.getPlayers()) {
players += (player == dGroup.getPlayers().get(0) ? "" : "&b, &e") + player.getName();
}
MessageUtil.sendMessage(sender, "&bPlayers: &e" + players);
MessageUtil.sendMessage(sender, "&bDungeon: &e" + (dGroup.getDungeonName() == null ? "N/A" : dGroup.getDungeonName()));
MessageUtil.sendMessage(sender, "&bMap: &e" + (dGroup.getMapName() == null ? "N/A" : dGroup.getMapName()));
}
public void showHelp(String page) {
MessageUtil.sendPluginTag(sender, plugin);
switch (page) {
default:
MessageUtil.sendCenteredMessage(sender, "&4&l[ &61-5 &4/ &67 &4| &61 &4&l]");
MessageUtil.sendMessage(sender, "&bcreate" + "&7 - " + messageConfig.getMessage(Messages.HELP_CMD_GROUP_CREATE));
MessageUtil.sendMessage(sender, "&bdisband" + "&7 - " + messageConfig.getMessage(Messages.HELP_CMD_GROUP_DISBAND));
MessageUtil.sendMessage(sender, "&binvite" + "&7 - " + messageConfig.getMessage(Messages.HELP_CMD_GROUP_INVITE));
MessageUtil.sendMessage(sender, "&buninvite" + "&7 - " + messageConfig.getMessage(Messages.HELP_CMD_GROUP_UNINVITE));
MessageUtil.sendMessage(sender, "&bjoin" + "&7 - " + messageConfig.getMessage(Messages.HELP_CMD_GROUP_JOIN));
break;
case "2":
MessageUtil.sendCenteredMessage(sender, "&4&l[ &66-10 &4/ &67 &4| &62 &4&l]");
MessageUtil.sendMessage(sender, "&bkick" + "&7 - " + messageConfig.getMessage(Messages.HELP_CMD_GROUP_KICK));
MessageUtil.sendMessage(sender, "&bshow" + "&7 - " + messageConfig.getMessage(Messages.HELP_CMD_GROUP_SHOW));
break;
}
}
}

View File

@ -3,7 +3,7 @@ package io.github.dre2n.dungeonsxl.command;
import java.util.ArrayList;
import java.util.List;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.util.NumberUtil;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
@ -15,7 +15,7 @@ public class HelpCommand extends DCommand {
setCommand("help");
setMinArgs(0);
setMaxArgs(1);
setHelp(dMessages.getMessage(Messages.HELP_CMD_HELP));
setHelp(messageConfig.getMessage(Messages.HELP_CMD_HELP));
setPermission("dxl.help");
setPlayerCommand(true);
setConsoleCommand(true);

View File

@ -1,7 +1,7 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.util.UUIDUtil;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
@ -13,7 +13,7 @@ public class InviteCommand extends DCommand {
setMinArgs(2);
setMaxArgs(2);
setCommand("invite");
setHelp(dMessages.getMessage(Messages.HELP_CMD_INVITE));
setHelp(messageConfig.getMessage(Messages.HELP_CMD_INVITE));
setPermission("dxl.invite");
setPlayerCommand(true);
setConsoleCommand(true);
@ -22,10 +22,10 @@ public class InviteCommand extends DCommand {
@Override
public void onExecute(String[] args, CommandSender sender) {
if (EditWorld.addInvitedPlayer(args[2], UUIDUtil.getUniqueIdFromName(args[1]))) {
MessageUtil.sendMessage(sender, dMessages.getMessage(Messages.CMD_INVITE_SUCCESS, args[1], args[2]));
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.CMD_INVITE_SUCCESS, args[1], args[2]));
} else {
MessageUtil.sendMessage(sender, dMessages.getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, args[2]));
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, args[2]));
}
}

View File

@ -1,8 +1,8 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerEscapeEvent;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
@ -16,7 +16,7 @@ public class LeaveCommand extends DCommand {
setCommand("leave");
setMinArgs(0);
setMaxArgs(0);
setHelp(dMessages.getMessage(Messages.HELP_CMD_LEAVE));
setHelp(messageConfig.getMessage(Messages.HELP_CMD_LEAVE));
setPermission("dxl.leave");
setPlayerCommand(true);
}
@ -28,7 +28,7 @@ public class LeaveCommand extends DCommand {
if (GameWorld.getByWorld(player.getWorld()) != null) {
if (GameWorld.getByWorld(player.getWorld()).isTutorial()) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NO_LEAVE_IN_TUTORIAL));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_NO_LEAVE_IN_TUTORIAL));
return;
}
}
@ -41,17 +41,17 @@ public class LeaveCommand extends DCommand {
}
dPlayer.leave();
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_LEAVE_SUCCESS));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.CMD_LEAVE_SUCCESS));
} else {
DGroup dGroup = DGroup.getByPlayer(player);
if (dGroup != null) {
dGroup.removePlayer(player);
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_LEAVE_SUCCESS));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.CMD_LEAVE_SUCCESS));
return;
}
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NOT_IN_DUNGEON));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_NOT_IN_DUNGEON));
}
}

View File

@ -1,11 +1,11 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
import io.github.dre2n.dungeonsxl.config.WorldConfig;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
import io.github.dre2n.dungeonsxl.dungeon.DungeonConfig;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.dungeon.WorldConfig;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.util.NumberUtil;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
@ -20,7 +20,7 @@ public class ListCommand extends DCommand {
setCommand("list");
setMinArgs(0);
setMaxArgs(3);
setHelp(dMessages.getMessage(Messages.HELP_CMD_LIST));
setHelp(messageConfig.getMessage(Messages.HELP_CMD_LIST));
setPermission("dxl.list");
setPlayerCommand(true);
setConsoleCommand(true);

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
@ -14,7 +14,7 @@ public class LivesCommand extends DCommand {
setCommand("lives");
setMinArgs(0);
setMaxArgs(1);
setHelp(dMessages.getMessage(Messages.HELP_CMD_LIVES));
setHelp(messageConfig.getMessage(Messages.HELP_CMD_LIVES));
setPermission("dxl.lives");
setPlayerCommand(true);
setConsoleCommand(true);
@ -33,16 +33,16 @@ public class LivesCommand extends DCommand {
player = (Player) sender;
} else {
MessageUtil.sendMessage(sender, dMessages.getMessage(Messages.ERROR_NO_CONSOLE_COMMAND, getCommand()));
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_NO_CONSOLE_COMMAND, getCommand()));
return;
}
DPlayer dPlayer = DPlayer.getByPlayer(player);
if (dPlayer != null) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_LIVES, player.getName(), String.valueOf(dPlayer.getLives())));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.CMD_LIVES, player.getName(), String.valueOf(dPlayer.getLives())));
} else {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NOT_IN_DUNGEON));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_NOT_IN_DUNGEON));
}
}

View File

@ -3,7 +3,7 @@ package io.github.dre2n.dungeonsxl.command;
import java.io.File;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.util.VersionUtil.Internals;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
@ -15,7 +15,7 @@ public class MainCommand extends DCommand {
public MainCommand() {
setCommand("main");
setHelp(dMessages.getMessage(Messages.HELP_CMD_MAIN));
setHelp(messageConfig.getMessage(Messages.HELP_CMD_MAIN));
setPermission("dxl.main");
setPlayerCommand(true);
setConsoleCommand(true);
@ -44,10 +44,10 @@ public class MainCommand extends DCommand {
MessageUtil.sendCenteredMessage(sender, "&4" + MessageUtil.BIG_D[2] + "&f" + MessageUtil.BIG_X[2] + MessageUtil.BIG_L[2]);
MessageUtil.sendCenteredMessage(sender, "&4" + MessageUtil.BIG_D[3] + "&f" + MessageUtil.BIG_X[3] + MessageUtil.BIG_L[3]);
MessageUtil.sendCenteredMessage(sender, "&4" + MessageUtil.BIG_D[4] + "&f" + MessageUtil.BIG_X[4] + MessageUtil.BIG_L[4]);
MessageUtil.sendCenteredMessage(sender, "&b&l####### " + dMessages.getMessage(Messages.CMD_MAIN_WELCOME) + "&7 v" + plugin.getDescription().getVersion() + " &b&l#######");
MessageUtil.sendCenteredMessage(sender, dMessages.getMessage(Messages.CMD_MAIN_LOADED, String.valueOf(maps), String.valueOf(dungeons), String.valueOf(loaded), String.valueOf(players)));
MessageUtil.sendCenteredMessage(sender, dMessages.getMessage(Messages.CMD_MAIN_COMPATIBILITY, String.valueOf(internals), vault, mythicMobs));
MessageUtil.sendCenteredMessage(sender, dMessages.getMessage(Messages.CMD_MAIN_HELP));
MessageUtil.sendCenteredMessage(sender, "&b&l####### " + messageConfig.getMessage(Messages.CMD_MAIN_WELCOME) + "&7 v" + plugin.getDescription().getVersion() + " &b&l#######");
MessageUtil.sendCenteredMessage(sender, messageConfig.getMessage(Messages.CMD_MAIN_LOADED, String.valueOf(maps), String.valueOf(dungeons), String.valueOf(loaded), String.valueOf(players)));
MessageUtil.sendCenteredMessage(sender, messageConfig.getMessage(Messages.CMD_MAIN_COMPATIBILITY, String.valueOf(internals), vault, mythicMobs));
MessageUtil.sendCenteredMessage(sender, messageConfig.getMessage(Messages.CMD_MAIN_HELP));
MessageUtil.sendCenteredMessage(sender, "&7\u00a92012-2016 Frank Baumann & contributors; lcsd. under GPLv3.");
}

View File

@ -1,8 +1,8 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.dungeon.WorldConfig;
import io.github.dre2n.dungeonsxl.config.WorldConfig;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.util.NumberUtil;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
@ -18,7 +18,7 @@ public class MsgCommand extends DCommand {
setMinArgs( -1);
setMaxArgs( -1);
setCommand("msg");
setHelp(dMessages.getMessage(Messages.HELP_CMD_MSG));
setHelp(messageConfig.getMessage(Messages.HELP_CMD_MSG));
setPermission("dxl.msg");
setPlayerCommand(true);
}
@ -29,7 +29,7 @@ public class MsgCommand extends DCommand {
EditWorld editWorld = EditWorld.getByWorld(player.getWorld());
if (editWorld == null) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NOT_IN_DUNGEON));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_NOT_IN_DUNGEON));
return;
}
@ -50,7 +50,7 @@ public class MsgCommand extends DCommand {
MessageUtil.sendMessage(player, ChatColor.WHITE + msg);
} else {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_MSG_ID_NOT_EXIST, "" + id));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_MSG_ID_NOT_EXIST, "" + id));
}
} else {
@ -69,22 +69,22 @@ public class MsgCommand extends DCommand {
msg = splitMsg[1];
String old = confreader.getMsg(id, false);
if (old == null) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_MSG_ADDED, "" + id));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.CMD_MSG_ADDED, "" + id));
} else {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_MSG_UPDATED, "" + id));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.CMD_MSG_UPDATED, "" + id));
}
confreader.setMsg(msg, id);
confreader.save();
} else {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_MSG_FORMAT));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_MSG_FORMAT));
}
}
} catch (NumberFormatException e) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_MSG_NO_INT));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_MSG_NO_INT));
}
}

View File

@ -1,11 +1,12 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
import io.github.dre2n.dungeonsxl.config.WorldConfig;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
import io.github.dre2n.dungeonsxl.dungeon.WorldConfig;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
@ -21,7 +22,7 @@ public class PlayCommand extends DCommand {
setCommand("play");
setMinArgs(1);
setMaxArgs(2);
setHelp(dMessages.getMessage(Messages.HELP_CMD_PLAY));
setHelp(messageConfig.getMessage(Messages.HELP_CMD_PLAY));
setPermission("dxl.play");
setPlayerCommand(true);
}
@ -29,10 +30,10 @@ public class PlayCommand extends DCommand {
@Override
public void onExecute(String[] args, CommandSender sender) {
Player player = (Player) sender;
DPlayer dplayer = DPlayer.getByPlayer(player);
DPlayer dPlayer = DPlayer.getByPlayer(player);
if (dplayer != null) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON));
if (dPlayer != null) {
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_LEAVE_DUNGEON));
return;
}
@ -63,8 +64,8 @@ public class PlayCommand extends DCommand {
}
}
if ( !multiFloor && !EditWorld.exist(identifier)) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, identifier));
if ( !multiFloor && !EditWorld.exists(identifier)) {
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, identifier));
return;
}
@ -75,27 +76,54 @@ public class PlayCommand extends DCommand {
WorldConfig confReader = new WorldConfig(file);
if (confReader != null) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_COOLDOWN, "" + confReader.getTimeToNextPlay()));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_COOLDOWN, "" + confReader.getTimeToNextPlay()));
}
}
return;
}
if ( !GameWorld.checkRequirements(mapName, player)) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_REQUIREMENTS));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_REQUIREMENTS));
return;
}
if (DGroup.getByPlayer(player) != null) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_GROUP));
return;
}
DGroup dGroup = DGroup.getByPlayer(player);
DGroup dGroup = new DGroup(player, identifier, multiFloor);
if (dGroup != null) {
if ( !dGroup.getCaptain().equals(player) && !player.hasPermission("dxl.bypass")) {
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_NOT_CAPTAIN));
}
if (dGroup.getMapName() == null) {
if ( !multiFloor) {
dGroup.setMapName(identifier);
} else {
dGroup.setDungeonName(identifier);
Dungeon dungeon = plugin.getDungeons().getDungeon(identifier);
if (dungeon != null) {
DungeonConfig config = dungeon.getConfig();
if (config != null) {
dGroup.setMapName(config.getStartFloor());
}
}
}
} else {
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_LEAVE_GROUP));
return;
}
} else {
dGroup = new DGroup(player, identifier, multiFloor);
}
DGroupCreateEvent event = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.COMMAND);
if (event.isCancelled()) {
plugin.getDGroups().remove(dGroup);
dGroup = null;
}
@ -108,16 +136,20 @@ public class PlayCommand extends DCommand {
}
if (dGroup.getGameWorld() == null) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NOT_SAVED, DGroup.getByPlayer(player).getMapName()));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_NOT_SAVED, DGroup.getByPlayer(player).getMapName()));
dGroup.remove();
return;
}
if (dGroup.getGameWorld().getLocLobby() == null) {
new DPlayer(player, dGroup.getGameWorld().getWorld(), dGroup.getGameWorld().getWorld().getSpawnLocation(), false);
for (Player groupPlayer : dGroup.getPlayers()) {
new DPlayer(groupPlayer, dGroup.getGameWorld().getWorld(), dGroup.getGameWorld().getWorld().getSpawnLocation(), false);
}
} else {
new DPlayer(player, dGroup.getGameWorld().getWorld(), dGroup.getGameWorld().getLocLobby(), false);
for (Player groupPlayer : dGroup.getPlayers()) {
new DPlayer(groupPlayer, dGroup.getGameWorld().getWorld(), dGroup.getGameWorld().getLocLobby(), false);
}
}
}

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.global.DPortal;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
@ -16,7 +16,7 @@ public class PortalCommand extends DCommand {
setCommand("portal");
setMinArgs(0);
setMaxArgs(0);
setHelp(dMessages.getMessage(Messages.HELP_CMD_PORTAL));
setHelp(messageConfig.getMessage(Messages.HELP_CMD_PORTAL));
setPermission("dxl.portal");
setPlayerCommand(true);
}
@ -27,7 +27,7 @@ public class PortalCommand extends DCommand {
DPlayer dPlayer = DPlayer.getByPlayer(player);
if (dPlayer != null) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_LEAVE_DUNGEON));
}
DPortal dPortal = DPortal.getByPlayer(player);
@ -37,11 +37,11 @@ public class PortalCommand extends DCommand {
dPortal.setPlayer(player);
dPortal.setWorld(player.getWorld());
player.getInventory().setItemInHand(new ItemStack(Material.WOOD_SWORD));
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.PLAYER_PORTAL_INTRODUCTION));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.PLAYER_PORTAL_INTRODUCTION));
} else {
plugin.getDPortals().remove(dPortal);
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.PLAYER_PORTAL_ABORT));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.PLAYER_PORTAL_ABORT));
}
}

View File

@ -1,7 +1,7 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.util.VersionUtil.Internals;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
@ -17,7 +17,7 @@ public class ReloadCommand extends DCommand {
setCommand("reload");
setMinArgs(0);
setMaxArgs(0);
setHelp(dMessages.getMessage(Messages.HELP_CMD_RELOAD));
setHelp(messageConfig.getMessage(Messages.HELP_CMD_RELOAD));
setPermission("dxl.reload");
setPlayerCommand(true);
setConsoleCommand(true);
@ -43,19 +43,19 @@ public class ReloadCommand extends DCommand {
// Save
plugin.saveData();
plugin.getDMessages().save();
plugin.getMessageConfig().save();
// Load Config
plugin.loadMainConfig(new File(plugin.getDataFolder(), "config.yml"));
plugin.loadDMessages(new File(plugin.getDataFolder(), "languages/" + plugin.getMainConfig().getLanguage() + ".yml"));
plugin.loadMessageConfig(new File(plugin.getDataFolder(), "languages/" + plugin.getMainConfig().getLanguage() + ".yml"));
plugin.loadVersionUtil();
plugin.loadDCommands();
plugin.loadDungeons();
MessageUtil.sendPluginTag(sender, plugin);
MessageUtil.sendCenteredMessage(sender, dMessages.getMessage(Messages.CMD_RELOAD_DONE));
MessageUtil.sendCenteredMessage(sender, dMessages.getMessage(Messages.CMD_MAIN_LOADED, String.valueOf(maps), String.valueOf(dungeons), String.valueOf(loaded), String.valueOf(players)));
MessageUtil.sendCenteredMessage(sender, dMessages.getMessage(Messages.CMD_MAIN_COMPATIBILITY, String.valueOf(internals), vault, mythicMobs));
MessageUtil.sendCenteredMessage(sender, messageConfig.getMessage(Messages.CMD_RELOAD_DONE));
MessageUtil.sendCenteredMessage(sender, messageConfig.getMessage(Messages.CMD_MAIN_LOADED, String.valueOf(maps), String.valueOf(dungeons), String.valueOf(loaded), String.valueOf(players)));
MessageUtil.sendCenteredMessage(sender, messageConfig.getMessage(Messages.CMD_MAIN_COMPATIBILITY, String.valueOf(internals), vault, mythicMobs));
}
}

View File

@ -1,7 +1,7 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
import org.bukkit.command.CommandSender;
@ -13,7 +13,7 @@ public class SaveCommand extends DCommand {
setCommand("save");
setMinArgs(0);
setMaxArgs(0);
setHelp(dMessages.getMessage(Messages.HELP_CMD_SAVE));
setHelp(messageConfig.getMessage(Messages.HELP_CMD_SAVE));
setPermission("dxl.save");
setPlayerCommand(true);
}
@ -24,10 +24,10 @@ public class SaveCommand extends DCommand {
EditWorld editWorld = EditWorld.getByWorld(player.getWorld());
if (editWorld != null) {
editWorld.save();
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.CMD_SAVE_SUCCESS));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.CMD_SAVE_SUCCESS));
} else {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NOT_IN_DUNGEON));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_NOT_IN_DUNGEON));
}
}

View File

@ -1,10 +1,11 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
@ -18,7 +19,7 @@ public class TestCommand extends DCommand {
setCommand("test");
setMinArgs(1);
setMaxArgs(2);
setHelp(dMessages.getMessage(Messages.HELP_CMD_TEST));
setHelp(messageConfig.getMessage(Messages.HELP_CMD_TEST));
setPermission("dxl.test");
setPlayerCommand(true);
}
@ -29,7 +30,7 @@ public class TestCommand extends DCommand {
DPlayer dplayer = DPlayer.getByPlayer(player);
if (dplayer != null) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_DUNGEON));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_LEAVE_DUNGEON));
return;
}
@ -57,21 +58,48 @@ public class TestCommand extends DCommand {
}
}
if ( !multiFloor && !EditWorld.exist(identifier)) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, identifier));
if ( !multiFloor && !EditWorld.exists(identifier)) {
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, identifier));
return;
}
if (DGroup.getByPlayer(player) != null) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEAVE_GROUP));
return;
}
DGroup dGroup = DGroup.getByPlayer(player);
DGroup dGroup = new DGroup(player, identifier, multiFloor);
if (dGroup != null) {
if ( !dGroup.getCaptain().equals(player) && !player.hasPermission("dxl.bypass")) {
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_NOT_CAPTAIN));
}
if (dGroup.getMapName() == null) {
if ( !multiFloor) {
dGroup.setMapName(identifier);
} else {
dGroup.setDungeonName(identifier);
Dungeon dungeon = plugin.getDungeons().getDungeon(identifier);
if (dungeon != null) {
DungeonConfig config = dungeon.getConfig();
if (config != null) {
dGroup.setMapName(config.getStartFloor());
}
}
}
} else {
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_LEAVE_GROUP));
return;
}
} else {
dGroup = new DGroup(player, identifier, multiFloor);
}
DGroupCreateEvent event = new DGroupCreateEvent(dGroup, player, DGroupCreateEvent.Cause.COMMAND);
if (event.isCancelled()) {
plugin.getDGroups().remove(dGroup);
dGroup = null;
}
@ -84,21 +112,20 @@ public class TestCommand extends DCommand {
}
if (dGroup.getGameWorld() == null) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NOT_SAVED, DGroup.getByPlayer(player).getMapName()));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_NOT_SAVED, DGroup.getByPlayer(player).getMapName()));
dGroup.remove();
return;
}
DPlayer newDPlayer;
if (dGroup.getGameWorld().getLocLobby() == null) {
newDPlayer = new DPlayer(player, dGroup.getGameWorld().getWorld(), dGroup.getGameWorld().getWorld().getSpawnLocation(), false);
for (Player groupPlayer : dGroup.getPlayers()) {
new DPlayer(groupPlayer, dGroup.getGameWorld().getWorld(), dGroup.getGameWorld().getWorld().getSpawnLocation(), false).setInTestMode(true);
}
} else {
newDPlayer = new DPlayer(player, dGroup.getGameWorld().getWorld(), dGroup.getGameWorld().getLocLobby(), false);
for (Player groupPlayer : dGroup.getPlayers()) {
new DPlayer(groupPlayer, dGroup.getGameWorld().getWorld(), dGroup.getGameWorld().getLocLobby(), false).setInTestMode(true);
}
}
newDPlayer.setInTestMode(true);
}
}

View File

@ -1,7 +1,7 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.util.UUIDUtil;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
@ -13,7 +13,7 @@ public class UninviteCommand extends DCommand {
setCommand("uninvite");
setMinArgs(2);
setMaxArgs(2);
setHelp(dMessages.getMessage(Messages.HELP_CMD_UNINVITE));
setHelp(messageConfig.getMessage(Messages.HELP_CMD_UNINVITE));
setPermission("dxl.uninvite");
setPlayerCommand(true);
setConsoleCommand(true);
@ -22,10 +22,10 @@ public class UninviteCommand extends DCommand {
@Override
public void onExecute(String[] args, CommandSender sender) {
if (EditWorld.removeInvitedPlayer(args[2], UUIDUtil.getUniqueIdFromName(args[1]), args[1])) {
MessageUtil.sendMessage(sender, dMessages.getMessage(Messages.CMD_UNINVITE_SUCCESS, args[1], args[2]));
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.CMD_UNINVITE_SUCCESS, args[1], args[2]));
} else {
MessageUtil.sendMessage(sender, dMessages.getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, args[2]));
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, args[2]));
}
}

View File

@ -1,4 +1,4 @@
package io.github.dre2n.dungeonsxl.dungeon;
package io.github.dre2n.dungeonsxl.config;
import java.io.File;
import java.util.ArrayList;

View File

@ -1,6 +1,4 @@
package io.github.dre2n.dungeonsxl.file;
import io.github.dre2n.dungeonsxl.dungeon.WorldConfig;
package io.github.dre2n.dungeonsxl.config;
import java.io.File;
import java.io.IOException;
@ -23,7 +21,7 @@ public class MainConfig {
private String tutorialEndGroup = "player";
/* Default Dungeon Settings */
public WorldConfig defaultDungeon;
private WorldConfig defaultWorldConfig;
private List<String> editCommandWhitelist = new ArrayList<String>();
@ -92,8 +90,8 @@ public class MainConfig {
/* Default Dungeon Config */
ConfigurationSection configSection = configFile.getConfigurationSection("default");
if (configSection != null) {
defaultDungeon = new WorldConfig(configSection);
WorldConfig.defaultConfig = defaultDungeon;
setDefaultWorldConfig(new WorldConfig(configSection));
WorldConfig.defaultConfig = defaultWorldConfig;// TODO
}
}
}
@ -155,4 +153,19 @@ public class MainConfig {
return editCommandWhitelist;
}
/**
* @return the defaultWorldConfig
*/
public WorldConfig getDefaultWorldConfig() {
return defaultWorldConfig;
}
/**
* @param defaultWorldConfig
* the defaultWorldConfig to set
*/
public void setDefaultWorldConfig(WorldConfig defaultWorldConfig) {
this.defaultWorldConfig = defaultWorldConfig;
}
}

View File

@ -1,4 +1,4 @@
package io.github.dre2n.dungeonsxl.file;
package io.github.dre2n.dungeonsxl.config;
import java.io.File;
import java.io.IOException;
@ -7,10 +7,17 @@ import java.util.Set;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
public class DMessages {
public class MessageConfig {
public enum Messages {
GROUP_CREATED("Group_Created", "&4&v1&6 created the group &4&v2&6!"),
GROUP_DISBANDED("Group_Disbanded", "&4&v1&6 disbanded the group &4&v2&6."),
GROUP_INVITED_PLAYER("Group_InvitedPlayer", "&4&v1&6 invited the player &4&v2&6 to the group &4&v3&6."),
GROUP_UNINVITED_PLAYER("Group_UninvitedPlayer", "&4&v1&6 took back the invitation for &4&v2&6 to the group &4&v3&6."),
GROUP_KICKED_PLAYER("Group_KickedPlayer", "&4&v1&6 kicked the player &4&v2&6 from the group &4&v3&6."),
GROUP_PLAYER_JOINED("Group_PlayerJoined", "&6Player &4&v1&6 has joined the group!"),
LOG_ERROR_MOB_ENCHANTMENT("Log_Error_MobEnchantment", "&4Error at loading mob.yml: Enchantment &6&v1&4 doesn't exist!"),
LOG_ERROR_MOBTYPE("Log_Error_MobType", "&4Error at loading mob.yml: Mob &6&v1&4 doesn't exist!"),
LOG_ERROR_NO_CONSOLE_COMMAND("Log_Error_NoConsoleCommand", "&6/dxl &v1&4 can not be executed as Console!"),
@ -23,10 +30,14 @@ public class DMessages {
PLAYER_DEATH("Player_Death", "&6You died, lives left: &2&v1"),
PLAYER_DEATH_KICK("Player_DeathKick", "&2&v1&6 died and lost his last life."),
PLAYER_FINISHED_DUNGEON("Player_FinishedDungeon", "&6You successfully finished the Dungeon!"),
PLAYER_JOIN_GROUP("Player_JoinGroup", "&6Player &4&v1&6 has joined the Group!"),
PLAYER_INVITED("Player_Invited", "&4&v1&6 invited you to the group &4&v2&6."),
PLAYER_UNINVITED("Player_Uninvited", "&4&v1&6 took back your invitation to the group &4&v2&6."),
PLAYER_JOIN_GROUP("Player_JoinGroup", "&6You successfully joined the group!"),
PLAYER_KICKED("Player_Kicked", "&4You have been kicked out of the group &6&v1&4."),
PLAYER_LEAVE_GROUP("Player_LeaveGroup", "&6You have successfully left your group!"),
PLAYER_LEFT_GROUP("Player_LeftGroup", "&6Player &4&v1&6 has left the Group!"),
PLAYER_LOOT_ADDED("Player_LootAdded", "&4&v1&6 have been added to your reward inventory!"),
PLAYER_NEW_CAPTAIN("Player_NewCaptain", "&6You are now the new captain of your group."),
PLAYER_OFFLINE("Player_Offline", "&Player &4&v1&6 went offline. In &4&v2&6 seconds he will autmatically be kicked from the Dungeon!"),
PLAYER_OFFLINE_NEVER("Player_OfflineNever", "&Player &4&v1&6 went offline. He will &4not&6 be kicked from the Dungeon automatically!"),
PLAYER_PORTAL_ABORT("Player_PortalAbort", "&6Portal creation cancelled!"),
@ -69,6 +80,8 @@ public class DMessages {
ERROR_DROP("Error_Drop", "&4You cannot drop safe items"),
ERROR_DUNGEON_NOT_EXIST("Error_DungeonNotExist", "&4Dungeon &6&v1&4 does not exist!"),
ERROR_ENDERCHEST("Error_Enderchest", "&4You cannot use an enderchest while in a Dungeon!"),
ERROR_IN_GROUP("Error_InGroup", "&4The player &6&v1&4 is already member of a group."),
ERROR_JOIN_GROUP("Error_JoinGroup", "&4You have to join a group first!"),
ERROR_LEAVE_DUNGEON("Error_LeaveDungeon", "&4You have to leave your current dungeon first!"),
ERROR_LEAVE_GROUP("Error_LeaveGroup", "&4You have to leave your group first!"),
ERROR_LEFT_CLICK("Error_Leftklick", "&4You have to use Left-Click on this sign!"),
@ -81,8 +94,12 @@ public class DMessages {
ERROR_NO_PERMISSIONS("Error_NoPermissions", "&4You have no permission to do this!"),
ERROR_NO_PLAYER_COMMAND("Error_NoPlayerCommand", "&6/dxl &v1&4 cannot be executed as player!"),
ERROR_NO_PROTECTED_BLOCK("Error_NoDXLBlock", "&4This is not a block protected by DungeonsXL!"),
ERROR_NO_SUCH_GROUP("Error_NoSuchGroup", "&4The group &6&v1&4 does not exist!"),
ERROR_NO_SUCH_PLAYER("Error_NoSuchPlayer", "&4The player &6&v1&4 does not exist!"),
ERROR_NOT_CAPTAIN("Error_NotCaptain", "&4You are not the captain of your group!"),
ERROR_NOT_IN_DUNGEON("Error_NotInDungeon", "&4You are not in a dungeon!"),
ERROR_NOT_IN_GROUP("Error_NotInGroup", "&4You have to join a group first!"),
ERROR_NOT_IN_GROUP("Error_NotInGroup", "&4The player &6&v1&4 is not member of the group &6&v2&v4."),
ERROR_NOT_INVITED("Error_NotInvited", "&4You are not invited to the group &6&v1&4."),
ERROR_NOT_SAVED("Error_NotSaved", "&4The map &6&v1&4 has not been saved to the &6DungeonsXL/maps/ &4folder yet!"),
ERROR_TUTORIAL_NOT_EXIST("Error_TutorialNotExist", "&4Tutorial dungeon does not exist!"),
ERROR_READY("Error_Ready", "&4Choose your class first!"),
@ -95,6 +112,14 @@ public class DMessages {
HELP_CMD_CREATE("Help_Cmd_Create", "/dxl create <name> - Creates a new dungeon"),
HELP_CMD_EDIT("Help_Cmd_Edit", "/dxl edit <name> - Edit an existing dungeon"),
HELP_CMD_ESCAPE("Help_Cmd_Escape", "/dxl escape - Leaves the current dungeon, without saving!"),
HELP_CMD_GROUP("Help_Cmd_Group", "/dxl group - Shows group command help"),
HELP_CMD_GROUP_CREATE("Help_Cmd_GroupCreate", "/dxl group create [group] - Creates a new group"),
HELP_CMD_GROUP_DISBAND("Help_Cmd_GroupDisband", "/dxl group disband ([group]) - Disbands a group"),
HELP_CMD_GROUP_INVITE("Help_Cmd_GroupInvite", "/dxl group invite [player]- Invites someone to your group"),
HELP_CMD_GROUP_UNINVITE("Help_Cmd_GroupUninvite", "/dxl group uninvite [player] - Takes back an invitation to your group"),
HELP_CMD_GROUP_JOIN("Help_Cmd_GroupJoin", "/dxl group join [group]- Join a group"),
HELP_CMD_GROUP_KICK("Help_Cmd_GroupKick", "/dxl group kick [player] - Kicks a player"),
HELP_CMD_GROUP_SHOW("Help_Cmd_GroupShow", "/dxl group show [group] - Shows a group"),
HELP_CMD_HELP("Help_Cmd_Help", "/dxl help <page> - Shows the help page"),
HELP_CMD_INVITE("Help_Cmd_Invite", "/dxl invite <player> <dungeon> - Invite a player to edit a dungeon"),
HELP_CMD_LEAVE("Help_Cmd_Leave", "/dxl leave - Leaves the current dungeon"),
@ -175,7 +200,7 @@ public class DMessages {
private File file;
private FileConfiguration config;
public DMessages(File file) {
public MessageConfig(File file) {
this.file = file;
if ( !file.exists()) {

View File

@ -1,4 +1,4 @@
package io.github.dre2n.dungeonsxl.dungeon;
package io.github.dre2n.dungeonsxl.config;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.mob.DMobType;
@ -31,6 +31,7 @@ public class WorldConfig {
static DungeonsXL plugin = DungeonsXL.getPlugin();
@Deprecated
public static WorldConfig defaultConfig = new WorldConfig();
private File file;

View File

@ -1,7 +1,7 @@
package io.github.dre2n.dungeonsxl.dungeon;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -23,7 +23,7 @@ public class DLootInventory {
public DLootInventory(Player player, ItemStack[] itemStacks) {
plugin.getDLootInventories().add(this);
inventory = Bukkit.createInventory(player, 54, ChatColor.translateAlternateColorCodes('&', plugin.getDMessages().getMessage(Messages.PLAYER_TREASURES)));
inventory = Bukkit.createInventory(player, 54, ChatColor.translateAlternateColorCodes('&', plugin.getMessageConfig().getMessage(Messages.PLAYER_TREASURES)));
for (ItemStack itemStack : itemStacks) {
if (itemStack != null) {
inventory.addItem(itemStack);
@ -32,20 +32,6 @@ public class DLootInventory {
this.player = player;
}
/**
* @param player
* the player whose DLootIntentory will be returned
*/
public static DLootInventory getByPlayer(Player player) {
for (DLootInventory inventory : plugin.getDLootInventories()) {
if (inventory.player == player) {
return inventory;
}
}
return null;
}
/**
* @return the inventory
*/
@ -106,4 +92,20 @@ public class DLootInventory {
this.time = time;
}
// Static
/**
* @param player
* the player whose DLootIntentory will be returned
*/
public static DLootInventory getByPlayer(Player player) {
for (DLootInventory inventory : plugin.getDLootInventories()) {
if (inventory.player == player) {
return inventory;
}
}
return null;
}
}

View File

@ -1,6 +1,7 @@
package io.github.dre2n.dungeonsxl.dungeon;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
import java.io.File;

View File

@ -1,6 +1,7 @@
package io.github.dre2n.dungeonsxl.dungeon;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.WorldConfig;
import io.github.dre2n.dungeonsxl.event.editworld.EditWorldGenerateEvent;
import io.github.dre2n.dungeonsxl.event.editworld.EditWorldLoadEvent;
import io.github.dre2n.dungeonsxl.event.editworld.EditWorldSaveEvent;
@ -64,277 +65,6 @@ public class EditWorld {
name = "DXL_Edit_" + id;
}
public void generate() {
WorldCreator creator = WorldCreator.name(name);
creator.type(WorldType.FLAT);
creator.generateStructures(false);
EditWorldGenerateEvent event = new EditWorldGenerateEvent(this);
if (event.isCancelled()) {
return;
}
world = plugin.getServer().createWorld(creator);
}
public void save() {
EditWorldSaveEvent event = new EditWorldSaveEvent(this);
if (event.isCancelled()) {
return;
}
world.save();
File dir = new File("DXL_Edit_" + id);
FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + mapName));
FileUtil.deleteUnusedFiles(new File(plugin.getDataFolder(), "/maps/" + mapName));
try {
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(new File(plugin.getDataFolder(), "/maps/" + mapName + "/DXLData.data")));
out.writeInt(sign.size());
for (Block sign : this.sign) {
out.writeInt(sign.getX());
out.writeInt(sign.getY());
out.writeInt(sign.getZ());
}
out.close();
} catch (IOException exception) {
}
}
public void checkSign(Block block) {
if (block.getState() instanceof Sign) {
Sign sign = (Sign) block.getState();
String[] lines = sign.getLines();
if (lines[0].equalsIgnoreCase("[lobby]")) {
lobby = block.getLocation();
}
}
}
public void delete() {
EditWorldUnloadEvent event = new EditWorldUnloadEvent(this, true);
if (event.isCancelled()) {
return;
}
plugin.getEditWorlds().remove(this);
for (Player player : world.getPlayers()) {
DPlayer dPlayer = DPlayer.getByPlayer(player);
dPlayer.leave();
}
plugin.getServer().unloadWorld(world, true);
File dir = new File("DXL_Edit_" + id);
FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + mapName));
FileUtil.deleteUnusedFiles(new File(plugin.getDataFolder(), "/maps/" + mapName));
FileUtil.removeDirectory(dir);
}
public void deleteNoSave() {
EditWorldUnloadEvent event = new EditWorldUnloadEvent(this, false);
if (event.isCancelled()) {
return;
}
plugin.getEditWorlds().remove(this);
for (Player player : world.getPlayers()) {
DPlayer dPlayer = DPlayer.getByPlayer(player);
dPlayer.leave();
}
File dir = new File("DXL_Edit_" + id);
FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + mapName));
FileUtil.deleteUnusedFiles(new File(plugin.getDataFolder(), "/maps/" + mapName));
plugin.getServer().unloadWorld(world, true);
FileUtil.removeDirectory(dir);
}
// Static
public static EditWorld getByWorld(World world) {
for (EditWorld editWorld : plugin.getEditWorlds()) {
if (editWorld.world.equals(world)) {
return editWorld;
}
}
return null;
}
public static EditWorld getByName(String name) {
for (EditWorld editWorld : plugin.getEditWorlds()) {
if (editWorld.mapName.equalsIgnoreCase(name)) {
return editWorld;
}
}
return null;
}
public static void deleteAll() {
for (EditWorld editWorld : plugin.getEditWorlds()) {
editWorld.delete();
}
}
public static EditWorld load(String name) {
EditWorldLoadEvent event = new EditWorldLoadEvent(name);
if (event.isCancelled()) {
return null;
}
for (EditWorld editWorld : plugin.getEditWorlds()) {
if (editWorld.mapName.equalsIgnoreCase(name)) {
return editWorld;
}
}
File file = new File(plugin.getDataFolder(), "/maps/" + name);
if (file.exists()) {
EditWorld editWorld = new EditWorld();
editWorld.mapName = name;
// World
FileUtil.copyDirectory(file, new File("DXL_Edit_" + editWorld.id));
// Id File
File idFile = new File("DXL_Edit_" + editWorld.id + "/.id_" + name);
try {
idFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
editWorld.world = plugin.getServer().createWorld(WorldCreator.name("DXL_Edit_" + editWorld.id));
try {
ObjectInputStream os = new ObjectInputStream(new FileInputStream(new File(plugin.getDataFolder(), "/maps/" + editWorld.mapName + "/DXLData.data")));
int length = os.readInt();
for (int i = 0; i < length; i++) {
int x = os.readInt();
int y = os.readInt();
int z = os.readInt();
Block block = editWorld.world.getBlockAt(x, y, z);
editWorld.checkSign(block);
editWorld.sign.add(block);
}
os.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return editWorld;
}
return null;
}
public static boolean exist(String name) {
// Cheack Loaded EditWorlds
for (EditWorld editWorld : plugin.getEditWorlds()) {
if (editWorld.mapName.equalsIgnoreCase(name)) {
return true;
}
}
// Cheack Unloaded Worlds
File file = new File(plugin.getDataFolder(), "/maps/" + name);
if (file.exists()) {
return true;
}
return false;
}
public void msg(String msg) {
for (DPlayer dPlayer : DPlayer.getByWorld(world)) {
MessageUtil.sendMessage(dPlayer.getPlayer(), msg);
}
}
// Invite
public static boolean addInvitedPlayer(String editWorldName, UUID uuid) {
if ( !exist(editWorldName)) {
return false;
}
File file = new File(plugin.getDataFolder() + "/maps/" + editWorldName, "config.yml");
if ( !file.exists()) {
try {
file.createNewFile();
} catch (IOException exception) {
exception.printStackTrace();
return false;
}
}
WorldConfig config = new WorldConfig(file);
config.addInvitedPlayer(uuid.toString());
config.save();
return true;
}
public static boolean removeInvitedPlayer(String editWorldName, UUID uuid, String name) {
if ( !exist(editWorldName)) {
return false;
}
File file = new File(plugin.getDataFolder() + "/maps/" + editWorldName, "config.yml");
if ( !file.exists()) {
return false;
}
WorldConfig config = new WorldConfig(file);
config.removeInvitedPlayers(uuid.toString(), name.toLowerCase());
config.save();
// Kick Player
EditWorld editWorld = EditWorld.getByName(editWorldName);
if (editWorld != null) {
DPlayer player = DPlayer.getByName(name);
if (player != null) {
if (editWorld.world.getPlayers().contains(player.getPlayer())) {
player.leave();
}
}
}
return true;
}
public static boolean isInvitedPlayer(String editWorldName, UUID uuid, String name) {
if ( !exist(editWorldName)) {
return false;
}
File file = new File(plugin.getDataFolder() + "/maps/" + editWorldName, "config.yml");
if ( !file.exists()) {
return false;
}
WorldConfig config = new WorldConfig(file);
// get player from both a 0.9.1 and lower and 0.9.2 and higher file
if (config.getInvitedPlayers().contains(name.toLowerCase()) || config.getInvitedPlayers().contains(uuid.toString())) {
return true;
} else {
return false;
}
}
/**
* @return the world
*/
@ -455,4 +185,276 @@ public class EditWorld {
this.sign = sign;
}
public void generate() {
WorldCreator creator = WorldCreator.name(name);
creator.type(WorldType.FLAT);
creator.generateStructures(false);
EditWorldGenerateEvent event = new EditWorldGenerateEvent(this);
if (event.isCancelled()) {
return;
}
world = plugin.getServer().createWorld(creator);
}
public void save() {
EditWorldSaveEvent event = new EditWorldSaveEvent(this);
if (event.isCancelled()) {
return;
}
world.save();
File dir = new File("DXL_Edit_" + id);
FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + mapName));
FileUtil.deleteUnusedFiles(new File(plugin.getDataFolder(), "/maps/" + mapName));
try {
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(new File(plugin.getDataFolder(), "/maps/" + mapName + "/DXLData.data")));
out.writeInt(sign.size());
for (Block sign : this.sign) {
out.writeInt(sign.getX());
out.writeInt(sign.getY());
out.writeInt(sign.getZ());
}
out.close();
} catch (IOException exception) {
}
}
public void checkSign(Block block) {
if (block.getState() instanceof Sign) {
Sign sign = (Sign) block.getState();
String[] lines = sign.getLines();
if (lines[0].equalsIgnoreCase("[lobby]")) {
lobby = block.getLocation();
}
}
}
public void delete() {
EditWorldUnloadEvent event = new EditWorldUnloadEvent(this, true);
if (event.isCancelled()) {
return;
}
plugin.getEditWorlds().remove(this);
for (Player player : world.getPlayers()) {
DPlayer dPlayer = DPlayer.getByPlayer(player);
dPlayer.leave();
}
plugin.getServer().unloadWorld(world, true);
File dir = new File("DXL_Edit_" + id);
FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + mapName));
FileUtil.deleteUnusedFiles(new File(plugin.getDataFolder(), "/maps/" + mapName));
FileUtil.removeDirectory(dir);
}
public void deleteNoSave() {
EditWorldUnloadEvent event = new EditWorldUnloadEvent(this, false);
if (event.isCancelled()) {
return;
}
plugin.getEditWorlds().remove(this);
for (Player player : world.getPlayers()) {
DPlayer dPlayer = DPlayer.getByPlayer(player);
dPlayer.leave();
}
File dir = new File("DXL_Edit_" + id);
FileUtil.copyDirectory(dir, new File(plugin.getDataFolder(), "/maps/" + mapName));
FileUtil.deleteUnusedFiles(new File(plugin.getDataFolder(), "/maps/" + mapName));
plugin.getServer().unloadWorld(world, true);
FileUtil.removeDirectory(dir);
}
public void sendMessage(String message) {
for (DPlayer dPlayer : DPlayer.getByWorld(world)) {
MessageUtil.sendMessage(dPlayer.getPlayer(), message);
}
}
// Static
public static EditWorld getByWorld(World world) {
for (EditWorld editWorld : plugin.getEditWorlds()) {
if (editWorld.world.equals(world)) {
return editWorld;
}
}
return null;
}
public static EditWorld getByName(String name) {
for (EditWorld editWorld : plugin.getEditWorlds()) {
if (editWorld.mapName.equalsIgnoreCase(name)) {
return editWorld;
}
}
return null;
}
public static void deleteAll() {
for (EditWorld editWorld : plugin.getEditWorlds()) {
editWorld.delete();
}
}
public static EditWorld load(String name) {
EditWorldLoadEvent event = new EditWorldLoadEvent(name);
if (event.isCancelled()) {
return null;
}
for (EditWorld editWorld : plugin.getEditWorlds()) {
if (editWorld.mapName.equalsIgnoreCase(name)) {
return editWorld;
}
}
File file = new File(plugin.getDataFolder(), "/maps/" + name);
if (file.exists()) {
EditWorld editWorld = new EditWorld();
editWorld.mapName = name;
// World
FileUtil.copyDirectory(file, new File("DXL_Edit_" + editWorld.id));
// Id File
File idFile = new File("DXL_Edit_" + editWorld.id + "/.id_" + name);
try {
idFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
editWorld.world = plugin.getServer().createWorld(WorldCreator.name("DXL_Edit_" + editWorld.id));
try {
ObjectInputStream os = new ObjectInputStream(new FileInputStream(new File(plugin.getDataFolder(), "/maps/" + editWorld.mapName + "/DXLData.data")));
int length = os.readInt();
for (int i = 0; i < length; i++) {
int x = os.readInt();
int y = os.readInt();
int z = os.readInt();
Block block = editWorld.world.getBlockAt(x, y, z);
editWorld.checkSign(block);
editWorld.sign.add(block);
}
os.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return editWorld;
}
return null;
}
public static boolean exists(String name) {
// Cheack Loaded EditWorlds
for (EditWorld editWorld : plugin.getEditWorlds()) {
if (editWorld.mapName.equalsIgnoreCase(name)) {
return true;
}
}
// Cheack Unloaded Worlds
File file = new File(plugin.getDataFolder(), "/maps/" + name);
if (file.exists()) {
return true;
}
return false;
}
// Invite
public static boolean addInvitedPlayer(String editWorldName, UUID uuid) {
if ( !exists(editWorldName)) {
return false;
}
File file = new File(plugin.getDataFolder() + "/maps/" + editWorldName, "config.yml");
if ( !file.exists()) {
try {
file.createNewFile();
} catch (IOException exception) {
exception.printStackTrace();
return false;
}
}
WorldConfig config = new WorldConfig(file);
config.addInvitedPlayer(uuid.toString());
config.save();
return true;
}
public static boolean removeInvitedPlayer(String editWorldName, UUID uuid, String name) {
if ( !exists(editWorldName)) {
return false;
}
File file = new File(plugin.getDataFolder() + "/maps/" + editWorldName, "config.yml");
if ( !file.exists()) {
return false;
}
WorldConfig config = new WorldConfig(file);
config.removeInvitedPlayers(uuid.toString(), name.toLowerCase());
config.save();
// Kick Player
EditWorld editWorld = EditWorld.getByName(editWorldName);
if (editWorld != null) {
DPlayer player = DPlayer.getByName(name);
if (player != null) {
if (editWorld.world.getPlayers().contains(player.getPlayer())) {
player.leave();
}
}
}
return true;
}
public static boolean isInvitedPlayer(String editWorldName, UUID uuid, String name) {
if ( !exists(editWorldName)) {
return false;
}
File file = new File(plugin.getDataFolder() + "/maps/" + editWorldName, "config.yml");
if ( !file.exists()) {
return false;
}
WorldConfig config = new WorldConfig(file);
// get player from both a 0.9.1 and lower and 0.9.2 and higher file
if (config.getInvitedPlayers().contains(name.toLowerCase()) || config.getInvitedPlayers().contains(uuid.toString())) {
return true;
} else {
return false;
}
}
}

View File

@ -1,7 +1,7 @@
package io.github.dre2n.dungeonsxl.dungeon.game;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.reward.Reward;
@ -44,105 +44,6 @@ public class GameChest {
gameWorld.getGameChests().add(this);
}
public void addTreasure(DGroup dGroup) {
if (dGroup == null) {
return;
}
boolean hasMoneyReward = false;
for (Reward reward : dGroup.getRewards()) {
if (reward instanceof MoneyReward) {
hasMoneyReward = true;
((MoneyReward) reward).addMoney(moneyReward);
}
}
if ( !hasMoneyReward) {
Reward reward = Reward.create(RewardTypeDefault.MONEY);
((MoneyReward) reward).addMoney(moneyReward);
dGroup.addReward(reward);
}
for (Player player : dGroup.getPlayers()) {
DPlayer dPlayer = DPlayer.getByPlayer(player);
if (dPlayer == null) {
continue;
}
String msg = "";
for (ItemStack itemStack : chest.getInventory().getContents()) {
if (itemStack == null) {
continue;
}
dPlayer.getTreasureInv().addItem(itemStack);
String name = null;
if (itemStack.hasItemMeta()) {
if (itemStack.getItemMeta().hasDisplayName()) {
name = itemStack.getItemMeta().getDisplayName();
}
}
if (name == null && Bukkit.getPluginManager().getPlugin("Vault") != null) {
ItemInfo itemInfo = Items.itemByStack(itemStack);
if (itemInfo != null) {
name = itemInfo.getName();
} else {
name = itemStack.getType().name();
}
}
msg += ChatColor.RED + " " + itemStack.getAmount() + " " + name + ChatColor.GOLD + ",";
}
msg = msg.substring(0, msg.length() - 1);
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.PLAYER_LOOT_ADDED, msg));
if (moneyReward != 0) {
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.PLAYER_LOOT_ADDED, plugin.getEconomyProvider().format(moneyReward)));
}
}
}
// Statics
public static void onOpenInventory(InventoryOpenEvent event) {
InventoryView inventory = event.getView();
GameWorld gameWorld = GameWorld.getByWorld(event.getPlayer().getWorld());
if (gameWorld == null) {
return;
}
if ( !(inventory.getTopInventory().getHolder() instanceof Chest)) {
return;
}
Chest chest = (Chest) inventory.getTopInventory().getHolder();
for (GameChest gameChest : gameWorld.getGameChests()) {
if ( !gameChest.chest.equals(chest)) {
continue;
}
if (gameChest.used) {
MessageUtil.sendMessage(plugin.getServer().getPlayer(event.getPlayer().getUniqueId()), plugin.getDMessages().getMessage(Messages.ERROR_CHEST_IS_OPENED));
event.setCancelled(true);
continue;
}
if (gameChest.chest.getLocation().distance(chest.getLocation()) < 1) {
gameChest.addTreasure(DGroup.getByGameWorld(gameWorld));
gameChest.used = true;
event.setCancelled(true);
}
}
}
/**
* @return if the GameChest is used
*/
@ -203,4 +104,103 @@ public class GameChest {
this.moneyReward = moneyReward;
}
public void addTreasure(DGroup dGroup) {
if (dGroup == null) {
return;
}
boolean hasMoneyReward = false;
for (Reward reward : dGroup.getRewards()) {
if (reward instanceof MoneyReward) {
hasMoneyReward = true;
((MoneyReward) reward).addMoney(moneyReward);
}
}
if ( !hasMoneyReward) {
Reward reward = Reward.create(RewardTypeDefault.MONEY);
((MoneyReward) reward).addMoney(moneyReward);
dGroup.addReward(reward);
}
for (Player player : dGroup.getPlayers()) {
DPlayer dPlayer = DPlayer.getByPlayer(player);
if (dPlayer == null) {
continue;
}
String msg = "";
for (ItemStack itemStack : chest.getInventory().getContents()) {
if (itemStack == null) {
continue;
}
dPlayer.getTreasureInv().addItem(itemStack);
String name = null;
if (itemStack.hasItemMeta()) {
if (itemStack.getItemMeta().hasDisplayName()) {
name = itemStack.getItemMeta().getDisplayName();
}
}
if (name == null && Bukkit.getPluginManager().getPlugin("Vault") != null) {
ItemInfo itemInfo = Items.itemByStack(itemStack);
if (itemInfo != null) {
name = itemInfo.getName();
} else {
name = itemStack.getType().name();
}
}
msg += ChatColor.RED + " " + itemStack.getAmount() + " " + name + ChatColor.GOLD + ",";
}
msg = msg.substring(0, msg.length() - 1);
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.PLAYER_LOOT_ADDED, msg));
if (moneyReward != 0) {
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.PLAYER_LOOT_ADDED, plugin.getEconomyProvider().format(moneyReward)));
}
}
}
// Statics
public static void onOpenInventory(InventoryOpenEvent event) {
InventoryView inventory = event.getView();
GameWorld gameWorld = GameWorld.getByWorld(event.getPlayer().getWorld());
if (gameWorld == null) {
return;
}
if ( !(inventory.getTopInventory().getHolder() instanceof Chest)) {
return;
}
Chest chest = (Chest) inventory.getTopInventory().getHolder();
for (GameChest gameChest : gameWorld.getGameChests()) {
if ( !gameChest.chest.equals(chest)) {
continue;
}
if (gameChest.used) {
MessageUtil.sendMessage(plugin.getServer().getPlayer(event.getPlayer().getUniqueId()), plugin.getMessageConfig().getMessage(Messages.ERROR_CHEST_IS_OPENED));
event.setCancelled(true);
continue;
}
if (gameChest.chest.getLocation().distance(chest.getLocation()) < 1) {
gameChest.addTreasure(DGroup.getByGameWorld(gameWorld));
gameChest.used = true;
event.setCancelled(true);
}
}
}
}

View File

@ -238,7 +238,7 @@ public class GamePlaceableBlock {
}
}
// Canbuild
// Can build
public static boolean canBuildHere(Block block, BlockFace blockFace, Material mat, GameWorld gameWorld) {
for (GamePlaceableBlock gamePlacableBlock : gameWorld.getPlaceableBlocks()) {
if (gamePlacableBlock.block.getFace(block) != BlockFace.SELF) {

View File

@ -1,9 +1,9 @@
package io.github.dre2n.dungeonsxl.dungeon.game;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
import io.github.dre2n.dungeonsxl.config.WorldConfig;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
import io.github.dre2n.dungeonsxl.dungeon.DungeonConfig;
import io.github.dre2n.dungeonsxl.dungeon.WorldConfig;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.event.gameworld.GameWorldLoadEvent;
import io.github.dre2n.dungeonsxl.event.gameworld.GameWorldStartGameEvent;
@ -83,49 +83,6 @@ public class GameWorld {
}
}
public void checkSign(Block block) {
if (block.getState() instanceof Sign) {
Sign sign = (Sign) block.getState();
dSigns.add(DSign.create(sign, this));
}
}
public void startGame() {
GameWorldStartGameEvent event = new GameWorldStartGameEvent(this);
if (event.isCancelled()) {
return;
}
isPlaying = true;
for (DSign dSign : dSigns) {
if (dSign != null) {
if ( !dSign.getType().isOnDungeonInit()) {
dSign.onInit();
}
}
}
if (RedstoneTrigger.hasTriggers(this)) {
for (RedstoneTrigger trigger : RedstoneTrigger.getTriggersArray(this)) {
trigger.onTrigger();
}
}
for (DSign dSign : dSigns) {
if (dSign != null) {
if ( !dSign.hasTriggers()) {
dSign.onTrigger();
}
}
}
}
public void msg(String msg) {
for (DPlayer dPlayer : DPlayer.getByWorld(world)) {
MessageUtil.sendMessage(dPlayer.getPlayer(), msg);
}
}
/**
* @return the tutorial
*/
@ -365,8 +322,154 @@ public class GameWorld {
return null;
}
public void checkSign(Block block) {
if (block.getState() instanceof Sign) {
Sign sign = (Sign) block.getState();
dSigns.add(DSign.create(sign, this));
}
}
public void startGame() {
GameWorldStartGameEvent event = new GameWorldStartGameEvent(this);
if (event.isCancelled()) {
return;
}
isPlaying = true;
for (DSign dSign : dSigns) {
if (dSign != null) {
if ( !dSign.getType().isOnDungeonInit()) {
dSign.onInit();
}
}
}
if (RedstoneTrigger.hasTriggers(this)) {
for (RedstoneTrigger trigger : RedstoneTrigger.getTriggersArray(this)) {
trigger.onTrigger();
}
}
for (DSign dSign : dSigns) {
if (dSign != null) {
if ( !dSign.hasTriggers()) {
dSign.onTrigger();
}
}
}
}
public void sendMessage(String message) {
for (DPlayer dPlayer : DPlayer.getByWorld(world)) {
MessageUtil.sendMessage(dPlayer.getPlayer(), message);
}
}
public void delete() {
GameWorldUnloadEvent event = new GameWorldUnloadEvent(this);
if (event.isCancelled()) {
return;
}
plugin.getGameWorlds().remove(this);
plugin.getServer().unloadWorld(world, true);
File dir = new File("DXL_Game_" + id);
FileUtil.removeDirectory(dir);
}
public void update() {
if (getWorld() == null) {
return;
}
// Update Spiders
for (LivingEntity mob : getWorld().getLivingEntities()) {
if (mob.getType() == EntityType.SPIDER || mob.getType() == EntityType.CAVE_SPIDER) {
Spider spider = (Spider) mob;
if (spider.getTarget() != null) {
if (spider.getTarget().getType() == EntityType.PLAYER) {
continue;
}
}
for (Entity player : spider.getNearbyEntities(10, 10, 10)) {
if (player.getType() == EntityType.PLAYER) {
spider.setTarget((LivingEntity) player);
}
}
}
}
}
// Statics
public static GameWorld load(String name) {
GameWorldLoadEvent event = new GameWorldLoadEvent(name);
if (event.isCancelled()) {
return null;
}
File file = new File(plugin.getDataFolder(), "/maps/" + name);
if (file.exists()) {
GameWorld gameWorld = new GameWorld();
gameWorld.mapName = name;
// Unload empty editWorlds
for (EditWorld editWorld : plugin.getEditWorlds()) {
if (editWorld.getWorld().getPlayers().isEmpty()) {
editWorld.delete();
}
}
// Config einlesen
gameWorld.worldConfig = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + gameWorld.mapName, "config.yml"));
// Secure Objects
gameWorld.secureObjects = gameWorld.worldConfig.getSecureObjects();
// World
FileUtil.copyDirectory(file, new File("DXL_Game_" + gameWorld.id));
// Id File
File idFile = new File("DXL_Game_" + gameWorld.id + "/.id_" + name);
try {
idFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
gameWorld.world = plugin.getServer().createWorld(WorldCreator.name("DXL_Game_" + gameWorld.id));
ObjectInputStream os;
try {
os = new ObjectInputStream(new FileInputStream(new File(plugin.getDataFolder() + "/maps/" + gameWorld.mapName + "/DXLData.data")));
int length = os.readInt();
for (int i = 0; i < length; i++) {
int x = os.readInt();
int y = os.readInt();
int z = os.readInt();
Block block = gameWorld.world.getBlockAt(x, y, z);
gameWorld.checkSign(block);
}
os.close();
} catch (FileNotFoundException exception) {
plugin.getLogger().info("Could not find any sign data for the world \"" + name + "\"!");
} catch (IOException exception) {
exception.printStackTrace();
}
return gameWorld;
}
return null;
}
public static GameWorld getByWorld(World world) {
for (GameWorld gameWorld : plugin.getGameWorlds()) {
if (gameWorld.world.equals(world)) {
@ -408,6 +511,28 @@ public class GameWorld {
return true;
}
public static long getPlayerTime(String dungeon, Player player) {
File file = new File(plugin.getDataFolder() + "/maps/" + dungeon, "players.yml");
if ( !file.exists()) {
try {
file.createNewFile();
} catch (IOException exception) {
exception.printStackTrace();
}
}
FileConfiguration playerConfig = YamlConfiguration.loadConfiguration(file);
if (playerConfig.contains(player.getUniqueId().toString())) {
return playerConfig.getLong(player.getUniqueId().toString());
}
if (playerConfig.contains(player.getName())) {
return playerConfig.getLong(player.getName());
}
return -1;
}
public static boolean checkRequirements(String dungeon, Player player) {
if (player.hasPermission("dxl.ignorerequirements")) {
return true;
@ -483,131 +608,4 @@ public class GameWorld {
return true;
}
public static long getPlayerTime(String dungeon, Player player) {
File file = new File(plugin.getDataFolder() + "/maps/" + dungeon, "players.yml");
if ( !file.exists()) {
try {
file.createNewFile();
} catch (IOException exception) {
exception.printStackTrace();
}
}
FileConfiguration playerConfig = YamlConfiguration.loadConfiguration(file);
if (playerConfig.contains(player.getUniqueId().toString())) {
return playerConfig.getLong(player.getUniqueId().toString());
}
if (playerConfig.contains(player.getName())) {
return playerConfig.getLong(player.getName());
}
return -1;
}
public void delete() {
GameWorldUnloadEvent event = new GameWorldUnloadEvent(this);
if (event.isCancelled()) {
return;
}
plugin.getGameWorlds().remove(this);
plugin.getServer().unloadWorld(world, true);
File dir = new File("DXL_Game_" + id);
FileUtil.removeDirectory(dir);
}
public static GameWorld load(String name) {
GameWorldLoadEvent event = new GameWorldLoadEvent(name);
if (event.isCancelled()) {
return null;
}
File file = new File(plugin.getDataFolder(), "/maps/" + name);
if (file.exists()) {
GameWorld gameWorld = new GameWorld();
gameWorld.mapName = name;
// Unload empty editWorlds
for (EditWorld editWorld : plugin.getEditWorlds()) {
if (editWorld.getWorld().getPlayers().isEmpty()) {
editWorld.delete();
}
}
// Config einlesen
gameWorld.worldConfig = new WorldConfig(new File(plugin.getDataFolder() + "/maps/" + gameWorld.mapName, "config.yml"));
// Secure Objects
gameWorld.secureObjects = gameWorld.worldConfig.getSecureObjects();
// World
FileUtil.copyDirectory(file, new File("DXL_Game_" + gameWorld.id));
// Id File
File idFile = new File("DXL_Game_" + gameWorld.id + "/.id_" + name);
try {
idFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
gameWorld.world = plugin.getServer().createWorld(WorldCreator.name("DXL_Game_" + gameWorld.id));
ObjectInputStream os;
try {
os = new ObjectInputStream(new FileInputStream(new File(plugin.getDataFolder() + "/maps/" + gameWorld.mapName + "/DXLData.data")));
int length = os.readInt();
for (int i = 0; i < length; i++) {
int x = os.readInt();
int y = os.readInt();
int z = os.readInt();
Block block = gameWorld.world.getBlockAt(x, y, z);
gameWorld.checkSign(block);
}
os.close();
} catch (FileNotFoundException exception) {
plugin.getLogger().info("Could not find any sign data for the world \"" + name + "\"!");
} catch (IOException exception) {
exception.printStackTrace();
}
return gameWorld;
}
return null;
}
public static void update() {
for (GameWorld gameWorld : plugin.getGameWorlds()) {
if (gameWorld.getWorld() == null) {
return;
}
// Update Spiders
for (LivingEntity mob : gameWorld.getWorld().getLivingEntities()) {
if (mob.getType() == EntityType.SPIDER || mob.getType() == EntityType.CAVE_SPIDER) {
Spider spider = (Spider) mob;
if (spider.getTarget() != null) {
if (spider.getTarget().getType() == EntityType.PLAYER) {
continue;
}
}
for (Entity player : spider.getNearbyEntities(10, 10, 10)) {
if (player.getType() == EntityType.PLAYER) {
spider.setTarget((LivingEntity) player);
}
}
}
}
}
}
}

View File

@ -12,7 +12,7 @@ public class DGroupCreateEvent extends DGroupEvent implements Cancellable {
COMMAND,
GROUP_SIGN,
CUSTOM;
CUSTOM
}

View File

@ -0,0 +1,86 @@
package io.github.dre2n.dungeonsxl.event.dgroup;
import io.github.dre2n.dungeonsxl.player.DGroup;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
public class DGroupDisbandEvent extends DGroupEvent implements Cancellable {
public enum Cause {
COMMAND,
DUNGEON_FINISHED,
CUSTOM
}
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
private Player disbander;
private Cause cause;
public DGroupDisbandEvent(DGroup dGroup, Cause cause) {
super(dGroup);
this.cause = cause;
}
public DGroupDisbandEvent(DGroup dGroup, Player disbander, Cause cause) {
super(dGroup);
this.disbander = disbander;
this.cause = cause;
}
/**
* @return the disbander
*/
public Player getDisbander() {
return disbander;
}
/**
* @param disbander
* the disbander to set
*/
public void setDisbander(Player disbander) {
this.disbander = disbander;
}
/**
* @return the cause
*/
public Cause getCause() {
return cause;
}
/**
* @param cause
* the cause to set
*/
public void setCause(Cause cause) {
this.cause = cause;
}
@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;
}
}

View File

@ -7,11 +7,38 @@ import org.bukkit.event.HandlerList;
public class DPlayerKickEvent extends DPlayerEvent implements Cancellable {
public enum Cause {
COMMAND,
DEATH,
OFFLINE,
CUSTOM
}
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
public DPlayerKickEvent(DPlayer dPlayer) {
private Cause cause;
public DPlayerKickEvent(DPlayer dPlayer, Cause cause) {
super(dPlayer);
this.cause = cause;
}
/**
* @return the cause
*/
public Cause getCause() {
return cause;
}
/**
* @param cause
* the cause to set
*/
public void setCause(Cause cause) {
this.cause = cause;
}
@Override

View File

@ -1,8 +1,8 @@
package io.github.dre2n.dungeonsxl.global;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
@ -29,6 +29,81 @@ public class DPortal {
this.active = active;
}
/**
* @return the world
*/
public World getWorld() {
return world;
}
/**
* @param world
* the world to set
*/
public void setWorld(World world) {
this.world = world;
}
/**
* @return the block1
*/
public Block getBlock1() {
return block1;
}
/**
* @param block1
* the block1 to set
*/
public void setBlock1(Block block1) {
this.block1 = block1;
}
/**
* @return the block2
*/
public Block getBlock2() {
return block2;
}
/**
* @param block2
* the block2 to set
*/
public void setBlock2(Block block2) {
this.block2 = block2;
}
/**
* @return if the portal is active
*/
public boolean isActive() {
return active;
}
/**
* @param active
* set the DPortal active
*/
public void setActive(boolean active) {
this.active = active;
}
/**
* @return the player
*/
public Player getPlayer() {
return player;
}
/**
* @param player
* the player to set
*/
public void setPlayer(Player player) {
this.player = player;
}
public void create() {
player = null;
@ -87,7 +162,7 @@ public class DPortal {
DGroup dgroup = DGroup.getByPlayer(player);
if (dgroup == null) {
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.ERROR_NOT_IN_GROUP));
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.ERROR_JOIN_GROUP));
return;
}
@ -96,7 +171,7 @@ public class DPortal {
}
if (dgroup.getGameWorld() == null) {
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, DGroup.getByPlayer(player).getMapName()));
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.ERROR_DUNGEON_NOT_EXIST, DGroup.getByPlayer(player).getMapName()));
return;
}
@ -260,79 +335,4 @@ public class DPortal {
}
}
/**
* @return the world
*/
public World getWorld() {
return world;
}
/**
* @param world
* the world to set
*/
public void setWorld(World world) {
this.world = world;
}
/**
* @return the block1
*/
public Block getBlock1() {
return block1;
}
/**
* @param block1
* the block1 to set
*/
public void setBlock1(Block block1) {
this.block1 = block1;
}
/**
* @return the block2
*/
public Block getBlock2() {
return block2;
}
/**
* @param block2
* the block2 to set
*/
public void setBlock2(Block block2) {
this.block2 = block2;
}
/**
* @return if the portal is active
*/
public boolean isActive() {
return active;
}
/**
* @param active
* set the DPortal active
*/
public void setActive(boolean active) {
this.active = active;
}
/**
* @return the player
*/
public Player getPlayer() {
return player;
}
/**
* @param player
* the player to set
*/
public void setPlayer(Player player) {
this.player = player;
}
}

View File

@ -1,10 +1,10 @@
package io.github.dre2n.dungeonsxl.global;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.WorldConfig;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
import io.github.dre2n.dungeonsxl.dungeon.WorldConfig;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
@ -382,7 +382,7 @@ public class GroupSign {
}
if (DGroup.getByPlayer(player) != null) {
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.ERROR_LEAVE_GROUP));
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.ERROR_LEAVE_GROUP));
return true;
}
@ -391,7 +391,7 @@ public class GroupSign {
if (file != null) {
WorldConfig confReader = new WorldConfig(file);
if (confReader != null) {
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.ERROR_COOLDOWN, String.valueOf(confReader.getTimeToNextPlay())));
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.ERROR_COOLDOWN, String.valueOf(confReader.getTimeToNextPlay())));
}
}
@ -399,7 +399,7 @@ public class GroupSign {
}
if ( !GameWorld.checkRequirements(groupSign.mapName, player)) {
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.ERROR_REQUIREMENTS));
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.ERROR_REQUIREMENTS));
return true;
}

View File

@ -1,7 +1,7 @@
package io.github.dre2n.dungeonsxl.global;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
@ -57,7 +57,7 @@ public class LeaveSign {
DGroup dgroup = DGroup.getByPlayer(player);
if (dgroup != null) {
dgroup.removePlayer(player);
MessageUtil.sendMessage(player, DungeonsXL.getPlugin().getDMessages().getMessage(Messages.PLAYER_LEAVE_GROUP));// ChatColor.YELLOW+"Du hast deine Gruppe erfolgreich verlassen!");
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.PLAYER_LEAVE_GROUP));// ChatColor.YELLOW+"Du hast deine Gruppe erfolgreich verlassen!");
return true;
}
}

View File

@ -1,15 +1,15 @@
package io.github.dre2n.dungeonsxl.listener;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.dungeon.game.GamePlaceableBlock;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.global.DPortal;
import io.github.dre2n.dungeonsxl.global.GroupSign;
import io.github.dre2n.dungeonsxl.global.LeaveSign;
import io.github.dre2n.dungeonsxl.sign.DSign;
import io.github.dre2n.dungeonsxl.trigger.RedstoneTrigger;
import io.github.dre2n.dungeonsxl.task.RedstoneEventTask;
import io.github.dre2n.dungeonsxl.util.NumberUtil;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
@ -27,7 +27,6 @@ import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.scheduler.BukkitRunnable;
public class BlockListener implements Listener {
@ -55,8 +54,8 @@ public class BlockListener implements Listener {
if (dPortal != null) {
if (plugin.getInBreakMode().contains(player)) {
dPortal.delete();
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.PLAYER_PROTECTED_BLOCK_DELETED));
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.CMD_BREAK_PROTECTED_MODE));
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 {
@ -72,8 +71,8 @@ public class BlockListener implements Listener {
if (groupSign != null) {
if (plugin.getInBreakMode().contains(player)) {
groupSign.delete();
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.PLAYER_PROTECTED_BLOCK_DELETED));
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.CMD_BREAK_PROTECTED_MODE));
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 {
@ -94,8 +93,8 @@ public class BlockListener implements Listener {
if (leaveSign != null) {
if (plugin.getInBreakMode().contains(player)) {
leaveSign.delete();
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.PLAYER_PROTECTED_BLOCK_DELETED));
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.CMD_BREAK_PROTECTED_MODE));
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 {
@ -217,16 +216,16 @@ public class BlockListener implements Listener {
}
if ( !player.hasPermission(dsign.getType().getBuildPermission())) {
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.ERROR_NO_PERMISSIONS));
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.ERROR_NO_PERMISSIONS));
}
if (dsign.check()) {
editWorld.checkSign(block);
editWorld.getSign().add(block);
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.PLAYER_SIGN_CREATED));
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.PLAYER_SIGN_CREATED));
} else {
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.ERROR_SIGN_WRONG_FORMAT));
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.ERROR_SIGN_WRONG_FORMAT));
}
}
}
@ -259,22 +258,4 @@ public class BlockListener implements Listener {
new RedstoneEventTask(event.getBlock()).runTaskLater(plugin, 1);
}
public class RedstoneEventTask extends BukkitRunnable {
private final Block block;
public RedstoneEventTask(final Block block) {
this.block = block;
}
@Override
public void run() {
for (GameWorld gameWorld : plugin.getGameWorlds()) {
if (block.getWorld() == gameWorld.getWorld()) {
RedstoneTrigger.updateAll(gameWorld);
}
}
}
}
}

View File

@ -3,8 +3,8 @@ package io.github.dre2n.dungeonsxl.listener;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.command.DCommand;
import io.github.dre2n.dungeonsxl.file.DMessages;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.config.MessageConfig;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -19,13 +19,13 @@ public class CommandListener implements CommandExecutor {
DungeonsXL plugin = DungeonsXL.getPlugin();
if (args.length > 0) {
DMessages dMessages = plugin.getDMessages();
MessageConfig MessageConfig = plugin.getMessageConfig();
DCommand dCommand = plugin.getDCommands().getDCommand(args[0]);
if (dCommand != null) {
if (sender instanceof ConsoleCommandSender) {
if ( !dCommand.isConsoleCommand()) {
MessageUtil.sendMessage(sender, dMessages.getMessage(Messages.LOG_ERROR_NO_CONSOLE_COMMAND, dCommand.getCommand()));
MessageUtil.sendMessage(sender, MessageConfig.getMessage(Messages.LOG_ERROR_NO_CONSOLE_COMMAND, dCommand.getCommand()));
return false;
}
}
@ -34,13 +34,13 @@ public class CommandListener implements CommandExecutor {
Player player = (Player) sender;
if ( !dCommand.isPlayerCommand()) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NO_PLAYER_COMMAND, dCommand.getCommand()));
MessageUtil.sendMessage(player, MessageConfig.getMessage(Messages.ERROR_NO_PLAYER_COMMAND, dCommand.getCommand()));
return false;
} else {
if (dCommand.getPermission() != null) {
if ( !dCommand.playerHasPermissions(player)) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_NO_PERMISSIONS));
MessageUtil.sendMessage(player, MessageConfig.getMessage(Messages.ERROR_NO_PERMISSIONS));
return false;
}
}

View File

@ -1,7 +1,7 @@
package io.github.dre2n.dungeonsxl.listener;
import io.github.dre2n.dungeonsxl.config.WorldConfig;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.dungeon.WorldConfig;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.global.DPortal;
import io.github.dre2n.dungeonsxl.global.GroupSign;
@ -11,6 +11,7 @@ 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;
@ -121,11 +122,13 @@ public class EntityListener implements Listener {
attackedDGroup = DGroup.getByPlayer(attackedPlayer);
if (config.isPlayerVersusPlayer()) {
Bukkit.broadcastMessage("pvp cancel");
event.setCancelled(true);
}
if (attackerDGroup != null && attackedDGroup != null) {
if (config.isFriendlyFire() && attackerDGroup.equals(attackedDGroup)) {
Bukkit.broadcastMessage("ff cancel");
event.setCancelled(true);
}
}

View File

@ -3,23 +3,24 @@ package io.github.dre2n.dungeonsxl.listener;
import java.util.ArrayList;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.dungeon.WorldConfig;
import io.github.dre2n.dungeonsxl.config.MessageConfig;
import io.github.dre2n.dungeonsxl.config.WorldConfig;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.dungeon.DLootInventory;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.dungeon.game.GameChest;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerDeathEvent;
import io.github.dre2n.dungeonsxl.file.DMessages;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerKickEvent;
import io.github.dre2n.dungeonsxl.global.DPortal;
import io.github.dre2n.dungeonsxl.global.GroupSign;
import io.github.dre2n.dungeonsxl.global.LeaveSign;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.task.RespawnTask;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
import io.github.dre2n.dungeonsxl.trigger.UseItemTrigger;
import io.github.dre2n.dungeonsxl.util.MiscUtil;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
import org.bukkit.ChatColor;
@ -47,12 +48,11 @@ import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
import org.bukkit.scheduler.BukkitRunnable;
public class PlayerListener implements Listener {
static DungeonsXL plugin = DungeonsXL.getPlugin();
DMessages dMessages = plugin.getDMessages();
MessageConfig messageConfig = plugin.getMessageConfig();
@EventHandler(priority = EventPriority.HIGH)
public void onDeath(PlayerDeathEvent event) {
@ -79,17 +79,21 @@ public class PlayerListener implements Listener {
dPlayer.setLives(dPlayer.getLives() - dPlayerDeathEvent.getLostLives());
if (dPlayer.getLives() == 0 && dPlayer.isReady()) {
MessageUtil.broadcastMessage(dMessages.getMessage(Messages.PLAYER_DEATH_KICK, player.getName()));
DPlayerKickEvent dPlayerKickEvent = new DPlayerKickEvent(dPlayer, DPlayerKickEvent.Cause.DEATH);
// TODO: This Runnable is a workaround for a bug I couldn't find, yet...
new BukkitRunnable() {
public void run() {
dPlayer.leave();
}
}.runTaskLater(plugin, 1L);
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);
}
} else if ( !(dPlayer.getLives() == -1)) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.PLAYER_DEATH, String.valueOf(dPlayer.getLives())));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.PLAYER_DEATH, String.valueOf(dPlayer.getLives())));
} else if (dConfig != null) {
if (dConfig.getKeepInventoryOnDeath()) {
@ -118,13 +122,13 @@ public class PlayerListener implements Listener {
if (event.getAction() != Action.LEFT_CLICK_BLOCK) {
if (clickedBlock.getType() == Material.ENDER_CHEST) {
if ( !player.hasPermission("dxl.bypass")) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_ENDERCHEST));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_ENDERCHEST));
event.setCancelled(true);
}
} else if (clickedBlock.getType() == Material.BED_BLOCK) {
if ( !player.hasPermission("dxl.bypass")) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_BED));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_BED));
event.setCancelled(true);
}
}
@ -136,7 +140,7 @@ public class PlayerListener implements Listener {
if (event.getAction() != Action.LEFT_CLICK_BLOCK) {
if (clickedBlock.getType() == Material.DISPENSER) {
if ( !player.hasPermission("dxl.bypass")) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_DISPENSER));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_DISPENSER));
event.setCancelled(true);
}
}
@ -154,13 +158,13 @@ public class PlayerListener implements Listener {
if (dportal.getPlayer() == player) {
if (dportal.getBlock1() == null) {
dportal.setBlock1(event.getClickedBlock());
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.PLAYER_PORTAL_PROGRESS));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.PLAYER_PORTAL_PROGRESS));
} else if (dportal.getBlock2() == null) {
dportal.setBlock2(event.getClickedBlock());
dportal.setActive(true);
dportal.create();
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.PLAYER_PORTAL_CREATED));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.PLAYER_PORTAL_CREATED));
}
event.setCancelled(true);
}
@ -240,7 +244,7 @@ public class PlayerListener implements Listener {
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
trigger.onTrigger(player);
} else {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEFT_CLICK));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_LEFT_CLICK));
}
}
@ -251,7 +255,7 @@ public class PlayerListener implements Listener {
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
dPlayer.setDClass(ChatColor.stripColor(classSign.getLine(1)));
} else {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_LEFT_CLICK));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_LEFT_CLICK));
}
return;
}
@ -291,7 +295,7 @@ public class PlayerListener implements Listener {
for (Material material : gameWorld.getConfig().getSecureObjects()) {
if (material == event.getItemDrop().getItemStack().getType()) {
event.setCancelled(true);
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_DROP));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_DROP));
return;
}
}
@ -335,7 +339,7 @@ public class PlayerListener implements Listener {
// Da einige Plugins einen anderen Respawn setzen wird
// ein Scheduler gestartet der den Player nach einer
// Sekunde teleportiert.
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new RespawnRunnable(player, dGroup.getGameWorld().getLocStart()), 10);
new RespawnTask(player, dGroup.getGameWorld().getLocStart()).runTaskLater(plugin, 10L);
if (dPlayer.getWolf() != null) {
dPlayer.getWolf().teleport(dGroup.getGameWorld().getLocStart());
@ -347,7 +351,7 @@ public class PlayerListener implements Listener {
// Da einige Plugins einen anderen Respawn setzen wird
// ein Scheduler gestartet der den Player nach einer
// Sekunde teleportiert.
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new RespawnRunnable(player, dPlayer.getCheckpoint()), 10);
new RespawnTask(player, dPlayer.getCheckpoint()).runTaskLater(plugin, 10L);
if (dPlayer.getWolf() != null) {
dPlayer.getWolf().teleport(dPlayer.getCheckpoint());
@ -420,11 +424,11 @@ public class PlayerListener implements Listener {
dPlayer.leave();
} else if (timeUntilKickOfflinePlayer > 0) {
dGroup.sendMessage(dMessages.getMessage(Messages.PLAYER_OFFLINE, dPlayer.getPlayer().getName(), "" + timeUntilKickOfflinePlayer), player);
dGroup.sendMessage(messageConfig.getMessage(Messages.PLAYER_OFFLINE, dPlayer.getPlayer().getName(), "" + timeUntilKickOfflinePlayer), player);
dPlayer.setOfflineTime(System.currentTimeMillis() + timeUntilKickOfflinePlayer * 1000);
} else {
dGroup.sendMessage(dMessages.getMessage(Messages.PLAYER_OFFLINE_NEVER, dPlayer.getPlayer().getName()), player);
dGroup.sendMessage(messageConfig.getMessage(Messages.PLAYER_OFFLINE_NEVER, dPlayer.getPlayer().getName()), player);
}
} else if (dPlayer.isEditing()) {
@ -490,7 +494,7 @@ public class PlayerListener implements Listener {
}
if (dGroup.getGameWorld() == null) {
MessageUtil.sendMessage(player, dMessages.getMessage(Messages.ERROR_TUTORIAL_NOT_EXIST));
MessageUtil.sendMessage(player, messageConfig.getMessage(Messages.ERROR_TUTORIAL_NOT_EXIST));
continue;
}
@ -544,7 +548,7 @@ public class PlayerListener implements Listener {
}
if (event.isCancelled()) {
MessageUtil.sendMessage(event.getPlayer(), dMessages.getMessage(Messages.ERROR_CMD));
MessageUtil.sendMessage(event.getPlayer(), messageConfig.getMessage(Messages.ERROR_CMD));
}
}
@ -599,37 +603,4 @@ public class PlayerListener implements Listener {
}
}
// Etc. ---------------------------------
public class RespawnRunnable implements Runnable {
private Player player;
private Location location;
public RespawnRunnable(Player player, Location location) {
this.location = location;
this.player = player;
}
@Override
public void run() {
if (player.getLocation().distance(location) > 2) {
MiscUtil.secureTeleport(player, location);
}
DPlayer dPlayer = DPlayer.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);
}
}
}
}

View File

@ -1,8 +1,8 @@
package io.github.dre2n.dungeonsxl.mob;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.util.NumberUtil;
import java.util.Arrays;
@ -112,7 +112,7 @@ public class DMobType {
EntityType type = EntityType.fromName(configFile.getString(mobName + ".Type"));
if (type == null) {
plugin.getLogger().info(plugin.getDMessages().getMessage(Messages.LOG_ERROR_MOBTYPE, configFile.getString(mobName + ".Type")));
plugin.getLogger().info(plugin.getMessageConfig().getMessage(Messages.LOG_ERROR_MOBTYPE, configFile.getString(mobName + ".Type")));
continue;
}
@ -194,7 +194,7 @@ public class DMobType {
itemMeta.addEnchant(Enchantment.getByName(splittedEnchantment[0].toUpperCase()), 1, true);
}
} else {
plugin.getLogger().info(plugin.getDMessages().getMessage(Messages.LOG_ERROR_MOB_ENCHANTMENT, splittedEnchantment[0]));
plugin.getLogger().info(plugin.getMessageConfig().getMessage(Messages.LOG_ERROR_MOB_ENCHANTMENT, splittedEnchantment[0]));
}
}
}
@ -233,8 +233,8 @@ public class DMobType {
}
}
if (plugin.getMainConfig().defaultDungeon != null) {
for (DMobType mobType : plugin.getMainConfig().defaultDungeon.getMobTypes()) {
if (plugin.getMainConfig().getDefaultWorldConfig() != null) {
for (DMobType mobType : plugin.getMainConfig().getDefaultWorldConfig().getMobTypes()) {
if (mobType.name.equalsIgnoreCase(name)) {
return mobType;
}

View File

@ -1,12 +1,12 @@
package io.github.dre2n.dungeonsxl.player;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupStartFloorEvent;
import io.github.dre2n.dungeonsxl.event.requirement.RequirementDemandEvent;
import io.github.dre2n.dungeonsxl.event.reward.RewardAdditionEvent;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.global.GroupSign;
import io.github.dre2n.dungeonsxl.requirement.Requirement;
import io.github.dre2n.dungeonsxl.reward.Reward;
@ -14,7 +14,7 @@ import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.UUID;
import org.bukkit.entity.Player;
@ -23,7 +23,9 @@ public class DGroup {
static DungeonsXL plugin = DungeonsXL.getPlugin();
private String name;
private CopyOnWriteArrayList<Player> players = new CopyOnWriteArrayList<Player>();
private Player captain;
private List<Player> players = new ArrayList<Player>();
private List<UUID> invitedPlayers = new ArrayList<UUID>();
private String dungeonName;
private String mapName;
private List<String> unplayedFloors = new ArrayList<String>();
@ -32,42 +34,75 @@ public class DGroup {
private int floorCount;
private List<Reward> rewards = new ArrayList<Reward>();
public DGroup(String name, Player player, String identifier, boolean multiFloor) {
public DGroup(String name, Player player) {
plugin.getDGroups().add(this);
this.name = name;
this.players.add(player);
captain = player;
players.add(player);
Dungeon dungeon = plugin.getDungeons().getDungeon(identifier);
if (multiFloor && dungeon != null) {
this.dungeonName = identifier;
this.mapName = dungeon.getConfig().getStartFloor();
this.unplayedFloors = dungeon.getConfig().getFloors();
} else {
this.mapName = identifier;
}
this.playing = false;
this.floorCount = 0;
playing = false;
floorCount = 0;
}
public DGroup(Player player, String identifier, boolean multiFloor) {
plugin.getDGroups().add(this);
this.name = "Group_" + plugin.getDGroups().size();
name = "Group_" + plugin.getDGroups().size();
this.players.add(player);
captain = player;
players.add(player);
Dungeon dungeon = plugin.getDungeons().getDungeon(identifier);
if (multiFloor && dungeon != null) {
this.dungeonName = identifier;
this.mapName = dungeon.getConfig().getStartFloor();
this.unplayedFloors = dungeon.getConfig().getFloors();
dungeonName = identifier;
mapName = dungeon.getConfig().getStartFloor();
unplayedFloors = dungeon.getConfig().getFloors();
} else {
this.mapName = identifier;
mapName = identifier;
}
this.playing = false;
this.floorCount = 0;
playing = false;
floorCount = 0;
}
public DGroup(String name, Player player, String identifier, boolean multiFloor) {
plugin.getDGroups().add(this);
this.name = name;
captain = player;
players.add(player);
Dungeon dungeon = plugin.getDungeons().getDungeon(identifier);
if (multiFloor && dungeon != null) {
dungeonName = identifier;
mapName = dungeon.getConfig().getStartFloor();
unplayedFloors = dungeon.getConfig().getFloors();
} else {
mapName = identifier;
}
playing = false;
floorCount = 0;
}
public DGroup(String name, Player captain, List<Player> players, String identifier, boolean multiFloor) {
plugin.getDGroups().add(this);
this.name = name;
this.captain = captain;
this.players = players;
Dungeon dungeon = plugin.getDungeons().getDungeon(identifier);
if (multiFloor && dungeon != null) {
dungeonName = identifier;
mapName = dungeon.getConfig().getStartFloor();
unplayedFloors = dungeon.getConfig().getFloors();
} else {
mapName = identifier;
}
playing = false;
floorCount = 0;
}
// Getters and setters
@ -87,10 +122,25 @@ public class DGroup {
this.name = name;
}
/**
* @return the captain
*/
public Player getCaptain() {
return captain;
}
/**
* @param captain
* the captain to set
*/
public void setCaptain(Player captain) {
this.captain = captain;
}
/**
* @return the players
*/
public CopyOnWriteArrayList<Player> getPlayers() {
public List<Player> getPlayers() {
return players;
}
@ -99,13 +149,10 @@ public class DGroup {
* the player to add
*/
public void addPlayer(Player player) {
// Send message
for (Player groupPlayer : getPlayers()) {
MessageUtil.sendMessage(groupPlayer, plugin.getDMessages().getMessage(Messages.PLAYER_JOIN_GROUP, player.getName()));
}
sendMessage(plugin.getMessageConfig().getMessage(Messages.GROUP_PLAYER_JOINED, player.getName()));
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.PLAYER_JOIN_GROUP));
// Add player
getPlayers().add(player);
players.add(player);
}
/**
@ -113,13 +160,11 @@ public class DGroup {
* the player to remove
*/
public void removePlayer(Player player) {
getPlayers().remove(player);
players.remove(player);
GroupSign.updatePerGroup(this);
// Send message
for (Player groupPlayer : getPlayers()) {
MessageUtil.sendMessage(groupPlayer, plugin.getDMessages().getMessage(Messages.PLAYER_LEFT_GROUP, player.getName()));
}
sendMessage(plugin.getMessageConfig().getMessage(Messages.PLAYER_LEFT_GROUP, player.getName()));
// Check group
if (isEmpty()) {
@ -127,6 +172,92 @@ public class DGroup {
}
}
/**
* @return the players
*/
public List<Player> getInvitedPlayers() {
ArrayList<Player> players = new ArrayList<Player>();
for (UUID uuid : invitedPlayers) {
players.add(plugin.getServer().getPlayer(uuid));
}
return players;
}
/**
* @param player
* the player to add
*/
public void addInvitedPlayer(Player player, boolean silent) {
if (player == null) {
return;
}
if (DGroup.getByPlayer(player) != null) {
if ( !silent) {
MessageUtil.sendMessage(captain, plugin.getMessageConfig().getMessage(Messages.ERROR_IN_GROUP, player.getName()));
}
return;
}
if ( !silent) {
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.PLAYER_INVITED, captain.getName(), name));
}
// Send message
if ( !silent) {
sendMessage(plugin.getMessageConfig().getMessage(Messages.GROUP_INVITED_PLAYER, captain.getName(), player.getName(), name));
}
// Add player
invitedPlayers.add(player.getUniqueId());
}
/**
* @param player
* the player to remove
*/
public void removeInvitedPlayer(Player player, boolean silent) {
if (player == null) {
return;
}
if (DGroup.getByPlayer(player) != this) {
if ( !silent) {
MessageUtil.sendMessage(captain, plugin.getMessageConfig().getMessage(Messages.ERROR_NOT_IN_GROUP, player.getName(), name));
}
return;
}
if ( !silent) {
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.PLAYER_UNINVITED, player.getName(), name));
}
// Send message
if ( !silent) {
for (Player groupPlayer : getPlayers()) {
MessageUtil.sendMessage(groupPlayer, plugin.getMessageConfig().getMessage(Messages.GROUP_UNINVITED_PLAYER, captain.getName(), player.getName(), name));
}
}
invitedPlayers.remove(player.getUniqueId());
}
/**
* Remove all invitations for players who are not online
*/
public void clearOfflineInvitedPlayers() {
ArrayList<UUID> toRemove = new ArrayList<UUID>();
for (UUID uuid : invitedPlayers) {
if (plugin.getServer().getPlayer(uuid) == null) {
toRemove.add(uuid);
}
}
invitedPlayers.removeAll(toRemove);
}
/**
* @return the gameWorld
*/
@ -184,7 +315,7 @@ public class DGroup {
* the name to set
*/
public void setMapName(String name) {
this.mapName = name;
mapName = name;
}
/**
@ -325,27 +456,37 @@ public class DGroup {
public void sendMessage(String message) {
for (Player player : players) {
if (player.isOnline()) {
MessageUtil.sendCenteredMessage(player, message);
MessageUtil.sendMessage(player, message);
}
}
}
/**
* Send a message to all players in the group
*
*
* @param except
* Players who do not receive the message
*/
public void sendMessage(String message, Player... except) {
for (Player player : players) {
if (player.isOnline() && !player.equals(except)) {
MessageUtil.sendCenteredMessage(player, message);
MessageUtil.sendMessage(player, message);
}
}
}
// Statics
public static DGroup getByName(String name) {
for (DGroup dGroup : plugin.getDGroups()) {
if (dGroup.getName().equals(name)) {
return dGroup;
}
}
return null;
}
public static DGroup getByPlayer(Player player) {
for (DGroup dGroup : plugin.getDGroups()) {
if (dGroup.getPlayers().contains(player)) {

View File

@ -1,8 +1,10 @@
package io.github.dre2n.dungeonsxl.player;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.dungeon.DungeonConfig;
import io.github.dre2n.dungeonsxl.dungeon.WorldConfig;
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
import io.github.dre2n.dungeonsxl.config.MessageConfig;
import io.github.dre2n.dungeonsxl.config.WorldConfig;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.dungeon.DLootInventory;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
@ -11,12 +13,10 @@ import io.github.dre2n.dungeonsxl.event.dgroup.DGroupFinishFloorEvent;
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerFinishEvent;
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerKickEvent;
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerUpdateEvent;
import io.github.dre2n.dungeonsxl.file.DMessages;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.reward.Reward;
import io.github.dre2n.dungeonsxl.trigger.DistanceTrigger;
import io.github.dre2n.dungeonsxl.util.NumberUtil;
import io.github.dre2n.dungeonsxl.util.MiscUtil;
import io.github.dre2n.dungeonsxl.util.playerutil.PlayerUtil;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
import java.io.File;
@ -44,7 +44,7 @@ import org.bukkit.potion.PotionEffect;
public class DPlayer {
static DungeonsXL plugin = DungeonsXL.getPlugin();
DMessages dMessages = plugin.getDMessages();
MessageConfig messageConfig = plugin.getMessageConfig();
// Variables
private Player player;
@ -67,7 +67,7 @@ public class DPlayer {
private ItemStack[] respawnArmor;
private String[] linesCopy;
private Inventory treasureInv = plugin.getServer().createInventory(getPlayer(), 45, dMessages.getMessage(Messages.PLAYER_TREASURES));
private Inventory treasureInv = plugin.getServer().createInventory(getPlayer(), 45, messageConfig.getMessage(Messages.PLAYER_TREASURES));
private int initialLives = -1;
private int lives;
@ -102,7 +102,7 @@ public class DPlayer {
lives = initialLives;
}
MiscUtil.secureTeleport(this.getPlayer(), teleport);
PlayerUtil.secureTeleport(this.getPlayer(), teleport);
}
public void clearPlayerData() {
@ -117,330 +117,7 @@ public class DPlayer {
}
}
public void escape() {
remove(this);
savePlayer.reset(false);
}
public void leave() {
remove(this);
if ( !editing) {
WorldConfig dConfig = GameWorld.getByWorld(world).getConfig();
if (finished) {
savePlayer.reset(dConfig.getKeepInventoryOnFinish());
} else {
savePlayer.reset(dConfig.getKeepInventoryOnEscape());
}
} else {
savePlayer.reset(false);
}
if (editing) {
EditWorld editWorld = EditWorld.getByWorld(world);
if (editWorld != null) {
editWorld.save();
}
} else {
GameWorld gameWorld = GameWorld.getByWorld(world);
DGroup dGroup = DGroup.getByPlayer(getPlayer());
if (dGroup != null) {
dGroup.removePlayer(getPlayer());
}
// Belohnung
if ( !inTestMode) {// Nur wenn man nicht am Testen ist
if (finished) {
for (Reward reward : gameWorld.getConfig().getRewards()) {
reward.giveTo(player);
}
addTreasure();
// Set Time
File file = new File(plugin.getDataFolder() + "/maps/" + gameWorld.getMapName(), "players.yml");
if ( !file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
FileConfiguration playerConfig = YamlConfiguration.loadConfiguration(file);
playerConfig.set(getPlayer().getUniqueId().toString(), System.currentTimeMillis());
try {
playerConfig.save(file);
} catch (IOException exception) {
exception.printStackTrace();
}
// Tutorial Permissions
if (gameWorld.isTutorial()) {
String endGroup = plugin.getMainConfig().getTutorialEndGroup();
if (plugin.isGroupEnabled(endGroup)) {
plugin.getPermissionProvider().playerAddGroup(getPlayer(), endGroup);
}
String startGroup = plugin.getMainConfig().getTutorialStartGroup();
if (plugin.isGroupEnabled(startGroup)) {
plugin.getPermissionProvider().playerRemoveGroup(getPlayer(), startGroup);
}
}
}
}
// Give Secure Objects other Players
if (dGroup != null) {
if ( !dGroup.isEmpty()) {
int i = 0;
Player groupPlayer;
do {
groupPlayer = dGroup.getPlayers().get(i);
if (groupPlayer != null) {
for (ItemStack istack : getPlayer().getInventory()) {
if (istack != null) {
if (gameWorld.getSecureObjects().contains(istack.getType())) {
groupPlayer.getInventory().addItem(istack);
}
}
}
}
i++;
} while (groupPlayer == null);
}
}
}
}
public void ready() {
ready = true;
DGroup dGroup = DGroup.getByPlayer(getPlayer());
if ( !dGroup.isPlaying()) {
if (dGroup != null) {
for (Player player : dGroup.getPlayers()) {
DPlayer dPlayer = getByPlayer(player);
if ( !dPlayer.ready) {
return;
}
}
}
dGroup.startGame();
} else {
respawn();
}
}
public void respawn() {
DGroup dGroup = DGroup.getByPlayer(getPlayer());
if (checkpoint == null) {
MiscUtil.secureTeleport(getPlayer(), dGroup.getGameWorld().getLocStart());
} else {
MiscUtil.secureTeleport(getPlayer(), checkpoint);
}
if (wolf != null) {
wolf.teleport(getPlayer());
}
// 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);
}
}
public void finishFloor(String specifiedFloor) {
MessageUtil.sendMessage(getPlayer(), dMessages.getMessage(Messages.PLAYER_FINISHED_DUNGEON));
finished = true;
DGroup dGroup = DGroup.getByPlayer(getPlayer());
if (dGroup == null) {
return;
}
if ( !dGroup.isPlaying()) {
return;
}
for (Player player : dGroup.getPlayers()) {
DPlayer dPlayer = getByPlayer(player);
if ( !dPlayer.finished) {
MessageUtil.sendMessage(this.getPlayer(), dMessages.getMessage(Messages.PLAYER_WAIT_FOR_OTHER_PLAYERS));
return;
}
}
boolean invalid = false;
if (dGroup.getDungeon() == null) {
invalid = true;
}
for (Player player : dGroup.getPlayers()) {
DPlayer dPlayer = getByPlayer(player);
if (invalid) {
dPlayer.leave();
} else {
dPlayer.finished = false;
}
}
if (invalid) {
return;
}
DungeonConfig dConfig = dGroup.getDungeon().getConfig();
int random = NumberUtil.generateRandomInt(0, dConfig.getFloors().size());
String newFloor = dGroup.getUnplayedFloors().get(random);
if (dConfig.getFloorCount() == dGroup.getFloorCount() - 1) {
newFloor = dConfig.getEndFloor();
} else if (specifiedFloor != null) {
newFloor = specifiedFloor;
}
DGroupFinishFloorEvent event = new DGroupFinishFloorEvent(dGroup, dGroup.getGameWorld(), newFloor);
if (event.isCancelled()) {
return;
}
dGroup.removeUnplayedFloor(dGroup.getMapName());
dGroup.setMapName(newFloor);
GameWorld gameWorld = GameWorld.load(newFloor);
dGroup.setGameWorld(gameWorld);
for (Player player : dGroup.getPlayers()) {
DPlayer dPlayer = getByPlayer(player);
dPlayer.setWorld(gameWorld.getWorld());
dPlayer.setCheckpoint(dGroup.getGameWorld().getLocStart());
if (dPlayer.getWolf() != null) {
dPlayer.getWolf().teleport(dPlayer.getCheckpoint());
}
}
dGroup.startGame();
}
public void finish() {
MessageUtil.sendMessage(getPlayer(), dMessages.getMessage(Messages.PLAYER_FINISHED_DUNGEON));
finished = true;
DGroup dGroup = DGroup.getByPlayer(getPlayer());
if (dGroup == null) {
return;
}
if ( !dGroup.isPlaying()) {
return;
}
boolean first = true;
boolean hasToWait = false;
for (Player player : dGroup.getPlayers()) {
DPlayer dPlayer = getByPlayer(player);
if ( !dPlayer.finished) {
MessageUtil.sendMessage(this.getPlayer(), dMessages.getMessage(Messages.PLAYER_WAIT_FOR_OTHER_PLAYERS));
hasToWait = true;
} else if (dPlayer != this) {
first = false;
}
}
DPlayerFinishEvent dPlayerFinishEvent = new DPlayerFinishEvent(this, first, hasToWait);
if (dPlayerFinishEvent.isCancelled()) {
finished = false;
return;
}
if (hasToWait) {
return;
}
DGroupFinishDungeonEvent dGroupFinishDungeonEvent = new DGroupFinishDungeonEvent(dGroup);
if (dGroupFinishDungeonEvent.isCancelled()) {
return;
}
for (Player player : dGroup.getPlayers()) {
DPlayer dPlayer = getByPlayer(player);
dPlayer.leave();
for (Reward reward : dGroup.getRewards()) {
reward.giveTo(player);
}
}
}
public void sendMessage(String message) {
if (editing) {
EditWorld editWorld = EditWorld.getByWorld(world);
editWorld.msg(message);
for (Player player : plugin.getChatSpyers()) {
if ( !editWorld.getWorld().getPlayers().contains(player)) {
MessageUtil.sendMessage(player, ChatColor.GREEN + "[Chatspy] " + ChatColor.WHITE + message);
}
}
} else {
GameWorld gameWorld = GameWorld.getByWorld(world);
gameWorld.msg(message);
for (Player player : plugin.getChatSpyers()) {
if ( !gameWorld.getWorld().getPlayers().contains(player)) {
MessageUtil.sendMessage(player, ChatColor.GREEN + "[Chatspy] " + ChatColor.WHITE + message);
}
}
}
}
@SuppressWarnings("deprecation")
public void poke(Block block) {
if (block.getState() instanceof Sign) {
Sign sign = (Sign) block.getState();
String[] lines = sign.getLines();
if (lines[0].equals("") && lines[1].equals("") && lines[2].equals("") && lines[3].equals("")) {
if (linesCopy != null) {
SignChangeEvent event = new SignChangeEvent(block, getPlayer(), linesCopy);
plugin.getServer().getPluginManager().callEvent(event);
if ( !event.isCancelled()) {
sign.setLine(0, event.getLine(0));
sign.setLine(1, event.getLine(1));
sign.setLine(2, event.getLine(2));
sign.setLine(3, event.getLine(3));
sign.update();
}
}
} else {
linesCopy = lines;
MessageUtil.sendMessage(getPlayer(), dMessages.getMessage(Messages.PLAYER_SIGN_COPIED));
}
} else {
String info = "" + block.getType();
if (block.getData() != 0) {
info = info + "," + block.getData();
}
MessageUtil.sendMessage(getPlayer(), dMessages.getMessage(Messages.PLAYER_BLOCK_INFO, info));
}
}
public void addTreasure() {
new DLootInventory(getPlayer(), treasureInv.getContents());
}
// Getters and setters
/**
* @return the player
@ -795,6 +472,452 @@ public class DPlayer {
this.lives = lives;
}
// ...
public void escape() {
remove(this);
savePlayer.reset(false);
}
public void leave() {
remove(this);
if ( !editing) {
WorldConfig dConfig = GameWorld.getByWorld(world).getConfig();
if (finished) {
savePlayer.reset(dConfig.getKeepInventoryOnFinish());
} else {
savePlayer.reset(dConfig.getKeepInventoryOnEscape());
}
} else {
savePlayer.reset(false);
}
if (editing) {
EditWorld editWorld = EditWorld.getByWorld(world);
if (editWorld != null) {
editWorld.save();
}
} else {
GameWorld gameWorld = GameWorld.getByWorld(world);
DGroup dGroup = DGroup.getByPlayer(getPlayer());
if (dGroup != null) {
dGroup.removePlayer(getPlayer());
}
// Belohnung
if ( !inTestMode) {// Nur wenn man nicht am Testen ist
if (finished) {
for (Reward reward : gameWorld.getConfig().getRewards()) {
reward.giveTo(player);
}
addTreasure();
// Set Time
File file = new File(plugin.getDataFolder() + "/maps/" + gameWorld.getMapName(), "players.yml");
if ( !file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
FileConfiguration playerConfig = YamlConfiguration.loadConfiguration(file);
playerConfig.set(getPlayer().getUniqueId().toString(), System.currentTimeMillis());
try {
playerConfig.save(file);
} catch (IOException exception) {
exception.printStackTrace();
}
// Tutorial Permissions
if (gameWorld.isTutorial()) {
String endGroup = plugin.getMainConfig().getTutorialEndGroup();
if (plugin.isGroupEnabled(endGroup)) {
plugin.getPermissionProvider().playerAddGroup(getPlayer(), endGroup);
}
String startGroup = plugin.getMainConfig().getTutorialStartGroup();
if (plugin.isGroupEnabled(startGroup)) {
plugin.getPermissionProvider().playerRemoveGroup(getPlayer(), startGroup);
}
}
}
}
if (dGroup != null) {
// Give Secure Objects other Players
if ( !dGroup.isEmpty()) {
int i = 0;
Player groupPlayer;
do {
groupPlayer = dGroup.getPlayers().get(i);
if (groupPlayer != null) {
for (ItemStack itemStack : getPlayer().getInventory()) {
if (itemStack != null) {
if (gameWorld.getSecureObjects().contains(itemStack.getType())) {
groupPlayer.getInventory().addItem(itemStack);
}
}
}
}
i++;
} while (groupPlayer == null);
}
if (dGroup.getCaptain().equals(player) && dGroup.getPlayers().size() > 0) {
// Captain here!
Player newCaptain = dGroup.getPlayers().get(0);
dGroup.setCaptain(newCaptain);
MessageUtil.sendMessage(newCaptain, messageConfig.getMessage(Messages.PLAYER_NEW_CAPTAIN));
// ...*flies away*
}
}
}
}
public void ready() {
ready = true;
DGroup dGroup = DGroup.getByPlayer(getPlayer());
if ( !dGroup.isPlaying()) {
if (dGroup != null) {
for (Player player : dGroup.getPlayers()) {
DPlayer dPlayer = getByPlayer(player);
if ( !dPlayer.ready) {
return;
}
}
}
dGroup.startGame();
} else {
respawn();
}
}
public void respawn() {
DGroup dGroup = DGroup.getByPlayer(getPlayer());
if (checkpoint == null) {
PlayerUtil.secureTeleport(getPlayer(), dGroup.getGameWorld().getLocStart());
} else {
PlayerUtil.secureTeleport(getPlayer(), checkpoint);
}
if (wolf != null) {
wolf.teleport(getPlayer());
}
// 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);
}
}
public void finishFloor(String specifiedFloor) {
MessageUtil.sendMessage(getPlayer(), messageConfig.getMessage(Messages.PLAYER_FINISHED_DUNGEON));
finished = true;
DGroup dGroup = DGroup.getByPlayer(getPlayer());
if (dGroup == null) {
return;
}
if ( !dGroup.isPlaying()) {
return;
}
for (Player player : dGroup.getPlayers()) {
DPlayer dPlayer = getByPlayer(player);
if ( !dPlayer.finished) {
MessageUtil.sendMessage(this.getPlayer(), messageConfig.getMessage(Messages.PLAYER_WAIT_FOR_OTHER_PLAYERS));
return;
}
}
boolean invalid = false;
if (dGroup.getDungeon() == null) {
invalid = true;
}
for (Player player : dGroup.getPlayers()) {
DPlayer dPlayer = getByPlayer(player);
if (invalid) {
dPlayer.leave();
} else {
dPlayer.finished = false;
}
}
if (invalid) {
return;
}
DungeonConfig dConfig = dGroup.getDungeon().getConfig();
int random = NumberUtil.generateRandomInt(0, dConfig.getFloors().size());
String newFloor = dGroup.getUnplayedFloors().get(random);
if (dConfig.getFloorCount() == dGroup.getFloorCount() - 1) {
newFloor = dConfig.getEndFloor();
} else if (specifiedFloor != null) {
newFloor = specifiedFloor;
}
DGroupFinishFloorEvent event = new DGroupFinishFloorEvent(dGroup, dGroup.getGameWorld(), newFloor);
if (event.isCancelled()) {
return;
}
dGroup.removeUnplayedFloor(dGroup.getMapName());
dGroup.setMapName(newFloor);
GameWorld gameWorld = GameWorld.load(newFloor);
dGroup.setGameWorld(gameWorld);
for (Player player : dGroup.getPlayers()) {
DPlayer dPlayer = getByPlayer(player);
dPlayer.setWorld(gameWorld.getWorld());
dPlayer.setCheckpoint(dGroup.getGameWorld().getLocStart());
if (dPlayer.getWolf() != null) {
dPlayer.getWolf().teleport(dPlayer.getCheckpoint());
}
}
dGroup.startGame();
}
public void finish() {
MessageUtil.sendMessage(getPlayer(), messageConfig.getMessage(Messages.PLAYER_FINISHED_DUNGEON));
finished = true;
DGroup dGroup = DGroup.getByPlayer(getPlayer());
if (dGroup == null) {
return;
}
if ( !dGroup.isPlaying()) {
return;
}
boolean first = true;
boolean hasToWait = false;
for (Player player : dGroup.getPlayers()) {
DPlayer dPlayer = getByPlayer(player);
if ( !dPlayer.finished) {
MessageUtil.sendMessage(this.getPlayer(), messageConfig.getMessage(Messages.PLAYER_WAIT_FOR_OTHER_PLAYERS));
hasToWait = true;
} else if (dPlayer != this) {
first = false;
}
}
DPlayerFinishEvent dPlayerFinishEvent = new DPlayerFinishEvent(this, first, hasToWait);
if (dPlayerFinishEvent.isCancelled()) {
finished = false;
return;
}
if (hasToWait) {
return;
}
DGroupFinishDungeonEvent dGroupFinishDungeonEvent = new DGroupFinishDungeonEvent(dGroup);
if (dGroupFinishDungeonEvent.isCancelled()) {
return;
}
for (Player player : dGroup.getPlayers()) {
DPlayer dPlayer = getByPlayer(player);
dPlayer.leave();
for (Reward reward : dGroup.getRewards()) {
reward.giveTo(player);
}
}
}
public void sendMessage(String message) {
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);
}
}
} 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);
}
}
}
}
@SuppressWarnings("deprecation")
public void poke(Block block) {
if (block.getState() instanceof Sign) {
Sign sign = (Sign) block.getState();
String[] lines = sign.getLines();
if (lines[0].equals("") && lines[1].equals("") && lines[2].equals("") && lines[3].equals("")) {
if (linesCopy != null) {
SignChangeEvent event = new SignChangeEvent(block, getPlayer(), linesCopy);
plugin.getServer().getPluginManager().callEvent(event);
if ( !event.isCancelled()) {
sign.setLine(0, event.getLine(0));
sign.setLine(1, event.getLine(1));
sign.setLine(2, event.getLine(2));
sign.setLine(3, event.getLine(3));
sign.update();
}
}
} else {
linesCopy = lines;
MessageUtil.sendMessage(getPlayer(), messageConfig.getMessage(Messages.PLAYER_SIGN_COPIED));
}
} else {
String info = "" + block.getType();
if (block.getData() != 0) {
info = info + "," + block.getData();
}
MessageUtil.sendMessage(getPlayer(), messageConfig.getMessage(Messages.PLAYER_BLOCK_INFO, info));
}
}
public void addTreasure() {
new DLootInventory(getPlayer(), treasureInv.getContents());
}
public void update(boolean updateSecond) {
boolean locationValid = true;
Location teleportLocation = getPlayer().getLocation();
boolean teleportWolf = false;
boolean respawnInventory = false;
boolean offline = false;
boolean kick = false;
boolean triggerAllInDistance = false;
GameWorld gameWorld = GameWorld.getByWorld(getWorld());
EditWorld editWorld = EditWorld.getByWorld(getWorld());
if ( !updateSecond) {
if ( !getPlayer().getWorld().equals(getWorld())) {
locationValid = false;
if (isEditing()) {
if (editWorld != null) {
if (editWorld.getLobby() == null) {
teleportLocation = editWorld.getWorld().getSpawnLocation();
} else {
teleportLocation = editWorld.getLobby();
}
}
} else {
if (gameWorld != null) {
DGroup dGroup = DGroup.getByPlayer(getPlayer());
if (getCheckpoint() == null) {
teleportLocation = dGroup.getGameWorld().getLocStart();
if (getWolf() != null) {
getWolf().teleport(dGroup.getGameWorld().getLocStart());
}
} else {
teleportLocation = getCheckpoint();
if (getWolf() != null) {
teleportWolf = true;
}
}
// Respawn Items
if (getRespawnInventory() != null || getRespawnArmor() != null) {
respawnInventory = true;
}
}
}
}
} else {
if (gameWorld != null) {
// Update Wolf
if (getWolf() != null) {
if (getWolf().isDead()) {
if (getWolfRespawnTime() <= 0) {
setWolf((Wolf) getWorld().spawnEntity(getPlayer().getLocation(), EntityType.WOLF));
getWolf().setTamed(true);
getWolf().setOwner(getPlayer());
setWolfRespawnTime(30);
}
wolfRespawnTime--;
}
}
// Kick offline plugin.getDPlayers()
if (getOfflineTime() > 0) {
offline = true;
if (getOfflineTime() < System.currentTimeMillis()) {
kick = true;
}
}
triggerAllInDistance = true;
}
}
DPlayerUpdateEvent event = new DPlayerUpdateEvent(this, locationValid, teleportWolf, respawnInventory, offline, kick, triggerAllInDistance);
if (event.isCancelled()) {
return;
}
if ( !locationValid) {
PlayerUtil.secureTeleport(getPlayer(), teleportLocation);
}
if (teleportWolf) {
getWolf().teleport(getCheckpoint());
}
if (respawnInventory) {
getPlayer().getInventory().setContents(getRespawnInventory());
getPlayer().getInventory().setArmorContents(getRespawnArmor());
setRespawnInventory(null);
setRespawnArmor(null);
}
if (kick) {
DPlayerKickEvent dPlayerKickEvent = new DPlayerKickEvent(this, DPlayerKickEvent.Cause.OFFLINE);
if ( !dPlayerKickEvent.isCancelled()) {
leave();
}
}
if (triggerAllInDistance) {
DistanceTrigger.triggerAllInDistance(getPlayer(), gameWorld);
}
}
// Static
public static void remove(DPlayer player) {
@ -831,115 +954,4 @@ public class DPlayer {
return dPlayers;
}
public static void update(boolean updateSecond) {
for (DPlayer dPlayer : plugin.getDPlayers()) {
boolean locationValid = true;
Location teleportLocation = dPlayer.getPlayer().getLocation();
boolean teleportWolf = false;
boolean respawnInventory = false;
boolean offline = false;
boolean kick = false;
boolean triggerAllInDistance = false;
GameWorld gameWorld = GameWorld.getByWorld(dPlayer.world);
EditWorld editWorld = EditWorld.getByWorld(dPlayer.world);
if ( !updateSecond) {
if ( !dPlayer.getPlayer().getWorld().equals(dPlayer.world)) {
locationValid = false;
if (dPlayer.editing) {
if (editWorld != null) {
if (editWorld.getLobby() == null) {
teleportLocation = editWorld.getWorld().getSpawnLocation();
} else {
teleportLocation = editWorld.getLobby();
}
}
} else {
if (gameWorld != null) {
DGroup dGroup = DGroup.getByPlayer(dPlayer.getPlayer());
if (dPlayer.checkpoint == null) {
teleportLocation = dGroup.getGameWorld().getLocStart();
if (dPlayer.wolf != null) {
dPlayer.wolf.teleport(dGroup.getGameWorld().getLocStart());
}
} else {
teleportLocation = dPlayer.getCheckpoint();
if (dPlayer.wolf != null) {
teleportWolf = true;
}
}
// Respawn Items
if (dPlayer.respawnInventory != null || dPlayer.respawnArmor != null) {
respawnInventory = true;
}
}
}
}
} else {
if (gameWorld != null) {
// Update Wolf
if (dPlayer.wolf != null) {
if (dPlayer.wolf.isDead()) {
if (dPlayer.wolfRespawnTime <= 0) {
dPlayer.wolf = (Wolf) dPlayer.world.spawnEntity(dPlayer.getPlayer().getLocation(), EntityType.WOLF);
dPlayer.wolf.setTamed(true);
dPlayer.wolf.setOwner(dPlayer.getPlayer());
dPlayer.wolfRespawnTime = 30;
}
dPlayer.wolfRespawnTime--;
}
}
// Kick offline plugin.getDPlayers()
if (dPlayer.offlineTime > 0) {
offline = true;
if (dPlayer.offlineTime < System.currentTimeMillis()) {
kick = true;
}
}
triggerAllInDistance = true;
}
}
DPlayerUpdateEvent event = new DPlayerUpdateEvent(dPlayer, locationValid, teleportWolf, respawnInventory, offline, kick, triggerAllInDistance);
if (event.isCancelled()) {
return;
}
if ( !locationValid) {
MiscUtil.secureTeleport(dPlayer.getPlayer(), teleportLocation);
}
if (teleportWolf) {
dPlayer.wolf.teleport(dPlayer.checkpoint);
}
if (respawnInventory) {
dPlayer.getPlayer().getInventory().setContents(dPlayer.respawnInventory);
dPlayer.getPlayer().getInventory().setArmorContents(dPlayer.respawnArmor);
dPlayer.respawnInventory = null;
dPlayer.respawnArmor = null;
}
if (kick) {
DPlayerKickEvent dPlayerKickEvent = new DPlayerKickEvent(dPlayer);
if ( !dPlayerKickEvent.isCancelled()) {
dPlayer.leave();
}
}
if (triggerAllInDistance) {
DistanceTrigger.triggerAllInDistance(dPlayer.getPlayer(), gameWorld);
}
}
}
}

View File

@ -1,8 +1,7 @@
package io.github.dre2n.dungeonsxl.player;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.util.MiscUtil;
import io.github.dre2n.dungeonsxl.util.offlineplayerutil.OfflinePlayerUtil;
import io.github.dre2n.dungeonsxl.util.playerutil.PlayerUtil;
import java.io.File;
import java.io.IOException;
@ -66,7 +65,7 @@ public class DSavePlayer {
Player player = plugin.getServer().getPlayer(playerName);
boolean offline = false;
if (player == null) {
player = OfflinePlayerUtil.getOfflinePlayer(playerName, UUID.fromString(uuid), oldLocation);
player = PlayerUtil.getOfflinePlayer(playerName, UUID.fromString(uuid), oldLocation);
offline = true;
}
if (player == null) {
@ -96,7 +95,7 @@ public class DSavePlayer {
}
if ( !offline && oldLocation.getWorld() != null) {
MiscUtil.secureTeleport(player, oldLocation);
PlayerUtil.secureTeleport(player, oldLocation);
}
} catch (NullPointerException exception) {

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.requirement;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
import org.bukkit.entity.Player;
@ -47,7 +47,7 @@ public class FeeRequirement extends Requirement {
}
plugin.getEconomyProvider().withdrawPlayer(player, fee);
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.REQUIREMENT_FEE, plugin.getEconomyProvider().format(fee)));
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.REQUIREMENT_FEE, plugin.getEconomyProvider().format(fee)));
}
@Override

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.reward;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
import org.bukkit.entity.Player;
@ -41,7 +41,7 @@ public class MoneyReward extends Reward {
}
plugin.getEconomyProvider().depositPlayer(player, money);
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.REWARD_MONEY, plugin.getEconomyProvider().format(money)));
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.REWARD_MONEY, plugin.getEconomyProvider().format(money)));
}
@Override

View File

@ -1,7 +1,7 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
@ -43,7 +43,7 @@ public class CheckpointSign extends DSign {
for (DPlayer dplayer : DPlayer.getByWorld(getGameWorld().getWorld())) {
dplayer.setCheckpoint(getSign().getLocation());
MessageUtil.sendMessage(dplayer.getPlayer(), plugin.getDMessages().getMessage(Messages.PLAYER_CHECKPOINT_REACHED));
MessageUtil.sendMessage(dplayer.getPlayer(), plugin.getMessageConfig().getMessage(Messages.PLAYER_CHECKPOINT_REACHED));
}
remove();
@ -60,7 +60,7 @@ public class CheckpointSign extends DSign {
if ( !done.contains(dplayer)) {
done.add(dplayer);
dplayer.setCheckpoint(getSign().getLocation());
MessageUtil.sendMessage(player, plugin.getDMessages().getMessage(Messages.PLAYER_CHECKPOINT_REACHED));
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(Messages.PLAYER_CHECKPOINT_REACHED));
}
}

View File

@ -2,6 +2,7 @@ package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.task.SignUpdateTask;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
import io.github.dre2n.dungeonsxl.util.NumberUtil;
@ -60,7 +61,9 @@ public class InteractSign extends DSign {
}
getSign().setLine(1, id + "");
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new UpdateTask(), 2);
new SignUpdateTask(getSign()).runTaskLater(plugin, 2L);
return true;
}
@ -89,15 +92,4 @@ public class InteractSign extends DSign {
return type;
}
public class UpdateTask implements Runnable {
public UpdateTask() {
}
@Override
public void run() {
getSign().update();
}
}
}

View File

@ -1,19 +1,12 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.mob.DMob;
import io.github.dre2n.dungeonsxl.mob.DMobType;
import io.github.dre2n.dungeonsxl.task.MobSpawnTask;
import io.github.dre2n.dungeonsxl.util.NumberUtil;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Sign;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitTask;
public class MobSign extends DSign {
@ -26,12 +19,117 @@ public class MobSign extends DSign {
private int amount = 1;
private boolean initialized;
private boolean active;
private int taskId = -1;
private BukkitTask task;
public MobSign(Sign sign, GameWorld gameWorld) {
super(sign, gameWorld);
}
/**
* @return the mob
*/
public String getMob() {
return mob;
}
/**
* @param mob
* the mob to set
*/
public void setMob(String mob) {
this.mob = mob;
}
/**
* @return the maxinterval
*/
public int getMaxinterval() {
return maxinterval;
}
/**
* @param maxinterval
* the maxinterval to set
*/
public void setMaxinterval(int maxinterval) {
this.maxinterval = maxinterval;
}
/**
* @return the interval
*/
public int getInterval() {
return interval;
}
/**
* @param interval
* the interval to set
*/
public void setInterval(int interval) {
this.interval = interval;
}
/**
* @return the amount
*/
public int getAmount() {
return amount;
}
/**
* @param amount
* the amount to set
*/
public void setAmount(int amount) {
this.amount = amount;
}
/**
* @return the initialized
*/
public boolean isInitialized() {
return initialized;
}
/**
* @param initialized
* the initialized to set
*/
public void setInitialized(boolean initialized) {
this.initialized = initialized;
}
/**
* @return the active
*/
public boolean isActive() {
return active;
}
/**
* @param active
* the active to set
*/
public void setActive(boolean active) {
this.active = active;
}
/**
* @return the task
*/
public BukkitTask getTask() {
return task;
}
/**
* @param task
* the task to set
*/
public void setTask(BukkitTask task) {
this.task = task;
}
@Override
public boolean check() {
String lines[] = getSign().getLines();
@ -77,9 +175,7 @@ public class MobSign extends DSign {
return;
}
MobSpawnScheduler scheduler = new MobSpawnScheduler(this);
taskId = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, scheduler, 0L, 20L);
task = new MobSpawnTask(this).runTaskTimer(plugin, 0L, 20L);
active = true;
}
@ -100,72 +196,9 @@ public class MobSign extends DSign {
return;
}
if (taskId != -1) {
plugin.getServer().getScheduler().cancelTask(taskId);
taskId = -1;
}
}
public class MobSpawnScheduler implements Runnable {
private MobSign sign;
public MobSpawnScheduler(MobSign sign) {
this.sign = sign;
}
@SuppressWarnings("deprecation")
@Override
public void run() {
if (sign.interval <= 0) {
World world = sign.getSign().getWorld();
GameWorld gameWorld = GameWorld.getByWorld(world);
if (gameWorld != null) {
Location spawnLoc = sign.getSign().getLocation().add(0.5, 0, 0.5);
// Check normal mobs
if (EntityType.fromName(sign.mob) != null) {
if (EntityType.fromName(sign.mob).isAlive()) {
LivingEntity entity = (LivingEntity) world.spawnEntity(spawnLoc, EntityType.fromName(sign.mob));
// Add Bow to normal Skeletons
if (entity.getType() == EntityType.SKELETON) {
Skeleton skeleton = (Skeleton) entity;
if (skeleton.getSkeletonType() == SkeletonType.NORMAL) {
skeleton.getEquipment().setItemInHand(new ItemStack(Material.BOW));
}
}
// Disable Despawning
entity.setRemoveWhenFarAway(false);
new DMob(entity, sign.getGameWorld(), null);
}
}
// Check custom mobs
DMobType mobType = DMobType.getByName(sign.mob, gameWorld.getConfig().getMobTypes());
if (mobType != null) {
mobType.spawn(GameWorld.getByWorld(world), spawnLoc);
}
// Set the amount
if (amount != -1) {
if (amount > 1) {
amount--;
} else {
killTask();
sign.remove();
}
}
sign.interval = sign.maxinterval;
} else {
sign.killTask();
}
}
sign.interval--;
if (task != null) {
task.cancel();
task = null;
}
}

View File

@ -1,19 +1,18 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.mob.DMob;
import io.github.dre2n.dungeonsxl.task.MythicMobSpawnTask;
import io.github.dre2n.dungeonsxl.util.NumberUtil;
import java.util.ArrayList;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Sign;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask;
public class MythicMobsSign extends DSign {
@ -26,8 +25,8 @@ public class MythicMobsSign extends DSign {
private int amount = 1;
private boolean initialized;
private boolean active;
private int taskId = -1;
private Location spawnLoc;
private BukkitTask task;
private Location spawnLocation;
private LivingEntity mythicMob;
private ArrayList<Entity> mythicMobs = new ArrayList<Entity>();
@ -35,6 +34,156 @@ public class MythicMobsSign extends DSign {
super(sign, gameWorld);
}
/**
* @return the mob
*/
public String getMob() {
return mob;
}
/**
* @param mob
* the mob to set
*/
public void setMob(String mob) {
this.mob = mob;
}
/**
* @return the maxinterval
*/
public int getMaxinterval() {
return maxinterval;
}
/**
* @param maxinterval
* the maxinterval to set
*/
public void setMaxinterval(int maxinterval) {
this.maxinterval = maxinterval;
}
/**
* @return the interval
*/
public int getInterval() {
return interval;
}
/**
* @param interval
* the interval to set
*/
public void setInterval(int interval) {
this.interval = interval;
}
/**
* @return the amount
*/
public int getAmount() {
return amount;
}
/**
* @param amount
* the amount to set
*/
public void setAmount(int amount) {
this.amount = amount;
}
/**
* @return the initialized
*/
public boolean isInitialized() {
return initialized;
}
/**
* @param initialized
* the initialized to set
*/
public void setInitialized(boolean initialized) {
this.initialized = initialized;
}
/**
* @return the active
*/
public boolean isActive() {
return active;
}
/**
* @param active
* the active to set
*/
public void setActive(boolean active) {
this.active = active;
}
/**
* @return the spawnLocation
*/
public Location getSpawnLocation() {
return spawnLocation;
}
/**
* @param spawnLocation
* the spawnLocation to set
*/
public void setSpawnLocation(Location spawnLocation) {
this.spawnLocation = spawnLocation;
}
/**
* @return the mythicMob
*/
public LivingEntity getMythicMob() {
return mythicMob;
}
/**
* @param mythicMob
* the mythicMob to set
*/
public void setMythicMob(LivingEntity mythicMob) {
this.mythicMob = mythicMob;
}
/**
* @return the mythicMobs
*/
public ArrayList<Entity> getMythicMobs() {
return mythicMobs;
}
/**
* @param mythicMobs
* the mythicMobs to set
*/
public void setMythicMobs(ArrayList<Entity> mythicMobs) {
this.mythicMobs = mythicMobs;
}
/**
* @return the task
*/
public BukkitTask getTask() {
return task;
}
/**
* @param task
* the task to set
*/
public void setTask(BukkitTask task) {
this.task = task;
}
@Override
public boolean check() {
String lines[] = getSign().getLines();
@ -63,9 +212,9 @@ public class MythicMobsSign extends DSign {
if (mob != null) {
String[] attributes = lines[2].split(",");
if (attributes.length == 2) {
this.mob = mob;
maxinterval = NumberUtil.parseInt(attributes[0]);
amount = NumberUtil.parseInt(attributes[1]);
this.setMob(mob);
setMaxinterval(NumberUtil.parseInt(attributes[0]));
setAmount(NumberUtil.parseInt(attributes[1]));
}
}
}
@ -80,9 +229,7 @@ public class MythicMobsSign extends DSign {
return;
}
MobSpawnScheduler scheduler = new MobSpawnScheduler(this);
taskId = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, scheduler, 0L, 20L);
task = new MythicMobSpawnTask(this).runTaskTimer(plugin, 0L, 20L);
active = true;
}
@ -94,7 +241,7 @@ public class MythicMobsSign extends DSign {
}
killTask();
interval = 0;
setInterval(0);
active = false;
}
@ -103,64 +250,18 @@ public class MythicMobsSign extends DSign {
return;
}
if (taskId != -1) {
plugin.getServer().getScheduler().cancelTask(taskId);
taskId = -1;
if (task != null) {
task.cancel();
task = null;
}
}
public class MobSpawnScheduler implements Runnable {
private MythicMobsSign sign;
public MobSpawnScheduler(MythicMobsSign sign) {
this.sign = sign;
}
@Override
public void run() {
if (sign.interval <= 0) {
World world = sign.getSign().getWorld();
GameWorld gameWorld = GameWorld.getByWorld(world);
if (gameWorld != null) {
spawnLoc = sign.getSign().getLocation().add(0.5, 0, 0.5);
double x = spawnLoc.getX();
double y = spawnLoc.getY();
double z = spawnLoc.getZ();
String command = "mm mobs spawn " + mob + " " + amount + " DXL_Game_" + gameWorld.getId() + "," + x + "," + y + "," + z;
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), command);
setMythicMobs();
if (mythicMob != null) {
new DMob(mythicMob, sign.getGameWorld(), null, mob);
}
// Set the amount
if (amount != -1) {
if (amount > 1) {
amount--;
} else {
killTask();
sign.remove();
}
}
sign.interval = sign.maxinterval;
} else {
sign.killTask();
}
}
sign.interval--;
}
}
private void setMythicMobs() {
for (Entity entity : spawnLoc.getChunk().getEntities()) {
if (entity.getLocation().getX() >= spawnLoc.getX() - 1 && entity.getLocation().getX() <= spawnLoc.getX() + 1 && entity.getLocation().getY() >= spawnLoc.getY() - 1
&& entity.getLocation().getY() <= spawnLoc.getY() + 1 && entity.getLocation().getZ() >= spawnLoc.getZ() - 1 && entity.getLocation().getZ() <= spawnLoc.getZ() + 1
public void setMythicMobs() {
for (Entity entity : spawnLocation.getChunk().getEntities()) {
if (entity.getLocation().getX() >= spawnLocation.getX() - 1 && entity.getLocation().getX() <= spawnLocation.getX() + 1 && entity.getLocation().getY() >= spawnLocation.getY() - 1
&& entity.getLocation().getY() <= spawnLocation.getY() + 1 && entity.getLocation().getZ() >= spawnLocation.getZ() - 1 && entity.getLocation().getZ() <= spawnLocation.getZ() + 1
&& !mythicMobs.contains(entity) && entity.isCustomNameVisible() && !(entity instanceof Player)) {
mythicMob = (LivingEntity) entity;
setMythicMob((LivingEntity) entity);
mythicMobs.add(entity);
return;
}

View File

@ -1,7 +1,7 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.file.DMessages.Messages;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
@ -68,11 +68,11 @@ public class ReadySign extends DSign {
if (getGameWorld().getSignClass().isEmpty() || dPlayer.getDClass() != null) {
dPlayer.ready();
MessageUtil.sendMessage(dPlayer.getPlayer(), plugin.getDMessages().getMessage(Messages.PLAYER_READY));
MessageUtil.sendMessage(dPlayer.getPlayer(), plugin.getMessageConfig().getMessage(Messages.PLAYER_READY));
return;
} else {
MessageUtil.sendMessage(dPlayer.getPlayer(), plugin.getDMessages().getMessage(Messages.ERROR_READY));
MessageUtil.sendMessage(dPlayer.getPlayer(), plugin.getMessageConfig().getMessage(Messages.ERROR_READY));
}
}

View File

@ -1,12 +1,13 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.task.DelayedPowerTask;
import io.github.dre2n.dungeonsxl.util.NumberUtil;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.scheduler.BukkitTask;
public class RedstoneSign extends DSign {
@ -15,16 +16,151 @@ public class RedstoneSign extends DSign {
// Variables
private boolean initialized;
private boolean active;
private int enableTaskId = -1;
private int disableTaskId = -1;
private BukkitTask enableTask;
private BukkitTask disableTask;
private Block block;
private long delay = 0;
private long offDelay = 0;
private int repeat = 1;
private int repeatsToDo = 1;
public RedstoneSign(Sign sign, GameWorld gworld) {
super(sign, gworld);
public RedstoneSign(Sign sign, GameWorld gameWorld) {
super(sign, gameWorld);
}
/**
* @return the initialized
*/
public boolean isInitialized() {
return initialized;
}
/**
* @param initialized
* the initialized to set
*/
public void setInitialized(boolean initialized) {
this.initialized = initialized;
}
/**
* @return the active
*/
public boolean isActive() {
return active;
}
/**
* @param active
* the active to set
*/
public void setActive(boolean active) {
this.active = active;
}
/**
* @return the enableTask
*/
public BukkitTask getEnableTask() {
return enableTask;
}
/**
* @param enableTask
* the enableTask to set
*/
public void setEnableTask(BukkitTask enableTask) {
this.enableTask = enableTask;
}
/**
* @return the disableTask
*/
public BukkitTask getDisableTask() {
return disableTask;
}
/**
* @param disableTask
* the disableTask to set
*/
public void setDisableTask(BukkitTask disableTask) {
this.disableTask = disableTask;
}
/**
* @return the block
*/
public Block getBlock() {
return block;
}
/**
* @param block
* the block to set
*/
public void setBlock(Block block) {
this.block = block;
}
/**
* @return the delay
*/
public long getDelay() {
return delay;
}
/**
* @param delay
* the delay to set
*/
public void setDelay(long delay) {
this.delay = delay;
}
/**
* @return the offDelay
*/
public long getOffDelay() {
return offDelay;
}
/**
* @param offDelay
* the offDelay to set
*/
public void setOffDelay(long offDelay) {
this.offDelay = offDelay;
}
/**
* @return the repeat
*/
public int getRepeat() {
return repeat;
}
/**
* @param repeat
* the repeat to set
*/
public void setRepeat(int repeat) {
this.repeat = repeat;
}
/**
* @return the repeatsToDo
*/
public int getRepeatsToDo() {
return repeatsToDo;
}
/**
* @param repeatsToDo
* the repeatsToDo to set
*/
public void setRepeatsToDo(int repeatsToDo) {
this.repeatsToDo = repeatsToDo;
}
@Override
@ -74,11 +210,11 @@ public class RedstoneSign extends DSign {
}
if (delay > 0) {
enableTaskId = DungeonsXL.getPlugin().getServer().getScheduler().scheduleSyncRepeatingTask(DungeonsXL.getPlugin(), new DelayedPower(true), delay, delay + offDelay);
enableTask = new DelayedPowerTask(this, true).runTaskTimer(plugin, delay, delay + offDelay);
if (repeat != 1) {
repeatsToDo = repeat;
disableTaskId = DungeonsXL.getPlugin().getServer().getScheduler().scheduleSyncRepeatingTask(DungeonsXL.getPlugin(), new DelayedPower(false), delay + offDelay, delay + offDelay);
disableTask = new DelayedPowerTask(this, false).runTaskTimer(plugin, delay + offDelay, delay + offDelay);
}
} else {
@ -96,10 +232,8 @@ public class RedstoneSign extends DSign {
unpower();
disableTask(enableTaskId);
disableTask(disableTaskId);
enableTaskId = -1;
disableTaskId = -1;
enableTask.cancel();
disableTask.cancel();
active = false;
}
@ -112,50 +246,9 @@ public class RedstoneSign extends DSign {
block.setType(Material.AIR);
}
public void disableTask(int taskId) {
if (taskId == -1) {
return;
}
if (DungeonsXL.getPlugin().getServer().getScheduler().isCurrentlyRunning(taskId) || DungeonsXL.getPlugin().getServer().getScheduler().isQueued(taskId)) {
DungeonsXL.getPlugin().getServer().getScheduler().cancelTask(taskId);
}
}
@Override
public DSignType getType() {
return type;
}
public class DelayedPower implements Runnable {
private final boolean enable;
public DelayedPower(boolean enable) {
this.enable = enable;
}
@Override
public void run() {
if (GameWorld.getByWorld(block.getWorld()) == null) {
disableTask(enableTaskId);
disableTask(disableTaskId);
return;
}
if (enable) {
power();
if (repeatsToDo == 1) {
disableTask(enableTaskId);
enableTaskId = -1;
}
} else {
unpower();
if (repeatsToDo == 1) {
disableTask(disableTaskId);
disableTaskId = -1;
}
repeatsToDo--;
}
}
}
}

View File

@ -2,6 +2,7 @@ package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.task.SignUpdateTask;
import io.github.dre2n.dungeonsxl.trigger.SignTrigger;
import io.github.dre2n.dungeonsxl.util.NumberUtil;
@ -62,7 +63,9 @@ public class TriggerSign extends DSign {
}
getSign().setLine(1, id + "");
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new UpdateTask(), 2);
new SignUpdateTask(getSign()).runTaskLater(plugin, 2L);
return true;
}
@ -103,15 +106,4 @@ public class TriggerSign extends DSign {
return type;
}
public class UpdateTask implements Runnable {
public UpdateTask() {
}
@Override
public void run() {
getSign().update();
}
}
}

View File

@ -0,0 +1,38 @@
package io.github.dre2n.dungeonsxl.task;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.sign.RedstoneSign;
import org.bukkit.scheduler.BukkitRunnable;
public class DelayedPowerTask extends BukkitRunnable {
private RedstoneSign sign;
private boolean enable;
public DelayedPowerTask(RedstoneSign sign, boolean enable) {
this.sign = sign;
this.enable = enable;
}
@Override
public void run() {
if (GameWorld.getByWorld(sign.getBlock().getWorld()) == null) {
sign.getEnableTask().cancel();
sign.getDisableTask().cancel();
return;
}
if (enable) {
sign.power();
if (sign.getRepeatsToDo() == 1) {
sign.getEnableTask().cancel();
}
} else {
sign.unpower();
if (sign.getRepeatsToDo() == 1) {
sign.getDisableTask().cancel();
}
sign.setRepeatsToDo(sign.getRepeatsToDo() - 1);
}
}
}

View File

@ -0,0 +1,24 @@
package io.github.dre2n.dungeonsxl.task;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import org.bukkit.scheduler.BukkitRunnable;
public class LazyUpdateTask extends BukkitRunnable {
static DungeonsXL plugin = DungeonsXL.getPlugin();
@Override
public void run() {
for (GameWorld gameWorld : plugin.getGameWorlds()) {
gameWorld.update();
}
for (DPlayer dPlayer : plugin.getDPlayers()) {
dPlayer.update(true);
}
}
}

View File

@ -0,0 +1,81 @@
package io.github.dre2n.dungeonsxl.task;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.mob.DMob;
import io.github.dre2n.dungeonsxl.mob.DMobType;
import io.github.dre2n.dungeonsxl.sign.MobSign;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
public class MobSpawnTask extends BukkitRunnable {
private MobSign sign;
public MobSpawnTask(MobSign sign) {
this.sign = sign;
}
@SuppressWarnings("deprecation")
@Override
public void run() {
if (sign.getInterval() <= 0) {
World world = sign.getSign().getWorld();
GameWorld gameWorld = GameWorld.getByWorld(world);
if (gameWorld != null) {
Location spawnLoc = sign.getSign().getLocation().add(0.5, 0, 0.5);
// Check normal mobs
if (EntityType.fromName(sign.getMob()) != null) {
if (EntityType.fromName(sign.getMob()).isAlive()) {
LivingEntity entity = (LivingEntity) world.spawnEntity(spawnLoc, EntityType.fromName(sign.getMob()));
// Add Bow to normal Skeletons
if (entity.getType() == EntityType.SKELETON) {
Skeleton skeleton = (Skeleton) entity;
if (skeleton.getSkeletonType() == SkeletonType.NORMAL) {
skeleton.getEquipment().setItemInHand(new ItemStack(Material.BOW));
}
}
// Disable Despawning
entity.setRemoveWhenFarAway(false);
new DMob(entity, sign.getGameWorld(), null);
}
}
// Check custom mobs
DMobType mobType = DMobType.getByName(sign.getMob(), gameWorld.getConfig().getMobTypes());
if (mobType != null) {
mobType.spawn(GameWorld.getByWorld(world), spawnLoc);
}
// Set the amount
if (sign.getAmount() != -1) {
if (sign.getAmount() > 1) {
sign.setAmount(sign.getAmount() - 1);
} else {
sign.killTask();
sign.remove();
}
}
sign.setInterval(sign.getMaxinterval());
} else {
sign.killTask();
}
}
sign.setInterval(sign.getInterval() - 1);
}
}

View File

@ -0,0 +1,57 @@
package io.github.dre2n.dungeonsxl.task;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.mob.DMob;
import io.github.dre2n.dungeonsxl.sign.MythicMobsSign;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.scheduler.BukkitRunnable;
public class MythicMobSpawnTask extends BukkitRunnable {
private MythicMobsSign sign;
public MythicMobSpawnTask(MythicMobsSign sign) {
this.sign = sign;
}
@Override
public void run() {
if (sign.getInterval() <= 0) {
World world = sign.getSign().getWorld();
GameWorld gameWorld = GameWorld.getByWorld(world);
if (gameWorld != null) {
sign.setSpawnLocation(sign.getSign().getLocation().add(0.5, 0, 0.5));
double x = sign.getSpawnLocation().getX();
double y = sign.getSpawnLocation().getY();
double z = sign.getSpawnLocation().getZ();
String command = "mm mobs spawn " + sign.getMob() + " " + sign.getAmount() + " DXL_Game_" + gameWorld.getId() + "," + x + "," + y + "," + z;
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), command);
sign.setMythicMobs();
if (sign.getMythicMob() != null) {
new DMob(sign.getMythicMob(), sign.getGameWorld(), null, sign.getMob());
}
// Set the amount
if (sign.getAmount() != -1) {
if (sign.getAmount() > 1) {
sign.setAmount(sign.getAmount() - 1);
} else {
sign.killTask();
sign.remove();
}
}
sign.setInterval(sign.getMaxinterval());
} else {
sign.killTask();
}
}
sign.setInterval(sign.getInterval() - 1);
}
}

View File

@ -0,0 +1,27 @@
package io.github.dre2n.dungeonsxl.task;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.trigger.RedstoneTrigger;
import org.bukkit.block.Block;
import org.bukkit.scheduler.BukkitRunnable;
public class RedstoneEventTask extends BukkitRunnable {
private final Block block;
public RedstoneEventTask(final Block block) {
this.block = block;
}
@Override
public void run() {
for (GameWorld gameWorld : DungeonsXL.getPlugin().getGameWorlds()) {
if (block.getWorld() == gameWorld.getWorld()) {
RedstoneTrigger.updateAll(gameWorld);
}
}
}
}

View File

@ -0,0 +1,41 @@
package io.github.dre2n.dungeonsxl.task;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.playerutil.PlayerUtil;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class RespawnTask extends BukkitRunnable {
private Player player;
private Location location;
public RespawnTask(Player player, Location location) {
this.location = location;
this.player = player;
}
@Override
public void run() {
if (player.getLocation().distance(location) > 2) {
PlayerUtil.secureTeleport(player, location);
}
DPlayer dPlayer = DPlayer.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);
}
}
}

View File

@ -0,0 +1,19 @@
package io.github.dre2n.dungeonsxl.task;
import org.bukkit.block.Sign;
import org.bukkit.scheduler.BukkitRunnable;
public class SignUpdateTask extends BukkitRunnable {
private Sign sign;
public SignUpdateTask(Sign sign) {
this.sign = sign;
}
@Override
public void run() {
sign.update();
}
}

View File

@ -0,0 +1,17 @@
package io.github.dre2n.dungeonsxl.task;
import org.bukkit.scheduler.BukkitRunnable;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.player.DPlayer;
public class UpdateTask extends BukkitRunnable {
@Override
public void run() {
for (DPlayer dPlayer : DungeonsXL.getPlugin().getDPlayers()) {
dPlayer.update(false);
}
}
}

View File

@ -0,0 +1,31 @@
package io.github.dre2n.dungeonsxl.task;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.dungeon.EditWorld;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import org.bukkit.scheduler.BukkitRunnable;
public class WorldUnloadTask extends BukkitRunnable {
static DungeonsXL plugin = DungeonsXL.getPlugin();
@Override
public void run() {
for (GameWorld gameWorld : plugin.getGameWorlds()) {
if (gameWorld.getWorld().getPlayers().isEmpty()) {
if (DPlayer.getByWorld(gameWorld.getWorld()).isEmpty()) {
gameWorld.delete();
}
}
}
for (EditWorld editWorld : plugin.getEditWorlds()) {
if (editWorld.getWorld().getPlayers().isEmpty()) {
editWorld.delete();
}
}
}
}

View File

@ -1,95 +0,0 @@
package io.github.dre2n.dungeonsxl.util;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
public class MiscUtil {
public static DungeonsXL p = DungeonsXL.getPlugin();
public static void convertOldSigns() {
File file = new File(p.getDataFolder(), "/dungeons/");
if (file.exists()) {
for (File dungeonFolder : file.listFiles()) {
if (dungeonFolder.isDirectory()) {
FileUtil.copyDirectory(dungeonFolder, new File("DXL_TMP"));
World world = p.getServer().createWorld(WorldCreator.name("DXL_TMP"));
// World
try {
ObjectInputStream os = new ObjectInputStream(new FileInputStream(new File(p.getDataFolder(), "/dungeons/" + dungeonFolder.getName() + "/DXLData.data")));
int length = os.readInt();
for (int i = 0; i < length; i++) {
int x = os.readInt();
int y = os.readInt();
int z = os.readInt();
Block block = world.getBlockAt(x, y, z);
if (block.getState() instanceof Sign) {
Sign sign = (Sign) block.getState();
if (sign.getLine(0).equalsIgnoreCase("[dxl]")) {
sign.setLine(0, "[" + sign.getLine(1) + "]");
sign.setLine(1, sign.getLine(2));
sign.setLine(2, sign.getLine(3));
sign.update();
if (sign.getLine(0).equalsIgnoreCase("[mob]")) {
String[] splitted = sign.getLine(2).split(",");
if (splitted.length >= 3) {
sign.setLine(2, splitted[0] + "," + splitted[1]);
sign.setLine(3, "D " + splitted[2]);
}
}
if (sign.getLine(0).equalsIgnoreCase("[msg]") || sign.getLine(0).equalsIgnoreCase("[soundmsg]")) {
sign.setLine(3, "D " + sign.getLine(2));
sign.setLine(2, "");
}
if (sign.getLine(0).equalsIgnoreCase("[checkpoint]")) {
sign.setLine(3, "D " + sign.getLine(1));
sign.setLine(1, "");
}
sign.update();
}
}
}
os.close();
p.getServer().unloadWorld(world, true);
FileUtil.copyDirectory(new File("DXL_TMP"), dungeonFolder);
FileUtil.removeDirectory(new File("DXL_TMP"));
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
public static void secureTeleport(Player player, Location location) {
if (player.isInsideVehicle()) {
player.leaveVehicle();
}
player.teleport(location);
}
}

View File

@ -1,66 +0,0 @@
package io.github.dre2n.dungeonsxl.util.offlineplayerutil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.util.VersionUtil;
import io.github.dre2n.dungeonsxl.util.VersionUtil.Internals;
import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.entity.Player;
public class OfflinePlayerUtil {
public static Player getOfflinePlayer(String player, UUID uuid) {
VersionUtil versions = DungeonsXL.getPlugin().getVersion();
if (versions.getInternals() == Internals.v1_9_R1) {
return v1_9_R1.getOfflinePlayer(player, uuid);
} else if (versions.getInternals() == Internals.v1_8_R3) {
return v1_8_R3.getOfflinePlayer(player, uuid);
} else if (versions.getInternals() == Internals.v1_8_R2) {
return v1_8_R2.getOfflinePlayer(player, uuid);
} else if (versions.getInternals() == Internals.v1_8_R1) {
return v1_8_R1.getOfflinePlayer(player, uuid);
} else if (versions.getInternals() == Internals.v1_7_R4) {
return v1_7_R4.getOfflinePlayer(player, uuid);
} else if (versions.getInternals() == Internals.v1_7_R3) {
return v1_7_R3.getOfflinePlayer(player, uuid);
} else {
return null;
}
}
public static Player getOfflinePlayer(String player, UUID uuid, Location location) {
VersionUtil versions = DungeonsXL.getPlugin().getVersion();
if (versions.getInternals() == Internals.v1_9_R1) {
return v1_9_R1.getOfflinePlayer(player, uuid, location);
} else if (versions.getInternals() == Internals.v1_8_R3) {
return v1_8_R3.getOfflinePlayer(player, uuid, location);
} else if (versions.getInternals() == Internals.v1_8_R2) {
return v1_8_R2.getOfflinePlayer(player, uuid, location);
} else if (versions.getInternals() == Internals.v1_8_R1) {
return v1_8_R1.getOfflinePlayer(player, uuid, location);
} else if (versions.getInternals() == Internals.v1_7_R4) {
return v1_7_R4.getOfflinePlayer(player, uuid, location);
} else if (versions.getInternals() == Internals.v1_7_R3) {
return v1_7_R3.getOfflinePlayer(player, uuid, location);
} else {
return null;
}
}
}

View File

@ -0,0 +1,87 @@
package io.github.dre2n.dungeonsxl.util.playerutil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.util.VersionUtil;
import io.github.dre2n.dungeonsxl.util.VersionUtil.Internals;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
public class PlayerUtil {
public static Player getOfflinePlayer(String name) {
@SuppressWarnings("deprecation")
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(name);
return getOfflinePlayer(name, offlinePlayer.getUniqueId());
}
public static Player getOfflinePlayer(UUID uuid) {
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(uuid);
return getOfflinePlayer(offlinePlayer.getName(), uuid);
}
public static Player getOfflinePlayer(String name, UUID uuid) {
VersionUtil versions = DungeonsXL.getPlugin().getVersion();
if (versions.getInternals() == Internals.v1_9_R1) {
return v1_9_R1.getOfflinePlayer(name, uuid);
} else if (versions.getInternals() == Internals.v1_8_R3) {
return v1_8_R3.getOfflinePlayer(name, uuid);
} else if (versions.getInternals() == Internals.v1_8_R2) {
return v1_8_R2.getOfflinePlayer(name, uuid);
} else if (versions.getInternals() == Internals.v1_8_R1) {
return v1_8_R1.getOfflinePlayer(name, uuid);
} else if (versions.getInternals() == Internals.v1_7_R4) {
return v1_7_R4.getOfflinePlayer(name, uuid);
} else if (versions.getInternals() == Internals.v1_7_R3) {
return v1_7_R3.getOfflinePlayer(name, uuid);
} else {
return null;
}
}
public static Player getOfflinePlayer(String name, UUID uuid, Location location) {
VersionUtil versions = DungeonsXL.getPlugin().getVersion();
if (versions.getInternals() == Internals.v1_9_R1) {
return v1_9_R1.getOfflinePlayer(name, uuid, location);
} else if (versions.getInternals() == Internals.v1_8_R3) {
return v1_8_R3.getOfflinePlayer(name, uuid, location);
} else if (versions.getInternals() == Internals.v1_8_R2) {
return v1_8_R2.getOfflinePlayer(name, uuid, location);
} else if (versions.getInternals() == Internals.v1_8_R1) {
return v1_8_R1.getOfflinePlayer(name, uuid, location);
} else if (versions.getInternals() == Internals.v1_7_R4) {
return v1_7_R4.getOfflinePlayer(name, uuid, location);
} else if (versions.getInternals() == Internals.v1_7_R3) {
return v1_7_R3.getOfflinePlayer(name, uuid, location);
} else {
return null;
}
}
public static void secureTeleport(Player player, Location location) {
if (player.isInsideVehicle()) {
player.leaveVehicle();
}
player.teleport(location);
}
}

View File

@ -1,4 +1,4 @@
package io.github.dre2n.dungeonsxl.util.offlineplayerutil;
package io.github.dre2n.dungeonsxl.util.playerutil;
import java.io.File;
import java.util.UUID;
@ -16,18 +16,18 @@ import org.bukkit.entity.Player;
class v1_7_R3 {
static Player getOfflinePlayer(String player, UUID uuid) {
static Player getOfflinePlayer(String name, UUID uuid) {
Player pplayer = null;
try {
File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
File playerFolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
for (File playerfile : playerfolder.listFiles()) {
String filename = playerfile.getName();
String playername = filename.substring(0, filename.length() - 4);
for (File playerFile : playerFolder.listFiles()) {
String fileName = playerFile.getName();
String playerName = fileName.substring(0, fileName.length() - 4);
GameProfile profile = new GameProfile(uuid, playername);
GameProfile profile = new GameProfile(uuid, playerName);
if (playername.trim().equalsIgnoreCase(player)) {
if (playerName.trim().equalsIgnoreCase(name)) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), profile, new PlayerInteractManager(server.getWorldServer(0)));
Player target = entity == null ? null : (Player) entity.getBukkitEntity();
@ -43,18 +43,18 @@ class v1_7_R3 {
return pplayer;
}
static Player getOfflinePlayer(String player, UUID uuid, Location location) {
static Player getOfflinePlayer(String name, UUID uuid, Location location) {
Player pplayer = null;
try {
File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
File playerFolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
for (File playerfile : playerfolder.listFiles()) {
String filename = playerfile.getName();
String playername = filename.substring(0, filename.length() - 4);
for (File playerFile : playerFolder.listFiles()) {
String fileName = playerFile.getName();
String playerName = fileName.substring(0, fileName.length() - 4);
GameProfile profile = new GameProfile(uuid, playername);
GameProfile profile = new GameProfile(uuid, playerName);
if (playername.trim().equalsIgnoreCase(player)) {
if (playerName.trim().equalsIgnoreCase(name)) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), profile, new PlayerInteractManager(server.getWorldServer(0)));
entity.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());

View File

@ -1,4 +1,4 @@
package io.github.dre2n.dungeonsxl.util.offlineplayerutil;
package io.github.dre2n.dungeonsxl.util.playerutil;
import java.io.File;
import java.util.UUID;
@ -16,18 +16,18 @@ import org.bukkit.entity.Player;
class v1_7_R4 {
static Player getOfflinePlayer(String player, UUID uuid) {
static Player getOfflinePlayer(String name, UUID uuid) {
Player pplayer = null;
try {
File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
File playerFolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
for (File playerfile : playerfolder.listFiles()) {
String filename = playerfile.getName();
String playername = filename.substring(0, filename.length() - 4);
for (File playerFile : playerFolder.listFiles()) {
String fileName = playerFile.getName();
String playerName = fileName.substring(0, fileName.length() - 4);
GameProfile profile = new GameProfile(uuid, playername);
GameProfile profile = new GameProfile(uuid, playerName);
if (playername.trim().equalsIgnoreCase(player)) {
if (playerName.trim().equalsIgnoreCase(name)) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), profile, new PlayerInteractManager(server.getWorldServer(0)));
Player target = entity == null ? null : (Player) entity.getBukkitEntity();
@ -43,18 +43,18 @@ class v1_7_R4 {
return pplayer;
}
static Player getOfflinePlayer(String player, UUID uuid, Location location) {
static Player getOfflinePlayer(String name, UUID uuid, Location location) {
Player pplayer = null;
try {
File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
File playerFolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
for (File playerfile : playerfolder.listFiles()) {
String filename = playerfile.getName();
String playername = filename.substring(0, filename.length() - 4);
for (File playerFile : playerFolder.listFiles()) {
String fileName = playerFile.getName();
String playerName = fileName.substring(0, fileName.length() - 4);
GameProfile profile = new GameProfile(uuid, playername);
GameProfile profile = new GameProfile(uuid, playerName);
if (playername.trim().equalsIgnoreCase(player)) {
if (playerName.trim().equalsIgnoreCase(name)) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), profile, new PlayerInteractManager(server.getWorldServer(0)));
entity.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());

View File

@ -1,4 +1,4 @@
package io.github.dre2n.dungeonsxl.util.offlineplayerutil;
package io.github.dre2n.dungeonsxl.util.playerutil;
import java.io.File;
import java.util.UUID;
@ -17,18 +17,18 @@ import com.mojang.authlib.GameProfile;
class v1_8_R1 {
static Player getOfflinePlayer(String player, UUID uuid) {
static Player getOfflinePlayer(String name, UUID uuid) {
Player pplayer = null;
try {
File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
File playerFolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
for (File playerfile : playerfolder.listFiles()) {
String filename = playerfile.getName();
String playername = filename.substring(0, filename.length() - 4);
for (File playerFile : playerFolder.listFiles()) {
String filename = playerFile.getName();
String playerName = filename.substring(0, filename.length() - 4);
GameProfile profile = new GameProfile(uuid, playername);
GameProfile profile = new GameProfile(uuid, playerName);
if (playername.trim().equalsIgnoreCase(player)) {
if (playerName.trim().equalsIgnoreCase(name)) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), profile, new PlayerInteractManager(server.getWorldServer(0)));
Player target = entity == null ? null : (Player) entity.getBukkitEntity();
@ -44,18 +44,18 @@ class v1_8_R1 {
return pplayer;
}
static Player getOfflinePlayer(String player, UUID uuid, Location location) {
static Player getOfflinePlayer(String name, UUID uuid, Location location) {
Player pplayer = null;
try {
File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
File playerFolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
for (File playerfile : playerfolder.listFiles()) {
String filename = playerfile.getName();
String playername = filename.substring(0, filename.length() - 4);
for (File playerFile : playerFolder.listFiles()) {
String filename = playerFile.getName();
String playerName = filename.substring(0, filename.length() - 4);
GameProfile profile = new GameProfile(uuid, playername);
GameProfile profile = new GameProfile(uuid, playerName);
if (playername.trim().equalsIgnoreCase(player)) {
if (playerName.trim().equalsIgnoreCase(name)) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), profile, new PlayerInteractManager(server.getWorldServer(0)));
entity.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());

View File

@ -1,4 +1,4 @@
package io.github.dre2n.dungeonsxl.util.offlineplayerutil;
package io.github.dre2n.dungeonsxl.util.playerutil;
import java.io.File;
import java.util.UUID;
@ -17,18 +17,18 @@ import com.mojang.authlib.GameProfile;
class v1_8_R2 {
static Player getOfflinePlayer(String player, UUID uuid) {
static Player getOfflinePlayer(String name, UUID uuid) {
Player pplayer = null;
try {
File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
File playerFolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
for (File playerfile : playerfolder.listFiles()) {
String filename = playerfile.getName();
String playername = filename.substring(0, filename.length() - 4);
for (File playerFile : playerFolder.listFiles()) {
String fileName = playerFile.getName();
String playerName = fileName.substring(0, fileName.length() - 4);
GameProfile profile = new GameProfile(uuid, playername);
GameProfile profile = new GameProfile(uuid, playerName);
if (playername.trim().equalsIgnoreCase(player)) {
if (playerName.trim().equalsIgnoreCase(name)) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), profile, new PlayerInteractManager(server.getWorldServer(0)));
Player target = entity == null ? null : (Player) entity.getBukkitEntity();
@ -44,18 +44,18 @@ class v1_8_R2 {
return pplayer;
}
static Player getOfflinePlayer(String player, UUID uuid, Location location) {
static Player getOfflinePlayer(String name, UUID uuid, Location location) {
Player pplayer = null;
try {
File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
File playerFolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
for (File playerfile : playerfolder.listFiles()) {
String filename = playerfile.getName();
String playername = filename.substring(0, filename.length() - 4);
for (File playerFile : playerFolder.listFiles()) {
String fileName = playerFile.getName();
String playerName = fileName.substring(0, fileName.length() - 4);
GameProfile profile = new GameProfile(uuid, playername);
GameProfile profile = new GameProfile(uuid, playerName);
if (playername.trim().equalsIgnoreCase(player)) {
if (playerName.trim().equalsIgnoreCase(name)) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), profile, new PlayerInteractManager(server.getWorldServer(0)));
entity.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());

View File

@ -1,4 +1,4 @@
package io.github.dre2n.dungeonsxl.util.offlineplayerutil;
package io.github.dre2n.dungeonsxl.util.playerutil;
import java.io.File;
import java.util.UUID;
@ -17,18 +17,18 @@ import com.mojang.authlib.GameProfile;
class v1_8_R3 {
static Player getOfflinePlayer(String player, UUID uuid) {
static Player getOfflinePlayer(String name, UUID uuid) {
Player pplayer = null;
try {
File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
File playerFolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
for (File playerfile : playerfolder.listFiles()) {
String filename = playerfile.getName();
String playername = filename.substring(0, filename.length() - 4);
for (File playerFile : playerFolder.listFiles()) {
String fileName = playerFile.getName();
String playerName = fileName.substring(0, fileName.length() - 4);
GameProfile profile = new GameProfile(uuid, playername);
GameProfile profile = new GameProfile(uuid, playerName);
if (playername.trim().equalsIgnoreCase(player)) {
if (playerName.trim().equalsIgnoreCase(name)) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), profile, new PlayerInteractManager(server.getWorldServer(0)));
Player target = entity == null ? null : (Player) entity.getBukkitEntity();
@ -44,18 +44,18 @@ class v1_8_R3 {
return pplayer;
}
static Player getOfflinePlayer(String player, UUID uuid, Location location) {
static Player getOfflinePlayer(String name, UUID uuid, Location location) {
Player pplayer = null;
try {
File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
File playerFolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
for (File playerfile : playerfolder.listFiles()) {
String filename = playerfile.getName();
String playername = filename.substring(0, filename.length() - 4);
for (File playerFile : playerFolder.listFiles()) {
String fileName = playerFile.getName();
String playerName = fileName.substring(0, fileName.length() - 4);
GameProfile profile = new GameProfile(uuid, playername);
GameProfile profile = new GameProfile(uuid, playerName);
if (playername.trim().equalsIgnoreCase(player)) {
if (playerName.trim().equalsIgnoreCase(name)) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), profile, new PlayerInteractManager(server.getWorldServer(0)));
entity.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());

View File

@ -1,4 +1,4 @@
package io.github.dre2n.dungeonsxl.util.offlineplayerutil;
package io.github.dre2n.dungeonsxl.util.playerutil;
import java.io.File;
import java.util.UUID;
@ -17,18 +17,18 @@ import com.mojang.authlib.GameProfile;
class v1_9_R1 {
static Player getOfflinePlayer(String player, UUID uuid) {
static Player getOfflinePlayer(String name, UUID uuid) {
Player pplayer = null;
try {
File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
File playerFolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
for (File playerfile : playerfolder.listFiles()) {
String filename = playerfile.getName();
String playername = filename.substring(0, filename.length() - 4);
for (File playerFile : playerFolder.listFiles()) {
String fileName = playerFile.getName();
String playerName = fileName.substring(0, fileName.length() - 4);
GameProfile profile = new GameProfile(uuid, playername);
GameProfile profile = new GameProfile(uuid, playerName);
if (playername.trim().equalsIgnoreCase(player)) {
if (playerName.trim().equalsIgnoreCase(name)) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), profile, new PlayerInteractManager(server.getWorldServer(0)));
Player target = entity == null ? null : (Player) entity.getBukkitEntity();
@ -44,18 +44,18 @@ class v1_9_R1 {
return pplayer;
}
static Player getOfflinePlayer(String player, UUID uuid, Location location) {
static Player getOfflinePlayer(String name, UUID uuid, Location location) {
Player pplayer = null;
try {
File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
File playerFolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
for (File playerfile : playerfolder.listFiles()) {
String filename = playerfile.getName();
String playername = filename.substring(0, filename.length() - 4);
for (File playerFile : playerFolder.listFiles()) {
String fileName = playerFile.getName();
String playerName = fileName.substring(0, fileName.length() - 4);
GameProfile profile = new GameProfile(uuid, playername);
GameProfile profile = new GameProfile(uuid, playerName);
if (playername.trim().equalsIgnoreCase(player)) {
if (playerName.trim().equalsIgnoreCase(name)) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), profile, new PlayerInteractManager(server.getWorldServer(0)));
entity.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());

View File

@ -22,6 +22,10 @@ permissions:
default: op
dxl.escape:
default: true
dxl.group:
default: op
dxl.group.admin:
default: op
dxl.help:
default: true
dxl.invite: