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


Java Player.sendMessage方法代碼示例

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


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

示例1: execute

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (!this.testPermission(sender)) {
        return true;
    }

    if (args.length < 2) {
        sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));

        return false;
    }

    String name = args[0].toLowerCase();

    Player player = sender.getServer().getPlayer(name);
    if (player == null) {
        sender.sendMessage(new TranslationContainer("commands.generic.player.notFound"));
        return true;
    }

    if (Objects.equals(player, sender)) {
        sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.message.sameTarget"));
        return true;
    }

    String msg = "";
    for (int i = 1; i < args.length; i++) {
        msg += args[i] + " ";
    }
    if (msg.length() > 0) {
        msg = msg.substring(0, msg.length() - 1);
    }

    String displayName = (sender instanceof Player ? ((Player) sender).getDisplayName() : sender.getName());

    sender.sendMessage("[" + sender.getName() + " -> " + player.getDisplayName() + "] " + msg);
    player.sendMessage("[" + displayName + " -> " + player.getName() + "] " + msg);

    return true;
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:41,代碼來源:TellCommand.java

示例2: onChestLock

import cn.nukkit.Player; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL,ignoreCancelled = true)
public void onChestLock(PlayerInteractEvent event){
    if(plugin.getLockSetting().containsKey(event.getPlayer().getName())){
        event.setCancelled();
        Block block = event.getBlock();
        Player player = event.getPlayer();
        if(block.getId()==Block.CHEST){
            BlockEntity chestP = block.getLevel().getBlockEntity(block);
            if(chestP instanceof BlockEntityChest){
                BlockEntityChest chest = (BlockEntityChest)chestP;
                if(chest.namedTag.contains("Owner")){
                    if(Objects.equals(player.getName(),ChestLocker.getInstance().getChestOwner(chest))){
                        player.sendMessage(TextFormat.GRAY+"[ChestLocker] 這個箱子已經被你鎖上過了");
                    }else{
                        player.sendMessage(TextFormat.GRAY+"[ChestLocker] 這個箱子已經被[ "+ChestLocker.getInstance().getChestOwner(chest)+" ]鎖上了,你無法再次鎖定");
                    }
                }else{
                    chest.namedTag.putString("Owner",player.getName());

                    player.sendMessage(TextFormat.GOLD+"[ChestLocker] 成功鎖上箱子,這個箱子的擁有者變更為 [ "+player.getName()+" ]");
                    if(chest.getPair()!=null){
                        BlockEntityChest chestPair = chest.getPair();
                        ChestLocker.getInstance().CopyChestInformation(chest,chestPair);
                    }
                }
                //this.plugin.getLogger().info("chest  "+chest.namedTag.getAllTags());
                //this.plugin.getLogger().info("chestPair   "+ chest.namedTag.getAllTags());
                plugin.getLockSetting().remove(player.getName());

                player.sendMessage(TextFormat.GRAY+"[ChestLocker] 退出鎖定箱子模式");
            }

        }
    }
}
 
開發者ID:zzz1999,項目名稱:ChestLocker,代碼行數:36,代碼來源:EventListener.java

示例3: onUnlockChest

import cn.nukkit.Player; //導入方法依賴的package包/類
@EventHandler
public void onUnlockChest(PlayerInteractEvent event){
    if(plugin.getUnLockSetting().containsKey(event.getPlayer().getName())){
        event.setCancelled();
        Block block = event.getBlock();
        Player player = event.getPlayer();
        if(block.getId()==Block.CHEST){
            BlockEntity chestP = block.getLevel().getBlockEntity(block);
            if(chestP instanceof BlockEntityChest){
                BlockEntityChest chest = (BlockEntityChest)chestP;
                if(Objects.equals(player.getName(),ChestLocker.getInstance().getChestOwner(chest))){
                    chest.namedTag.remove("Owner");
                    chest.namedTag.remove("Guest");
                    for(Player p : chest.getInventory().getViewers()){
                        chest.getInventory().onClose(p);
                    }
                    player.sendMessage(TextFormat.RED+"[ChestLocker] 你以解鎖該箱子,並且刪除所有共享該箱子的玩家信息");
                    plugin.getUnLockSetting().remove(player.getName());

                    player.sendMessage(TextFormat.AQUA+"[ChestLocker] 以退出解鎖箱子模式");
                }else{
                    player.sendMessage(TextFormat.YELLOW+"[ChestLocker] 你選擇了一個不屬於你的箱子,你無法對此進行操作");
                }

            }
        }
    }
}
 
