mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2025-02-03 14:02:00 +01:00
parent
d43234943b
commit
750db495d6
@ -70,7 +70,7 @@ Maven automatically fetches all dependencies and builds DungeonsXL; just run _bu
|
||||
[BRCommons](https://github.com/DRE2N/BRCommons) is a util library for common tasks. DungeonsXL contains BRCommons 1.0.1.
|
||||
|
||||
#### Caliburn API
|
||||
[Caliburn](https://github.com/DRE2N/CaliburnAPI) is an API to read custom items and mobs from config files. DungeonsXL contains Caliburn Beta 0.2.
|
||||
[Caliburn](https://github.com/DRE2N/CaliburnAPI) is an API to read custom items and mobs from config files. DungeonsXL contains Caliburn Beta 0.2.1.
|
||||
|
||||
### Java
|
||||
Make sure that your server uses Java 7 or higher.
|
||||
|
@ -434,7 +434,7 @@ public class Announcer {
|
||||
|
||||
boolean full = playerCount >= maxPlayersPerGroup;
|
||||
|
||||
ItemStack button = new ItemStack(Material.WOOL, playerCount, plugin.getMainConfig().getGroupColorPriority().get(groupCount));
|
||||
ItemStack button = new ItemStack(Material.WOOL, playerCount, plugin.getMainConfig().getGroupColorPriority().get(groupCount).getWoolData());
|
||||
ItemMeta meta = button.getItemMeta();
|
||||
meta.setDisplayName(name + (full ? ChatColor.DARK_RED : ChatColor.GREEN) + " [" + playerCount + "/" + maxPlayersPerGroup + "]");
|
||||
meta.setLore(lore);
|
||||
|
@ -21,6 +21,7 @@ import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -61,11 +62,15 @@ public class LivesCommand extends BRCommand {
|
||||
}
|
||||
|
||||
DGamePlayer dPlayer = DGamePlayer.getByPlayer(player);
|
||||
DGroup dGroup = dPlayer != null ? dPlayer.getDGroup() : DGroup.getByName(args[1]);
|
||||
if (dPlayer != null) {
|
||||
MessageUtil.sendMessage(sender, DMessages.CMD_LIVES.getMessage(player.getName(), String.valueOf(dPlayer.getLives())));
|
||||
MessageUtil.sendMessage(sender, DMessages.CMD_LIVES_PLAYER.getMessage(dPlayer.getName(), String.valueOf(dPlayer.getLives() == -1 ? "UNLIMITED" : dPlayer.getLives())));
|
||||
|
||||
} else if (dGroup != null) {
|
||||
MessageUtil.sendMessage(sender, DMessages.CMD_LIVES_GROUP.getMessage(dGroup.getName(), String.valueOf(dGroup.getLives() == -1 ? "UNLIMITED" : dPlayer.getLives())));
|
||||
|
||||
} else {
|
||||
MessageUtil.sendMessage(sender, DMessages.ERROR_NOT_IN_DUNGEON.getMessage());
|
||||
MessageUtil.sendMessage(sender, DMessages.ERROR_NO_SUCH_PLAYER.getMessage(args[1]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,8 @@ public enum DMessages implements Messages {
|
||||
CMD_INVITE_SUCCESS("Cmd_Invite_Success", "&6Player &4&v1&6 was successfully invited to edit the map &4&v2&6."),
|
||||
CMD_KICK_SUCCESS("Cmd_Kick_Success", "&6Successfully attempted to kick &4&v1&6."),
|
||||
CMD_LEAVE_SUCCESS("Cmd_Leave_Success", "&6You have successfully left your group!"),
|
||||
CMD_LIVES("Cmd_Lives", "&4&v1&6 has &4&v2 &6lives left."),
|
||||
CMD_LIVES_GROUP("Cmd_Lives_Group", "&4&v1 &6have &4&v2 &6lives left."),
|
||||
CMD_LIVES_PLAYER("Cmd_Lives_Player", "&4&v1 &6has &4&v2 &6lives left."),
|
||||
CMD_MAIN_WELCOME("Cmd_Main_Welcome", "&7Welcome to &4Dungeons&fXL"),
|
||||
CMD_MAIN_LOADED("Cmd_Main_Loaded", "&eMaps: &o[&v1] &eDungeons: &o[&v2] &eLoaded: &o[&v3] &ePlayers: &o[&v4]"),
|
||||
CMD_MAIN_COMPATIBILITY("Cmd_Main_Compatibility", "&eInternals: &o[&v1] &eVault: &o[&v2] &eItemsXL: &o[&v3]"),
|
||||
@ -128,12 +129,21 @@ public enum DMessages implements Messages {
|
||||
HELP_CMD_TEST("Help_Cmd_Test", "/dxl test - Starts the game in test mode"),
|
||||
HELP_CMD_UNINVITE("Help_Cmd_Uninvite", "/dxl uninvite [player] [dungeon] - Uninvite a player to edit a dungeon"),
|
||||
GROUP_BED_DESTROYED("Group_BedDestroyed", "&6The bed of the group &4&v1 &6has been destroyed by &4&v2&6!"),
|
||||
GROUP_CONGRATS("Group_Congrats", "&6Congratulations!"),
|
||||
GROUP_CONGRATS_SUB("Group_CongratsSub", "&l&4Your group &v1 &4won the match!"),
|
||||
GROUP_CREATED("Group_Created", "&4&v1&6 created the group &4&v2&6!"),
|
||||
GROUP_DEATH("Group_Death", "&4&v1 &6died. &4&v2 have &4&v3 &6lives left."),
|
||||
GROUP_DEATH_KICK("Group_DeathKick", "&2&v1 &6was kicked because &4&v2 &6have no lives left."),
|
||||
GROUP_DISBANDED("Group_Disbanded", "&4&v1&6 disbanded the group &4&v2&6."),
|
||||
GROUP_FLAG_CAPTURED("Group_FlagCaptured", "&4&v1&6 has captured the flag of the group &4&v2&6!"),
|
||||
GROUP_FLAG_LOST("Group_FlagLost", "&4&v1&6 died and lost &4&v2&6's flag."),
|
||||
GROUP_FLAG_STEALING("Group_FlagStealing", "&4&v1&6 is stealing the flag of 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_JOINED_GAME("Group_JoinedGame", "&6Your group successfully joined the game."),
|
||||
GROUP_KILLED("Group_Killed", "&4&v1 &6was killed by &4&v2&6. &4&v3&6 have &4&v4 &6lives left."),
|
||||
GROUP_KILLED_KICK("Group_KilledKick", "&4&v1&6 was killed by &4&v2&6. &4&v3 have no lives left."),
|
||||
GROUP_LIVES_ADDED("Group_LivesAdded", "&6Your group received a bonus of &4&v1&6 lives."),
|
||||
GROUP_LIVES_REMOVED("Group_LivesRemoved", "&6Your group lost &4&v1&6 lives!"),
|
||||
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!"),
|
||||
@ -151,13 +161,15 @@ public enum DMessages implements Messages {
|
||||
LOG_WORLD_GENERATION_FINISHED("Log_WorldGenerationFinished", "&6World generation finished!"),
|
||||
PLAYER_BLOCK_INFO("Player_BlockInfo", "&6Block ID: &2&v1"),
|
||||
PLAYER_CHECKPOINT_REACHED("Player_CheckpointReached", "&6Checkpoint reached!"),
|
||||
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_DEATH("Player_Death", "&4&v1 &6died and has &4&v2 &6lives left."),
|
||||
PLAYER_DEATH_KICK("Player_DeathKick", "&2&v1 &6lost his last life and was kicked."),
|
||||
PLAYER_FINISHED_DUNGEON("Player_FinishedDungeon", "&6You successfully finished the dungeon!"),
|
||||
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_KILLED("Player_Killed", "&4&v1 &6was killed by &4&v2 &6and has &4&v3 &6lives left."),
|
||||
PLAYER_KILLED_KICK("Player_KilledKick", "&4&v1&6 was killed by &4&v2 &6and lost his last life."),
|
||||
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_LIVES_ADDED("Player_LivesAdded", "&6Received a bonus of &4&v1&6 lives."),
|
||||
|
@ -21,6 +21,8 @@ import io.github.dre2n.commons.compatibility.Internals;
|
||||
import io.github.dre2n.commons.config.BRConfig;
|
||||
import io.github.dre2n.commons.util.EnumUtil;
|
||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||
import io.github.dre2n.dungeonsxl.util.DColor;
|
||||
import static io.github.dre2n.dungeonsxl.util.DColor.*;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -41,7 +43,7 @@ public class MainConfig extends BRConfig {
|
||||
NEVER
|
||||
}
|
||||
|
||||
public static final int CONFIG_VERSION = 11;
|
||||
public static final int CONFIG_VERSION = 12;
|
||||
|
||||
private String language = "english";
|
||||
private boolean enableEconomy = false;
|
||||
@ -53,15 +55,22 @@ public class MainConfig extends BRConfig {
|
||||
private String tutorialEndGroup = "player";
|
||||
|
||||
/* Announcers */
|
||||
private List<Short> groupColorPriority = new ArrayList<>(Arrays.asList(
|
||||
(short) 11,
|
||||
(short) 14,
|
||||
(short) 4,
|
||||
(short) 5,
|
||||
(short) 10,
|
||||
(short) 1,
|
||||
(short) 0,
|
||||
(short) 15
|
||||
private List<DColor> groupColorPriority = new ArrayList<>(Arrays.asList(
|
||||
DARK_BLUE,
|
||||
LIGHT_RED,
|
||||
YELLOW,
|
||||
LIGHT_GREEN,
|
||||
PURPLE,
|
||||
ORANGE,
|
||||
WHITE,
|
||||
BLACK,
|
||||
LIGHT_BLUE,
|
||||
DARK_GREEN,
|
||||
DARK_RED,
|
||||
LIGHT_GRAY,
|
||||
CYAN,
|
||||
MAGENTA,
|
||||
DARK_GRAY
|
||||
));
|
||||
private double announcementInterval = 30;
|
||||
|
||||
@ -189,16 +198,16 @@ public class MainConfig extends BRConfig {
|
||||
/**
|
||||
* @return the group colors
|
||||
*/
|
||||
public List<Short> getGroupColorPriority() {
|
||||
public List<DColor> getGroupColorPriority() {
|
||||
return groupColorPriority;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dataValues
|
||||
* wool data values
|
||||
* @param colors
|
||||
* the colors to set
|
||||
*/
|
||||
public void setGroupColorPriority(List<Short> dataValues) {
|
||||
groupColorPriority = dataValues;
|
||||
public void setGroupColorPriority(List<DColor> colors) {
|
||||
groupColorPriority = colors;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -392,7 +401,11 @@ public class MainConfig extends BRConfig {
|
||||
}
|
||||
|
||||
if (!config.contains("groupColorPriority")) {
|
||||
config.set("groupColorPriority", groupColorPriority);
|
||||
ArrayList<String> strings = new ArrayList<>();
|
||||
for (DColor color : groupColorPriority) {
|
||||
strings.add(color.toString());
|
||||
}
|
||||
config.set("groupColorPriority", strings);
|
||||
}
|
||||
|
||||
if (!config.contains("announcementInterval")) {
|
||||
@ -479,7 +492,12 @@ public class MainConfig extends BRConfig {
|
||||
}
|
||||
|
||||
if (config.contains("groupColorPriority")) {
|
||||
groupColorPriority = config.getShortList("groupColorPriority");
|
||||
groupColorPriority.clear();
|
||||
for (String color : config.getStringList("groupColorPriority")) {
|
||||
if (EnumUtil.isValidEnum(DColor.class, color)) {
|
||||
groupColorPriority.add(DColor.valueOf(color));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (config.contains("announcementInterval")) {
|
||||
|
@ -190,6 +190,10 @@ public class WorldConfig extends GameRules {
|
||||
initialLives = configFile.getInt("initialLives");
|
||||
}
|
||||
|
||||
if (configFile.contains("initialGroupLives")) {
|
||||
initialGroupLives = configFile.getInt("initialGroupLives");
|
||||
}
|
||||
|
||||
/* Lobby */
|
||||
if (configFile.contains("isLobbyDisabled")) {
|
||||
lobbyDisabled = configFile.getBoolean("isLobbyDisabled");
|
||||
|
@ -57,33 +57,44 @@ public class Game {
|
||||
private Map<String, Integer> waveKills = new HashMap<>();
|
||||
|
||||
public Game(DGroup dGroup) {
|
||||
dGroups.add(dGroup);
|
||||
started = false;
|
||||
fetchRules();
|
||||
|
||||
plugin.getGames().add(this);
|
||||
|
||||
started = false;
|
||||
|
||||
dGroups.add(dGroup);
|
||||
dGroup.setGameWorld(world);
|
||||
fetchRules();
|
||||
dGroup.setInitialLives(rules.getInitialGroupLives());
|
||||
dGroup.setLives(rules.getInitialGroupLives());
|
||||
}
|
||||
|
||||
public Game(DGroup dGroup, DGameWorld world) {
|
||||
dGroups.add(dGroup);
|
||||
plugin.getGames().add(this);
|
||||
|
||||
started = false;
|
||||
this.world = world;
|
||||
fetchRules();
|
||||
|
||||
plugin.getGames().add(this);
|
||||
dGroups.add(dGroup);
|
||||
dGroup.setGameWorld(world);
|
||||
fetchRules();
|
||||
dGroup.setInitialLives(rules.getInitialGroupLives());
|
||||
dGroup.setLives(rules.getInitialGroupLives());
|
||||
}
|
||||
|
||||
public Game(DGroup dGroup, String worldName) {
|
||||
plugin.getGames().add(this);
|
||||
|
||||
dGroups.add(dGroup);
|
||||
started = false;
|
||||
DResourceWorld resource = plugin.getDWorlds().getResourceByName(worldName);
|
||||
if (resource != null) {
|
||||
world = resource.instantiateAsGameWorld();
|
||||
}
|
||||
|
||||
dGroups.add(dGroup);
|
||||
dGroup.setGameWorld(world);
|
||||
fetchRules();
|
||||
dGroup.setInitialLives(rules.getInitialGroupLives());
|
||||
dGroup.setLives(rules.getInitialGroupLives());
|
||||
}
|
||||
|
||||
public Game(DGroup dGroup, GameType type, DGameWorld world) {
|
||||
@ -91,13 +102,19 @@ public class Game {
|
||||
}
|
||||
|
||||
public Game(List<DGroup> dGroups, GameType type, DGameWorld world) {
|
||||
plugin.getGames().add(this);
|
||||
|
||||
this.dGroups = dGroups;
|
||||
this.type = type;
|
||||
this.world = world;
|
||||
this.started = true;
|
||||
fetchRules();
|
||||
|
||||
plugin.getGames().add(this);
|
||||
for (DGroup dGroup : dGroups) {
|
||||
dGroup.setGameWorld(world);
|
||||
fetchRules();
|
||||
dGroup.setInitialLives(rules.getInitialGroupLives());
|
||||
dGroup.setLives(rules.getInitialGroupLives());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -113,6 +130,10 @@ public class Game {
|
||||
*/
|
||||
public void addDGroup(DGroup dGroup) {
|
||||
dGroups.add(dGroup);
|
||||
|
||||
dGroup.setGameWorld(world);
|
||||
dGroup.setInitialLives(rules.getInitialGroupLives());
|
||||
dGroup.setLives(rules.getInitialGroupLives());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,7 +54,8 @@ public class GameRules {
|
||||
/* Fighting */
|
||||
DEFAULT_VALUES.playerVersusPlayer = false;
|
||||
DEFAULT_VALUES.friendlyFire = false;
|
||||
DEFAULT_VALUES.initialLives = 3;
|
||||
DEFAULT_VALUES.initialLives = -1;
|
||||
DEFAULT_VALUES.initialGroupLives = -1;
|
||||
|
||||
/* Timer */
|
||||
DEFAULT_VALUES.timeLastPlayed = 0;
|
||||
@ -98,6 +99,7 @@ public class GameRules {
|
||||
protected Boolean playerVersusPlayer;
|
||||
protected Boolean friendlyFire;
|
||||
protected Integer initialLives;
|
||||
protected Integer initialGroupLives;
|
||||
|
||||
/* Timer */
|
||||
protected Integer timeLastPlayed;
|
||||
@ -223,6 +225,13 @@ public class GameRules {
|
||||
return initialLives;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the initial amount of group lives
|
||||
*/
|
||||
public int getInitialGroupLives() {
|
||||
return initialGroupLives;
|
||||
}
|
||||
|
||||
// Timer
|
||||
/**
|
||||
* @return the timeLastPlayed
|
||||
@ -411,6 +420,10 @@ public class GameRules {
|
||||
if (gameMode == null) {
|
||||
gameMode = defaultValues.getGameMode();
|
||||
}
|
||||
|
||||
if (initialLives == null) {
|
||||
initialLives = defaultValues.hasLives() ? null : -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -477,6 +490,10 @@ public class GameRules {
|
||||
initialLives = defaultValues.initialLives;
|
||||
}
|
||||
|
||||
if (initialGroupLives == null) {
|
||||
initialGroupLives = defaultValues.initialGroupLives;
|
||||
}
|
||||
|
||||
/* Timer */
|
||||
if (timeLastPlayed == null) {
|
||||
timeLastPlayed = defaultValues.timeLastPlayed;
|
||||
|
@ -23,6 +23,17 @@ import org.bukkit.GameMode;
|
||||
*/
|
||||
public interface GameType {
|
||||
|
||||
/**
|
||||
* @return if the game ends when one group is left
|
||||
*/
|
||||
public Boolean isLastManStanding();
|
||||
|
||||
/**
|
||||
* @param lastManStanding
|
||||
* set if the game ends when one group is left
|
||||
*/
|
||||
public void setLastManStanding(Boolean lastManStanding);
|
||||
|
||||
/**
|
||||
* @return the displayName
|
||||
*/
|
||||
|
@ -23,26 +23,27 @@ import org.bukkit.GameMode;
|
||||
*/
|
||||
public enum GameTypeDefault implements GameType {
|
||||
|
||||
ADVENTURE("Adventure", "Adventure", false, false, false, true, false, true, true, true, GameMode.ADVENTURE, true),
|
||||
ADVENTURE_TIME_IS_RUNNING("Adventure - Time is Running", "Adventure TiR", false, false, false, true, true, true, true, true, GameMode.ADVENTURE, true),
|
||||
APOCALYPSE_LAST_MAN_STANDING("Apocalypse", "Apocalypse LMS", true, true, true, true, false, false, false, false, GameMode.SURVIVAL, true),
|
||||
APOCALYPSE_LIMITED_MOBS("Apocalypse - Limited Mobs", "Apc Limited", true, true, true, true, false, false, false, false, GameMode.SURVIVAL, true),
|
||||
APOCALYPSE_TIME_IS_RUNNING("Apocalypse - Time is Running", "Apocalypse TiR", true, true, true, true, true, false, false, false, GameMode.SURVIVAL, true),
|
||||
BEDWARS("Bedwars", "Bedwars", true, false, false, false, false, false, true, true, GameMode.SURVIVAL, true),
|
||||
PVE_LAST_MAN_STANDING("Player versus Environment - Last Man Standing", "PvE LMS", false, false, true, true, false, false, false, false, GameMode.SURVIVAL, true),
|
||||
PVE_LIMITED_MOBS("Player versus Environment - Limited Mobs", "PvE Limited", false, false, true, true, false, false, false, false, GameMode.SURVIVAL, true),
|
||||
PVE_TIME_IS_RUNNING("Player versus Environment - Time is Running", "PvE TiR", false, false, true, true, true, false, false, false, GameMode.SURVIVAL, true),
|
||||
PVP_FACTIONS_BATTLEFIELD("Player versus Player - Factions Battlefield", "FactionsPvP", true, false, false, false, false, false, false, false, GameMode.SURVIVAL, true),
|
||||
PVP_LAST_MAN_STANDING("Player versus Player - Last Man Standing", "PvP LMS", true, false, false, false, false, false, false, false, GameMode.SURVIVAL, true),
|
||||
QUEST("Quest", "Quest", false, false, false, true, false, false, false, false, GameMode.SURVIVAL, true),
|
||||
QUEST_TIME_IS_RUNNING("Quest - Time is Running", "Quest TiR", false, false, false, true, true, false, false, false, GameMode.SURVIVAL, true),
|
||||
TEST("Test", "Test", false, false, false, false, true, true, true, true, GameMode.SURVIVAL, false),
|
||||
TUTORIAL("Tutorial", "Tutorial", false, false, false, true, false, false, false, false, GameMode.SURVIVAL, false),
|
||||
DEFAULT("Default", "Default", false, false, false, true, false, false, false, false, GameMode.SURVIVAL, true),
|
||||
ADVENTURE("Adventure", "Adventure", false, false, false, false, true, false, true, true, true, GameMode.ADVENTURE, true),
|
||||
ADVENTURE_TIME_IS_RUNNING("Adventure - Time is Running", "Adventure TiR", false, false, false, false, true, true, true, true, true, GameMode.ADVENTURE, true),
|
||||
APOCALYPSE_LAST_MAN_STANDING("Apocalypse", "Apocalypse LMS", true, true, true, true, true, false, false, false, false, GameMode.SURVIVAL, true),
|
||||
APOCALYPSE_LIMITED_MOBS("Apocalypse - Limited Mobs", "Apc Limited", false, true, true, true, true, false, false, false, false, GameMode.SURVIVAL, true),
|
||||
APOCALYPSE_TIME_IS_RUNNING("Apocalypse - Time is Running", "Apocalypse TiR", false, true, true, true, true, true, false, false, false, GameMode.SURVIVAL, true),
|
||||
BEDWARS("Bedwars", "Bedwars", true, true, false, false, false, false, false, true, true, GameMode.SURVIVAL, false),
|
||||
PVE_LAST_MAN_STANDING("Player versus Environment - Last Man Standing", "PvE LMS", true, false, false, true, true, false, false, false, false, GameMode.SURVIVAL, true),
|
||||
PVE_LIMITED_MOBS("Player versus Environment - Limited Mobs", "PvE Limited", false, false, false, true, true, false, false, false, false, GameMode.SURVIVAL, true),
|
||||
PVE_TIME_IS_RUNNING("Player versus Environment - Time is Running", "PvE TiR", false, false, false, true, true, true, false, false, false, GameMode.SURVIVAL, true),
|
||||
PVP_FACTIONS_BATTLEFIELD("Player versus Player - Factions Battlefield", "FactionsPvP", true, true, false, false, false, false, false, false, false, GameMode.SURVIVAL, true),
|
||||
PVP_LAST_MAN_STANDING("Player versus Player - Last Man Standing", "PvP LMS", true, true, false, false, false, false, false, false, false, GameMode.SURVIVAL, true),
|
||||
QUEST("Quest", "Quest", false, false, false, false, true, false, false, false, false, GameMode.SURVIVAL, true),
|
||||
QUEST_TIME_IS_RUNNING("Quest - Time is Running", "Quest TiR", false, false, false, false, true, true, false, false, false, GameMode.SURVIVAL, true),
|
||||
TEST("Test", "Test", false, false, false, false, false, true, true, true, true, GameMode.SURVIVAL, false),
|
||||
TUTORIAL("Tutorial", "Tutorial", false, false, false, false, true, false, false, false, false, GameMode.SURVIVAL, false),
|
||||
DEFAULT("Default", "Default", false, false, false, false, true, false, false, false, false, GameMode.SURVIVAL, true),
|
||||
CUSTOM("Custom", "Custom");
|
||||
|
||||
private String displayName;
|
||||
private String signName;
|
||||
private Boolean lastManStanding;
|
||||
private Boolean playerVersusPlayer;
|
||||
private Boolean friendlyFire;
|
||||
private Boolean mobWaves;
|
||||
@ -54,10 +55,11 @@ public enum GameTypeDefault implements GameType {
|
||||
private GameMode gameMode;
|
||||
private Boolean lives;
|
||||
|
||||
GameTypeDefault(String displayName, String signName, Boolean playerVersusPlayer, Boolean friendlyFire, Boolean mobWaves, Boolean rewards,
|
||||
GameTypeDefault(String displayName, String signName, Boolean lastManStanding, Boolean playerVersusPlayer, Boolean friendlyFire, Boolean mobWaves, Boolean rewards,
|
||||
Boolean showTime, Boolean breakBlocks, Boolean breakPlacedBlocks, Boolean placeBlocks, GameMode gameMode, Boolean lives) {
|
||||
this.displayName = displayName;
|
||||
this.signName = signName;
|
||||
this.lastManStanding = lastManStanding;
|
||||
this.playerVersusPlayer = playerVersusPlayer;
|
||||
this.friendlyFire = friendlyFire;
|
||||
this.mobWaves = mobWaves;
|
||||
@ -75,6 +77,16 @@ public enum GameTypeDefault implements GameType {
|
||||
this.signName = signName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isLastManStanding() {
|
||||
return lastManStanding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastManStanding(Boolean lastManStanding) {
|
||||
this.lastManStanding = lastManStanding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
|
@ -21,7 +21,6 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||
import io.github.dre2n.dungeonsxl.config.MainConfig;
|
||||
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
|
||||
import io.github.dre2n.dungeonsxl.event.dplayer.instance.game.DGamePlayerDeathEvent;
|
||||
import io.github.dre2n.dungeonsxl.game.Game;
|
||||
import io.github.dre2n.dungeonsxl.global.DPortal;
|
||||
import io.github.dre2n.dungeonsxl.global.GameSign;
|
||||
@ -87,54 +86,11 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onDeath(PlayerDeathEvent event) {
|
||||
Player player = event.getEntity();
|
||||
|
||||
DGameWorld gameWorld = DGameWorld.getByWorld(player.getLocation().getWorld());
|
||||
if (gameWorld == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Game game = Game.getByGameWorld(gameWorld);
|
||||
if (game == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
DGamePlayer dPlayer = DGamePlayer.getByPlayer(player);
|
||||
if (dPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
DGamePlayerDeathEvent dPlayerDeathEvent = new DGamePlayerDeathEvent(dPlayer, event, 1);
|
||||
plugin.getServer().getPluginManager().callEvent(dPlayerDeathEvent);
|
||||
|
||||
if (dPlayerDeathEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (gameWorld.getGame() != null) {
|
||||
if (!gameWorld.getGame().getType().hasLives()) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (dPlayer.getLives() != -1) {
|
||||
dPlayer.setLives(dPlayer.getLives() - dPlayerDeathEvent.getLostLives());
|
||||
MessageUtil.sendMessage(player, DMessages.PLAYER_DEATH.getMessage(String.valueOf(dPlayer.getLives())));
|
||||
|
||||
if (game.getRules().getKeepInventoryOnDeath()) {
|
||||
dPlayer.setRespawnInventory(event.getEntity().getInventory().getContents());
|
||||
dPlayer.setRespawnArmor(event.getEntity().getInventory().getArmorContents());
|
||||
// Delete all drops
|
||||
for (ItemStack item : event.getDrops()) {
|
||||
item.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dPlayer.getLives() == 0 && dPlayer.isReady()) {
|
||||
dPlayer.kill();
|
||||
}
|
||||
dPlayer.onDeath(event);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@ -470,11 +426,11 @@ public class PlayerListener implements Listener {
|
||||
((DGamePlayer) dPlayer).leave();
|
||||
|
||||
} else if (timeUntilKickOfflinePlayer > 0) {
|
||||
dGroup.sendMessage(DMessages.PLAYER_OFFLINE.getMessage(dPlayer.getPlayer().getName(), String.valueOf(timeUntilKickOfflinePlayer)), player);
|
||||
dGroup.sendMessage(DMessages.PLAYER_OFFLINE.getMessage(dPlayer.getName(), String.valueOf(timeUntilKickOfflinePlayer)), player);
|
||||
((DGamePlayer) dPlayer).setOfflineTime(System.currentTimeMillis() + timeUntilKickOfflinePlayer * 1000);
|
||||
|
||||
} else {
|
||||
dGroup.sendMessage(DMessages.PLAYER_OFFLINE_NEVER.getMessage(dPlayer.getPlayer().getName()), player);
|
||||
dGroup.sendMessage(DMessages.PLAYER_OFFLINE_NEVER.getMessage(dPlayer.getName()), player);
|
||||
}
|
||||
|
||||
} else if (dPlayer instanceof DEditPlayer) {
|
||||
|
@ -207,7 +207,7 @@ public class DEditPlayer extends DInstancePlayer {
|
||||
|
||||
public static DEditPlayer getByName(String name) {
|
||||
for (DEditPlayer dPlayer : plugin.getDPlayers().getDEditPlayers()) {
|
||||
if (dPlayer.getPlayer().getName().equalsIgnoreCase(name)) {
|
||||
if (dPlayer.getName().equalsIgnoreCase(name)) {
|
||||
return dPlayer;
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import io.github.dre2n.dungeonsxl.event.dgroup.DGroupFinishDungeonEvent;
|
||||
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupRewardEvent;
|
||||
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerKickEvent;
|
||||
import io.github.dre2n.dungeonsxl.event.dplayer.instance.DInstancePlayerUpdateEvent;
|
||||
import io.github.dre2n.dungeonsxl.event.dplayer.instance.game.DGamePlayerDeathEvent;
|
||||
import io.github.dre2n.dungeonsxl.event.dplayer.instance.game.DGamePlayerFinishEvent;
|
||||
import io.github.dre2n.dungeonsxl.event.requirement.RequirementCheckEvent;
|
||||
import io.github.dre2n.dungeonsxl.game.Game;
|
||||
@ -39,6 +40,7 @@ import io.github.dre2n.dungeonsxl.task.CreateDInstancePlayerTask;
|
||||
import io.github.dre2n.dungeonsxl.trigger.DistanceTrigger;
|
||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.block.TeamFlag;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -51,6 +53,7 @@ import org.bukkit.entity.Damageable;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
@ -62,6 +65,8 @@ import org.bukkit.potion.PotionEffect;
|
||||
public class DGamePlayer extends DInstancePlayer {
|
||||
|
||||
// Variables
|
||||
private DGroup dGroup;
|
||||
|
||||
private boolean ready = false;
|
||||
private boolean finished = false;
|
||||
|
||||
@ -131,6 +136,25 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
}
|
||||
|
||||
/* Getters and setters */
|
||||
@Override
|
||||
public String getName() {
|
||||
String name = player.getName();
|
||||
if (getDGroup() != null && dGroup.getDColor() != null) {
|
||||
name = getDGroup().getDColor().getChatColor() + name;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the DGroup of this player
|
||||
*/
|
||||
public DGroup getDGroup() {
|
||||
if (dGroup == null) {
|
||||
dGroup = DGroup.getByPlayer(player);
|
||||
}
|
||||
return dGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* the player to set
|
||||
@ -143,8 +167,7 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
* @return if the player is in test mode
|
||||
*/
|
||||
public boolean isInTestMode() {
|
||||
DGroup dGroup = DGroup.getByPlayer(getPlayer());
|
||||
if (dGroup == null) {
|
||||
if (getDGroup() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -386,6 +409,10 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
* the group whose flag is stolen
|
||||
*/
|
||||
public void setRobbedGroup(DGroup dGroup) {
|
||||
if (dGroup != null) {
|
||||
player.getInventory().getHelmet().setType(Material.WOOL);
|
||||
}
|
||||
|
||||
stealing = dGroup;
|
||||
}
|
||||
|
||||
@ -400,7 +427,6 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
* if messages should be sent
|
||||
*/
|
||||
public void leave(boolean message) {
|
||||
plugin.debug.start("DGamePlayer#leave");
|
||||
GameRules rules = Game.getByWorld(getWorld()).getRules();
|
||||
delete();
|
||||
|
||||
@ -417,8 +443,7 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
}
|
||||
}
|
||||
|
||||
DGroup dGroup = DGroup.getByPlayer(getPlayer());
|
||||
if (dGroup != null) {
|
||||
if (getDGroup() != null) {
|
||||
dGroup.removePlayer(getPlayer(), message);
|
||||
}
|
||||
|
||||
@ -431,7 +456,7 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
reward.giveTo(getPlayer());
|
||||
}
|
||||
|
||||
getData().logTimeLastPlayed(dGroup.getDungeon().getName());
|
||||
getData().logTimeLastPlayed(getDGroup().getDungeon().getName());
|
||||
|
||||
// Tutorial Permissions
|
||||
if (gameWorld.isTutorial() && plugin.getPermissionProvider() != null && plugin.getPermissionProvider().hasGroupSupport()) {
|
||||
@ -449,7 +474,7 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
}
|
||||
}
|
||||
|
||||
if (dGroup != null) {
|
||||
if (getDGroup() != null) {
|
||||
if (!dGroup.isEmpty()) {
|
||||
if (dGroup.finishIfMembersFinished()) {
|
||||
return;
|
||||
@ -483,7 +508,6 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
// ...*flies away*
|
||||
}
|
||||
}
|
||||
plugin.debug.end("DGamePlayer#leave", true);
|
||||
}
|
||||
|
||||
public void kill() {
|
||||
@ -491,7 +515,13 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
plugin.getServer().getPluginManager().callEvent(dPlayerKickEvent);
|
||||
|
||||
if (!dPlayerKickEvent.isCancelled()) {
|
||||
MessageUtil.broadcastMessage(DMessages.PLAYER_DEATH_KICK.getMessage(player.getName()));
|
||||
DGameWorld gameWorld = getDGroup().getGameWorld();
|
||||
if (lives != -1) {
|
||||
gameWorld.sendMessage(DMessages.PLAYER_DEATH_KICK.getMessage(getName()));
|
||||
} else if (getDGroup().getLives() != -1) {
|
||||
gameWorld.sendMessage(DMessages.GROUP_DEATH_KICK.getMessage(getName(), dGroup.getName()));
|
||||
}
|
||||
|
||||
GameRules rules = Game.getByPlayer(player).getRules();
|
||||
leave();
|
||||
if (rules.getKeepInventoryOnEscape() && rules.getKeepInventoryOnDeath()) {
|
||||
@ -602,9 +632,7 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
}
|
||||
|
||||
public void ready(GameType gameType) {
|
||||
DGroup dGroup = DGroup.getByPlayer(getPlayer());
|
||||
|
||||
if (dGroup == null) {
|
||||
if (getDGroup() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -635,12 +663,10 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
}
|
||||
|
||||
public void respawn() {
|
||||
DGroup dGroup = DGroup.getByPlayer(getPlayer());
|
||||
|
||||
Location respawn = checkpoint;
|
||||
|
||||
if (respawn == null) {
|
||||
respawn = dGroup.getGameWorld().getStartLocation(dGroup);
|
||||
respawn = getDGroup().getGameWorld().getStartLocation(dGroup);
|
||||
}
|
||||
|
||||
if (respawn == null) {
|
||||
@ -669,18 +695,14 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
* the name of the next floor
|
||||
*/
|
||||
public void finishFloor(DResourceWorld specifiedFloor) {
|
||||
plugin.debug.start("DGamePlayer#finishFloor");
|
||||
MessageUtil.sendMessage(getPlayer(), DMessages.PLAYER_FINISHED_DUNGEON.getMessage());
|
||||
finished = true;
|
||||
|
||||
DGroup dGroup = DGroup.getByPlayer(getPlayer());
|
||||
if (dGroup == null) {
|
||||
plugin.debug.end("DGamePlayer#finishFloor", true);
|
||||
if (getDGroup() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!dGroup.isPlaying()) {
|
||||
plugin.debug.end("DGamePlayer#finishFloor", true);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -764,20 +786,16 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
* if messages should be sent
|
||||
*/
|
||||
public void finish(boolean message) {
|
||||
plugin.debug.start("DGamePlayer#finish");
|
||||
if (message) {
|
||||
MessageUtil.sendMessage(getPlayer(), DMessages.PLAYER_FINISHED_DUNGEON.getMessage());
|
||||
}
|
||||
finished = true;
|
||||
|
||||
DGroup dGroup = DGroup.getByPlayer(getPlayer());
|
||||
if (dGroup == null) {
|
||||
plugin.debug.end("DGamePlayer#finish", true);
|
||||
if (getDGroup() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!dGroup.isPlaying()) {
|
||||
plugin.debug.end("DGamePlayer#finish", true);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -801,12 +819,10 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
|
||||
if (dPlayerFinishEvent.isCancelled()) {
|
||||
finished = false;
|
||||
plugin.debug.end("DGamePlayer#finish", true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasToWait) {
|
||||
plugin.debug.end("DGamePlayer#finish", true);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -847,6 +863,72 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
}
|
||||
}
|
||||
|
||||
public void onDeath(PlayerDeathEvent event) {
|
||||
DGameWorld gameWorld = DGameWorld.getByWorld(player.getLocation().getWorld());
|
||||
if (gameWorld == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Game game = Game.getByGameWorld(gameWorld);
|
||||
if (game == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
DGamePlayerDeathEvent dPlayerDeathEvent = new DGamePlayerDeathEvent(this, event, 1);
|
||||
plugin.getServer().getPluginManager().callEvent(dPlayerDeathEvent);
|
||||
|
||||
if (dPlayerDeathEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (lives != -1) {
|
||||
lives = lives - dPlayerDeathEvent.getLostLives();
|
||||
|
||||
DGamePlayer killer = DGamePlayer.getByPlayer(player.getKiller());
|
||||
if (killer != null) {
|
||||
gameWorld.sendMessage(DMessages.PLAYER_KILLED.getMessage(getName(), killer.getName(), String.valueOf(lives)));
|
||||
} else {
|
||||
gameWorld.sendMessage(DMessages.PLAYER_DEATH.getMessage(getName(), String.valueOf(lives)));
|
||||
}
|
||||
|
||||
if (game.getRules().getKeepInventoryOnDeath()) {
|
||||
setRespawnInventory(event.getEntity().getInventory().getContents());
|
||||
setRespawnArmor(event.getEntity().getInventory().getArmorContents());
|
||||
// Delete all drops
|
||||
for (ItemStack item : event.getDrops()) {
|
||||
item.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
} else if (getDGroup() != null && dGroup.getLives() != -1) {
|
||||
dGroup.setLives(dGroup.getLives() - 1);
|
||||
MessageUtil.broadcastMessage(DMessages.GROUP_DEATH.getMessage(player.getName(), String.valueOf(lives)));
|
||||
}
|
||||
|
||||
if (isStealing()) {
|
||||
for (TeamFlag teamFlag : gameWorld.getTeamFlags()) {
|
||||
if (teamFlag.getOwner().equals(stealing)) {
|
||||
teamFlag.reset();
|
||||
gameWorld.sendMessage(DMessages.GROUP_FLAG_LOST.getMessage(player.getName(), stealing.getName()));
|
||||
stealing = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lives == 0 && ready) {
|
||||
kill();
|
||||
}
|
||||
|
||||
GameType gameType = game.getType();
|
||||
if (gameType != null && gameType != GameTypeDefault.CUSTOM) {
|
||||
if (gameType.isLastManStanding()) {
|
||||
if (game.getDGroups().size() == 1) {
|
||||
game.getDGroups().get(0).winGame();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(boolean updateSecond) {
|
||||
boolean locationValid = true;
|
||||
@ -864,12 +946,10 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
locationValid = false;
|
||||
|
||||
if (gameWorld != null) {
|
||||
DGroup dGroup = DGroup.getByPlayer(getPlayer());
|
||||
|
||||
teleportLocation = getCheckpoint();
|
||||
|
||||
if (teleportLocation == null) {
|
||||
teleportLocation = dGroup.getGameWorld().getStartLocation(dGroup);
|
||||
teleportLocation = getDGroup().getGameWorld().getStartLocation(getDGroup());
|
||||
}
|
||||
|
||||
// Don't forget Doge!
|
||||
@ -959,10 +1039,11 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
|
||||
public static DGamePlayer getByName(String name) {
|
||||
for (DGamePlayer dPlayer : plugin.getDPlayers().getDGamePlayers()) {
|
||||
if (dPlayer.getPlayer().getName().equalsIgnoreCase(name)) {
|
||||
if (dPlayer.getPlayer().getName().equalsIgnoreCase(name) || dPlayer.getName().equalsIgnoreCase(name)) {
|
||||
return dPlayer;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -79,6 +79,13 @@ public class DGlobalPlayer {
|
||||
}
|
||||
|
||||
/* Getters and setters */
|
||||
/**
|
||||
* @return the player's name
|
||||
*/
|
||||
public String getName() {
|
||||
return player.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Bukkit player
|
||||
*/
|
||||
|
@ -31,6 +31,7 @@ import io.github.dre2n.dungeonsxl.global.GroupSign;
|
||||
import io.github.dre2n.dungeonsxl.requirement.Requirement;
|
||||
import io.github.dre2n.dungeonsxl.reward.Reward;
|
||||
import io.github.dre2n.dungeonsxl.task.TimeIsRunningTask;
|
||||
import io.github.dre2n.dungeonsxl.util.DColor;
|
||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
||||
import java.util.ArrayList;
|
||||
@ -64,6 +65,9 @@ public class DGroup {
|
||||
private List<Reward> rewards = new ArrayList<>();
|
||||
private BukkitTask timeIsRunningTask;
|
||||
private DResourceWorld nextFloor;
|
||||
private DColor color;
|
||||
private int initialLives = -1;
|
||||
private int lives = -1;
|
||||
|
||||
public DGroup(Player player) {
|
||||
this("Group_" + plugin.getDGroups().size(), player);
|
||||
@ -89,7 +93,6 @@ public class DGroup {
|
||||
}
|
||||
|
||||
public DGroup(String name, Player captain, List<Player> players, String identifier, boolean multiFloor) {
|
||||
plugin.debug.start("DGroup#init4");
|
||||
plugin.getDGroups().add(this);
|
||||
this.name = name;
|
||||
|
||||
@ -120,14 +123,20 @@ public class DGroup {
|
||||
|
||||
playing = false;
|
||||
floorCount = 0;
|
||||
plugin.debug.end("DGroup#init4", true);
|
||||
}
|
||||
|
||||
// Getters and setters
|
||||
/**
|
||||
* @return the name
|
||||
* @return the name; formatted
|
||||
*/
|
||||
public String getName() {
|
||||
return (color != null ? color.getChatColor().toString() : new String()) + name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name; not formatted
|
||||
*/
|
||||
public String getRawName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@ -558,6 +567,54 @@ public class DGroup {
|
||||
nextFloor = floor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the color that represents this group
|
||||
*/
|
||||
public DColor getDColor() {
|
||||
if (color != null) {
|
||||
return color;
|
||||
} else {
|
||||
return DColor.DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param color the group color to set
|
||||
*/
|
||||
public void setDColor(DColor color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the initial group lives
|
||||
*/
|
||||
public int getInitialLives() {
|
||||
return initialLives;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param initialLives
|
||||
* the initial group lives to set
|
||||
*/
|
||||
public void setInitialLives(int initialLives) {
|
||||
this.initialLives = initialLives;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the group lives
|
||||
*/
|
||||
public int getLives() {
|
||||
return lives;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lives
|
||||
* the group lives to set
|
||||
*/
|
||||
public void setLives(int lives) {
|
||||
this.lives = lives;
|
||||
}
|
||||
|
||||
/* Actions */
|
||||
/**
|
||||
* Remove the group from the List
|
||||
@ -579,11 +636,13 @@ public class DGroup {
|
||||
}
|
||||
|
||||
public void startGame(Game game) {
|
||||
plugin.debug.start("DGroup#startGame");
|
||||
if (game == null) {
|
||||
return;
|
||||
}
|
||||
game.fetchRules();
|
||||
GameRules rules = game.getRules();
|
||||
|
||||
color = plugin.getMainConfig().getGroupColorPriority().get(game.getDGroups().indexOf(this));
|
||||
|
||||
for (DGroup dGroup : game.getDGroups()) {
|
||||
if (dGroup == null) {
|
||||
@ -603,7 +662,6 @@ public class DGroup {
|
||||
}
|
||||
|
||||
if (!ready) {
|
||||
plugin.debug.end("DGroup#startGame", true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -612,7 +670,6 @@ public class DGroup {
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
plugin.debug.end("DGroup#startGame", true);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -643,8 +700,6 @@ public class DGroup {
|
||||
}
|
||||
}
|
||||
|
||||
GameRules rules = game.getRules();
|
||||
|
||||
for (Requirement requirement : rules.getRequirements()) {
|
||||
RequirementDemandEvent requirementDemandEvent = new RequirementDemandEvent(requirement, player);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
@ -671,7 +726,17 @@ public class DGroup {
|
||||
|
||||
GroupSign.updatePerGroup(this);
|
||||
nextFloor = null;
|
||||
plugin.debug.end("DGroup#startGame", true);
|
||||
initialLives = rules.getInitialGroupLives();
|
||||
lives = initialLives;
|
||||
}
|
||||
|
||||
public void winGame() {
|
||||
String title = DMessages.GROUP_CONGRATS.getMessage();
|
||||
String subtitle = DMessages.GROUP_CONGRATS_SUB.getMessage(getName());
|
||||
for (DGamePlayer player : getDGamePlayers()) {
|
||||
player.leave(false);
|
||||
MessageUtil.sendTitleMessage(player.getPlayer(), title, subtitle, 20, 20, 100);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkTime(Game game) {
|
||||
@ -748,7 +813,7 @@ public class DGroup {
|
||||
/* Statics */
|
||||
public static DGroup getByName(String name) {
|
||||
for (DGroup dGroup : plugin.getDGroups()) {
|
||||
if (dGroup.getName().equals(name)) {
|
||||
if (dGroup.getName().equalsIgnoreCase(name) || dGroup.getRawName().equalsIgnoreCase(name)) {
|
||||
return dGroup;
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class FlagSign extends DSign {
|
||||
@Override
|
||||
public void onInit() {
|
||||
this.team = NumberUtil.parseInt(lines[1]);
|
||||
getGameWorld().addGameBlock(new TeamFlag(getSign().getBlock(), team, getGame().getDGroups().get(team)));
|
||||
getGameWorld().addGameBlock(new TeamFlag(getSign().getBlock(), getGame().getDGroups().get(team)));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -93,9 +93,7 @@ public class LivesModifierSign extends DSign {
|
||||
break;
|
||||
|
||||
case GROUP:
|
||||
for (DGamePlayer dPlayer : DGroup.getByPlayer(player).getDGamePlayers()) {
|
||||
modifyLives(dPlayer);
|
||||
}
|
||||
modifyLives(DGroup.getByPlayer(player));
|
||||
break;
|
||||
|
||||
case PLAYER:
|
||||
@ -119,6 +117,16 @@ public class LivesModifierSign extends DSign {
|
||||
}
|
||||
}
|
||||
|
||||
public void modifyLives(DGroup dGroup) {
|
||||
dGroup.setLives(dGroup.getLives() + lives);
|
||||
if (lives > 0) {
|
||||
dGroup.sendMessage(DMessages.GROUP_LIVES_ADDED.getMessage(String.valueOf(lives)));
|
||||
|
||||
} else {
|
||||
dGroup.sendMessage(DMessages.GROUP_LIVES_REMOVED.getMessage(String.valueOf(-1 * lives)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DSignType getType() {
|
||||
return type;
|
||||
|
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2016 Frank Baumann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package io.github.dre2n.dungeonsxl.util;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.DyeColor;
|
||||
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public enum DColor {
|
||||
|
||||
BLACK(ChatColor.BLACK, DyeColor.BLACK),
|
||||
DARK_GRAY(ChatColor.DARK_GRAY, DyeColor.GRAY),
|
||||
LIGHT_GRAY(ChatColor.GRAY, DyeColor.SILVER),
|
||||
WHITE(ChatColor.WHITE, DyeColor.WHITE),
|
||||
DARK_GREEN(ChatColor.DARK_GREEN, DyeColor.GREEN),
|
||||
LIGHT_GREEN(ChatColor.GREEN, DyeColor.LIME),
|
||||
CYAN(ChatColor.DARK_AQUA, DyeColor.CYAN),
|
||||
DARK_BLUE(ChatColor.DARK_BLUE, DyeColor.BLUE),
|
||||
LIGHT_BLUE(ChatColor.AQUA, DyeColor.LIGHT_BLUE),
|
||||
PURPLE(ChatColor.DARK_PURPLE, DyeColor.PURPLE),
|
||||
MAGENTA(ChatColor.LIGHT_PURPLE, DyeColor.MAGENTA),
|
||||
DARK_RED(ChatColor.DARK_RED, DyeColor.BROWN),
|
||||
LIGHT_RED(ChatColor.RED, DyeColor.RED),
|
||||
ORANGE(ChatColor.GOLD, DyeColor.ORANGE),
|
||||
YELLOW(ChatColor.YELLOW, DyeColor.YELLOW),
|
||||
DEFAULT(ChatColor.BLUE, DyeColor.PINK);
|
||||
|
||||
private ChatColor chat;
|
||||
private DyeColor dye;
|
||||
|
||||
DColor(ChatColor chat, DyeColor dye) {
|
||||
this.chat = chat;
|
||||
this.dye = dye;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ChatColor
|
||||
*/
|
||||
public ChatColor getChatColor() {
|
||||
return chat;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the DyeColor
|
||||
*/
|
||||
public DyeColor getDyeColor() {
|
||||
return dye;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the RGB value
|
||||
*/
|
||||
public int getRGBColor() {
|
||||
return dye.getColor().asRGB();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the wool DV
|
||||
*/
|
||||
public byte getWoolData() {
|
||||
return dye.getWoolData();
|
||||
}
|
||||
|
||||
}
|
@ -80,8 +80,9 @@ public class TeamBed extends TeamBlock implements MultiBlock {
|
||||
for (DGamePlayer player : owner.getDGamePlayers()) {
|
||||
player.setLives(1);
|
||||
}
|
||||
owner.setLives(0);
|
||||
|
||||
owner.getGameWorld().sendMessage(DMessages.GROUP_BED_DESTROYED.getMessage(owner.getName(), breaker.getName()));
|
||||
owner.getGameWorld().sendMessage(DMessages.GROUP_BED_DESTROYED.getMessage(owner.getName(), DGamePlayer.getByPlayer(breaker).getName()));
|
||||
Block block1 = event.getBlock();
|
||||
if (((Bed) block1.getState().getData()).isHeadOfBed()) {
|
||||
Block block2 = getAttachedBlock(block1);
|
||||
|
@ -35,11 +35,8 @@ public class TeamFlag extends TeamBlock {
|
||||
|
||||
public static final int WOOL = 35;
|
||||
|
||||
private byte teamId;
|
||||
|
||||
public TeamFlag(Block block, int teamId, DGroup owner) {
|
||||
public TeamFlag(Block block, DGroup owner) {
|
||||
super(block, owner);
|
||||
this.teamId = plugin.getMainConfig().getGroupColorPriority().get(teamId).byteValue();
|
||||
reset();
|
||||
}
|
||||
|
||||
@ -48,7 +45,7 @@ public class TeamFlag extends TeamBlock {
|
||||
* Reset a team flag when the capturer dies.
|
||||
*/
|
||||
public void reset() {
|
||||
block.setTypeIdAndData(WOOL, teamId, false);
|
||||
block.setTypeIdAndData(WOOL, owner.getDColor().getWoolData(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,10 +23,11 @@ import org.bukkit.GameMode;
|
||||
*/
|
||||
public enum CustomGameType implements GameType {
|
||||
|
||||
GHOST("My awesome game type", "Identifier", false, false, false, false, false, false, false, false, GameMode.SPECTATOR, false);
|
||||
GHOST("My awesome game type", "Identifier", false, false, false, false, false, false, false, false, false, GameMode.SPECTATOR, false);
|
||||
|
||||
private String displayName;
|
||||
private String signName;
|
||||
private Boolean lastManStanding;
|
||||
private Boolean playerVersusPlayer;
|
||||
private Boolean friendlyFire;
|
||||
private Boolean mobWaves;
|
||||
@ -38,10 +39,11 @@ public enum CustomGameType implements GameType {
|
||||
private GameMode gameMode;
|
||||
private Boolean lives;
|
||||
|
||||
CustomGameType(String displayName, String signName, Boolean playerVersusPlayer, Boolean friendlyFire, Boolean mobWaves, Boolean rewards,
|
||||
CustomGameType(String displayName, String signName, Boolean lastManStanding, Boolean playerVersusPlayer, Boolean friendlyFire, Boolean mobWaves, Boolean rewards,
|
||||
Boolean showTime, Boolean breakBlocks, Boolean breakPlacedBlocks, Boolean placeBlocks, GameMode gameMode, Boolean lives) {
|
||||
this.displayName = displayName;
|
||||
this.signName = signName;
|
||||
this.lastManStanding = lastManStanding;
|
||||
this.playerVersusPlayer = playerVersusPlayer;
|
||||
this.friendlyFire = friendlyFire;
|
||||
this.mobWaves = mobWaves;
|
||||
@ -74,6 +76,16 @@ public enum CustomGameType implements GameType {
|
||||
this.signName = signName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isLastManStanding() {
|
||||
return lastManStanding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastManStanding(Boolean lastManStanding) {
|
||||
this.lastManStanding = lastManStanding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isPlayerVersusPlayer() {
|
||||
return playerVersusPlayer;
|
||||
|
Loading…
Reference in New Issue
Block a user