本文整理汇总了Java中org.bukkit.GameMode.SURVIVAL属性的典型用法代码示例。如果您正苦于以下问题:Java GameMode.SURVIVAL属性的具体用法?Java GameMode.SURVIVAL怎么用?Java GameMode.SURVIVAL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.GameMode
的用法示例。
在下文中一共展示了GameMode.SURVIVAL属性的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: 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;
}
}
示例3: CPGamemode
@SuppressWarnings("deprecation")
public CPGamemode(ConfigurationSection section, MessageManager manager, String name){
super(section, manager, name);
ErrorLogger.addPrefix("GAMEMODE");
Object o = section.get("GAMEMODE");
if(o instanceof Integer){
gm = GameMode.getByValue((int) o);
if(gm == null){
Error.INVALID.add();
}
}else if(o instanceof String){
gm = GameMode.valueOf((String) o);
if(gm == null){
Error.INVALID.add();
}
}else {
gm = GameMode.SURVIVAL;
Error.INVALID.add();
}
ErrorLogger.removePrefix();
}
示例4: 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();
}
}
示例5: 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();
}
}
示例6: onGameModeChange
@EventHandler
public void onGameModeChange(PlayerGameModeChangeEvent event) {
GameMode gameMode = event.getPlayer().getGameMode();
// check if we switch to survival from an exempt GameMode and update.
if (Arc.COMPATIBILITY) {
if ((gameMode == GameMode.CREATIVE && event.getNewGameMode() == GameMode.SURVIVAL)) {
MovingData.getData(event.getPlayer()).setLastGameModeChange(System.currentTimeMillis());
}
} else {
if ((gameMode == GameMode.CREATIVE || gameMode == GameMode.SPECTATOR) && event.getNewGameMode() == GameMode.SURVIVAL) {
MovingData.getData(event.getPlayer()).setLastGameModeChange(System.currentTimeMillis());
}
}
}
示例7: 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();
}
}
示例8: isImmune
/**
* Is the player in a state or situation that we should deem them not flying?
* @param player
* @return immune
*/
private static boolean isImmune(Player player) {
return player.getGameMode() != GameMode.SURVIVAL
|| Utils.getRank(player).isAtLeast(EnumRank.MEDIA) // Don't bypass this check.
|| player.isGliding() // Not using Elytra
|| player.hasPotionEffect(PotionEffectType.LEVITATION) // Doesn't have a levitation potion
|| player.getVehicle() != null // Not in a vehicle
|| player.getVelocity().getY() > 0 // Not being launched up
|| player.getNearbyEntities(1, 2, 1).stream().anyMatch(e -> e.getType() == EntityType.BOAT) // Not standing on a boat.
|| player.getLocation().getBlock().isLiquid(); // Not in water.
}
示例9: 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);
}
}
}
}
示例10: 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;
}
示例11: 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);
}
}
}
}
}
}
}
示例12: 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);
}
示例13: 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;
}
}
}
示例14: 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:
}
}
}
示例15: onItemClick
@SuppressWarnings("deprecation")
@EventHandler
public void onItemClick(PlayerInteractEvent event)
{
Player player = event.getPlayer();
ItemStack mainItem = player.getInventory().getItemInMainHand();
ItemStack offItem = player.getInventory().getItemInOffHand();
Score score_dualWieldMsg = tech_dualWieldMsg.getScore(player);
if(mainItem.getType() == Material.GOLD_HOE)
{
if(dualWield.getScore(player).getScore() == 0)
{
if(event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR)
{
if(player.isSprinting())
{
if(charge.getScore(player).getScore() == 0)
{
Random rand = new Random();
ChargeForward(player, 3);
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(event.getItem().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("Unable to Charge immediately"));
}
}
}
}
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 Giant Blade"));
}
}
}
else if(offItem.getType() == Material.GOLD_HOE)
{
if(dualWield.getScore(player).getScore() != 0)
{
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 Giant Blade"));
}
}
}
score_dualWieldMsg.setScore(0);
}