- Messenger no longer has a static nature and must be instantiated to be used. The prefix is provided in the constructor. - MobArena instantiates a global Messenger in onEnable() with a prefix string from global-settings. This instance is used by anything that isn't arena-specific, as well as for arenas with no prefix. - ArenaImpl instantiates a local Messenger in its constructor if, and only if, its arena-specific prefix setting is non-empty. Otherwise it uses the plugin's global instance.
40 lines
1.3 KiB
Java
40 lines
1.3 KiB
Java
package com.garbagemule.MobArena.commands.admin;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
|
|
import com.garbagemule.MobArena.commands.*;
|
|
import com.garbagemule.MobArena.framework.Arena;
|
|
import com.garbagemule.MobArena.framework.ArenaMaster;
|
|
|
|
@CommandInfo(
|
|
name = "kick",
|
|
pattern = "kick|kcik",
|
|
usage = "/ma kick <player>",
|
|
desc = "kick a player from an arena",
|
|
permission = "mobarena.admin.kick"
|
|
)
|
|
public class KickCommand implements Command
|
|
{
|
|
@Override
|
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
|
// Require a player name
|
|
if (args.length != 1) return false;
|
|
|
|
Arena arena = am.getArenaWithPlayer(args[0]);
|
|
if (arena == null) {
|
|
am.getGlobalMessenger().tell(sender, "That player is not in an arena.");
|
|
return true;
|
|
}
|
|
|
|
// Grab the Player object.
|
|
Player bp = am.getPlugin().getServer().getPlayer(args[0]);
|
|
|
|
// Force leave.
|
|
arena.playerLeave(bp);
|
|
am.getGlobalMessenger().tell(sender, "Player '" + args[0] + "' was kicked from arena '" + arena.configName() + "'.");
|
|
am.getGlobalMessenger().tell(bp, "You were kicked by " + sender.getName() + ".");
|
|
return true;
|
|
}
|
|
}
|