開發者ID:zzz1999,項目名稱:ChestLocker,代碼行數:29,代碼來源:EventListener.java

示例4: DemandChest

import cn.nukkit.Player; //導入方法依賴的package包/類
@EventHandler
public void DemandChest(PlayerInteractEvent event){
    if(ChestLocker.getInstance().getDemandChest().containsKey(event.getPlayer().getName())){
        if(event.getBlock().getId() == Block.CHEST){
            event.setCancelled();
            Block block = event.getBlock();
            if(block.getLevel().getBlockEntity(block) instanceof BlockEntityChest){
                BlockEntityChest chest = (BlockEntityChest) block.getLevel().getBlockEntity(block);
                Player p = event.getPlayer();
                p.sendMessage(TextFormat.LIGHT_PURPLE+"----------------\n["+block.getName()+"]"+" 箱子信息如下:");
                p.sendMessage(TextFormat.LIGHT_PURPLE+"箱子所有者: ["+(chest.namedTag.exist("Owner") ? chest.namedTag.getString("Owner") : "無主")+"]");
                if(chest.namedTag.exist("Guest")) {
                    List<StringTag> list = chest.namedTag.getList("Guest",StringTag.class).getAll();
                    p.sendMessage(TextFormat.LIGHT_PURPLE+"箱子共享者:");
                    for (StringTag aList : list) {
                        p.sendMessage(TextFormat.LIGHT_PURPLE+aList.data);
                    }

                }
                p.sendMessage(TextFormat.LIGHT_PURPLE+"----------------");
                ChestLocker.getInstance().getDemandChest().remove(event.getPlayer().getName());
            }
        }else{
            event.getPlayer().sendPopup(TextFormat.GRAY+"查詢失敗,點擊的不是箱子");
        }
    }
}
 
開發者ID:zzz1999,項目名稱:ChestLocker,代碼行數:28,代碼來源:EventListener.java

示例5: getList

import cn.nukkit.Player; //導入方法依賴的package包/類
private void getList(Player player) {
	StringBuilder str = new StringBuilder();
	for (String s : DataBase.getInstance().mine.keySet()) {
		str.append(DataBase.message(
				DataBase.getInstance().lengthString(25, s) + "(" + DataBase.getInstance().toBlock(s).getName()
						+ ") : " + DataBase.getInstance().mine.get(s) + "\n"));
	}
	player.sendMessage(str.toString());
}
 
開發者ID:angelless,項目名稱:MineLess,代碼行數:10,代碼來源:addMineCommand.java

示例6: rekit

import cn.nukkit.Player; //導入方法依賴的package包/類
public static void rekit(Player player) {
	player.getInventory().clearAll();
	player.getInventory().clearAll();
	String name = player.getName();
	HashMap<String,Integer> map = mysql.getskills(name);
	if(Main.skillc.exists("s"+map.get("skill")+"name")){
		player.getInventory().setArmorItem(0,Item.get(Main.skillc.getInt("s"+map.get("skill")+"a"),0,1));//ヘルメット
		player.getInventory().setArmorItem(1,Item.get(Main.skillc.getInt("s"+map.get("skill")+"b"),0,1));//ヘルメット
		player.getInventory().setArmorItem(2,Item.get(Main.skillc.getInt("s"+map.get("skill")+"c"),0,1));//ヘルメット
		player.getInventory().setArmorItem(3,Item.get(Main.skillc.getInt("s"+map.get("skill")+"d"),0,1));//ヘルメット
		player.getInventory().sendArmorContents(player);
		if(Main.skillc.getInt("s"+map.get("skill")+"ef1") !=0){
		player.addEffect(Effect.getEffect(Main.skillc.getInt("s"+map.get("skill")+"ef1")).setDuration(1000000).setAmplifier(2).setVisible(true));
		}
		if(Main.skillc.getInt("s"+map.get("skill")+"ef2") !=0){
		player.addEffect(Effect.getEffect(Main.skillc.getInt("s"+map.get("skill")+"ef2")).setDuration(1000000).setAmplifier(2).setVisible(true));
		}
	}
	int mai =map.get("gslot");
	int i = 1;
	while(mai >= i){
		player.getInventory().addItem(Item.get(346, 0, 1).setCustomName(Main.gunlangjpn.getString(map.get("gun"+i)+"_name")).clone());
		i++;
	}
	player.sendMessage("[ArrowGun] "+lj.rekit_comp);

}
 
開發者ID:haniokasai,項目名稱:NuclearGunWars-plugin,代碼行數:28,代碼來源:gunsys.java

示例7: chatEvent

