當前位置: 首頁>>代碼示例>>Java>>正文


Java Bukkit.dispatchCommand方法代碼示例

本文整理匯總了Java中org.bukkit.Bukkit.dispatchCommand方法的典型用法代碼示例。如果您正苦於以下問題:Java Bukkit.dispatchCommand方法的具體用法?Java Bukkit.dispatchCommand怎麽用?Java Bukkit.dispatchCommand使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.Bukkit的用法示例。


在下文中一共展示了Bukkit.dispatchCommand方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: apply

import org.bukkit.Bukkit; //導入方法依賴的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;
}
 
開發者ID:dracnis,項目名稱:VanillaPlus,代碼行數:24,代碼來源:CPOp.java

示例2: onInventoryClick

import org.bukkit.Bukkit; //導入方法依賴的package包/類
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
    Player player = (Player) event.getWhoClicked();
    ItemStack clicked = event.getCurrentItem();
    Inventory inventory = event.getInventory();

    if (inventory.getName().equals("Faction Management")) {

        if (clicked.getType() == Material.SKULL_ITEM) {
            if (event.getClick() == ClickType.LEFT) {
                Bukkit.dispatchCommand(player, "f promote " + clicked.getItemMeta().getDisplayName());
                event.setCancelled(true);
            }
            if (event.getClick() == ClickType.MIDDLE){
                Bukkit.dispatchCommand(player, "f leader " + clicked.getItemMeta().getDisplayName());
                event.setCancelled(true);
            }
            if (event.getClick() == ClickType.RIGHT) {
                Bukkit.dispatchCommand(player, "f demote " + clicked.getItemMeta().getDisplayName());
                event.setCancelled(true);
            }
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:25,代碼來源:FactionManagerArgument.java

示例3: finishChallenge

import org.bukkit.Bukkit; //導入方法依賴的package包/類
public void finishChallenge(Player player, boolean buy) {
	if(!buy) {
		for(Entity e : player.getWorld().getEntities()) {
			if(e.hasMetadata(metaData) && e.getMetadata(metaData).get(0).asString().contains(player.getName())) {
				e.remove();
			}
		}
		player.teleport(plugin.getChallengesFile().getVictorySpawnpoint(getChallenge(player)));
		loadData(player);
		player.playSound(player.getLocation(), Sound.ENTITY_FIREWORK_TWINKLE, 1F, 1F);
	}
	for(String cmd : plugin.getChallengesFile().getCommands(getChallenge(player))) {
		cmd = cmd.replaceAll("%s", player.getName());
		Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
	}
	if(!isTesting(player)) {
		plugin.getPlayerManager().setRank(player, getChallenge(player));
		player.sendMessage(Lang.HEADERS_CHALLENGES.toString() 
				+ Lang.CHALLENGES_COMPLETE.toString()
					.replaceAll("%s", plugin.getChallengesFile().getTitle(getChallenge(player))));
	} else {
		player.sendMessage(Lang.HEADERS_CHALLENGES.toString()
				+ Lang.CHALLENGES_TEST_COMPLETE.toString());
	}
	playerChallenge.remove(player.getName());
}
 
開發者ID:benNek,項目名稱:AsgardAscension,代碼行數:27,代碼來源:Challenge.java

示例4: run__A

import org.bukkit.Bukkit; //導入方法依賴的package包/類
private void run__A(int id){
	HashMap<Integer, ArmorStand> car = cars.get(id);
	double radius = carsR.get(id);
	int total = car.size()-1;
	
	ArmorStand A1 = car.get(1);
	
	for(int i = 1; i < total+1; i++)
	{
		ArmorStand A2 = car.get(i+1);
		
		{
			double angle = ((A1.getLocation().getYaw()+(360.0/total*i))*Math.PI / 180);
	        double x = radius*Math.cos(angle);
	        double z = radius*Math.sin(angle);
	        
	        String command = String.format("minecraft:tp @e[name=%s] %s %s %s %s %s", A2.getUniqueId().toString(), A1.getLocation().getX() + x, A1.getLocation().getY(), A1.getLocation().getZ() + z, A1.getLocation().getYaw(), A1.getLocation().getPitch());
	        Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
		}
	}
}
 
開發者ID:LimitedDani,項目名稱:Achtbaan,代碼行數:22,代碼來源:attractie.java

示例5: run__A

import org.bukkit.Bukkit; //導入方法依賴的package包/類
private void run__A(int id){
	HashMap<Integer, ArmorStand> car = cars.get(id);
	double radius = carsR.get(id);
	int total = car.size()-1;
	
	ArmorStand A1 = car.get(1);
	
	for(int i = 1; i < total+1; i++)
	{
		ArmorStand A2 = car.get(i+1);
		
		{
			double angle = ((A1.getLocation().getYaw()+(360.0/total*i))*Math.PI / 180);
	        double x = radius*Math.cos(angle);
	        double z = radius*Math.sin(angle);
	        
	        String command = String.format("tp @e[name=%s] %s %s %s %s %s", A2.getUniqueId().toString(), A1.getLocation().getX() + x, A1.getLocation().getY(), A1.getLocation().getZ() + z, A1.getLocation().getYaw(), A1.getLocation().getPitch());
	        Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
		}
	}
}
 
開發者ID:LimitedDani,項目名稱:Achtbaan,代碼行數:22,代碼來源:attractie.java

示例6: stopSound

import org.bukkit.Bukkit; //導入方法依賴的package包/類
private void stopSound(Player player, Faction faction) {
    if (player == null || faction == null || faction.getAnthem() == null) {
        return;
    }
    if (Version.andHigher(Version.MC1_10).contains(CompatibilityHandler.getInstance().getVersion())) {
        player.stopSound(faction.getAnthem());
    } else {
        Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "stopsound " + player.getName() + " master " + faction.getAnthem());
    }
}
 
開發者ID:DRE2N,項目名稱:FactionsXL,代碼行數:11,代碼來源:PlayerListener.java

示例7: onCommand

import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  	if (args.length != 1) {
  		new VotePanel((Player) sender).show();
	Bukkit.dispatchCommand(sender, "maps");
  		return true;
  	}
  	if (Scheduler.getState() != State.PREP) {
  		Chat.player(sender, "&4[SG] &cThe voting period has ended.");
  		return true;
  	}
  	int id = 1;
  	try {
  		id = Integer.parseInt(args[0]);
  	}
  	catch(NumberFormatException e) {
  		Chat.player(sender, "&4[SG] &cThat is not a valid id. Type /maps to see your choices.");
  		return true;
  	}
  	
  	Map map = Map.getByID(id);
  	if (map == null) {
  		Chat.player(sender, "&4[SG] &cCould not find a map with the ID of " + id);
  		return true;
  	}


  	map.addVote((Player) sender);
  	Chat.player(sender, "&2[SG] &aThe map, &f" + map.getTitle() + " &anow has " + map.getVotes().size() + " votes");
return true;
  }
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:32,代碼來源:VoteCmd.java

