mirror of
https://github.com/taoneill/war.git
synced 2024-11-23 10:45:52 +01:00
Much less glitchy lobbies: proper handling of team adding, deleting and of autoassign mode switching. Win.
This commit is contained in:
parent
ea454e3027
commit
a4d8075ad1
@ -75,13 +75,15 @@ public class Warzone {
|
||||
private final List<Player> respawn = new ArrayList<Player>();
|
||||
private final List<String> reallyDeadFighters = new ArrayList<String>();
|
||||
|
||||
private final WarzoneConfigBag warzoneConfig = new WarzoneConfigBag();
|
||||
private final TeamConfigBag teamDefaultConfig = new TeamConfigBag();
|
||||
private final WarzoneConfigBag warzoneConfig;
|
||||
private final TeamConfigBag teamDefaultConfig;
|
||||
private InventoryBag defaultInventories = new InventoryBag();
|
||||
|
||||
public Warzone(World world, String name) {
|
||||
this.world = world;
|
||||
this.name = name;
|
||||
this.warzoneConfig = new WarzoneConfigBag(this);
|
||||
this.teamDefaultConfig = new TeamConfigBag(); // don't use ctor with Warzone, as this changes config resolution
|
||||
this.volume = new ZoneVolume(name, this.getWorld(), this);
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,7 @@ public class DeleteTeamCommand extends AbstractZoneMakerCommand {
|
||||
team.getSpawnVolume().resetBlocks();
|
||||
zone.getTeams().remove(team);
|
||||
if (zone.getLobby() != null) {
|
||||
zone.getLobby().setLocation(zone.getTeleport());
|
||||
zone.getLobby().initialize();
|
||||
}
|
||||
WarzoneYmlMapper.save(zone, false);
|
||||
|
@ -56,7 +56,7 @@ public class SetTeamCommand extends AbstractZoneMakerCommand {
|
||||
newTeam.setRemainingLives(newTeam.getTeamConfig().resolveInt(TeamConfig.LIFEPOOL));
|
||||
zone.getTeams().add(newTeam);
|
||||
if (zone.getLobby() != null) {
|
||||
zone.getLobby().getVolume().resetBlocks();
|
||||
zone.getLobby().setLocation(zone.getTeleport());
|
||||
zone.getLobby().initialize();
|
||||
}
|
||||
newTeam.setTeamSpawn(player.getLocation());
|
||||
|
@ -6,12 +6,23 @@ import java.util.Map;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.tommytony.war.War;
|
||||
import com.tommytony.war.Warzone;
|
||||
|
||||
|
||||
public class WarzoneConfigBag {
|
||||
|
||||
EnumMap<WarzoneConfig, Object> bag = new EnumMap<WarzoneConfig, Object>(WarzoneConfig.class);
|
||||
private final Warzone warzone;
|
||||
|
||||
public WarzoneConfigBag(Warzone warzone) {
|
||||
this.warzone = warzone;
|
||||
}
|
||||
|
||||
public WarzoneConfigBag() {
|
||||
// default zone settings (at War level) don't have a warzone
|
||||
this.warzone = null;
|
||||
}
|
||||
|
||||
public void put(WarzoneConfig config, Object value) {
|
||||
bag.put(config, value);
|
||||
}
|
||||
@ -80,6 +91,10 @@ public class WarzoneConfigBag {
|
||||
} else if (warzoneConfig.getConfigType().equals(Boolean.class)) {
|
||||
String onOff = namedParams.get(namedParam);
|
||||
this.bag.put(warzoneConfig, onOff.equals("on") || onOff.equals("true"));
|
||||
if (this.warzone != null && namedParam.equals(WarzoneConfig.AUTOASSIGN.toString())) {
|
||||
this.warzone.getLobby().setLocation(this.warzone.getTeleport());
|
||||
this.warzone.getLobby().initialize();
|
||||
}
|
||||
}
|
||||
returnMessage += " " + warzoneConfig.toString() + " set to " + namedParams.get(namedParam);
|
||||
} else if (namedParam.equals("delete")) {
|
||||
|
Loading…
Reference in New Issue
Block a user