import cn.nukkit.Player; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void chatEvent(PlayerChatEvent event) throws NullPointerException{
   	Player player = event.getPlayer();
	String name   = player.getName().toLowerCase();
   	if(!Main.canchat.get(name)){
   		player.sendMessage(Main.chatred+ "" +"[Arrowgun]"+lj.cantchat);
   		event.setCancelled(true);
   	}
   }
 
開發者ID:haniokasai,項目名稱:NuclearGunWars-plugin,代碼行數:10,代碼來源:events.java

示例8: onMove

import cn.nukkit.Player; //導入方法依賴的package包/類
@EventHandler
public void onMove(PlayerMoveEvent event) {
    Player player = event.getPlayer();
    if (AntiCheatAPI.getInstance().getMasterConfig().getAntiAutoAim()) {
        if (AntiAutoAim.containsKey(player.getName())) {
            AntiAutoAim.get(player.getName()).move(player);
        } else {
            AntiAutoAim.put(player.getName(), new AntiAutoAim(event.getPlayer()));
        }
    }
    if (AntiCheatAPI.getInstance().getMasterConfig().getAntiSpeed()) {
        AntiSpeed antiSpeed = new AntiSpeed(player);
        if (antiSpeed.isCheat()) {
            if(!teleport.contains(player.getName())) {
                AntiCheatAPI.getInstance().addRecord(player, antiSpeed.getCheatType());
                player.sendMessage(TextFormat.RED + "We detected that you used to accelerate. Perhaps this is a misjudgment.");
                event.setCancelled();
            }else{
                teleport.remove(player.getName());
            }
        }
    }
    if (AntiCheatAPI.getInstance().getMasterConfig().getCheckBB()) {
        CheckBB checkBB = new CheckBB(player);
        if (checkBB.isCheat()) {
            AntiCheatAPI.getInstance().addRecord(player, checkBB.getCheatType());
            //player.sendMessage(TextFormat.RED+"We detected that you used to accelerate. Perhaps this is a misjudgment.");
            //player.teleport(player.getLocation().add(0,1.5,0));
            event.setCancelled();
        }
    }
}
 
開發者ID:WetABQ,項目名稱:Nukkit-AntiCheat,代碼行數:33,代碼來源:EventListener.java

示例9: onChat

import cn.nukkit.Player; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void onChat(PlayerChatEvent event) {
    Player player = event.getPlayer();
    String msg = event.getMessage();
    CheckChat checkChat = new CheckChat(player, msg);
    CheckWords checkWords = new CheckWords(player, msg);
    if (AntiCheatAPI.getInstance().getMasterConfig().getCheckChat() && checkChat.isCheat()) {
        AntiCheatAPI.getInstance().addRecord(player, checkChat.getCheatType());
        player.sendMessage(TextFormat.RED + "You chat faster than predetermined value.");
        event.setCancelled();
    }
    if (AntiCheatAPI.getInstance().getMasterConfig().getCheckChatWord() && checkWords.isCheat()) {
        event.setMessage(checkWords.ChangeMessage());
    }
}
 
開發者ID:WetABQ,項目名稱:Nukkit-AntiCheat,代碼行數:16,代碼來源:EventListener.java

