本文整理汇总了Java中org.bukkit.GameMode.ADVENTURE属性的典型用法代码示例。如果您正苦于以下问题:Java GameMode.ADVENTURE属性的具体用法?Java GameMode.ADVENTURE怎么用?Java GameMode.ADVENTURE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.GameMode
的用法示例。
在下文中一共展示了GameMode.ADVENTURE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onConsumeCake
@EventHandler(priority = EventPriority.HIGHEST)
public void onConsumeCake(PlayerInteractEvent event)
{
if(event.isCancelled()) return;
Player player = event.getPlayer();
if(event.hasBlock() && event.getAction().equals(Action.RIGHT_CLICK_BLOCK))
{
Block cake = event.getClickedBlock();
if(cake.getType().equals(Material.CAKE_BLOCK))
{
if(player.getFoodLevel() < 20 && (player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE))
{
addStats(player, carbon, 171);
addStats(player, protein, 114);
addStats(player, salts, 3);
}
}
}
}
示例2: doAction
@Override
public boolean doAction(Player player, Command command, String s, String[] args)
{
if (!SamaGamesAPI.get().getPermissionsManager().hasPermission(player, "hub.fly"))
{
player.sendMessage(PlayerManager.SETTINGS_TAG + ChatColor.RED + "Vous n'avez pas le grade nécéssaire pour utiliser cette commande.");
return true;
}
if (player.getGameMode() != GameMode.ADVENTURE || this.hub.getPlayerManager().isBusy(player))
{
player.sendMessage(PlayerManager.SETTINGS_TAG + ChatColor.RED + "Vous ne pouvez pas utiliser cette commande actuellement.");
return true;
}
boolean now = !player.getAllowFlight();
player.setAllowFlight(now);
if (now)
player.sendMessage(PlayerManager.SETTINGS_TAG + ChatColor.GREEN + "Vous pouvez maintenant voler.");
else
player.sendMessage(PlayerManager.SETTINGS_TAG + ChatColor.GREEN + "Vous ne pouvez plus voler.");
return true;
}
示例3: onPlayerMove
@EventHandler
public void onPlayerMove(PlayerMoveEvent event)
{
if (event.getPlayer().getGameMode() != GameMode.ADVENTURE)
return;
if (event.getPlayer().getAllowFlight())
return;
if (this.hub.getPlayerManager().isBusy(event.getPlayer()))
return;
if (((LivingEntity) event.getPlayer()).isOnGround())
{
event.getPlayer().setAllowFlight(true);
this.allowed.add(event.getPlayer().getUniqueId());
}
}
示例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: executePlayer
@Override
public void executePlayer(final Player p, PlayerDataRPG pd, String[] args) {
if (p.getGameMode() == GameMode.ADVENTURE) {
p.setGameMode(GameMode.CREATIVE);
} else {
p.setGameMode(GameMode.ADVENTURE);
}
p.sendMessage(ChatColor.GREEN + "You are now in " + p.getGameMode().toString() + ".");
}
示例6: onPlayerClickTrinket
@EventHandler
public void onPlayerClickTrinket(InventoryClickEvent event) {
if (event.getInventory() instanceof CraftInventoryCrafting && event.getRawSlot() == 45) { //offhand slot
event.setCancelled(true);
if (event.getWhoClicked().getGameMode() != GameMode.ADVENTURE && event.getWhoClicked().getGameMode() != GameMode.SURVIVAL) {
event.getWhoClicked().getInventory().setItemInOffHand(null);
}
if (event.getWhoClicked() instanceof Player)
((Player) event.getWhoClicked()).updateInventory();
}
}
示例7: onPlayerClickTrinket2
@EventHandler
public void onPlayerClickTrinket2(InventoryDragEvent event) {
if (event.getRawSlots().contains(45)) {
event.setCancelled(true);
if (event.getWhoClicked().getGameMode() != GameMode.ADVENTURE && event.getWhoClicked().getGameMode() != GameMode.SURVIVAL) {
event.getWhoClicked().getInventory().setItemInOffHand(null);
}
if (event.getWhoClicked() instanceof Player)
((Player) event.getWhoClicked()).updateInventory();
}
}
示例8: detectBlockPunch
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void detectBlockPunch(PlayerAnimationEvent event) {
if(event.getAnimationType() != PlayerAnimationType.ARM_SWING) return;
if(event.getPlayer().getGameMode() != GameMode.ADVENTURE) return;
// Client will not punch blocks in adventure mode, so we detect it ourselves and fire a BlockPunchEvent.
// We do this in the kit module only because its the one that is responsible for putting players in adventure mode.
// A few other modules rely on this, including StaminaModule and BlockDropsModule.
RayBlockIntersection hit = event.getPlayer().getTargetedBlock(true, false);
if(hit == null) return;
eventBus.callEvent(new BlockPunchEvent(event.getPlayer(), hit));
}
示例9: 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();
}
}
示例10: onMove
@EventHandler
public void onMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
if (!(player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR)) {
if (BlockListener.inMineLocation(player.getLocation())) {
if (player.getGameMode() != GameMode.SURVIVAL) {
player.setGameMode(GameMode.SURVIVAL);
}
} else {
if (player.getGameMode() != GameMode.ADVENTURE) {
player.setGameMode(GameMode.ADVENTURE);
}
}
}
}
示例11: isPVE
public boolean isPVE() {
Player p = getPlayer();
if ((p.getGameMode() != GameMode.SURVIVAL && p.getGameMode() != GameMode.ADVENTURE) || dead || (region != null && region.dangerLevel <= 1))
return false;
return true;
}
示例12: onItemClick
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST)
public void onItemClick(PlayerInteractEvent event)
{
if(event.isCancelled()) return;
if(event.hasItem())
{
Player player = event.getPlayer();
if(player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE)
{
ItemStack mainItem = player.getInventory().getItemInMainHand();
if(mainItem.getType() == Material.GLASS_BOTTLE)
{
if(event.getAction() == Action.RIGHT_CLICK_BLOCK)
{
if(event.getClickedBlock().getType() == Material.CAULDRON && event.getClickedBlock().getData() != (byte)0)
{
Block fire = event.getClickedBlock().getRelative(BlockFace.DOWN);
event.setCancelled(true);
event.getClickedBlock().setData((byte)((int)event.getClickedBlock().getData() - 1));
ItemStack waterBottle = new ItemStack(Material.POTION, 1);
net.minecraft.server.v1_12_R1.ItemStack nmsStack_bottle = CraftItemStack.asNMSCopy(waterBottle);
NBTTagCompound compound_bottle = nmsStack_bottle.getTag();
compound_bottle.setString("Potion","minecraft:water");
compound_bottle.setInt("HideFlags", 32);
nmsStack_bottle.setTag(compound_bottle);
waterBottle = CraftItemStack.asBukkitCopy(nmsStack_bottle);
ItemMeta meta = waterBottle.getItemMeta();
if(fire != null && fire.getType() == Material.FIRE)
{
List<String> lore = Arrays.asList
(
ChatColor.RESET + "" + ChatColor.GRAY + Survival.Words.get("Purified")
);
meta.setLore(lore);
}
waterBottle.setItemMeta(meta);
if(mainItem.getAmount() > 1)
{
mainItem.setAmount(mainItem.getAmount() - 1);
if(player.getInventory().firstEmpty() != -1)
player.getInventory().addItem(waterBottle);
else
player.getWorld().dropItem(player.getLocation(), waterBottle);
}
else
{
player.getInventory().setItemInMainHand(waterBottle);
}
}
}
}
}
}
}
示例13: onItemClick
@SuppressWarnings("deprecation")
@EventHandler
public void onItemClick(PlayerInteractEvent event)
{
Player player = event.getPlayer();
ItemStack mainItem = player.getInventory().getItemInMainHand();
Score score_dualWieldMsg = tech_dualWieldMsg.getScore(player);
if(mainItem.getType() == Material.GOLD_AXE)
{
if(dualWield.getScore(player).getScore() == 0)
{
if(event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_AIR)
{
if(spin.getScore(player).getScore() == 0)
{
if(player.getFoodLevel() > 6)
{
Random rand = new Random();
Spin(player);
if(player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE)
player.setFoodLevel(player.getFoodLevel() - 1);
int chance_reduceDur = rand.nextInt(10) + 1;
switch(chance_reduceDur)
{
case 1:
mainItem.setDurability((short)(mainItem.getDurability() + 1));
break;
default:
}
if(mainItem.getDurability() >= 32)
{
player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
player.getInventory().setItemInMainHand(null);
}
player.updateInventory();
}
else
{
player.sendMessage(ChatColor.RED + Survival.Words.get("Lack of energy, unable to spin"));
}
}
}
}
else
{
if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)
score_dualWieldMsg.setScore(score_dualWieldMsg.getScore() + 1);
else if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)
score_dualWieldMsg.setScore(score_dualWieldMsg.getScore() + 2);
if(score_dualWieldMsg.getScore() == 2)
{
player.sendMessage(ChatColor.RED + Survival.Words.get("Unable to dual-wield with Valkyrie's Axe"));
}
}
}
score_dualWieldMsg.setScore(0);
}
示例14: onAttack
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST)
public void onAttack(EntityDamageByEntityEvent event)
{
if(event.isCancelled()) return;
if(event.getDamager() instanceof Player)
{
Player player = (Player)event.getDamager();
ItemStack mainItem = player.getInventory().getItemInMainHand();
if(dualWield.getScore(player).getScore() == 0)
{
if(mainItem.getType() == Material.GOLD_AXE)
{
if(spin.getScore(player).getScore() == 0)
{
if(player.getFoodLevel() > 6)
{
Random rand = new Random();
Spin(player);
if(player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE)
player.setFoodLevel(player.getFoodLevel() - 1);
int chance_reduceDur = rand.nextInt(10) + 1;
switch(chance_reduceDur)
{
case 1:
mainItem.setDurability((short)(mainItem.getDurability() + 1));
break;
default:
}
if(mainItem.getDurability() >= 32)
{
player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
player.getInventory().setItemInMainHand(null);
}
player.updateInventory();
}
else
{
player.sendMessage(ChatColor.RED + Survival.Words.get("Lack of energy, unable to spin"));
}
}
}
}
else
{
event.setCancelled(true);
return;
}
}
}
示例15: onBreakSnow
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST)
public void onBreakSnow(BlockBreakEvent e)
{
if(e.isCancelled()) return;
Player player = e.getPlayer();
if(player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE)
{
ItemStack mainItem = player.getInventory().getItemInMainHand();
switch(mainItem.getType())
{
case WOOD_SPADE:
case GOLD_SPADE:
case STONE_SPADE:
case DIAMOND_SPADE:
case IRON_SPADE:
Block block = e.getBlock();
switch(block.getType())
{
case SNOW:
e.setCancelled(true);
mainItem.setDurability((short) (mainItem.getDurability() + 1));
if(mainItem.getDurability() >= mainItem.getType().getMaxDurability() + 1)
player.getInventory().setItemInMainHand(null);
player.updateInventory();
block.getWorld().dropItemNaturally(block.getLocation(), new ItemStack(Material.SNOW_BALL, block.getData() + 1));
block.setType(Material.AIR);
break;
case SNOW_BLOCK:
e.setCancelled(true);
mainItem.setDurability((short) (mainItem.getDurability() + 1));
if(mainItem.getDurability() >= mainItem.getType().getMaxDurability() + 1)
player.getInventory().setItemInMainHand(null);
player.updateInventory();
block.getWorld().dropItemNaturally(block.getLocation(), new ItemStack(Material.SNOW_BALL, 8));
block.setType(Material.AIR);
break;
default:
}
break;
default:
}
}
}