mirror of
https://github.com/garbagemule/MobArena.git
synced 2025-02-12 02:21:46 +01:00
Add per-arena setting announcer-type
.
Introduces the concept of an Announcer, which is invoked whenever the `announce` methods on the Arena interface are invoked. Previously, all announcements would simply be sent to the arena's Messenger, but this new feature allows us to move them up into titles to help declutter the somewhat overloaded chat box. By default, to help people discover the new feature, the announcer type is `title`, but it is possible to switch back to `chat` for the original behavior. Closes #272
This commit is contained in:
parent
31010c1576
commit
4f11889549
@ -17,6 +17,7 @@ These changes will (most likely) be included in the next version.
|
||||
- Elytra and Netherite armor pieces now correctly auto-equip if specified in the generic `armor` node in classes in the config-file.
|
||||
- Boss names now support color codes.
|
||||
- New per-arena setting `arena-warp-offset` can be used to spread out players randomly by an offset from the arena warp. This should help prevent players taking suffocation damage.
|
||||
- New per-arena setting `announcer-type` determines where to display per-arena announcements such as wave spawns, auto start timers, boss abilities, and death messages. Options are `title` (default) or `chat`.
|
||||
- The Root Target ability now uses potion effects (slowness, slow falling, and negative jump boost) instead of repeated teleports. This should make for a smoother root experience.
|
||||
- Using `spectate-on-death: true` no longer forces players out to their join location/exit warp before moving them to the spectator area. This should prevent "jumpy" behavior in multi-world setups.
|
||||
- Players should now properly respawn at the spectator area rather than at world spawn on servers with plugins that override respawn locations.
|
||||
|
@ -3,6 +3,9 @@ package com.garbagemule.MobArena;
|
||||
import static com.garbagemule.MobArena.util.config.ConfigUtils.makeSection;
|
||||
|
||||
import com.garbagemule.MobArena.ScoreboardManager.NullScoreboardManager;
|
||||
import com.garbagemule.MobArena.announce.Announcer;
|
||||
import com.garbagemule.MobArena.announce.MessengerAnnouncer;
|
||||
import com.garbagemule.MobArena.announce.TitleAnnouncer;
|
||||
import com.garbagemule.MobArena.steps.Step;
|
||||
import com.garbagemule.MobArena.steps.StepFactory;
|
||||
import com.garbagemule.MobArena.steps.PlayerJoinArena;
|
||||
@ -75,6 +78,7 @@ public class ArenaImpl implements Arena
|
||||
private String name;
|
||||
private World world;
|
||||
private Messenger messenger;
|
||||
private Announcer announcer;
|
||||
|
||||
// Settings section of the config-file for this arena.
|
||||
private ConfigurationSection settings;
|
||||
@ -232,6 +236,16 @@ public class ArenaImpl implements Arena
|
||||
String prefix = settings.getString("prefix", "");
|
||||
this.messenger = !prefix.isEmpty() ? new Messenger(prefix) : plugin.getGlobalMessenger();
|
||||
|
||||
// Announcer
|
||||
String announcerType = settings.getString("announcer-type", "chat");
|
||||
if (announcerType.equals("chat")) {
|
||||
announcer = new MessengerAnnouncer(this.messenger);
|
||||
} else if (announcerType.equals("title")) {
|
||||
announcer = new TitleAnnouncer(5, 60, 10);
|
||||
} else {
|
||||
throw new ConfigError("Unsupported announcer type: " + announcerType);
|
||||
}
|
||||
|
||||
// Actions
|
||||
this.histories = new HashMap<>();
|
||||
this.playerJoinArena = PlayerJoinArena.create(this);
|
||||
@ -454,7 +468,7 @@ public class ArenaImpl implements Arena
|
||||
@Override
|
||||
public void announce(String msg) {
|
||||
for (Player p : getAllPlayers()) {
|
||||
messenger.tell(p, msg);
|
||||
announcer.announce(p, msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.garbagemule.MobArena.announce;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface Announcer {
|
||||
|
||||
/**
|
||||
* Announce the given message to the given player.
|
||||
*
|
||||
* @param player a player to send a message to, non-null
|
||||
* @param message the message to send, non-null
|
||||
*/
|
||||
void announce(Player player, String message);
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.garbagemule.MobArena.announce;
|
||||
|
||||
import com.garbagemule.MobArena.Messenger;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class MessengerAnnouncer implements Announcer {
|
||||
|
||||
private final Messenger messenger;
|
||||
|
||||
public MessengerAnnouncer(Messenger messenger) {
|
||||
this.messenger = messenger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void announce(Player player, String message) {
|
||||
messenger.tell(player, message);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.garbagemule.MobArena.announce;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TitleAnnouncer implements Announcer {
|
||||
|
||||
private final int fadeIn;
|
||||
private final int stay;
|
||||
private final int fadeOut;
|
||||
|
||||
public TitleAnnouncer(int fadeIn, int stay, int fadeOut) {
|
||||
this.fadeIn = fadeIn;
|
||||
this.stay = stay;
|
||||
this.fadeOut = fadeOut;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void announce(Player player, String message) {
|
||||
player.sendTitle("", message, fadeIn, stay, fadeOut);
|
||||
}
|
||||
|
||||
}
|
@ -41,6 +41,7 @@ display-waves-as-level: false
|
||||
display-timer-as-level: false
|
||||
use-scoreboards: true
|
||||
isolated-chat: false
|
||||
announcer-type: title
|
||||
global-join-announce: false
|
||||
global-end-announce: false
|
||||
show-death-messages: true
|
||||
|
Loading…
Reference in New Issue
Block a user