本文整理汇总了Java中org.bukkit.GameMode.CREATIVE属性的典型用法代码示例。如果您正苦于以下问题:Java GameMode.CREATIVE属性的具体用法?Java GameMode.CREATIVE怎么用?Java GameMode.CREATIVE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.GameMode
的用法示例。
在下文中一共展示了GameMode.CREATIVE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onClick
/**
* Called when a player clicks on the inventory, the filters to check if the Player clicked on the GUi's inventory should be made outside of this method
*
* @param event the click event
*/
public void onClick(InventoryClickEvent event) {
HumanEntity h = event.getWhoClicked();
if (!(h instanceof Player))
return;
LinkedList<Gui> g = histories.get(h);
if (g != null && !g.isEmpty()) {
Gui gui = g.peek();
GuiClickEvent e = new GuiClickEvent(event, (Player) h, gui);
Bukkit.getPluginManager().callEvent(e);
if (e.isCancelled())
return;
//Event cancelled BEFORE the method call to permit the un-cancelling
event.setCancelled(true);
gui.onClick(event);
//Creative idiots could copy the links
if (event.isShiftClick() && event.getWhoClicked().getGameMode() == GameMode.CREATIVE)
((Player) event.getWhoClicked()).updateInventory();
}
}
示例2: onPlayerInteract
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() == Action.LEFT_CLICK_BLOCK && event.hasItem()) {
// The player didn't click an enchantment table, Creative players will instantly destroy.
Player player = event.getPlayer();
if (event.getClickedBlock().getType() == Material.ENCHANTMENT_TABLE && player.getGameMode() != GameMode.CREATIVE) {
// The player didn't click with an enchanted book.
ItemStack stack = event.getItem();
if (stack != null && stack.getType() == Material.ENCHANTED_BOOK) {
ItemMeta meta = stack.getItemMeta();
if (meta instanceof EnchantmentStorageMeta) {
EnchantmentStorageMeta enchantmentStorageMeta = (EnchantmentStorageMeta) meta;
for (Enchantment enchantment : enchantmentStorageMeta.getStoredEnchants().keySet()) {
enchantmentStorageMeta.removeStoredEnchant(enchantment);
}
event.setCancelled(true);
player.setItemInHand(EMPTY_BOOK);
player.sendMessage(ChatColor.GREEN + "You reverted this item to its original form.");
}
}
}
}
}
示例3: onBlockBreak
@EventHandler(ignoreCancelled=true, priority=EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent event)
{
Block block = event.getBlock();
if (isEventSign(block))
{
BlockState state = block.getState();
Sign sign = (Sign)state;
ItemStack stack = new ItemStack(Material.SIGN, 1);
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(EVENT_SIGN_ITEM_NAME);
meta.setLore(Arrays.asList(sign.getLines()));
stack.setItemMeta(meta);
Player player = event.getPlayer();
World world = player.getWorld();
Location blockLocation = block.getLocation();
if ((player.getGameMode() != GameMode.CREATIVE) && (world.isGameRule("doTileDrops"))) {
world.dropItemNaturally(blockLocation, stack);
}
event.setCancelled(true);
block.setType(Material.AIR);
state.update();
}
}
示例4: parseGamemode
private GameMode parseGamemode(String gamemode) {
switch (gamemode) {
case "creativo":
case "1":
case "c":
return GameMode.CREATIVE;
case "survival":
case "0":
case "s":
return GameMode.SURVIVAL;
case "adventura":
case "2":
case "a":
return GameMode.ADVENTURE;
case "espectador":
case "3":
case "e":
return GameMode.SPECTATOR;
default:
return GameMode.SURVIVAL;
}
}
示例5: onBlockPlaceCreative
@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);
}
}
示例6: getType
@Override
public InventoryType getType() {
InventoryType type = viewing.getType();
if (type == InventoryType.CRAFTING && player.getGameMode() == GameMode.CREATIVE) {
return InventoryType.CREATIVE;
}
return type;
}
示例7: breakBlock
public static void breakBlock(Player player, Block block) {
if (player.getGameMode() == GameMode.CREATIVE)
return;
PlayerBlockTracking playerBlockTracking = getPlayerBlockTracking(player);
if (playerBlockTracking.isBlock(block)) {
playerBlockTracking.decrementHackingIndicator(2);
}
}
示例8: onBlockBreak
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
PlayerDataRPG pd = plugin.getPD(event.getPlayer());
if (pd == null)
event.setCancelled(true);
if (event.getPlayer().getGameMode() != GameMode.CREATIVE)
event.setCancelled(true);
if (!canBuild(pd))
event.setCancelled(true);
}
示例9: onBucketEmpty
@EventHandler
public void onBucketEmpty(PlayerBucketEmptyEvent event) {
PlayerDataRPG pd = plugin.getPD(event.getPlayer());
if (pd == null)
event.setCancelled(true);
if (event.getPlayer().getGameMode() != GameMode.CREATIVE)
event.setCancelled(true);
if (!canBuild(pd))
event.setCancelled(true);
event.getPlayer().updateInventory();
}
示例10: onBucketFill
@EventHandler
public void onBucketFill(PlayerBucketFillEvent event) {
PlayerDataRPG pd = plugin.getPD(event.getPlayer());
if (pd == null)
event.setCancelled(true);
if (event.getPlayer().getGameMode() != GameMode.CREATIVE)
event.setCancelled(true);
if (!canBuild(pd))
event.setCancelled(true);
event.getPlayer().updateInventory();
}
示例11: onBlockBreak
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
event.setCancelled(false);
if (event.getPlayer().getGameMode() != GameMode.CREATIVE)
event.setCancelled(true);
}
示例12: onItemUse
@EventHandler
public void onItemUse(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (!event.hasItem() || !InventoryManager.playerIsLoaded(player)) {
return;
}
Inventory inventory = InventoryManager.get(player).getInventory();
ItemStack petItem = event.getItem();
if (player.getGameMode() == GameMode.CREATIVE && PetManager.isPetItem(petItem)) {
petItem = PetManager.toPetItem(petItem);
player.getEquipment().setItemInMainHand(petItem);
}
if (PetType.isPetItem(petItem)
&& (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR)) {
Slot petSlot = SlotManager.instance().getPetSlot();
if (petSlot != null && petSlot.isCup(inventory.getItem(PetManager.getPetSlotId()))
&& ItemManager.allowedForPlayer(player, petItem, false)) {
inventory.setItem(PetManager.getPetSlotId(), event.getItem());
PetManager.spawnPet(player, petItem);
player.getEquipment().setItemInMainHand(null);
}
event.setCancelled(true);
}
}
示例13: onAnvilOrEnchantInteract
@EventHandler
public void onAnvilOrEnchantInteract(PlayerInteractEvent event) {
if (event.getClickedBlock() != null) {
if (event.getPlayer().getGameMode() == GameMode.CREATIVE && (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK))
return;
Material type = event.getClickedBlock().getType();
for (Material m : RESTRICTED_TYPES) {
if (m == type) {
event.setCancelled(true);
break;
}
}
}
}
示例14: onChangeGM
@EventHandler
public void onChangeGM(PlayerGameModeChangeEvent e) {
Player p = e.getPlayer();
UUID pU = e.getPlayer().getUniqueId();
int GamemodeTemp1 = 0;
if (e.getNewGameMode() == GameMode.SURVIVAL) {
GamemodeTemp1 = 0;
} else if (e.getNewGameMode() == GameMode.CREATIVE) {
GamemodeTemp1 = 1;
} else if (e.getNewGameMode() == GameMode.ADVENTURE) {
GamemodeTemp1 = 2;
} else if (e.getNewGameMode() == GameMode.SPECTATOR) {
GamemodeTemp1 = 3;
}
int GamemodeTemp2 = Integer.valueOf(GamemodeTemp1);
if (!ConfigTemp.getConfig().contains(String.valueOf(pU))) {
ConfigTemp.getConfig().set(pU+".Player", String.valueOf(p));
ConfigTemp.getConfig().set(pU+".Options.Gamemode", Integer.valueOf(GamemodeTemp2));
ConfigTemp.saveConfigFile();
} else if (ConfigTemp.getConfig().contains(String.valueOf(pU))) {
ConfigTemp.getConfig().set(pU+".Player", String.valueOf(p));
ConfigTemp.getConfig().set(pU+".Options.Gamemode", Integer.valueOf(GamemodeTemp2));
ConfigTemp.saveConfigFile();
}
}
示例15: dropItems
private void dropItems(BlockDrops drops, @Nullable MatchPlayer player, Location location, double yield) {
if(player == null || player.getBukkit().getGameMode() != GameMode.CREATIVE) {
Random random = getMatch().getRandom();
for (Pair<Double, ItemStack> entry : drops.items) {
if (random.nextFloat() < yield * entry.first) {
location.getWorld().dropItemNaturally(BlockUtils.center(location), entry.second);
}
}
}
}