示例10: onActivate

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean onActivate(Item item, Player player) {
    int time = this.getLevel().getTime() % Level.TIME_FULL;

    boolean isNight = (time >= Level.TIME_NIGHT && time < Level.TIME_SUNRISE);

    if (player != null && !isNight) {
        player.sendMessage(new TranslationContainer("tile.bed.noSleep"));
        return true;
    }

    Block blockNorth = this.north();
    Block blockSouth = this.south();
    Block blockEast = this.east();
    Block blockWest = this.west();

    Block b;
    if ((this.meta & 0x08) == 0x08) {
        b = this;
    } else {
        if (blockNorth.getId() == this.getId() && (blockNorth.meta & 0x08) == 0x08) {
            b = blockNorth;
        } else if (blockSouth.getId() == this.getId() && (blockSouth.meta & 0x08) == 0x08) {
            b = blockSouth;
        } else if (blockEast.getId() == this.getId() && (blockEast.meta & 0x08) == 0x08) {
            b = blockEast;
        } else if (blockWest.getId() == this.getId() && (blockWest.meta & 0x08) == 0x08) {
            b = blockWest;
        } else {
            if (player != null) {
                player.sendMessage(new TranslationContainer("tile.bed.notValid"));
            }

            return true;
        }
    }

    if (player != null && !player.sleepOn(b)) {
        player.sendMessage(new TranslationContainer("tile.bed.occupied"));
    }


    return true;
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:45,代碼來源:BlockBed.java

示例11: onActivate

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean onActivate(Item item, Player player) {
    if (this.getLevel().getDimension() != Level.DIMENSION_OVERWORLD) {
        BedExplosionEvent event = new BedExplosionEvent(player, this, 4);
        Server.getInstance().getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            return true;
        }
        Explosion explosion = new Explosion(this, event.getForce(), this);
        explosion.explodeA();

        return false;
    } 

    int time = this.getLevel().getTime() % Level.TIME_FULL;

    boolean isNight = (time >= Level.TIME_NIGHT && time < Level.TIME_SUNRISE);

    if (player != null && !isNight) {
        player.sendMessage(TextFormat.GRAY + "You can only sleep at night");
        return true;
    }

    Block blockNorth = this.north();
    Block blockSouth = this.south();
    Block blockEast = this.east();
    Block blockWest = this.west();

    Block b;
    if ((this.meta & 0x08) == 0x08) {
        b = this;
    } else {
        if (blockNorth.getId() == this.getId() && (blockNorth.meta & 0x08) == 0x08) {
            b = blockNorth;
        } else if (blockSouth.getId() == this.getId() && (blockSouth.meta & 0x08) == 0x08) {
            b = blockSouth;
        } else if (blockEast.getId() == this.getId() && (blockEast.meta & 0x08) == 0x08) {
            b = blockEast;
        } else if (blockWest.getId() == this.getId() && (blockWest.meta & 0x08) == 0x08) {
            b = blockWest;
        } else {
            if (player != null) {
                player.sendMessage(TextFormat.GRAY + "This bed is incomplete");
            }

            return true;
        }
    }

    if (player != null && !player.sleepOn(b)) {
        player.sendMessage(TextFormat.GRAY + "This bed is occupied");
    }


    return true;
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:57,代碼來源:BlockBed.java

示例12: onActivate

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean onActivate(Item item, Player player) {
    int time = this.getLevel().getTime() % Level.TIME_FULL;

    boolean isNight = (time >= Level.TIME_NIGHT && time < Level.TIME_SUNRISE);

    if (player != null && !isNight) {
        player.sendMessage(TextFormat.GRAY + "You can only sleep at night");
        return true;
    }

    Block blockNorth = this.north();
    Block blockSouth = this.south();
    Block blockEast = this.east();
    Block blockWest = this.west();

    Block b;
    if ((this.meta & 0x08) == 0x08) {
        b = this;
    } else {
        if (blockNorth.getId() == this.getId() && (blockNorth.meta & 0x08) == 0x08) {
            b = blockNorth;
        } else if (blockSouth.getId() == this.getId() && (blockSouth.meta & 0x08) == 0x08) {
            b = blockSouth;
        } else if (blockEast.getId() == this.getId() && (blockEast.meta & 0x08) == 0x08) {
            b = blockEast;
        } else if (blockWest.getId() == this.getId() && (blockWest.meta & 0x08) == 0x08) {
            b = blockWest;
        } else {
            if (player != null) {
                player.sendMessage(TextFormat.GRAY + "This bed is incomplete");
            }

            return true;
        }
    }

    if (player != null && !player.sleepOn(b)) {
        player.sendMessage(TextFormat.GRAY + "This bed is occupied");
    }


    return true;
}
 
開發者ID:FrontierDevs,項目名稱:Jenisys3,代碼行數:45,代碼來源:BlockBed.java

示例13: onCommand

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
	if (!this.testPermission(sender)) {
		//sender.sendMessage(this.getPlugin().translateMessage("has-no-permission"));
		return true;
	}


	if (args.length < 2) {
		sender.sendMessage(this.getPlugin().translateMessage("give-format-error", "cmd", this.getName()));
		return true;
	}

	float to = Float.parseFloat(args[1]);

	Player p = Utils.getPlayer(args[0]);
	String name;
	if (p == null) {
		name = args[0];
	} else {
		name = p.getName();
	}

	if (Objects.equals(name, "")) {
		sender.sendMessage(getPlugin().translateMessage("invalid-name", "cmd", this.getName()));
		return true;
	}

	if (!getPlugin().addMoney(name, to, CurrencyType.SECOND)) {
		sender.sendMessage(getPlugin().translateMessage("give-failed",
                   "amount", to,
                   "type", getPlugin().getCurrency2(),
				"name", name));
		return true;
	}

	if (p != null) {
		p.sendMessage(getPlugin().translateMessage("give-done",
				"name", sender.getName(),
                   "amount", to,
                   "type", getPlugin().getCurrency2()));
	}
	sender.sendMessage(getPlugin().translateMessage("give-success",
               "amount", to,
               "type", getPlugin().getCurrency2(),
			"name", name));
	return true;
}
 
