Modularize Minestrike and add Strike Games

This commit is contained in:
xXVevzZXx 2016-06-25 19:11:08 +02:00
parent 7a55b131d4
commit 8d4f5f0f93
30 changed files with 2438 additions and 1602 deletions

View File

@ -1,5 +1,7 @@
package nautilus.game.arcade; package nautilus.game.arcade;
import mineplex.core.common.MinecraftVersion;
import mineplex.core.common.Pair;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
/** /**
@ -14,16 +16,34 @@ public class GameMode
private GameType _gameType; private GameType _gameType;
private String _name; private String _name;
private Pair<MinecraftVersion, String>[] _resourcePackUrls;
private boolean _enforceResourcePack;
/** /**
* *
* @param gameMode Game class that in most cases extends the host game class * @param gameMode Game class that in most cases extends the host game class
* @param name Gamemode name * @param name Gamemode name
*/ */
public GameMode(Class<? extends Game> gameMode, GameType gameType, String name) public GameMode(Class<? extends Game> gameMode, GameType gameType, String name)
{
this(gameMode, gameType, name, null, false);
}
/**
*
* @param gameMode Game class that in most cases extends the host game class
* @param gameType original GameType of modded game
* @param name Gamemode name
* @param resourcePackUrls URLs to 1.8/1.9 resource pack
* @param enforceResourcePack enforece resource pack on players
*/
public GameMode(Class<? extends Game> gameMode, GameType gameType, String name, Pair<MinecraftVersion, String>[] resourcePackUrls, boolean enforceResourcePack)
{ {
_gameMode = gameMode; _gameMode = gameMode;
_gameType = gameType; _gameType = gameType;
_name = name; _name = name;
_resourcePackUrls = resourcePackUrls;
_enforceResourcePack = enforceResourcePack;
} }
/** /**
@ -52,5 +72,23 @@ public class GameMode
{ {
return _gameType; return _gameType;
} }
/**
*
* @return Gamemode resource pack URLs
*/
public Pair<MinecraftVersion, String>[] getResPackURLs()
{
return _resourcePackUrls;
}
/**
*
* @return Gamemode enforcing of resource packs
*/
public boolean enforceResourcePack()
{
return _enforceResourcePack;
}
} }

View File

@ -50,7 +50,8 @@ import nautilus.game.arcade.game.games.micro.modes.TinySmash;
import nautilus.game.arcade.game.games.micro.modes.TinyWinners; import nautilus.game.arcade.game.games.micro.modes.TinyWinners;
import nautilus.game.arcade.game.games.milkcow.MilkCow; import nautilus.game.arcade.game.games.milkcow.MilkCow;
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.minestrike.GunModule;
import nautilus.game.arcade.game.games.minestrike.Minestrike;
import nautilus.game.arcade.game.games.mineware.MineWare; import nautilus.game.arcade.game.games.mineware.MineWare;
import nautilus.game.arcade.game.games.monsterleague.MonsterLeague; import nautilus.game.arcade.game.games.monsterleague.MonsterLeague;
import nautilus.game.arcade.game.games.monstermaze.MonsterMaze; import nautilus.game.arcade.game.games.monstermaze.MonsterMaze;
@ -89,6 +90,7 @@ import nautilus.game.arcade.game.games.survivalgames.SoloSurvivalGames;
import nautilus.game.arcade.game.games.survivalgames.TeamSurvivalGames; import nautilus.game.arcade.game.games.survivalgames.TeamSurvivalGames;
import nautilus.game.arcade.game.games.survivalgames.modes.ChangingKits; import nautilus.game.arcade.game.games.survivalgames.modes.ChangingKits;
import nautilus.game.arcade.game.games.survivalgames.modes.OverpoweredSurvival; import nautilus.game.arcade.game.games.survivalgames.modes.OverpoweredSurvival;
import nautilus.game.arcade.game.games.survivalgames.modes.StrikeGames;
import nautilus.game.arcade.game.games.survivalgames.modes.UHCSurvivalgames; import nautilus.game.arcade.game.games.survivalgames.modes.UHCSurvivalgames;
import nautilus.game.arcade.game.games.tug.Tug; import nautilus.game.arcade.game.games.tug.Tug;
import nautilus.game.arcade.game.games.turfforts.TurfForts; import nautilus.game.arcade.game.games.turfforts.TurfForts;
@ -142,7 +144,7 @@ public enum GameType
Lobbers(BombLobbers.class, GameDisplay.Lobbers), Lobbers(BombLobbers.class, GameDisplay.Lobbers),
Micro(Micro.class, GameDisplay.Micro), Micro(Micro.class, GameDisplay.Micro),
MilkCow(MilkCow.class, GameDisplay.MilkCow), MilkCow(MilkCow.class, GameDisplay.MilkCow),
MineStrike(MineStrike.class, GameDisplay.MineStrike, new Pair[] MineStrike(Minestrike.class, GameDisplay.MineStrike, new Pair[]
{ {
Pair.create(MinecraftVersion.Version1_8, "http://file.mineplex.com/ResMinestrike.zip"), Pair.create(MinecraftVersion.Version1_8, "http://file.mineplex.com/ResMinestrike.zip"),
Pair.create(MinecraftVersion.Version1_9, "http://file.mineplex.com/ResMinestrike19.zip") Pair.create(MinecraftVersion.Version1_9, "http://file.mineplex.com/ResMinestrike19.zip")
@ -222,7 +224,12 @@ public enum GameType
new GameMode(Assassins.class, GameType.UHC, "Assassins"), new GameMode(Assassins.class, GameType.UHC, "Assassins"),
new GameMode(OverpoweredSurvival.class, GameType.SurvivalGames, "OP Survival Games"), new GameMode(OverpoweredSurvival.class, GameType.SurvivalGames, "OP Survival Games"),
new GameMode(UHCSurvivalgames.class, GameType.SurvivalGames, "UHC Survivalgames"), new GameMode(UHCSurvivalgames.class, GameType.SurvivalGames, "UHC Survivalgames"),
new GameMode(ChangingKits.class, GameType.SurvivalGames, "Changing Kits"), new GameMode(ChangingKits.class, GameType.SurvivalGames, "Changing Kits"),
new GameMode(StrikeGames.class, GameType.SurvivalGames, "Strike Games", new Pair[]
{
Pair.create(MinecraftVersion.Version1_8, "http://file.mineplex.com/ResMinestrike.zip"),
Pair.create(MinecraftVersion.Version1_9, "http://file.mineplex.com/ResMinestrike19.zip")
}, true),
new GameMode(TinyWinners.class, GameType.Micro, "Tiny Winners"), new GameMode(TinyWinners.class, GameType.Micro, "Tiny Winners"),
new GameMode(OverpoweredMicroBattles.class, GameType.Micro, "OP Micro Battles"), new GameMode(OverpoweredMicroBattles.class, GameType.Micro, "OP Micro Battles"),
new GameMode(CookieFight.class, GameType.Micro, "Cookie Fight"), new GameMode(CookieFight.class, GameType.Micro, "Cookie Fight"),
@ -304,13 +311,21 @@ public enum GameType
return _gameModes; return _gameModes;
} }
public boolean isEnforceResourcePack() public boolean isEnforceResourcePack(Game game)
{ {
if (hasGamemodes())
{
return getGameMode(game.getClass()).enforceResourcePack();
}
return _enforceResourcePack; return _enforceResourcePack;
} }
public Pair<MinecraftVersion, String>[] getResourcePackUrls() public Pair<MinecraftVersion, String>[] getResourcePackUrls(Game game)
{ {
if (hasGamemodes())
{
return getGameMode(game.getClass()).getResPackURLs();
}
return _resourcePacks; return _resourcePacks;
} }
@ -359,15 +374,25 @@ public enum GameType
return _gameMaps; return _gameMaps;
} }
public GameType getModeGameType(Class<? extends Game> game) public GameMode getGameMode(Class<? extends Game> game)
{ {
for (GameMode mode : getGameModes()) for (GameMode mode : getGameModes())
{ {
if (mode.getGameClass() != null && mode.getGameClass().getName().contentEquals(game.getName())) if (mode.getGameClass() != null && mode.getGameClass().getName().contentEquals(game.getName()))
{ {
return mode.getType(); return mode;
} }
} }
return null; return null;
} }
public GameType getModeGameType(Class<? extends Game> game)
{
return getGameMode(game).getType();
}
public boolean hasGamemodes()
{
return _gameModes.length != 0;
}
} }

