mirror of
https://github.com/taoneill/war.git
synced 2024-11-27 12:46:11 +01:00
Removed AbstractWarzoneCommand and moved methods into War
This commit is contained in:
parent
92bd84da75
commit
38bcafae01
@ -228,6 +228,29 @@ 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
|
||||
*
|
||||
|
@ -1,40 +0,0 @@
|
||||
package bukkit.tommytony.war.command;
|
||||
|
||||
import org.bukkit.Location;
|
||||
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 abstract class AbstractWarzoneCommand extends AbstractWarCommand {
|
||||
public AbstractWarzoneCommand(WarCommandHandler handler, CommandSender sender, String[] args) {
|
||||
super(handler, sender, args);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ import com.tommytony.war.TeamKind;
|
||||
import com.tommytony.war.TeamKinds;
|
||||
import com.tommytony.war.Warzone;
|
||||
|
||||
public class JoinCommand extends AbstractWarzoneCommand {
|
||||
public class JoinCommand extends AbstractWarCommand {
|
||||
public JoinCommand(WarCommandHandler handler, CommandSender sender, String[] args) {
|
||||
super(handler, sender, args);
|
||||
}
|
||||
@ -29,7 +29,7 @@ public class JoinCommand extends AbstractWarzoneCommand {
|
||||
if (this.args.length < 1) {
|
||||
return false;
|
||||
}
|
||||
Warzone zone = this.getWarzoneFromLocation(player);
|
||||
Warzone zone = War.war.getWarzoneFromLocation(player);
|
||||
if (zone == null) {
|
||||
War.war.badMsg(player, "No such warzone.");
|
||||
return true;
|
||||
|
@ -8,7 +8,7 @@ import bukkit.tommytony.war.WarCommandHandler;
|
||||
|
||||
import com.tommytony.war.Warzone;
|
||||
|
||||
public class LeaveCommand extends AbstractWarzoneCommand {
|
||||
public class LeaveCommand extends AbstractWarCommand {
|
||||
public LeaveCommand(WarCommandHandler handler, CommandSender sender, String[] args) {
|
||||
super(handler, sender, args);
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import bukkit.tommytony.war.WarCommandHandler;
|
||||
|
||||
import com.tommytony.war.Team;
|
||||
|
||||
public class TeamCommand extends AbstractWarzoneCommand {
|
||||
public class TeamCommand extends AbstractWarCommand {
|
||||
public TeamCommand(WarCommandHandler handler, CommandSender sender, String[] args) {
|
||||
super(handler, sender, args);
|
||||
}
|
||||
|
@ -3,11 +3,12 @@ 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;
|
||||
|
||||
public class TeamsCommand extends AbstractWarzoneCommand {
|
||||
public class TeamsCommand extends AbstractWarCommand {
|
||||
public TeamsCommand(WarCommandHandler handler, CommandSender sender, String[] args) {
|
||||
super(handler, sender, args);
|
||||
}
|
||||
@ -15,12 +16,12 @@ public class TeamsCommand extends AbstractWarzoneCommand {
|
||||
public boolean handle() {
|
||||
Warzone zone;
|
||||
if (this.args.length == 1) {
|
||||
zone = this.getWarzoneFromName(this.args[0]);
|
||||
zone = War.war.getWarzoneFromName(this.args[0]);
|
||||
} else {
|
||||
if (!(this.sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
zone = this.getWarzoneFromLocation((Player) this.sender);
|
||||
zone = War.war.getWarzoneFromLocation((Player) this.sender);
|
||||
}
|
||||
if (zone == null) {
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user