本文整理匯總了Java中org.bukkit.Bukkit.getPlayerExact方法的典型用法代碼示例。如果您正苦於以下問題:Java Bukkit.getPlayerExact方法的具體用法?Java Bukkit.getPlayerExact怎麽用?Java Bukkit.getPlayerExact使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.Bukkit
的用法示例。
在下文中一共展示了Bukkit.getPlayerExact方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: Cheak
import org.bukkit.Bukkit; //導入方法依賴的package包/類
private int Cheak(String[] args) {
if (args[0] == null) {
return 0;
} else if (Bukkit.getPlayerExact(args[0]) == null) {
return 3;
} else if (args[1] == null) {
return 0;
} else if (CheckPS(args[1]) == false) {
return 4;
} else if (args[2] == null) {
return 0;
} else if (args[3] == null) {
return 0;
} else if (CheakColor(args[3]) == false) {
return 1;
} else if (CheakFormat(args[4]) == false) {
return 2;
} else
return 233;
}
示例2: onCommand
import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) {
Chat.player(sender, "&cThis command is only available for players!");
return true;
}
Player p = (Player) sender;
if (args.length == 0) {
Chat.player(sender, "&cUse command like this: /team [message]");
return true;
}
StringBuilder sb = new StringBuilder();
for (String arg : args) {
sb.append(arg);
sb.append(" ");
}
Team team = Team.getTeam(p);
for (String s : team.getMembers()) {
Player t = Bukkit.getPlayerExact(s);
Chat.player(t, "&2/team &7" + team.getColor() + p.getName() + "&f: " + sb.toString());
return true;
}
return true;
}
示例3: incrementUser
import org.bukkit.Bukkit; //導入方法依賴的package包/類
public void incrementUser(User user, String reason) {
if(user == null) {
System.err.println("User reported null!");
return;
}
Player player = Bukkit.getPlayerExact(user.getName());
if(player != null && user.getLevel() < MagicNumbers.MAX_WARN) {
player.sendMessage(DynamicAC.prefix + "You've been warned for hacking!");
if(reason.isEmpty()) {
for (Player p : DynamicAC.instance.onlinestaff) {
p.sendMessage(DynamicAC.prefix + player.getName() + " failed a check!");
}
}
int warns = user.increment();
user.serialize();
DynamicAC.punishmentLog(user.getName() + " incremented to " + user.getLevel() + " at " + LocalDateTime.now()
+ ".");
if (warns >= MagicNumbers.MAX_WARN && !player.isOnline()) {
users.remove(user);
user = null; // so it can be garbage collected
}
}
}
示例4: getDisplayName
import org.bukkit.Bukkit; //導入方法依賴的package包/類
public static String getDisplayName(@Nullable String username, CommandSender viewer) {
if(username == null || username.trim().length() == 0 || username.trim().equalsIgnoreCase("CONSOLE")) {
return CONSOLE_DISPLAY_NAME;
} else {
Player targetPlayer = Bukkit.getPlayerExact(username, viewer);
if(targetPlayer == null) {
return ChatColor.DARK_AQUA + username;
} else {
return targetPlayer.getDisplayName(viewer);
}
}
}
示例5: runCommand
import org.bukkit.Bukkit; //導入方法依賴的package包/類
private void runCommand(Command command) {
Player player = Bukkit.getPlayerExact(command.getPlayer().getName());
if (command.isRequiredOnline() && (player == null || !player.isOnline())) {
return;
}
if (command.getRequiredSlots() > 0 && (player != null && player.isOnline())) {
if (getEmptySlots(player.getInventory()) < command.getRequiredSlots()) {
return;
}
}
if (MCMarket.getApi().setExecuted(command.getId())) {
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, () -> {
plugin.getServer().getScheduler().runTask(plugin, () -> plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), command.getCommand()));
if (command.isRepeat()) {
long period = command.getRepeatPeriod() > 0 ? 20 * 60 * 60 * command.getRepeatPeriod() : 1;
new BukkitRunnable() {
int executed = 0;
@Override
public void run() {
plugin.getServer().getScheduler().runTask(plugin, () -> plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), command.getCommand()));
executed++;
if (executed >= command.getRepeatCycles()) {
cancel();
}
}
}.runTaskTimerAsynchronously(plugin, period, period);
}
}, command.getDelay() > 0 ? 20 * command.getDelay() : 1);
}
}
示例6: updateSpectators
import org.bukkit.Bukkit; //導入方法依賴的package包/類
public static void updateSpectators() {
for (String list : getSpectators()) {
Player t = Bukkit.getPlayerExact(list);
if (t == null || !t.isOnline())
continue;
t.setAllowFlight(true);
for (Player p : Bukkit.getOnlinePlayers()) {
if (getSpectators().contains(p.getName()))
continue;
p.hidePlayer(t);
}
}
}
示例7: getOwner
import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
public Player getOwner(){
if(this.ownerIdentification == null){ return null; }
if(this.ownerIdentification instanceof UUID){
return Bukkit.getPlayer((UUID) ownerIdentification);
}else{
return Bukkit.getPlayerExact((String) this.ownerIdentification);
}
}
示例8: onCommand
import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (Rank.getRank(sender.getName()).getType().getLevel() < RankType.MOD.getLevel()) {
Chat.player(sender, "&cYou don't have permission to do this.");
return true;
}
if (args.length < 2) {
Chat.player(sender, "&cUsage: /ban [username] [reason]");
return true;
}
String username = null;
String reason = Chat.stripColor(StringUtils.join(args, " ", 1, args.length));
Player p = Bukkit.getPlayerExact(args[0]);
if (p != null)
username = p.getName();
else {
String check = Hive.getInstance().getUsername(args[0]);
if (check != null)
username = check;
}
if (username == null) {
Chat.player(sender, "&cNo player found by the name of, " + args[0]);
return true;
}
String prefix = "INSERT INTO infractions (username,staff,type,reason) VALUES ";
String content = "('" + username + "','" + sender.getName() + "','ban','" + reason + "')";
Hive.getInstance().getDatabase().update(prefix + content);
Chat.player(sender, "&4[Ban] &b" + username + " &7&ofor &c" + reason);
Ban i = new Ban(username, reason, Hive.getInstance().getServerTime());
if (p != null && p.isOnline())
p.kickPlayer(i.getKickMessage());
return true;
}
示例9: getPlayerOf
import org.bukkit.Bukkit; //導入方法依賴的package包/類
/**
* Returns the player represented by the given identification (retrieved by using this class)
* <p/>
* This method makes use of both player names and UUIDs to find the required online player
*
* @param identification identification to search with
* @return player represented by the given identification, or null if the player is not online
*/
public static Player getPlayerOf(Object identification) {
if (supportsUuid()) {
if (identification instanceof UUID) {
return Bukkit.getPlayer((UUID) identification);
} else if (identification instanceof String) {
return Bukkit.getPlayer(convertUUID((String) identification));
}
} else if (identification instanceof String) {
return Bukkit.getPlayerExact((String) identification);
}
return null;
}
示例10: reset
import org.bukkit.Bukkit; //導入方法依賴的package包/類
protected void reset() {
Player player = Bukkit.getPlayerExact(playerName);
if(player != null && player.isOnline()) {
player.sendMessage(DynamicAC.prefix + "Your warn level was cleared!");
}
this.level = 0;
serialize();
}
示例11: update
import org.bukkit.Bukkit; //導入方法依賴的package包/類
public void update() {
if (entity != null) {
//((CraftEntity) entity).getHandle().setEquipment(4, new net.minecraft.server.v1_5_R2.ItemStack(Item.DIAMOND_HELMET));
//Chat.server(((CraftEntity) entity).getHandle().getEquipment().toString());
Player owner = Bukkit.getPlayerExact(this.owner);
if (owner == null)
return;
entity.setCustomName(nameColor + name);
entity.setCustomNameVisible(true);
if (entity instanceof Tameable) {
tamed = true;
((Tameable) entity).setTamed(true);
((Tameable) entity).setOwner(owner);
}
if (entity instanceof Ageable && age != null) {
if (getAge() == Age.BABY)
((Ageable) entity).setBaby();
((Ageable) entity).setAgeLock(true);
}
if (entity instanceof Zombie && age != null) {
if (getAge() == Age.BABY)
((Zombie) entity).setBaby(true);
}
if (entity instanceof Sheep && color != null) {
((Sheep) entity).setColor(getColor());
}
}
}
示例12: report
import org.bukkit.Bukkit; //導入方法依賴的package包/類
private static void report(String playername, Player reporter, String reason, String... message) {
Player player = Bukkit.getPlayerExact(playername);
if (player == null) {
reporter.sendMessage(ChatColor.RED + "That player cannot be found!");
return;
}
for (Player p : DynamicAC.instance.onlinestaff) {
p.sendMessage(DynamicAC.prefix + ChatColor.AQUA + reporter.getName() + " reported " + player.getName() +
" for " + reason + " with this message: " + ChatColor.GOLD + (message[0] != null ? message[0] : "") + (message[1] != null ? message[1] : "") + (message[2] != null ? message[2] : "") + (message[3] != null ? message[3] : "") + (message[4] != null ? message[4] : "") + (message[5] != null ? message[5] : "") + (message[6] != null ? message[6] : "") + (message[7] != null ? message[7] : "") + (message[8] != null ? message[8] : "") + (message[9] != null ? message[9] : "") + (message[10] != null ? message[10] : ""));
}
}
示例13: createThread
import org.bukkit.Bukkit; //導入方法依賴的package包/類
protected void createThread() {
playerThread = new Thread(new Runnable() {
@Override
public void run() {
while (!destroyed) {
long startTime = System.currentTimeMillis();
synchronized (SongPlayer.this) {
if (playing) {
calculateFade();
tick++;
if (tick > song.getLength()) {
playing = false;
tick = -1;
SongEndEvent event = new SongEndEvent(SongPlayer.this);
Bukkit.getPluginManager().callEvent(event);
if (autoDestroy) {
destroy();
return;
}
}
for (String s : playerList) {
@SuppressWarnings("deprecation")
Player p = Bukkit.getPlayerExact(s);
if (p == null) {
// offline...
continue;
}
playTick(p, tick);
}
}
}
long duration = System.currentTimeMillis() - startTime;
float delayMillis = song.getDelay() * 50;
if (duration < delayMillis) {
try {
Thread.sleep((long) (delayMillis - duration));
} catch (InterruptedException e) {
// do nothing
}
}
}
}
});
playerThread.setPriority(Thread.MAX_PRIORITY);
playerThread.start();
}
示例14: doesPlayerExist
import org.bukkit.Bukkit; //導入方法依賴的package包/類
public static boolean doesPlayerExist(String name) {
return Bukkit.getPlayerExact(name) != null;
}
示例15: createThread
import org.bukkit.Bukkit; //導入方法依賴的package包/類
protected void createThread() {
playerThread = new Thread(new Runnable() {
@Override
public void run() {
while (!destroyed) {
long startTime = System.currentTimeMillis();
synchronized (SongPlayer.this) {
if (playing) {
calculateFade();
tick++;
if (tick > song.getLength()) {
playing = false;
tick = -1;
SongEndEvent event = new SongEndEvent(SongPlayer.this);
Bukkit.getPluginManager().callEvent(event);
if (autoDestroy) {
destroy();
return;
}
}
for (String s : playerList) {
Player p = Bukkit.getPlayerExact(s);
if (p == null) {
// offline...
continue;
}
playTick(p, tick);
}
}
}
long duration = System.currentTimeMillis() - startTime;
float delayMillis = song.getDelay() * 50;
if (duration < delayMillis) {
try {
Thread.sleep((long) (delayMillis - duration));
} catch (InterruptedException e) {
// do nothing
}
}
}
}
});
playerThread.setPriority(Thread.MAX_PRIORITY);
playerThread.start();
}