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


Java BlockMultiPlaceEvent.getPlayer方法代码示例

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


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

示例1: onPlayerBlockPlace

import org.bukkit.event.block.BlockMultiPlaceEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerBlockPlace(final BlockMultiPlaceEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("DEBUG: " + e.getEventName());
        if (e.getPlayer() == null) {
            plugin.getLogger().info("DEBUG: player is null");
        } else {
            plugin.getLogger().info("DEBUG: block placed by " + e.getPlayer().getName());
        }
        plugin.getLogger().info("DEBUG: Block is " + e.getBlock().toString());
    }
    if (Settings.allowAutoActivator && e.getPlayer().getName().equals("[CoFH]")) {
        return;
    }
    // plugin.getLogger().info(e.getEventName());
    if (Util.inWorld(e.getPlayer())) {
        // This permission bypasses protection
        if (e.getPlayer().isOp() || VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) {
            return;
        }
        Island island = plugin.getIslands().getProtectedIslandAt(e.getBlock().getLocation());
        if (island == null) {
            if (!Settings.defaultWorldSettings.get(SettingsFlag.PLACE_BLOCKS)) {
                Util.sendMessage(e.getPlayer(), plugin.getLocale(e.getPlayer().getUniqueId()).get("island.protected"));
                e.setCancelled(true);
            }
            return;
        }
        // Island exists
        if (island.getFlag(SettingsFlag.PLACE_BLOCKS) || island.getMembers().contains(e.getPlayer().getUniqueId()))  {
            // Check how many placed
            //plugin.getLogger().info("DEBUG: block placed " + e.getBlock().getType());
            String type = e.getBlock().getType().toString();
            if (!e.getBlock().getState().getClass().getName().endsWith("CraftBlockState")
                    // Not all blocks have that type of class, so we have to do some explicit checking...
                    || e.getBlock().getType().equals(Material.REDSTONE_COMPARATOR_OFF)
                    || type.endsWith("BANNER") // Avoids V1.7 issues
                    || e.getBlock().getType().equals(Material.ENDER_CHEST)
                    || e.getBlock().getType().equals(Material.ENCHANTMENT_TABLE)
                    || e.getBlock().getType().equals(Material.DAYLIGHT_DETECTOR)
                    || e.getBlock().getType().equals(Material.FLOWER_POT)){
                // tile entity placed
                if (Settings.limitedBlocks.containsKey(type) && Settings.limitedBlocks.get(type) > -1) {
                    int count = island.getTileEntityCount(e.getBlock().getType(),e.getBlock().getWorld());
                    if (Settings.limitedBlocks.get(type) <= count) {
                        Util.sendMessage(e.getPlayer(), (plugin.getLocale(e.getPlayer().getUniqueId()).get("moblimits.entity").replace("[entity]",
                                Util.prettifyText(type))).replace("[number]", String.valueOf(Settings.limitedBlocks.get(type))));
                        e.setCancelled(true);
                        return;
                    }
                }
            }
            return;
        }
        // Outside of protection area or visitor
        Util.sendMessage(e.getPlayer(), plugin.getLocale(e.getPlayer().getUniqueId()).get("island.protected"));
        e.setCancelled(true);
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:60,代码来源:IslandGuard.java

示例2: onPlayerBlockPlace

import org.bukkit.event.block.BlockMultiPlaceEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerBlockPlace(final BlockMultiPlaceEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("DEBUG: " + e.getEventName());
        if (e.getPlayer() == null) {
            plugin.getLogger().info("DEBUG: player is null");
        } else {
            plugin.getLogger().info("DEBUG: block placed by " + e.getPlayer().getName());
        }
        plugin.getLogger().info("DEBUG: Block is " + e.getBlock().toString());
    }
    if (Settings.allowedFakePlayers.contains(e.getPlayer().getName())) return;

    // plugin.getLogger().info(e.getEventName());
    if (IslandGuard.inWorld(e.getPlayer())) {
        // This permission bypasses protection
        if (e.getPlayer().isOp() || VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) {
            return;
        }
        Island island = plugin.getGrid().getProtectedIslandAt(e.getBlock().getLocation());
        if (island == null) {
            if (!Settings.defaultWorldSettings.get(SettingsFlag.PLACE_BLOCKS)) {
                Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected);
                e.setCancelled(true);
            }
            return;
        }
        // Island exists
        if (island.getIgsFlag(SettingsFlag.PLACE_BLOCKS) || island.getMembers().contains(e.getPlayer().getUniqueId()))  {
            // Check how many placed
            //plugin.getLogger().info("DEBUG: block placed " + e.getBlock().getType());
            String type = e.getBlock().getType().toString();
            if (!e.getBlock().getState().getClass().getName().endsWith("CraftBlockState")
                    // Not all blocks have that type of class, so we have to do some explicit checking...
                    || e.getBlock().getType().equals(Material.REDSTONE_COMPARATOR_OFF)
                    || type.endsWith("BANNER") // Avoids V1.7 issues
                    || e.getBlock().getType().equals(Material.ENDER_CHEST)
                    || e.getBlock().getType().equals(Material.ENCHANTMENT_TABLE)
                    || e.getBlock().getType().equals(Material.DAYLIGHT_DETECTOR)
                    || e.getBlock().getType().equals(Material.FLOWER_POT)){
                // tile entity placed
                if (Settings.limitedBlocks.containsKey(type) && Settings.limitedBlocks.get(type) > -1) {
                    int count = island.getTileEntityCount(e.getBlock().getType(),e.getBlock().getWorld());
                    if (Settings.limitedBlocks.get(type) <= count) {
                        Util.sendMessage(e.getPlayer(), ChatColor.RED + (plugin.myLocale(e.getPlayer().getUniqueId()).entityLimitReached.replace("[entity]",
                                Util.prettifyText(type))).replace("[number]", String.valueOf(Settings.limitedBlocks.get(type))));
                        e.setCancelled(true);
                        return;
                    }
                }
            }
            return;
        }
        // Outside of protection area or visitor
        Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected);
        e.setCancelled(true);
    }
}
 
开发者ID:tastybento,项目名称:acidisland,代码行数:59,代码来源:EntityLimits.java


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