本文整理汇总了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;
}
示例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] 退出锁定箱子模式");
}
}
}
}
示例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] 你选择了一个不属于你的箱子,你无法对此进行操作");
}
}
}
}
}
示例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+"查询失败,点击的不是箱子");
}
}
}
示例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());
}
示例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);
}
示例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);
}
}
示例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();
}
}
}
示例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());
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}