開發者ID:Him188,項目名稱:Money,代碼行數:49,代碼來源:Give2Command.java

示例14: onCommand

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
	if (!this.testPermission(sender)) {
		//sender.sendMessage(this.getPlugin().translateMessage("has-no-permission"));
		return true;
	}
	if (!(sender instanceof Player)) {
		sender.sendMessage(this.getPlugin().translateMessage("use-in-game"));
		return true;
	}

	if (args.length < 2) {
		sender.sendMessage(this.getPlugin().translateMessage("pay-format-error", "cmd", this.getName()));
		return true;
	}

	float to = Float.parseFloat(args[1]);
	float money = getPlugin().getMoney((Player) sender);
	if (money < to) {
		sender.sendMessage(this.getPlugin().translateMessage("pay-value-error"));
		return true;
	}
	if (money < 0) {
		sender.sendMessage(this.getPlugin().translateMessage("pay-value-error-1"));
		return true;
	}
	if (money - to < Float.parseFloat(getPlugin().getConfig().get("pay-1-limit").toString())) {
		sender.sendMessage(this.getPlugin().translateMessage("pay-can-not-less-than-initiation",
				"amount", (Float.parseFloat(getPlugin().getConfig().get("pay-1-limit").toString())),
				"type", getPlugin().getCurrency1()));
		return true;
	}

	Player p = Utils.getPlayer(args[0]);
	String name;
	if (p == null) {
		name = args[0];
	} else {
		name = p.getName();
	}

	if (Objects.equals(name, "")) {
		sender.sendMessage(this.getPlugin().translateMessage("invalid-name", "cmd", this.getName()));
		return true;
	}


	if (!getPlugin().reduceMoney((Player) sender, to)) {
		sender.sendMessage(this.getPlugin().translateMessage("pay-failed",
				"amount", (Float.parseFloat(args[1])),
				"type", getPlugin().getCurrency1(),
				"name", name));
		return true;
	}

	if (!getPlugin().addMoney((Player) sender, to)) {
		sender.sendMessage(this.getPlugin().translateMessage("pay-failed",
				"amount", (Float.parseFloat(args[1])),
				"type", getPlugin().getCurrency1(),
				"name", name));
		getPlugin().addMoney((Player) sender, to);
		return true;
	}

	if (p != null) {
		p.sendMessage(this.getPlugin().translateMessage("pay-for-you",
				"name", (Float.parseFloat(args[1])),
				"type", getPlugin().getCurrency1()));
	}

	sender.sendMessage(this.getPlugin().translateMessage("pay-success",
			"amount", (Float.parseFloat(args[1])),
			"type", getPlugin().getCurrency1(),
			"name", name));
	return true;
}
 
開發者ID:Him188,項目名稱:Money,代碼行數:77,代碼來源:Pay1Command.java

示例15: onCommand

import cn.nukkit.Player; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
	if (!this.testPermission(sender)) {
		//sender.sendMessage(this.getPlugin().translateMessage("has-no-permission"));
		return true;
	}

	if (args.length < 2) {
		sender.sendMessage(this.getPlugin().translateMessage("give-format-error", "cmd", this.getName()));
		return true;
	}

	float to = Float.parseFloat(args[1]);

	Player p = Utils.getPlayer(args[0]);
	String name;
	if (p == null) {
		name = args[0];
	} else {
		name = p.getName();
	}

	if (Objects.equals(name, "")) {
		sender.sendMessage(getPlugin().translateMessage("invalid-name", "cmd", this.getName()));
		return true;
	}

	if (!getPlugin().addMoney(name, to)) {
		sender.sendMessage(getPlugin().translateMessage("give-failed",
                   "amount", to,
                   "type", getPlugin().getCurrency1(),
				"name", name));

		return true;
	}

	if (p != null) {
		p.sendMessage(getPlugin().translateMessage("give-done",
				"name", sender.getName(),
                   "amount", to,
                   "type", getPlugin().getCurrency1()));
	}

	sender.sendMessage(getPlugin().translateMessage("give-success",
               "amount", to,
               "type", getPlugin().getCurrency1(),
			"name", name));
	return true;
}
 
開發者ID:Him188,項目名稱:Money,代碼行數:50,代碼來源:Give1Command.java


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