本文整理汇总了Java中org.bukkit.entity.Player.isValid方法的典型用法代码示例。如果您正苦于以下问题:Java Player.isValid方法的具体用法?Java Player.isValid怎么用?Java Player.isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Player
的用法示例。
在下文中一共展示了Player.isValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void execute(CommandSender sender, String[] args) {
if (args.length != 1) {
sender.sendMessage(ChatColor.RED + "Use as /shadowmute <name>");
} else if (args.length == 1) {
Player p2 = plugin.getServer().getPlayer(args[0]);
if (p2 != null && p2.isValid() && p2.isOnline()) {
if(ChatManager.shadowMute.contains(p2.getName())) {
sender.sendMessage(ChatColor.GREEN + p2.getName() + " was taken off the shadowmute list.");
ChatManager.shadowMute.remove(p2.getName());
} else {
sender.sendMessage(ChatColor.GREEN + p2.getName() + " was shadowmuted!");
ChatManager.shadowMute.add(p2.getName());
}
} else {
sender.sendMessage("User is not online.");
}
}
}
示例2: executePlayer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void executePlayer(Player p, PlayerDataRPG pd, String[] args) {
if (args.length != 1) {
p.sendMessage(ChatColor.RED + "Use as /gm <name>");
} else if (args.length == 1) {
Player p2 = plugin.getServer().getPlayer(args[0]);
if (p2 != null && p2.isValid() && p2.isOnline()) {
PlayerDataRPG pd2 = plugin.getPD(p2);
pd2.setRank(Rank.GAMEMASTER );
p.sendMessage(ChatColor.GREEN + p2.getName() + "'s rank set to " + pd2.getChatRankPrefix().trim() + ChatColor.GREEN + ".");
p2.sendMessage(ChatColor.GREEN + "Your rank was set to " + pd2.getChatRankPrefix().trim() + ChatColor.GREEN + ".");
RMessages.announce(ChatColor.GREEN + ChatColor.BOLD.toString() + p2.getName() + " was given gm permissions by " + p.getName() + ".");
} else {
p.sendMessage("User is not online.");
}
}
}
示例3: executePlayer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void executePlayer(Player p, PlayerDataRPG pd, String[] args) {
if (args.length != 1) {
p.sendMessage(ChatColor.RED + "Use as /builder <name>");
} else if (args.length == 1) {
Player p2 = plugin.getServer().getPlayer(args[0]);
if (p2 != null && p2.isValid() && p2.isOnline()) {
PlayerDataRPG pd2 = plugin.getPD(p2);
pd2.setRank(Rank.BUILDER);
p.sendMessage(ChatColor.GREEN + p2.getName() + "'s rank set to " + pd2.getChatRankPrefix().trim() + ChatColor.GREEN + ".");
p2.sendMessage(ChatColor.GREEN + "Your rank was set to " + pd2.getChatRankPrefix().trim() + ChatColor.GREEN + ".");
RMessages.announce(ChatColor.GREEN + ChatColor.BOLD.toString()+ p2.getName() + " was given builder permissions by " + p.getName() + ".");
} else {
p.sendMessage("User is not online.");
}
}
}
示例4: onInventoryClose
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClose(InventoryCloseEvent event) {
UUID uuid = event.getPlayer().getUniqueId();
if (currentTrade.containsKey(uuid)) {
UUID other = currentTrade.remove(uuid);
Player otherP = plugin.getServer().getPlayer(other);
if (otherP != null && otherP.isOnline() && otherP.isValid()) {
if (currentTrade.containsKey(other))
currentTrade.remove(other);
event.getPlayer().sendMessage(ChatColor.RED + "The trade with " + otherP.getName() + " was canceled.");
otherP.sendMessage(ChatColor.RED + "The trade with " + event.getPlayer().getName() + " was canceled.");
otherP.closeInventory();
} else {
event.getPlayer().sendMessage(ChatColor.RED + "The trade was canceled.");
}
}
}
示例5: executeConsole
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void executeConsole(CommandSender sender, String[] args) {
if (args.length != 2) {
sender.sendMessage(ChatColor.RED + "Use as /giveunlock <name> <unlock>");
} else if (args.length == 2) {
Unlock unlock = Unlock.valueOf(args[1].toUpperCase());
Player p2 = plugin.getServer().getPlayer(args[0]);
if (p2 != null && p2.isValid() && p2.isOnline()) {
PlayerData pd2 = plugin.getPD(p2);
pd2.addUnlock(unlock);
unlock.sendMessage(pd2);
sender.sendMessage("Gave unlock " + unlock + " to " + pd2.getName());
} else {
sender.sendMessage("User is not online.");
}
}
}
示例6: giveStealth
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void giveStealth(int seconds) {
stealthed = true;
Player p = getPlayer();
if (p != null && p.isValid())
StealthManager.giveStealth(p, seconds);
final int counter = stealthCounter;
RScheduler.schedule(plugin, new Runnable() {
public void run() {
// if stealth counter hasn't changed, then stealth has not already been removed
// if stealth has been removed, it wont be removed again (this way, past stealth timers won't affect new stealths)
if (stealthCounter == counter)
removeStealth();
}
}, RTicks.seconds(seconds));
RScheduler.schedule(plugin, new Runnable() {
public void run() {
if (stealthCounter == counter && isStealthed()) {
if (p != null && p.isValid()) {
RParticles.showWithOffset(ParticleEffect.SMOKE_NORMAL, p.getLocation().add(0, 1, 0), 1, 8);
}
RScheduler.schedule(plugin, this, RTicks.seconds(0.5));
}
}
}, RTicks.seconds(0.5));
}
示例7: executePlayer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void executePlayer(Player p, PlayerData pd, String[] args) {
if (args.length != 2) {
p.sendMessage(ChatColor.RED + "Use as /givebadge <name> <badge>");
} else if (args.length == 2) {
Badge badge = Badge.valueOf(args[1].toUpperCase());
Player p2 = plugin.getServer().getPlayer(args[0]);
if (p2 != null && p2.isValid() && p2.isOnline()) {
PlayerData pd2 = plugin.getPD(p2);
pd2.badges.add(badge);
p.sendMessage(ChatColor.GREEN + p2.getName() + "'s was given the badge " + badge.getDisplayName() + ChatColor.GREEN + ".");
RMessages.announce(ChatColor.translateAlternateColorCodes('&', "&7> &e" + pd2.getName() + "&a just received a new badge: &b" + badge.getDisplayName()));
} else {
p.sendMessage("User is not online.");
}
}
}
示例8: executePlayer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void executePlayer(Player p, PlayerData pd, String[] args) {
if (args.length != 2) {
p.sendMessage(ChatColor.RED + "Use as /removebadge <name> <badge>");
} else if (args.length == 2) {
Badge badge = Badge.valueOf(args[1].toUpperCase());
Player p2 = plugin.getServer().getPlayer(args[0]);
if (p2 != null && p2.isValid() && p2.isOnline()) {
PlayerData pd2 = plugin.getPD(p2);
pd2.badges.remove(badge);
p.sendMessage(ChatColor.GREEN + p2.getName() + "'s badge " + badge.getDisplayName() + ChatColor.GREEN + " was removed.");
} else {
p.sendMessage("User is not online.");
}
}
}
示例9: executePlayer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void executePlayer(Player p, PlayerData pd, String[] args) {
if (args.length != 1 && args.length != 2) {
p.sendMessage(ChatColor.RED + "Use as /setrank <rank> or /setrank <name> <rank>");
} else if (args.length == 1) {
pd.setRank(args[0]);
p.sendMessage(ChatColor.GREEN + "Rank set to " + pd.getChatRankPrefix().trim() + ChatColor.GREEN + ".");
} else if (args.length == 2) {
Player p2 = plugin.getServer().getPlayer(args[0]);
if (p2 != null && p2.isValid() && p2.isOnline()) {
PlayerData pd2 = plugin.getPD(p2);
pd2.setRank(args[1]);
p.sendMessage(ChatColor.GREEN + p2.getName() + "'s rank set to " + pd2.getChatRankPrefix().trim() + ChatColor.GREEN + ".");
p2.sendMessage(ChatColor.GREEN + "Your rank was set to " + pd2.getChatRankPrefix().trim() + ChatColor.GREEN + ".");
} else {
p.sendMessage("User is not online.");
}
}
}
示例10: executePlayer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void executePlayer(Player p, PlayerData pd, String[] args) {
if (args.length != 2) {
p.sendMessage(ChatColor.RED + "Use as /removeunlock <name> <unlock>");
} else if (args.length == 2) {
Unlock unlock = Unlock.valueOf(args[1].toUpperCase());
Player p2 = plugin.getServer().getPlayer(args[0]);
if (p2 != null && p2.isValid() && p2.isOnline()) {
PlayerData pd2 = plugin.getPD(p2);
pd2.removeUnlock(unlock);
p.sendMessage("Removed unlock " + unlock + " from " + pd2.getName());
} else {
p.sendMessage("User is not online.");
}
}
}
示例11: executeConsole
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void executeConsole(CommandSender sender, String[] args) {
if (args.length != 2) {
sender.sendMessage(ChatColor.RED + "Use as /removeunlock <name> <unlock>");
} else if (args.length == 2) {
Unlock unlock = Unlock.valueOf(args[1].toUpperCase());
Player p2 = plugin.getServer().getPlayer(args[0]);
if (p2 != null && p2.isValid() && p2.isOnline()) {
PlayerData pd2 = plugin.getPD(p2);
pd2.removeUnlock(unlock);
sender.sendMessage("Removed unlock " + unlock + " from " + pd2.getName());
} else {
sender.sendMessage("User is not online.");
}
}
}
示例12: executePlayer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void executePlayer(Player p, PlayerData pd, String[] args) {
if (args.length != 2) {
p.sendMessage(ChatColor.RED + "Use as /giveunlock <name> <unlock>");
} else if (args.length == 2) {
Unlock unlock = Unlock.valueOf(args[1].toUpperCase());
Player p2 = plugin.getServer().getPlayer(args[0]);
if (p2 != null && p2.isValid() && p2.isOnline()) {
PlayerData pd2 = plugin.getPD(p2);
pd2.addUnlock(unlock);
unlock.sendMessage(pd2);
p.sendMessage("Gave unlock " + unlock + " to " + pd2.getName());
} else {
p.sendMessage("User is not online.");
}
}
}
示例13: executePlayer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void executePlayer(Player p, PlayerData pd, String[] args) {
if (pd.getRank() == Rank.BUILDER)
return;
if (args.length == 0) {
p.sendMessage(ChatColor.RED + "/kick <player> <reason>");
p.sendMessage(ChatColor.RED + "WARNING: Do not abuse staff privileges.");
} else if (args.length == 1) {
p.sendMessage(ChatColor.RED + "You must give a reason for kicking!");
p.sendMessage(ChatColor.RED + "/kick <player> <reason>");
} else if (args.length >= 2) {
Player p2 = plugin.getServer().getPlayer(args[0]);
if (p2 != null && p2.isValid() && p2.isOnline()) {
StringBuilder sb = new StringBuilder();
for (int k = 1; k < args.length; k++) {
sb.append(args[k]);
sb.append(' ');
}
String reason = sb.toString().trim();
String announce = ChatColor.YELLOW + p2.getName() + ChatColor.RED + " was kicked by " + ChatColor.YELLOW + p.getName() + ChatColor.RED + " for: " + ChatColor.WHITE + ChatColor.BOLD + reason + ".";
RMessages.announce(ChatColor.GRAY + "> " + announce);
p2.kickPlayer("You were kicked by " + p.getName() + " for: " + reason + ".");
} else {
p.sendMessage("User is not online.");
}
}
}
示例14: executePlayer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void executePlayer(Player p, PlayerData pd, String[] args) {
if(pd.getRank() == Rank.BUILDER)
return;
if (args.length < 3) {
p.sendMessage(ChatColor.RED + "/mute <player> <time> <reason>");
p.sendMessage(ChatColor.RED + "WARNING: Do not abuse staff privileges.");
} else if (args.length >= 3) {
Player p2 = plugin.getServer().getPlayer(args[0]);
if (p2 != null && p2.isValid() && p2.isOnline()) {
if (!executeMute(p2.getName(), p2.getUniqueId().toString(), args, p.getName(), p2)) {
p.sendMessage(ChatColor.RED + "/mute <player> <time> <reason>");
p.sendMessage(ChatColor.RED + "WARNING: Do not abuse staff privileges.");
}
} else {
RScheduler.scheduleAsync(plugin, () -> {
OfflinePlayer offline = plugin.getServer().getOfflinePlayer(args[0]);
String name = offline.getName();
String uuid = offline.getUniqueId().toString();
RScheduler.schedule(plugin, () -> {
if (!executeMute(name, uuid, args, p.getName(), null) && p.isOnline()) {
p.sendMessage(ChatColor.RED + "/mute <player> <time> <reason>");
p.sendMessage(ChatColor.RED + "WARNING: Do not abuse staff privileges.");
}
});
});
p.sendMessage("Player is not online, executing offline mute.");
}
}
}
示例15: executeConsole
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void executeConsole(CommandSender sender, String[] args) {
if (args.length == 2) {
Badge badge = Badge.valueOf(args[1].toUpperCase());
Player p2 = plugin.getServer().getPlayer(args[0]);
if (p2 != null && p2.isValid() && p2.isOnline()) {
PlayerData pd2 = plugin.getPD(p2);
pd2.badges.add(badge);
sender.sendMessage(ChatColor.GREEN + p2.getName() + "'s was given the badge " + badge.getDisplayName() + ChatColor.GREEN + ".");
RMessages.announce(ChatColor.translateAlternateColorCodes('&', "&7> &e" + pd2.getName() + "&a just received a new badge: &b" + badge.getDisplayName()));
} else {
sender.sendMessage("User is not online.");
}
}
}