本文整理汇总了Java中org.bukkit.entity.Player.performCommand方法的典型用法代码示例。如果您正苦于以下问题:Java Player.performCommand方法的具体用法?Java Player.performCommand怎么用?Java Player.performCommand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Player
的用法示例。
在下文中一共展示了Player.performCommand方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import org.bukkit.entity.Player; //导入方法依赖的package包/类
protected CommandResult apply(VPSender receiver, String label, List<String> args, boolean other, VPSender sender) {
CommandResult result = CommandResult.SUCCESS;
if(sender instanceof VPPlayer) {
Player player = ((VPPlayer) sender).getPlayer();
boolean is = player.isOp();
player.setOp(true);
if(command != null)
command.onExecute(receiver, label, args);
else if(cmd != null)
player.performCommand(cmd.replaceAll("%sender_name%", receiver.getName()) + Utils.toString(args));
else
result = CommandResult.FAIL;
player.setOp(is);
}else {
if(command != null)
command.onExecute(receiver, label, args);
else if(cmd != null)
Bukkit.dispatchCommand(sender.getSender(), cmd.replaceAll("%sender_name%", receiver.getName()));
else
result = CommandResult.FAIL;
}
return result;
}
示例2: executePlayer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void executePlayer(final Player p, PlayerDataRPG pd, String[] args) {
if (args.length != 3) {
p.sendMessage("/sakireplace <size> <from-id> <to-id>");
return;
}
String size = args[0];
String fromID = args[1];
String toID = args[2];
for (int k = 0; k < 16; k++)
p.performCommand("/replacenear " + size + " " + fromID + ":" + k + " " + toID + ":" + k);
p.sendMessage("Finished replacing with matching data values.");
}
示例3: removePlayersFromIsland
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* This removes players from an island overworld and nether - used when reseting or deleting an island
* Mobs are killed when the chunks are refreshed.
* @param island to remove players from
* @param uuid
*/
public void removePlayersFromIsland(final Island island) {
// Teleport players away
for (Player player : plugin.getServer().getOnlinePlayers()) {
if (island.inIslandSpace(player.getLocation().getBlockX(), player.getLocation().getBlockZ())) {
//plugin.getLogger().info("DEBUG: in island space");
// Teleport island players to their island home
if (plugin.getPlayers().hasIsland(player.getUniqueId()) || plugin.getPlayers().inTeam(player.getUniqueId())) {
//plugin.getLogger().info("DEBUG: home teleport");
homeTeleport(player);
} else {
//plugin.getLogger().info("DEBUG: move player to spawn");
// Move player to spawn
Island spawn = getSpawn();
if (spawn != null) {
// go to island spawn
player.teleport(IslandWorld.getIslandWorld().getSpawnLocation());
//plugin.getLogger().warning("During island deletion player " + player.getName() + " sent to spawn.");
} else {
if (!player.performCommand(Settings.SPAWNCOMMAND)) {
plugin.getLogger().warning(
"During island deletion player " + player.getName() + " could not be sent to spawn so was dropped, sorry.");
}
}
}
}
}
}
示例4: onVisitorReceiveDamage
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Prevents visitors from getting damage if invinciblevisitors option is set to TRUE
* @param e
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onVisitorReceiveDamage(EntityDamageEvent e){
if(!Settings.invincibleVisitor) return;
if(!(e.getEntity() instanceof Player)) return;
Player p = (Player) e.getEntity();
if (!Util.inWorld(p) || plugin.getIslands().locationIsOnIsland(p, p.getLocation())) return;
if (Settings.invincibleVisitorOptions.contains(e.getCause())) e.setCancelled(true);
else if(e.getCause().equals(DamageCause.VOID)) {
if(plugin.getPlayers().hasIsland(p.getUniqueId())) {
Location safePlace = plugin.getIslands().getSafeHomeLocation(p.getUniqueId(), 1);
if (safePlace != null) {
p.teleport(safePlace);
// Set their fall distance to zero otherwise they crash onto their island and die
p.setFallDistance(0);
e.setCancelled(true);
return;
}
}
// No island, or no safe spot on island
if (plugin.getIslands().getSpawn() != null) {
p.teleport(plugin.getIslands().getSpawnPoint());
// Set their fall distance to zero otherwise they crash onto their island and die
p.setFallDistance(0);
e.setCancelled(true);
return;
}
// No island spawn, try regular spawn
if (!p.performCommand("spawn")) {
// If this command doesn't work, let them die otherwise they may get trapped in the void forever
return;
}
// Set their fall distance to zero otherwise they crash onto their island and die
p.setFallDistance(0);
e.setCancelled(true);
}
}
示例5: performCommand
import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void performCommand(HumanEntity human, String args) {
if (!(human instanceof Player)) {
return;
}
Player player = (Player) human;
player.performCommand(COMMAND + args);
}
示例6: sendCommand
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Execute command from player to server
*
* @param player The player
* @param command The command
* @param runFromOp If true, command will be run from OP
*/
public static void sendCommand(Player player, String command, boolean runFromOp) {
command = StringUtils.setPlaceholders(player, command);
if (runFromOp) {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
} else {
player.performCommand(command);
}
}
示例7: preformAction
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void preformAction(Player player) {
if (this.isGui) {
player.closeInventory();
}
if (this.actionType == ActionType.WORKBENCH) {
InventoryManager.get(player).openWorkbench();
} else if (this.actionType == ActionType.ENDERCHEST) {
player.openInventory(player.getEnderChest());
} else if (this.actionType == ActionType.COMMAND && command != null) {
player.performCommand(command);
}
}
示例8: run
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void run(Player player) {
player.performCommand(command.resolve(player));
}
示例9: execute
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void execute(Player player, String command) {
player.performCommand(command);
}
示例10: onVoucherReward
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onVoucherReward(RVRewardEvent e) {
Player p = e.getPlayer();
String rw = e.getReward();
Voucher v = e.getVoucher();
String reward = rw
.replace("%x%", "" + p.getLocation().getBlockX())
.replace("%y%", "" + p.getLocation().getBlockY())
.replace("%z%", "" + p.getLocation().getBlockZ())
.replace("%tier%", v.getId())
.replace("%player%", p.getName())
.replace("%limit%", "" + v.getLimit());
switch (getType(e.getAction())) {
case "CONSOLE_COMMAND":
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), reward);
break;
case "PLAYER_COMMAND":
p.performCommand(reward);
break;
case "TELL_PLAYER":
p.sendMessage(ColorUtil.translate(reward));
break;
case "BROADCAST":
Bukkit.broadcastMessage(ColorUtil.translate(reward));
break;
case "PLAY_SOUND":
Sound s = Sound.valueOf(reward);
p.playSound(p.getLocation(), s, 3, 3);
break;
case "PLAYER_TITLE":
String title = reward.contains(";") ? reward.split(";")[0] : reward;
String sub = reward.contains(";") ? reward.split(";")[1] : "";
p.sendTitle(ColorUtil.translate(title), ColorUtil.translate(sub));
break;
case "CENTER_MESSAGE":
CenterUtil.sendCenteredMessage(p, reward);
break;
case "CENTER_BROADCAST":
for (Player player : Bukkit.getOnlinePlayers()) {
CenterUtil.sendCenteredMessage(player, reward);
}
break;
case "PLAYER_CHAT":
p.sendMessage(ColorUtil.translate(reward));
break;
case "FIREWORK":
Firework fw = p.getWorld().spawn(p.getLocation(), Firework.class);
//use meta to customize the firework or add parameters to the method
fw.setVelocity(p.getLocation().getDirection().multiply(50));
fw.setGlowing(true);
break;
}
}