Range check on performances for spectators

This commit is contained in:
Waverunner
2014-03-17 16:49:50 -04:00
parent 8d81e26504
commit e0ca1ea7b2
3 changed files with 48 additions and 2 deletions
+30
View File
@@ -422,6 +422,36 @@ public class EntertainmentService implements INetworkDispatch {
}
public void startSpectating(final CreatureObject spectator, final CreatureObject performer) {
final ScheduledFuture<?> spectatorTask = scheduler.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
if (spectator.getPosition().getDistance2D(performer.getWorldPosition()) > (float) 70) {
String pType = (performer.getPerformanceType()) ? "dance" : "music";
if(pType.equals("dance")) {
spectator.setPerformanceWatchee(null);
spectator.sendSystemMessage("You stop watching " + performer.getCustomName() + " because " + performer.getCustomName()
+ " is out of range.", (byte) 0);
}
else {
spectator.setPerformanceListenee(null);
spectator.sendSystemMessage("You stop listening to " + performer.getCustomName() + " because " + performer.getCustomName()
+ " is out of range.", (byte) 0);
}
spectator.setMoodAnimation("neutral");
performer.removeAudience(spectator);
spectator.getSpectatorTask().cancel(true);
}
}
}, 2, 2, TimeUnit.SECONDS);
spectator.setSpectatorTask(spectatorTask);
}
@Override
public void shutdown() {