use of org.bukkit.command.CommandSender in project MagicPlugin by elBukkit.
the class CommandCitizensTrait method perform.
@Override
public boolean perform(net.citizensnpcs.api.event.NPCRightClickEvent event) {
if (command == null || command.isEmpty())
return false;
CommandSender sender = event.getClicker();
Player player = event.getClicker();
boolean result = true;
boolean isOp = sender.isOp();
if (op && !isOp) {
sender.setOp(true);
}
Location location = player.getLocation();
CommandSender executor = console ? Bukkit.getConsoleSender() : player;
try {
String converted = command.replace("@pd", player.getDisplayName()).replace("@pn", player.getName()).replace("@p", player.getName()).replace("@uuid", player.getUniqueId().toString()).replace("@world", location.getWorld().getName()).replace("@x", Double.toString(location.getX())).replace("@y", Double.toString(location.getY())).replace("@z", Double.toString(location.getZ()));
;
api.getPlugin().getServer().dispatchCommand(executor, converted);
} catch (Exception ex) {
result = false;
api.getLogger().log(Level.WARNING, "Error running command: " + command, ex);
}
if (op && !isOp) {
sender.setOp(false);
}
return result;
}
use of org.bukkit.command.CommandSender in project MagicPlugin by elBukkit.
the class WandUpgradePath method upgraded.
public void upgraded(com.elmakers.mine.bukkit.api.wand.Wand wand, Mage mage) {
CommandSender sender = Bukkit.getConsoleSender();
Location location = null;
if (mage != null) {
playEffects(mage, "upgrade");
location = mage.getLocation();
}
Player player = mage != null ? mage.getPlayer() : null;
boolean shouldRunCommands = (player == null || !player.hasPermission("Magic.bypass_upgrade_commands"));
if (upgradeCommands != null && shouldRunCommands) {
for (String command : upgradeCommands) {
if (command.contains("@uuid") || command.contains("@pn") || command.contains("@pd")) {
if (mage == null) {
Bukkit.getLogger().warning("Tried to upgrade with commands but no mage");
continue;
}
command = command.replace("@uuid", mage.getId()).replace("@pn", mage.getName()).replace("@pd", mage.getDisplayName());
;
}
if (location != null) {
command = command.replace("@world", location.getWorld().getName()).replace("@x", Double.toString(location.getX())).replace("@y", Double.toString(location.getY())).replace("@z", Double.toString(location.getZ()));
}
WandUpgradePath upgrade = getPath(upgradeKey);
command = command.replace("$path", upgrade.getName());
command = ChatColor.translateAlternateColorCodes('&', command);
wand.getController().getPlugin().getServer().dispatchCommand(sender, command);
}
}
if (upgradeItemKey != null && !upgradeItemKey.isEmpty()) {
com.elmakers.mine.bukkit.api.wand.Wand upgradeWand = wand.getController().createWand(upgradeItemKey);
if (upgradeWand != null) {
wand.add(upgradeWand, mage);
}
}
}
use of org.bukkit.command.CommandSender in project MassiveCore by MassiveCraft.
the class Pager method getHeightCalc.
public Integer getHeightCalc() {
Integer ret = this.getHeight();
if (ret != null)
return ret;
CommandSender sender = this.getSenderCalc();
if (sender == null)
return Txt.PAGEHEIGHT_PLAYER;
if (sender instanceof Player)
return Txt.PAGEHEIGHT_PLAYER;
return Txt.PAGEHEIGHT_CONSOLE;
}
use of org.bukkit.command.CommandSender in project MassiveCore by MassiveCraft.
the class NmsChat method sendChatPlain.
public void sendChatPlain(Object sendeeObject, String plain) {
CommandSender sendee = IdUtil.getSender(sendeeObject);
if (sendee == null)
return;
MassiveCoreMConf mconf = MassiveCoreMConf.get();
if (mconf != null && !mconf.consoleColorsEnabled && sendee instanceof ConsoleCommandSender) {
plain = ChatColor.stripColor(plain);
}
sendee.sendMessage(plain);
}
use of org.bukkit.command.CommandSender in project MassiveCore by MassiveCraft.
the class NmsChatAbstract method sendChatMson.
// -------------------------------------------- //
// CHAT
// -------------------------------------------- //
@Override
public void sendChatMson(Object sendeeObject, Mson mson) {
CommandSender sendee = IdUtil.getSender(sendeeObject);
if (sendee == null)
return;
if (sendee instanceof Player) {
Player player = (Player) sendee;
String raw = mson.toRaw();
Object component = toComponent(raw);
Object packet = ReflectionUtil.invokeConstructor(this.constructorPacketPlayOutChat, component);
NmsBasics.get().sendPacket(player, packet);
} else {
String plain = mson.toPlain(true);
this.sendChatPlain(sendee, plain);
}
}
Aggregations