当前位置: 首页>>代码示例>>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;未经允许,请勿转载。