当前位置: 首页>>代码示例>>Java>>正文


Java Player.hasPermission方法代码示例

本文整理汇总了Java中org.spongepowered.api.entity.living.player.Player.hasPermission方法的典型用法代码示例。如果您正苦于以下问题:Java Player.hasPermission方法的具体用法?Java Player.hasPermission怎么用?Java Player.hasPermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.spongepowered.api.entity.living.player.Player的用法示例。


在下文中一共展示了Player.hasPermission方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: printCorrectPerm

import org.spongepowered.api.entity.living.player.Player; //导入方法依赖的package包/类
private void printCorrectPerm(int cost, Player player)
{
    if (cost != 0)
    {
        if (player.hasPermission("pixelupgrade.command.other.checkegg"))
            player.sendMessage(Text.of("§4Usage: §c/" + commandAlias + " [optional target] <slot, 1-6> {-c to confirm}"));
        else
            player.sendMessage(Text.of("§4Usage: §c/" + commandAlias + " <slot> {-c to confirm} §7(no perms for target)"));
    }
    else
    {
        if (player.hasPermission("pixelupgrade.command.other.checkegg"))
            player.sendMessage(Text.of("§4Usage: §c/" + commandAlias + " [optional target] <slot, 1-6>"));
        else
            player.sendMessage(Text.of("§4Usage: §c/" + commandAlias + " <slot> §7(no perms for target)"));
    }
}
 
开发者ID:xPXpanD,项目名称:PixelUpgrade,代码行数:18,代码来源:CheckEgg.java

示例2: onChangeBlockEvent