View File

@ -398,7 +398,7 @@ public abstract class Game implements Listener
new ExperienceStatTracker(this), new WinStatTracker(this), new LoseStatTracker(this), new DamageDealtStatTracker( new ExperienceStatTracker(this), new WinStatTracker(this), new LoseStatTracker(this), new DamageDealtStatTracker(
this), new DamageTakenStatTracker(this), new GamesPlayedStatTracker(this)); this), new DamageTakenStatTracker(this), new GamesPlayedStatTracker(this));
Manager.getResourcePackManager().setResourcePack(gameType.getResourcePackUrls(), gameType.isEnforceResourcePack()); Manager.getResourcePackManager().setResourcePack(gameType.getResourcePackUrls(this), gameType.isEnforceResourcePack(this));
_useEntityPacketHandler = new IPacketHandler() _useEntityPacketHandler = new IPacketHandler()
{ {

View File

@ -0,0 +1,59 @@
package nautilus.game.arcade.game.games.minestrike;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.minestrike.data.Bullet;
public class CustomGunDamageEvent extends PlayerEvent
{
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList()
{
return handlers;
}
@Override
public HandlerList getHandlers()
{
return getHandlerList();
}
private Bullet _bullet;
private final boolean _headshot;
private CustomDamageEvent _damageEvent;
private GunModule _game;
public CustomGunDamageEvent(Bullet _bullet, Player _target, boolean _headshot, CustomDamageEvent _damageEvent, GunModule game)
{
super(_target);
this._bullet = _bullet;
this._headshot = _headshot;
this._damageEvent = _damageEvent;
this._game = game;
}
public Bullet getBullet()
{
return _bullet;
}
public boolean isHeadshot()
{
return _headshot;
}
public CustomDamageEvent getDamageEvent()
{
return _damageEvent;
}
public GunModule getGame()
{
return _game;
}
}

View File

@ -0,0 +1,35 @@
package nautilus.game.arcade.game.games.minestrike;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
public class PlayerHeadshotEvent extends PlayerEvent
{
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList()
{
return handlers;
}
@Override
public HandlerList getHandlers()
{
return getHandlerList();
}
private final Player _shooter;
public PlayerHeadshotEvent(Player who, Player shooter)
{
super(who);
_shooter = shooter;
}
public Player getShooter()
{
return _shooter;
}
}

View File

@ -35,15 +35,15 @@ import org.bukkit.event.inventory.InventoryClickEvent;
public class ShopManager public class ShopManager
{ {
private MineStrike Host; private Minestrike Host;
private HashMap<Player, HashMap<Integer, StrikeItem>> _shop = new HashMap<Player, HashMap<Integer, StrikeItem>>(); private HashMap<Player, HashMap<Integer, StrikeItem>> _shop = new HashMap<Player, HashMap<Integer, StrikeItem>>();
private HashMap<Player, Integer> _money = new HashMap<Player, Integer>(); private HashMap<Player, Integer> _money = new HashMap<Player, Integer>();
private HashSet<Player> _inShop = new HashSet<Player>(); private HashSet<Player> _inShop = new HashSet<Player>();
public ShopManager(MineStrike host) public ShopManager(Minestrike minestrike)
{ {
Host = host; Host = minestrike;
} }
public void enterShop(Player player) public void enterShop(Player player)
@ -60,27 +60,27 @@ public class ShopManager
//Pistols //Pistols
slot = 9; slot = 9;
addItem(team.GetColor() == ChatColor.RED ? new Gun(GunStats.GLOCK_18) : new Gun(GunStats.P2000), player, slot++); addItem(team.GetColor() == ChatColor.RED ? new Gun(GunStats.GLOCK_18, Host.getGunModule()) : new Gun(GunStats.P2000, Host.getGunModule()), player, slot++);
addItem(new Gun(GunStats.P250), player, slot++); addItem(new Gun(GunStats.P250, Host.getGunModule()), player, slot++);
addItem(new Gun(GunStats.CZ75), player, slot++); addItem(new Gun(GunStats.CZ75, Host.getGunModule()), player, slot++);
addItem(new Gun(GunStats.DEAGLE), player, slot++); addItem(new Gun(GunStats.DEAGLE, Host.getGunModule()), player, slot++);
//Shotgun //Shotgun
slot = 18; slot = 18;
addItem(new Shotgun(GunStats.NOVA), player, slot++); addItem(new Shotgun(GunStats.NOVA, Host.getGunModule()), player, slot++);
addItem(new Shotgun(GunStats.XM1014), player, slot++); addItem(new Shotgun(GunStats.XM1014, Host.getGunModule()), player, slot++);
//SMG //SMG
addItem(new Gun(GunStats.PPBIZON), player, slot++); addItem(new Gun(GunStats.PPBIZON, Host.getGunModule()), player, slot++);
addItem(new Gun(GunStats.P90), player, slot++); addItem(new Gun(GunStats.P90, Host.getGunModule()), player, slot++);
//Rifles //Rifles
slot = 27; slot = 27;
addItem(team.GetColor() == ChatColor.RED ? new Gun(GunStats.GALIL) : new Gun(GunStats.FAMAS), player, slot++); addItem(team.GetColor() == ChatColor.RED ? new Gun(GunStats.GALIL, Host.getGunModule()) : new Gun(GunStats.FAMAS, Host.getGunModule()), player, slot++);
addItem(team.GetColor() == ChatColor.RED ? new Gun(GunStats.AK47) : new Gun(GunStats.M4A4), player, slot++); addItem(team.GetColor() == ChatColor.RED ? new Gun(GunStats.AK47, Host.getGunModule()) : new Gun(GunStats.M4A4, Host.getGunModule()), player, slot++);
addItem(team.GetColor() == ChatColor.RED ? new Gun(GunStats.SG553) : new Gun(GunStats.AUG), player, slot++); addItem(team.GetColor() == ChatColor.RED ? new Gun(GunStats.SG553, Host.getGunModule()) : new Gun(GunStats.AUG, Host.getGunModule()), player, slot++);
addItem(new Gun(GunStats.SSG08), player, slot++); addItem(new Gun(GunStats.SSG08, Host.getGunModule()), player, slot++);
addItem(new Gun(GunStats.AWP), player, slot++); addItem(new Gun(GunStats.AWP, Host.getGunModule()), player, slot++);
//Grenades //Grenades
addItem(new FlashBang(), player, 14); addItem(new FlashBang(), player, 14);
@ -217,11 +217,11 @@ public class ShopManager
if (item instanceof Gun) if (item instanceof Gun)
{ {
Gun gun = (Gun)item; Gun gun = (Gun)item;
Host.dropSlotItem(player, gun.getSlot()); Host.getGunModule().dropSlotItem(player, gun.getSlot());
gun.giveToPlayer(player, true); gun.giveToPlayer(player, true);
gun.updateWeaponName(player, Host); gun.updateWeaponName(player, Host.getGunModule());
gun.updateSkin(player, Host.getArcadeManager().getCosmeticManager().getGadgetManager()); gun.updateSkin(player, Host.getArcadeManager().getCosmeticManager().getGadgetManager());
Host.registerGun(gun, player); Host.getGunModule().registerGun(gun, player);
} }
//Grenade //Grenade
@ -235,7 +235,7 @@ public class ShopManager
return; return;
} }
Host.registerGrenade(grenade, player); Host.getGunModule().registerGrenade(grenade, player);
} }
//Use 250 instead of 255, to show that its kevlar/helmet //Use 250 instead of 255, to show that its kevlar/helmet

