mirror of
https://github.com/taoneill/war.git
synced 2025-02-21 13:51:19 +01:00
Add zone reset complete message.
- Also, notify command sender with progress report, not just people in teams or in lobby
This commit is contained in:
parent
df85b176b7
commit
31a2deef0f
@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.tommytony.war.War;
|
||||
import com.tommytony.war.Warzone;
|
||||
import com.tommytony.war.job.PartialZoneResetJob;
|
||||
import com.tommytony.war.structure.ZoneLobby;
|
||||
|
||||
|
||||
@ -42,6 +43,9 @@ public class NextBattleCommand extends AbstractZoneMakerCommand {
|
||||
|
||||
zone.clearThieves();
|
||||
zone.broadcast("zone.battle.next", zone.getName());
|
||||
|
||||
PartialZoneResetJob.setSenderToNotify(this.getSender());
|
||||
|
||||
zone.reinitialize();
|
||||
|
||||
War.war.log(this.getSender().getName() + " used nextbattle in warzone " + zone.getName(), Level.INFO);
|
||||
|
@ -10,6 +10,7 @@ import com.tommytony.war.Team;
|
||||
import com.tommytony.war.War;
|
||||
import com.tommytony.war.Warzone;
|
||||
import com.tommytony.war.Warzone.LeaveCause;
|
||||
import com.tommytony.war.job.PartialZoneResetJob;
|
||||
import com.tommytony.war.structure.ZoneLobby;
|
||||
|
||||
|
||||
@ -59,7 +60,9 @@ public class ResetZoneCommand extends AbstractZoneMakerCommand {
|
||||
}
|
||||
|
||||
this.msg("Reloading warzone " + zone.getName() + ".");
|
||||
|
||||
|
||||
PartialZoneResetJob.setSenderToNotify(this.getSender());
|
||||
|
||||
zone.reinitialize();
|
||||
|
||||
War.war.log(this.getSender().getName() + " reset warzone " + zone.getName(), Level.INFO);
|
||||
|
@ -2,8 +2,11 @@ package com.tommytony.war.job;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@ -13,7 +16,9 @@ import com.tommytony.war.structure.ZoneLobby;
|
||||
import com.tommytony.war.volume.ZoneVolume;
|
||||
|
||||
public class PartialZoneResetJob extends BukkitRunnable implements Cloneable {
|
||||
|
||||
|
||||
private static CommandSender senderToNotify = null;
|
||||
|
||||
private final Warzone zone;
|
||||
private final ZoneVolume volume;
|
||||
private final int speed;
|
||||
@ -21,7 +26,7 @@ public class PartialZoneResetJob extends BukkitRunnable implements Cloneable {
|
||||
private int completed = 0;
|
||||
private final long startTime = System.currentTimeMillis();
|
||||
private long messageCounter = System.currentTimeMillis();
|
||||
public static final long MESSAGE_INTERVAL = 3000;
|
||||
public static final long MESSAGE_INTERVAL = 7500;
|
||||
// Ticks between job runs
|
||||
public static final int JOB_INTERVAL = 1;
|
||||
|
||||
@ -53,20 +58,19 @@ public class PartialZoneResetJob extends BukkitRunnable implements Cloneable {
|
||||
String message = MessageFormat.format(
|
||||
War.war.getString("zone.battle.resetprogress"),
|
||||
percent, seconds);
|
||||
for (Player player : War.war.getServer().getOnlinePlayers()) {
|
||||
ZoneLobby lobby = ZoneLobby.getLobbyByLocation(player);
|
||||
if (zone.getPlayers().contains(player)
|
||||
|| (lobby != null && lobby.getZone() == zone)) {
|
||||
War.war.msg(player, message);
|
||||
}
|
||||
}
|
||||
this.sendMessageToAllWarzonePlayers(message);
|
||||
}
|
||||
War.war.getServer().getScheduler()
|
||||
.runTaskLater(War.war, this.clone(), JOB_INTERVAL);
|
||||
} else {
|
||||
long seconds = (System.currentTimeMillis() - startTime) / 1000;
|
||||
String message = MessageFormat.format(
|
||||
War.war.getString("zone.battle.resetcomplete"), seconds);
|
||||
this.sendMessageToAllWarzonePlayers(message);
|
||||
PartialZoneResetJob.setSenderToNotify(null); // stop notifying
|
||||
zone.initializeZone();
|
||||
War.war.getLogger().info(
|
||||
"Finished reset cycle for warzone " + volume.getName());
|
||||
"Finished reset cycle for warzone " + volume.getName() + " (took " + seconds + " seconds)");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
War.war.getLogger().log(Level.WARNING,
|
||||
@ -74,6 +78,20 @@ public class PartialZoneResetJob extends BukkitRunnable implements Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendMessageToAllWarzonePlayers(String message) {
|
||||
for (Player player : War.war.getServer().getOnlinePlayers()) {
|
||||
ZoneLobby lobby = ZoneLobby.getLobbyByLocation(player);
|
||||
if (zone.getPlayers().contains(player)
|
||||
|| (lobby != null && lobby.getZone() == zone)) {
|
||||
War.war.msg(player, message);
|
||||
}
|
||||
}
|
||||
|
||||
if (PartialZoneResetJob.senderToNotify != null) {
|
||||
War.war.msg(senderToNotify, message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PartialZoneResetJob clone() {
|
||||
try {
|
||||
@ -82,4 +100,8 @@ public class PartialZoneResetJob extends BukkitRunnable implements Cloneable {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setSenderToNotify(CommandSender sender) {
|
||||
PartialZoneResetJob.senderToNotify = sender;
|
||||
}
|
||||
}
|
||||
|
@ -92,8 +92,9 @@ zone.airstrike = {0} called in an airstrike!
|
||||
zone.battle.end = The battle is over. Team {0} lost: {1} died and there were no lives left in their life pool.
|
||||
zone.battle.newscores = New scores - {0}
|
||||
zone.battle.next = The battle was interrupted. Resetting warzone {0}...
|
||||
zone.battle.reset = A new battle begins. Resetting warzone...
|
||||
zone.battle.resetprogress = Reset progress: {0}%, {1} seconds
|
||||
zone.battle.reset = A new battle will begin shortly. Resetting warzone...
|
||||
zone.battle.resetprogress = Reset progress: {0}%, {1} seconds...
|
||||
zone.battle.resetcomplete = Warzone reset in {0} seconds. A new battle begins.
|
||||
zone.bomb.broadcast = {0} blew up team {1}''s spawn. Team {2} scores one point.
|
||||
zone.cake.broadcast = {0} captured cake {1}. Team {2} scores one point and gets a full lifepool.
|
||||
zone.flagcapture.broadcast = {0} captured team {1}''s flag. Team {2} scores one point.
|
||||
|
Loading…
Reference in New Issue
Block a user