import org.spongepowered.api.entity.living.player.Player; //导入方法依赖的package包/类
@Listener
public void onChangeBlockEvent(ChangeBlockEvent.Break e, @First Player player) {
    if (plugin.getMainConfig().isUseSigns()) {
        if (player.hasPermission("minecraftmarket.signs")) {
            if (e.getTransactions().size() > 0) {
                BlockSnapshot blockSnapshot = e.getTransactions().get(0).getOriginal();
                Optional<Location<World>> optionalLocation = blockSnapshot.getLocation();
                if (optionalLocation.isPresent()) {
                    if (plugin.getSignsConfig().getDonorSignFor(optionalLocation.get()) != null) {
                        if (plugin.getSignsConfig().removeDonorSign(optionalLocation.get())) {
                            player.sendMessage(Colors.color(I18n.tl("prefix") + " " + I18n.tl("sign_removed")));
                            plugin.getSignsTask().updateSigns();
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:MinecraftMarket,项目名称:MinecraftMarket-Plugin,代码行数:20,代码来源:SignsListener.java

示例3: allowAction

import org.spongepowered.api.entity.living.player.Player; //导入方法依赖的package包/类
public boolean allowAction(Player player, OptionalInt acceptableActionIntervalTickForInventory)
{
    boolean denyAction = false;
    long now = player.getWorld().getProperties().getTotalTime();
    if (!player.hasPermission("virtualchest.bypass") && this.tickFromLastAction.containsKey(player))
    {
        int coolDown = acceptableActionIntervalTickForInventory.orElse(this.acceptableActionIntervalTick);
        long boundary = this.tickFromLastAction.get(player) + coolDown;
        denyAction = now < boundary;
    }
    if (denyAction)
    {
        return false;
    }
    this.tickFromLastAction.put(player, now);
    return true;
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:18,代码来源:VirtualChestActionIntervalManager.java

示例4: getBackpackSize

import org.spongepowered.api.entity.living.player.Player; //导入方法依赖的package包/类
public int getBackpackSize(Player player, Integer size) {
    if (size == 0) {
        if (player.hasPermission(VTPermissions.COMMAND_BACKPACK_SIZE_SIX))
            return 6;
        if (player.hasPermission(VTPermissions.COMMAND_BACKPACK_SIZE_FIVE))
            return 5;
        if (player.hasPermission(VTPermissions.COMMAND_BACKPACK_SIZE_FOUR))
            return 4;
        if (player.hasPermission(VTPermissions.COMMAND_BACKPACK_SIZE_THREE))
            return 3;
        if (player.hasPermission(VTPermissions.COMMAND_BACKPACK_SIZE_TWO))
            return 2;
        if (player.hasPermission(VTPermissions.COMMAND_BACKPACK_SIZE_ONE))
            return 1;
        return 1;
    } else {
        if (size < 6) {
            return 6;
        } else {
            return size;
        }
    }

}
 
开发者ID:poqdavid,项目名称:VirtualTool,代码行数:25,代码来源:BackpackCMD.java

示例5: startBlockCasePreview

import org.spongepowered.api.entity.living.player.Player; //导入方法依赖的package包/类
@Listener(order = Order.LATE)
public void startBlockCasePreview(InteractBlockEvent.Primary.MainHand event) {
    Optional<Player> optional_player = event.getCause().first(Player.class);
    if (!optional_player.isPresent()) return;
    Player player = optional_player.get();
    Optional<Location<World>> optional_location = event.getTargetBlock().getLocation();
    if (!optional_location.isPresent()) return;
    Location<World> location = optional_location.get();
    for (Manager manager : GWMCrates.getInstance().getCreatedManagers()) {
        String manager_id = manager.getId();
        Case caze = manager.getCase();
        if (!(caze instanceof BlockCase)) continue;
        Location<World> block_case_location = ((BlockCase) caze).getLocation();
        if (!block_case_location.equals(location)) continue;
        event.setCancelled(true);
        if (!((BlockCase) caze).isStartPreviewOnLeftClick()) return;
        Optional<Preview> optional_preview = manager.getPreview();
        if (!optional_preview.isPresent()) {
            player.sendMessage(LanguageUtils.getText("PREVIEW_NOT_AVAILABLE",
                    new Pair<String, String>("%MANAGER%", manager.getName())));
            return;
        }
        Preview preview = optional_preview.get();
        if (!player.hasPermission("gwm_crates.preview." + manager_id)) {
            player.sendMessage(LanguageUtils.getText("HAVE_NOT_PERMISSION"));
            return;
        }
        preview.preview(player, manager);
        player.sendMessage(LanguageUtils.getText("PREVIEW_STARTED",
                new Pair<String, String>("%MANAGER%", manager.getName())));
        break;
    }
}
 
开发者ID:GreWeMa,项目名称:gwm_Crates,代码行数:34,代码来源:BlockCaseListener.java

示例6: startItemCasePreview

import org.spongepowered.api.entity.living.player.Player; //导入方法依赖的package包/类
@Listener(order = Order.LATE)
public void startItemCasePreview(InteractItemEvent.Primary.MainHand event) {
    Optional<Player> optional_player = event.getCause().first(Player.class);
    if (!optional_player.isPresent()) return;
    Player player = optional_player.get();
    ItemStack item = event.getItemStack().createStack();
    for (Manager manager : GWMCrates.getInstance().getCreatedManagers()) {
        String manager_id = manager.getId();
        Case caze = manager.getCase();
        if (!(caze instanceof ItemCase)) continue;
        ItemStack case_item = ((ItemCase) caze).getItem();
        if (!Utils.itemStacksEquals(item, case_item)) continue;
        event.setCancelled(true);
        if (!((ItemCase) caze).isStartPreviewOnLeftClick()) return;
        Optional<Preview> optional_preview = manager.getPreview();
        if (!optional_preview.isPresent()) {
            player.sendMessage(LanguageUtils.getText("PREVIEW_NOT_AVAILABLE",
                    new Pair<String, String>("%MANAGER%", manager.getName())));
            return;
        }
        Preview preview = optional_preview.get();
        if (!player.hasPermission("gwm_crates.preview." + manager_id)) {
            player.sendMessage(LanguageUtils.getText("HAVE_NOT_PERMISSION"));
            return;
        }
        preview.preview(player, manager);
        player.sendMessage(LanguageUtils.getText("PREVIEW_STARTED",
                new Pair<String, String>("%MANAGER%", manager.getName())));
        break;
    }
}
 
开发者ID:GreWeMa,项目名称:gwm_Crates,代码行数:32,代码来源:ItemCaseListener.java

示例7: onInteractItemSecondary

import org.spongepowered.api.entity.living.player.Player; //导入方法依赖的package包/类
@Listener(order = Order.EARLY)
public void onInteractItemSecondary(InteractItemEvent.Secondary event, @First Player player)
{
    String name = "";
    Optional<VirtualChestInventory> inventoryOptional = Optional.empty();
    for (String inventoryName : this.dispatcher.listInventories())
    {
        VirtualChestInventory inventory = this.dispatcher.getInventory(inventoryName).get();
        if (inventory.matchItemForOpeningWithSecondaryAction(event.getItemStack()))
        {
            if (player.hasPermission("virtualchest.open.self." + inventoryName))
            {
                name = inventoryName;
                inventoryOptional = Optional.of(inventory);
                event.setCancelled(true);
                break;
            }
        }
    }
    if (inventoryOptional.isPresent())
    {
        try
        {
            this.logger.debug("Player {} tries to create the GUI ({}) by secondary action", player.getName(), name);
            SpongeUnimplemented.openInventory(player, inventoryOptional.get().createInventory(player), this);
        }
        catch (InvalidDataException e)
        {
            this.logger.error("There is something wrong with the GUI configuration (" + name + ")", e);
        }
    }
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:33,代码来源:VirtualChestPlugin.java

示例8: isIgnored

import org.spongepowered.api.entity.living.player.Player; //导入方法依赖的package包/类
boolean isIgnored(Player player) {
    boolean isAFK = false;
    if (afkManager != null) {
        isAFK = afkManager.isAFK(player.getUniqueId());
    }

    SVPlayerData svPlayerData = getSVPlayerData(player);
    return (ignoreAdmins && player.hasPermission("sleepvote.hidden"))
            || isInIgnoredGameMode(player)
            || svPlayerData.isHidden()
            || isAFK;
}
 
开发者ID:Icohedron,项目名称:SleepVote,代码行数:13,代码来源:SleepVoteManager.java

示例9: preview

import org.spongepowered.api.entity.living.player.Player; //导入方法依赖的package包/类
@Override
public void preview(Player player, Manager manager) {
    if (player.hasPermission(permission)) {
        preview1.preview(player, manager);
    } else {
        preview2.preview(player, manager);
    }
}
 
开发者ID:GreWeMa,项目名称:gwm_Crates,代码行数:9,代码来源:PermissionPreview.java

示例10: open

import org.spongepowered.api.entity.living.player.Player; //导入方法依赖的package包/类
@Override
public void open(Player player, Manager manager) {
    if (player.hasPermission(permission)) {
        open_manager1.open(player, manager);
    } else {
        open_manager2.open(player, manager);
    }
}
 
开发者ID:GreWeMa,项目名称:gwm_Crates,代码行数:9,代码来源:PermissionOpenManager.java

示例11: onInteract

import org.spongepowered.api.entity.living.player.Player; //导入方法依赖的package包/类
/***
 * A method to listen to right click block interaction events
 * @param event the event object
 * @param player the player who fired it
 */
@Listener
public void onInteract(InteractBlockEvent.Secondary.MainHand event, @Root Player player) {
	if (!player.hasPermission(Permissions.PLAYER_SELECT_REGION))
		return;

	Optional<ItemStack> item = player.getItemInHand(HandTypes.MAIN_HAND);
	if (item.isPresent() && item.get().getItem().equals(ItemTypes.BLAZE_ROD) && event.getTargetBlock() != BlockSnapshot.NONE) {
		get(player).setPos2(event.getTargetBlock().getPosition());
		player.sendMessage(Text.of(TextColors.LIGHT_PURPLE, "Position 2 set to " + event.getTargetBlock().getPosition()));
		event.setCancelled(true);
	}
}
 
开发者ID:DevOnTheRocks,项目名称:StickyChunk,代码行数:18,代码来源:RegionAreaListener.java

示例12: onInteractItemPrimary

import org.spongepowered.api.entity.living.player.Player; //导入方法依赖的package包/类
@Listener(order = Order.EARLY)
public void onInteractItemPrimary(InteractItemEvent.Primary event, @First Player player)
{
    String name = "";
    Optional<VirtualChestInventory> inventoryOptional = Optional.empty();
    for (String inventoryName : this.dispatcher.listInventories())
    {
        VirtualChestInventory inventory = this.dispatcher.getInventory(inventoryName).get();
        if (inventory.matchItemForOpeningWithPrimaryAction(event.getItemStack()))
        {
            if (player.hasPermission("virtualchest.open.self." + inventoryName))
            {
                name = inventoryName;
                inventoryOptional = Optional.of(inventory);
                event.setCancelled(true);
                break;
            }
        }
    }
    if (inventoryOptional.isPresent())
    {
        try
        {
            this.logger.debug("Player {} tries to create the GUI ({}) by primary action", player.getName(), name);
            SpongeUnimplemented.openInventory(player, inventoryOptional.get().createInventory(player), this);
        }
        catch (InvalidDataException e)
        {
            this.logger.error("There is something wrong with the GUI configuration (" + name + ")", e);
        }
    }
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:33,代码来源:VirtualChestPlugin.java

示例13: onPlayerJoin

import org.spongepowered.api.entity.living.player.Player; //导入方法依赖的package包/类
@Listener
public void onPlayerJoin(ClientConnectionEvent.Join event) {
	Player player = (Player) event.getTargetEntity();
	String username = player.getName();
	if ((AurionsVoteListener.SQLType == "MySQL") && (dbHost.isEmpty() || dbHost == null || dbUser.isEmpty()
			|| dbUser == null || dbPass.isEmpty() || dbPass == null)) {
		if (player.hasPermission("*") || player.hasPermission("listener.top")) {
			player.sendMessage(
					Text.builder("<AurionsVoteListener> Please config Database.").color(TextColors.RED).build());
		}
	} else {
		if (SwitchSQL.QueueUsername(username)) {

			List<String> service = SwitchSQL.QueueReward(username);
			int totalVote = service.size();
			for (int i = 0; i < service.size(); i++) {
				RewardsTask.rewardoflline(username, service.get(i));
				SwitchSQL.removeQueue(username, service.get(i));
			}
			MessageChannel messageChannel = MessageChannel.TO_PLAYERS;

			messageChannel.send(AurionsVoteListener.GetInstance()
					.formatmessage(offlineBroadcast.replace("<amt>", String.valueOf(totalVote)), "", username));
			player.sendMessage(Text.of(AurionsVoteListener.GetInstance().formatmessage(
					offlinePlayerMessage.replace("<amt>", String.valueOf(totalVote)), "", username)));
		} else {
		}
		if (joinmessage) {
			for (int i = 0; i < AurionsVoteListener.messagejoin.size(); i++) {
				player.sendMessage(formatmessage(AurionsVoteListener.messagejoin.get(i), "", username));
			}
		}
	}
}
 
开发者ID:Mineaurion,项目名称:AurionVoteListener,代码行数:35,代码来源:AurionsVoteListener.java

示例14: canOpen

import org.spongepowered.api.entity.living.player.Player; //导入方法依赖的package包/类
public boolean canOpen(Player player, Manager manager) {
    return player.hasPermission("gwm_crates.open." + manager.getId().toLowerCase());
}
 
开发者ID:GreWeMa,项目名称:gwm_Crates,代码行数:4,代码来源:OpenManager.java

示例15: onBlockPlace

import org.spongepowered.api.entity.living.player.Player; //导入方法依赖的package包/类
@Listener
public void onBlockPlace(ChangeBlockEvent.Place event, @Root Player player)
{

    if(!EagleFactions.AdminList.contains(player.getUniqueId().toString()))
    {
        String playerFactionName = FactionLogic.getFactionName(player.getUniqueId());

        for (Transaction<BlockSnapshot> transaction : event.getTransactions())
         {
             World world = player.getWorld();
             Vector3i claim = transaction.getFinal().getLocation().get().getChunkPosition();

             if(FactionLogic.isClaimed(world.getUniqueId(), claim))
             {
                 if(FactionLogic.getFactionNameByChunk(world.getUniqueId(), claim).equals("SafeZone") && player.hasPermission("eaglefactions.safezone.build"))
                 {
                //     EagleFactions.getEagleFactions().getLogger().info("Player has permissions in SafeZone");

                     return;
                 }
                 else if(FactionLogic.getFactionNameByChunk(world.getUniqueId(), claim).equals("WarZone") && player.hasPermission("eaglefactions.warzone.build"))
                 {
                 //    EagleFactions.getEagleFactions().getLogger().info("Player has permissions in WarZone");

                     return;
                 }
                 else if(FactionLogic.getFactionNameByChunk(world.getUniqueId(), claim).equals(playerFactionName))
                 {
                     return;
                 }
                 else
                 {
                     event.setCancelled(true);
                     player.sendMessage(Text.of(PluginInfo.ErrorPrefix, TextColors.RED, "This land belongs to someone else!"));
                     return;
                 }
             }
             else return;
         }
    }
    return;
}
 
开发者ID:Aquerr,项目名称:EagleFactions,代码行数:44,代码来源:PlayerBlockPlaceListener.java


注:本文中的org.spongepowered.api.entity.living.player.Player.hasPermission方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。