Game type API

This commit is contained in:
Daniel Saukel 2016-01-29 23:59:33 +01:00
parent f641c9d4c7
commit 7dc26d5805
78 changed files with 803 additions and 226 deletions

View File

@ -7,7 +7,8 @@ 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.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameTypes;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.global.DPortal;
import io.github.dre2n.dungeonsxl.global.GroupSign;
import io.github.dre2n.dungeonsxl.global.LeaveSign;
@ -20,8 +21,8 @@ import io.github.dre2n.dungeonsxl.listener.WorldListener;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.player.DSavePlayer;
import io.github.dre2n.dungeonsxl.requirement.Requirements;
import io.github.dre2n.dungeonsxl.reward.Rewards;
import io.github.dre2n.dungeonsxl.requirement.RequirementTypes;
import io.github.dre2n.dungeonsxl.reward.RewardTypes;
import io.github.dre2n.dungeonsxl.sign.DSigns;
import io.github.dre2n.dungeonsxl.task.LazyUpdateTask;
import io.github.dre2n.dungeonsxl.task.UpdateTask;
@ -49,6 +50,7 @@ import org.bukkit.scheduler.BukkitTask;
public class DungeonsXL extends JavaPlugin {
private static DungeonsXL plugin;
private Economy economyProvider;
private Permission permissionProvider;
@ -59,8 +61,9 @@ public class DungeonsXL extends JavaPlugin {
private DCommands dCommands;
private DSigns dSigns;
private Requirements requirements;
private Rewards rewards;
private GameTypes gameTypes;
private RequirementTypes requirementTypes;
private RewardTypes rewardTypes;
private Triggers triggers;
private Dungeons dungeons;
@ -94,8 +97,9 @@ public class DungeonsXL extends JavaPlugin {
loadMessageConfig(new File(plugin.getDataFolder(), "languages/" + mainConfig.getLanguage() + ".yml"));
loadVersionUtil();
loadDCommands();
loadRequirements();
loadRewards();
loadGameTypes();
loadRequirementTypes();
loadRewardTypes();
loadTriggers();
loadDSigns();
loadDungeons();
@ -135,8 +139,8 @@ public class DungeonsXL extends JavaPlugin {
messageConfig.save();
// DPlayer leaves World
for (DPlayer dplayer : dPlayers) {
dplayer.leave();
for (DPlayer dPlayer : dPlayers) {
dPlayer.leave();
}
// Delete all Data
@ -195,8 +199,8 @@ public class DungeonsXL extends JavaPlugin {
try {
configFile.save(file);
} catch (IOException e) {
e.printStackTrace();
} catch (IOException exception) {
exception.printStackTrace();
}
}
@ -377,31 +381,45 @@ public class DungeonsXL extends JavaPlugin {
}
/**
* @return the requirements
* @return the game types
*/
public Requirements getRequirements() {
return requirements;
public GameTypes getGameTypes() {
return gameTypes;
}
/**
* load / reload a new instance of Requirements
* load / reload a new instance of GameTypes
*/
public void loadRequirements() {
requirements = new Requirements();
public void loadGameTypes() {
gameTypes = new GameTypes();
}
/**
* @return the rewards
* @return the requirement types
*/
public Rewards getRewards() {
return rewards;
public RequirementTypes getRequirementTypes() {
return requirementTypes;
}
/**
* load / reload a new instance of Rewards
* load / reload a new instance of RequirementTypes
*/
public void loadRewards() {
rewards = new Rewards();
public void loadRequirementTypes() {
requirementTypes = new RequirementTypes();
}
/**
* @return the reward types
*/
public RewardTypes getRewardTypes() {
return rewardTypes;
}
/**
* load / reload a new instance of RewardTypes
*/
public void loadRewardTypes() {
rewardTypes = new RewardTypes();
}
/**

View File

@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
public abstract class DCommand {
static DungeonsXL plugin = DungeonsXL.getPlugin();
MessageConfig messageConfig = plugin.getMessageConfig();
static 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 GameCommand());
dCommands.add(new GroupCommand());
dCommands.add(new InviteCommand());
dCommands.add(new LeaveCommand());

View File

@ -0,0 +1,55 @@
package io.github.dre2n.dungeonsxl.command;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.game.Game;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class GameCommand extends DCommand {
public GameCommand() {
setCommand("game");
setMinArgs(0);
setMaxArgs(0);
setHelp(messageConfig.getMessage(Messages.HELP_CMD_GAME));
setPermission("dxl.game");
setPlayerCommand(true);
}
@Override
public void onExecute(String[] args, CommandSender sender) {
Player player = (Player) sender;
DGroup dGroup = DGroup.getByPlayer(player);
if (dGroup == null) {
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_JOIN_GROUP));
return;
}
GameWorld gameWorld = dGroup.getGameWorld();
if (gameWorld == null) {
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_NO_GAME));
return;
}
Game game = gameWorld.getGame();
if (game == null) {
MessageUtil.sendMessage(sender, messageConfig.getMessage(Messages.ERROR_NO_GAME));
return;
}
MessageUtil.sendCenteredMessage(sender, "&4&l[ &6Game &4&l]");
String groups = "";
for (DGroup group : game.getDGroups()) {
groups += (group == game.getDGroups().get(0) ? "" : "&b, &e") + group.getName();
}
MessageUtil.sendMessage(sender, "&bGroups: &e" + groups);
MessageUtil.sendMessage(sender, "&bGame type: &e" + game.getType());
MessageUtil.sendMessage(sender, "&bDungeon: &e" + (dGroup.getDungeonName() == null ? "N/A" : dGroup.getDungeonName()));
MessageUtil.sendMessage(sender, "&bMap: &e" + (dGroup.getMapName() == null ? "N/A" : dGroup.getMapName()));
}
}

View File

@ -215,7 +215,7 @@ public class GroupCommand extends DCommand {
MessageUtil.sendCenteredMessage(sender, "&4&l[ &6" + dGroup.getName() + " &4&l]");
MessageUtil.sendMessage(sender, "&bCaptain: &e" + dGroup.getCaptain().getName());
String players = "&e";
String players = "";
for (Player player : dGroup.getPlayers()) {
players += (player == dGroup.getPlayers().get(0) ? "" : "&b, &e") + player.getName();
}

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.game.GameWorld;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;

View File

@ -5,7 +5,7 @@ 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.EditWorld;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.util.NumberUtil;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;

View File

@ -5,8 +5,8 @@ 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.EditWorld;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;

View File

@ -4,8 +4,8 @@ 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.game.GameWorld;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;

View File

@ -74,7 +74,7 @@ public class MessageConfig {
ERROR_CHEST_IS_OPENED("Error_ChestIsOpened", "&4This chest has already been opened."),
ERROR_CMD("Error_Cmd", "&4Commands are not allowed while in a dungeon!"),
ERROR_CMD_NOT_EXIST_1("Error_CmdNotExist1", "&4Command &6&v1&4 does not exist!"),
ERROR_CMD_NOT_EXIST_2("Error_CmdNotExist2", "&4Pleaser enter &6/dxl help&4 for help!"),
ERROR_CMD_NOT_EXIST_2("Error_CmdNotExist2", "&4Please enter &6/dxl help&4 for help!"),
ERROR_COOLDOWN("Error_Cooldown", "&4You can only enter this Dungeon every &6&v1&4 hours!"),
ERROR_DISPENSER("Error_Dispenser", "&4You cannot access this dispenser!"),
ERROR_DROP("Error_Drop", "&4You cannot drop safe items"),
@ -90,6 +90,7 @@ public class MessageConfig {
ERROR_MSG_NO_INT("Error_MsgNoInt", "&4Argument <id> has to include a number!"),
ERROR_NAME_TO_LONG("Error_NameToLong", "&4The name may not be longer than 15 characters!"),
ERROR_NO_CONSOLE_COMMAND("Error_NoConsoleCommand", "&6/dxl &v1&4 cannot be executed as console!"),
ERROR_NO_GAME("Error_NoGame", "&4You currently do not take part in a game."),
ERROR_NO_LEAVE_IN_TUTORIAL("Error_NoLeaveInTutorial", "&4You cannot use this command in the tutorial!"),
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!"),
@ -112,6 +113,7 @@ public class MessageConfig {
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_GAME("Help_Cmd_Game", "/dxl game - Shows information about the current game session"),
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"),

View File

@ -1,6 +1,7 @@
package io.github.dre2n.dungeonsxl.config;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.game.GameType;
import io.github.dre2n.dungeonsxl.mob.DMobType;
import io.github.dre2n.dungeonsxl.player.DClass;
import io.github.dre2n.dungeonsxl.requirement.FeeRequirement;
@ -70,6 +71,8 @@ public class WorldConfig {
private List<String> finishedAll;
private int timeLastPlayed = 0;
private GameType forcedGameType;
// MobTypes
private Set<DMobType> mobTypes = new HashSet<DMobType>();
@ -286,7 +289,7 @@ public class WorldConfig {
/* Dungeon Requirements */
if (configFile.contains("requirements")) {
for (String identifier : configFile.getConfigurationSection("requirements").getKeys(false)) {
Requirement requirement = Requirement.create(plugin.getRequirements().getByIdentifier(identifier));
Requirement requirement = Requirement.create(plugin.getRequirementTypes().getByIdentifier(identifier));
// Check for built-in requirements
if (requirement instanceof FeeRequirement) {
@ -321,6 +324,18 @@ public class WorldConfig {
if (configFile.contains("gameCommandWhitelist")) {
gameCommandWhitelist = configFile.getStringList("gameCommandWhitelist");
} else {
gameCommandWhitelist = plugin.getDefaultConfig().gameCommandWhitelist;
}
if (configFile.contains("forcedGameType")) {
GameType gameType = plugin.getGameTypes().getByName(configFile.getString("forcedGameType"));
if (gameType != null) {
forcedGameType = gameType;
} else {
forcedGameType = null;
}
}
}
@ -601,4 +616,19 @@ public class WorldConfig {
return gameCommandWhitelist;
}
/**
* @return the forcedGameType
*/
public GameType getForcedGameType() {
return forcedGameType;
}
/**
* @param forcedGameType
* the forcedGameType to set
*/
public void setForcedGameType(GameType forcedGameType) {
this.forcedGameType = forcedGameType;
}
}

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.event.dgroup;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.player.DGroup;
import org.bukkit.event.Cancellable;

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.event.dgroup;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.player.DGroup;
import org.bukkit.event.Cancellable;

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.event.dsign;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.sign.DSign;
import org.bukkit.block.Sign;

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.event.gameworld;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import org.bukkit.event.Event;

View File

@ -1,6 +1,7 @@
package io.github.dre2n.dungeonsxl.event.gameworld;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.Game;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@ -8,11 +9,28 @@ import org.bukkit.event.HandlerList;
public class GameWorldStartGameEvent extends GameWorldEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
public GameWorldStartGameEvent(GameWorld gameWorld) {
private Game game;
public GameWorldStartGameEvent(GameWorld gameWorld, Game game) {
super(gameWorld);
this.game = game;
}
/**
* @return the game
*/
public Game getGame() {
return game;
}
/**
* @param game
* the game to set
*/
public void setGame(Game game) {
this.game = game;
}
@Override

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.event.gameworld;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;

View File

@ -0,0 +1,61 @@
package io.github.dre2n.dungeonsxl.game;
import io.github.dre2n.dungeonsxl.player.DGroup;
import java.util.ArrayList;
import java.util.List;
public class Game {
private List<DGroup> dGroups = new ArrayList<DGroup>();
private GameType type;
public Game(DGroup dGroup) {
this.dGroups.add(dGroup);
this.type = GameTypeDefault.DEFAULT;
}
public Game(DGroup dGroup, GameType type) {
this.dGroups.add(dGroup);
this.type = type;
}
/**
* @return the dGroups
*/
public List<DGroup> getDGroups() {
return dGroups;
}
/**
* @param dGroup
* the dGroups to add
*/
public void addDGroup(DGroup dGroup) {
dGroups.add(dGroup);
}
/**
* @param dGroup
* the dGroups to remove
*/
public void removeDGroup(DGroup dGroup) {
dGroups.remove(dGroup);
}
/**
* @return the type
*/
public GameType getType() {
return type;
}
/**
* @param type
* the type to set
*/
public void setType(GameType type) {
this.type = type;
}
}

View File

@ -1,4 +1,4 @@
package io.github.dre2n.dungeonsxl.dungeon.game;
package io.github.dre2n.dungeonsxl.game;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;

View File

@ -1,4 +1,4 @@
package io.github.dre2n.dungeonsxl.dungeon.game;
package io.github.dre2n.dungeonsxl.game;
import io.github.dre2n.dungeonsxl.util.NumberUtil;

View File

@ -0,0 +1,95 @@
package io.github.dre2n.dungeonsxl.game;
import org.bukkit.GameMode;
public interface GameType {
/**
* @return the displayName
*/
public String getDisplayName();
/**
* @param displayName
* the displayName to set
*/
public void setDisplayName(String displayName);
/**
* @return the signName
*/
public String getSignName();
/**
* @param signName
* the signName to set
*/
public void setSignName(String signName);
/**
* @return the playerVersusPlayer
*/
public boolean isPlayerVersusPlayer();
/**
* @param playerVersusPlayer
* the playerVersusPlayer to set
*/
public void setPlayerVersusPlayer(boolean playerVersusPlayer);
/**
* @return the mobWaves
*/
public boolean hasMobWaves();
/**
* @param mobWaves
* the mobWaves to set
*/
public void setMobWaves(boolean mobWaves);
/**
* @return the rewards
*/
public boolean hasRewards();
/**
* @param rewards
* the rewards to set
*/
public void setRewards(boolean rewards);
/**
* @return the showTime
*/
public boolean getShowTime();
/**
* @param showTime
* the showTime to set
*/
public void setShowTime(boolean showTime);
/**
* @return the build
*/
public boolean canBuild();
/**
* @param build
* the build to set
*/
public void setBuild(boolean build);
/**
* @return the gameMode
*/
public GameMode getGameMode();
/**
* @param gameMode
* the gameMode to set
*/
public void setGameMode(GameMode gameMode);
}

View File

@ -0,0 +1,128 @@
package io.github.dre2n.dungeonsxl.game;
import org.bukkit.GameMode;
public enum GameTypeDefault implements GameType {
ADVENTURE("Adventure", "Adventure", false, false, true, false, true, GameMode.ADVENTURE),
ADVENTURE_TIME_IS_RUNNING("Adventure - Time is Running", "Adventure TiR", false, false, true, true, true, GameMode.ADVENTURE),
APOCALYPSE_LAST_MAN_STANDING("Apocalypse", "Apocalypse LMS", true, true, true, false, false, GameMode.SURVIVAL),
APOCALYPSE_LIMITED_MOBS("Apocalypse - Limited Mobs", "Apc Limited", true, true, true, false, false, GameMode.SURVIVAL),
APOCALYPSE_TIME_IS_RUNNING("Apocalypse - Time is Running", "Apocalypse TiR", true, true, true, true, false, GameMode.SURVIVAL),
PVE_LAST_MAN_STANDING("Player versus Environment - Last Man Standing", "PvE LMS", false, true, true, false, false, GameMode.SURVIVAL),
PVE_LIMITED_MOBS("Player versus Environment - Limited Mobs", "PvE Limited", false, true, true, false, false, GameMode.SURVIVAL),
PVE_TIME_IS_RUNNING("Player versus Environment - Time is Running", "PvE TiR", false, true, true, true, false, GameMode.SURVIVAL),
PVP_FACTIONS_BATTLEFIELD("Player versus Player - Factions Battlefield", "FactionsPvP", true, false, false, false, false, GameMode.SURVIVAL),
PVP_LAST_MAN_STANDING("Player versus Player - Last Man Standing", "PvP LMS", true, false, false, false, false, GameMode.SURVIVAL),
QUEST("Quest", "Quest", false, false, true, false, false, GameMode.SURVIVAL),
QUEST_TIME_IS_RUNNING("Quest - Time is Running", "Quest TiR", false, false, true, true, false, GameMode.SURVIVAL),
TEST("Test", "Test", false, false, false, true, true, GameMode.SURVIVAL),
TUTORIAL("Tutorial", "Tutorial", false, false, true, false, false, GameMode.SURVIVAL),
DEFAULT("Default", "Default");
private String displayName;
private String signName;
private boolean playerVersusPlayer;
private boolean mobWaves;
private boolean rewards;
private boolean showTime;
private boolean build;
private GameMode gameMode;
GameTypeDefault(String displayName, String signName) {
this.displayName = displayName;
this.signName = signName;
}
GameTypeDefault(String displayName, String signName, boolean playerVersusPlayer, boolean mobWaves, boolean rewards, boolean showTime, boolean build, GameMode gameMode) {
this.displayName = displayName;
this.signName = signName;
this.playerVersusPlayer = playerVersusPlayer;
this.mobWaves = mobWaves;
this.rewards = rewards;
this.showTime = showTime;
this.build = build;
this.gameMode = gameMode;
}
@Override
public String getDisplayName() {
return displayName;
}
@Override
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
@Override
public String getSignName() {
return signName;
}
@Override
public void setSignName(String signName) {
this.signName = signName;
}
@Override
public boolean isPlayerVersusPlayer() {
return playerVersusPlayer;
}
@Override
public void setPlayerVersusPlayer(boolean playerVersusPlayer) {
this.playerVersusPlayer = playerVersusPlayer;
}
@Override
public boolean hasMobWaves() {
return mobWaves;
}
@Override
public void setMobWaves(boolean mobWaves) {
this.mobWaves = mobWaves;
}
@Override
public boolean hasRewards() {
return rewards;
}
@Override
public void setRewards(boolean rewards) {
this.rewards = rewards;
}
@Override
public boolean getShowTime() {
return showTime;
}
@Override
public void setShowTime(boolean showTime) {
this.showTime = showTime;
}
@Override
public boolean canBuild() {
return build;
}
@Override
public void setBuild(boolean build) {
this.build = build;
}
@Override
public GameMode getGameMode() {
return gameMode;
}
@Override
public void setGameMode(GameMode gameMode) {
this.gameMode = gameMode;
}
}

View File

@ -0,0 +1,83 @@
package io.github.dre2n.dungeonsxl.game;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.game.GameType;
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.block.Sign;
public class GameTypes {
private List<GameType> types = new ArrayList<GameType>();
public GameTypes() {
for (GameType type : GameTypeDefault.values()) {
if (type == GameTypeDefault.PVP_FACTIONS_BATTLEFIELD) {
try {
Class.forName("com.massivecraft.factions.Patch");
} catch (ClassNotFoundException exception) {
DungeonsXL.getPlugin().getLogger().info("Could not find compatible Factions plugin. The game type PVP_FACTIONS_BATTLEFIELD will not get enabled...");
continue;
}
}
types.add(type);
}
}
/**
* @return the game type which has the enum value name
*/
public GameType getByName(String name) {
for (GameType type : types) {
if (type.toString().equals(name)) {
return type;
}
}
return null;
}
/**
* @return the game type which has the enum value sign text in the second line of the sign
*/
public GameType getBySign(Sign sign) {
String[] lines = sign.getLines();
for (GameType type : types) {
if (type.getSignName().equals(lines[1])) {
return type;
}
}
return null;
}
/**
* @return the game types
*/
public List<GameType> getGameTypes() {
return types;
}
/**
* @param type
* the game type to add
*/
public void addGameType(GameType type) {
types.add(type);
}
/**
* @param game
* the game to remove
*/
public void removeGameType(GameType type) {
types.remove(type);
}
}

View File

@ -1,4 +1,4 @@
package io.github.dre2n.dungeonsxl.dungeon.game;
package io.github.dre2n.dungeonsxl.game;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.config.DungeonConfig;
@ -43,7 +43,9 @@ public class GameWorld {
static DungeonsXL plugin = DungeonsXL.getPlugin();
// Variables placeable
// Variables
private Game game;
private boolean tutorial;
private CopyOnWriteArrayList<GamePlaceableBlock> placeableBlocks = new CopyOnWriteArrayList<GamePlaceableBlock>();
@ -83,6 +85,21 @@ public class GameWorld {
}
}
/**
* @return the game
*/
public Game getGame() {
return game;
}
/**
* @param game
* the game to set
*/
public void setGame(Game game) {
this.game = game;
}
/**
* @return the tutorial
*/
@ -330,7 +347,7 @@ public class GameWorld {
}
public void startGame() {
GameWorldStartGameEvent event = new GameWorldStartGameEvent(this);
GameWorldStartGameEvent event = new GameWorldStartGameEvent(this, game);
if (event.isCancelled()) {
return;

View File

@ -2,7 +2,7 @@ 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.game.GameWorld;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;

View File

@ -4,7 +4,7 @@ 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.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;

View File

@ -3,8 +3,8 @@ 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.game.GamePlaceableBlock;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.global.DPortal;
import io.github.dre2n.dungeonsxl.global.GroupSign;
import io.github.dre2n.dungeonsxl.global.LeaveSign;
@ -30,7 +30,7 @@ import org.bukkit.event.block.SignChangeEvent;
public class BlockListener implements Listener {
static DungeonsXL plugin = DungeonsXL.getPlugin();
DungeonsXL plugin = DungeonsXL.getPlugin();
@EventHandler(priority = EventPriority.HIGH)
public void onPhysics(BlockPhysicsEvent event) {

View File

@ -14,10 +14,10 @@ import org.bukkit.entity.Player;
public class CommandListener implements CommandExecutor {
static DungeonsXL plugin = DungeonsXL.getPlugin();
@Override
public boolean onCommand(CommandSender sender, Command cmd_notused, String arg, String[] args) {
DungeonsXL plugin = DungeonsXL.getPlugin();
if (args.length > 0) {
MessageConfig MessageConfig = plugin.getMessageConfig();
DCommand dCommand = plugin.getDCommands().getDCommand(args[0]);

View File

@ -2,7 +2,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.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.global.DPortal;
import io.github.dre2n.dungeonsxl.global.GroupSign;
import io.github.dre2n.dungeonsxl.mob.DMob;

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.listener;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

View File

@ -8,11 +8,11 @@ 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.event.dplayer.DPlayerKickEvent;
import io.github.dre2n.dungeonsxl.game.GameChest;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.global.DPortal;
import io.github.dre2n.dungeonsxl.global.GroupSign;
import io.github.dre2n.dungeonsxl.global.LeaveSign;
@ -52,7 +52,7 @@ import org.bukkit.inventory.meta.BookMeta;
public class PlayerListener implements Listener {
static DungeonsXL plugin = DungeonsXL.getPlugin();
MessageConfig messageConfig = plugin.getMessageConfig();
static MessageConfig messageConfig = plugin.getMessageConfig();
@EventHandler(priority = EventPriority.HIGH)
public void onDeath(PlayerDeathEvent event) {

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.listener;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;

View File

@ -1,7 +1,7 @@
package io.github.dre2n.dungeonsxl.mob;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.event.dmob.DMobDeathEvent;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.trigger.MobTrigger;
import java.util.Random;

View File

@ -2,7 +2,7 @@ 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.game.GameWorld;
import io.github.dre2n.dungeonsxl.util.NumberUtil;
import java.util.Arrays;

View File

@ -3,10 +3,11 @@ 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.game.Game;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.global.GroupSign;
import io.github.dre2n.dungeonsxl.requirement.Requirement;
import io.github.dre2n.dungeonsxl.reward.Reward;
@ -15,6 +16,7 @@ import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CopyOnWriteArrayList;
import org.bukkit.entity.Player;
@ -24,7 +26,7 @@ public class DGroup {
private String name;
private Player captain;
private List<Player> players = new ArrayList<Player>();
private List<Player> players = new CopyOnWriteArrayList<Player>();
private List<UUID> invitedPlayers = new ArrayList<UUID>();
private String dungeonName;
private String mapName;
@ -414,7 +416,30 @@ public class DGroup {
GroupSign.updatePerGroup(this);
}
public void startGame() {
public void startGame(Game game) {
if (game == null) {
return;
}
for (DGroup dGroup : game.getDGroups()) {
if (dGroup == null) {
continue;
}
for (Player player : dGroup.getPlayers()) {
DPlayer dPlayer = DPlayer.getByPlayer(player);
if (dPlayer == null) {
continue;
}
if ( !dPlayer.isReady()) {
return;
}
}
}
gameWorld.setGame(game);
DGroupStartFloorEvent event = new DGroupStartFloorEvent(this, gameWorld);
if (event.isCancelled()) {

View File

@ -7,12 +7,14 @@ 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;
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupFinishDungeonEvent;
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.game.Game;
import io.github.dre2n.dungeonsxl.game.GameType;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.reward.Reward;
import io.github.dre2n.dungeonsxl.trigger.DistanceTrigger;
import io.github.dre2n.dungeonsxl.util.NumberUtil;
@ -44,7 +46,7 @@ import org.bukkit.potion.PotionEffect;
public class DPlayer {
static DungeonsXL plugin = DungeonsXL.getPlugin();
MessageConfig messageConfig = plugin.getMessageConfig();
static MessageConfig messageConfig = plugin.getMessageConfig();
// Variables
private Player player;
@ -588,17 +590,31 @@ public class DPlayer {
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) {
if (dGroup == null) {
return;
}
if ( !dGroup.isPlaying()) {
dGroup.startGame(new Game(dGroup));
} else {
respawn();
}
}
dGroup.startGame();
public void ready(GameType gameType) {
ready = true;
DGroup dGroup = DGroup.getByPlayer(getPlayer());
if (dGroup == null) {
return;
}
if ( !dGroup.isPlaying()) {
dGroup.startGame(new Game(dGroup, gameType));
} else {
respawn();
}
@ -685,6 +701,8 @@ public class DPlayer {
return;
}
Game game = dGroup.getGameWorld().getGame();
dGroup.removeUnplayedFloor(dGroup.getMapName());
dGroup.setMapName(newFloor);
GameWorld gameWorld = GameWorld.load(newFloor);
@ -697,7 +715,7 @@ public class DPlayer {
dPlayer.getWolf().teleport(dPlayer.getCheckpoint());
}
}
dGroup.startGame();
dGroup.startGame(game);
}
public void finish() {

View File

@ -0,0 +1,52 @@
package io.github.dre2n.dungeonsxl.requirement;
import java.util.ArrayList;
import java.util.List;
public class RequirementTypes {
private List<RequirementType> types = new ArrayList<RequirementType>();
public RequirementTypes() {
for (RequirementType type : RequirementTypeDefault.values()) {
types.add(type);
}
}
/**
* @return the requirement type which has the identifier
*/
public RequirementType getByIdentifier(String identifier) {
for (RequirementType type : types) {
if (type.getIdentifier().equals(identifier)) {
return type;
}
}
return null;
}
/**
* @return the requirement types
*/
public List<RequirementType> getRequirements() {
return types;
}
/**
* @param type
* the requirement type to add
*/
public void addRequirement(RequirementType type) {
types.add(type);
}
/**
* @param type
* the requirement type to remove
*/
public void removeRequirement(RequirementType type) {
types.remove(type);
}
}

View File

@ -1,52 +0,0 @@
package io.github.dre2n.dungeonsxl.requirement;
import java.util.ArrayList;
import java.util.List;
public class Requirements {
private List<RequirementType> requirements = new ArrayList<RequirementType>();
public Requirements() {
for (RequirementType type : RequirementTypeDefault.values()) {
requirements.add(type);
}
}
/**
* @return the requirement which has the identifier
*/
public RequirementType getByIdentifier(String identifier) {
for (RequirementType requirement : requirements) {
if (requirement.getIdentifier().equals(identifier)) {
return requirement;
}
}
return null;
}
/**
* @return the requirements
*/
public List<RequirementType> getRequirements() {
return requirements;
}
/**
* @param requirement
* the requirement to add
*/
public void addRequirement(RequirementType requirement) {
requirements.add(requirement);
}
/**
* @param requirement
* the requirement to remove
*/
public void removeRequirement(RequirementType requirement) {
requirements.remove(requirement);
}
}

View File

@ -0,0 +1,52 @@
package io.github.dre2n.dungeonsxl.reward;
import java.util.ArrayList;
import java.util.List;
public class RewardTypes {
private List<RewardType> types = new ArrayList<RewardType>();
public RewardTypes() {
for (RewardType type : RewardTypeDefault.values()) {
types.add(type);
}
}
/**
* @return the reward type which has the identifier
*/
public RewardType getByIdentifier(String identifier) {
for (RewardType type : types) {
if (type.getIdentifier().equals(identifier)) {
return type;
}
}
return null;
}
/**
* @return the reward types
*/
public List<RewardType> getRewards() {
return types;
}
/**
* @param type
* the reward type to add
*/
public void addReward(RewardType type) {
types.add(type);
}
/**
* @param type
* the reward type to remove
*/
public void removeReward(RewardType type) {
types.remove(type);
}
}

View File

@ -1,52 +0,0 @@
package io.github.dre2n.dungeonsxl.reward;
import java.util.ArrayList;
import java.util.List;
public class Rewards {
private List<RewardType> rewards = new ArrayList<RewardType>();
public Rewards() {
for (RewardType type : RewardTypeDefault.values()) {
rewards.add(type);
}
}
/**
* @return the reward which has the identifier
*/
public RewardType getByIdentifier(String identifier) {
for (RewardType reward : rewards) {
if (reward.getIdentifier().equals(identifier)) {
return reward;
}
}
return null;
}
/**
* @return the rewards
*/
public List<RewardType> getRewards() {
return rewards;
}
/**
* @param reward
* the reward to add
*/
public void addReward(RewardType reward) {
rewards.add(reward);
}
/**
* @param reward
* the reward to remove
*/
public void removeReward(RewardType reward) {
rewards.remove(reward);
}
}

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.util.NumberUtil;
import org.bukkit.Material;

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.game.GameWorld;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;

View File

@ -1,7 +1,7 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.dungeon.game.GameChest;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameChest;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import org.bukkit.Material;
import org.bukkit.block.Sign;

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.util.NumberUtil;
import org.bukkit.Chunk;

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.global.GroupSign;
import io.github.dre2n.dungeonsxl.player.DClass;

View File

@ -3,7 +3,7 @@ package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.commandsxl.command.CCommand;
import io.github.dre2n.commandsxl.command.CCommandExecutorTask;
import io.github.dre2n.commandsxl.CommandsXL;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
import io.github.dre2n.dungeonsxl.util.NumberUtil;

View File

@ -1,8 +1,8 @@
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.event.dsign.DSignRegistrationEvent;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.trigger.Trigger;
import java.lang.reflect.Constructor;

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;

View File

@ -1,7 +1,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.game.GameWorld;
import io.github.dre2n.dungeonsxl.task.SignUpdateTask;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
import io.github.dre2n.dungeonsxl.util.NumberUtil;

View File

@ -1,7 +1,7 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerEscapeEvent;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import org.bukkit.Material;
import org.bukkit.block.Sign;

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.util.NumberUtil;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.task.MobSpawnTask;
import io.github.dre2n.dungeonsxl.util.NumberUtil;

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.task.MythicMobSpawnTask;
import io.github.dre2n.dungeonsxl.util.NumberUtil;

View File

@ -1,7 +1,7 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.dungeon.game.GamePlaceableBlock;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GamePlaceableBlock;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import org.bukkit.Material;
import org.bukkit.block.Sign;

View File

@ -1,7 +1,9 @@
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.game.GameType;
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
import io.github.dre2n.dungeonsxl.util.messageutil.MessageUtil;
@ -15,10 +17,27 @@ public class ReadySign extends DSign {
private DSignType type = DSignTypeDefault.READY;
private GameType gameType;
public ReadySign(Sign sign, GameWorld gameWorld) {
super(sign, gameWorld);
}
/**
* @return the gameType
*/
public GameType getGameType() {
return gameType;
}
/**
* @param gameType
* the gameType to set
*/
public void setGameType(GameType gameType) {
this.gameType = gameType;
}
@Override
public boolean check() {
return true;
@ -26,6 +45,13 @@ public class ReadySign extends DSign {
@Override
public void onInit() {
if (plugin.getGameTypes().getBySign(getSign()) != null) {
gameType = plugin.getGameTypes().getBySign(getSign());
} else {
gameType = GameTypeDefault.DEFAULT;
}
if ( !getTriggers().isEmpty()) {
getSign().getBlock().setType(Material.AIR);
return;
@ -39,7 +65,7 @@ public class ReadySign extends DSign {
getSign().setLine(0, ChatColor.DARK_BLUE + "############");
getSign().setLine(1, ChatColor.DARK_GREEN + "Ready");
getSign().setLine(2, "");
getSign().setLine(2, ChatColor.DARK_RED + gameType.getSignName());
getSign().setLine(3, ChatColor.DARK_BLUE + "############");
getSign().update();
}
@ -67,7 +93,7 @@ public class ReadySign extends DSign {
}
if (getGameWorld().getSignClass().isEmpty() || dPlayer.getDClass() != null) {
dPlayer.ready();
dPlayer.ready(gameType);
MessageUtil.sendMessage(dPlayer.getPlayer(), plugin.getMessageConfig().getMessage(Messages.PLAYER_READY));
return;

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.task.DelayedPowerTask;
import io.github.dre2n.dungeonsxl.util.NumberUtil;

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.util.NumberUtil;
import java.util.concurrent.CopyOnWriteArrayList;

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import org.bukkit.Material;
import org.bukkit.block.Sign;

View File

@ -1,7 +1,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.game.GameWorld;
import io.github.dre2n.dungeonsxl.task.SignUpdateTask;
import io.github.dre2n.dungeonsxl.trigger.SignTrigger;
import io.github.dre2n.dungeonsxl.util.NumberUtil;

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.task;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.sign.RedstoneSign;
import org.bukkit.scheduler.BukkitRunnable;

View File

@ -1,7 +1,7 @@
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.game.GameWorld;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import org.bukkit.scheduler.BukkitRunnable;

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.task;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.mob.DMob;
import io.github.dre2n.dungeonsxl.mob.DMobType;
import io.github.dre2n.dungeonsxl.sign.MobSign;

View File

@ -1,6 +1,6 @@
package io.github.dre2n.dungeonsxl.task;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.mob.DMob;
import io.github.dre2n.dungeonsxl.sign.MythicMobsSign;

View File

@ -1,7 +1,7 @@
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.game.GameWorld;
import io.github.dre2n.dungeonsxl.trigger.RedstoneTrigger;
import org.bukkit.block.Block;

View File

@ -2,7 +2,7 @@ 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.game.GameWorld;
import io.github.dre2n.dungeonsxl.player.DPlayer;
import org.bukkit.scheduler.BukkitRunnable;

View File

@ -1,7 +1,7 @@
package io.github.dre2n.dungeonsxl.trigger;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import java.util.ArrayList;
import java.util.HashMap;

View File

@ -1,7 +1,7 @@
package io.github.dre2n.dungeonsxl.trigger;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import java.util.ArrayList;
import java.util.HashMap;

View File

@ -1,7 +1,7 @@
package io.github.dre2n.dungeonsxl.trigger;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import java.util.ArrayList;
import java.util.HashMap;

View File

@ -1,7 +1,7 @@
package io.github.dre2n.dungeonsxl.trigger;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import java.util.ArrayList;
import java.util.HashMap;

View File

@ -1,7 +1,7 @@
package io.github.dre2n.dungeonsxl.trigger;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import java.util.ArrayList;
import java.util.HashMap;

View File

@ -1,8 +1,8 @@
package io.github.dre2n.dungeonsxl.trigger;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerRegistrationEvent;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import io.github.dre2n.dungeonsxl.sign.DSign;
import io.github.dre2n.dungeonsxl.util.NumberUtil;

View File

@ -1,7 +1,7 @@
package io.github.dre2n.dungeonsxl.trigger;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
import io.github.dre2n.dungeonsxl.game.GameWorld;
import java.util.ArrayList;
import java.util.HashMap;

View File

@ -16,8 +16,8 @@ class v1_8_R1 {
subtitle = ChatColor.translateAlternateColorCodes('&', subtitle);
title = ChatColor.translateAlternateColorCodes('&', title);
IChatBaseComponent subtitleComponent = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', subtitle) + "\"}");
IChatBaseComponent titleComponent = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', title) + "\"}");
IChatBaseComponent subtitleComponent = ChatSerializer.a("{\"text\": \"" + subtitle + "\"}");
IChatBaseComponent titleComponent = ChatSerializer.a("{\"text\": \"" + title + "\"}");
PacketPlayOutTitle clearPacket = new PacketPlayOutTitle(EnumTitleAction.CLEAR, titleComponent);
PacketPlayOutTitle resetPacket = new PacketPlayOutTitle(EnumTitleAction.RESET, titleComponent);

View File

@ -16,8 +16,8 @@ class v1_8_R2 {
subtitle = ChatColor.translateAlternateColorCodes('&', subtitle);
title = ChatColor.translateAlternateColorCodes('&', title);
IChatBaseComponent subtitleComponent = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', subtitle) + "\"}");
IChatBaseComponent titleComponent = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', title) + "\"}");
IChatBaseComponent subtitleComponent = ChatSerializer.a("{\"text\": \"" + subtitle + "\"}");
IChatBaseComponent titleComponent = ChatSerializer.a("{\"text\": \"" + title + "\"}");
PacketPlayOutTitle clearPacket = new PacketPlayOutTitle(EnumTitleAction.CLEAR, titleComponent);
PacketPlayOutTitle resetPacket = new PacketPlayOutTitle(EnumTitleAction.RESET, titleComponent);

View File

@ -16,8 +16,8 @@ class v1_8_R3 {
subtitle = ChatColor.translateAlternateColorCodes('&', subtitle);
title = ChatColor.translateAlternateColorCodes('&', title);
IChatBaseComponent subtitleComponent = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', subtitle) + "\"}");
IChatBaseComponent titleComponent = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', title) + "\"}");
IChatBaseComponent subtitleComponent = ChatSerializer.a("{\"text\": \"" + subtitle + "\"}");
IChatBaseComponent titleComponent = ChatSerializer.a("{\"text\": \"" + title + "\"}");
PacketPlayOutTitle clearPacket = new PacketPlayOutTitle(EnumTitleAction.CLEAR, titleComponent);
PacketPlayOutTitle resetPacket = new PacketPlayOutTitle(EnumTitleAction.RESET, titleComponent);

View File

@ -16,8 +16,8 @@ class v1_9_R1 {
subtitle = ChatColor.translateAlternateColorCodes('&', subtitle);
title = ChatColor.translateAlternateColorCodes('&', title);
IChatBaseComponent subtitleComponent = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', subtitle) + "\"}");
IChatBaseComponent titleComponent = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', title) + "\"}");
IChatBaseComponent subtitleComponent = ChatSerializer.a("{\"text\": \"" + subtitle + "\"}");
IChatBaseComponent titleComponent = ChatSerializer.a("{\"text\": \"" + title + "\"}");
PacketPlayOutTitle clearPacket = new PacketPlayOutTitle(EnumTitleAction.CLEAR, titleComponent);
PacketPlayOutTitle resetPacket = new PacketPlayOutTitle(EnumTitleAction.RESET, titleComponent);