當前位置: 首頁>>代碼示例>>Java>>正文


Java GameMode.SURVIVAL屬性代碼示例

本文整理匯總了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);
			}
		}
	}
}
 
開發者ID:FattyMieo,項目名稱:SurvivalPlus,代碼行數:19,代碼來源:FoodDiversityConsume.java

示例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;
    }
}
 
開發者ID:cadox8,項目名稱:PA,代碼行數:22,代碼來源:GamemodeCMD.java

示例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();
}
 
開發者ID:dracnis,項目名稱:VanillaPlus,代碼行數:21,代碼來源:CPGamemode.java

示例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();
    }
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:11,代碼來源:TrinketManager.java

示例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();
    }
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:11,代碼來源:TrinketManager.java

示例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());
        }
    }
}
 
開發者ID:Vrekt,項目名稱:Arc-v2,代碼行數:14,代碼來源:PlayerListener.java

示例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();
       }
}
 
開發者ID:DianoxDragon,項目名稱:UltimateSpawn,代碼行數:29,代碼來源:LittlesEvent.java

示例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.
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:15,代碼來源:Flight.java

示例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);
            }
        }
    }
}
 
開發者ID:Warvale,項目名稱:Locked,代碼行數:15,代碼來源:PlayerListener.java

示例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;
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:6,代碼來源:PlayerDataRPG.java

示例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);
						}
					}
				}
			}
		}
	}
}
 
開發者ID:FattyMieo,項目名稱:SurvivalPlus,代碼行數:61,代碼來源:CauldronWaterBottle.java

示例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);
}
 
開發者ID:FattyMieo,項目名稱:SurvivalPlus,代碼行數:63,代碼來源:Valkyrie.java

示例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;
		}
	}
}
 
開發者ID:FattyMieo,項目名稱:SurvivalPlus,代碼行數:55,代碼來源:Valkyrie.java

示例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:
		}
	}
}
 
開發者ID:FattyMieo,項目名稱:SurvivalPlus,代碼行數:44,代碼來源:SnowballThrow.java

示例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);
}
 
開發者ID:FattyMieo,項目名稱:SurvivalPlus,代碼行數:78,代碼來源:GiantBlade.java


注:本文中的org.bukkit.GameMode.SURVIVAL屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。