mirror of
https://github.com/garbagemule/MobArena.git
synced 2024-11-23 11:06:14 +01:00
Move Messenger announce() methods into Arena.
Since the announce() methods always required an Arena argument, and since the Messenger instance used was always acquired from an Arena instance, there really was no reason for the methods to exist on Messenger.
This commit is contained in:
parent
56dc504bec
commit
f212c657b0
@ -401,6 +401,22 @@ public class ArenaImpl implements Arena
|
||||
return plugin.getGlobalMessenger();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void announce(String msg) {
|
||||
for (Player p : getAllPlayers()) {
|
||||
messenger.tell(p, msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void announce(Msg msg, String s) {
|
||||
announce(msg.format(s));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void announce(Msg msg) {
|
||||
announce(msg.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startArena() {
|
||||
@ -500,7 +516,7 @@ public class ArenaImpl implements Arena
|
||||
leaderboard.initialize();
|
||||
leaderboard.startTracking();
|
||||
|
||||
messenger.announce(this, Msg.ARENA_START);
|
||||
announce(Msg.ARENA_START);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -540,7 +556,7 @@ public class ArenaImpl implements Arena
|
||||
messenger.tell(p, Msg.ARENA_END_GLOBAL, configName());
|
||||
}
|
||||
} else {
|
||||
messenger.announce(this, Msg.ARENA_END);
|
||||
announce(Msg.ARENA_END);
|
||||
}
|
||||
cleanup();
|
||||
|
||||
|
@ -492,7 +492,7 @@ public class ArenaListener
|
||||
onMountDeath(event);
|
||||
}
|
||||
else if (monsters.removeGolem(event.getEntity())) {
|
||||
arena.getMessenger().announce(arena, Msg.GOLEM_DIED);
|
||||
arena.announce(Msg.GOLEM_DIED);
|
||||
}
|
||||
}
|
||||
|
||||
@ -505,7 +505,7 @@ public class ArenaListener
|
||||
callKillEvent(player.getKiller(), player);
|
||||
}
|
||||
if (arena.getSettings().getBoolean("show-death-messages", true)) {
|
||||
arena.getMessenger().announce(arena, event.getDeathMessage());
|
||||
arena.announce(event.getDeathMessage());
|
||||
}
|
||||
event.setDeathMessage(null);
|
||||
arena.getScoreboard().death(player);
|
||||
|
@ -1,13 +1,7 @@
|
||||
package com.garbagemule.MobArena;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.garbagemule.MobArena.framework.Arena;
|
||||
|
||||
public class Messenger
|
||||
{
|
||||
@ -38,22 +32,4 @@ public class Messenger
|
||||
public boolean tell(CommandSender p, Msg msg) {
|
||||
return tell(p, msg.toString());
|
||||
}
|
||||
|
||||
public void announce(Arena arena, String msg) {
|
||||
List<Player> players = new ArrayList<Player>();
|
||||
players.addAll(arena.getPlayersInArena());
|
||||
players.addAll(arena.getPlayersInLobby());
|
||||
players.addAll(arena.getSpectators());
|
||||
for (Player p : players) {
|
||||
tell(p, msg);
|
||||
}
|
||||
}
|
||||
|
||||
public void announce(Arena arena, Msg msg, String s) {
|
||||
announce(arena, msg.format(s));
|
||||
}
|
||||
|
||||
public void announce(Arena arena, Msg msg) {
|
||||
announce(arena, msg.toString());
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.garbagemule.MobArena.framework;
|
||||
import java.util.*;
|
||||
|
||||
import com.garbagemule.MobArena.Messenger;
|
||||
import com.garbagemule.MobArena.Msg;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
@ -113,6 +114,12 @@ public interface Arena
|
||||
public Messenger getMessenger();
|
||||
|
||||
public Messenger getGlobalMessenger();
|
||||
|
||||
public void announce(String msg);
|
||||
|
||||
public void announce(Msg msg, String s);
|
||||
|
||||
public void announce(Msg msg);
|
||||
|
||||
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class ChatCallback extends TimerCallbackAdapter {
|
||||
// Announce remaining seconds
|
||||
long ticks = timer.getRemaining();
|
||||
int seconds = toSeconds(ticks);
|
||||
arena.getMessenger().announce(arena, msg, String.valueOf(seconds));
|
||||
arena.announce(msg, String.valueOf(seconds));
|
||||
|
||||
// Calculate the new interval
|
||||
index++;
|
||||
|
@ -105,7 +105,7 @@ public class StartDelayTimer extends CountdownTimer implements TimerCallback {
|
||||
|
||||
// Notify players of auto-start-timer duration
|
||||
if (autoStartTimer.isRunning()) {
|
||||
arena.getMessenger().announce(arena, Msg.ARENA_AUTO_START, "" + autoStartTimer.getRemaining() / 20l);
|
||||
arena.announce(Msg.ARENA_AUTO_START, "" + autoStartTimer.getRemaining() / 20l);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,42 +9,42 @@ public enum WaveType
|
||||
DEFAULT {
|
||||
@Override
|
||||
public void announce(Arena arena, int wave) {
|
||||
arena.getMessenger().announce(arena, Msg.WAVE_DEFAULT, "" + wave);
|
||||
arena.announce(Msg.WAVE_DEFAULT, "" + wave);
|
||||
}
|
||||
},
|
||||
|
||||
SPECIAL {
|
||||
@Override
|
||||
public void announce(Arena arena, int wave) {
|
||||
arena.getMessenger().announce(arena, Msg.WAVE_SPECIAL, "" + wave);
|
||||
arena.announce(Msg.WAVE_SPECIAL, "" + wave);
|
||||
}
|
||||
},
|
||||
|
||||
SWARM {
|
||||
@Override
|
||||
public void announce(Arena arena, int wave) {
|
||||
arena.getMessenger().announce(arena, Msg.WAVE_SWARM, "" + wave);
|
||||
arena.announce(Msg.WAVE_SWARM, "" + wave);
|
||||
}
|
||||
},
|
||||
|
||||
SUPPLY {
|
||||
@Override
|
||||
public void announce(Arena arena, int wave) {
|
||||
arena.getMessenger().announce(arena, Msg.WAVE_SUPPLY, "" + wave);
|
||||
arena.announce(Msg.WAVE_SUPPLY, "" + wave);
|
||||
}
|
||||
},
|
||||
|
||||
BOSS {
|
||||
@Override
|
||||
public void announce(Arena arena, int wave) {
|
||||
arena.getMessenger().announce(arena, Msg.WAVE_BOSS, "" + wave);
|
||||
arena.announce(Msg.WAVE_BOSS, "" + wave);
|
||||
}
|
||||
},
|
||||
|
||||
UPGRADE {
|
||||
@Override
|
||||
public void announce(Arena arena, int wave) {
|
||||
arena.getMessenger().announce(arena, Msg.WAVE_UPGRADE, "" + wave);
|
||||
arena.announce(Msg.WAVE_UPGRADE, "" + wave);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -153,7 +153,7 @@ public class BossWave extends AbstractWave
|
||||
public void announceAbility(Ability ability, MABoss boss, Arena arena) {
|
||||
if(getAbilityAnnounce()) {
|
||||
AbilityInfo info = ability.getClass().getAnnotation(AbilityInfo.class);
|
||||
arena.getMessenger().announce(arena, Msg.WAVE_BOSS_ABILITY, info.name());
|
||||
arena.announce(Msg.WAVE_BOSS_ABILITY, info.name());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user