some adjustments to UHC Survivalgames
This commit is contained in:
parent
3610f78b37
commit
91cf391724
@ -1009,7 +1009,7 @@ public abstract class SurvivalGames extends Game
|
||||
handlePickup(event.getItem().getItemStack());
|
||||
}
|
||||
|
||||
private void handlePickup(ItemStack stack)
|
||||
public void handlePickup(ItemStack stack)
|
||||
{
|
||||
if (stack.getType() == Material.CARROT
|
||||
|| stack.getType() == Material.POTATO
|
||||
|
@ -1,21 +1,38 @@
|
||||
package nautilus.game.arcade.game.games.survivalgames.modes;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.event.inventory.PrepareItemCraftEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.loot.RandomItem;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.games.AbsorptionFix;
|
||||
import nautilus.game.arcade.game.games.survivalgames.SoloSurvivalGames;
|
||||
import nautilus.game.arcade.game.games.survivalgames.SupplyChestOpenEvent;
|
||||
import nautilus.game.arcade.game.games.survivalgames.kit.KitLooter;
|
||||
import nautilus.game.arcade.game.games.survivalgames.modes.kit.KitSurvivalist;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
|
||||
/**
|
||||
* UHCSurvivalgames gamemode for Survivalgames
|
||||
@ -25,14 +42,73 @@ import nautilus.game.arcade.game.games.survivalgames.SoloSurvivalGames;
|
||||
public class UHCSurvivalgames extends SoloSurvivalGames
|
||||
{
|
||||
|
||||
private long _peacePhase;
|
||||
private boolean _peace;
|
||||
|
||||
public UHCSurvivalgames(ArcadeManager manager)
|
||||
{
|
||||
super(manager, GameType.Brawl);
|
||||
super(manager, new Kit[]
|
||||
{
|
||||
new KitSurvivalist(manager)
|
||||
},
|
||||
GameType.Brawl);
|
||||
|
||||
_peacePhase = 45000; // 45 Seconds
|
||||
SoupEnabled = false;
|
||||
|
||||
DamagePvP = false;
|
||||
|
||||
BlockBreak = true;
|
||||
BlockPlace = true;
|
||||
|
||||
BlockBreakDeny.add(Material.DIAMOND_BLOCK.getId());
|
||||
BlockBreakDeny.add(Material.IRON_BLOCK.getId());
|
||||
BlockBreakDeny.add(Material.GOLD_BLOCK.getId());
|
||||
BlockBreakDeny.add(Material.REDSTONE_ORE.getId());
|
||||
BlockBreakDeny.add(Material.REDSTONE_WIRE.getId());
|
||||
BlockBreakDeny.add(Material.REDSTONE.getId());
|
||||
BlockBreakDeny.add(Material.TNT.getId());
|
||||
BlockBreakDeny.add(Material.CHEST.getId());
|
||||
|
||||
BlockPlaceDeny.add(Material.REDSTONE.getId());
|
||||
BlockPlaceDeny.add(Material.REDSTONE_ORE.getId());
|
||||
BlockPlaceDeny.add(Material.REDSTONE_WIRE.getId());
|
||||
BlockPlaceDeny.add(Material.CHEST.getId());
|
||||
|
||||
new AbsorptionFix(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void enableDamage(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
return;
|
||||
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
if (!UtilTime.elapsed(GetStateTime(), _peacePhase))
|
||||
return;
|
||||
|
||||
if (!_peace)
|
||||
return;
|
||||
|
||||
_peace = false;
|
||||
|
||||
Announce(F.main("Game", "The Peace Phase has ended! You can now fight each other!"));
|
||||
DamagePvP = true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void informPeace(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Live)
|
||||
return;
|
||||
|
||||
_peace = true;
|
||||
|
||||
Announce(F.main("Game", "A Peace Phase of " + F.time((_peacePhase/1000) + "") + " seconds has started!"));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void registerObj(GameStateChangeEvent event)
|
||||
@ -58,14 +134,243 @@ public class UHCSurvivalgames extends SoloSurvivalGames
|
||||
{
|
||||
if (event.getEntity() instanceof Player)
|
||||
{
|
||||
event.getDrops().add(new ItemStack(Material.GOLDEN_APPLE));
|
||||
event.getDrops().add(new ItemStack(Material.GOLDEN_APPLE, 2));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.LOWEST)
|
||||
public void spawnBreak(BlockBreakEvent event)
|
||||
{
|
||||
if (UtilMath.offset(event.getBlock().getLocation(), getSpawn()) < 40)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.LOWEST)
|
||||
public void spawnPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if (UtilMath.offset(event.getBlock().getLocation(), getSpawn()) < 40)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
public void setupLoot()
|
||||
{
|
||||
// Build material
|
||||
getBaseLoot().addLoot(new RandomItem(Material.WOOD, 40, 7, 15));
|
||||
|
||||
// Food
|
||||
getBaseLoot().addLoot(new RandomItem(Material.BAKED_POTATO, 40, 1, 3));
|
||||
getBaseLoot().addLoot(new RandomItem(Material.COOKED_BEEF, 40, 1, 2));
|
||||
getBaseLoot().addLoot(new RandomItem(Material.COOKED_CHICKEN, 40, 1, 2));
|
||||
getBaseLoot().addLoot(new RandomItem(Material.MUSHROOM_SOUP, 10, 1, 1));
|
||||
getBaseLoot().addLoot(new RandomItem(Material.PORK, 35, 1, 4));
|
||||
|
||||
// Weapons
|
||||
getBaseLoot().addLoot(new RandomItem(Material.IRON_AXE, 80));
|
||||
getBaseLoot().addLoot(new RandomItem(Material.IRON_SWORD, 70));
|
||||
getBaseLoot().addLoot(new RandomItem(Material.DIAMOND_AXE, 60));
|
||||
getBaseLoot().addLoot(new RandomItem(Material.DIAMOND_SWORD, 30));
|
||||
|
||||
// Gold armor
|
||||
getBaseLoot().addLoot(new RandomItem(Material.GOLD_BOOTS, 25));
|
||||
getBaseLoot().addLoot(new RandomItem(Material.GOLD_CHESTPLATE, 25));
|
||||
getBaseLoot().addLoot(new RandomItem(Material.GOLD_HELMET, 25));
|
||||
getBaseLoot().addLoot(new RandomItem(Material.GOLD_LEGGINGS, 25));
|
||||
|
||||
// Chain armor
|
||||
getBaseLoot().addLoot(new RandomItem(Material.CHAINMAIL_BOOTS, 20));
|
||||
getBaseLoot().addLoot(new RandomItem(Material.CHAINMAIL_CHESTPLATE, 20));
|
||||
getBaseLoot().addLoot(new RandomItem(Material.CHAINMAIL_HELMET, 20));
|
||||
getBaseLoot().addLoot(new RandomItem(Material.CHAINMAIL_LEGGINGS, 20));
|
||||
|
||||
// Throwable
|
||||
getBaseLoot().addLoot(new RandomItem(Material.FISHING_ROD, 30));
|
||||
getBaseLoot().addLoot(new RandomItem(Material.BOW, 20));
|
||||
getBaseLoot().addLoot(new RandomItem(Material.ARROW, 40, 2, 4));
|
||||
|
||||
// Misc
|
||||
getBaseLoot().addLoot(new RandomItem(Material.EXP_BOTTLE, 40, 1, 2));
|
||||
getBaseLoot().addLoot(new RandomItem(Material.COMPASS, 20));
|
||||
getBaseLoot().addLoot(new RandomItem(Material.STICK, 30, 1, 2));
|
||||
getBaseLoot().addLoot(new RandomItem(Material.BOAT, 15));
|
||||
getBaseLoot().addLoot(new RandomItem(Material.GOLD_INGOT, 20));
|
||||
getBaseLoot().addLoot(new RandomItem(Material.GOLDEN_APPLE, 2));
|
||||
getBaseLoot().addLoot(new RandomItem(ItemStackFactory.Instance.CreateStack(
|
||||
Material.TNT, (byte) 0, 1, F.item("Throwing TNT")), 15));
|
||||
getSpawnLoot().addLoot(new RandomItem(Material.MUSHROOM_SOUP, 15));
|
||||
|
||||
getSpawnLoot().cloneLoot(getBaseLoot());
|
||||
|
||||
// Food
|
||||
getSpawnLoot().addLoot(new RandomItem(Material.BAKED_POTATO, 30, 1, 5));
|
||||
getSpawnLoot().addLoot(new RandomItem(Material.CAKE, 30));
|
||||
getSpawnLoot().addLoot(new RandomItem(Material.MUSHROOM_SOUP, 30, 1, 1));
|
||||
getSpawnLoot().addLoot(new RandomItem(Material.COOKED_BEEF, 30, 1, 3));
|
||||
getSpawnLoot().addLoot(new RandomItem(Material.COOKED_CHICKEN, 30, 1, 3));
|
||||
getSpawnLoot().addLoot(new RandomItem(Material.COOKED_FISH, 30, 1, 6));
|
||||
getSpawnLoot().addLoot(new RandomItem(Material.GRILLED_PORK, 30, 1, 3));
|
||||
getSpawnLoot().addLoot(new RandomItem(Material.COOKIE, 30));
|
||||
getSpawnLoot().addLoot(new RandomItem(Material.PUMPKIN_PIE, 30, 1, 3));
|
||||
getSpawnLoot().addLoot(new RandomItem(Material.APPLE, 30, 2, 6));
|
||||
|
||||
// Loot for chests in spawn
|
||||
// Weaponry and ores
|
||||
getSpawnLoot().addLoot(new RandomItem(Material.STONE_SWORD, 30));
|
||||
getSpawnLoot().addLoot(new RandomItem(Material.IRON_AXE, 30));
|
||||
getSpawnLoot().addLoot(new RandomItem(Material.IRON_INGOT, 40, 1, 2));
|
||||
getSpawnLoot().addLoot(new RandomItem(Material.DIAMOND, 30));
|
||||
|
||||
// Iron gear
|
||||
getSpawnLoot().addLoot(new RandomItem(Material.IRON_BOOTS, 30));
|
||||
getSpawnLoot().addLoot(new RandomItem(Material.IRON_CHESTPLATE, 30));
|
||||
getSpawnLoot().addLoot(new RandomItem(Material.IRON_HELMET, 30));
|
||||
getSpawnLoot().addLoot(new RandomItem(Material.IRON_LEGGINGS, 30));
|
||||
|
||||
// Supply crate loot
|
||||
// Diamond gear
|
||||
getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_HELMET, 10));
|
||||
getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_CHESTPLATE, 6));
|
||||
getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_LEGGINGS, 8));
|
||||
getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_BOOTS, 10));
|
||||
|
||||
// Iron gear
|
||||
getCrateLoot().addLoot(new RandomItem(Material.IRON_HELMET, 30));
|
||||
getCrateLoot().addLoot(new RandomItem(Material.IRON_CHESTPLATE, 24));
|
||||
getCrateLoot().addLoot(new RandomItem(Material.IRON_LEGGINGS, 27));
|
||||
getCrateLoot().addLoot(new RandomItem(Material.IRON_BOOTS, 30));
|
||||
|
||||
// Weapons
|
||||
getCrateLoot().addLoot(new RandomItem(Material.IRON_SWORD, 24));
|
||||
getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_SWORD, 8));
|
||||
getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_AXE, 16));
|
||||
|
||||
// Cooked furnace
|
||||
getFurnace().addLoot(new RandomItem(Material.COOKED_BEEF, 3, 1, 2));
|
||||
getFurnace().addLoot(new RandomItem(Material.COOKED_CHICKEN, 3, 1, 2));
|
||||
getFurnace().addLoot(new RandomItem(Material.COOKED_FISH, 3, 1, 2));
|
||||
getFurnace().addLoot(new RandomItem(Material.GRILLED_PORK, 3, 1, 2));
|
||||
getFurnace().addLoot(new RandomItem(Material.BAKED_POTATO, 3, 1, 1));
|
||||
getFurnace().addLoot(new RandomItem(Material.PUMPKIN_PIE, 3, 1, 1));
|
||||
getFurnace().addLoot(new RandomItem(Material.IRON_INGOT, 1, 1, 1));
|
||||
|
||||
// Raw furnace
|
||||
getRawFurnace().addLoot(new RandomItem(Material.RAW_BEEF, 1, 1, 3));
|
||||
getRawFurnace().addLoot(new RandomItem(Material.RAW_CHICKEN, 1, 1, 3));
|
||||
getRawFurnace().addLoot(new RandomItem(Material.RAW_FISH, 1, 1, 3));
|
||||
getRawFurnace().addLoot(new RandomItem(Material.PORK, 1, 1, 3));
|
||||
getRawFurnace().addLoot(new RandomItem(Material.POTATO_ITEM, 1, 1, 3));
|
||||
|
||||
// Deathmatch Loot
|
||||
getDeathMatch().addLoot(new RandomItem(Material.PUMPKIN_PIE, 4));
|
||||
getDeathMatch().addLoot(new RandomItem(Material.BAKED_POTATO, 4));
|
||||
getDeathMatch().addLoot(new RandomItem(Material.CAKE, 4));
|
||||
getDeathMatch().addLoot(new RandomItem(Material.APPLE, 4));
|
||||
getDeathMatch().addLoot(new RandomItem(Material.WOOD_SWORD, 3));
|
||||
getDeathMatch().addLoot(new RandomItem(Material.WOOD_AXE, 3));
|
||||
getDeathMatch().addLoot(new RandomItem(Material.STONE_AXE, 3));
|
||||
getDeathMatch().addLoot(new RandomItem(Material.STONE_SWORD, 1));
|
||||
}
|
||||
|
||||
public void fillChest(Player looter, Block block)
|
||||
{
|
||||
getLootedBlocks().add(block.getLocation());
|
||||
|
||||
Chest chest = (Chest) block.getState();
|
||||
|
||||
chest.getBlockInventory().clear();
|
||||
|
||||
int items = 2;
|
||||
if (Math.random() > 0.50)
|
||||
items++;
|
||||
if (Math.random() > 0.65)
|
||||
items++;
|
||||
if (Math.random() > 0.80)
|
||||
items++;
|
||||
if (Math.random() > 0.95)
|
||||
items++;
|
||||
|
||||
boolean spawnChest = getChestRefillTime() > 0
|
||||
&& UtilMath.offset(chest.getLocation(), getSpawn()) < 8;
|
||||
|
||||
if (spawnChest)
|
||||
items += 3;
|
||||
|
||||
if (GetKit(looter) instanceof KitLooter)
|
||||
{
|
||||
items += UtilMath.r(3);
|
||||
}
|
||||
|
||||
if (getSupplyBlocks().contains(block))
|
||||
{
|
||||
items = 2;
|
||||
if (Math.random() > 0.75)
|
||||
items++;
|
||||
if (Math.random() > 0.95)
|
||||
items++;
|
||||
}
|
||||
|
||||
for (int i = 0; i < items; i++)
|
||||
{
|
||||
ItemStack item;
|
||||
|
||||
if (spawnChest)
|
||||
{
|
||||
item = getSpawnLoot().getLoot();
|
||||
}
|
||||
else if (isDeathMatchTeleported())
|
||||
{
|
||||
item = getDeathMatch().getLoot();
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean drop = getSupplyBlocks().contains(block);
|
||||
item = GetChestItem(drop);
|
||||
|
||||
// Golden apple spawn
|
||||
if (drop && i == items)
|
||||
item = new ItemStack(Material.GOLDEN_APPLE);
|
||||
}
|
||||
|
||||
if (item.getType() == Material.COMPASS)
|
||||
{
|
||||
item = buildCompass(5);
|
||||
}
|
||||
|
||||
handlePickup(item);
|
||||
|
||||
chest.getBlockInventory().setItem(UtilMath.r(27), item);
|
||||
}
|
||||
|
||||
if (getSupplyBlocks().contains(block))
|
||||
{
|
||||
Bukkit.getPluginManager().callEvent(
|
||||
new SupplyChestOpenEvent(looter, block));
|
||||
}
|
||||
|
||||
getSupplyBlocks().remove(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
@EventHandler
|
||||
public void preventCrafting(PrepareItemCraftEvent event)
|
||||
{
|
||||
ItemStack result = event.getInventory().getResult();
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
Material type = result.getType();
|
||||
|
||||
if (type == Material.BUCKET
|
||||
|| type == Material.FLINT_AND_STEEL)
|
||||
{
|
||||
event.getInventory().setResult(new ItemStack(Material.AIR));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetMode()
|
||||
{
|
||||
return "UHC Survivalagmes";
|
||||
return "UHC Survivalgames";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,48 @@
|
||||
package nautilus.game.arcade.game.games.survivalgames.modes.kit;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.kit.KitAvailability;
|
||||
import nautilus.game.arcade.kit.Perk;
|
||||
|
||||
/**
|
||||
* KitSurvivalist
|
||||
*
|
||||
* @author xXVevzZXx
|
||||
*/
|
||||
public class KitSurvivalist extends Kit
|
||||
{
|
||||
public KitSurvivalist(ArcadeManager manager)
|
||||
{
|
||||
super(manager, "Survivalist", KitAvailability.Free,
|
||||
new String[]
|
||||
{
|
||||
"You are a survival expert!",
|
||||
},
|
||||
new Perk[]
|
||||
{
|
||||
|
||||
},
|
||||
EntityType.PLAYER,
|
||||
new ItemStack(Material.AIR));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void GiveItems(Player player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SpawnCustom(LivingEntity ent)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user