View File

@ -2,7 +2,7 @@ package nautilus.game.arcade.game.games.minestrike.data;
import java.util.HashSet; import java.util.HashSet;
import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.minestrike.GunModule;
import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; import nautilus.game.arcade.game.games.minestrike.items.guns.Gun;
import org.bukkit.Location; import org.bukkit.Location;
@ -25,7 +25,7 @@ public class Bullet
public HashSet<Player> WhizzSound = new HashSet<Player>(); public HashSet<Player> WhizzSound = new HashSet<Player>();
public Bullet(Entity bullet, Gun gun, Player shooter, MineStrike game) public Bullet(Entity bullet, Gun gun, Player shooter, GunModule game)
{ {
Bullet = bullet; Bullet = bullet;
Gun = gun; Gun = gun;

View File

@ -19,7 +19,7 @@ import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.minestrike.GunModule;
import nautilus.game.arcade.game.games.minestrike.items.grenades.Grenade; import nautilus.game.arcade.game.games.minestrike.items.grenades.Grenade;
import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; import nautilus.game.arcade.game.games.minestrike.items.guns.Gun;
@ -104,7 +104,7 @@ public abstract class StrikeItem
_ownerName = ownerName; _ownerName = ownerName;
} }
public void drop(MineStrike game, Player player, boolean natural, boolean onlyDeregisterAndRemove) public void drop(GunModule game, Player player, boolean natural, boolean onlyDeregisterAndRemove)
{ {
_stack.setAmount(1); _stack.setAmount(1);
@ -160,6 +160,20 @@ public abstract class StrikeItem
public boolean isStack(ItemStack stack) public boolean isStack(ItemStack stack)
{ {
if (stack.hasItemMeta())
{
if (stack.getItemMeta().hasLore())
{
if (getStack().hasItemMeta())
{
if (getStack().getItemMeta().hasLore())
{
if (UtilGear.isMat(stack, _skinMaterial))
return stack.getItemMeta().getLore().get(0).equalsIgnoreCase(getStack().getItemMeta().getLore().get(0));
}
}
}
}
return UtilGear.isMat(stack, _skinMaterial); return UtilGear.isMat(stack, _skinMaterial);
} }
@ -184,7 +198,7 @@ public abstract class StrikeItem
_stack.setItemMeta(meta); _stack.setItemMeta(meta);
} }
public abstract boolean pickup(MineStrike game, Player player); public abstract boolean pickup(GunModule game, Player player);
public ItemStack getShopItem(int money, boolean alreadyHas) public ItemStack getShopItem(int money, boolean alreadyHas)
{ {

View File

@ -8,7 +8,7 @@ import org.bukkit.entity.Player;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.minestrike.GunModule;
import nautilus.game.arcade.game.games.minestrike.items.StrikeItem; import nautilus.game.arcade.game.games.minestrike.items.StrikeItem;
import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType;
@ -24,7 +24,7 @@ public class DefusalKit extends StrikeItem
} }
@Override @Override
public boolean pickup(MineStrike game, Player player) public boolean pickup(GunModule game, Player player)
{ {
return false; return false;
} }

View File

@ -11,7 +11,7 @@ import org.bukkit.inventory.meta.LeatherArmorMeta;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.minestrike.GunModule;
import nautilus.game.arcade.game.games.minestrike.items.StrikeItem; import nautilus.game.arcade.game.games.minestrike.items.StrikeItem;
import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType;
@ -23,7 +23,7 @@ public class Armor extends StrikeItem
} }
@Override @Override
public boolean pickup(MineStrike game, Player player) public boolean pickup(GunModule game, Player player)
{ {
return false; return false;
} }

View File

