mirror of
https://github.com/taoneill/war.git
synced 2024-11-27 12:46:11 +01:00
Removed 'Equiped x loadout' message at every respawn. Message only appears at first respawn or during a sneak-toggle.
This commit is contained in:
parent
0b1d428266
commit
e1c6397f22
@ -105,6 +105,7 @@ public class War extends JavaPlugin {
|
||||
private boolean defaultResetOnEmpty = false, defaultResetOnLoad = false, defaultResetOnUnload = false;
|
||||
private TeamSpawnStyle defaultSpawnStyle = TeamSpawnStyle.BIG;
|
||||
private final HashMap<Integer, ItemStack> defaultReward = new HashMap<Integer, ItemStack>();
|
||||
private boolean isSpoutServer = false;
|
||||
|
||||
public War() {
|
||||
super();
|
||||
@ -135,6 +136,14 @@ public class War extends JavaPlugin {
|
||||
this.desc = this.getDescription();
|
||||
this.logger = this.getServer().getLogger();
|
||||
this.setupPermissions();
|
||||
|
||||
// Spout server detection
|
||||
try {
|
||||
Class.forName("org.getspout.spoutapi.player.SpoutPlayer");
|
||||
isSpoutServer = true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
isSpoutServer = false;
|
||||
}
|
||||
|
||||
if (!War.loadedOnce) {
|
||||
War.loadedOnce = true; // This prevented multiple hookups of the same listener
|
||||
@ -1105,12 +1114,7 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
|
||||
public boolean isSpoutServer() {
|
||||
try {
|
||||
Class.forName("org.getspout.spoutapi.player.SpoutPlayer");
|
||||
return true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
return this.isSpoutServer;
|
||||
}
|
||||
|
||||
public Warzone zoneOfZoneWallAtProximity(Location location) {
|
||||
|
@ -561,7 +561,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
int currentIndex = (selection.getSelectedIndex() + 1) % (playerWarzone.getExtraLoadouts().keySet().size() + 1);
|
||||
selection.setSelectedIndex(currentIndex);
|
||||
|
||||
playerWarzone.equipPlayerLoadoutSelection(event.getPlayer(), playerTeam);
|
||||
playerWarzone.equipPlayerLoadoutSelection(event.getPlayer(), playerTeam, false, true);
|
||||
} else {
|
||||
War.war.badMsg(event.getPlayer(), "Can't change loadout after exiting the spawn.");
|
||||
}
|
||||
|
@ -355,7 +355,9 @@ public class Warzone {
|
||||
// clear potion effects
|
||||
PotionEffect.clearPotionEffects(player);
|
||||
|
||||
boolean isFirstRespawn = false;
|
||||
if (!this.getLoadoutSelections().keySet().contains(player.getName())) {
|
||||
isFirstRespawn = true;
|
||||
this.getLoadoutSelections().put(player.getName(), new LoadoutSelection(true, 0));
|
||||
} else {
|
||||
this.getLoadoutSelections().get(player.getName()).setStillInSpawn(true);
|
||||
@ -366,8 +368,8 @@ public class Warzone {
|
||||
((SpoutPlayer) player).setTitle(team.getKind().getColor() + player.getName());
|
||||
}
|
||||
|
||||
final LoadoutResetJob job = new LoadoutResetJob(this, team, player);
|
||||
if (respawnTimer == 0) {
|
||||
final LoadoutResetJob job = new LoadoutResetJob(this, team, player, isFirstRespawn, false);
|
||||
if (respawnTimer == 0 || isFirstRespawn) {
|
||||
War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, job);
|
||||
}
|
||||
else {
|
||||
@ -962,7 +964,7 @@ public class Warzone {
|
||||
}
|
||||
|
||||
|
||||
War.war.msg(player, "Left the zone. Your inventory is being restored.");
|
||||
War.war.msg(player, "Your inventory is being restored.");
|
||||
if (War.war.getWarHub() != null) {
|
||||
War.war.getWarHub().resetZoneSign(this);
|
||||
}
|
||||
@ -1307,13 +1309,17 @@ public class Warzone {
|
||||
return authors;
|
||||
}
|
||||
|
||||
public void equipPlayerLoadoutSelection(Player player, Team playerTeam) {
|
||||
public void equipPlayerLoadoutSelection(Player player, Team playerTeam, boolean isFirstRespawn, boolean isToggle) {
|
||||
LoadoutSelection selection = this.getLoadoutSelections().get(player.getName());
|
||||
if (selection != null && !this.isRespawning(player)) {
|
||||
int currentIndex = selection.getSelectedIndex();
|
||||
if (currentIndex == 0) {
|
||||
this.resetInventory(playerTeam, player, this.getLoadout());
|
||||
War.war.msg(player, "Equipped default loadout.");
|
||||
if (isFirstRespawn && this.extraLoadouts.keySet().size() > 0) {
|
||||
War.war.msg(player, "Equipped default loadout (sneak to switch).");
|
||||
} else if (isToggle){
|
||||
War.war.msg(player, "Equipped default loadout.");
|
||||
}
|
||||
} else {
|
||||
int i = 0;
|
||||
Iterator it = this.getExtraLoadouts().entrySet().iterator();
|
||||
@ -1321,7 +1327,9 @@ public class Warzone {
|
||||
Map.Entry pairs = (Map.Entry)it.next();
|
||||
if (i == currentIndex - 1) {
|
||||
this.resetInventory(playerTeam, player, (HashMap<Integer, ItemStack>)pairs.getValue());
|
||||
War.war.msg(player, "Equipped " + pairs.getKey() + " loadout.");
|
||||
if (isToggle) {
|
||||
War.war.msg(player, "Equipped " + pairs.getKey() + " loadout.");
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
@ -10,15 +10,19 @@ public class LoadoutResetJob implements Runnable {
|
||||
private final Player player;
|
||||
private final Warzone zone;
|
||||
private final Team team;
|
||||
private final boolean isFirstRespawn;
|
||||
private final boolean isToggle;
|
||||
|
||||
public LoadoutResetJob(Warzone zone, Team team, Player player) {
|
||||
public LoadoutResetJob(Warzone zone, Team team, Player player, boolean isFirstRespawn, boolean isToggle) {
|
||||
this.zone = zone;
|
||||
this.team = team;
|
||||
this.player = player;
|
||||
this.isFirstRespawn = isFirstRespawn;
|
||||
this.isToggle = isToggle;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
this.zone.equipPlayerLoadoutSelection(player, team);
|
||||
this.zone.equipPlayerLoadoutSelection(player, team, isFirstRespawn, isToggle);
|
||||
|
||||
// Stop fire here, since doing it in the same tick as death doesn't extinguish it
|
||||
this.player.setFireTicks(0);
|
||||
|
Loading…
Reference in New Issue
Block a user