本文整理汇总了Java中org.bukkit.entity.Player.hasPermission方法的典型用法代码示例。如果您正苦于以下问题:Java Player.hasPermission方法的具体用法?Java Player.hasPermission怎么用?Java Player.hasPermission使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Player
的用法示例。
在下文中一共展示了Player.hasPermission方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: upElevator
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void upElevator(PlayerMoveEvent e) {
Player p = e.getPlayer();
Block b = e.getTo().getBlock().getRelative(BlockFace.DOWN);
if (p.hasPermission("ironelevators.use") && e.getFrom().getY() < e.getTo().getY()
&& b.getType() == elevatorMaterial) {
b = b.getRelative(BlockFace.UP, minElevation);
int i = maxElevation;
while (i > 0 && !(
b.getType() == elevatorMaterial
&& b.getRelative(BlockFace.UP).getType().isTransparent()
&& b.getRelative(BlockFace.UP, 2).getType().isTransparent()
)
) {
i--;
b = b.getRelative(BlockFace.UP);
}
if (i > 0) {
Location l = p.getLocation();
l.setY(l.getY() + maxElevation + 3 - i);
p.teleport(l);
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_IRONGOLEM_ATTACK, 1, 1);
}
}
}
示例2: onCommand
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You must be a player to execute this command!");
} else {
Player player = (Player) sender;
if(!player.hasPermission("ghostskull.spawn")) {
player.sendMessage(ChatColor.RED + "You do not have permission to execute this command.");
} else {
player.getInventory().addItem(plugin.constructGhostSkull());
player.playSound(player.getLocation(), Sounds.NOTE_PLING.spigot(), 10, 1.2f);
player.sendMessage(ChatColor.GREEN + "You have obtained a Ghost skull.");
}
}
return false;
}
示例3: onPlayerChat
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
String message = event.getMessage();
if (!(Main.chatHoldOn(player, "addshortenmessagelist"))) {
if (Commander.addshortenmessagelist.contains(player)) {
event.setCancelled(true);
Commander.addshortenmessagemessage = message;
String addmessage = message, addkey = Commander.addshortenmessagekey;
Commander.addshortenmessagelist.remove(player);
setMessage(addkey, addmessage, true);
Main.sendMessage(ChatColor.GREEN + "You have successfully added a new shorten message!", player);
player.sendMessage("Key: " + Main.colorcode(addkey));
player.sendMessage("Message: " + Main.colorcode(addmessage));
} else {
if (player.hasPermission("chatassets.messageshortener.use")) {
event.setMessage(Main.colorcode(replaceKey(message)));
}
}
}
String output = String.join(" ", messagewords);
return output;
}
示例4: onPlayerRequestRespawn
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerRequestRespawn(PlayerRespawnEvent event) {
Player player = event.getPlayer();
FactionUser user = this.plugin.getUserManager().getUser(player.getUniqueId());
Deathban deathban = user.getDeathban();
if (deathban != null && deathban.getRemaining() > 0L) {
if (player.hasPermission(DeathbanListener.DEATH_BAN_BYPASS_PERMISSION)) {
this.cancelRespawnKickTask(player);
user.removeDeathban();
new DelayedMessageRunnable(player, ChatColor.RED + "You would be death-banned for " + deathban.getReason() + ChatColor.RED + ", but you have access to bypass.").runTask(this.plugin);
return;
}
//TODO: FIX setcancelled
//event.setCancelled(true);
this.handleKick(player, deathban);
}
}
示例5: onBlockBreak
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onBlockBreak(BlockBreakEvent event) {
if (plugin.getEotwHandler().isEndOfTheWorld())
return;
Player player = event.getPlayer();
if (player.getGameMode() == GameMode.CREATIVE && player.hasPermission(ProtectionListener.PROTECTION_BYPASS_PERMISSION)) {
return;
}
Block block = event.getBlock();
BlockState state = block.getState();
Block subclaimObjectBlock = null;
if (!(state instanceof Sign)) {
subclaimObjectBlock = block;
} else {
Sign sign = (Sign) state;
MaterialData signData = sign.getData();
if (signData instanceof org.bukkit.material.Sign) {
org.bukkit.material.Sign materialSign = (org.bukkit.material.Sign) signData;
subclaimObjectBlock = block.getRelative(materialSign.getAttachedFace());
}
}
if (subclaimObjectBlock != null && !this.checkSubclaimIntegrity(player, subclaimObjectBlock)) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + "You cannot break this subclaimed " + subclaimObjectBlock.getType().toString() + '.');
}
}
示例6: onBlockPlaceCreative
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockPlaceCreative(BlockBreakEvent event) {
Player player = event.getPlayer();
if (player.getGameMode() == GameMode.CREATIVE && !player.hasPermission("base.command.gamemode")) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + "You are not allowed to be in gamemode! Setting you to default gamemode!");
player.setGameMode(GameMode.SURVIVAL);
}
}
示例7: addCategoriesToInventory
import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void addCategoriesToInventory(Inventory inventory, Player player) {
for (MerchantCategory category : this.categories) {
if (category.getMaterial() == null) {
Main.getInstance()
.getServer()
.getConsoleSender()
.sendMessage(
ChatWriter
.pluginMessage(ChatColor.RED
+ "Careful: Not supported material in shop category '"
+ category.getName() + "'"));
} else if ((player == null)
|| (player.hasPermission(category.getPermission()))) {
ItemStack is = new ItemStack(category.getMaterial(), 1);
ItemMeta im = is.getItemMeta();
if ((this.currentCategory != null)
&& (this.currentCategory.equals(category))) {
im.addEnchant(Enchantment.DAMAGE_ALL, 1, true);
}
im.setDisplayName(category.getName());
im.setLore(category.getLores());
is.setItemMeta(im);
inventory.addItem(new ItemStack[] { is });
}
}
}
示例8: localTeleport
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void localTeleport(Player traveler, @Nullable Player destinationPlayer) {
if(destinationPlayer != null && traveler.hasPermission(PERMISSION)) {
audiences.get(traveler).sendMessage(new Component(
new TranslatableComponent("command.server.teleporting",
new PlayerComponent(identityProvider.currentIdentity(destinationPlayer), NameStyle.VERBOSE)),
ChatColor.DARK_PURPLE
));
traveler.teleport(destinationPlayer);
}
}
示例9: run
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void run() {
Set<UUID> players=rs.getPlayerDatas().keySet();
for(UUID ps:players){
Player p = rs.getServer().getPlayer(ps);
if(p==null||p.isDead())continue;
if ((p.hasPermission("RealSurvival.unlimited")||p.hasPermission("RealSurvival.Admin"))&&!TestCMD.contains(p))
continue;
PlayerData pd=rs.getPlayerData(p);
if(pd.isSleep())
{
byte lightLevel=pd.getLight();
if(lightLevel>10){
pd.changeSleep(rs.getSleepAdd()*0.3);
continue;
}
else if(lightLevel>5){
pd.changeSleep(rs.getSleepAdd()*0.6);
continue;
}
pd.changeSleep(rs.getSleepAdd());
continue;
}else{
pd.changeSleep(-rs.getSleepSub());
continue;
}
}
}
示例10: onPlayerJoin
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
if (cm.clientModDisabler) {
Player p = e.getPlayer();
if (p.isOp() || p.hasPermission("neverlag.nosendmagiccode"))
return;
for (String code : cm.modMagicCode) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', code));
}
}
}
示例11: hasPermission
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public boolean hasPermission(Permission perm, Player p)
{
if(p.hasPermission(perm))
{
return true;
}
else
{
p.sendMessage(Translation.get("not_allowed"));
return false;
}
}
示例12: addAllOnline
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public int addAllOnline() {
int count = 0;
for(Player player : onlinePlayers.all()) {
if(!player.hasPermission(BYPASS_PERM) && add(userStore.getUser(player))) {
count++;
}
}
return count;
}
示例13: ownsGizmo
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public boolean ownsGizmo(Player player) {
if(cost <= 0) {
return true;
} else {
return player.hasPermission(this.getPermissionNode());
}
}
示例14: activity
import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void activity(Player player) {
if(player.hasPermission(AFK_FOREVER_PERM)) {
this.lastActivity.remove(player);
} else {
this.lastActivity.put(player, Instant.now());
}
}
示例15: onCommand
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player))
{
sender.sendMessage(ChatColor.RED + "This is a player-only command!");
return false;
}
Player p = (Player) sender;
if (!p.hasPermission("lotto.end") && !p.isOp())
{
sender.sendMessage(lotto.getPrefix() + ChatColor.RED + "Permission denied.");
return false;
}
if (lotto.getCurrentGame() == null || lotto.getCurrentGame().isClosed())
{
sender.sendMessage(lotto.getPrefix() + "No active game found to end!");
return false;
}
LottoGame game = lotto.getCurrentGame();
Bukkit.getScheduler().cancelTask(game.getEndTaskId());
game.end();
p.sendMessage(lotto.getPrefix() + "Successfully ended the current Lotto game!");
return true;
}