@ -2,16 +2,6 @@ package nautilus.game.arcade.game.games.minestrike.items.grenades;
import java.util.HashMap; import java.util.HashMap;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.minestrike.MineStrike;
import nautilus.game.arcade.game.games.minestrike.Radio;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -21,6 +11,15 @@ import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.minestrike.GunModule;
import nautilus.game.arcade.game.games.minestrike.Radio;
public abstract class FireGrenadeBase extends Grenade public abstract class FireGrenadeBase extends Grenade
{ {
private long _baseTime; private long _baseTime;
@ -37,7 +36,7 @@ public abstract class FireGrenadeBase extends Grenade
} }
@Override @Override
public boolean updateCustom(MineStrike game, Entity ent) public boolean updateCustom(GunModule game, Entity ent)
{ {
// Fixed grenade effect not being activated when thrown in the ground. // Fixed grenade effect not being activated when thrown in the ground.
// Looks like ent.isOnGround() worked, while we previously used UtilEnt.isGrounded(ent). // Looks like ent.isOnGround() worked, while we previously used UtilEnt.isGrounded(ent).
@ -52,7 +51,7 @@ public abstract class FireGrenadeBase extends Grenade
return false; return false;
} }
private void createFire(final MineStrike game, final Location loc) private void createFire(final GunModule game, final Location loc)
{ {
//Sound //Sound
loc.getWorld().playSound(loc, Sound.IRONGOLEM_THROW, 1f, 1f); loc.getWorld().playSound(loc, Sound.IRONGOLEM_THROW, 1f, 1f);
@ -114,9 +113,9 @@ public abstract class FireGrenadeBase extends Grenade
} }
@Override @Override
public void playSound(MineStrike game, Player player) public void playSound(GunModule game, Player player)
{ {
GameTeam team = game.GetTeam(player); GameTeam team = game.getHost().GetTeam(player);
if (team == null) if (team == null)
return; return;

View File

@ -9,7 +9,7 @@ import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.minestrike.GunModule;
import nautilus.game.arcade.game.games.minestrike.Radio; import nautilus.game.arcade.game.games.minestrike.Radio;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -33,7 +33,7 @@ public class FlashBang extends Grenade
} }
@Override @Override
public boolean updateCustom(MineStrike game, Entity ent) public boolean updateCustom(GunModule game, Entity ent)
{ {
if (UtilTime.elapsed(_throwTime, 2000)) if (UtilTime.elapsed(_throwTime, 2000))
{ {
@ -43,7 +43,7 @@ public class FlashBang extends Grenade
HashMap<Player, Double> players = UtilPlayer.getInRadius(ent.getLocation(), 48); HashMap<Player, Double> players = UtilPlayer.getInRadius(ent.getLocation(), 48);
for (Player player : players.keySet()) for (Player player : players.keySet())
{ {
if (!game.IsAlive(player)) if (!game.getHost().IsAlive(player))
continue; continue;
//Line of Sight //Line of Sight
@ -83,9 +83,9 @@ public class FlashBang extends Grenade
} }
@Override @Override
public void playSound(MineStrike game, Player player) public void playSound(GunModule game, Player player)
{ {
GameTeam team = game.GetTeam(player); GameTeam team = game.getHost().GetTeam(player);
if (team == null) if (team == null)
return; return;

View File

@ -11,6 +11,7 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
@ -20,7 +21,7 @@ import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.minestrike.GunModule;
import nautilus.game.arcade.game.games.minestrike.items.StrikeItem; import nautilus.game.arcade.game.games.minestrike.items.StrikeItem;
import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType;
@ -132,9 +133,20 @@ public abstract class Grenade extends StrikeItem
return true; return true;
} }
public void throwGrenade(Player player, boolean wasLeftClick, MineStrike game) public void throwGrenade(Player player, boolean wasLeftClick, GunModule game)
{ {
player.setItemInHand(null);
if (player.getItemInHand().getAmount() < 2)
{
player.setItemInHand(null);
}
else
{
int amount = player.getItemInHand().getAmount();
ItemStack stack = getStack();
stack.setAmount(amount - 1);
player.setItemInHand(stack);
}
_thrower = player; _thrower = player;
@ -151,9 +163,13 @@ public abstract class Grenade extends StrikeItem
_lastLoc = ent.getLocation(); _lastLoc = ent.getLocation();
UtilPlayer.message(player, F.main("Game", "You threw " + getName() + ".")); UtilPlayer.message(player, F.main("Game", "You threw " + getName() + "."));
game.registerThrownGrenade(ent, this); game.registerThrownGrenade(ent, this);
game.deregisterGrenade(this);
if (player.getItemInHand().getAmount() < 2)
{
game.deregisterGrenade(this);
}
//Sound //Sound
playSound(game, player); playSound(game, player);
@ -161,7 +177,7 @@ public abstract class Grenade extends StrikeItem
_throwTime = System.currentTimeMillis(); _throwTime = System.currentTimeMillis();
} }
public boolean update(MineStrike game, Entity ent) public boolean update(GunModule game, Entity ent)
{ {
if (UtilTime.elapsed(_throwTime, 20000)) if (UtilTime.elapsed(_throwTime, 20000))
return true; return true;
@ -233,10 +249,10 @@ public abstract class Grenade extends StrikeItem
_lastLoc = ent.getLocation(); _lastLoc = ent.getLocation();
} }
public abstract boolean updateCustom(MineStrike game, Entity ent); public abstract boolean updateCustom(GunModule game, Entity ent);
@Override @Override
public boolean pickup(MineStrike game, Player player) public boolean pickup(GunModule game, Player player)
{ {
if (giveToPlayer(player, false)) if (giveToPlayer(player, false))
{ {
@ -255,5 +271,5 @@ public abstract class Grenade extends StrikeItem
return C.cDGreen + C.Bold + "Grenade" + ChatColor.RESET; return C.cDGreen + C.Bold + "Grenade" + ChatColor.RESET;
} }
public abstract void playSound(MineStrike game, Player player); public abstract void playSound(GunModule game, Player player);
} }

View File

@ -11,7 +11,7 @@ import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.minestrike.GunModule;
import nautilus.game.arcade.game.games.minestrike.Radio; import nautilus.game.arcade.game.games.minestrike.Radio;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -34,7 +34,7 @@ public class HighExplosive extends Grenade
} }
@Override @Override
public boolean updateCustom(MineStrike game, Entity ent) public boolean updateCustom(GunModule game, Entity ent)
{ {
if (UtilTime.elapsed(_throwTime, 2000)) if (UtilTime.elapsed(_throwTime, 2000))
{ {
@ -48,7 +48,7 @@ public class HighExplosive extends Grenade
List<Player> damagedPlayers = new ArrayList<>(); List<Player> damagedPlayers = new ArrayList<>();
for (Player player : players.keySet()) for (Player player : players.keySet())
{ {
if (!game.IsAlive(player)) if (!game.getHost().IsAlive(player))
continue; continue;
// Damage Event // Damage Event
@ -68,9 +68,9 @@ public class HighExplosive extends Grenade
} }
@Override @Override
public void playSound(MineStrike game, Player player) public void playSound(GunModule game, Player player)
{ {
GameTeam team = game.GetTeam(player); GameTeam team = game.getHost().GetTeam(player);
if (team == null) if (team == null)
return; return;

View File

@ -10,7 +10,7 @@ import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilParticle.ViewDist;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.minestrike.GunModule;
import nautilus.game.arcade.game.games.minestrike.Radio; import nautilus.game.arcade.game.games.minestrike.Radio;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -36,7 +36,7 @@ public class Smoke extends Grenade
} }
@Override @Override
public boolean updateCustom(final MineStrike game, Entity ent) public boolean updateCustom(final GunModule game, Entity ent)
{ {
if (UtilTime.elapsed(_throwTime, 2000) && (UtilEnt.isGrounded(ent) || !ent.isValid())) if (UtilTime.elapsed(_throwTime, 2000) && (UtilEnt.isGrounded(ent) || !ent.isValid()))
{ {
@ -95,9 +95,9 @@ public class Smoke extends Grenade
} }
@Override @Override
public void playSound(MineStrike game, Player player) public void playSound(GunModule game, Player player)
{ {
GameTeam team = game.GetTeam(player); GameTeam team = game.getHost().GetTeam(player);
if (team == null) if (team == null)
return; return;

View File

@ -32,10 +32,11 @@ import mineplex.core.common.util.UtilTime;
import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType; import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType;
import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.GameModifierMineStrikeSkin; import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.GameModifierMineStrikeSkin;
import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.MineStrikeSkin;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.recharge.RechargedEvent; import mineplex.core.recharge.RechargedEvent;
import mineplex.core.stats.PlayerStats; import mineplex.core.stats.PlayerStats;
import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.minestrike.GunModule;
import nautilus.game.arcade.game.games.minestrike.data.Bullet; import nautilus.game.arcade.game.games.minestrike.data.Bullet;
import nautilus.game.arcade.game.games.minestrike.items.StrikeItem; import nautilus.game.arcade.game.games.minestrike.items.StrikeItem;
import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType;
@ -59,11 +60,15 @@ public class Gun extends StrikeItem
protected int _kills = -1; protected int _kills = -1;
protected String _activeSkinName = "Default"; protected String _activeSkinName = "Default";
protected GunModule _module;
public Gun(GunStats gunStats) public Gun(GunStats gunStats, GunModule module)
{ {
super(gunStats.getItemType(), gunStats.getName(), gunStats.getDesc(), gunStats.getCost(), gunStats.getGemCost(), gunStats.getSkin()); super(gunStats.getItemType(), gunStats.getName(), gunStats.getDesc(), gunStats.getCost(), gunStats.getGemCost(), gunStats.getSkin());
_module = module;
_gunStats = gunStats; _gunStats = gunStats;
if (gunStats.getItemType() == StrikeItemType.PRIMARY_WEAPON) if (gunStats.getItemType() == StrikeItemType.PRIMARY_WEAPON)
@ -79,7 +84,7 @@ public class Gun extends StrikeItem
updateWeaponName(null, null); updateWeaponName(null, null);
} }
public void shoot(final Player player, final MineStrike game) public void shoot(final Player player, final GunModule game)
{ {
if (_reloading) if (_reloading)
return; return;
@ -94,7 +99,7 @@ public class Gun extends StrikeItem
{ {
public void run() public void run()
{ {
if (game.IsAlive(player)) if (game.getHost().IsAlive(player))
shootOnce(player, game); shootOnce(player, game);
} }
}, 2); }, 2);
@ -109,7 +114,7 @@ public class Gun extends StrikeItem
{ {
public void run() public void run()
{ {
if (game.IsAlive(player)) if (game.getHost().IsAlive(player))
shootOnce(player, game); shootOnce(player, game);
} }
}, i); }, i);
@ -117,7 +122,7 @@ public class Gun extends StrikeItem
} }
} }
public void shootOnce(Player player, MineStrike game) public void shootOnce(Player player, GunModule game)
{ {
if (_reloading) if (_reloading)
return; return;
@ -167,7 +172,7 @@ public class Gun extends StrikeItem
reload(player); reload(player);
} }
public Bullet fireBullet(Player player, MineStrike game) public Bullet fireBullet(Player player, GunModule game)
{ {
//Instant? //Instant?
boolean instant = game.getBulletType() == 1 || (game.getBulletType() == 2 && _gunStats.getGunType() == GunType.SNIPER); boolean instant = game.getBulletType() == 1 || (game.getBulletType() == 2 && _gunStats.getGunType() == GunType.SNIPER);
@ -186,7 +191,7 @@ public class Gun extends StrikeItem
Vector cof = new Vector(Math.random() - 0.5, (Math.random() - 0.2) * (5d/8d), Math.random() - 0.5); Vector cof = new Vector(Math.random() - 0.5, (Math.random() - 0.2) * (5d/8d), Math.random() - 0.5);
cof.normalize(); cof.normalize();
cof.multiply(cone); cof.multiply(cone);
cof.multiply(MineStrike.CONE); cof.multiply(GunModule.CONE);
cof.add(player.getLocation().getDirection()); cof.add(player.getLocation().getDirection());
cof.normalize(); cof.normalize();
@ -307,12 +312,12 @@ public class Gun extends StrikeItem
public void displayAmmo(Player player) public void displayAmmo(Player player)
{ {
if (!UtilGear.isMat(player.getItemInHand(), getStack().getType())) if (_module.getGunInHand(player, null) != this)
return; return;
//Weapon Bob during reload //Weapon Bob during reload
if (_reloading) if (_reloading)
updateWeaponName(player, null); updateWeaponName(player, null, false);
if (!Recharge.Instance.usable(player, getName() + " Reload")) if (!Recharge.Instance.usable(player, getName() + " Reload"))
return; return;
@ -323,7 +328,7 @@ public class Gun extends StrikeItem
UtilTextBottom.display(C.cRed + "No Ammo", player); UtilTextBottom.display(C.cRed + "No Ammo", player);
} }
public void updateWeaponName(Player player, MineStrike game) public void updateWeaponName(Player player, GunModule game, boolean setItem)
{ {
if(game != null) if(game != null)
{ {
@ -331,24 +336,24 @@ public class Gun extends StrikeItem
{ {
new BukkitRunnable() { new BukkitRunnable() {
public void run() { public void run() {
PlayerStats remoteStats = game.getArcadeManager().GetStatsManager().Get(player);; PlayerStats remoteStats = game.getHost().getArcadeManager().GetStatsManager().Get(player);;
_kills = (int) remoteStats.getStat(game.GetName() + "." + getStatNameKills(true)); _kills = (int) remoteStats.getStat(game.getHost().GetName() + "." + getStatNameKills(true));
Player owner = UtilPlayer.searchExact(getOwnerName()); Player owner = UtilPlayer.searchExact(getOwnerName());
if(owner != null) { if(owner != null) {
HashMap<String, Integer> localStatsMap = game.GetStats().get(owner); HashMap<String, Integer> localStatsMap = game.getHost().GetStats().get(owner);
if(localStatsMap != null) if(localStatsMap != null)
{ {
Integer kills = localStatsMap.get(game.GetName() + "." + getStatNameKills(true)); Integer kills = localStatsMap.get(game.getHost().GetName() + "." + getStatNameKills(true));
if(kills != null) if(kills != null)
{ {
_kills += kills.intValue(); _kills += kills.intValue();
} }
} }
} }
updateWeaponName(player, null); updateWeaponName(player, null, setItem);
} }
}.runTaskAsynchronously(game.getArcadeManager().getPlugin()); }.runTaskAsynchronously(game.getHost().getArcadeManager().getPlugin());
} }
} }
int kls = _kills; int kls = _kills;
@ -368,11 +373,18 @@ public class Gun extends StrikeItem
if (player != null) if (player != null)
{ {
player.getInventory().setItem(_slot, getStack()); if (setItem)
player.getInventory().setItem(_slot, getStack());
_reloadTick = !_reloadTick; _reloadTick = !_reloadTick;
} }
} }
public void updateWeaponName(Player player, GunModule module)
{
updateWeaponName(player, module, true);
}
public void incrementKill() { public void incrementKill() {
_kills++; _kills++;
} }
@ -399,7 +411,7 @@ public class Gun extends StrikeItem
loc.getWorld().playSound(loc, Sound.PISTON_RETRACT, 1f, 0.8f); loc.getWorld().playSound(loc, Sound.PISTON_RETRACT, 1f, 0.8f);
} }
public void cancelReloadCheck(Player player, MineStrike game) public void cancelReloadCheck(Player player, GunModule game)
{ {
if (!_reloading) if (!_reloading)
return; return;
@ -457,6 +469,19 @@ public class Gun extends StrikeItem
owner.getInventory().setItem(_slot, getStack()); owner.getInventory().setItem(_slot, getStack());
} }
public void enableSkin()
{
MineStrikeSkin skin = null;
for (MineStrikeSkin otherSkin : MineStrikeSkin.values())
{
if (otherSkin.getWeaponName().equalsIgnoreCase(_gunStats.getName()))
skin = otherSkin;
}
setSkin(skin.getSkinMaterial(), skin.getSkinData());
_activeSkinName = skin.getSkinName();
}
public int getSlot() public int getSlot()
{ {
@ -492,7 +517,7 @@ public class Gun extends StrikeItem
} }
@Override @Override
public boolean pickup(MineStrike game, Player player) public boolean pickup(GunModule game, Player player)
{ {
if (player.getInventory().getItem(_slot) != null && player.getInventory().getItem(_slot).getType() != Material.AIR) if (player.getInventory().getItem(_slot) != null && player.getInventory().getItem(_slot).getType() != Material.AIR)
return false; return false;

View File

@ -1,12 +1,14 @@
package nautilus.game.arcade.game.games.minestrike.items.guns; package nautilus.game.arcade.game.games.minestrike.items.guns;
import nautilus.game.arcade.game.games.minestrike.GunModule;
public class GunFactory public class GunFactory
{ {
public Gun createGun(GunStats gun) public Gun createGun(GunStats gun, GunModule module)
{ {
if (gun.getGunType() == GunType.SHOTGUN) if (gun.getGunType() == GunType.SHOTGUN)
return new Shotgun(gun); return new Shotgun(gun, module);
return new Gun(gun); return new Gun(gun, module);
} }
} }

View File

@ -1,6 +1,6 @@
package nautilus.game.arcade.game.games.minestrike.items.guns; package nautilus.game.arcade.game.games.minestrike.items.guns;
import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.minestrike.GunModule;
import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType;
import org.bukkit.Material; import org.bukkit.Material;
@ -375,7 +375,7 @@ public enum GunStats
public double getConeIncreaseRate() public double getConeIncreaseRate()
{ {
return _coneIncreaseRate * MineStrike.RECOIL; return _coneIncreaseRate * GunModule.RECOIL;
} }
public boolean getScope() public boolean getScope()

View File

@ -1,6 +1,6 @@
package nautilus.game.arcade.game.games.minestrike.items.guns; package nautilus.game.arcade.game.games.minestrike.items.guns;
import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.minestrike.GunModule;
public enum GunType public enum GunType
{ {
@ -40,17 +40,17 @@ public enum GunType
public double getMovePenalty() public double getMovePenalty()
{ {
return _movePenalty * MineStrike.MOVE_PENALTY; return _movePenalty * GunModule.MOVE_PENALTY;
} }
public double getSprintPenalty() public double getSprintPenalty()
{ {
return _sprintPentalty * MineStrike.MOVE_PENALTY; return _sprintPentalty * GunModule.MOVE_PENALTY;
} }
public double getJumpPenalty() public double getJumpPenalty()
{ {
return _jumpPenalty * MineStrike.MOVE_PENALTY; return _jumpPenalty * GunModule.MOVE_PENALTY;
} }
public float getVolume() public float getVolume()

View File

@ -5,7 +5,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.minestrike.GunModule;
import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType;
import org.bukkit.Location; import org.bukkit.Location;
@ -18,15 +18,15 @@ public class Shotgun extends Gun
{ {
private int _pellets; private int _pellets;
public Shotgun(GunStats gunStats) public Shotgun(GunStats gunStats, GunModule module)
{ {
super(gunStats); super(gunStats, module);
_pellets = gunStats.getPellets(); _pellets = gunStats.getPellets();
} }
@Override @Override
public void shoot(Player player, MineStrike game) public void shoot(Player player, GunModule game)
{ {
if (_reloading) if (_reloading)
return; return;

View File

@ -0,0 +1,444 @@
package nautilus.game.arcade.game.games.survivalgames.modes;
import java.util.Arrays;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Chest;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilMath;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType;
import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.GameModifierMineStrikeSkin;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.loot.RandomItem;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.PlayerKitGiveEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.minestrike.GunModule;
import nautilus.game.arcade.game.games.minestrike.items.grenades.FlashBang;
import nautilus.game.arcade.game.games.minestrike.items.grenades.Grenade;
import nautilus.game.arcade.game.games.minestrike.items.grenades.HighExplosive;
import nautilus.game.arcade.game.games.minestrike.items.grenades.Incendiary;
import nautilus.game.arcade.game.games.minestrike.items.grenades.Molotov;
import nautilus.game.arcade.game.games.minestrike.items.grenades.Smoke;
import nautilus.game.arcade.game.games.minestrike.items.guns.Gun;
import nautilus.game.arcade.game.games.minestrike.items.guns.GunStats;
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.KitPlayer;
import nautilus.game.arcade.kit.Kit;
/**
* StrikeGames
*
* @author xXVevzZXx
*/
public class StrikeGames extends SoloSurvivalGames
{
private GunModule _gunModule;
public StrikeGames(ArcadeManager manager)
{
super(manager, new Kit[]
{ new KitPlayer(manager) }, GameType.Brawl);
_gunModule = new GunModule(this);
_gunModule.setEnablePickup(false);
_gunModule.setEnableDrop(false);
_gunModule.setEnableCleaning(false);
}
public void setupLoot()
{
// Food
getBaseLoot().addLoot(new RandomItem(Material.BAKED_POTATO, 30, 1, 3));
getBaseLoot().addLoot(new RandomItem(Material.COOKED_BEEF, 30, 1, 2));
getBaseLoot().addLoot(new RandomItem(Material.COOKED_CHICKEN, 30, 1, 2));
getBaseLoot().addLoot(new RandomItem(Material.MUSHROOM_SOUP, 15, 1, 1));
getBaseLoot().addLoot(new RandomItem(Material.WHEAT, 30, 1, 6));
getBaseLoot().addLoot(new RandomItem(Material.ROTTEN_FLESH, 40, 1, 6));
// Weapons
getBaseLoot().addLoot(new RandomItem(Material.WOOD_SWORD, 70));
getBaseLoot().addLoot(new RandomItem(Material.STONE_SWORD, 30));
// Leather armor
getBaseLoot().addLoot(new RandomItem(Material.LEATHER_BOOTS, 30));
getBaseLoot().addLoot(new RandomItem(Material.LEATHER_LEGGINGS, 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));
// Grenades
getBaseLoot().addLoot(new RandomItem(Material.CARROT_ITEM, 15));
getBaseLoot().addLoot(new RandomItem(Material.APPLE, 15));
getBaseLoot().addLoot(new RandomItem(Material.PORK, 15));
getBaseLoot().addLoot(new RandomItem(Material.GRILLED_PORK, 15));
getBaseLoot().addLoot(new RandomItem(Material.POTATO_ITEM, 15));
// 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, 20, 1, 3));
getBaseLoot().addLoot(new RandomItem(Material.EGG, 30, 1, 2));
// Misc
getBaseLoot().addLoot(new RandomItem(Material.EXP_BOTTLE, 30, 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.FLINT, 30, 1, 2));
getBaseLoot().addLoot(new RandomItem(Material.FEATHER, 30, 1, 2));
getBaseLoot().addLoot(new RandomItem(Material.GOLD_INGOT, 20));
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.COOKIE, 30));
getSpawnLoot().addLoot(new RandomItem(Material.PUMPKIN_PIE, 30, 1, 3));
// Loot for chests in spawn
// Weaponry and ores
getSpawnLoot().addLoot(new RandomItem(Material.STONE_SWORD, 30));
getSpawnLoot().addLoot(new RandomItem(Material.IRON_INGOT, 30, 1, 2));
// 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.GOLD_SPADE, 12));
// 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.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));
// 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.WOOD_SWORD, 3));
getDeathMatch().addLoot(new RandomItem(Material.STONE_SWORD, 1));
}
@Override
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 = 5;
if (Math.random() > 0.50)
items++;
if (Math.random() > 0.60)
items++;
if (Math.random() > 0.70)
items++;
if (Math.random() > 0.80)
items++;
if (Math.random() > 0.90)
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
{
item = GetChestItem(getSupplyBlocks().contains(block));
}
if (item.getType() == Material.COMPASS)
{
item = buildCompass(5);
}
if (UtilItem.isWeapon(item))
{
GunStats gunStat = GunStats.values()[UtilMath.r(GunStats.values().length)];
int e = 0;
while (gunStat == GunStats.AWP && e < 20)
{
gunStat = GunStats.values()[UtilMath.r(GunStats.values().length)];
e++;
}
item = ItemStackFactory.Instance.CreateStack(gunStat.getSkin(), (byte) 0, 1, gunStat.getName());
}
String name = null;
if (item.getType() == Material.APPLE)
{
name = "High Explosive";
}
else if (item.getType() == Material.CARROT_ITEM)
{
name = "Flash Bang";
}
else if (item.getType() == Material.POTATO_ITEM)
{
name = "Smoke";
}
else if (item.getType() == Material.PORK)
{
name = "Incendiary";
}
else if (item.getType() == Material.GRILLED_PORK)
{
name = "Molotov";
}
if (name != null)
{
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(name);
item.setItemMeta(meta);
}
chest.getBlockInventory().setItem(UtilMath.r(27), item);
}
if (getSupplyBlocks().contains(block))
{
Bukkit.getPluginManager().callEvent(new SupplyChestOpenEvent(looter, block));
}
getSupplyBlocks().remove(block);
}
@EventHandler
public void addEquipment(InventoryClickEvent event)
{
if (event.getCurrentItem() == null)
return;
if (!(event.getWhoClicked() instanceof Player))
return;
Player player = (Player) event.getWhoClicked();
if (!(event.getClickedInventory() instanceof PlayerInventory))
{
ItemStack stack = event.getCurrentItem();
for (GunStats stat : GunStats.values())
{
if (stat.getSkin() == stack.getType())
{
Gun gun = new Gun(stat, _gunModule);
ItemMeta meta = stack.getItemMeta();
meta.setLore(Arrays.asList(ChatColor.RED + "" + ChatColor.BOLD + "Identifier: " + UtilMath.r(1000) + 1));
stack.setItemMeta(meta);
gun.setStack(stack);
gun.updateWeaponName(player, null, false);
_gunModule.registerGun(gun, player);
return;
}
}
Grenade grenade = null;
if (stack.getType() == Material.APPLE)
{
grenade = new HighExplosive();
}
else if (stack.getType() == Material.CARROT_ITEM)
{
grenade = new FlashBang();
}
else if (stack.getType() == Material.POTATO_ITEM)
{
grenade = new Smoke();
}
else if (stack.getType() == Material.PORK)
{
grenade = new Incendiary();
}
else if (stack.getType() == Material.GRILLED_PORK)
{
grenade = new Molotov();
}
if (grenade != null)
{
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(grenade.getName());
stack.setItemMeta(meta);
grenade.setStack(stack);
_gunModule.registerGrenade(grenade, player);
}
}
}
@EventHandler
public void triggerPickup(PlayerPickupItemEvent event)
{
if (!InProgress())
return;
if (!IsAlive(event.getPlayer()))
return;
//Guns
Gun gun = _gunModule.getDroppedGuns().get(event.getItem());
if (gun != null)
{
_gunModule.deregisterDroppedGun(gun);
_gunModule.registerGun(gun, event.getPlayer());
gun.setStack(event.getItem().getItemStack());
}
//Grenades
Grenade grenade = _gunModule.getDroppedGrenades().get(event.getItem());
if (grenade != null)
{
_gunModule.deregisterDroppedGrenade(grenade);
_gunModule.registerGrenade(grenade, event.getPlayer());
grenade.setStack(event.getItem().getItemStack());
}
}
@EventHandler
public void triggerDrop(PlayerDropItemEvent event)
{
if (!InProgress())
return;
//Guns
Gun gun = _gunModule.getGunInHand(event.getPlayer(), event.getItemDrop().getItemStack());
if (gun != null)
{
gun.drop(_gunModule, event.getPlayer(), false, false);
event.getItemDrop().remove();
event.getPlayer().setItemInHand(null);
return;
}
//Grenades
Grenade grenade = _gunModule.getGrenadeInHand(event.getPlayer(), event.getItemDrop().getItemStack());
if (grenade != null)
{
grenade.drop(_gunModule, event.getPlayer(), false, false);
event.getItemDrop().remove();
event.getPlayer().setItemInHand(null);
return;
}
}@EventHandler
public void giveStartEquipment(PlayerKitGiveEvent event)
{
GameTeam team = GetTeam(event.getPlayer());
if (team == null)
return;
Material mat = Material.IRON_SWORD;
byte data = 0;
String name = "Knife";
ItemStack knife = ItemStackFactory.Instance.CreateStack(mat, data, 1, name);
event.getPlayer().getInventory().setItem(0, knife);
}
@Override
public String GetMode()
{
return "Strike Games";
}
}

View File

@ -0,0 +1,46 @@
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 mineplex.core.common.util.C;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
public class KitPlayer extends Kit
{
public KitPlayer(ArcadeManager manager)
{
super(manager, "Player", KitAvailability.Free,
new String[]
{
C.cGreen + "Right-Click" + C.cWhite + " - " + C.cYellow + "Fire Gun",
C.cGreen + "Left-Click" + C.cWhite + " - " + C.cYellow + "Reload Gun",
C.cGreen + "Crouch" + C.cWhite + " - " + C.cYellow + "Sniper Scope",
},
new Perk[]
{
},
EntityType.PLAYER,
new ItemStack(Material.AIR));
}
@Override
public void GiveItems(Player player)
{
}
@Override
public void SpawnCustom(LivingEntity ent)
{
}
}

View File

@ -1263,7 +1263,7 @@ public class GameFlagManager implements Listener
if (Manager.GetGame() == null) if (Manager.GetGame() == null)
return; return;
if (Manager.GetGame().GetType().getResourcePackUrls() == null || Manager.GetGame().GetType().getResourcePackUrls().length == 0) if (Manager.GetGame().GetType().getResourcePackUrls(Manager.GetGame()) == null || Manager.GetGame().GetType().getResourcePackUrls(Manager.GetGame()).length == 0)
return; return;
UtilTextMiddle.display(C.cGold + C.Bold + Manager.GetGame().GetType().GetName(), "Make sure you accept the Resource Pack", 20, 120, 20, event.getPlayer()); UtilTextMiddle.display(C.cGold + C.Bold + Manager.GetGame().GetType().GetName(), "Make sure you accept the Resource Pack", 20, 120, 20, event.getPlayer());

View File

@ -4,7 +4,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.minestrike.PlayerHeadshotEvent;
public class HeadShotStatTracker extends StatTracker<Game> public class HeadShotStatTracker extends StatTracker<Game>
{ {
@ -23,7 +23,7 @@ public class HeadShotStatTracker extends StatTracker<Game>
} }
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerHeadshot(MineStrike.PlayerHeadshotEvent event) public void onPlayerHeadshot(PlayerHeadshotEvent event)
{ {
addStat(event.getShooter(), "Headshot", 1, false, false); addStat(event.getShooter(), "Headshot", 1, false, false);
} }

View File

@ -4,13 +4,13 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.minestrike.Minestrike;
import nautilus.game.arcade.game.games.minestrike.items.grenades.Grenade; import nautilus.game.arcade.game.games.minestrike.items.grenades.Grenade;
import nautilus.game.arcade.game.games.minestrike.items.grenades.HighExplosive; import nautilus.game.arcade.game.games.minestrike.items.grenades.HighExplosive;
public class KaboomStatTracker extends StatTracker<MineStrike> public class KaboomStatTracker extends StatTracker<Minestrike>
{ {
public KaboomStatTracker(MineStrike game) public KaboomStatTracker(Minestrike game)
{ {
super(game); super(game);
} }

View File

@ -14,14 +14,14 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.minestrike.GunModule;
import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.minestrike.Minestrike;
public class KillAllOpposingMineStrikeRoundStatTracker extends StatTracker<MineStrike> public class KillAllOpposingMineStrikeRoundStatTracker extends StatTracker<Minestrike>
{ {
private final Map<UUID, Set<UUID>> _kills = new HashMap<>(); private final Map<UUID, Set<UUID>> _kills = new HashMap<>();
public KillAllOpposingMineStrikeRoundStatTracker(MineStrike game) public KillAllOpposingMineStrikeRoundStatTracker(Minestrike game)
{ {
super(game); super(game);
} }
@ -63,7 +63,7 @@ public class KillAllOpposingMineStrikeRoundStatTracker extends StatTracker<MineS
} }
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onRoundOver(MineStrike.RoundOverEvent event) public void onRoundOver(GunModule.RoundOverEvent event)
{ {
for (GameTeam team : getGame().GetTeamList()) for (GameTeam team : getGame().GetTeamList())
{ {

View File

@ -5,7 +5,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.games.minestrike.MineStrike.CustomGunDamageEvent; import nautilus.game.arcade.game.games.minestrike.CustomGunDamageEvent;
public class MineStrikeGunStats extends StatTracker<Game> public class MineStrikeGunStats extends StatTracker<Game>
{ {

View File

@ -13,13 +13,14 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.minestrike.GunModule;
import nautilus.game.arcade.game.games.minestrike.Minestrike;
public class MineStrikeLastAliveKillStatTracker extends StatTracker<MineStrike> public class MineStrikeLastAliveKillStatTracker extends StatTracker<Minestrike>
{ {
private final Map<UUID, Integer> _killCount = new HashMap<>(); private final Map<UUID, Integer> _killCount = new HashMap<>();
public MineStrikeLastAliveKillStatTracker(MineStrike game) public MineStrikeLastAliveKillStatTracker(Minestrike game)
{ {
super(game); super(game);
} }
@ -45,7 +46,7 @@ public class MineStrikeLastAliveKillStatTracker extends StatTracker<MineStrike>
} }
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onRoundOver(MineStrike.RoundOverEvent event) public void onRoundOver(GunModule.RoundOverEvent event)
{ {
for (GameTeam team : getGame().GetTeamList()) for (GameTeam team : getGame().GetTeamList())
{ {