示例8: send

import org.bukkit.Bukkit; //導入方法依賴的package包/類
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);
}
 
開發者ID:Chazmondo,項目名稱:RankVouchers,代碼行數:9,代碼來源:FancyMessage.java

示例9: onCommand

import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
protected void onCommand(CommandSender sender, String[] args) {
    Player player = (Player) sender;

    if (MetadataManager.updateCooldown(player, "rtp", 20 * 60 * 10)) // 10 Minutes
        return;

    if (player.getWorld().getEnvironment() != World.Environment.NORMAL) {
        sender.sendMessage(ChatColor.RED + "You may only randomly teleport in the overworld.");
        return;
    }

    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "spreadplayers 0 0 0 15000 false " + player.getName());
    player.teleport(Utils.findSafe(player.getLocation())); // Prevent suffocation.
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:16,代碼來源:CommandRTP.java

示例10: increment

import org.bukkit.Bukkit; //導入方法依賴的package包/類
protected int increment() {
    this.level++;
    if(this.level >= MagicNumbers.MAX_WARN && Bukkit.getPlayerExact(this.playerName).isOnline() && (!Bukkit.getPlayerExact(this.playerName).hasPermission("dynamicac.staff")) && DynamicAC.instance.getCfgBoolean("dynamicac.autoban")) {
        Bukkit.dispatchCommand(Bukkit.getConsoleSender(),"ban " + this.playerName + " [DAC] Maximum Warn Level");
    }
    if(this.level >= MagicNumbers.MAX_WARN) {
        for (Player player : DynamicAC.instance.onlinestaff) {
            player.sendMessage(DynamicAC.prefix + playerName + " has reached max DAC warn level!");
        }
    }
    return level;
}
 
