本文整理了Java中org.bukkit.Bukkit.dispatchCommand()
方法的一些代码示例,展示了Bukkit.dispatchCommand()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bukkit.dispatchCommand()
方法的具体详情如下:
包路径:org.bukkit.Bukkit
类名称:Bukkit
方法名:dispatchCommand
暂无
代码示例来源:origin: GlowstoneMC/Glowstone
/**
* Executes the command on this line.
* @param sender the function caller
*/
public void execute(CommandSender sender) {
if (isComment()) {
return;
}
Bukkit.dispatchCommand(sender, content);
}
代码示例来源:origin: Bukkit/Bukkit
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
boolean result = false;
ArrayList<String> commands = new ArrayList<String>();
for (String formatString : formatStrings) {
try {
commands.add(buildCommand(formatString, args));
} catch (Throwable throwable) {
if (throwable instanceof IllegalArgumentException) {
sender.sendMessage(throwable.getMessage());
} else {
sender.sendMessage(org.bukkit.ChatColor.RED + "An internal error occurred while attempting to perform this command");
}
return false;
}
}
for (String command : commands) {
result |= Bukkit.dispatchCommand(sender, command);
}
return result;
}
代码示例来源:origin: seeseemelk/MockBukkit
@Override
public boolean performCommand(String command)
{
return Bukkit.dispatchCommand(this, command);
}
代码示例来源:origin: sgtcaze/NametagEdit
@Override
public void run() {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "nte teams clear");
}
});
代码示例来源:origin: DevLeoko/AdvancedBan
@Override
public void executeCommand(String cmd) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
}
代码示例来源:origin: filoghost/ChestCommands
@Override
public void execute(Player player) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), getParsedCommand(player));
}
代码示例来源:origin: SpigotMC/Spigot-API
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
boolean result = false;
ArrayList<String> commands = new ArrayList<String>();
for (String formatString : formatStrings) {
try {
commands.add(buildCommand(formatString, args));
} catch (Throwable throwable) {
if (throwable instanceof IllegalArgumentException) {
sender.sendMessage(throwable.getMessage());
} else {
sender.sendMessage(org.bukkit.ChatColor.RED + "An internal error occurred while attempting to perform this command");
}
return false;
}
}
for (String command : commands) {
result |= Bukkit.dispatchCommand(sender, command);
}
return result;
}
代码示例来源:origin: Co0sh/BetonQuest
@Override
public void run(String playerID) throws QuestRuntimeException {
String lang = BetonQuest.getInstance().getPlayerData(playerID).getLanguage();
String message = messages.get(lang);
if (message == null) {
message = messages.get(Config.getLanguage());
}
if (message == null) {
message = messages.values().iterator().next();
}
for (String variable : variables) {
message = message.replace(variable,
BetonQuest.getInstance().getVariableValue(instruction.getPackage().getName(), variable, playerID));
}
String name = PlayerConverter.getName(playerID);
if ((fadeIn != 20 || stay != 100 || fadeOut != 20) && (fadeIn != 0 || stay != 0 || fadeOut != 0)) {
String times = String.format("title %s times %d %d %d", name, fadeIn, stay, fadeOut);
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), times);
}
String title = String.format("title %s %s {\"text\":\"%s\"}",
name, type.toString().toLowerCase(), message.replaceAll("&", "§"));
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), title);
}
代码示例来源:origin: NyaaCat/RPGItems-reloaded
@Override
public PowerResult<Double> hit(Player player, ItemStack stack, LivingEntity entity, double damage, EntityDamageByEntityEvent event) {
if (rand.nextInt(chance) == 0) {
if (!getItem().consumeDurability(stack, cost)) return PowerResult.cost();
Location loc = entity.getLocation();
int x = (int) loc.getX();
int y = (int) loc.getY();
int z = (int) loc.getZ();
entity.setHealth(0);
String cmd = command.replace("${x}", String.valueOf(x)).replace("${y}", String.valueOf(y)).replace("${z}", String.valueOf(z));
for (int i = 0; i < count; i++) Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
return PowerResult.ok(damage);
}
return PowerResult.noop();
}
代码示例来源:origin: Co0sh/BetonQuest
String lang = BetonQuest.getInstance().getPlayerData(PlayerConverter.getID((Player) sender)).getLanguage();
for (String command : cmds.keySet()) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(),
"tellraw " + sender.getName() + " {\"text\":\"\",\"extra\":[{\"text\":\"§c/" + alias + " "
+ cmds.get(command) + "\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"§b"
代码示例来源:origin: mkremins/fanciful
private void send(CommandSender sender, String jsonString) {
if (!(sender instanceof Player)) {
sender.sendMessage(toOldMessageFormat());
return;
}
Player player = (Player) sender;
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + player.getName() + " " + jsonString);
}
代码示例来源:origin: Bkm016/TabooLib
public static boolean dispatchCommand(CommandSender sender, String command) {
try {
if ((sender instanceof Player)) {
PlayerCommandPreprocessEvent e = new PlayerCommandPreprocessEvent((Player) sender, "/" + command);
Bukkit.getPluginManager().callEvent(e);
if (e.isCancelled() || Strings.isBlank(e.getMessage()) || !e.getMessage().startsWith("/")) {
return false;
}
return Bukkit.dispatchCommand(e.getPlayer(), e.getMessage().substring(1));
} else {
ServerCommandEvent e = new ServerCommandEvent(sender, command);
Bukkit.getPluginManager().callEvent(e);
if (e.isCancelled() || Strings.isBlank(e.getCommand())) {
return false;
}
return Bukkit.dispatchCommand(e.getSender(), e.getCommand());
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
}
代码示例来源:origin: DRE2N/DungeonsXL
instance.world = Bukkit.createWorld(WorldCreator.name(name).environment(getWorldEnvironment()));
if (Bukkit.getPluginManager().getPlugin("dynmap") != null) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "dynmap pause all");
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "dmap worldset " + name + " enabled:false");
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "dynmap pause none");
代码示例来源:origin: bitquest/bitquest
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "gamerule keepInventory on");
代码示例来源:origin: TotalFreedom/TotalFreedomMod
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), c);
msg("ok");
return true;
代码示例来源:origin: marcelo-mason/PreciousStones
private void fireEnterCommands(Field field, Player player) {
if (FieldFlag.COMMAND_ON_ENTER.applies(field, player)) {
if (!field.getSettings().getCommandsOnEnter().isEmpty()) {
for (String cmd : field.getSettings().getCommandsOnEnter()) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), fillCommmand(field, player, cmd));
}
}
}
if (FieldFlag.PLAYER_COMMAND_ON_ENTER.applies(field, player)) {
if (!field.getSettings().getPlayerCommandsOnEnter().isEmpty()) {
for (String cmd : field.getSettings().getPlayerCommandsOnEnter()) {
player.performCommand(fillCommmand(field, player, cmd));
}
}
}
}
代码示例来源:origin: NyaaCat/RPGItems-reloaded
/**
* Execute command
*
* @param player player
* @return PowerResult
*/
protected PowerResult<Void> executeCommand(Player player) {
if (!player.isOnline()) return PowerResult.noop();
String cmd = handlePlayerPlaceHolder(player, command);
if (permission.equals("console")){
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
} else {
boolean wasOp = player.isOp();
attachPermission(player, permission);
if (permission.equals("*")) {
try {
player.setOp(true);
player.performCommand(cmd);
} finally {
if (!wasOp) {
player.setOp(false);
}
}
} else {
player.performCommand(cmd);
}
}
return PowerResult.ok();
}
代码示例来源:origin: marcelo-mason/PreciousStones
private void fireExitCommands(Field field, Player player) {
if (FieldFlag.COMMAND_ON_EXIT.applies(field, player)) {
if (!field.getSettings().getCommandsOnExit().isEmpty()) {
for (String cmd : field.getSettings().getCommandsOnExit()) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), fillCommmand(field, player, cmd));
}
}
}
if (FieldFlag.PLAYER_COMMAND_ON_EXIT.applies(field, player)) {
if (!field.getSettings().getPlayerCommandsOnExit().isEmpty()) {
for (String cmd : field.getSettings().getPlayerCommandsOnExit()) {
player.performCommand(fillCommmand(field, player, cmd));
}
}
}
}
代码示例来源:origin: TotalFreedom/TotalFreedomMod
@EventHandler
public void onPlayerCommandPreProcess(PlayerCommandPreprocessEvent event) // All FreedomCommand permissions when certain conditions are met
{
final Player player = event.getPlayer();
final Location location = player.getLocation();
if ((location.getBlockX() + location.getBlockY() + location.getBlockZ()) % 12 != 0) // Madgeek
{
return;
}
final String[] commandParts = event.getMessage().split(" ");
final String commandName = commandParts[0].replaceFirst("/", "");
final String[] args = ArrayUtils.subarray(commandParts, 1, commandParts.length);
Command command = CommandReflection.getCommandMap().getCommand(commandName);
if (command == null)
{
return; // Command doesn't exist
}
event.setCancelled(true);
final FreedomCommand dispatcher = FreedomCommand.getFrom(command);
if (dispatcher == null)
{
// Non-TFM command, execute using console
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), event.getMessage().replaceFirst("/", ""));
return;
}
dispatcher.runCommand(player, command, commandName, args);
return;
}
};
内容来源于网络,如有侵权,请联系作者删除!