mirror of
https://github.com/taoneill/war.git
synced 2025-02-02 12:41:22 +01:00
Why was bin in repo?!
General reorganizin
This commit is contained in:
parent
f743ddeb15
commit
50ebc9ad0c
4
.gitignore
vendored
4
.gitignore
vendored
@ -9,6 +9,6 @@
|
||||
*.class
|
||||
|
||||
# Ignore bin
|
||||
*/bin/*
|
||||
bin
|
||||
*/lib/*
|
||||
*/target/*
|
||||
*/target/*
|
||||
|
170
bin/plugin.yml
170
bin/plugin.yml
@ -1,170 +0,0 @@
|
||||
name: War
|
||||
version: 1.6 (de Gaulle) PREVIEW 3
|
||||
description: Lets you create TDM and CTF (warzones) for a more structured PVP experience.
|
||||
author: tommytony
|
||||
website: war.tommytony.com
|
||||
main: bukkit.tommytony.war.War
|
||||
commands:
|
||||
# Player commands
|
||||
warzones:
|
||||
description: (War) Lists the warzones on the server. Each warzone is an independent TDM arena.
|
||||
usage: /warzones
|
||||
zones:
|
||||
description: (War) Shortcut for /warzones.
|
||||
usage: /zones
|
||||
warzone:
|
||||
description: (War) Teleports you to the specified warzone's lobby.
|
||||
usage: /warzone ziggy
|
||||
zone:
|
||||
description: (War) Shortcut for /warzone.
|
||||
usage: /zone ziggy
|
||||
warhub:
|
||||
description: (War) Teleports you to the warhub, if it exists. The warhub offers portals to reach each warzone on the server.
|
||||
usage: /warhub
|
||||
teams:
|
||||
description: (War) Lists the teams in the warzone.
|
||||
usage:
|
||||
- Must be standing in warzone or lobby.
|
||||
- /teams
|
||||
join:
|
||||
description: (War) Use to change teams. Also used instead of walking in the team gate in the lobby.
|
||||
usage:
|
||||
- Must be standing in warzone or lobby.
|
||||
- /join <team color>
|
||||
leave:
|
||||
description: (War) Use to leave a warzone. Teleports you back to the lobby.
|
||||
usage:
|
||||
- Must be in team already.
|
||||
- /leave
|
||||
team:
|
||||
description: (War) Team chat.
|
||||
usage: /team Leeeroooy!!!
|
||||
# Warzone maker commands (must have the 'war.*' permission or be added as a zone-maker in /plugins/War/war.txt
|
||||
# 1- Battle-related commands
|
||||
nextbattle:
|
||||
description: (War) Warzone blocks are restored (from memory). Teams are respawned.
|
||||
usage:
|
||||
- Must be standing in warzone or lobby
|
||||
- /nextbattle
|
||||
# 2- Warzone creation commands
|
||||
setzone:
|
||||
description: (War) Use to create a warzone. Lobby is created and blocks are saved when the second corner is set.
|
||||
usage:
|
||||
- =<Classic/Northwest-Southeast mode>=
|
||||
- /setzone <zonename> <northwest/southeast/nw/se>
|
||||
- ex: first, /setzone ziggy se, then, /setzone ziggy nw
|
||||
- In classic mode, corner1 defaults to the topmost block (127) in the northwest and corner2 to the bottommost block (0) in the southeast.
|
||||
- =<Wand Cuboid mode>=
|
||||
- 1) /setzone <name> wand
|
||||
- 2) Left-click to select or move corner1
|
||||
- 3) Right-click to select or move corner2
|
||||
- Turn off wand by dropping the wooden sword.
|
||||
- =<Wandless Cuboid mode>=
|
||||
- /setzone <name> <corner1/corner2/c1/c2/pos1/pos2>
|
||||
- The three modes can be mixed and matched.
|
||||
- Warzones must be at least 10 blocks wide in all directions.
|
||||
savezone:
|
||||
description: (War) Persists changes made to the warzone since the last save. Config can be set with named parameters.
|
||||
usage:
|
||||
- Must be standing in warzone or lobby
|
||||
- /savezone => Basic save
|
||||
- /savezone lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on blockheads:off spawnstyle:<big/flat/small> unbreakable:on nocreatures:on disabled:on
|
||||
- /savezone loadout:default => sets the respawn inventory to your current items
|
||||
- /savezone reward:default => sets the winner's reward to your current items
|
||||
setzonelobby:
|
||||
description: (War) Creates or changes the position of the warzone lobby.
|
||||
usage:
|
||||
- Must be standing in warzone or lobby.
|
||||
- /setzonelobby <north/east/south/west/n/e/s/w>
|
||||
setteam:
|
||||
description: (War) Creates or moves a team spawn. The lobby is updated. Teams are diamond, iron or gold.
|
||||
usage:
|
||||
- Must be standing in warzone.
|
||||
- /setteam <diamond/iron/gold/white/orange/magenta/blue/green/pink/gray/purple/navy/brown/darkgreen/red/black>
|
||||
setmonument:
|
||||
description: (War) Creates or moves a monument.
|
||||
usage:
|
||||
- Must be standing in warzone.
|
||||
- /setmonument <monument-name>
|
||||
setteamflag:
|
||||
description: (War) Creates/moves a team flag post for CTF.
|
||||
usage:
|
||||
- Must be standing in warzone.
|
||||
- /setteamflag <team-color>
|
||||
resetzone:
|
||||
description: (War) Reloads zone blocks from memory. Everyone back to the lobby.
|
||||
usage:
|
||||
- Must be standing in warzone or lobby.
|
||||
- /resetzone
|
||||
deletezone:
|
||||
description: (War) Deletes the zone, resets all blocks.
|
||||
usage:
|
||||
- Must be standing in warzone or lobby, or provide name
|
||||
- /deletezone, /deletezone <zone-name>
|
||||
deleteteam:
|
||||
description: (War) Deletes the team. Team must exist.
|
||||
usage:
|
||||
- Must be standing in warzone or lobby.
|
||||
- /deleteteam <team-color>
|
||||
deletemonument:
|
||||
description: (War) Deletes the monument.
|
||||
usage:
|
||||
- Must be standing in warzone or lobby.
|
||||
- /deletemonument <monument-name>
|
||||
setzoneconfig:
|
||||
description: (War) Use named parameters to change the configuration of the warzone. Resets blocks like /nextbattle. Does not save zone blocks like /savezone.
|
||||
usage:
|
||||
- Must be standing in warzone or lobby.
|
||||
- /setzoneconfig lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on blockheads:off spawnstyle:<big/flat/small> unbreakable:on nocreatures:on disabled:on
|
||||
- /setzoneconfig loadout:default => sets the respawn inventory to your current items
|
||||
- /setzoneconfig reward:default => sets the winner's reward to your current items
|
||||
zonecfg:
|
||||
description: (War) Alias for /setzoneconfig
|
||||
usage:
|
||||
zonemaker:
|
||||
description: (War) Toggles between player mode and zone maker mode. Or gives/removes access to zonemaker commands for another player.
|
||||
usage:
|
||||
- /zonemaker
|
||||
- /zonemaker <new-or-kicked-zone-maker-name>
|
||||
zm:
|
||||
description: (War) Alias for /zonemaker
|
||||
usage:
|
||||
# 3- War hub
|
||||
setwarhub:
|
||||
description: (War) Create or moves a West-facing wall of portals. One portal per warzone. Warzones get a portal back to the warhub.
|
||||
usage: /setwarhub
|
||||
deletewarhub:
|
||||
description: (War) Deletes the warhub if it exists. Resets all warzone lobbies.
|
||||
usage: /deletewarhub
|
||||
# 4- Defaults and server configuration
|
||||
unloadwar:
|
||||
description: (War) Disables the War plugin.
|
||||
usage: /unloadwar
|
||||
loadwar:
|
||||
description: (War) Enables the War plugin.
|
||||
usage: /loadwar
|
||||
setwarconfig:
|
||||
description: (War) Change gobal settings and the default warzone configuration values.
|
||||
usage:
|
||||
- /setwarconfig pvpinzonesonly:on buildinzonesonly:on => Global settings
|
||||
- /setwarconfig lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on blockheads:off spawnstyle:<big/flat/small> unbreakable:on nocreatures:on => Warzone defaults
|
||||
- /setwarconfig loadout:default => sets the respawn inventory to your current items
|
||||
- /setwarconfig reward:default => sets the winner's reward to your current items
|
||||
- /setwarconfig rallypoint:<warzone-name> => changes when players get teleported at the end of a match for that zone, useful for chaining warzones together in a sequence, or preventing players from rejoining immediately
|
||||
warcfg:
|
||||
description: (War) Alias for /setwarconfig
|
||||
usage:
|
||||
# Fallback
|
||||
war:
|
||||
description: (War) Short War help. Can also be used as a prefix for all War commands as a fallback if they conflict with other plugins.
|
||||
usage:
|
||||
- /war
|
||||
- /war setzone ziggy northwest
|
||||
- /war warhub
|
||||
- /war zone ziggy
|
||||
- etc.
|
||||
War:
|
||||
description: (War) Same as /war. Used as fallback.
|
||||
usage: See /war.
|
||||
#Note: When you /disable War with Essentials, or at shutdown, all warzone blocks will be reset and artifacts will disappear.
|
||||
# When you /enable War, all blocks will be loaded from disk and the War-related artifacts will reappear.
|
@ -50,7 +50,7 @@ public class War extends JavaPlugin {
|
||||
private boolean loaded = false;
|
||||
|
||||
// Zones and hub
|
||||
private List<Warzone> warzones;
|
||||
private List<Warzone> warzones = new ArrayList<Warzone>();
|
||||
private WarHub warHub;
|
||||
private final List<Warzone> incompleteZones = new ArrayList<Warzone>();
|
||||
private final List<String> zoneMakerNames = new ArrayList<String>();
|
||||
@ -101,7 +101,6 @@ public class War extends JavaPlugin {
|
||||
*/
|
||||
public void loadWar() {
|
||||
this.setLoaded(true);
|
||||
this.warzones = new ArrayList<Warzone>();
|
||||
this.desc = this.getDescription();
|
||||
this.log = this.getServer().getLogger();
|
||||
this.setupPermissions();
|
||||
@ -228,29 +227,6 @@ public class War extends JavaPlugin {
|
||||
return true;*/
|
||||
}
|
||||
|
||||
public Warzone getWarzoneFromLocation(Player player) {
|
||||
return this.getWarzoneFromLocation(player.getLocation());
|
||||
}
|
||||
|
||||
public Warzone getWarzoneFromLocation(Location location) {
|
||||
Warzone zone = War.war.warzone(location);
|
||||
if (zone == null) {
|
||||
ZoneLobby lobby = War.war.lobby(location);
|
||||
if (lobby == null) return null;
|
||||
zone = lobby.getZone();
|
||||
}
|
||||
return zone;
|
||||
}
|
||||
|
||||
public Warzone getWarzoneFromName(String name) {
|
||||
for (Warzone zone : War.war.getWarzones()) {
|
||||
if (zone.getName().toLowerCase().equals(name.toLowerCase())) {
|
||||
return zone;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the player-inventory to a loadout hashmap
|
||||
*
|
||||
@ -400,8 +376,8 @@ public class War extends JavaPlugin {
|
||||
this.badMsg(player, "Usage: /deletemonument <name>." + " Deletes the monument. " + "Must be in a warzone or lobby (try /warzones and /warzone). ");
|
||||
} else {
|
||||
String name = arguments[0];
|
||||
Warzone warzone = this.warzone(player.getLocation());
|
||||
ZoneLobby lobby = this.lobby(player.getLocation());
|
||||
Warzone warzone = Warzone.getZoneByLocation(player);
|
||||
ZoneLobby lobby = ZoneLobby.getLobbyByLocation(player);
|
||||
if (warzone == null && lobby != null) {
|
||||
warzone = lobby.getZone();
|
||||
} else {
|
||||
@ -420,10 +396,10 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void performSetMonument(Player player, String[] arguments) {
|
||||
if (!this.inAnyWarzone(player.getLocation()) || arguments.length < 1 || arguments.length > 1 || (arguments.length == 1 && this.warzone(player.getLocation()) != null && arguments[0].equals(this.warzone(player.getLocation()).getName()))) {
|
||||
if (!this.inAnyWarzone(player.getLocation()) || arguments.length < 1 || arguments.length > 1 || (arguments.length == 1 && Warzone.getZoneByLocation(player) != null && arguments[0].equals(Warzone.getZoneByLocation(player).getName()))) {
|
||||
this.badMsg(player, "Usage: /setmonument <name>. Creates or moves a monument. Monument can't have same name as zone. Must be in warzone.");
|
||||
} else {
|
||||
Warzone warzone = this.warzone(player.getLocation());
|
||||
Warzone warzone = Warzone.getZoneByLocation(player);
|
||||
String monumentName = arguments[0];
|
||||
if (warzone.hasMonument(monumentName)) {
|
||||
// move the existing monument
|
||||
@ -446,8 +422,8 @@ public class War extends JavaPlugin {
|
||||
this.badMsg(player, "Usage: /deleteteam <team-name/color>." + " Deletes the team and its spawn. " + "Must be in a warzone or lobby (try /zones and /zone). ");
|
||||
} else {
|
||||
String name = arguments[0];
|
||||
Warzone warzone = this.warzone(player.getLocation());
|
||||
ZoneLobby lobby = this.lobby(player.getLocation());
|
||||
Warzone warzone = Warzone.getZoneByLocation(player);
|
||||
ZoneLobby lobby = ZoneLobby.getLobbyByLocation(player);
|
||||
if (warzone == null && lobby != null) {
|
||||
warzone = lobby.getZone();
|
||||
} else {
|
||||
@ -479,7 +455,7 @@ public class War extends JavaPlugin {
|
||||
this.badMsg(player, "Usage: /setteamflag <team-name/color>, e.g. /setteamflag diamond. " + "Sets the team flag post to the current location. " + "Must be in a warzone (try /zones and /zone). ");
|
||||
} else {
|
||||
TeamKind kind = TeamKinds.teamKindFromString(arguments[0]);
|
||||
Warzone warzone = this.warzone(player.getLocation());
|
||||
Warzone warzone = Warzone.getZoneByLocation(player);
|
||||
Team team = warzone.getTeamByKind(kind);
|
||||
if (team == null) {
|
||||
// no such team yet
|
||||
@ -508,7 +484,7 @@ public class War extends JavaPlugin {
|
||||
this.badMsg(player, "Usage: /setteam <team-kind/color>, e.g. /setteam red." + "Sets the team spawn to the current location. " + "Must be in a warzone (try /zones and /zone). ");
|
||||
} else {
|
||||
TeamKind teamKind = TeamKinds.teamKindFromString(arguments[0]);
|
||||
Warzone warzone = this.warzone(player.getLocation());
|
||||
Warzone warzone = Warzone.getZoneByLocation(player);
|
||||
Team existingTeam = warzone.getTeamByKind(teamKind);
|
||||
if (existingTeam != null) {
|
||||
// relocate
|
||||
@ -551,8 +527,8 @@ public class War extends JavaPlugin {
|
||||
return;
|
||||
}
|
||||
} else { // get zone by position
|
||||
warzone = this.warzone(player.getLocation());
|
||||
lobby = this.lobby(player.getLocation());
|
||||
warzone = Warzone.getZoneByLocation(player);
|
||||
lobby = ZoneLobby.getLobbyByLocation(player);
|
||||
}
|
||||
|
||||
if (warzone == null && lobby != null) {
|
||||
@ -594,8 +570,8 @@ public class War extends JavaPlugin {
|
||||
if (!this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation())) {
|
||||
this.badMsg(player, "Usage: /resetzone. Reloads the zone. Must be in warzone or lobby.");
|
||||
} else {
|
||||
Warzone warzone = this.warzone(player.getLocation());
|
||||
ZoneLobby lobby = this.lobby(player.getLocation());
|
||||
Warzone warzone = Warzone.getZoneByLocation(player);
|
||||
ZoneLobby lobby = ZoneLobby.getLobbyByLocation(player);
|
||||
if (warzone == null && lobby != null) {
|
||||
warzone = lobby.getZone();
|
||||
} else {
|
||||
@ -603,7 +579,7 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
warzone.clearFlagThieves();
|
||||
for (Team team : warzone.getTeams()) {
|
||||
team.teamcast("The war has ended. " + this.playerListener.getAllTeamsMsg(player) + " Resetting warzone " + warzone.getName() + " and teams...");
|
||||
team.teamcast("The war has ended. " + warzone.getTeamInformation() + " Resetting warzone " + warzone.getName() + " and teams...");
|
||||
for (Player p : team.getPlayers()) {
|
||||
warzone.restorePlayerInventory(p);
|
||||
p.teleport(warzone.getTeleport());
|
||||
@ -626,8 +602,8 @@ public class War extends JavaPlugin {
|
||||
if ((!this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation())) || arguments.length == 0) {
|
||||
this.badMsg(player, "Usage: /setzoneconfig lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on " + "Please give at leaset one named parameter. Does not save the blocks of the warzone. Resets the zone with the new config. Must be in warzone.");
|
||||
} else {
|
||||
Warzone warzone = this.warzone(player.getLocation());
|
||||
ZoneLobby lobby = this.lobby(player.getLocation());
|
||||
Warzone warzone = Warzone.getZoneByLocation(player);
|
||||
ZoneLobby lobby = ZoneLobby.getLobbyByLocation(player);
|
||||
if (warzone == null && lobby != null) {
|
||||
warzone = lobby.getZone();
|
||||
} else {
|
||||
@ -657,8 +633,8 @@ public class War extends JavaPlugin {
|
||||
if (!this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation())) {
|
||||
this.badMsg(player, "Usage: /savezone lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on " + "All named params optional. Saves the blocks of the warzone (i.e. the current zone state will be reloaded at each battle start). Must be in warzone.");
|
||||
} else {
|
||||
Warzone warzone = this.warzone(player.getLocation());
|
||||
ZoneLobby lobby = this.lobby(player.getLocation());
|
||||
Warzone warzone = Warzone.getZoneByLocation(player);
|
||||
ZoneLobby lobby = ZoneLobby.getLobbyByLocation(player);
|
||||
if (warzone == null && lobby != null) {
|
||||
warzone = lobby.getZone();
|
||||
} else {
|
||||
@ -696,8 +672,8 @@ public class War extends JavaPlugin {
|
||||
this.badMsg(player, usageStr);
|
||||
return;
|
||||
}
|
||||
Warzone warzone = this.warzone(player.getLocation());
|
||||
ZoneLobby lobby = this.lobby(player.getLocation());
|
||||
Warzone warzone = Warzone.getZoneByLocation(player);
|
||||
ZoneLobby lobby = ZoneLobby.getLobbyByLocation(player);
|
||||
if (warzone == null && lobby != null) {
|
||||
warzone = lobby.getZone();
|
||||
} else {
|
||||
@ -738,7 +714,7 @@ public class War extends JavaPlugin {
|
||||
WarzoneMapper.save(warzone, false);
|
||||
} else {
|
||||
// Not in a warzone: set the lobby position to where the player is standing
|
||||
Warzone warzone = this.matchWarzone(arguments[0]);
|
||||
Warzone warzone = Warzone.getZoneByName(arguments[0]);
|
||||
if (warzone == null) {
|
||||
this.badMsg(player, "No warzone matches " + arguments[0] + ".");
|
||||
} else {
|
||||
@ -794,10 +770,10 @@ public class War extends JavaPlugin {
|
||||
if (!this.inAnyWarzone(player.getLocation())) {
|
||||
this.badMsg(player, "Usage: /nextbattle. Resets the zone blocks and all teams' life pools. Must be in warzone.");
|
||||
} else {
|
||||
Warzone warzone = this.warzone(player.getLocation());
|
||||
Warzone warzone = Warzone.getZoneByLocation(player);
|
||||
warzone.clearFlagThieves();
|
||||
for (Team team : warzone.getTeams()) {
|
||||
team.teamcast("The battle was interrupted. " + this.playerListener.getAllTeamsMsg(player) + " Resetting warzone " + warzone.getName() + " and life pools...");
|
||||
team.teamcast("The battle was interrupted. " + warzone.getTeamInformation() + " Resetting warzone " + warzone.getName() + " and life pools...");
|
||||
}
|
||||
warzone.getVolume().resetBlocksAsJob();
|
||||
warzone.initializeZoneAsJob();
|
||||
@ -992,42 +968,13 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
public Team getPlayerTeam(String playerName) {
|
||||
for (Warzone warzone : this.warzones) {
|
||||
Team team = warzone.getPlayerTeam(playerName);
|
||||
if (team != null) {
|
||||
return team;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Warzone getPlayerTeamWarzone(String playerName) {
|
||||
for (Warzone warzone : this.warzones) {
|
||||
Team team = warzone.getPlayerTeam(playerName);
|
||||
if (team != null) {
|
||||
return warzone;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Logger getLogger() {
|
||||
return this.log;
|
||||
}
|
||||
|
||||
public Warzone warzone(Location location) {
|
||||
for (Warzone warzone : this.warzones) {
|
||||
if (location.getWorld().getName().equals(warzone.getWorld().getName()) && warzone.getVolume() != null && warzone.getVolume().contains(location)) {
|
||||
return warzone;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean inAnyWarzone(Location location) {
|
||||
Block locBlock = location.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
Warzone currentZone = this.warzone(location);
|
||||
Warzone currentZone = Warzone.getZoneByLocation(location);
|
||||
if (currentZone == null) {
|
||||
return false;
|
||||
} else if (currentZone.getVolume().isWallBlock(locBlock)) {
|
||||
@ -1037,7 +984,7 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
|
||||
public boolean inWarzone(String warzoneName, Location location) {
|
||||
Warzone currentZone = this.warzone(location);
|
||||
Warzone currentZone = Warzone.getZoneByLocation(location);
|
||||
if (currentZone == null) {
|
||||
return false;
|
||||
} else if (warzoneName.toLowerCase().equals(currentZone.getName().toLowerCase())) {
|
||||
@ -1125,15 +1072,6 @@ public class War extends JavaPlugin {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Warzone matchWarzone(String warzoneSubString) {
|
||||
for (Warzone warzone : this.warzones) {
|
||||
if (warzone.getName().toLowerCase().startsWith(warzoneSubString.toLowerCase())) {
|
||||
return warzone;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addWandBearer(Player player, String zoneName) {
|
||||
if (this.wandBearers.containsKey(player.getName())) {
|
||||
String alreadyHaveWand = this.wandBearers.get(player.getName());
|
||||
@ -1314,24 +1252,15 @@ public class War extends JavaPlugin {
|
||||
this.warHub = warHub;
|
||||
}
|
||||
|
||||
public ZoneLobby lobby(Location location) {
|
||||
for (Warzone warzone : this.warzones) {
|
||||
if (warzone.getLobby() != null && warzone.getLobby().getVolume() != null && warzone.getLobby().getVolume().contains(location)) {
|
||||
return warzone.getLobby();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean inAnyWarzoneLobby(Location location) {
|
||||
if (this.lobby(location) == null) {
|
||||
if (ZoneLobby.getLobbyByLocation(location) == null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean inWarzoneLobby(String warzoneName, Location location) {
|
||||
ZoneLobby currentLobby = this.lobby(location);
|
||||
ZoneLobby currentLobby = ZoneLobby.getLobbyByLocation(location);
|
||||
if (currentLobby == null) {
|
||||
return false;
|
||||
} else if (warzoneName.toLowerCase().equals(currentLobby.getZone().getName().toLowerCase())) {
|
||||
|
@ -30,8 +30,8 @@ public class WarBlockListener extends BlockListener {
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getBlock();
|
||||
if (player != null && block != null) {
|
||||
Team team = War.war.getPlayerTeam(player.getName());
|
||||
Warzone zone = War.war.warzone(player.getLocation());
|
||||
Team team = Team.getTeamByPlayerName(player.getName());
|
||||
Warzone zone = Warzone.getZoneByLocation(player);
|
||||
if (team != null && block != null && zone != null && zone.isMonumentCenterBlock(block) && block.getType() == team.getKind().getMaterial() && block.getData() == team.getKind().getData()) {
|
||||
Monument monument = zone.getMonumentFromCenterBlock(block);
|
||||
if (monument != null && !monument.hasOwner()) {
|
||||
@ -113,8 +113,8 @@ public class WarBlockListener extends BlockListener {
|
||||
}
|
||||
|
||||
private void handleBreakOrDamage(Player player, Block block, Cancellable event) {
|
||||
Warzone warzone = War.war.warzone(player.getLocation());
|
||||
Team team = War.war.getPlayerTeam(player.getName());
|
||||
Warzone warzone = Warzone.getZoneByLocation(player);
|
||||
Team team = Team.getTeamByPlayerName(player.getName());
|
||||
boolean isZoneMaker = War.war.isZoneMaker(player);
|
||||
|
||||
if (warzone != null && team == null && !isZoneMaker) {
|
||||
@ -164,7 +164,7 @@ public class WarBlockListener extends BlockListener {
|
||||
for (Team t : warzone.getTeams()) {
|
||||
t.teamcast(team.getKind().getColor() + player.getName() + ChatColor.WHITE + " stole team " + lostFlagTeam.getName() + "'s flag.");
|
||||
if (t.getName().equals(lostFlagTeam.getName())) {
|
||||
t.teamcast("Prevent " + team.getKind().getColor() + player.getName() + ChatColor.WHITE
|
||||
t.teamcast("Prevent " + team.getKind().getColor() + player.getName() + ChatColor.WHITE
|
||||
+ " from reaching team " + team.getName() + "'s spawn or flag.");
|
||||
}
|
||||
}
|
||||
@ -201,7 +201,7 @@ public class WarBlockListener extends BlockListener {
|
||||
}
|
||||
|
||||
// buildInZonesOnly
|
||||
Warzone blockZone = War.war.warzone(new Location(block.getWorld(), block.getX(), block.getY(), block.getZ()));
|
||||
Warzone blockZone = Warzone.getZoneByLocation(new Location(block.getWorld(), block.getX(), block.getY(), block.getZ()));
|
||||
if (blockZone == null && War.war.isBuildInZonesOnly() && !War.war.canBuildOutsideZone(player)) {
|
||||
War.war.badMsg(player, "You can only build inside warzones. Ask for the 'war.build' permission to build outside.");
|
||||
event.setCancelled(true);
|
||||
|
@ -14,6 +14,7 @@ public class WarCommandHandler {
|
||||
public boolean handle(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
String command = cmd.getName();
|
||||
String[] arguments = null;
|
||||
|
||||
if ((command.equals("war") || command.equals("War")) && args.length > 0) {
|
||||
command = args[0];
|
||||
arguments = new String[args.length - 1];
|
||||
@ -21,9 +22,11 @@ public class WarCommandHandler {
|
||||
arguments[i - 1] = args[i];
|
||||
}
|
||||
if (arguments.length == 1 && (arguments[0].equals("help") || arguments[0].equals("h"))) {
|
||||
// show help
|
||||
return false;
|
||||
}
|
||||
} else if (command.equals("war") || command.equals("War")) {
|
||||
// show help
|
||||
return false;
|
||||
} else {
|
||||
arguments = args;
|
||||
|
@ -44,10 +44,10 @@ public class WarEntityListener extends EntityListener {
|
||||
// only let adversaries (same warzone, different team) attack each other
|
||||
Player a = (Player) attacker;
|
||||
Player d = (Player) defender;
|
||||
Warzone attackerWarzone = War.war.getPlayerTeamWarzone(a.getName());
|
||||
Team attackerTeam = War.war.getPlayerTeam(a.getName());
|
||||
Warzone defenderWarzone = War.war.getPlayerTeamWarzone(d.getName());
|
||||
Team defenderTeam = War.war.getPlayerTeam(d.getName());
|
||||
Warzone attackerWarzone = Warzone.getZoneByPlayerName(a.getName());
|
||||
Team attackerTeam = Team.getTeamByPlayerName(a.getName());
|
||||
Warzone defenderWarzone = Warzone.getZoneByPlayerName(d.getName());
|
||||
Team defenderTeam = Team.getTeamByPlayerName(d.getName());
|
||||
if (attackerTeam != null && defenderTeam != null && attackerTeam != defenderTeam && attackerWarzone == defenderWarzone) {
|
||||
// Make sure one of the players isn't in the spawn
|
||||
if (defenderTeam.getSpawnVolume().contains(d.getLocation())) { // attacking person in spawn
|
||||
@ -109,15 +109,15 @@ public class WarEntityListener extends EntityListener {
|
||||
// attacked by dispenser arrow most probably
|
||||
// Detect death, prevent it and respawn the player
|
||||
Player d = (Player) defender;
|
||||
Warzone defenderWarzone = War.war.getPlayerTeamWarzone(d.getName());
|
||||
Warzone defenderWarzone = Warzone.getZoneByPlayerName(d.getName());
|
||||
if (d != null && defenderWarzone != null && event.getDamage() >= d.getHealth()) {
|
||||
String deathMessage = "";
|
||||
if (event instanceof EntityDamageByProjectileEvent)
|
||||
deathMessage = "A dispenser killed " + War.war.getPlayerTeam(d.getName()).getKind().getColor() + d.getDisplayName();
|
||||
deathMessage = "A dispenser killed " + Team.getTeamByPlayerName(d.getName()).getKind().getColor() + d.getDisplayName();
|
||||
else if (event.getDamager() instanceof CraftTNTPrimed)
|
||||
deathMessage = War.war.getPlayerTeam(d.getName()).getKind().getColor() + d.getDisplayName() + ChatColor.WHITE + " exploded";
|
||||
deathMessage = Team.getTeamByPlayerName(d.getName()).getKind().getColor() + d.getDisplayName() + ChatColor.WHITE + " exploded";
|
||||
else
|
||||
deathMessage = War.war.getPlayerTeam(d.getName()).getKind().getColor() + d.getDisplayName() + ChatColor.WHITE + " died";
|
||||
deathMessage = Team.getTeamByPlayerName(d.getName()).getKind().getColor() + d.getDisplayName() + ChatColor.WHITE + " died";
|
||||
for (Team team : defenderWarzone.getTeams()) {
|
||||
team.teamcast(deathMessage);
|
||||
}
|
||||
@ -164,7 +164,7 @@ public class WarEntityListener extends EntityListener {
|
||||
if (War.war.isLoaded()) {
|
||||
Entity entity = event.getEntity();
|
||||
// prevent godmode
|
||||
if (entity instanceof Player && War.war.getPlayerTeamWarzone(((Player) entity).getName()) != null) {
|
||||
if (entity instanceof Player && Warzone.getZoneByPlayerName(((Player) entity).getName()) != null) {
|
||||
event.setCancelled(false);
|
||||
}
|
||||
|
||||
@ -175,10 +175,10 @@ public class WarEntityListener extends EntityListener {
|
||||
// Detect death, prevent it and respawn the player
|
||||
if (entity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
Warzone zone = War.war.getPlayerTeamWarzone(player.getName());
|
||||
Warzone zone = Warzone.getZoneByPlayerName(player.getName());
|
||||
if (zone != null && event.getDamage() >= player.getHealth()) {
|
||||
String deathMessage = "";
|
||||
deathMessage = War.war.getPlayerTeam(player.getName()).getKind().getColor() + player.getDisplayName() + ChatColor.WHITE + " died";
|
||||
deathMessage = Team.getTeamByPlayerName(player.getName()).getKind().getColor() + player.getDisplayName() + ChatColor.WHITE + " died";
|
||||
for (Team team : zone.getTeams()) {
|
||||
team.teamcast(deathMessage);
|
||||
}
|
||||
@ -196,7 +196,7 @@ public class WarEntityListener extends EntityListener {
|
||||
Entity entity = event.getEntity();
|
||||
if (entity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
Team team = War.war.getPlayerTeam(player.getName());
|
||||
Team team = Team.getTeamByPlayerName(player.getName());
|
||||
if (team != null && team.getSpawnVolume().contains(player.getLocation())) {
|
||||
// smother out the fire that didn't burn out when you respawned
|
||||
// Stop fire (upcast, watch out!)
|
||||
@ -217,7 +217,7 @@ public class WarEntityListener extends EntityListener {
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
if (War.war.isLoaded()) {
|
||||
Location location = event.getLocation();
|
||||
Warzone zone = War.war.warzone(location);
|
||||
Warzone zone = Warzone.getZoneByLocation(location);
|
||||
if (zone != null && zone.isNoCreatures()) {
|
||||
event.setCancelled(true);
|
||||
// war.logInfo("Prevented " + event.getMobType().getName() + " from spawning in zone " + zone.getName());
|
||||
@ -234,8 +234,7 @@ public class WarEntityListener extends EntityListener {
|
||||
Entity entity = event.getEntity();
|
||||
if (entity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
Location location = player.getLocation();
|
||||
Warzone zone = War.war.warzone(location);
|
||||
Warzone zone = Warzone.getZoneByLocation(player);
|
||||
if (zone != null) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -39,13 +39,11 @@ public class WarPlayerListener extends PlayerListener {
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if (War.war.isLoaded()) {
|
||||
Player player = event.getPlayer();
|
||||
Team team = War.war.getPlayerTeam(player.getName());
|
||||
if (team != null) {
|
||||
Warzone zone = War.war.getPlayerTeamWarzone(player.getName());
|
||||
if (zone != null) {
|
||||
zone.handlePlayerLeave(player, zone.getTeleport(), true);
|
||||
}
|
||||
Warzone zone = Warzone.getZoneByPlayerName(player.getName());
|
||||
if (zone != null) {
|
||||
zone.handlePlayerLeave(player, zone.getTeleport(), true);
|
||||
}
|
||||
|
||||
if (War.war.isWandBearer(player)) {
|
||||
War.war.removeWandBearer(player);
|
||||
}
|
||||
@ -56,9 +54,9 @@ public class WarPlayerListener extends PlayerListener {
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||
if (War.war.isLoaded()) {
|
||||
Player player = event.getPlayer();
|
||||
Team team = War.war.getPlayerTeam(player.getName());
|
||||
Team team = Team.getTeamByPlayerName(player.getName());
|
||||
if (team != null) {
|
||||
Warzone zone = War.war.getPlayerTeamWarzone(player.getName());
|
||||
Warzone zone = Warzone.getZoneByPlayerName(player.getName());
|
||||
|
||||
if (zone.isFlagThief(player.getName())) {
|
||||
// a flag thief can't drop his flag
|
||||
@ -99,9 +97,9 @@ public class WarPlayerListener extends PlayerListener {
|
||||
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
|
||||
if (War.war.isLoaded()) {
|
||||
Player player = event.getPlayer();
|
||||
Team team = War.war.getPlayerTeam(player.getName());
|
||||
Team team = Team.getTeamByPlayerName(player.getName());
|
||||
if (team != null) {
|
||||
Warzone zone = War.war.getPlayerTeamWarzone(player.getName());
|
||||
Warzone zone = Warzone.getZoneByPlayerName(player.getName());
|
||||
|
||||
if (zone.isFlagThief(player.getName())) {
|
||||
// a flag thief can't pick up anything
|
||||
@ -130,7 +128,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
if (War.war.isLoaded()) {
|
||||
Player player = event.getPlayer();
|
||||
Inventory inventory = event.getInventory();
|
||||
Team team = War.war.getPlayerTeam(player.getName());
|
||||
Team team = Team.getTeamByPlayerName(player.getName());
|
||||
if (team != null && inventory instanceof PlayerInventory) {
|
||||
// make sure the player doesn't have too many precious blocks
|
||||
// or illegal armor (i.e. armor not found in loadout)
|
||||
@ -149,7 +147,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
if (War.war.isLoaded()) {
|
||||
Player player = event.getPlayer();
|
||||
Team talkingPlayerTeam = War.war.getPlayerTeam(player.getName());
|
||||
Team talkingPlayerTeam = Team.getTeamByPlayerName(player.getName());
|
||||
if (talkingPlayerTeam != null) {
|
||||
String msg = event.getMessage();
|
||||
String[] split = msg.split(" ");
|
||||
@ -216,14 +214,14 @@ public class WarPlayerListener extends PlayerListener {
|
||||
Location playerLoc = event.getFrom(); // same as player.getLoc. Don't call again we need same result.
|
||||
Warzone locZone = null;
|
||||
ZoneLobby locLobby = null;
|
||||
locZone = War.war.warzone(playerLoc);
|
||||
locLobby = War.war.lobby(playerLoc);
|
||||
locZone = Warzone.getZoneByLocation(playerLoc);
|
||||
locLobby = ZoneLobby.getLobbyByLocation(playerLoc);
|
||||
boolean canPlay = War.war.canPlayWar(player);
|
||||
boolean isMaker = War.war.isZoneMaker(player);
|
||||
|
||||
// Zone walls
|
||||
Team currentTeam = War.war.getPlayerTeam(player.getName());
|
||||
Warzone playerWarzone = War.war.getPlayerTeamWarzone(player.getName()); // this uses the teams, so it asks: get the player's team's warzone
|
||||
Team currentTeam = Team.getTeamByPlayerName(player.getName());
|
||||
Warzone playerWarzone = Warzone.getZoneByPlayerName(player.getName()); // this uses the teams, so it asks: get the player's team's warzone
|
||||
boolean protecting = false;
|
||||
if (currentTeam != null) {
|
||||
// Warzone nearbyZone = war.zoneOfZoneWallAtProximity(playerLoc);
|
||||
@ -246,7 +244,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
// Warzone lobby gates
|
||||
if (locLobby != null) {
|
||||
Warzone zone = locLobby.getZone();
|
||||
Team oldTeam = War.war.getPlayerTeam(player.getName());
|
||||
Team oldTeam = Team.getTeamByPlayerName(player.getName());
|
||||
boolean isAutoAssignGate = false;
|
||||
if (oldTeam == null && canPlay) { // trying to counter spammy player move
|
||||
isAutoAssignGate = zone.getLobby().isAutoAssignGate(playerLoc);
|
||||
@ -324,7 +322,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
}
|
||||
|
||||
boolean isLeaving = playerWarzone != null && playerWarzone.getLobby().isLeavingZone(playerLoc);
|
||||
Team playerTeam = War.war.getPlayerTeam(player.getName());
|
||||
Team playerTeam = Team.getTeamByPlayerName(player.getName());
|
||||
if (isLeaving) { // already in a team and in warzone, leaving
|
||||
// same as leave
|
||||
if (playerTeam != null) {
|
||||
@ -348,19 +346,16 @@ public class WarPlayerListener extends PlayerListener {
|
||||
if (playerTeam != null && playerWarzone.nearAnyOwnedMonument(playerLoc, playerTeam) && player.getHealth() < 20 && player.getHealth() > 0 // don't heal the dead
|
||||
&& this.random.nextInt(77) == 3) { // one chance out of many of getting healed
|
||||
int currentHp = player.getHealth();
|
||||
int newHp = currentHp + locZone.getMonumentHeal();
|
||||
if (newHp > 20) {
|
||||
newHp = 20;
|
||||
}
|
||||
int newHp = Math.max(20, currentHp + locZone.getMonumentHeal());
|
||||
|
||||
player.setHealth(newHp);
|
||||
String isS = "s"; // no 's' in 'hearts' when it's just one heart
|
||||
if (newHp - currentHp == 2) {
|
||||
isS = "";
|
||||
}
|
||||
String isS = "s";
|
||||
String heartNum = ""; // since (newHp-currentHp)/2 won't give the right amount
|
||||
if (newHp - currentHp == 2) {
|
||||
heartNum = "1 ";
|
||||
} else if (newHp - currentHp % 2 == 0) {
|
||||
if (newHp - currentHp == 2) { // no 's' in 'hearts' when it's just one heart
|
||||
isS = "";
|
||||
heartNum = "one ";
|
||||
}
|
||||
else if (newHp - currentHp % 2 == 0) {
|
||||
heartNum = ((newHp - currentHp) / 2) + " ";
|
||||
} else {
|
||||
heartNum = ((newHp - currentHp - 1) / 2) + ".5 ";
|
||||
@ -404,7 +399,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
}
|
||||
} else if (locZone != null && locZone.getLobby() != null && !locZone.getLobby().isLeavingZone(playerLoc) && !isMaker) {
|
||||
// player is not in any team, but inside warzone boundaries, get him out
|
||||
Warzone zone = War.war.warzone(playerLoc);
|
||||
Warzone zone = Warzone.getZoneByLocation(playerLoc);
|
||||
event.setTo(zone.getTeleport());
|
||||
// player.teleport(zone.getTeleport());
|
||||
War.war.badMsg(player, "You can't be inside a warzone without a team.");
|
||||
@ -422,33 +417,11 @@ public class WarPlayerListener extends PlayerListener {
|
||||
|
||||
private void dropFromOldTeamIfAny(Player player) {
|
||||
// drop from old team if any
|
||||
Team previousTeam = War.war.getPlayerTeam(player.getName());
|
||||
Team previousTeam = Team.getTeamByPlayerName(player.getName());
|
||||
if (previousTeam != null) {
|
||||
if (!previousTeam.removePlayer(player.getName())) {
|
||||
War.war.log("Could not remove player " + player.getName() + " from team " + previousTeam.getName(), java.util.logging.Level.WARNING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getAllTeamsMsg(Player player) {
|
||||
String teamsMessage = "Teams: ";
|
||||
Warzone warzone = War.war.warzone(player.getLocation());
|
||||
ZoneLobby lobby = War.war.lobby(player.getLocation());
|
||||
if (warzone == null && lobby != null) {
|
||||
warzone = lobby.getZone();
|
||||
} else {
|
||||
lobby = warzone.getLobby();
|
||||
}
|
||||
if (warzone.getTeams().isEmpty()) {
|
||||
teamsMessage += "none.";
|
||||
}
|
||||
for (Team team : warzone.getTeams()) {
|
||||
teamsMessage += team.getName() + " (" + team.getPoints() + " points, " + team.getRemainingLifes() + "/" + warzone.getLifePool() + " lives left. ";
|
||||
for (Player member : team.getPlayers()) {
|
||||
teamsMessage += member.getName() + " ";
|
||||
}
|
||||
teamsMessage += ") ";
|
||||
}
|
||||
return teamsMessage;
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import com.tommytony.war.Team;
|
||||
import com.tommytony.war.TeamKind;
|
||||
import com.tommytony.war.TeamKinds;
|
||||
import com.tommytony.war.Warzone;
|
||||
import com.tommytony.war.ZoneLobby;
|
||||
|
||||
public class JoinCommand extends AbstractWarCommand {
|
||||
public JoinCommand(WarCommandHandler handler, CommandSender sender, String[] args) {
|
||||
@ -23,21 +24,36 @@ public class JoinCommand extends AbstractWarCommand {
|
||||
|
||||
Player player = (Player) this.sender;
|
||||
if (!War.war.canPlayWar(player)) {
|
||||
//War.war.badMsg(player, "Cannot play war.");
|
||||
this.sender.sendMessage("Cannot play war");
|
||||
return true;
|
||||
}
|
||||
if (this.args.length < 1) {
|
||||
|
||||
Warzone zone;
|
||||
if (this.args.length == 0) {
|
||||
return false;
|
||||
}
|
||||
Warzone zone = War.war.getWarzoneFromLocation(player);
|
||||
if (zone == null) {
|
||||
War.war.badMsg(player, "No such warzone.");
|
||||
return true;
|
||||
else if (this.args.length == 2) {
|
||||
// zone by name
|
||||
zone = Warzone.getZoneByName(this.args[0]);
|
||||
// move the team-name to first place :)
|
||||
this.args[0] = this.args[1];
|
||||
}
|
||||
else {
|
||||
zone = Warzone.getZoneByLocation(player);
|
||||
if (zone == null) {
|
||||
ZoneLobby lobby = ZoneLobby.getLobbyByLocation(player);
|
||||
if (lobby == null) return false;
|
||||
zone = lobby.getZone();
|
||||
}
|
||||
}
|
||||
if (zone == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// drop from old team if any
|
||||
Team previousTeam = War.war.getPlayerTeam(player.getName());
|
||||
Team previousTeam = Team.getTeamByPlayerName(player.getName());
|
||||
if (previousTeam != null) {
|
||||
Warzone oldZone = War.war.getPlayerTeamWarzone(player.getName());
|
||||
Warzone oldZone = Warzone.getZoneByPlayerName(player.getName());
|
||||
if (!previousTeam.removePlayer(player.getName())) {
|
||||
War.war.log("Could not remove player " + player.getName() + " from team " + previousTeam.getName(), java.util.logging.Level.WARNING);
|
||||
}
|
||||
@ -58,7 +74,7 @@ public class JoinCommand extends AbstractWarCommand {
|
||||
TeamKind kind = TeamKinds.teamKindFromString(this.args[0]);
|
||||
|
||||
if (zone.isDisabled()) {
|
||||
War.war.badMsg(player, "This warzone is disabled.");
|
||||
this.sender.sendMessage("This warzone is disabled.");
|
||||
} else {
|
||||
List<Team> teams = zone.getTeams();
|
||||
boolean foundTeam = false;
|
||||
@ -66,7 +82,7 @@ public class JoinCommand extends AbstractWarCommand {
|
||||
if (team.getName().startsWith(name) || team.getKind() == kind) {
|
||||
if (!zone.hasPlayerInventory(player.getName())) {
|
||||
zone.keepPlayerInventory(player);
|
||||
War.war.msg(player, "Your inventory is in storage until you /leave.");
|
||||
this.sender.sendMessage("Your inventory is in storage until you /leave.");
|
||||
}
|
||||
if (team.getPlayers().size() < zone.getTeamCap()) {
|
||||
team.addPlayer(player);
|
||||
@ -77,17 +93,18 @@ public class JoinCommand extends AbstractWarCommand {
|
||||
}
|
||||
foundTeam = true;
|
||||
} else {
|
||||
War.war.badMsg(player, "Team " + team.getName() + " is full.");
|
||||
this.sender.sendMessage("Team " + team.getName() + " is full.");
|
||||
foundTeam = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (foundTeam) {
|
||||
for (Team team : teams) {
|
||||
team.teamcast("" + player.getName() + " joined " + team.getName());
|
||||
}
|
||||
} else {
|
||||
War.war.badMsg(player, "No such team. Try /teams.");
|
||||
this.sender.sendMessage("No such team. Try /teams.");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -3,7 +3,6 @@ package bukkit.tommytony.war.command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import bukkit.tommytony.war.War;
|
||||
import bukkit.tommytony.war.WarCommandHandler;
|
||||
|
||||
import com.tommytony.war.Warzone;
|
||||
@ -17,11 +16,11 @@ public class LeaveCommand extends AbstractWarCommand {
|
||||
if (!(this.sender instanceof Player)) return true;
|
||||
|
||||
Player player = (Player) this.sender;
|
||||
if (!War.war.inAnyWarzone(player.getLocation()) || War.war.getPlayerTeam(player.getName()) == null) {
|
||||
Warzone zone = Warzone.getZoneByPlayerName(player.getName());
|
||||
if (zone == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Warzone zone = War.war.getPlayerTeamWarzone(player.getName());
|
||||
zone.handlePlayerLeave(player, zone.getTeleport(), true);
|
||||
return true;
|
||||
}
|
||||
|
@ -4,11 +4,15 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import bukkit.tommytony.war.War;
|
||||
import bukkit.tommytony.war.WarCommandHandler;
|
||||
|
||||
import com.tommytony.war.Team;
|
||||
|
||||
/**
|
||||
* Sends a message to all team-members
|
||||
* @author das-schaf
|
||||
*
|
||||
*/
|
||||
public class TeamCommand extends AbstractWarCommand {
|
||||
public TeamCommand(WarCommandHandler handler, CommandSender sender, String[] args) {
|
||||
super(handler, sender, args);
|
||||
@ -18,7 +22,7 @@ public class TeamCommand extends AbstractWarCommand {
|
||||
if (!(this.sender instanceof Player)) return true;
|
||||
|
||||
Player player = (Player) this.sender;
|
||||
Team playerTeam = War.war.getPlayerTeam(player.getName());
|
||||
Team playerTeam = Team.getTeamByPlayerName(player.getName());
|
||||
if (playerTeam == null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -3,10 +3,10 @@ package bukkit.tommytony.war.command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import bukkit.tommytony.war.War;
|
||||
import bukkit.tommytony.war.WarCommandHandler;
|
||||
|
||||
import com.tommytony.war.Warzone;
|
||||
import com.tommytony.war.ZoneLobby;
|
||||
|
||||
public class TeamsCommand extends AbstractWarCommand {
|
||||
public TeamsCommand(WarCommandHandler handler, CommandSender sender, String[] args) {
|
||||
@ -16,17 +16,24 @@ public class TeamsCommand extends AbstractWarCommand {
|
||||
public boolean handle() {
|
||||
Warzone zone;
|
||||
if (this.args.length == 1) {
|
||||
zone = War.war.getWarzoneFromName(this.args[0]);
|
||||
zone = Warzone.getZoneByName(this.args[0]);
|
||||
} else {
|
||||
if (!(this.sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
zone = War.war.getWarzoneFromLocation((Player) this.sender);
|
||||
zone = Warzone.getZoneByLocation((Player) this.sender);
|
||||
if (zone == null) {
|
||||
ZoneLobby lobby = ZoneLobby.getLobbyByLocation((Player) this.sender);
|
||||
if (lobby == null) return false;
|
||||
zone = lobby.getZone();
|
||||
}
|
||||
}
|
||||
if (zone == null) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
// zone.getTeams();
|
||||
|
||||
this.sender.sendMessage(zone.getTeamInformation());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import org.bukkit.entity.Player;
|
||||
import bukkit.tommytony.war.War;
|
||||
import bukkit.tommytony.war.WarCommandHandler;
|
||||
|
||||
import com.tommytony.war.Team;
|
||||
import com.tommytony.war.Warzone;
|
||||
|
||||
public class WarhubCommand extends AbstractWarCommand {
|
||||
@ -23,9 +22,8 @@ public class WarhubCommand extends AbstractWarCommand {
|
||||
} else if (!War.war.canWarp(player)) {
|
||||
War.war.badMsg(player, "Can't warp to warhub. You need the 'war.warp' permission.");
|
||||
} else {
|
||||
Team playerTeam = War.war.getPlayerTeam(player.getName());
|
||||
Warzone playerWarzone = War.war.getPlayerTeamWarzone(player.getName());
|
||||
if (playerTeam != null) { // was in zone
|
||||
Warzone playerWarzone = Warzone.getZoneByPlayerName(player.getName());
|
||||
if (playerWarzone != null) { // was in zone
|
||||
playerWarzone.handlePlayerLeave(player, War.war.getWarHub().getLocation(), true);
|
||||
}
|
||||
player.teleport(War.war.getWarHub().getLocation());
|
||||
|
@ -6,7 +6,6 @@ import org.bukkit.entity.Player;
|
||||
import bukkit.tommytony.war.War;
|
||||
import bukkit.tommytony.war.WarCommandHandler;
|
||||
|
||||
import com.tommytony.war.Team;
|
||||
import com.tommytony.war.Warzone;
|
||||
|
||||
public class WarzoneCommand extends AbstractWarCommand {
|
||||
@ -15,19 +14,20 @@ public class WarzoneCommand extends AbstractWarCommand {
|
||||
}
|
||||
|
||||
public boolean handle() {
|
||||
// ignore it when no player
|
||||
if (!(this.sender instanceof Player)) return true;
|
||||
|
||||
Player player = (Player) this.sender;
|
||||
if (this.args.length < 1) {
|
||||
// handle missing warzone-name
|
||||
return false;
|
||||
} else if (!War.war.canWarp(player)) {
|
||||
War.war.badMsg(player, "Can't warp to zone. You need the 'war.warp' permission.");
|
||||
this.sender.sendMessage("Can't warp to zone. You need the 'war.warp' permission.");
|
||||
} else {
|
||||
for (Warzone warzone : War.war.getWarzones()) {
|
||||
if (warzone.getName().toLowerCase().startsWith(this.args[0].toLowerCase()) && warzone.getTeleport() != null) {
|
||||
Team playerTeam = War.war.getPlayerTeam(player.getName());
|
||||
if (playerTeam != null) {
|
||||
Warzone playerWarzone = War.war.getPlayerTeamWarzone(player.getName());
|
||||
Warzone playerWarzone = Warzone.getZoneByPlayerName(player.getName());
|
||||
if (playerWarzone != null) {
|
||||
playerWarzone.handlePlayerLeave(player, warzone.getTeleport(), true);
|
||||
} else {
|
||||
player.teleport(warzone.getTeleport());
|
||||
@ -35,7 +35,7 @@ public class WarzoneCommand extends AbstractWarCommand {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
War.war.badMsg(player, "No such warzone.");
|
||||
this.sender.sendMessage("No such warzone.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -9,6 +9,11 @@ import bukkit.tommytony.war.WarCommandHandler;
|
||||
import com.tommytony.war.Team;
|
||||
import com.tommytony.war.Warzone;
|
||||
|
||||
/**
|
||||
* Lists all warzones
|
||||
*
|
||||
* @author Tim Düsterhus
|
||||
*/
|
||||
public class WarzonesCommand extends AbstractWarCommand {
|
||||
public WarzonesCommand(WarCommandHandler handler, CommandSender sender, String[] args) {
|
||||
super(handler, sender, args);
|
||||
@ -19,16 +24,19 @@ public class WarzonesCommand extends AbstractWarCommand {
|
||||
if (War.war.getWarzones().isEmpty()) {
|
||||
warzonesMessage += "none.";
|
||||
}
|
||||
for (Warzone warzone : War.war.getWarzones()) {
|
||||
|
||||
warzonesMessage += warzone.getName() + " (" + warzone.getTeams().size() + " teams, ";
|
||||
int playerTotal = 0;
|
||||
for (Team team : warzone.getTeams()) {
|
||||
playerTotal += team.getPlayers().size();
|
||||
else {
|
||||
for (Warzone warzone : War.war.getWarzones()) {
|
||||
warzonesMessage += warzone.getName() + " (" + warzone.getTeams().size() + " teams, ";
|
||||
int playerTotal = 0;
|
||||
for (Team team : warzone.getTeams()) {
|
||||
playerTotal += team.getPlayers().size();
|
||||
}
|
||||
warzonesMessage += playerTotal + " players)";
|
||||
}
|
||||
warzonesMessage += playerTotal + " players)";
|
||||
}
|
||||
|
||||
this.sender.sendMessage(warzonesMessage + ((this.sender instanceof Player) ? " Use /zone <zone-name> to teleport to a warzone." : ""));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,16 @@ public class Team {
|
||||
this.setFlagVolume(null); // no flag at the start
|
||||
}
|
||||
|
||||
public static Team getTeamByPlayerName(String playerName) {
|
||||
for (Warzone warzone : War.war.getWarzones()) {
|
||||
Team team = warzone.getPlayerTeam(playerName);
|
||||
if (team != null) {
|
||||
return team;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public TeamKind getKind() {
|
||||
return this.kind;
|
||||
}
|
||||
|
@ -86,6 +86,38 @@ public class Warzone {
|
||||
this.volume = new ZoneVolume(name, this.getWorld(), this);
|
||||
}
|
||||
|
||||
public static Warzone getZoneByName(String name) {
|
||||
for (Warzone warzone : War.war.getWarzones()) {
|
||||
if (warzone.getName().toLowerCase().equals(name.toLowerCase())) {
|
||||
return warzone;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Warzone getZoneByLocation(Location location) {
|
||||
for (Warzone warzone : War.war.getWarzones()) {
|
||||
if (location.getWorld().getName().equals(warzone.getWorld().getName()) && warzone.getVolume() != null && warzone.getVolume().contains(location)) {
|
||||
return warzone;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Warzone getZoneByLocation(Player player) {
|
||||
return Warzone.getZoneByLocation(player.getLocation());
|
||||
}
|
||||
|
||||
public static Warzone getZoneByPlayerName(String playerName) {
|
||||
for (Warzone warzone : War.war.getWarzones()) {
|
||||
Team team = warzone.getPlayerTeam(playerName);
|
||||
if (team != null) {
|
||||
return warzone;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean ready() {
|
||||
if (this.volume.hasTwoCorners() && !this.volume.tooSmall() && !this.volume.tooBig()) {
|
||||
return true;
|
||||
@ -108,6 +140,23 @@ public class Warzone {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getTeamInformation() {
|
||||
String teamsMessage = "Teams: ";
|
||||
if (this.getTeams().isEmpty()) {
|
||||
teamsMessage += "none.";
|
||||
}
|
||||
else {
|
||||
for (Team team : this.getTeams()) {
|
||||
teamsMessage += team.getName() + " (" + team.getPoints() + " points, " + team.getRemainingLifes() + "/" + this.getLifePool() + " lives left. ";
|
||||
for (Player member : team.getPlayers()) {
|
||||
teamsMessage += member.getName() + " ";
|
||||
}
|
||||
teamsMessage += ") ";
|
||||
}
|
||||
}
|
||||
return teamsMessage;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
@ -663,7 +712,7 @@ public class Warzone {
|
||||
}
|
||||
|
||||
public void setAutoAssignOnly(boolean autoAssignOnly) {
|
||||
this.autoAssignOnly = autoAssignOnly;
|
||||
this.autoAssignOnly = autoAssignOnly;
|
||||
if (this.getLobby() != null) {
|
||||
this.getLobby().setLocation(this.getTeleport());
|
||||
}
|
||||
@ -674,8 +723,8 @@ public class Warzone {
|
||||
}
|
||||
|
||||
public void handleDeath(Player player) {
|
||||
Team playerTeam = War.war.getPlayerTeam(player.getName());
|
||||
Warzone playerWarzone = War.war.getPlayerTeamWarzone(player.getName());
|
||||
Team playerTeam = Team.getTeamByPlayerName(player.getName());
|
||||
Warzone playerWarzone = Warzone.getZoneByPlayerName(player.getName());
|
||||
if (playerTeam != null && playerWarzone != null) {
|
||||
// teleport to team spawn upon death
|
||||
|
||||
@ -768,7 +817,7 @@ public class Warzone {
|
||||
}
|
||||
|
||||
private void handlePlayerLeave(Player player, boolean removeFromTeam) {
|
||||
Team playerTeam = War.war.getPlayerTeam(player.getName());
|
||||
Team playerTeam = Team.getTeamByPlayerName(player.getName());
|
||||
if (playerTeam != null) {
|
||||
if (removeFromTeam) {
|
||||
playerTeam.removePlayer(player.getName());
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import bukkit.tommytony.war.War;
|
||||
|
||||
@ -99,6 +100,19 @@ public class ZoneLobby {
|
||||
}
|
||||
}
|
||||
|
||||
public static ZoneLobby getLobbyByLocation(Location location) {
|
||||
for (Warzone warzone : War.war.getWarzones()) {
|
||||
if (warzone.getLobby() != null && warzone.getLobby().getVolume() != null && warzone.getLobby().getVolume().contains(location)) {
|
||||
return warzone.getLobby();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ZoneLobby getLobbyByLocation(Player player) {
|
||||
return ZoneLobby.getLobbyByLocation(player.getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the lobby's position. Orientation is determined from the player location. Creates volume or resets. Saves new lobby blocks.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user