開發者ID:Notoh,項目名稱:DynamicAC,代碼行數:13,代碼來源:User.java

示例11: remove__A

import org.bukkit.Bukkit; //導入方法依賴的package包/類
public void remove__A()
{
	for(HashMap<Integer, ArmorStand> car : cars.values())
	{
		for(ArmorStand as : car.values())
		{
			String command = String.format("kill @e[name=%s]", as.getUniqueId().toString());
	        Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
		}
	}
}
 
開發者ID:LimitedDani,項目名稱:Achtbaan,代碼行數:12,代碼來源:attractie.java

示例12: spawnLootFor

import org.bukkit.Bukkit; //導入方法依賴的package包/類
/**
 * Spawn loot for the specific dragon battle
 * 
 * @param battle the battle to spawn loot for
 * @param dragon the dragon whose egg should be spawned
 */
public void spawnLootFor(DragonBattle battle, EnderDragon dragon) {
	Validate.notNull(battle, "Cannot spawn loot for null dragon battle");
	Validate.notNull(dragon, "Cannot spawn loot for null ender dragon");
	
	Location location = battle.getEndPortalLocation();
	
	boolean spawnEgg = RANDOM.nextDouble() * 100 <= eggSpawnChance;
	boolean spawnChest = RANDOM.nextDouble() * 100 <= chestSpawnChance;
	
	// Spawn a chest
	if (spawnChest) {
		location.getBlock().setType(Material.CHEST);
		Chest chest = (Chest) location.getBlock().getState();
		NMS_ABSTRACT.setChestName(chest, chestName);
		
		Inventory inventory = chest.getInventory();
		inventory.clear();
		
		// Spawn an egg within the chest
		if (spawnEgg) {
			ItemStack eggItem = new ItemStack(Material.DRAGON_EGG);
			ItemMeta eggMeta = eggItem.getItemMeta();
			eggMeta.setDisplayName(eggName.replace("%dragon%", dragon.getName()));
			eggMeta.setLore(eggLore);
			eggItem.setItemMeta(eggMeta);
			
			inventory.setItem(inventory.getSize() / 2, eggItem);
		}
		
		// Generate loot within the chest
		int itemGenCount = Math.max(RANDOM.nextInt(maxLootGen), minLootGen);
		for (int i = 0; i < itemGenCount; i++) {
			if (inventory.firstEmpty() == -1) break;
			
			int slot = RANDOM.nextInt(inventory.getSize());
			
			if (inventory.getItem(slot) != null) {
				i--;
				continue;
			}
			
			inventory.setItem(slot, loot.next());
		}
	}
	
	// Spawn the egg
	else if (spawnEgg) {
		location.getBlock().setType(Material.DRAGON_EGG);
	}
	
	// Execute commands
	List<Player> playersInWorld = dragon.getWorld().getPlayers();
	Player commandTarget = playersInWorld.size() > 0 ? playersInWorld.get(0) : null;
	
	for (String command : commands) {
		if (command.contains("%player%") && commandTarget == null) continue;
		
		String commandToExecute = command.replace("%dragon%", dragon.getCustomName());
		if (commandTarget != null) {
			commandToExecute = commandToExecute.replace("%player%", commandTarget.getName());
		}
		
		Bukkit.dispatchCommand(Bukkit.getConsoleSender(), commandToExecute);
	}
}
 
開發者ID:2008Choco,項目名稱:DragonEggDrop,代碼行數:72,代碼來源:DragonLoot.java

示例13: run

import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
public void run(Player player) {
    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command.resolve(player));
}
 
開發者ID:upperlevel,項目名稱:uppercore,代碼行數:5,代碼來源:ConsoleCommandLink.java

示例14: execute

import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
public void execute(Player player, String command) {
    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
}
 
開發者ID:upperlevel,項目名稱:uppercore,代碼行數:5,代碼來源:CommandAction.java

示例15: onVoucherReward

import org.bukkit.Bukkit; //導入方法依賴的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;
    }
}
 
開發者ID:Chazmondo,項目名稱:RankVouchers,代碼行數:56,代碼來源:VoucherRewardEvent.java


注:本文中的org.bukkit.Bukkit.dispatchCommand方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。