Survival Games Update
This commit is contained in:
parent
e8e9eb3052
commit
0b61b6600a
@ -780,7 +780,7 @@ public class ItemMapManager extends MiniPlugin
|
|||||||
|
|
||||||
if (_scanList.size() % 20 == 0)
|
if (_scanList.size() % 20 == 0)
|
||||||
{
|
{
|
||||||
Collections.sort(_scanList, _comparator);
|
_scanList.sort(_comparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_scanList.isEmpty())
|
if (_scanList.isEmpty())
|
||||||
|
@ -1,58 +0,0 @@
|
|||||||
|
|
||||||
package mineplex.hub.server.ui;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.donation.DonationManager;
|
|
||||||
import mineplex.core.itemstack.ItemBuilder;
|
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
|
||||||
import mineplex.hub.server.ServerManager;
|
|
||||||
import mineplex.serverdata.data.ServerGroup;
|
|
||||||
|
|
||||||
public class MinestrikeServerTypePage extends ShopPageBase<ServerManager, ServerNpcShop>
|
|
||||||
{
|
|
||||||
|
|
||||||
private ServerGroup _serverGroup;
|
|
||||||
|
|
||||||
public MinestrikeServerTypePage(ServerManager plugin, ServerNpcShop shop, CoreClientManager clientManager,
|
|
||||||
DonationManager donationManager, Player player, ServerGroup serverGroup)
|
|
||||||
{
|
|
||||||
super(plugin, shop, clientManager, donationManager, serverGroup.getServerNpcName(), player, 27);
|
|
||||||
|
|
||||||
_serverGroup = serverGroup;
|
|
||||||
|
|
||||||
buildPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void buildPage()
|
|
||||||
{
|
|
||||||
setItem(12, new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setTitle(C.Reset + C.cYellow + "MineStrike Classic")
|
|
||||||
.addLore(new String[]
|
|
||||||
{
|
|
||||||
C.Reset + "",
|
|
||||||
C.Reset + C.cGreen + "Click to Play",
|
|
||||||
}).build());
|
|
||||||
|
|
||||||
setItem(14, new ItemBuilder(Material.SKULL_ITEM, 2, (byte) 3).setTitle(C.Reset + C.cYellow + "StrikeGames")
|
|
||||||
.addLore(new String[]
|
|
||||||
{
|
|
||||||
C.Reset + "",
|
|
||||||
C.Reset + C.cGray + "Survival Games with MineStrike weapons",
|
|
||||||
C.Reset + "",
|
|
||||||
C.Reset + C.cGreen + "Click to Play"
|
|
||||||
}).build());
|
|
||||||
|
|
||||||
getButtonMap().put(12, (player, __) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "MineStrike Classic", player, "MS")));
|
|
||||||
getButtonMap().put(14, (player, __) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "StrikeGames", player, "MS2")));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update()
|
|
||||||
{
|
|
||||||
getButtonMap().clear();
|
|
||||||
buildPage();
|
|
||||||
}
|
|
||||||
}
|
|
@ -29,9 +29,6 @@ public class ServerNpcShop extends ShopBase<ServerManager>
|
|||||||
case "HG":
|
case "HG":
|
||||||
return new ServerTypePage(getPlugin(), this, getClientManager(), getDonationManager(), player, _serverGroup);
|
return new ServerTypePage(getPlugin(), this, getClientManager(), getDonationManager(), player, _serverGroup);
|
||||||
|
|
||||||
case "MS":
|
|
||||||
return new MinestrikeServerTypePage(getPlugin(), this, getClientManager(), getDonationManager(), player, _serverGroup);
|
|
||||||
|
|
||||||
case "UHC":
|
case "UHC":
|
||||||
return new UHCServerTypePage(getPlugin(), this, getClientManager(), getDonationManager(), player);
|
return new UHCServerTypePage(getPlugin(), this, getClientManager(), getDonationManager(), player);
|
||||||
|
|
||||||
|
@ -106,12 +106,8 @@ import nautilus.game.arcade.game.games.spleef.SpleefTeams;
|
|||||||
import nautilus.game.arcade.game.games.spleef.modes.UltraSpleef;
|
import nautilus.game.arcade.game.games.spleef.modes.UltraSpleef;
|
||||||
import nautilus.game.arcade.game.games.squidshooter.SquidShooter;
|
import nautilus.game.arcade.game.games.squidshooter.SquidShooter;
|
||||||
import nautilus.game.arcade.game.games.stacker.Stacker;
|
import nautilus.game.arcade.game.games.stacker.Stacker;
|
||||||
import nautilus.game.arcade.game.games.survivalgames.SoloSurvivalGames;
|
import nautilus.game.arcade.game.games.survivalgames.SurvivalGamesNewSolo;
|
||||||
import nautilus.game.arcade.game.games.survivalgames.TeamSurvivalGames;
|
import nautilus.game.arcade.game.games.survivalgames.SurvivalGamesNewTeams;
|
||||||
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.StrikeGames;
|
|
||||||
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;
|
||||||
import nautilus.game.arcade.game.games.typewars.TypeWars;
|
import nautilus.game.arcade.game.games.typewars.TypeWars;
|
||||||
@ -204,8 +200,8 @@ public enum GameType
|
|||||||
SpleefTeams(SpleefTeams.class, GameDisplay.SpleefTeams),
|
SpleefTeams(SpleefTeams.class, GameDisplay.SpleefTeams),
|
||||||
SquidShooter(SquidShooter.class, GameDisplay.SquidShooter),
|
SquidShooter(SquidShooter.class, GameDisplay.SquidShooter),
|
||||||
Stacker(Stacker.class, GameDisplay.Stacker),
|
Stacker(Stacker.class, GameDisplay.Stacker),
|
||||||
SurvivalGames(SoloSurvivalGames.class, GameDisplay.SurvivalGames),
|
SurvivalGames(SurvivalGamesNewSolo.class, GameDisplay.SurvivalGames),
|
||||||
SurvivalGamesTeams(TeamSurvivalGames.class, GameDisplay.SurvivalGamesTeams, new GameType[]{GameType.SurvivalGames}, false),
|
SurvivalGamesTeams(SurvivalGamesNewTeams.class, GameDisplay.SurvivalGamesTeams, new GameType[]{GameType.SurvivalGames}, false),
|
||||||
Tug(Tug.class, GameDisplay.Tug),
|
Tug(Tug.class, GameDisplay.Tug),
|
||||||
TurfWars(TurfForts.class, GameDisplay.TurfWars),
|
TurfWars(TurfForts.class, GameDisplay.TurfWars),
|
||||||
UHC(UHCTeams.class, GameDisplay.UHC),
|
UHC(UHCTeams.class, GameDisplay.UHC),
|
||||||
@ -228,11 +224,6 @@ public enum GameType
|
|||||||
Gladiators(Gladiators.class, GameDisplay.Gladiators),
|
Gladiators(Gladiators.class, GameDisplay.Gladiators),
|
||||||
Skyfall(SoloSkyfall.class, GameDisplay.Skyfall),
|
Skyfall(SoloSkyfall.class, GameDisplay.Skyfall),
|
||||||
SkyfallTeams(TeamSkyfall.class, GameDisplay.SkyfallTeams, new GameType[]{GameType.Skyfall}, false),
|
SkyfallTeams(TeamSkyfall.class, GameDisplay.SkyfallTeams, new GameType[]{GameType.Skyfall}, false),
|
||||||
StrikeGames(StrikeGames.class, new GameMode[]{}, GameDisplay.StrikeGames, new Pair[]
|
|
||||||
{
|
|
||||||
Pair.create(MinecraftVersion.Version1_8, "http://file.mineplex.com/ResStrikeGames18.zip"),
|
|
||||||
Pair.create(MinecraftVersion.Version1_9, "http://file.mineplex.com/ResStrikeGames19.zip")
|
|
||||||
}, true, new GameType[]{GameType.SurvivalGames}, false, false),
|
|
||||||
|
|
||||||
BouncyBalls(BouncyBalls.class, GameDisplay.BouncyBalls),
|
BouncyBalls(BouncyBalls.class, GameDisplay.BouncyBalls),
|
||||||
|
|
||||||
@ -281,14 +272,6 @@ public enum GameType
|
|||||||
new GameMode(GodBattles.class, GameType.UHC, "God Battles"),
|
new GameMode(GodBattles.class, GameType.UHC, "God Battles"),
|
||||||
new GameMode(BloodDiamonds.class, GameType.UHC, "Blood Diamonds"),
|
new GameMode(BloodDiamonds.class, GameType.UHC, "Blood Diamonds"),
|
||||||
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(UHCSurvivalgames.class, GameType.SurvivalGames, "UHC Survivalgames"),
|
|
||||||
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/ResStrikeGames18.zip"),
|
|
||||||
// Pair.create(MinecraftVersion.Version1_9, "http://file.mineplex.com/ResStrikeGames19.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"),
|
||||||
|
@ -1,31 +1,24 @@
|
|||||||
package nautilus.game.arcade.events;
|
package nautilus.game.arcade.events;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
/**
|
public class ChestRefillEvent extends Event
|
||||||
* ChestRefillEvent
|
|
||||||
*
|
|
||||||
* @author xXVevzZXx
|
|
||||||
*/
|
|
||||||
public class ChestRefillEvent extends Event implements Cancellable
|
|
||||||
{
|
{
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private boolean _cancelled = false;
|
private final List<Location> _chests;
|
||||||
|
|
||||||
private ArrayList<Location> _chests;
|
public ChestRefillEvent(List<Location> chests)
|
||||||
|
|
||||||
public ChestRefillEvent(ArrayList<Location> chests)
|
|
||||||
{
|
{
|
||||||
_chests = (ArrayList<Location>) chests.clone();
|
_chests = new ArrayList<>(chests);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Location> getChests()
|
public List<Location> getChests()
|
||||||
{
|
{
|
||||||
return _chests;
|
return _chests;
|
||||||
}
|
}
|
||||||
@ -40,16 +33,4 @@ public class ChestRefillEvent extends Event implements Cancellable
|
|||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled()
|
|
||||||
{
|
|
||||||
return _cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean cancelled)
|
|
||||||
{
|
|
||||||
_cancelled = cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.event.world.WorldLoadEvent;
|
import org.bukkit.event.world.WorldLoadEvent;
|
||||||
import org.bukkit.scoreboard.NameTagVisibility;
|
import org.bukkit.scoreboard.NameTagVisibility;
|
||||||
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
import org.bukkit.scoreboard.Team;
|
import org.bukkit.scoreboard.Team;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
@ -68,7 +69,6 @@ import mineplex.core.common.util.UtilPlayer;
|
|||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.common.util.UtilTabTitle;
|
import mineplex.core.common.util.UtilTabTitle;
|
||||||
import mineplex.core.common.util.UtilTextMiddle;
|
import mineplex.core.common.util.UtilTextMiddle;
|
||||||
import mineplex.core.common.util.UtilTime;
|
|
||||||
import mineplex.core.disguise.disguises.DisguisePlayer;
|
import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||||
import mineplex.core.elo.EloPlayer;
|
import mineplex.core.elo.EloPlayer;
|
||||||
import mineplex.core.elo.EloTeam;
|
import mineplex.core.elo.EloTeam;
|
||||||
@ -95,9 +95,6 @@ import nautilus.game.arcade.events.PlayerGameRespawnEvent;
|
|||||||
import nautilus.game.arcade.events.PlayerPrepareTeleportEvent;
|
import nautilus.game.arcade.events.PlayerPrepareTeleportEvent;
|
||||||
import nautilus.game.arcade.events.PlayerStateChangeEvent;
|
import nautilus.game.arcade.events.PlayerStateChangeEvent;
|
||||||
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
||||||
import nautilus.game.arcade.game.games.build.Build;
|
|
||||||
import nautilus.game.arcade.game.games.draw.Draw;
|
|
||||||
import nautilus.game.arcade.game.games.speedbuilders.SpeedBuilders;
|
|
||||||
import nautilus.game.arcade.game.modules.AntiExpOrbModule;
|
import nautilus.game.arcade.game.modules.AntiExpOrbModule;
|
||||||
import nautilus.game.arcade.game.modules.Module;
|
import nautilus.game.arcade.game.modules.Module;
|
||||||
import nautilus.game.arcade.game.modules.gamesummary.GameSummaryModule;
|
import nautilus.game.arcade.game.modules.gamesummary.GameSummaryModule;
|
||||||
@ -2109,17 +2106,19 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
|||||||
}
|
}
|
||||||
|
|
||||||
Location loc = player.getLocation();
|
Location loc = player.getLocation();
|
||||||
|
String name = "Body #" + ++_deadBodyCount;
|
||||||
|
|
||||||
String name = "Body #" + _deadBodyCount++;
|
if (UseCustomScoreboard)
|
||||||
|
|
||||||
Team team = Scoreboard.getScoreboard().getTeam(ChatColor.COLOR_CHAR + "DeadBodies");
|
|
||||||
|
|
||||||
if (team == null)
|
|
||||||
{
|
{
|
||||||
team = Scoreboard.getScoreboard().registerNewTeam(ChatColor.COLOR_CHAR + "DeadBodies");
|
for (Player other : UtilServer.getPlayersCollection())
|
||||||
team.setNameTagVisibility(NameTagVisibility.NEVER);
|
{
|
||||||
|
setupDeadBodyScoreboard(other.getScoreboard(), name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setupDeadBodyScoreboard(Scoreboard.getScoreboard(), name);
|
||||||
}
|
}
|
||||||
team.addEntry(name);
|
|
||||||
|
|
||||||
EntityItem entityItem = new EntityItem(
|
EntityItem entityItem = new EntityItem(
|
||||||
((CraftWorld) loc.getWorld()).getHandle(),
|
((CraftWorld) loc.getWorld()).getHandle(),
|
||||||
@ -2152,6 +2151,19 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
|||||||
getArcadeManager().GetDisguise().disguise(disguise);
|
getArcadeManager().GetDisguise().disguise(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupDeadBodyScoreboard(Scoreboard scoreboard, String name)
|
||||||
|
{
|
||||||
|
Team team = scoreboard.getTeam(ChatColor.COLOR_CHAR + "DeadBodies");
|
||||||
|
|
||||||
|
if (team == null)
|
||||||
|
{
|
||||||
|
team = scoreboard.registerNewTeam(ChatColor.COLOR_CHAR + "DeadBodies");
|
||||||
|
team.setNameTagVisibility(NameTagVisibility.NEVER);
|
||||||
|
}
|
||||||
|
|
||||||
|
team.addEntry(name);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onDeadBodyItemSpawn(ItemSpawnEvent event)
|
public void onDeadBodyItemSpawn(ItemSpawnEvent event)
|
||||||
{
|
{
|
||||||
|
@ -31,12 +31,12 @@ public class KitDemolitionist extends KitPlayer
|
|||||||
},
|
},
|
||||||
new Perk[][]
|
new Perk[][]
|
||||||
{
|
{
|
||||||
new Perk[] {new PerkBomberHG(10, 2, true)},
|
new Perk[] {new PerkBomberHG(10, 2)},
|
||||||
new Perk[] {new PerkBomberHG(10, 4, true)},
|
new Perk[] {new PerkBomberHG(10, 4)},
|
||||||
new Perk[] {new PerkBomberHG(10, 6, true)},
|
new Perk[] {new PerkBomberHG(10, 6)},
|
||||||
new Perk[] {new PerkBomberHG(10, 4, true)},
|
new Perk[] {new PerkBomberHG(10, 4)},
|
||||||
new Perk[] {new PerkBomberHG(10, 4, true)},
|
new Perk[] {new PerkBomberHG(10, 4)},
|
||||||
new Perk[] {new PerkBomberHG(10, 6, true)}
|
new Perk[] {new PerkBomberHG(10, 6)}
|
||||||
},
|
},
|
||||||
new String[][]
|
new String[][]
|
||||||
{
|
{
|
||||||
|
@ -58,7 +58,6 @@ import mineplex.core.gadget.gadgets.morph.MorphBlock;
|
|||||||
import mineplex.core.gadget.types.Gadget;
|
import mineplex.core.gadget.types.Gadget;
|
||||||
import mineplex.core.gadget.types.GadgetType;
|
import mineplex.core.gadget.types.GadgetType;
|
||||||
import mineplex.core.give.Give;
|
import mineplex.core.give.Give;
|
||||||
import mineplex.core.gadget.gadgets.mount.Mount;
|
|
||||||
import mineplex.core.punish.PunishClient;
|
import mineplex.core.punish.PunishClient;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
@ -67,7 +66,6 @@ import nautilus.game.arcade.ArcadeManager;
|
|||||||
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
||||||
import nautilus.game.arcade.game.games.bridge.Bridge;
|
import nautilus.game.arcade.game.games.bridge.Bridge;
|
||||||
import nautilus.game.arcade.game.games.smash.SuperSmash;
|
import nautilus.game.arcade.game.games.smash.SuperSmash;
|
||||||
import nautilus.game.arcade.game.games.survivalgames.SurvivalGames;
|
|
||||||
import nautilus.game.arcade.kit.Kit;
|
import nautilus.game.arcade.kit.Kit;
|
||||||
|
|
||||||
public class EventModule extends MiniPlugin
|
public class EventModule extends MiniPlugin
|
||||||
@ -572,40 +570,6 @@ public class EventModule extends MiniPlugin
|
|||||||
((Bridge) Manager.GetGame()).setBridgeTime((int) ((System.currentTimeMillis() - Manager.GetGame().GetStateTime()) + seconds * 1000));
|
((Bridge) Manager.GetGame()).setBridgeTime((int) ((System.currentTimeMillis() - Manager.GetGame().GetStateTime()) + seconds * 1000));
|
||||||
UtilPlayer.message(event.getPlayer(), F.main("Event", "Bridges will drop in " + F.elem(seconds + " Seconds") + "!"));
|
UtilPlayer.message(event.getPlayer(), F.main("Event", "Bridges will drop in " + F.elem(seconds + " Seconds") + "!"));
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("dm"))
|
|
||||||
{
|
|
||||||
if (!(Manager.GetGame() instanceof SurvivalGames))
|
|
||||||
{
|
|
||||||
UtilPlayer.message(event.getPlayer(), F.main("Event", "You can only start the deathmatch in SG!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (((SurvivalGames) Manager.GetGame()).isDeathMatchTeleported())
|
|
||||||
{
|
|
||||||
UtilPlayer.message(event.getPlayer(), F.main("Event", "The Deathmatch has already began!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Manager.GetGame().Announce(C.cGreen + C.Bold + event.getPlayer().getName()
|
|
||||||
+ " has initiated Deathmatch!");
|
|
||||||
Manager.GetGame().Announce(C.cGreen + C.Bold + "Deathmatch starting in 60 seconds...");
|
|
||||||
|
|
||||||
((SurvivalGames) Manager.GetGame()).setDeathMatchTime(60);
|
|
||||||
|
|
||||||
for (Player player : UtilServer.getPlayers())
|
|
||||||
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1f,
|
|
||||||
1f);
|
|
||||||
}
|
|
||||||
else if (args[0].equalsIgnoreCase("supplydrop"))
|
|
||||||
{
|
|
||||||
if (!(Manager.GetGame() instanceof SurvivalGames))
|
|
||||||
{
|
|
||||||
UtilPlayer.message(event.getPlayer(), F.main("Event", "You can only start the Supply Srop in SG!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Manager.GetGame().WorldData.World.setTime(18000);
|
|
||||||
}
|
|
||||||
else if (args[0].equalsIgnoreCase("smash"))
|
else if (args[0].equalsIgnoreCase("smash"))
|
||||||
{
|
{
|
||||||
if (!(Manager.GetGame() instanceof SuperSmash))
|
if (!(Manager.GetGame() instanceof SuperSmash))
|
||||||
|
@ -87,11 +87,9 @@ import nautilus.game.arcade.game.games.skyfall.kits.KitStunner;
|
|||||||
import nautilus.game.arcade.game.games.skyfall.quests.RingQuestTracker;
|
import nautilus.game.arcade.game.games.skyfall.quests.RingQuestTracker;
|
||||||
import nautilus.game.arcade.game.games.skyfall.stats.AeronaughtStatTracker;
|
import nautilus.game.arcade.game.games.skyfall.stats.AeronaughtStatTracker;
|
||||||
import nautilus.game.arcade.game.games.skyfall.stats.RingStatTracker;
|
import nautilus.game.arcade.game.games.skyfall.stats.RingStatTracker;
|
||||||
import nautilus.game.arcade.game.games.survivalgames.SupplyChestOpenEvent;
|
|
||||||
import nautilus.game.arcade.game.modules.VersionModule;
|
import nautilus.game.arcade.game.modules.VersionModule;
|
||||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||||
import nautilus.game.arcade.kit.Kit;
|
import nautilus.game.arcade.kit.Kit;
|
||||||
import nautilus.game.arcade.stats.FirstSupplyDropOpenStatTracker;
|
|
||||||
import nautilus.game.arcade.stats.KillsWithinTimeLimitStatTracker;
|
import nautilus.game.arcade.stats.KillsWithinTimeLimitStatTracker;
|
||||||
import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker;
|
import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker;
|
||||||
|
|
||||||
@ -191,7 +189,6 @@ public abstract class Skyfall extends Game
|
|||||||
|
|
||||||
registerStatTrackers(new WinWithoutWearingArmorStatTracker(this),
|
registerStatTrackers(new WinWithoutWearingArmorStatTracker(this),
|
||||||
new KillsWithinTimeLimitStatTracker(this, 3, 60, "Bloodlust"),
|
new KillsWithinTimeLimitStatTracker(this, 3, 60, "Bloodlust"),
|
||||||
new FirstSupplyDropOpenStatTracker(this),
|
|
||||||
new RingStatTracker(this),
|
new RingStatTracker(this),
|
||||||
new AeronaughtStatTracker(this));
|
new AeronaughtStatTracker(this));
|
||||||
|
|
||||||
@ -331,9 +328,7 @@ public abstract class Skyfall extends Game
|
|||||||
_chestsRefilled = System.currentTimeMillis();
|
_chestsRefilled = System.currentTimeMillis();
|
||||||
_refillAnnounced = false;
|
_refillAnnounced = false;
|
||||||
|
|
||||||
ChestRefillEvent refillEvent = UtilServer.CallEvent(new ChestRefillEvent(_lowerIsland.getChests()));
|
UtilServer.CallEvent(new ChestRefillEvent(_lowerIsland.getChests()));
|
||||||
if (refillEvent.isCancelled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
_lowerIsland.refillChests();
|
_lowerIsland.refillChests();
|
||||||
|
|
||||||
@ -749,9 +744,9 @@ public abstract class Skyfall extends Game
|
|||||||
&& event.getClickedBlock().getLocation().getBlockY() == _supplyDrop.getBlockY()
|
&& event.getClickedBlock().getLocation().getBlockY() == _supplyDrop.getBlockY()
|
||||||
&& event.getClickedBlock().getLocation().getBlockZ() == _supplyDrop.getBlockZ())
|
&& event.getClickedBlock().getLocation().getBlockZ() == _supplyDrop.getBlockZ())
|
||||||
{
|
{
|
||||||
UtilServer.CallEvent(new SupplyChestOpenEvent(event.getPlayer(), event.getClickedBlock()));
|
|
||||||
if (!_supplyOpened)
|
if (!_supplyOpened)
|
||||||
{
|
{
|
||||||
|
AddStat(event.getPlayer(), "SupplyDropsOpened", 1, false, false);
|
||||||
AddGems(event.getPlayer(), 15, "Supply Drop", false, false);
|
AddGems(event.getPlayer(), 15, "Supply Drop", false, false);
|
||||||
_supplyOpened = true;
|
_supplyOpened = true;
|
||||||
}
|
}
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
package nautilus.game.arcade.game.games.survivalgames;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
|
|
||||||
public class BlockChange
|
|
||||||
{
|
|
||||||
public Location Location;
|
|
||||||
public int Id;
|
|
||||||
public byte Data;
|
|
||||||
|
|
||||||
public BlockChange(Location loc, int id, byte data)
|
|
||||||
{
|
|
||||||
Location = loc;
|
|
||||||
Id = id;
|
|
||||||
Data = data;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
package nautilus.game.arcade.game.games.survivalgames;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_8_R3.PlayerChunkMap;
|
|
||||||
|
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
|
|
||||||
public class ChunkChange
|
|
||||||
{
|
|
||||||
public Chunk Chunk;
|
|
||||||
public long Time;
|
|
||||||
public ArrayList<BlockChange> Changes;
|
|
||||||
public short[] DirtyBlocks = new short[64];
|
|
||||||
public short DirtyCount = 0;
|
|
||||||
|
|
||||||
public ChunkChange(Location loc, int id, byte data)
|
|
||||||
{
|
|
||||||
Chunk = loc.getChunk();
|
|
||||||
|
|
||||||
Changes = new ArrayList<BlockChange>();
|
|
||||||
|
|
||||||
AddChange(loc, id, data);
|
|
||||||
|
|
||||||
Time = System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddChange(Location loc, int id, byte data)
|
|
||||||
{
|
|
||||||
Changes.add(new BlockChange(loc, id, data));
|
|
||||||
|
|
||||||
if (DirtyCount < 63)
|
|
||||||
{
|
|
||||||
short short1 = (short)((loc.getBlockX() & 0xF) << 12 | (loc.getBlockZ() & 0xF) << 8 | loc.getBlockY());
|
|
||||||
|
|
||||||
for (int l = 0; l < DirtyCount; l++)
|
|
||||||
{
|
|
||||||
if (DirtyBlocks[l] == short1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DirtyBlocks[(DirtyCount++)] = short1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DirtyCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,222 +0,0 @@
|
|||||||
package nautilus.game.arcade.game.games.survivalgames;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.common.util.UtilTime;
|
|
||||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
|
||||||
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.GameTeam;
|
|
||||||
import nautilus.game.arcade.kit.Kit;
|
|
||||||
import nautilus.game.arcade.managers.chat.ChatStatData;
|
|
||||||
import nautilus.game.arcade.stats.FirstSupplyDropOpenStatTracker;
|
|
||||||
import nautilus.game.arcade.stats.KillsWithinTimeLimitStatTracker;
|
|
||||||
import nautilus.game.arcade.stats.SimultaneousSkeletonStatTracker;
|
|
||||||
import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker;
|
|
||||||
|
|
||||||
public class SoloSurvivalGames extends SurvivalGames
|
|
||||||
{
|
|
||||||
|
|
||||||
private GameTeam _players;
|
|
||||||
|
|
||||||
public SoloSurvivalGames(ArcadeManager manager)
|
|
||||||
{
|
|
||||||
this(manager, GameType.SurvivalGames);
|
|
||||||
|
|
||||||
registerStatTrackers(new WinWithoutWearingArmorStatTracker(this),
|
|
||||||
new KillsWithinTimeLimitStatTracker(this, 3, 60, "Bloodlust"),
|
|
||||||
new FirstSupplyDropOpenStatTracker(this),
|
|
||||||
new SimultaneousSkeletonStatTracker(this, 5));
|
|
||||||
|
|
||||||
registerChatStats(
|
|
||||||
Kills,
|
|
||||||
Assists,
|
|
||||||
BlankLine,
|
|
||||||
DamageTaken,
|
|
||||||
DamageDealt,
|
|
||||||
BlankLine,
|
|
||||||
new ChatStatData("SupplyDropsOpened", "Event chests opened", true)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SoloSurvivalGames(ArcadeManager manager, GameType type)
|
|
||||||
{
|
|
||||||
super(manager, type,
|
|
||||||
new String[]
|
|
||||||
{
|
|
||||||
"Search for chests to find loot",
|
|
||||||
|
|
||||||
"Slaughter your opponents",
|
|
||||||
|
|
||||||
"Stay away from the borders!",
|
|
||||||
|
|
||||||
"Last tribute alive wins!"
|
|
||||||
});
|
|
||||||
|
|
||||||
this.DamageTeamSelf = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SoloSurvivalGames(ArcadeManager manager, Kit[] kits, GameType type)
|
|
||||||
{
|
|
||||||
super(manager, kits, type,
|
|
||||||
new String[]
|
|
||||||
{
|
|
||||||
"Search for chests to find loot",
|
|
||||||
|
|
||||||
"Slaughter your opponents",
|
|
||||||
|
|
||||||
"Stay away from the borders!",
|
|
||||||
|
|
||||||
"Last tribute alive wins!"
|
|
||||||
});
|
|
||||||
|
|
||||||
this.DamageTeamSelf = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void CustomTeamGeneration(GameStateChangeEvent event)
|
|
||||||
{
|
|
||||||
if (event.GetState() != GameState.Recruit)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_players = GetTeamList().get(0);
|
|
||||||
_players.SetColor(ChatColor.YELLOW);
|
|
||||||
_players.SetName("Players");
|
|
||||||
_players.setDisplayName(C.cYellow + C.Bold + "Players");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@EventHandler
|
|
||||||
public void ScoreboardUpdate(UpdateEvent event)
|
|
||||||
{
|
|
||||||
if (event.getType() != UpdateType.FAST)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (GetTeamList().isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
Scoreboard.reset();
|
|
||||||
|
|
||||||
Scoreboard.writeNewLine();
|
|
||||||
|
|
||||||
GameTeam team = GetTeamList().get(0);
|
|
||||||
|
|
||||||
Scoreboard.write(C.cGreen + C.Bold + "Time");
|
|
||||||
Scoreboard.write(UtilTime.convertString(this.getSecondsSinceStart() * 1000, 0, TimeUnit.FIT));
|
|
||||||
|
|
||||||
Scoreboard.writeNewLine();
|
|
||||||
|
|
||||||
Scoreboard.write(C.cYellow + C.Bold + "Tributes");
|
|
||||||
if (team.GetPlayers(true).size() > 7)
|
|
||||||
{
|
|
||||||
Scoreboard.write("" + team.GetPlayers(true).size());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (Player player : team.GetPlayers(true))
|
|
||||||
{
|
|
||||||
Scoreboard.write(C.cWhite + player.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Scoreboard.writeNewLine();
|
|
||||||
|
|
||||||
if (this.getChestRefillTime() > 0 && this.getDeathMatchTime() > 60)
|
|
||||||
{
|
|
||||||
Scoreboard.write(C.cGold + C.Bold + "Chest Refill");
|
|
||||||
Scoreboard.write(UtilTime.convertString(this.getChestRefillTime() * 1000, 0, TimeUnit.FIT));
|
|
||||||
}
|
|
||||||
else if (this.getDeathMatchTime() > 0)
|
|
||||||
{
|
|
||||||
Scoreboard.write(C.cRed + C.Bold + "Deathmatch");
|
|
||||||
Scoreboard.write(UtilTime.convertString(
|
|
||||||
Math.min(this.getDeathMatchTime(), this.isDeathMatchTeleported() ? 10 : this.getDeathMatchTime()) * 1000, 0, TimeUnit.FIT));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Scoreboard.write(C.cRed + C.Bold + "Game End");
|
|
||||||
Scoreboard.write(UtilTime.convertString(Math.max(0, this.getGameEndTime()) * 1000, 0, TimeUnit.FIT));
|
|
||||||
}
|
|
||||||
|
|
||||||
Scoreboard.draw();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void EndCheck()
|
|
||||||
{
|
|
||||||
if (!IsLive())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (GetPlayers(true).size() <= 1)
|
|
||||||
{
|
|
||||||
ArrayList<Player> places = GetTeamList().get(0).GetPlacements(true);
|
|
||||||
|
|
||||||
//Announce
|
|
||||||
AnnounceEnd(places);
|
|
||||||
|
|
||||||
//Gems
|
|
||||||
if (places.size() >= 1)
|
|
||||||
AddGems(places.get(0), 20, "1st Place", false, false);
|
|
||||||
|
|
||||||
if (places.size() >= 2)
|
|
||||||
AddGems(places.get(1), 15, "2nd Place", false, false);
|
|
||||||
|
|
||||||
if (places.size() >= 3)
|
|
||||||
AddGems(places.get(2), 10, "3rd Place", false, false);
|
|
||||||
|
|
||||||
for (Player player : GetPlayers(false))
|
|
||||||
if (player.isOnline())
|
|
||||||
AddGems(player, 10, "Participation", false, false);
|
|
||||||
|
|
||||||
//End
|
|
||||||
SetState(GameState.End);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Player> getWinners()
|
|
||||||
{
|
|
||||||
if (GetState().ordinal() >= GameState.End.ordinal())
|
|
||||||
{
|
|
||||||
List<Player> places = GetTeamList().get(0).GetPlacements(true);
|
|
||||||
|
|
||||||
if (places.isEmpty() || !places.get(0).isOnline())
|
|
||||||
return Arrays.asList();
|
|
||||||
else
|
|
||||||
return Arrays.asList(places.get(0));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Player> getLosers()
|
|
||||||
{
|
|
||||||
List<Player> winners = getWinners();
|
|
||||||
|
|
||||||
if (winners == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
List<Player> losers = GetTeamList().get(0).GetPlayers(false);
|
|
||||||
|
|
||||||
losers.removeAll(winners);
|
|
||||||
|
|
||||||
return losers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String GetMode()
|
|
||||||
{
|
|
||||||
return "Solo Mode";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
package nautilus.game.arcade.game.games.survivalgames;
|
|
||||||
|
|
||||||
import org.bukkit.block.*;
|
|
||||||
import org.bukkit.entity.*;
|
|
||||||
import org.bukkit.event.*;
|
|
||||||
import org.bukkit.event.player.*;
|
|
||||||
|
|
||||||
public class SupplyChestOpenEvent extends PlayerEvent
|
|
||||||
{
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList()
|
|
||||||
{
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HandlerList getHandlers()
|
|
||||||
{
|
|
||||||
return getHandlerList();
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Block _chest;
|
|
||||||
|
|
||||||
public SupplyChestOpenEvent(Player who, Block chest)
|
|
||||||
{
|
|
||||||
super(who);
|
|
||||||
|
|
||||||
_chest = chest;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Block getChest()
|
|
||||||
{
|
|
||||||
return _chest;
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,95 @@
|
|||||||
|
package nautilus.game.arcade.game.games.survivalgames;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.map.MapCanvas;
|
||||||
|
import org.bukkit.map.MapCursor.Type;
|
||||||
|
import org.bukkit.map.MapPalette;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.game.GameTeam;
|
||||||
|
import nautilus.game.arcade.game.modules.worldmap.WorldMapRenderer;
|
||||||
|
|
||||||
|
public class SurvivalGamesMapRenderer extends WorldMapRenderer<SurvivalGamesNew>
|
||||||
|
{
|
||||||
|
|
||||||
|
private int _borderSize;
|
||||||
|
|
||||||
|
SurvivalGamesMapRenderer(SurvivalGamesNew game)
|
||||||
|
{
|
||||||
|
super(game);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderTick()
|
||||||
|
{
|
||||||
|
_borderSize = (int) _game.WorldData.World.getWorldBorder().getSize() / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void preRender(Player player)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected byte renderBlock(Player player, byte color, int mapX, int mapZ, int blockX, int blockZ)
|
||||||
|
{
|
||||||
|
int scale = _manager.getScale() * 2, minX = -_borderSize, maxX = _borderSize, minZ = -_borderSize, maxZ = _borderSize;
|
||||||
|
boolean bigX = blockX > maxX, smallX = blockX < minX, bigZ = blockZ > maxZ, smallZ = blockZ < minZ;
|
||||||
|
|
||||||
|
if (bigX || smallX || bigZ || smallZ)
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
bigX && blockX - scale < maxX && !smallX && !bigZ && !smallZ ||
|
||||||
|
smallX && blockX + scale > minX && !bigX && !bigZ && !smallZ ||
|
||||||
|
bigZ && blockZ - scale < maxZ && !bigX && !smallX && !smallZ ||
|
||||||
|
smallZ && blockZ + scale > minZ && !bigX && !smallX && !bigZ ||
|
||||||
|
(mapX + (mapZ % 4)) % 4 == 0)
|
||||||
|
{
|
||||||
|
color = MapPalette.RED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void renderCursors(MapCanvas canvas, Player player)
|
||||||
|
{
|
||||||
|
GameTeam team = _game.GetTeam(player);
|
||||||
|
|
||||||
|
for (Player other : UtilServer.getPlayersCollection())
|
||||||
|
{
|
||||||
|
if (UtilPlayer.isSpectator(other))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Location location = other.getLocation();
|
||||||
|
|
||||||
|
if (player.equals(other))
|
||||||
|
{
|
||||||
|
addCursor(canvas, location, Type.WHITE_POINTER);
|
||||||
|
}
|
||||||
|
else if (_game.TeamMode && team.HasPlayer(other))
|
||||||
|
{
|
||||||
|
addCursor(canvas, location, Type.GREEN_POINTER);
|
||||||
|
}
|
||||||
|
else if (!Recharge.Instance.usable(player, "Show All Players"))
|
||||||
|
{
|
||||||
|
addCursor(canvas, location, Type.RED_POINTER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Location supplyDrop = _game.getSupplyDrop().getCurrentDrop();
|
||||||
|
|
||||||
|
if (supplyDrop != null)
|
||||||
|
{
|
||||||
|
addCursor(canvas, supplyDrop, Type.WHITE_CROSS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,916 @@
|
|||||||
|
package nautilus.game.arcade.game.games.survivalgames;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.bukkit.Effect;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Boat;
|
||||||
|
import org.bukkit.entity.Egg;
|
||||||
|
import org.bukkit.entity.ItemFrame;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Snowball;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.block.BlockBurnEvent;
|
||||||
|
import org.bukkit.event.block.BlockFadeEvent;
|
||||||
|
import org.bukkit.event.block.BlockSpreadEvent;
|
||||||
|
import org.bukkit.event.block.LeavesDecayEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
|
import org.bukkit.event.hanging.HangingBreakEvent;
|
||||||
|
import org.bukkit.event.inventory.CraftItemEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
|
import org.bukkit.event.inventory.PrepareItemCraftEvent;
|
||||||
|
import org.bukkit.event.vehicle.VehicleCreateEvent;
|
||||||
|
import org.bukkit.inventory.BeaconInventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.scoreboard.NameTagVisibility;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.MapUtil;
|
||||||
|
import mineplex.core.common.util.UtilAlg;
|
||||||
|
import mineplex.core.common.util.UtilBlock;
|
||||||
|
import mineplex.core.common.util.UtilEnt;
|
||||||
|
import mineplex.core.common.util.UtilItem;
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
import mineplex.core.common.util.UtilTime;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
||||||
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
|
import nautilus.game.arcade.GameType;
|
||||||
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
|
import nautilus.game.arcade.game.Game;
|
||||||
|
import nautilus.game.arcade.game.GameTeam;
|
||||||
|
import nautilus.game.arcade.game.games.survivalgames.kit.KitArcher;
|
||||||
|
import nautilus.game.arcade.game.games.survivalgames.kit.KitAssassin;
|
||||||
|
import nautilus.game.arcade.game.games.survivalgames.kit.KitAxeman;
|
||||||
|
import nautilus.game.arcade.game.games.survivalgames.kit.KitBarbarian;
|
||||||
|
import nautilus.game.arcade.game.games.survivalgames.kit.KitBeastmaster;
|
||||||
|
import nautilus.game.arcade.game.games.survivalgames.kit.KitBomber;
|
||||||
|
import nautilus.game.arcade.game.games.survivalgames.kit.KitBrawler;
|
||||||
|
import nautilus.game.arcade.game.games.survivalgames.kit.KitHorseman;
|
||||||
|
import nautilus.game.arcade.game.games.survivalgames.kit.KitKnight;
|
||||||
|
import nautilus.game.arcade.game.games.survivalgames.kit.KitNecromancer;
|
||||||
|
import nautilus.game.arcade.game.games.survivalgames.modules.BorderModule;
|
||||||
|
import nautilus.game.arcade.game.games.survivalgames.modules.FurnaceLootModule;
|
||||||
|
import nautilus.game.arcade.game.games.survivalgames.modules.SupplyDropModule;
|
||||||
|
import nautilus.game.arcade.game.games.survivalgames.modules.TrackingCompassModule;
|
||||||
|
import nautilus.game.arcade.game.modules.CustomScoreboardModule;
|
||||||
|
import nautilus.game.arcade.game.modules.EXPForKillsModule;
|
||||||
|
import nautilus.game.arcade.game.modules.ThrowableTNTModule;
|
||||||
|
import nautilus.game.arcade.game.modules.chest.ChestLootModule;
|
||||||
|
import nautilus.game.arcade.game.modules.chest.ChestLootPool;
|
||||||
|
import nautilus.game.arcade.game.modules.combattracker.CombatData;
|
||||||
|
import nautilus.game.arcade.game.modules.combattracker.CombatTrackerModule;
|
||||||
|
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||||
|
import nautilus.game.arcade.game.modules.winstreak.WinStreakModule;
|
||||||
|
import nautilus.game.arcade.game.modules.worldmap.WorldMapModule;
|
||||||
|
import nautilus.game.arcade.kit.Kit;
|
||||||
|
import nautilus.game.arcade.kit.Perk;
|
||||||
|
import nautilus.game.arcade.managers.chat.ChatStatData;
|
||||||
|
import nautilus.game.arcade.scoreboard.GameScoreboard;
|
||||||
|
import nautilus.game.arcade.stats.KillsWithinTimeLimitStatTracker;
|
||||||
|
import nautilus.game.arcade.stats.SimultaneousSkeletonStatTracker;
|
||||||
|
import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker;
|
||||||
|
|
||||||
|
public abstract class SurvivalGamesNew extends Game
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final long PREPARE_TIME = TimeUnit.SECONDS.toMillis(15);
|
||||||
|
private static final long REFILL_TIME = TimeUnit.MINUTES.toMillis(7);
|
||||||
|
private static final long REFILL_INFORM_TIME = TimeUnit.MINUTES.toMillis(3);
|
||||||
|
private static final long KIT_COOLDOWN = TimeUnit.SECONDS.toMillis(30);
|
||||||
|
private static final int MAX_ITEM_SPAWN_DISTANCE_SQUARED = 36;
|
||||||
|
private static final String START_EFFECT_REASON = "Start Effect";
|
||||||
|
private static final int START_EFFECT_DURATION = 30;
|
||||||
|
private static final int ENCHANTMENT_TABLES = 5;
|
||||||
|
private static final int CRAFTING_TABLES = 10;
|
||||||
|
private static final int DISTANCE_NON_ASSASSIN = 576;
|
||||||
|
private static final int DISTANCE_ASSASSIN = 64;
|
||||||
|
|
||||||
|
private List<Location> _chests;
|
||||||
|
private SupplyDropModule _supplyDrop;
|
||||||
|
private final CombatTrackerModule _combatTrackerModule;
|
||||||
|
private final CustomScoreboardModule _customScoreboardModule;
|
||||||
|
private boolean _refilled;
|
||||||
|
|
||||||
|
SurvivalGamesNew(ArcadeManager manager, GameType gameType, String[] gameDesc)
|
||||||
|
{
|
||||||
|
super(manager, gameType, new Kit[]
|
||||||
|
{
|
||||||
|
new KitAxeman(manager),
|
||||||
|
new KitKnight(manager),
|
||||||
|
new KitArcher(manager),
|
||||||
|
new KitBrawler(manager),
|
||||||
|
new KitAssassin(manager),
|
||||||
|
new KitBeastmaster(manager),
|
||||||
|
new KitBomber(manager),
|
||||||
|
new KitNecromancer(manager),
|
||||||
|
new KitBarbarian(manager),
|
||||||
|
new KitHorseman(manager)
|
||||||
|
}, gameDesc);
|
||||||
|
|
||||||
|
AnnounceStay = false;
|
||||||
|
StrictAntiHack = true;
|
||||||
|
|
||||||
|
HideTeamSheep = true;
|
||||||
|
ReplaceTeamsWithKits = true;
|
||||||
|
|
||||||
|
DeathDropItems = true;
|
||||||
|
QuitDropItems = true;
|
||||||
|
|
||||||
|
DamageSelf = true;
|
||||||
|
DeadBodies = true;
|
||||||
|
|
||||||
|
ItemDrop = true;
|
||||||
|
ItemPickup = true;
|
||||||
|
|
||||||
|
InventoryClick = true;
|
||||||
|
InventoryOpenBlock = true;
|
||||||
|
InventoryOpenChest = true;
|
||||||
|
|
||||||
|
PrepareTime = PREPARE_TIME;
|
||||||
|
PlaySoundGameStart = false;
|
||||||
|
|
||||||
|
WorldTimeSet = 0;
|
||||||
|
WorldBoundaryKill = false;
|
||||||
|
|
||||||
|
BlockBreakAllow.add(Material.WEB.getId());
|
||||||
|
BlockPlaceAllow.add(Material.WEB.getId());
|
||||||
|
|
||||||
|
BlockBreakAllow.add(Material.LEAVES.getId());
|
||||||
|
BlockBreakAllow.add(Material.LEAVES_2.getId());
|
||||||
|
|
||||||
|
BlockPlaceAllow.add(Material.CAKE_BLOCK.getId());
|
||||||
|
BlockBreakAllow.add(Material.CAKE_BLOCK.getId());
|
||||||
|
|
||||||
|
BlockBreakAllow.add(Material.LONG_GRASS.getId());
|
||||||
|
BlockBreakAllow.add(Material.RED_ROSE.getId());
|
||||||
|
BlockBreakAllow.add(Material.YELLOW_FLOWER.getId());
|
||||||
|
BlockBreakAllow.add(Material.BROWN_MUSHROOM.getId());
|
||||||
|
BlockBreakAllow.add(Material.RED_MUSHROOM.getId());
|
||||||
|
BlockBreakAllow.add(Material.DEAD_BUSH.getId());
|
||||||
|
BlockBreakAllow.add(Material.CARROT.getId());
|
||||||
|
BlockBreakAllow.add(Material.POTATO.getId());
|
||||||
|
BlockBreakAllow.add(Material.DOUBLE_PLANT.getId());
|
||||||
|
BlockBreakAllow.add(Material.CROPS.getId());
|
||||||
|
BlockBreakAllow.add(Material.SAPLING.getId());
|
||||||
|
BlockBreakAllow.add(Material.VINE.getId());
|
||||||
|
BlockBreakAllow.add(Material.WATER_LILY.getId());
|
||||||
|
|
||||||
|
_help = new String[]
|
||||||
|
{
|
||||||
|
"Use a Compass to find and kill enemies!",
|
||||||
|
"You lose Speed 2 at start of game if you attack.",
|
||||||
|
"Avoid enemies who have better gear than you!",
|
||||||
|
"Supply drops appear on your item map!"
|
||||||
|
};
|
||||||
|
|
||||||
|
manager.GetCreature().SetDisableCustomDrops(true);
|
||||||
|
|
||||||
|
registerStatTrackers
|
||||||
|
(
|
||||||
|
new WinWithoutWearingArmorStatTracker(this),
|
||||||
|
new KillsWithinTimeLimitStatTracker(this, 3, 60, "Bloodlust"),
|
||||||
|
new SimultaneousSkeletonStatTracker(this, 5)
|
||||||
|
);
|
||||||
|
|
||||||
|
registerChatStats
|
||||||
|
(
|
||||||
|
Kills,
|
||||||
|
Assists,
|
||||||
|
BlankLine,
|
||||||
|
DamageTaken,
|
||||||
|
DamageDealt,
|
||||||
|
BlankLine,
|
||||||
|
new ChatStatData("SupplyDropsOpened", "Supply Drops Opened", true)
|
||||||
|
);
|
||||||
|
|
||||||
|
new CompassModule()
|
||||||
|
.register(this);
|
||||||
|
|
||||||
|
new WinStreakModule()
|
||||||
|
.register(this);
|
||||||
|
|
||||||
|
new EXPForKillsModule()
|
||||||
|
.register(this);
|
||||||
|
|
||||||
|
_supplyDrop = new SupplyDropModule();
|
||||||
|
_supplyDrop.register(this);
|
||||||
|
|
||||||
|
_combatTrackerModule = new CombatTrackerModule();
|
||||||
|
_combatTrackerModule.register(this);
|
||||||
|
|
||||||
|
_customScoreboardModule = new CustomScoreboardModule()
|
||||||
|
.setSidebar((player, scoreboard) ->
|
||||||
|
{
|
||||||
|
switch (GetState())
|
||||||
|
{
|
||||||
|
case Prepare:
|
||||||
|
writePrepare(player, scoreboard);
|
||||||
|
break;
|
||||||
|
case Live:
|
||||||
|
writeLive(player, scoreboard);
|
||||||
|
break;
|
||||||
|
case End:
|
||||||
|
case WinRoom:
|
||||||
|
writeEnd(player, scoreboard);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setPrefix((perspective, subject) ->
|
||||||
|
{
|
||||||
|
GameTeam team = GetTeam(subject);
|
||||||
|
|
||||||
|
return team == null || !team.IsAlive(subject) ? C.cGray : team.GetColor().toString();
|
||||||
|
})
|
||||||
|
.setNameTagVisibility((perspective, subject) ->
|
||||||
|
{
|
||||||
|
if (!IsLive() || !IsAlive(perspective) || !IsAlive(subject))
|
||||||
|
{
|
||||||
|
return NameTagVisibility.ALWAYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameTeam perspectiveTeam = GetTeam(perspective);
|
||||||
|
GameTeam subjectTeam = GetTeam(subject);
|
||||||
|
Kit kit = GetKit(subject);
|
||||||
|
|
||||||
|
if (perspectiveTeam == null || subjectTeam == null || perspectiveTeam.equals(subjectTeam) && TeamMode)
|
||||||
|
{
|
||||||
|
return NameTagVisibility.ALWAYS;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return UtilMath.offsetSquared(perspective, subject) > (kit instanceof KitAssassin ? DISTANCE_ASSASSIN : DISTANCE_NON_ASSASSIN) || !perspective.hasLineOfSight(subject) ? NameTagVisibility.NEVER : NameTagVisibility.ALWAYS;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
_customScoreboardModule.register(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writePrepare(Player player, GameScoreboard scoreboard)
|
||||||
|
{
|
||||||
|
GameTeam team = GetTeam(player);
|
||||||
|
|
||||||
|
scoreboard.writeNewLine();
|
||||||
|
|
||||||
|
scoreboard.write((team == null ? "" : team.GetColor()) + C.Bold + "Survival Games");
|
||||||
|
scoreboard.write(WorldData.MapName);
|
||||||
|
|
||||||
|
scoreboard.writeNewLine();
|
||||||
|
|
||||||
|
scoreboard.write(C.cYellowB + "Tributes");
|
||||||
|
scoreboard.write(GetPlayers(true).size() + " Players");
|
||||||
|
|
||||||
|
if (team != null && TeamMode)
|
||||||
|
{
|
||||||
|
scoreboard.writeNewLine();
|
||||||
|
scoreboard.write(team.GetFormattedName());
|
||||||
|
|
||||||
|
team.GetPlayers(false).forEach(teammate -> scoreboard.write(teammate.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
scoreboard.writeNewLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeLive(Player player, GameScoreboard scoreboard)
|
||||||
|
{
|
||||||
|
GameTeam team = GetTeam(player);
|
||||||
|
List<Player> alive = GetPlayers(true);
|
||||||
|
Location supplyDrop = _supplyDrop.getCurrentDrop();
|
||||||
|
long supplyIn = (SupplyDropModule.TIME - WorldTimeSet) * 50 / 4;
|
||||||
|
long chestRefillIn = Math.max(0, GetStateTime() + REFILL_TIME - System.currentTimeMillis());
|
||||||
|
String event, in;
|
||||||
|
|
||||||
|
if (supplyDrop != null)
|
||||||
|
{
|
||||||
|
event = "Supply Drop";
|
||||||
|
in = "(" + supplyDrop.getBlockX() + ", " + supplyDrop.getBlockZ() + ")";
|
||||||
|
}
|
||||||
|
else if (!_refilled && chestRefillIn < REFILL_INFORM_TIME)
|
||||||
|
{
|
||||||
|
event = "Chest Refill";
|
||||||
|
in = UtilTime.MakeStr(chestRefillIn);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
event = "Supply Drop";
|
||||||
|
in = UtilTime.MakeStr(supplyIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
scoreboard.writeNewLine();
|
||||||
|
|
||||||
|
scoreboard.write(C.cYellowB + "Tributes");
|
||||||
|
|
||||||
|
if (TeamMode)
|
||||||
|
{
|
||||||
|
List<GameTeam> aliveTeams = GetTeamList().stream()
|
||||||
|
.filter(GameTeam::IsTeamAlive)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (alive.size() < 5)
|
||||||
|
{
|
||||||
|
for (GameTeam teams : GetTeamList())
|
||||||
|
{
|
||||||
|
for (Player teamMember : teams.GetPlayers(true))
|
||||||
|
{
|
||||||
|
scoreboard.write(teams.GetColor() + teamMember.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (aliveTeams.size() < 5)
|
||||||
|
{
|
||||||
|
for (GameTeam teams : aliveTeams)
|
||||||
|
{
|
||||||
|
scoreboard.write(teams.GetPlayers(true).size() + " " + teams.GetColor() + teams.GetName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
scoreboard.write(alive.size() + " Alive");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (alive.size() > 6)
|
||||||
|
{
|
||||||
|
scoreboard.write(alive.size() + " Alive");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
alive.forEach(other -> scoreboard.write(other.getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
writeStats(player, team, scoreboard);
|
||||||
|
|
||||||
|
scoreboard.writeNewLine();
|
||||||
|
|
||||||
|
scoreboard.write(C.cRedB + event);
|
||||||
|
scoreboard.write(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeEnd(Player player, GameScoreboard scoreboard)
|
||||||
|
{
|
||||||
|
List<Player> winners = getWinners();
|
||||||
|
|
||||||
|
writeStats(player, GetTeam(player), scoreboard);
|
||||||
|
|
||||||
|
if (winners == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
scoreboard.writeNewLine();
|
||||||
|
scoreboard.write(C.cYellowB + "Winner" + (TeamMode ? "s" : ""));
|
||||||
|
|
||||||
|
for (Player winner : winners)
|
||||||
|
{
|
||||||
|
scoreboard.write(winner.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeStats(Player player, GameTeam team, GameScoreboard scoreboard)
|
||||||
|
{
|
||||||
|
if (team != null)
|
||||||
|
{
|
||||||
|
scoreboard.writeNewLine();
|
||||||
|
|
||||||
|
scoreboard.write(C.cGoldB + "Stats");
|
||||||
|
|
||||||
|
CombatData combatData = _combatTrackerModule.getCombatData(player);
|
||||||
|
|
||||||
|
scoreboard.write("Kills: " + C.cGreen + combatData.getKills());
|
||||||
|
scoreboard.write("Assists: " + C.cGreen + combatData.getAssits());
|
||||||
|
|
||||||
|
if (TeamMode)
|
||||||
|
{
|
||||||
|
int teamKills = 0, teamAssists = 0;
|
||||||
|
|
||||||
|
for (Player teammate : team.GetPlayers(false))
|
||||||
|
{
|
||||||
|
CombatData teammateCombatData = _combatTrackerModule.getCombatData(teammate);
|
||||||
|
|
||||||
|
teamKills += teammateCombatData.getKills();
|
||||||
|
teamAssists += teammateCombatData.getAssits();
|
||||||
|
}
|
||||||
|
|
||||||
|
scoreboard.write("Team Kills: " + C.cGreen + teamKills);
|
||||||
|
scoreboard.write("Team Assists: " + C.cGreen + teamAssists);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void ScoreboardUpdate(UpdateEvent event)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void ParseData()
|
||||||
|
{
|
||||||
|
new BorderModule()
|
||||||
|
.register(this);
|
||||||
|
|
||||||
|
setupLoot();
|
||||||
|
|
||||||
|
new WorldMapModule(WorldData, new SurvivalGamesMapRenderer(this))
|
||||||
|
.register(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupLoot()
|
||||||
|
{
|
||||||
|
ThrowableTNTModule tntModule = new ThrowableTNTModule()
|
||||||
|
.setThrowStrength(0.3);
|
||||||
|
tntModule.register(this);
|
||||||
|
ItemStack tnt = tntModule.getTntItem();
|
||||||
|
|
||||||
|
TrackingCompassModule compassModule = new TrackingCompassModule();
|
||||||
|
compassModule.register(this);
|
||||||
|
|
||||||
|
new FurnaceLootModule()
|
||||||
|
.register(this);
|
||||||
|
|
||||||
|
Location center = GetSpectatorLocation();
|
||||||
|
_chests = WorldData.GetCustomLocs(String.valueOf(Material.CHEST.getId()));
|
||||||
|
List<Location> midChests = _chests.stream()
|
||||||
|
.filter(location -> UtilMath.offset2dSquared(location, center) < 64)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
_chests.removeAll(midChests);
|
||||||
|
|
||||||
|
ChestLootModule lootModule = new ChestLootModule();
|
||||||
|
|
||||||
|
lootModule.registerChestType("Tier 1", _chests, 0.35,
|
||||||
|
|
||||||
|
new ChestLootPool()
|
||||||
|
.addItem(new ItemStack(Material.WOOD_AXE), 240)
|
||||||
|
.addItem(new ItemStack(Material.WOOD_SWORD), 210)
|
||||||
|
.addItem(new ItemStack(Material.STONE_AXE), 180)
|
||||||
|
.addItem(new ItemStack(Material.STONE_SWORD))
|
||||||
|
.setUnbreakable(true)
|
||||||
|
,
|
||||||
|
|
||||||
|
new ChestLootPool()
|
||||||
|
.addItem(new ItemStack(Material.LEATHER_HELMET))
|
||||||
|
.addItem(new ItemStack(Material.LEATHER_CHESTPLATE))
|
||||||
|
.addItem(new ItemStack(Material.LEATHER_LEGGINGS))
|
||||||
|
.addItem(new ItemStack(Material.LEATHER_BOOTS))
|
||||||
|
.addItem(new ItemStack(Material.GOLD_HELMET), 75)
|
||||||
|
.addItem(new ItemStack(Material.GOLD_CHESTPLATE), 75)
|
||||||
|
.addItem(new ItemStack(Material.GOLD_LEGGINGS), 75)
|
||||||
|
.addItem(new ItemStack(Material.GOLD_BOOTS), 75)
|
||||||
|
.addItem(new ItemStack(Material.CHAINMAIL_HELMET), 30)
|
||||||
|
.addItem(new ItemStack(Material.CHAINMAIL_CHESTPLATE), 30)
|
||||||
|
.addItem(new ItemStack(Material.CHAINMAIL_LEGGINGS), 30)
|
||||||
|
.addItem(new ItemStack(Material.CHAINMAIL_BOOTS), 30)
|
||||||
|
.setAmountsPerChest(1, 2)
|
||||||
|
.setUnbreakable(true)
|
||||||
|
,
|
||||||
|
|
||||||
|
new ChestLootPool()
|
||||||
|
.addItem(new ItemStack(Material.FISHING_ROD))
|
||||||
|
.addItem(new ItemStack(Material.BOW), 60)
|
||||||
|
.addItem(new ItemStack(Material.ARROW), 1, 3)
|
||||||
|
.addItem(new ItemStack(Material.SNOW_BALL), 1, 2)
|
||||||
|
.addItem(new ItemStack(Material.EGG), 1, 2)
|
||||||
|
.setUnbreakable(true)
|
||||||
|
,
|
||||||
|
|
||||||
|
new ChestLootPool()
|
||||||
|
.addItem(new ItemStack(Material.BAKED_POTATO), 1, 3)
|
||||||
|
.addItem(new ItemStack(Material.COOKED_BEEF), 1, 2)
|
||||||
|
.addItem(new ItemStack(Material.COOKED_CHICKEN), 1, 3)
|
||||||
|
.addItem(new ItemStack(Material.CARROT_ITEM), 1, 3)
|
||||||
|
.addItem(new ItemStack(Material.WHEAT), 1, 3)
|
||||||
|
.addItem(new ItemStack(Material.APPLE), 1, 3)
|
||||||
|
.addItem(new ItemStack(Material.PORK), 1, 3)
|
||||||
|
.addItem(new ItemStack(Material.MUSHROOM_SOUP), 80)
|
||||||
|
,
|
||||||
|
|
||||||
|
new ChestLootPool()
|
||||||
|
.addItem(new ItemStack(Material.EXP_BOTTLE), 1, 2)
|
||||||
|
.addItem(new ItemStack(Material.STICK), 1, 2)
|
||||||
|
.addItem(new ItemStack(Material.BOAT), 50)
|
||||||
|
.addItem(new ItemStack(Material.FLINT), 1, 2)
|
||||||
|
.addItem(new ItemStack(Material.FEATHER), 1, 2)
|
||||||
|
.addItem(new ItemStack(Material.GOLD_INGOT), 1, 1, 80)
|
||||||
|
.addItem(compassModule.getCompass(5))
|
||||||
|
.addItem(tnt, 50)
|
||||||
|
);
|
||||||
|
|
||||||
|
lootModule.registerChestType("Tier 2", midChests,
|
||||||
|
|
||||||
|
new ChestLootPool()
|
||||||
|
.addItem(new ItemStack(Material.WOOD_AXE), 240)
|
||||||
|
.addItem(new ItemStack(Material.WOOD_SWORD), 210)
|
||||||
|
.addItem(new ItemStack(Material.STONE_AXE), 180)
|
||||||
|
.addItem(new ItemStack(Material.STONE_SWORD))
|
||||||
|
.addItem(new ItemStack(Material.IRON_AXE))
|
||||||
|
.setUnbreakable(true)
|
||||||
|
,
|
||||||
|
|
||||||
|
new ChestLootPool()
|
||||||
|
.addItem(new ItemStack(Material.LEATHER_HELMET))
|
||||||
|
.addItem(new ItemStack(Material.LEATHER_CHESTPLATE))
|
||||||
|
.addItem(new ItemStack(Material.LEATHER_LEGGINGS))
|
||||||
|
.addItem(new ItemStack(Material.LEATHER_BOOTS))
|
||||||
|
.addItem(new ItemStack(Material.GOLD_HELMET), 75)
|
||||||
|
.addItem(new ItemStack(Material.GOLD_CHESTPLATE), 75)
|
||||||
|
.addItem(new ItemStack(Material.GOLD_LEGGINGS), 75)
|
||||||
|
.addItem(new ItemStack(Material.GOLD_BOOTS), 75)
|
||||||
|
.addItem(new ItemStack(Material.CHAINMAIL_HELMET), 75)
|
||||||
|
.addItem(new ItemStack(Material.CHAINMAIL_CHESTPLATE), 75)
|
||||||
|
.addItem(new ItemStack(Material.CHAINMAIL_LEGGINGS), 75)
|
||||||
|
.addItem(new ItemStack(Material.CHAINMAIL_BOOTS), 75)
|
||||||
|
.addItem(new ItemStack(Material.IRON_HELMET), 50)
|
||||||
|
.addItem(new ItemStack(Material.IRON_CHESTPLATE), 50)
|
||||||
|
.addItem(new ItemStack(Material.IRON_LEGGINGS), 50)
|
||||||
|
.addItem(new ItemStack(Material.IRON_BOOTS), 50)
|
||||||
|
.setAmountsPerChest(1, 2)
|
||||||
|
.setUnbreakable(true)
|
||||||
|
,
|
||||||
|
|
||||||
|
new ChestLootPool()
|
||||||
|
.addItem(new ItemStack(Material.FISHING_ROD))
|
||||||
|
.addItem(new ItemStack(Material.BOW), 50)
|
||||||
|
.addItem(new ItemStack(Material.ARROW), 1, 3)
|
||||||
|
.addItem(new ItemStack(Material.SNOW_BALL), 1, 2)
|
||||||
|
.addItem(new ItemStack(Material.EGG), 1, 2)
|
||||||
|
.setUnbreakable(true)
|
||||||
|
,
|
||||||
|
|
||||||
|
new ChestLootPool()
|
||||||
|
.addItem(new ItemStack(Material.BAKED_POTATO), 1, 3)
|
||||||
|
.addItem(new ItemStack(Material.COOKED_BEEF), 1, 2)
|
||||||
|
.addItem(new ItemStack(Material.COOKED_CHICKEN), 1, 3)
|
||||||
|
.addItem(new ItemStack(Material.CARROT_ITEM), 1, 3)
|
||||||
|
.addItem(new ItemStack(Material.WHEAT), 1, 3)
|
||||||
|
.addItem(new ItemStack(Material.APPLE), 1, 3)
|
||||||
|
.addItem(new ItemStack(Material.PORK), 1, 3)
|
||||||
|
.addItem(new ItemStack(Material.MUSHROOM_SOUP), 80)
|
||||||
|
.addItem(new ItemStack(Material.CAKE), 80)
|
||||||
|
,
|
||||||
|
|
||||||
|
new ChestLootPool()
|
||||||
|
.addItem(new ItemStack(Material.EXP_BOTTLE), 1, 2)
|
||||||
|
.addItem(new ItemStack(Material.STICK), 1, 2)
|
||||||
|
.addItem(new ItemStack(Material.BOAT), 50)
|
||||||
|
.addItem(new ItemStack(Material.FLINT), 1, 2)
|
||||||
|
.addItem(new ItemStack(Material.STRING), 1, 2)
|
||||||
|
.addItem(new ItemStack(Material.FEATHER), 1, 2)
|
||||||
|
.addItem(new ItemStack(Material.GOLD_INGOT), 1, 1, 80)
|
||||||
|
.addItem(compassModule.getCompass(5))
|
||||||
|
.addItem(new ItemStack(Material.DIAMOND), 50)
|
||||||
|
.addItem(tnt, 50)
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
lootModule.register(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void updateScoreboard(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.SEC)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_customScoreboardModule.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void createTables(GameStateChangeEvent event)
|
||||||
|
{
|
||||||
|
if (event.GetState() != GameState.Prepare)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < ENCHANTMENT_TABLES; i++)
|
||||||
|
{
|
||||||
|
createRandomBlock(Material.ENCHANTMENT_TABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < CRAFTING_TABLES; i++)
|
||||||
|
{
|
||||||
|
createRandomBlock(Material.WORKBENCH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createRandomBlock(Material type)
|
||||||
|
{
|
||||||
|
MapUtil.QuickChangeBlockAt(UtilAlg.Random(_chests), type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void kitCooldowns(GameStateChangeEvent event)
|
||||||
|
{
|
||||||
|
if (event.GetState() != GameState.Live)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player player : GetPlayers(true))
|
||||||
|
{
|
||||||
|
Kit kit = GetKit(player);
|
||||||
|
|
||||||
|
for (Perk perk : kit.GetPerks())
|
||||||
|
{
|
||||||
|
Recharge.Instance.useForce(player, perk.GetName(), KIT_COOLDOWN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Manager.runSyncLater(() -> Announce(F.main("Game", "You can now use " + F.skill("Kit Abilities") + ".")), KIT_COOLDOWN / 50);
|
||||||
|
|
||||||
|
Manager.runSyncLater(() ->
|
||||||
|
{
|
||||||
|
for (Player player : Manager.GetGame().GetPlayers(true))
|
||||||
|
{
|
||||||
|
if (GetKit(player) instanceof KitArcher)
|
||||||
|
{
|
||||||
|
player.sendMessage(F.main("Game", "You received your kit " + F.item("Bow") + "."));
|
||||||
|
player.getInventory().addItem(KitArcher.BOW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 90 * 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void timeUpdate(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.TICK || !IsLive())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WorldTimeSet > 22000 || WorldTimeSet < 14000)
|
||||||
|
{
|
||||||
|
WorldTimeSet += 4;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WorldTimeSet += 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
WorldTimeSet %= 24000;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void startEffect(GameStateChangeEvent event)
|
||||||
|
{
|
||||||
|
if (event.GetState() != GameState.Live)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack mapItem = getModule(WorldMapModule.class).getMapItem()
|
||||||
|
.setTitle(C.cGreenB + "World Map")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
for (Player player : GetPlayers(true))
|
||||||
|
{
|
||||||
|
player.playSound(player.getLocation(), Sound.DONKEY_DEATH, 0.8F, 0);
|
||||||
|
|
||||||
|
Manager.GetCondition().Factory()
|
||||||
|
.Speed(START_EFFECT_REASON, player, player, START_EFFECT_DURATION, 1, false, false, false);
|
||||||
|
Manager.GetCondition().Factory()
|
||||||
|
.HealthBoost(START_EFFECT_REASON, player, player, START_EFFECT_DURATION, 1, false, false, false);
|
||||||
|
|
||||||
|
player.setHealth(player.getMaxHealth());
|
||||||
|
player.getInventory().setItem(8, mapItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
public void damage(CustomDamageEvent event)
|
||||||
|
{
|
||||||
|
Player damager = event.GetDamagerPlayer(true);
|
||||||
|
|
||||||
|
event.SetDamageToLevel(false);
|
||||||
|
|
||||||
|
boolean egg = event.GetProjectile() instanceof Egg;
|
||||||
|
boolean snowball = event.GetProjectile() instanceof Snowball;
|
||||||
|
|
||||||
|
if (egg || snowball)
|
||||||
|
{
|
||||||
|
event.AddMod(event.GetDamagerPlayer(true).getName(), (egg ? "Egg" : "Snowball"), 0.5, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (damager != null && !event.isCancelled())
|
||||||
|
{
|
||||||
|
Manager.GetCondition().EndCondition(damager, ConditionType.SPEED, START_EFFECT_REASON);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void boatPlace(VehicleCreateEvent event)
|
||||||
|
{
|
||||||
|
if (!(event.getVehicle() instanceof Boat))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Block block : UtilBlock.getSurrounding(event.getVehicle().getLocation().getBlock(), true))
|
||||||
|
{
|
||||||
|
if (block.isLiquid())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
event.getVehicle().remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void inventoryOpen(InventoryOpenEvent event)
|
||||||
|
{
|
||||||
|
if (event.getInventory().getType() == InventoryType.BREWING || event.getInventory() instanceof BeaconInventory)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void preventItemSpawning(ItemSpawnEvent event)
|
||||||
|
{
|
||||||
|
if (!IsLive())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.getEntity().getItemStack().getType() == Material.MAP)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player player : GetPlayers(true))
|
||||||
|
{
|
||||||
|
if (UtilMath.offsetSquared(event.getEntity(), player) < MAX_ITEM_SPAWN_DISTANCE_SQUARED)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void preventCrafting(PrepareItemCraftEvent event)
|
||||||
|
{
|
||||||
|
ItemStack result = event.getInventory().getResult();
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Material type = result.getType();
|
||||||
|
|
||||||
|
if (type == Material.BUCKET || type == Material.GOLDEN_APPLE || type == Material.FLINT_AND_STEEL || type.isBlock())
|
||||||
|
{
|
||||||
|
event.getInventory().setResult(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void craftedItems(CraftItemEvent event)
|
||||||
|
{
|
||||||
|
ItemStack itemStack = event.getCurrentItem();
|
||||||
|
|
||||||
|
if (UtilItem.isWeapon(itemStack) || UtilItem.isArmor(itemStack) || itemStack.getType() == Material.FISHING_ROD)
|
||||||
|
{
|
||||||
|
UtilItem.makeUnbreakable(itemStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void updateRefill(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.FAST || _refilled || !UtilTime.elapsed(GetStateTime(), REFILL_TIME))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_refilled = true;
|
||||||
|
getModule(ChestLootModule.class)
|
||||||
|
.refill();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void explosion(EntityExplodeEvent event)
|
||||||
|
{
|
||||||
|
event.blockList().clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void blockBurn(BlockBurnEvent event)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void blockDecay(LeavesDecayEvent event)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void blockFade(BlockFadeEvent event)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void blockSpread(BlockSpreadEvent event)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void itemFrameBreak(HangingBreakEvent event)
|
||||||
|
{
|
||||||
|
if (event.getEntity() instanceof ItemFrame)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
public void blockBreak(BlockBreakEvent event)
|
||||||
|
{
|
||||||
|
if (event.isCancelled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Block block = event.getBlock();
|
||||||
|
|
||||||
|
if (UtilBlock.airFoliage(event.getBlock()))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
block.setType(Material.AIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.getBlock().getType() == Material.LEAVES && Math.random() < 0.05)
|
||||||
|
{
|
||||||
|
Location location = block.getLocation().add(0.5, 0.5, 0.5);
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
location.getWorld().playEffect(location, Effect.STEP_SOUND, block.getType());
|
||||||
|
block.setType(Material.AIR);
|
||||||
|
location.getWorld().dropItemNaturally(location, new ItemStack(Material.STICK));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void explosionDamage(CustomDamageEvent event)
|
||||||
|
{
|
||||||
|
Player damagee = event.GetDamageePlayer();
|
||||||
|
|
||||||
|
if (event.GetCause() != DamageCause.ENTITY_EXPLOSION || damagee == null || !UtilEnt.isInWater(damagee))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.AddMod("Water Explosion", -event.GetDamage() / 2D);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void entityDeath(EntityDeathEvent event)
|
||||||
|
{
|
||||||
|
if (event.getEntity() instanceof Player)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setDroppedExp(0);
|
||||||
|
event.getDrops().clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double GetKillsGems(Player killer, Player killed, boolean assist)
|
||||||
|
{
|
||||||
|
return assist ? 3 : 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SupplyDropModule getSupplyDrop()
|
||||||
|
{
|
||||||
|
return _supplyDrop;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,126 @@
|
|||||||
|
package nautilus.game.arcade.game.games.survivalgames;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
|
import nautilus.game.arcade.GameType;
|
||||||
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
|
import nautilus.game.arcade.game.GameTeam;
|
||||||
|
|
||||||
|
public class SurvivalGamesNewSolo extends SurvivalGamesNew
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final String[] DESCRIPTION =
|
||||||
|
{
|
||||||
|
"Search for chests to find loot",
|
||||||
|
"Slaughter your opponents",
|
||||||
|
"Stay away from the borders!",
|
||||||
|
"Last tribute alive wins!"
|
||||||
|
};
|
||||||
|
|
||||||
|
public SurvivalGamesNewSolo(ArcadeManager manager)
|
||||||
|
{
|
||||||
|
super(manager, GameType.SurvivalGames, DESCRIPTION);
|
||||||
|
|
||||||
|
DamageTeamSelf = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void customTeamGeneration(GameStateChangeEvent event)
|
||||||
|
{
|
||||||
|
if (event.GetState() != GameState.Recruit)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameTeam players = GetTeamList().get(0);
|
||||||
|
players.SetColor(ChatColor.YELLOW);
|
||||||
|
players.SetName("Tributes");
|
||||||
|
players.setDisplayName(C.cYellowB + "Tributes");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void EndCheck()
|
||||||
|
{
|
||||||
|
if (!IsLive())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GetPlayers(true).size() <= 1)
|
||||||
|
{
|
||||||
|
List<Player> places = GetTeamList().get(0).GetPlacements(true);
|
||||||
|
|
||||||
|
if (places.size() > 0)
|
||||||
|
{
|
||||||
|
AddGems(places.get(0), 20, "1st Place", false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (places.size() > 1)
|
||||||
|
{
|
||||||
|
AddGems(places.get(1), 15, "2nd Place", false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (places.size() > 2)
|
||||||
|
{
|
||||||
|
AddGems(places.get(2), 10, "3rd Place", false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player player : GetPlayers(false))
|
||||||
|
{
|
||||||
|
if (player.isOnline())
|
||||||
|
{
|
||||||
|
AddGems(player, 10, "Participation", false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AnnounceEnd(places);
|
||||||
|
SetState(GameState.End);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Player> getWinners()
|
||||||
|
{
|
||||||
|
if (GetState().ordinal() >= GameState.End.ordinal())
|
||||||
|
{
|
||||||
|
List<Player> places = GetTeamList().get(0).GetPlacements(true);
|
||||||
|
|
||||||
|
if (places.isEmpty() || !places.get(0).isOnline())
|
||||||
|
{
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Collections.singletonList(places.get(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Player> getLosers()
|
||||||
|
{
|
||||||
|
List<Player> winners = getWinners();
|
||||||
|
|
||||||
|
if (winners == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Player> losers = GetPlayers(false);
|
||||||
|
losers.removeAll(winners);
|
||||||
|
|
||||||
|
return losers;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,112 @@
|
|||||||
|
package nautilus.game.arcade.game.games.survivalgames;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
|
import nautilus.game.arcade.GameType;
|
||||||
|
import nautilus.game.arcade.game.GameTeam;
|
||||||
|
import nautilus.game.arcade.game.modules.TeamModule;
|
||||||
|
|
||||||
|
public class SurvivalGamesNewTeams extends SurvivalGamesNew
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final String[] DESCRIPTION =
|
||||||
|
{
|
||||||
|
"Search for chests to find loot",
|
||||||
|
"Slaughter your opponents",
|
||||||
|
"Stay away from the borders!",
|
||||||
|
"Last tribute alive wins!"
|
||||||
|
};
|
||||||
|
|
||||||
|
public SurvivalGamesNewTeams(ArcadeManager manager)
|
||||||
|
{
|
||||||
|
super(manager, GameType.SurvivalGamesTeams, DESCRIPTION);
|
||||||
|
|
||||||
|
PlayersPerTeam = 2;
|
||||||
|
FillTeamsInOrderToCount = 2;
|
||||||
|
TeamMode = true;
|
||||||
|
ShowTeammateMessage = true;
|
||||||
|
|
||||||
|
SpawnNearAllies = true;
|
||||||
|
SpawnNearEnemies = true;
|
||||||
|
|
||||||
|
DamageTeamSelf = false;
|
||||||
|
|
||||||
|
DontAllowOverfill = true;
|
||||||
|
|
||||||
|
new TeamModule()
|
||||||
|
.register(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void EndCheck()
|
||||||
|
{
|
||||||
|
if (!IsLive())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<GameTeam> teamsAlive = GetTeamList().stream()
|
||||||
|
.filter(GameTeam::IsTeamAlive)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (teamsAlive.size() < 2)
|
||||||
|
{
|
||||||
|
for (GameTeam team : GetTeamList())
|
||||||
|
{
|
||||||
|
if (WinnerTeam != null && team.equals(WinnerTeam))
|
||||||
|
{
|
||||||
|
for (Player player : team.GetPlayers(false))
|
||||||
|
{
|
||||||
|
AddGems(player, 10, "Winning Team", false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player player : team.GetPlayers(false))
|
||||||
|
{
|
||||||
|
if (player.isOnline())
|
||||||
|
{
|
||||||
|
AddGems(player, 10, "Participation", false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!teamsAlive.isEmpty())
|
||||||
|
{
|
||||||
|
AnnounceEnd(teamsAlive.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
SetState(GameState.End);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Player> getWinners()
|
||||||
|
{
|
||||||
|
return WinnerTeam == null ? null : WinnerTeam.GetPlayers(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Player> getLosers()
|
||||||
|
{
|
||||||
|
List<Player> winners = getWinners();
|
||||||
|
|
||||||
|
if (winners == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return GetPlayers(false).stream()
|
||||||
|
.filter(player -> !winners.contains(player))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String GetMode()
|
||||||
|
{
|
||||||
|
return "Team Mode";
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -1,229 +0,0 @@
|
|||||||
package nautilus.game.arcade.game.games.survivalgames;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
|
||||||
import mineplex.core.common.util.UtilTime;
|
|
||||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
|
||||||
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.game.GameTeam;
|
|
||||||
import nautilus.game.arcade.game.modules.TeamModule;
|
|
||||||
import nautilus.game.arcade.managers.chat.ChatStatData;
|
|
||||||
import nautilus.game.arcade.stats.FirstSupplyDropOpenStatTracker;
|
|
||||||
import nautilus.game.arcade.stats.KillsWithinTimeLimitStatTracker;
|
|
||||||
import nautilus.game.arcade.stats.SimultaneousSkeletonStatTracker;
|
|
||||||
import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
|
|
||||||
public class TeamSurvivalGames extends SurvivalGames
|
|
||||||
{
|
|
||||||
|
|
||||||
public TeamSurvivalGames(ArcadeManager manager)
|
|
||||||
{
|
|
||||||
super(manager, GameType.SurvivalGamesTeams,
|
|
||||||
new String[]
|
|
||||||
{
|
|
||||||
"Search for chests to find loot",
|
|
||||||
|
|
||||||
"Slaughter your opponents",
|
|
||||||
|
|
||||||
"Stay away from the borders!",
|
|
||||||
|
|
||||||
"Last team alive wins!"
|
|
||||||
});
|
|
||||||
|
|
||||||
PlayersPerTeam = 2;
|
|
||||||
FillTeamsInOrderToCount = 2;
|
|
||||||
|
|
||||||
SpawnNearAllies = true;
|
|
||||||
SpawnNearEnemies = true;
|
|
||||||
|
|
||||||
DamageTeamSelf = false;
|
|
||||||
|
|
||||||
DontAllowOverfill = true;
|
|
||||||
TeamMode = true;
|
|
||||||
ShowTeammateMessage = true;
|
|
||||||
|
|
||||||
new TeamModule().register(this);
|
|
||||||
|
|
||||||
registerStatTrackers(new WinWithoutWearingArmorStatTracker(this),
|
|
||||||
new KillsWithinTimeLimitStatTracker(this, 3, 60, "Bloodlust"),
|
|
||||||
new FirstSupplyDropOpenStatTracker(this),
|
|
||||||
new SimultaneousSkeletonStatTracker(this, 5));
|
|
||||||
|
|
||||||
registerChatStats(
|
|
||||||
Kills,
|
|
||||||
Assists,
|
|
||||||
BlankLine,
|
|
||||||
DamageTaken,
|
|
||||||
DamageDealt,
|
|
||||||
BlankLine,
|
|
||||||
new ChatStatData("SupplyDropsOpened", "Event chests opened", true)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@EventHandler
|
|
||||||
public void ScoreboardUpdate(UpdateEvent event)
|
|
||||||
{
|
|
||||||
if (event.getType() != UpdateType.FAST)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (GetTeamList().isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
Scoreboard.reset();
|
|
||||||
|
|
||||||
Scoreboard.writeNewLine();
|
|
||||||
|
|
||||||
Scoreboard.write(C.cGreen + C.Bold + "Time");
|
|
||||||
Scoreboard.write(UtilTime.convertString(getSecondsSinceStart() * 1000, 0, TimeUnit.FIT));
|
|
||||||
|
|
||||||
Scoreboard.writeNewLine();
|
|
||||||
Scoreboard.write(C.cYellow + C.Bold + "Teams");
|
|
||||||
|
|
||||||
ArrayList<GameTeam> alive = new ArrayList<GameTeam>();
|
|
||||||
for (GameTeam team : GetTeamList())
|
|
||||||
{
|
|
||||||
if (team.IsTeamAlive())
|
|
||||||
alive.add(team);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GetPlayers(true).size() <= 7)
|
|
||||||
{
|
|
||||||
for (GameTeam team : GetTeamList())
|
|
||||||
{
|
|
||||||
for (Player player : team.GetPlayers(true))
|
|
||||||
{
|
|
||||||
Scoreboard.write(team.GetColor() + player.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (alive.size() <= 7)
|
|
||||||
{
|
|
||||||
for (GameTeam team : alive)
|
|
||||||
{
|
|
||||||
Scoreboard.write(C.cWhite + team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Scoreboard.write(C.cWhite + alive.size() + " Alive");
|
|
||||||
}
|
|
||||||
|
|
||||||
Scoreboard.writeNewLine();
|
|
||||||
|
|
||||||
if (getChestRefillTime() > 0 && getDeathMatchTime() > 60)
|
|
||||||
{
|
|
||||||
Scoreboard.write(C.cGold + C.Bold + "Chest Refill");
|
|
||||||
Scoreboard.write(UtilTime.convertString(getChestRefillTime() * 1000, 0, TimeUnit.FIT));
|
|
||||||
}
|
|
||||||
else if (getDeathMatchTime() > 0)
|
|
||||||
{
|
|
||||||
Scoreboard.write(C.cRed + C.Bold + "Deathmatch");
|
|
||||||
Scoreboard.write(UtilTime.convertString(
|
|
||||||
Math.min(getDeathMatchTime(), isDeathMatchTeleported() ? 10 : getDeathMatchTime()) * 1000, 0, TimeUnit.FIT));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Scoreboard.write(C.cRed + C.Bold + "Game End");
|
|
||||||
Scoreboard.write(UtilTime.convertString(Math.max(0, getGameEndTime()) * 1000, 0, TimeUnit.FIT));
|
|
||||||
}
|
|
||||||
|
|
||||||
Scoreboard.draw();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void EndCheck()
|
|
||||||
{
|
|
||||||
if (!IsLive())
|
|
||||||
return;
|
|
||||||
|
|
||||||
ArrayList<GameTeam> teamsAlive = new ArrayList<GameTeam>();
|
|
||||||
|
|
||||||
for (GameTeam team : GetTeamList())
|
|
||||||
if (team.GetPlayers(true).size() > 0)
|
|
||||||
teamsAlive.add(team);
|
|
||||||
|
|
||||||
if (teamsAlive.size() <= 1)
|
|
||||||
{
|
|
||||||
//Announce
|
|
||||||
if (teamsAlive.size() > 0)
|
|
||||||
AnnounceEnd(teamsAlive.get(0));
|
|
||||||
|
|
||||||
for (GameTeam team : GetTeamList())
|
|
||||||
{
|
|
||||||
if (WinnerTeam != null && team.equals(WinnerTeam))
|
|
||||||
{
|
|
||||||
for (Player player : team.GetPlayers(false))
|
|
||||||
AddGems(player, 10, "Winning Team", false, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Player player : team.GetPlayers(false))
|
|
||||||
if (player.isOnline())
|
|
||||||
AddGems(player, 10, "Participation", false, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
//End
|
|
||||||
SetState(GameState.End);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Player> getWinners()
|
|
||||||
{
|
|
||||||
if (WinnerTeam == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return WinnerTeam.GetPlayers(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Player> getLosers()
|
|
||||||
{
|
|
||||||
if (WinnerTeam == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
List<Player> players = new ArrayList<>();
|
|
||||||
|
|
||||||
for (GameTeam team : GetTeamList())
|
|
||||||
{
|
|
||||||
if (team != WinnerTeam)
|
|
||||||
players.addAll(team.GetPlayers(false));
|
|
||||||
}
|
|
||||||
|
|
||||||
return players;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String GetMode()
|
|
||||||
{
|
|
||||||
return "Team Mode";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void deathmatchTeleport()
|
|
||||||
{
|
|
||||||
List<Location> spawns = GetTeamList().get(0).GetSpawns();
|
|
||||||
|
|
||||||
List<Player> spectators = GetPlayers(false);
|
|
||||||
|
|
||||||
List<Player> living = GetPlayers(true);
|
|
||||||
|
|
||||||
spectators.removeAll(living);
|
|
||||||
|
|
||||||
Location spectatorLocation = GetSpectatorLocation();
|
|
||||||
|
|
||||||
spectators.forEach(s -> s.teleport(spectatorLocation));
|
|
||||||
|
|
||||||
UtilPlayer.teleportUniform(living, spawns);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +1,20 @@
|
|||||||
package nautilus.game.arcade.game.games.survivalgames.kit;
|
package nautilus.game.arcade.game.games.survivalgames.kit;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
|
|
||||||
import nautilus.game.arcade.ArcadeManager;
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
import nautilus.game.arcade.game.games.smash.perks.skeleton.PerkBarrage;
|
import nautilus.game.arcade.game.games.smash.perks.skeleton.PerkBarrage;
|
||||||
import nautilus.game.arcade.kit.KitAvailability;
|
import nautilus.game.arcade.kit.KitAvailability;
|
||||||
import nautilus.game.arcade.kit.Perk;
|
import nautilus.game.arcade.kit.Perk;
|
||||||
import nautilus.game.arcade.kit.perks.PerkFletcher;
|
import nautilus.game.arcade.kit.perks.PerkFletcher;
|
||||||
|
import nautilus.game.arcade.kit.perks.PerkQuickshot;
|
||||||
|
|
||||||
public class KitArcher extends SurvivalGamesKit
|
public class KitArcher extends SurvivalGamesKit
|
||||||
{
|
{
|
||||||
@ -17,19 +23,35 @@ public class KitArcher extends SurvivalGamesKit
|
|||||||
"Passively crafts arrows from surrounding terrain.",
|
"Passively crafts arrows from surrounding terrain.",
|
||||||
"",
|
"",
|
||||||
receiveArrowString(1, 20, 3),
|
receiveArrowString(1, 20, 3),
|
||||||
"Charge Bow to use " + C.cGreen + "Barrage"
|
receiveItem("Bow", 1) + " 90 seconds " + C.cWhite + "into the game",
|
||||||
|
"Charge Bow to use " + C.cGreen + "Barrage",
|
||||||
|
click(true, "to fire a Quick Shot arrow")
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final Perk[] PERKS = {
|
private static final Perk[] PERKS = {
|
||||||
new PerkFletcher(20, 3, true),
|
new PerkFletcher(20, 3, true),
|
||||||
new PerkBarrage(5, 250, true, false),
|
new PerkBarrage(5, 250, true, false),
|
||||||
|
new PerkQuickshot("Quick Shot", 2, 30000, true)
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final ItemStack IN_HAND = new ItemStack(Material.BOW);
|
private static final ItemStack IN_HAND = new ItemStack(Material.BOW);
|
||||||
|
public static final ItemStack BOW = new ItemBuilder(Material.BOW)
|
||||||
|
.setTitle(C.cYellow + "Archer's Bow")
|
||||||
|
.build();
|
||||||
|
|
||||||
public KitArcher(ArcadeManager manager)
|
public KitArcher(ArcadeManager manager)
|
||||||
{
|
{
|
||||||
super(manager, "Archer", KitAvailability.Gem, DESCRIPTION, PERKS, IN_HAND);
|
super(manager, "Archer", KitAvailability.Gem, DESCRIPTION, PERKS, IN_HAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void playerDeath(PlayerDeathEvent event)
|
||||||
|
{
|
||||||
|
if (!HasKit(event.getEntity()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.getDrops().removeIf(itemStack -> itemStack.isSimilar(BOW));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,26 @@
|
|||||||
package nautilus.game.arcade.game.games.survivalgames.kit;
|
package nautilus.game.arcade.game.games.survivalgames.kit;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilEvent;
|
||||||
|
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||||
|
import mineplex.core.common.util.UtilTime;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
|
|
||||||
import nautilus.game.arcade.ArcadeManager;
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
import nautilus.game.arcade.kit.KitAvailability;
|
import nautilus.game.arcade.kit.KitAvailability;
|
||||||
import nautilus.game.arcade.kit.Perk;
|
import nautilus.game.arcade.kit.Perk;
|
||||||
import nautilus.game.arcade.kit.perks.PerkBackstab;
|
import nautilus.game.arcade.kit.perks.PerkBackstab;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
public class KitAssassin extends SurvivalGamesKit
|
public class KitAssassin extends SurvivalGamesKit
|
||||||
{
|
{
|
||||||
@ -17,6 +31,8 @@ public class KitAssassin extends SurvivalGamesKit
|
|||||||
"when you're 8 blocks away!",
|
"when you're 8 blocks away!",
|
||||||
"",
|
"",
|
||||||
"Deal " + C.cGreen + "+2" + C.cWhite + " damage from behind opponents.",
|
"Deal " + C.cGreen + "+2" + C.cWhite + " damage from behind opponents.",
|
||||||
|
"Fall damage reduced by " + C.cGreen + "50" + C.cWhite + "%.",
|
||||||
|
click(false, "your map to show the locations of all players.")
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final Perk[] PERKS = {
|
private static final Perk[] PERKS = {
|
||||||
@ -25,8 +41,44 @@ public class KitAssassin extends SurvivalGamesKit
|
|||||||
|
|
||||||
private static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD);
|
private static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD);
|
||||||
|
|
||||||
|
private static final long MAP_COOLDOWN = TimeUnit.SECONDS.toMillis(45);
|
||||||
|
private static final long MAP_TIME = TimeUnit.SECONDS.toMillis(5);
|
||||||
|
|
||||||
public KitAssassin(ArcadeManager manager)
|
public KitAssassin(ArcadeManager manager)
|
||||||
{
|
{
|
||||||
super(manager, "Assassin", KitAvailability.Gem, 5000, DESCRIPTION, PERKS, IN_HAND);
|
super(manager, "Assassin", KitAvailability.Gem, 5000, DESCRIPTION, PERKS, IN_HAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void fallDamage(CustomDamageEvent event)
|
||||||
|
{
|
||||||
|
Player damagee = event.GetDamageePlayer();
|
||||||
|
|
||||||
|
if (event.GetCause() != DamageCause.FALL || damagee == null || !HasKit(damagee))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.AddMod(GetName() + " Fall Damage", -event.GetDamage() / 2D);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void showMapPlayers(PlayerInteractEvent event)
|
||||||
|
{
|
||||||
|
if (!UtilEvent.isAction(event, ActionType.R))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
ItemStack itemStack = player.getItemInHand();
|
||||||
|
|
||||||
|
if (itemStack == null || itemStack.getType() != Material.MAP || !HasKit(player) || !Recharge.Instance.use(player, "Assassin's Eye", MAP_COOLDOWN, true, true))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.sendMessage(F.main("Game", "You can now see all players on your map for " + F.time(UtilTime.MakeStr(MAP_TIME)) + "."));
|
||||||
|
Recharge.Instance.useForce(player, "Show All Players", MAP_TIME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,8 @@ public class KitBrawler extends SurvivalGamesKit
|
|||||||
private static final String[] DESCRIPTION = {
|
private static final String[] DESCRIPTION = {
|
||||||
"Giant and muscular, easily smacks others around.",
|
"Giant and muscular, easily smacks others around.",
|
||||||
"",
|
"",
|
||||||
"Take " + C.cGreen + "75%" + C.cWhite + " knockback",
|
"Take " + C.cGreen + "85%" + C.cWhite + " knockback",
|
||||||
"Deal " + C.cGreen + "125%" + C.cWhite + " knockback",
|
"Deal " + C.cGreen + "115%" + C.cWhite + " knockback",
|
||||||
C.cYellow + "Right-Click" + C.cWhite + " with Sword/Axe to " + C.cGreen + "Ground Pound"
|
C.cYellow + "Right-Click" + C.cWhite + " with Sword/Axe to " + C.cGreen + "Ground Pound"
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
package nautilus.game.arcade.game.games.survivalgames.kit;
|
|
||||||
|
|
||||||
import nautilus.game.arcade.ArcadeManager;
|
|
||||||
import nautilus.game.arcade.kit.KitAvailability;
|
|
||||||
import nautilus.game.arcade.kit.Perk;
|
|
||||||
import nautilus.game.arcade.kit.perks.PerkLooter;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
public class KitLooter extends SurvivalGamesKit
|
|
||||||
{
|
|
||||||
|
|
||||||
private static final String[] DESCRIPTION = {
|
|
||||||
"Defeat your opponents with your swag loots!",
|
|
||||||
"",
|
|
||||||
"You find extra loot in chests.",
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
private static final Perk[] PERKS = {
|
|
||||||
new PerkLooter(),
|
|
||||||
};
|
|
||||||
|
|
||||||
private static final ItemStack IN_HAND = new ItemStack(Material.CHEST);
|
|
||||||
|
|
||||||
public KitLooter(ArcadeManager manager)
|
|
||||||
{
|
|
||||||
super(manager, "Looter", KitAvailability.Free, DESCRIPTION, PERKS, IN_HAND);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,13 +7,16 @@ import nautilus.game.arcade.kit.perks.PerkSkeletons;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
|
||||||
public class KitNecromancer extends SurvivalGamesKit
|
public class KitNecromancer extends SurvivalGamesKit
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final String[] DESCRIPTION = {
|
private static final String[] DESCRIPTION = {
|
||||||
"Harness the power of the dark arts.",
|
C.mBody + "Harness the power of the dark arts.",
|
||||||
"",
|
"",
|
||||||
"Killing an opponent summons a skeletal minion."
|
C.mBody + "Killing an opponent summons a skeletal minion.",
|
||||||
|
C.cYellow + "Right Click " + C.mBody + "a minion to access its inventory."
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final Perk[] PERKS = {
|
private static final Perk[] PERKS = {
|
||||||
|
@ -0,0 +1,163 @@
|
|||||||
|
package nautilus.game.arcade.game.games.survivalgames.kit.necroinventory;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Skeleton;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryInteractEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilItem;
|
||||||
|
import mineplex.core.lifetimes.ListenerComponent;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.kit.perks.PerkSkeletons;
|
||||||
|
|
||||||
|
public class NecroInventoryMenu extends ListenerComponent
|
||||||
|
{
|
||||||
|
private final Map<Player, NecroInventoryPage> _pageMap;
|
||||||
|
private final PerkSkeletons _perk;
|
||||||
|
|
||||||
|
public NecroInventoryMenu(PerkSkeletons perk)
|
||||||
|
{
|
||||||
|
_pageMap = new WeakHashMap<>();
|
||||||
|
_perk = perk;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openInventory(Player player, Skeleton minion)
|
||||||
|
{
|
||||||
|
NecroInventoryPage inventoryPage = new NecroInventoryPage(player, minion);
|
||||||
|
|
||||||
|
_pageMap.put(player, inventoryPage);
|
||||||
|
|
||||||
|
inventoryPage.openInventory();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean shouldCallInteract(InventoryInteractEvent event)
|
||||||
|
{
|
||||||
|
if (!(event.getWhoClicked() instanceof Player))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_pageMap.containsKey(event.getWhoClicked()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
NecroInventoryPage inventoryPage = _pageMap.get(event.getWhoClicked());
|
||||||
|
|
||||||
|
return inventoryPage.matchesInventory(event.getInventory());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void skeletonClick(PlayerInteractEntityEvent event)
|
||||||
|
{
|
||||||
|
if (event.getPlayer() == null || event.getRightClicked() == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(event.getRightClicked() instanceof Skeleton))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_perk.hasPerk(event.getPlayer()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Skeleton skeleton = (Skeleton) event.getRightClicked();
|
||||||
|
|
||||||
|
List<Skeleton> skeletons = _perk.getSkeletons(event.getPlayer());
|
||||||
|
|
||||||
|
if (skeletons == null || !skeletons.contains(skeleton))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack itemInHand = event.getPlayer().getItemInHand();
|
||||||
|
|
||||||
|
// Don't open the skeleton inventory if it's a weapon/fishing rod
|
||||||
|
if (UtilItem.isWeapon(itemInHand)
|
||||||
|
|| itemInHand.getType() == Material.FISHING_ROD
|
||||||
|
|| itemInHand.getType() == Material.BOW
|
||||||
|
|| itemInHand.getType() == Material.EGG
|
||||||
|
|| itemInHand.getType() == Material.SNOW_BALL)
|
||||||
|
{
|
||||||
|
event.getPlayer().sendMessage(F.main("Game", C.mBody + "You can't open a minion inventory with that item in your hand."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
openInventory(event.getPlayer(), skeleton);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deactivate()
|
||||||
|
{
|
||||||
|
super.deactivate();
|
||||||
|
_pageMap.values().forEach(NecroInventoryPage::cleanup);
|
||||||
|
_pageMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void inventoryClick(InventoryClickEvent event)
|
||||||
|
{
|
||||||
|
if (!shouldCallInteract(event))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NecroInventoryPage inventoryPage = _pageMap.get(event.getWhoClicked());
|
||||||
|
|
||||||
|
inventoryPage.inventoryClick(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void inventoryDrag(InventoryDragEvent event)
|
||||||
|
{
|
||||||
|
if (!shouldCallInteract(event))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NecroInventoryPage inventoryPage = _pageMap.get(event.getWhoClicked());
|
||||||
|
|
||||||
|
inventoryPage.inventoryDrag(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void inventoryClose(InventoryCloseEvent event)
|
||||||
|
{
|
||||||
|
if (event.getPlayer() == null || !(event.getPlayer() instanceof Player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_pageMap.containsKey(event.getPlayer()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NecroInventoryPage inventoryPage = _pageMap.get(event.getPlayer());
|
||||||
|
|
||||||
|
if (!inventoryPage.matchesInventory(event.getInventory()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_pageMap.remove(event.getPlayer());
|
||||||
|
inventoryPage.cleanup();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,374 @@
|
|||||||
|
package nautilus.game.arcade.game.games.survivalgames.kit.necroinventory;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Skeleton;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
import org.bukkit.event.inventory.InventoryAction;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
|
import org.bukkit.inventory.EntityEquipment;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilItem;
|
||||||
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
|
||||||
|
public class NecroInventoryPage
|
||||||
|
{
|
||||||
|
public enum EquipmentType
|
||||||
|
{
|
||||||
|
HELMET("Helmet"),
|
||||||
|
CHESTPLATE("Chestplate"),
|
||||||
|
LEGGINGS("Leggings"),
|
||||||
|
BOOTS("Boots"),
|
||||||
|
WEAPON("Weapon");
|
||||||
|
|
||||||
|
private String _name;
|
||||||
|
|
||||||
|
EquipmentType(String name)
|
||||||
|
{
|
||||||
|
_name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return _name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<Integer, EquipmentType> slots;
|
||||||
|
|
||||||
|
private Player _player;
|
||||||
|
private Skeleton _minion;
|
||||||
|
|
||||||
|
private Inventory _inventory;
|
||||||
|
|
||||||
|
public NecroInventoryPage(Player player, Skeleton minion)
|
||||||
|
{
|
||||||
|
slots = new HashMap<>();
|
||||||
|
slots.put(0, EquipmentType.HELMET);
|
||||||
|
slots.put(1, EquipmentType.CHESTPLATE);
|
||||||
|
slots.put(2, EquipmentType.LEGGINGS);
|
||||||
|
slots.put(3, EquipmentType.BOOTS);
|
||||||
|
slots.put(4, EquipmentType.WEAPON);
|
||||||
|
|
||||||
|
_player = player;
|
||||||
|
_minion = minion;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the player name, from "Skeletal PLAYERNAME"
|
||||||
|
private String getTitle()
|
||||||
|
{
|
||||||
|
return _minion.getCustomName().split(" ")[1] + " - Inventory";
|
||||||
|
}
|
||||||
|
|
||||||
|
private ItemStack getButtonEmpty(String inventoryType)
|
||||||
|
{
|
||||||
|
return new ItemBuilder(Material.STAINED_GLASS_PANE)
|
||||||
|
.setData(DyeColor.GRAY.getWoolData())
|
||||||
|
.setTitle(C.cRed + "No " + inventoryType + " equipped")
|
||||||
|
.addLore(C.mBody + "Drag an item onto this slot", "to equip it.")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ItemStack getButton(ItemStack stack, String inventoryType)
|
||||||
|
{
|
||||||
|
if (stack != null && stack.getType() != Material.AIR)
|
||||||
|
{
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
return getButtonEmpty(inventoryType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openInventory()
|
||||||
|
{
|
||||||
|
Inventory inventory = Bukkit.createInventory(_player, InventoryType.HOPPER, getTitle());
|
||||||
|
|
||||||
|
EntityEquipment equipment = _minion.getEquipment();
|
||||||
|
|
||||||
|
inventory.setItem(0, getButton(equipment.getHelmet(), slots.get(0).getName()));
|
||||||
|
inventory.setItem(1, getButton(equipment.getChestplate(), slots.get(1).getName()));
|
||||||
|
inventory.setItem(2, getButton(equipment.getLeggings(), slots.get(2).getName()));
|
||||||
|
inventory.setItem(3, getButton(equipment.getBoots(), slots.get(3).getName()));
|
||||||
|
inventory.setItem(4, getButton(equipment.getItemInHand(), slots.get(4).getName()));
|
||||||
|
|
||||||
|
_inventory = inventory;
|
||||||
|
|
||||||
|
_player.openInventory(inventory);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean matchesInventory(Inventory inventory)
|
||||||
|
{
|
||||||
|
return inventory != null && _inventory != null && inventory.equals(_inventory);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isValidItem(ItemStack item, EquipmentType equipmentType)
|
||||||
|
{
|
||||||
|
switch (equipmentType)
|
||||||
|
{
|
||||||
|
case HELMET:
|
||||||
|
return UtilItem.isHelmet(item);
|
||||||
|
case CHESTPLATE:
|
||||||
|
return UtilItem.isChestplate(item);
|
||||||
|
case LEGGINGS:
|
||||||
|
return UtilItem.isLeggings(item);
|
||||||
|
case BOOTS:
|
||||||
|
return UtilItem.isBoots(item);
|
||||||
|
case WEAPON:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setEquipment(ItemStack item, EquipmentType equipmentType)
|
||||||
|
{
|
||||||
|
EntityEquipment equipment = _minion.getEquipment();
|
||||||
|
|
||||||
|
switch (equipmentType)
|
||||||
|
{
|
||||||
|
case HELMET:
|
||||||
|
equipment.setHelmet(item);
|
||||||
|
break;
|
||||||
|
case CHESTPLATE:
|
||||||
|
equipment.setChestplate(item);
|
||||||
|
break;
|
||||||
|
case LEGGINGS:
|
||||||
|
equipment.setLeggings(item);
|
||||||
|
break;
|
||||||
|
case BOOTS:
|
||||||
|
equipment.setBoots(item);
|
||||||
|
break;
|
||||||
|
case WEAPON:
|
||||||
|
equipment.setItemInHand(item);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void equip(ItemStack item, int slot)
|
||||||
|
{
|
||||||
|
if (!slots.containsKey(slot))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_inventory.setItem(slot, item);
|
||||||
|
|
||||||
|
EquipmentType equipmentType = slots.get(slot);
|
||||||
|
|
||||||
|
setEquipment(item, equipmentType);
|
||||||
|
|
||||||
|
_player.sendMessage(F.main("Game", C.mBody + "Your minion equipped " + C.cYellow + ItemStackFactory.Instance.GetItemStackName(item) + C.mBody + "."));
|
||||||
|
_player.playSound(_player.getLocation(), Sound.HORSE_ARMOR, 1f, 1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void unequip(int slot)
|
||||||
|
{
|
||||||
|
if (!slots.containsKey(slot))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack old = _inventory.getItem(slot);
|
||||||
|
|
||||||
|
EquipmentType equipmentType = slots.get(slot);
|
||||||
|
|
||||||
|
_inventory.setItem(slot, getButtonEmpty(equipmentType.getName()));
|
||||||
|
|
||||||
|
ItemStack air = new ItemStack(Material.AIR);
|
||||||
|
|
||||||
|
setEquipment(air, equipmentType);
|
||||||
|
|
||||||
|
_player.sendMessage(F.main("Game", C.mBody + "Your minion unequipped " + C.cYellow + ItemStackFactory.Instance.GetItemStackName(old) + C.mBody + "."));
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isPickup(InventoryAction action)
|
||||||
|
{
|
||||||
|
return (action == InventoryAction.PICKUP_ALL || action == InventoryAction.PICKUP_HALF || action == InventoryAction.PICKUP_ONE || action == InventoryAction.PICKUP_SOME);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void playDeny(Player player)
|
||||||
|
{
|
||||||
|
player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, .6f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void inventoryClick(InventoryClickEvent event)
|
||||||
|
{
|
||||||
|
if (_inventory == null || event.getInventory() == null || event.getClickedInventory() == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!event.getInventory().equals(_inventory))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.getWhoClicked() == null || !(event.getWhoClicked() instanceof Player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = (Player) event.getWhoClicked();
|
||||||
|
|
||||||
|
if (!event.getClickedInventory().equals(_inventory))
|
||||||
|
{
|
||||||
|
// It's the player's inventory
|
||||||
|
if (event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY)
|
||||||
|
{
|
||||||
|
ItemStack shiftClickedItem = event.getClickedInventory().getItem(event.getSlot());
|
||||||
|
|
||||||
|
for (int slot : slots.keySet())
|
||||||
|
{
|
||||||
|
EquipmentType equipmentType = slots.get(slot);
|
||||||
|
|
||||||
|
if (isValidItem(shiftClickedItem, equipmentType))
|
||||||
|
{
|
||||||
|
if (_inventory.getItem(slot).getType() != Material.STAINED_GLASS_PANE)
|
||||||
|
{
|
||||||
|
player.getInventory().setItem(event.getSlot(), _inventory.getItem(slot));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.getInventory().setItem(event.getSlot(), new ItemStack(Material.AIR));
|
||||||
|
}
|
||||||
|
|
||||||
|
equip(shiftClickedItem, slot);
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
playDeny(player);
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isPlaceholder = _inventory.getItem(event.getSlot()).getType() == Material.STAINED_GLASS_PANE;
|
||||||
|
|
||||||
|
// If the user is picking up an item
|
||||||
|
// meaning they are NOT swapping one...
|
||||||
|
if (isPickup(event.getAction()))
|
||||||
|
{
|
||||||
|
// If it's a placeholder pane
|
||||||
|
// cancel it for obvious reasons
|
||||||
|
if (isPlaceholder)
|
||||||
|
{
|
||||||
|
playDeny(player);
|
||||||
|
}
|
||||||
|
// Otherwise it's OK to pick up,
|
||||||
|
// so unequip that item.
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_player.setItemOnCursor(_inventory.getItem(event.getSlot()));
|
||||||
|
unequip(event.getSlot());
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the player has an item in their cursor and is
|
||||||
|
// trying to swap it with something in the hopper inventory
|
||||||
|
if (event.getAction() == InventoryAction.SWAP_WITH_CURSOR)
|
||||||
|
{
|
||||||
|
// If the item in the player's
|
||||||
|
// cursor is allowed to go into
|
||||||
|
// that gear slot, put it in there.
|
||||||
|
if (isValidItem(event.getCursor(), slots.get(event.getSlot())))
|
||||||
|
{
|
||||||
|
equip(event.getCursor(), event.getSlot());
|
||||||
|
|
||||||
|
// Don't give them the placeholder item on their cursor...
|
||||||
|
if (!isPlaceholder)
|
||||||
|
{
|
||||||
|
player.setItemOnCursor(_inventory.getItem(event.getSlot()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.setItemOnCursor(new ItemStack(Material.AIR));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If the cursor is not empty,
|
||||||
|
// don't let the player do anything
|
||||||
|
// with it.
|
||||||
|
else if (event.getCursor() != null && event.getCursor().getType() != Material.AIR)
|
||||||
|
{
|
||||||
|
playDeny(player);
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Otherwise, let the item in the
|
||||||
|
// slot be unequipped because the
|
||||||
|
// cursor is empty.
|
||||||
|
else if (!isPlaceholder)
|
||||||
|
{
|
||||||
|
// Set cursor before unequipping so the item is still there
|
||||||
|
_player.setItemOnCursor(_inventory.getItem(event.getSlot()));
|
||||||
|
unequip(event.getSlot());
|
||||||
|
}
|
||||||
|
// It is a placeholder, so play the deny
|
||||||
|
else
|
||||||
|
{
|
||||||
|
playDeny(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shift clicking has odd behavior with ghosting items
|
||||||
|
// so just disable shift clicking items out of the hopper.
|
||||||
|
if (event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY)
|
||||||
|
{
|
||||||
|
_player.sendMessage(F.main("Game", "You can't use shift-click to unequip items."));
|
||||||
|
playDeny(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
// No clue what they're trying to do in my inventory,
|
||||||
|
// but I haven't caught it so just cancel the event.
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void inventoryDrag(InventoryDragEvent event)
|
||||||
|
{
|
||||||
|
if (_inventory == null || event.getInventory() == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!event.getInventory().equals(_inventory))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(event.getWhoClicked() instanceof Player) || event.getWhoClicked().equals(_player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cleanup()
|
||||||
|
{
|
||||||
|
_inventory = null;
|
||||||
|
}
|
||||||
|
}
|
@ -1,173 +0,0 @@
|
|||||||
package nautilus.game.arcade.game.games.survivalgames.modes;
|
|
||||||
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.UtilItem;
|
|
||||||
import mineplex.core.common.util.UtilMath;
|
|
||||||
import mineplex.core.common.util.UtilServer;
|
|
||||||
import mineplex.core.common.util.UtilTextBottom;
|
|
||||||
import mineplex.core.common.util.UtilTime;
|
|
||||||
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.Game.GameState;
|
|
||||||
import nautilus.game.arcade.game.games.smash.modes.kits.KitHipster;
|
|
||||||
import nautilus.game.arcade.game.games.survivalgames.SoloSurvivalGames;
|
|
||||||
import nautilus.game.arcade.game.games.survivalgames.kit.KitArcher;
|
|
||||||
import nautilus.game.arcade.game.games.survivalgames.kit.KitAssassin;
|
|
||||||
import nautilus.game.arcade.game.games.survivalgames.kit.KitAxeman;
|
|
||||||
import nautilus.game.arcade.game.games.survivalgames.kit.KitBarbarian;
|
|
||||||
import nautilus.game.arcade.game.games.survivalgames.kit.KitBeastmaster;
|
|
||||||
import nautilus.game.arcade.game.games.survivalgames.kit.KitBomber;
|
|
||||||
import nautilus.game.arcade.game.games.survivalgames.kit.KitBrawler;
|
|
||||||
import nautilus.game.arcade.game.games.survivalgames.kit.KitHorseman;
|
|
||||||
import nautilus.game.arcade.game.games.survivalgames.kit.KitKnight;
|
|
||||||
import nautilus.game.arcade.game.games.survivalgames.kit.KitNecromancer;
|
|
||||||
import nautilus.game.arcade.kit.Kit;
|
|
||||||
import nautilus.game.arcade.kit.Perk;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ChangingKits
|
|
||||||
*
|
|
||||||
* @author xXVevzZXx
|
|
||||||
*/
|
|
||||||
public class ChangingKits extends SoloSurvivalGames
|
|
||||||
{
|
|
||||||
private Kit[] _kits;
|
|
||||||
|
|
||||||
private long _lastChanged;
|
|
||||||
private int _changeInterval;
|
|
||||||
|
|
||||||
public ChangingKits(ArcadeManager manager)
|
|
||||||
{
|
|
||||||
super(manager, new Kit[]
|
|
||||||
{
|
|
||||||
new KitHipster(manager)
|
|
||||||
}, GameType.Brawl);
|
|
||||||
|
|
||||||
_kits = new Kit[]
|
|
||||||
{
|
|
||||||
new KitAxeman(manager),
|
|
||||||
|
|
||||||
// new KitLooter(manager),
|
|
||||||
|
|
||||||
new KitKnight(manager),
|
|
||||||
|
|
||||||
new KitArcher(manager),
|
|
||||||
|
|
||||||
new KitBrawler(manager),
|
|
||||||
|
|
||||||
new KitAssassin(manager),
|
|
||||||
|
|
||||||
new KitBeastmaster(manager),
|
|
||||||
|
|
||||||
new KitBomber(manager),
|
|
||||||
|
|
||||||
new KitNecromancer(manager),
|
|
||||||
|
|
||||||
new KitBarbarian(manager),
|
|
||||||
};
|
|
||||||
|
|
||||||
_lastChanged = 0;
|
|
||||||
_changeInterval = 60;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void countdown(UpdateEvent event)
|
|
||||||
{
|
|
||||||
if (!IsLive())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.getType() == UpdateType.SEC)
|
|
||||||
{
|
|
||||||
if (System.currentTimeMillis() > _lastChanged + 25000)
|
|
||||||
{
|
|
||||||
for (Player player : UtilServer.getPlayers())
|
|
||||||
{
|
|
||||||
player.playSound(player.getLocation(), Sound.NOTE_PLING, 2F, 2F);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.getType() != UpdateType.TICK)
|
|
||||||
return;
|
|
||||||
|
|
||||||
double percentage = (double) (System.currentTimeMillis() - _lastChanged) / (_changeInterval*1000);
|
|
||||||
|
|
||||||
for (Player player : UtilServer.getPlayers())
|
|
||||||
{
|
|
||||||
UtilTextBottom.displayProgress("New Kit", percentage,
|
|
||||||
UtilTime.MakeStr(Math.max(0, (_changeInterval*1000) - (System.currentTimeMillis() - _lastChanged))), player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void KitRegister(GameStateChangeEvent event)
|
|
||||||
{
|
|
||||||
if (event.GetState() != event.GetGame().KitRegisterState)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (Kit kit : _kits)
|
|
||||||
{
|
|
||||||
UtilServer.getServer().getPluginManager().registerEvents(kit, Manager.getPlugin());
|
|
||||||
|
|
||||||
for (Perk perk : kit.GetPerks())
|
|
||||||
{
|
|
||||||
UtilServer.getServer().getPluginManager().registerEvents(perk, Manager.getPlugin());
|
|
||||||
perk.registeredEvents();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void end(GameStateChangeEvent event)
|
|
||||||
{
|
|
||||||
if (event.GetState() != GameState.Dead)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (Kit kit : _kits)
|
|
||||||
{
|
|
||||||
HandlerList.unregisterAll(kit);
|
|
||||||
|
|
||||||
for (Perk perk : kit.GetPerks())
|
|
||||||
{
|
|
||||||
HandlerList.unregisterAll(perk);
|
|
||||||
perk.unregisteredEvents();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void kitSwitch(UpdateEvent event)
|
|
||||||
{
|
|
||||||
if (event.getType() != UpdateType.SEC)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!IsLive())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!UtilTime.elapsed(_lastChanged, _changeInterval*1000))
|
|
||||||
return;
|
|
||||||
|
|
||||||
_lastChanged = System.currentTimeMillis();
|
|
||||||
|
|
||||||
for (Player player : GetPlayers(true))
|
|
||||||
{
|
|
||||||
Kit kit = _kits[UtilMath.r(_kits.length)];
|
|
||||||
SetKit((Player) player, kit, true, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String GetMode()
|
|
||||||
{
|
|
||||||
return "Changing Kits";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,321 +0,0 @@
|
|||||||
package nautilus.game.arcade.game.games.survivalgames.modes;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.Chest;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.F;
|
|
||||||
import mineplex.core.common.util.UtilMath;
|
|
||||||
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.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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* OverpoweredSurvival gammeode for Survivalgames
|
|
||||||
*
|
|
||||||
* @author xXVevzZXx
|
|
||||||
*/
|
|
||||||
public class OverpoweredSurvival extends SoloSurvivalGames
|
|
||||||
{
|
|
||||||
|
|
||||||
public OverpoweredSurvival(ArcadeManager manager)
|
|
||||||
{
|
|
||||||
super(manager, GameType.Brawl);
|
|
||||||
|
|
||||||
new AbsorptionFix(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
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.APPLE, 30));
|
|
||||||
|
|
||||||
// Weapons
|
|
||||||
getBaseLoot().addLoot(new RandomItem(Material.DIAMOND_AXE, 80));
|
|
||||||
getBaseLoot().addLoot(new RandomItem(Material.DIAMOND_SWORD, 70));
|
|
||||||
getBaseLoot().addLoot(new RandomItem(Material.IRON_AXE, 40));
|
|
||||||
getBaseLoot().addLoot(new RandomItem(Material.IRON_SWORD, 35));
|
|
||||||
|
|
||||||
// armor
|
|
||||||
getBaseLoot().addLoot(new RandomItem(Material.DIAMOND_BOOTS, 35));
|
|
||||||
getBaseLoot().addLoot(new RandomItem(Material.DIAMOND_CHESTPLATE, 35));
|
|
||||||
getBaseLoot().addLoot(new RandomItem(Material.DIAMOND_HELMET, 35));
|
|
||||||
getBaseLoot().addLoot(new RandomItem(Material.DIAMOND_LEGGINGS, 35));
|
|
||||||
|
|
||||||
getBaseLoot().addLoot(new RandomItem(Material.IRON_BOOTS, 15));
|
|
||||||
getBaseLoot().addLoot(new RandomItem(Material.IRON_CHESTPLATE, 15));
|
|
||||||
getBaseLoot().addLoot(new RandomItem(Material.IRON_HELMET, 15));
|
|
||||||
getBaseLoot().addLoot(new RandomItem(Material.IRON_LEGGINGS, 15));
|
|
||||||
|
|
||||||
// Throwable
|
|
||||||
getBaseLoot().addLoot(new RandomItem(Material.FISHING_ROD, 30));
|
|
||||||
getBaseLoot().addLoot(new RandomItem(Material.BOW, 20));
|
|
||||||
getBaseLoot().addLoot(new RandomItem(Material.ARROW, 40, 4, 12));
|
|
||||||
|
|
||||||
// Misc
|
|
||||||
getBaseLoot().addLoot(new RandomItem(Material.EXP_BOTTLE, 40, 5, 20));
|
|
||||||
getBaseLoot().addLoot(new RandomItem(Material.COMPASS, 20));
|
|
||||||
getBaseLoot().addLoot(new RandomItem(Material.STICK, 30, 1, 2));
|
|
||||||
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));
|
|
||||||
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().addLoot(new RandomItem(Material.BAKED_POTATO, 30, 1, 3));
|
|
||||||
getSpawnLoot().addLoot(new RandomItem(Material.COOKED_BEEF, 30, 1, 2));
|
|
||||||
getSpawnLoot().addLoot(new RandomItem(Material.COOKED_CHICKEN, 30, 1, 2));
|
|
||||||
getSpawnLoot().addLoot(new RandomItem(Material.MUSHROOM_SOUP, 15, 1, 1));
|
|
||||||
getSpawnLoot().addLoot(new RandomItem(Material.APPLE, 30));
|
|
||||||
|
|
||||||
getSpawnLoot().addLoot(new RandomItem(Material.IRON_BOOTS, 15));
|
|
||||||
getSpawnLoot().addLoot(new RandomItem(Material.IRON_CHESTPLATE, 15));
|
|
||||||
getSpawnLoot().addLoot(new RandomItem(Material.IRON_HELMET, 15));
|
|
||||||
getSpawnLoot().addLoot(new RandomItem(Material.IRON_LEGGINGS, 15));
|
|
||||||
// Loot for chests in spawn
|
|
||||||
// Weaponry and ores
|
|
||||||
getSpawnLoot().addLoot(new RandomItem(Material.IRON_SWORD, 30));
|
|
||||||
getSpawnLoot().addLoot(new RandomItem(Material.IRON_AXE, 30));
|
|
||||||
getSpawnLoot().addLoot(new RandomItem(Material.DIAMOND, 30, 3, 6));
|
|
||||||
|
|
||||||
// Supply crate loot
|
|
||||||
int e = 4;
|
|
||||||
for (int i = 1; i < 4; i++)
|
|
||||||
{
|
|
||||||
getCrateLoot().addLoot(new RandomItem(
|
|
||||||
ItemStackFactory.Instance.CreateStack(Material.DIAMOND_HELMET.getId(), (byte) 0,
|
|
||||||
1, (short) 0, null, Arrays.asList(new String[] {}), null, false, i,
|
|
||||||
Enchantment.PROTECTION_ENVIRONMENTAL),
|
|
||||||
e * 10));
|
|
||||||
getCrateLoot().addLoot(new RandomItem(
|
|
||||||
ItemStackFactory.Instance.CreateStack(Material.DIAMOND_CHESTPLATE.getId(),
|
|
||||||
(byte) 0, 1, (short) 0, null, Arrays.asList(new String[] {}), null,
|
|
||||||
false, i, Enchantment.PROTECTION_ENVIRONMENTAL),
|
|
||||||
e * 10));
|
|
||||||
getCrateLoot().addLoot(new RandomItem(
|
|
||||||
ItemStackFactory.Instance.CreateStack(Material.DIAMOND_LEGGINGS.getId(),
|
|
||||||
(byte) 0, 1, (short) 0, null, Arrays.asList(new String[] {}), null,
|
|
||||||
false, i, Enchantment.PROTECTION_ENVIRONMENTAL),
|
|
||||||
e * 10));
|
|
||||||
getCrateLoot().addLoot(new RandomItem(
|
|
||||||
ItemStackFactory.Instance.CreateStack(Material.DIAMOND_BOOTS.getId(), (byte) 0,
|
|
||||||
1, (short) 0, null, Arrays.asList(new String[] {}), null, false, i,
|
|
||||||
Enchantment.PROTECTION_ENVIRONMENTAL),
|
|
||||||
e * 10));
|
|
||||||
|
|
||||||
getCrateLoot().addLoot(new RandomItem(
|
|
||||||
ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD.getId(), (byte) 0,
|
|
||||||
1, (short) 0, null, Arrays.asList(new String[] {}), null, false, i,
|
|
||||||
Enchantment.DAMAGE_ALL),
|
|
||||||
e * 10));
|
|
||||||
getCrateLoot().addLoot(new RandomItem(
|
|
||||||
ItemStackFactory.Instance.CreateStack(Material.DIAMOND_AXE.getId(), (byte) 0, 1,
|
|
||||||
(short) 0, null, Arrays.asList(new String[] {}), null, false, i,
|
|
||||||
Enchantment.DAMAGE_ALL),
|
|
||||||
e * 10));
|
|
||||||
|
|
||||||
getCrateLoot().addLoot(new RandomItem(
|
|
||||||
ItemStackFactory.Instance.CreateStack(Material.IRON_HELMET.getId(), (byte) 0, 1,
|
|
||||||
(short) 0, null, Arrays.asList(new String[] {}), null, false, i,
|
|
||||||
Enchantment.PROTECTION_ENVIRONMENTAL),
|
|
||||||
e * 3));
|
|
||||||
getCrateLoot().addLoot(new RandomItem(
|
|
||||||
ItemStackFactory.Instance.CreateStack(Material.IRON_CHESTPLATE.getId(),
|
|
||||||
(byte) 0, 1, (short) 0, null, Arrays.asList(new String[] {}), null,
|
|
||||||
false, i, Enchantment.PROTECTION_ENVIRONMENTAL),
|
|
||||||
e * 3));
|
|
||||||
getCrateLoot().addLoot(new RandomItem(
|
|
||||||
ItemStackFactory.Instance.CreateStack(Material.IRON_LEGGINGS.getId(), (byte) 0,
|
|
||||||
1, (short) 0, null, Arrays.asList(new String[] {}), null, false, i,
|
|
||||||
Enchantment.PROTECTION_ENVIRONMENTAL),
|
|
||||||
e * 3));
|
|
||||||
getCrateLoot().addLoot(new RandomItem(
|
|
||||||
ItemStackFactory.Instance.CreateStack(Material.IRON_BOOTS.getId(), (byte) 0, 1,
|
|
||||||
(short) 0, null, Arrays.asList(new String[] {}), null, false, i,
|
|
||||||
Enchantment.PROTECTION_ENVIRONMENTAL),
|
|
||||||
e * 3));
|
|
||||||
|
|
||||||
getCrateLoot().addLoot(new RandomItem(
|
|
||||||
ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD.getId(), (byte) 0, 1,
|
|
||||||
(short) 0, null, Arrays.asList(new String[] {}), null, false, i,
|
|
||||||
Enchantment.DAMAGE_ALL),
|
|
||||||
e * 3));
|
|
||||||
getCrateLoot().addLoot(
|
|
||||||
new RandomItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE.getId(),
|
|
||||||
(byte) 0, 1, (short) 0, null, Arrays.asList(new String[] {}), null,
|
|
||||||
false, i, Enchantment.DAMAGE_ALL), e * 3));
|
|
||||||
e--;
|
|
||||||
}
|
|
||||||
// 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.DIAMOND_AXE, 3));
|
|
||||||
getDeathMatch().addLoot(new RandomItem(Material.DIAMOND_SWORD, 3));
|
|
||||||
}
|
|
||||||
|
|
||||||
@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);
|
|
||||||
}
|
|
||||||
|
|
||||||
chest.getBlockInventory().setItem(UtilMath.r(27), item);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getSupplyBlocks().contains(block))
|
|
||||||
{
|
|
||||||
Bukkit.getPluginManager().callEvent(new SupplyChestOpenEvent(looter, block));
|
|
||||||
}
|
|
||||||
|
|
||||||
getSupplyBlocks().remove(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setupChestsEnchantingCrafting()
|
|
||||||
{
|
|
||||||
ArrayList<Location> chests = WorldData.GetCustomLocs("54");
|
|
||||||
|
|
||||||
System.out.println("Map Chest Locations: " + chests.size());
|
|
||||||
|
|
||||||
// Enchants
|
|
||||||
System.out.println("Enchanting Tables: " + Math.min(5, chests.size()));
|
|
||||||
for (int i = 0; i < 5 && !chests.isEmpty(); i++)
|
|
||||||
{
|
|
||||||
Location loc = chests.remove(UtilMath.r(chests.size()));
|
|
||||||
loc.getBlock().setType(Material.ENCHANTMENT_TABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Crafting
|
|
||||||
System.out.println("Crafting Benches: " + Math.min(10, chests.size()));
|
|
||||||
for (int i = 0; i < 10 && !chests.isEmpty(); i++)
|
|
||||||
{
|
|
||||||
Location loc = chests.remove(UtilMath.r(chests.size()));
|
|
||||||
loc.getBlock().setType(Material.WORKBENCH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
|
||||||
public void StartEffectApply(GameStateChangeEvent event)
|
|
||||||
{
|
|
||||||
if (event.GetState() != GameState.Live)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (Player player : GetPlayers(true))
|
|
||||||
{
|
|
||||||
Manager.GetCondition().Factory().HealthBoost("Start Health", player, player, 30, 3,
|
|
||||||
false, false, false);
|
|
||||||
|
|
||||||
player.setHealth(player.getMaxHealth());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String GetMode()
|
|
||||||
{
|
|
||||||
return "OP Survival Games";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,385 +0,0 @@
|
|||||||
package nautilus.game.arcade.game.games.survivalgames.modes;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.F;
|
|
||||||
import mineplex.core.common.util.UtilEvent;
|
|
||||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
|
||||||
import mineplex.core.common.util.UtilItem;
|
|
||||||
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.minestrike.GunModule;
|
|
||||||
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.game.modules.StrikeGamesModule;
|
|
||||||
import nautilus.game.arcade.kit.Kit;
|
|
||||||
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.entity.ItemSpawnEvent;
|
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* StrikeGames
|
|
||||||
*
|
|
||||||
* @author xXVevzZXx
|
|
||||||
*/
|
|
||||||
public class StrikeGames extends SoloSurvivalGames
|
|
||||||
{
|
|
||||||
|
|
||||||
private long _peacePhase;
|
|
||||||
private boolean _peace = false;
|
|
||||||
|
|
||||||
public StrikeGames(ArcadeManager manager)
|
|
||||||
{
|
|
||||||
super(manager, new Kit[]
|
|
||||||
{
|
|
||||||
new KitPlayer(manager)
|
|
||||||
}, GameType.StrikeGames);
|
|
||||||
|
|
||||||
Damage = false;
|
|
||||||
|
|
||||||
_peacePhase = 20000;
|
|
||||||
|
|
||||||
HungerSet = 20;
|
|
||||||
|
|
||||||
GunModule gunModule = new GunModule(this);
|
|
||||||
gunModule.EnableCleaning = false;
|
|
||||||
gunModule.EnableDrop = false;
|
|
||||||
gunModule.EnablePickup = false;
|
|
||||||
gunModule.BlockRegeneration = false;
|
|
||||||
gunModule.EnableNormalArmor = true;
|
|
||||||
|
|
||||||
new StrikeGamesModule(gunModule)
|
|
||||||
.register(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!"));
|
|
||||||
Damage = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
|
||||||
public void DeathmatchDamage(UpdateEvent event)
|
|
||||||
{
|
|
||||||
if (event.getType() != UpdateType.FAST)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!isDeathMatchTeleported())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (getDeathMatchTime() <= 0)
|
|
||||||
{
|
|
||||||
Damage = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Damage = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@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 disableCrafting(PlayerInteractEvent event)
|
|
||||||
{
|
|
||||||
if (!UtilEvent.isAction(event, ActionType.R_BLOCK))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.getClickedBlock().getType() == Material.WORKBENCH)
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setupLoot()
|
|
||||||
{
|
|
||||||
// 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.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());
|
|
||||||
|
|
||||||
// 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));
|
|
||||||
|
|
||||||
// Deathmatch Loot
|
|
||||||
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
|
|
||||||
@Override
|
|
||||||
public void ItemSpawn(ItemSpawnEvent event)
|
|
||||||
{
|
|
||||||
if (event.getEntity().getItemStack().hasItemMeta())
|
|
||||||
return;
|
|
||||||
|
|
||||||
Material mat = event.getEntity().getItemStack().getType();
|
|
||||||
|
|
||||||
switch (mat)
|
|
||||||
{
|
|
||||||
case SEEDS:
|
|
||||||
case SAPLING:
|
|
||||||
case VINE:
|
|
||||||
case LEAVES:
|
|
||||||
case LONG_GRASS:
|
|
||||||
case RED_ROSE:
|
|
||||||
case YELLOW_FLOWER:
|
|
||||||
case DEAD_BUSH:
|
|
||||||
case WATER_LILY:
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
case CARROT_ITEM:
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
case POTATO_ITEM:
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
case WHEAT:
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
case WOOD:
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Player player : GetPlayers(true))
|
|
||||||
if (UtilMath.offset(player, event.getEntity()) < 6)
|
|
||||||
return;
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String GetMode()
|
|
||||||
{
|
|
||||||
return "Strike Games";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,376 +0,0 @@
|
|||||||
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
|
|
||||||
*
|
|
||||||
* @author xXVevzZXx
|
|
||||||
*/
|
|
||||||
public class UHCSurvivalgames extends SoloSurvivalGames
|
|
||||||
{
|
|
||||||
|
|
||||||
private long _peacePhase;
|
|
||||||
private boolean _peace;
|
|
||||||
|
|
||||||
public UHCSurvivalgames(ArcadeManager manager)
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
if (event.GetState() != GameState.Prepare)
|
|
||||||
return;
|
|
||||||
else if (event.GetState() != GameState.Live)
|
|
||||||
getCrateLoot().addLoot(new RandomItem(new ItemStack(Material.GOLDEN_APPLE), 100));
|
|
||||||
|
|
||||||
Objective objective = Scoreboard.getScoreboard().registerNewObjective("Health", "health");
|
|
||||||
objective.setDisplaySlot(DisplaySlot.PLAYER_LIST);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void regenHealth(EntityRegainHealthEvent event)
|
|
||||||
{
|
|
||||||
if (event.getRegainReason() == RegainReason.SATIATED)
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void gappleDrop(EntityDeathEvent event)
|
|
||||||
{
|
|
||||||
if (event.getEntity() instanceof Player)
|
|
||||||
{
|
|
||||||
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 Survivalgames";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
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)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
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)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,123 @@
|
|||||||
|
package nautilus.game.arcade.game.games.survivalgames.modules;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.WorldBorder;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
|
import nautilus.game.arcade.events.PlayerDeathOutEvent;
|
||||||
|
import nautilus.game.arcade.game.Game;
|
||||||
|
import nautilus.game.arcade.game.Game.GameState;
|
||||||
|
import nautilus.game.arcade.game.modules.Module;
|
||||||
|
|
||||||
|
public class BorderModule extends Module
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final int RATE_CONSTANT = 60;
|
||||||
|
private static final int PLAYER_CONSTANT = 24;
|
||||||
|
|
||||||
|
private double _initialBorder, _initialPlayers, _deathmatchSize = 61;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setup()
|
||||||
|
{
|
||||||
|
Game game = getGame();
|
||||||
|
Location center = game.GetSpectatorLocation();
|
||||||
|
List<Double> borders = Arrays.asList
|
||||||
|
(
|
||||||
|
game.WorldData.MaxX - center.getX(),
|
||||||
|
center.getX() - game.WorldData.MinX,
|
||||||
|
game.WorldData.MaxZ - center.getZ(),
|
||||||
|
center.getZ() - game.WorldData.MinZ
|
||||||
|
);
|
||||||
|
|
||||||
|
borders.sort(Comparator.naturalOrder());
|
||||||
|
double largestBorder = borders.get(borders.size() - 1);
|
||||||
|
WorldBorder border = game.WorldData.World.getWorldBorder();
|
||||||
|
|
||||||
|
_initialBorder = largestBorder * 2;
|
||||||
|
border.setCenter(center);
|
||||||
|
border.setSize(_initialBorder);
|
||||||
|
border.setDamageAmount(0.1);
|
||||||
|
border.setDamageBuffer(0);
|
||||||
|
border.setWarningDistance(10);
|
||||||
|
|
||||||
|
List<Location> deathmatchPoint = game.WorldData.GetDataLocs("BROWN");
|
||||||
|
|
||||||
|
if (!deathmatchPoint.isEmpty())
|
||||||
|
{
|
||||||
|
_deathmatchSize = UtilMath.offset(center, deathmatchPoint.get(0)) * 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void live(GameStateChangeEvent event)
|
||||||
|
{
|
||||||
|
if (event.GetState() != GameState.Live)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int players = getGame().GetPlayers(true).size();
|
||||||
|
_initialPlayers = players;
|
||||||
|
updateBorderSize(players);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void end(GameStateChangeEvent event)
|
||||||
|
{
|
||||||
|
if (event.GetState() != GameState.End)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
getGame().WorldData.World.getWorldBorder().setSize(Integer.MAX_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void playerDeathOut(PlayerDeathOutEvent event)
|
||||||
|
{
|
||||||
|
if (event.isCancelled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateBorderSize(getGame().GetPlayers(true).size() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateBorderSize(int players)
|
||||||
|
{
|
||||||
|
WorldBorder border = getGame().WorldData.World.getWorldBorder();
|
||||||
|
|
||||||
|
border.setSize(border.getSize());
|
||||||
|
border.setSize(_deathmatchSize, (long) ((border.getSize() / _initialBorder) * (players * (PLAYER_CONSTANT / _initialPlayers)) * RATE_CONSTANT));
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void borderDamage(CustomDamageEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.GetDamageePlayer();
|
||||||
|
|
||||||
|
if (event.GetCause() != DamageCause.SUFFOCATION || player == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.SetCancelled("Border Pre-Event");
|
||||||
|
if (Recharge.Instance.use(player, "World Border Damage", 1000, false, false))
|
||||||
|
{
|
||||||
|
getGame().getArcadeManager().GetDamage().NewDamageEvent(event.GetDamageeEntity(), null, null, DamageCause.CUSTOM, 2, false, true, true, getGame().GetName(), "World Border");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,96 @@
|
|||||||
|
package nautilus.game.arcade.game.games.survivalgames.modules;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.Furnace;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.inventory.FurnaceInventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilAlg;
|
||||||
|
import mineplex.core.common.util.UtilEvent;
|
||||||
|
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.events.ChestRefillEvent;
|
||||||
|
import nautilus.game.arcade.game.modules.Module;
|
||||||
|
|
||||||
|
public class FurnaceLootModule extends Module
|
||||||
|
{
|
||||||
|
|
||||||
|
private final Set<Block> _lootedBlocks;
|
||||||
|
private final List<ItemStack> _rawLoot = Arrays.asList
|
||||||
|
(
|
||||||
|
new ItemStack(Material.RAW_BEEF),
|
||||||
|
new ItemStack(Material.RAW_CHICKEN),
|
||||||
|
new ItemStack(Material.RAW_FISH),
|
||||||
|
new ItemStack(Material.PORK),
|
||||||
|
new ItemStack(Material.POTATO_ITEM)
|
||||||
|
);
|
||||||
|
private final List<ItemStack> _cookedLoot = Arrays.asList
|
||||||
|
(
|
||||||
|
new ItemStack(Material.COOKED_BEEF),
|
||||||
|
new ItemStack(Material.COOKED_CHICKEN),
|
||||||
|
new ItemStack(Material.COOKED_FISH),
|
||||||
|
new ItemStack(Material.GRILLED_PORK),
|
||||||
|
new ItemStack(Material.BAKED_POTATO),
|
||||||
|
new ItemStack(Material.BAKED_POTATO),
|
||||||
|
new ItemStack(Material.IRON_INGOT)
|
||||||
|
);
|
||||||
|
|
||||||
|
public FurnaceLootModule()
|
||||||
|
{
|
||||||
|
_lootedBlocks = new HashSet<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void furnaceInteract(PlayerInteractEvent event)
|
||||||
|
{
|
||||||
|
if (!UtilEvent.isAction(event, ActionType.R_BLOCK) || !getGame().IsLive())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Block block = event.getClickedBlock();
|
||||||
|
|
||||||
|
if (block.getType() != Material.FURNACE || !_lootedBlocks.add(block))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Furnace furnace = ((Furnace) block.getState());
|
||||||
|
|
||||||
|
if (furnace.getCookTime() != 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FurnaceInventory inventory = furnace.getInventory();
|
||||||
|
int random = UtilMath.r(9);
|
||||||
|
|
||||||
|
if (random == 0)
|
||||||
|
{
|
||||||
|
inventory.setFuel(new ItemStack(Material.STICK, UtilMath.r(2) + 1));
|
||||||
|
}
|
||||||
|
else if (random <= 3)
|
||||||
|
{
|
||||||
|
inventory.setSmelting(UtilAlg.Random(_rawLoot));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inventory.setResult(UtilAlg.Random(_cookedLoot));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void chestRefill(ChestRefillEvent event)
|
||||||
|
{
|
||||||
|
_lootedBlocks.clear();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,348 @@
|
|||||||
|
package nautilus.game.arcade.game.games.survivalgames.modules;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Color;
|
||||||
|
import org.bukkit.FireworkEffect;
|
||||||
|
import org.bukkit.FireworkEffect.Type;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEnderDragon;
|
||||||
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
||||||
|
import org.bukkit.entity.EnderDragon;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
import mineplex.core.blockrestore.BlockRestore;
|
||||||
|
import mineplex.core.common.Pair;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.MapUtil;
|
||||||
|
import mineplex.core.common.util.UtilAlg;
|
||||||
|
import mineplex.core.common.util.UtilBlock;
|
||||||
|
import mineplex.core.common.util.UtilEnt;
|
||||||
|
import mineplex.core.common.util.UtilEvent;
|
||||||
|
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||||
|
import mineplex.core.common.util.UtilFirework;
|
||||||
|
import mineplex.core.common.util.UtilItem;
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilTime;
|
||||||
|
import mineplex.core.treasure.util.TreasureUtil;
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.game.modules.Module;
|
||||||
|
|
||||||
|
public class SupplyDropModule extends Module
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final int TIME = 14000;
|
||||||
|
private static final long DURATION = TimeUnit.SECONDS.toMillis(60);
|
||||||
|
private static final int HEIGHT = 40;
|
||||||
|
private static final int RADIUS = 8;
|
||||||
|
private static final int POINTS = 80;
|
||||||
|
private static final FireworkEffect FIREWORK_EFFECT = FireworkEffect.builder()
|
||||||
|
.with(Type.BURST)
|
||||||
|
.withColor(Color.YELLOW)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
private static final int[][] LOOT_CONFIGURATIONS =
|
||||||
|
{
|
||||||
|
{
|
||||||
|
1, 1, 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
1, 1, 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
1, 2, 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
2, 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
2, 3
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private final ImmutableMap<Integer, List<ItemStack>> _lootTable;
|
||||||
|
private final Inventory _chestInventory;
|
||||||
|
private SupplyDrop _supplyDrop;
|
||||||
|
private Block _lastBlock;
|
||||||
|
private boolean _firstOpening;
|
||||||
|
|
||||||
|
public SupplyDropModule()
|
||||||
|
{
|
||||||
|
_lootTable = ImmutableMap.<Integer, List<ItemStack>>builder()
|
||||||
|
.put(1, Lists.newArrayList
|
||||||
|
(
|
||||||
|
new ItemStack(Material.IRON_BOOTS),
|
||||||
|
new ItemStack(Material.IRON_SWORD),
|
||||||
|
new ItemStack(Material.DIAMOND_AXE)
|
||||||
|
))
|
||||||
|
.put(2, Lists.newArrayList
|
||||||
|
(
|
||||||
|
new ItemStack(Material.IRON_CHESTPLATE),
|
||||||
|
new ItemStack(Material.IRON_LEGGINGS),
|
||||||
|
new ItemStack(Material.DIAMOND_HELMET),
|
||||||
|
new ItemStack(Material.DIAMOND_BOOTS)
|
||||||
|
))
|
||||||
|
.put(3, Lists.newArrayList
|
||||||
|
(
|
||||||
|
new ItemStack(Material.DIAMOND_CHESTPLATE),
|
||||||
|
new ItemStack(Material.DIAMOND_LEGGINGS),
|
||||||
|
new ItemStack(Material.DIAMOND_SWORD)
|
||||||
|
))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
_chestInventory = Bukkit.createInventory(null, 27, "Supply Drop");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cleanup()
|
||||||
|
{
|
||||||
|
_chestInventory.clear();
|
||||||
|
_supplyDrop = null;
|
||||||
|
_lastBlock = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void update(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.TICK || !getGame().IsLive())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_supplyDrop == null)
|
||||||
|
{
|
||||||
|
if (getGame().WorldTimeSet > TIME && getGame().WorldTimeSet < TIME + 1000)
|
||||||
|
{
|
||||||
|
Location location = getRandom();
|
||||||
|
|
||||||
|
if (location == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockRestore restore = getGame().getArcadeManager().GetBlockRestore();
|
||||||
|
long duration = DURATION + TimeUnit.SECONDS.toMillis(10);
|
||||||
|
for (Pair<Location, Pair<Material, Byte>> pair : UtilBlock.getBeaconBlocks(location, (byte) 4))
|
||||||
|
{
|
||||||
|
restore.add(pair.getLeft().getBlock(), pair.getRight().getLeft().getId(), pair.getRight().getRight(), duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
getGame().CreatureAllowOverride = true;
|
||||||
|
|
||||||
|
LivingEntity entity = location.getWorld().spawn(location.add(0, HEIGHT, 0), EnderDragon.class);
|
||||||
|
|
||||||
|
entity.setRemoveWhenFarAway(false);
|
||||||
|
UtilEnt.setTickWhenFarAway(entity, true);
|
||||||
|
UtilEnt.vegetate(entity, true);
|
||||||
|
UtilEnt.ghost(entity, true, false);
|
||||||
|
|
||||||
|
getGame().CreatureAllowOverride = false;
|
||||||
|
|
||||||
|
getGame().Announce(C.cRedB + "A Supply Drop has appeared at " + C.cWhite + "(" + location.getBlockX() + ", " + location.getBlockZ() + ").");
|
||||||
|
|
||||||
|
_supplyDrop = new SupplyDrop(location, entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!_supplyDrop.Dropped)
|
||||||
|
{
|
||||||
|
if (UtilTime.elapsed(_supplyDrop.Start, DURATION))
|
||||||
|
{
|
||||||
|
_supplyDrop.Dropped = true;
|
||||||
|
((CraftEnderDragon) _supplyDrop.Dragon).getHandle().setTargetBlock(256, 100, 256);
|
||||||
|
byte data = (byte) (UtilMath.r(4) + 2);
|
||||||
|
|
||||||
|
getGame().getArcadeManager().runSyncTimer(new BukkitRunnable()
|
||||||
|
{
|
||||||
|
Block block = _supplyDrop.Drop.getBlock();
|
||||||
|
boolean done = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
MapUtil.QuickChangeBlockAt(block.getLocation(), Material.AIR);
|
||||||
|
block = block.getRelative(BlockFace.DOWN);
|
||||||
|
|
||||||
|
if (UtilBlock.solid(block))
|
||||||
|
{
|
||||||
|
block = block.getRelative(BlockFace.UP);
|
||||||
|
done = true;
|
||||||
|
_supplyDrop.Dragon.remove();
|
||||||
|
_supplyDrop = null;
|
||||||
|
_firstOpening = true;
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
UtilFirework.playFirework(block.getLocation().add(0.5, 0.5, 0.5), FIREWORK_EFFECT);
|
||||||
|
MapUtil.QuickChangeBlockAt(block.getLocation(), Material.ENDER_CHEST, data);
|
||||||
|
|
||||||
|
if (done)
|
||||||
|
{
|
||||||
|
_lastBlock = block;
|
||||||
|
populateChest();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 5);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Location center = _supplyDrop.Drop;
|
||||||
|
double theta = Math.PI * 2 / POINTS * _supplyDrop.Point;
|
||||||
|
double x = RADIUS * Math.cos(theta), z = RADIUS * Math.sin(theta);
|
||||||
|
float yaw = 360 / POINTS * _supplyDrop.Point - 90;
|
||||||
|
|
||||||
|
((CraftEntity) _supplyDrop.Dragon).getHandle().setPositionRotation(center.getX() + x, center.getY(), center.getZ() + z, yaw, 0);
|
||||||
|
|
||||||
|
_supplyDrop.Point++;
|
||||||
|
_supplyDrop.Point %= POINTS;
|
||||||
|
_supplyDrop.Drop.setYaw(yaw);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void openChest(PlayerInteractEvent event)
|
||||||
|
{
|
||||||
|
if (!UtilEvent.isAction(event, ActionType.R_BLOCK))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
Block block = event.getClickedBlock();
|
||||||
|
|
||||||
|
if (UtilPlayer.isSpectator(player) || !block.equals(_lastBlock))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
TreasureUtil.playChestOpen(block.getLocation(), true);
|
||||||
|
player.openInventory(_chestInventory);
|
||||||
|
|
||||||
|
if (_firstOpening)
|
||||||
|
{
|
||||||
|
_firstOpening = false;
|
||||||
|
getGame().AddStat(player, "SupplyDropsOpened", 1, false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateChest()
|
||||||
|
{
|
||||||
|
List<Integer> slots = new ArrayList<>(_chestInventory.getSize());
|
||||||
|
|
||||||
|
for (int i = 0; i < _chestInventory.getSize(); i++)
|
||||||
|
{
|
||||||
|
slots.add(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Integer, List<ItemStack>> lootTable = new HashMap<>(_lootTable.size());
|
||||||
|
|
||||||
|
_lootTable.forEach((integer, itemStacks) -> lootTable.put(integer, new ArrayList<>(itemStacks)));
|
||||||
|
_chestInventory.clear();
|
||||||
|
|
||||||
|
int[] configuration = UtilMath.randomElement(LOOT_CONFIGURATIONS);
|
||||||
|
|
||||||
|
for (int i : configuration)
|
||||||
|
{
|
||||||
|
List<ItemStack> itemStacks = lootTable.get(i);
|
||||||
|
ItemStack itemStack = UtilAlg.Random(itemStacks);
|
||||||
|
UtilItem.makeUnbreakable(itemStack);
|
||||||
|
itemStacks.remove(itemStack);
|
||||||
|
int slot = UtilMath.r(slots.size());
|
||||||
|
slots.remove(slot);
|
||||||
|
|
||||||
|
_chestInventory.setItem(slot, itemStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Location getRandom()
|
||||||
|
{
|
||||||
|
double size = getGame().WorldData.World.getWorldBorder().getSize() / 3;
|
||||||
|
Location center = getGame().GetSpectatorLocation();
|
||||||
|
|
||||||
|
int attempts = 0;
|
||||||
|
|
||||||
|
attemptsLoop:
|
||||||
|
while (attempts++ < 50)
|
||||||
|
{
|
||||||
|
Location location = UtilAlg.getRandomLocation(center, size, 0, size);
|
||||||
|
Block block = location.getBlock();
|
||||||
|
|
||||||
|
while (block.getLocation().getY() > 0 && !UtilBlock.solid(block))
|
||||||
|
{
|
||||||
|
if (block.isLiquid())
|
||||||
|
{
|
||||||
|
continue attemptsLoop;
|
||||||
|
}
|
||||||
|
|
||||||
|
block = block.getRelative(BlockFace.DOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (BlockFace face : UtilBlock.horizontals)
|
||||||
|
{
|
||||||
|
if (!UtilBlock.solid(block.getRelative(face)))
|
||||||
|
{
|
||||||
|
continue attemptsLoop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
block = block.getRelative(BlockFace.UP);
|
||||||
|
Block bottom = block;
|
||||||
|
|
||||||
|
while (block.getLocation().getY() < getGame().WorldData.MaxY)
|
||||||
|
{
|
||||||
|
if (UtilBlock.solid(block))
|
||||||
|
{
|
||||||
|
continue attemptsLoop;
|
||||||
|
}
|
||||||
|
|
||||||
|
block = block.getRelative(BlockFace.UP);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bottom.getLocation().add(0.5, 0, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SupplyDrop
|
||||||
|
{
|
||||||
|
Location Drop;
|
||||||
|
boolean Dropped;
|
||||||
|
long Start;
|
||||||
|
Entity Dragon;
|
||||||
|
int Point;
|
||||||
|
|
||||||
|
SupplyDrop(Location drop, Entity dragon)
|
||||||
|
{
|
||||||
|
Drop = drop;
|
||||||
|
Start = System.currentTimeMillis();
|
||||||
|
Dragon = dragon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getCurrentDrop()
|
||||||
|
{
|
||||||
|
return _supplyDrop == null ? null : _supplyDrop.Drop;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,122 @@
|
|||||||
|
package nautilus.game.arcade.game.games.survivalgames.modules;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilEvent;
|
||||||
|
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.game.GameTeam;
|
||||||
|
import nautilus.game.arcade.game.modules.Module;
|
||||||
|
|
||||||
|
public class TrackingCompassModule extends Module
|
||||||
|
{
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void interactCompass(PlayerInteractEvent event)
|
||||||
|
{
|
||||||
|
if (!UtilEvent.isAction(event, ActionType.R))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
ItemStack itemStack = player.getItemInHand();
|
||||||
|
|
||||||
|
if (UtilPlayer.isSpectator(player) || itemStack == null || itemStack.getType() != Material.COMPASS)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int uses = getUses(itemStack);
|
||||||
|
|
||||||
|
if (uses == 0)
|
||||||
|
{
|
||||||
|
player.sendMessage(F.main("Game", "The compass breaks! No remaining uses!"));
|
||||||
|
player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 1);
|
||||||
|
player.setItemInHand(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (!Recharge.Instance.use(player, "Compass", 500, true, true))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameTeam team = getGame().GetTeam(player);
|
||||||
|
|
||||||
|
for (Player nearby : UtilPlayer.getNearby(player.getLocation(), 256))
|
||||||
|
{
|
||||||
|
if (player.equals(nearby) || getGame().TeamMode && team.HasPlayer(nearby))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.setCompassTarget(nearby.getLocation());
|
||||||
|
player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 1, 1);
|
||||||
|
player.sendMessage(F.main("Game", F.name(nearby.getName()) + " is " + F.count((int) UtilMath.offset(player, nearby)) + " blocks away."));
|
||||||
|
player.setItemInHand(getCompass(--uses));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void combineCompasses(InventoryClickEvent event)
|
||||||
|
{
|
||||||
|
Player player = (Player) event.getWhoClicked();
|
||||||
|
ItemStack cursor = event.getCursor();
|
||||||
|
ItemStack currentItem = event.getCurrentItem();
|
||||||
|
|
||||||
|
if (UtilPlayer.isSpectator(player) || cursor == null || currentItem == null || cursor.getType() != Material.COMPASS || currentItem.getType() != Material.COMPASS)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int a = getUses(cursor), b = getUses(currentItem);
|
||||||
|
|
||||||
|
event.setCursor(getCompass(a + b));
|
||||||
|
event.setCurrentItem(null);
|
||||||
|
player.sendMessage(F.main("Game", "You combined two compasses."));
|
||||||
|
player.playSound(player.getLocation(), Sound.ANVIL_USE, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getUses(ItemStack itemStack)
|
||||||
|
{
|
||||||
|
if (!itemStack.hasItemMeta())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
|
List<String> lore = itemMeta.getLore();
|
||||||
|
|
||||||
|
if (lore.isEmpty())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Integer.parseInt(ChatColor.stripColor(lore.get(0)).replaceAll("\\D+", ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getCompass(int uses)
|
||||||
|
{
|
||||||
|
return new ItemBuilder(Material.COMPASS)
|
||||||
|
.setTitle(C.cYellowB + "Tracking Compass")
|
||||||
|
.addLore("Uses " + C.cYellow + uses, "Use this to find the location and", "distance of the nearest player!", "Click on another compass in your inventory to", "combine them!", "Id: " + C.cRed + UtilMath.r(1000))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,7 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.scoreboard.DisplaySlot;
|
import org.bukkit.scoreboard.DisplaySlot;
|
||||||
|
import org.bukkit.scoreboard.NameTagVisibility;
|
||||||
import org.bukkit.scoreboard.Objective;
|
import org.bukkit.scoreboard.Objective;
|
||||||
import org.bukkit.scoreboard.Score;
|
import org.bukkit.scoreboard.Score;
|
||||||
import org.bukkit.scoreboard.Scoreboard;
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
@ -50,6 +51,7 @@ public class CustomScoreboardModule extends Module
|
|||||||
private BiConsumer<Player, GameScoreboard> _scoreboardConsumer;
|
private BiConsumer<Player, GameScoreboard> _scoreboardConsumer;
|
||||||
private BiFunction<Player, Player, String> _prefixFunction;
|
private BiFunction<Player, Player, String> _prefixFunction;
|
||||||
private BiFunction<Player, Player, String> _suffixFunction;
|
private BiFunction<Player, Player, String> _suffixFunction;
|
||||||
|
private BiFunction<Player, Player, NameTagVisibility> _nameTagVisibilityFunction;
|
||||||
private BiFunction<Player, Player, Integer> _tabListFunction;
|
private BiFunction<Player, Player, Integer> _tabListFunction;
|
||||||
private String _underNameObjective;
|
private String _underNameObjective;
|
||||||
private BiFunction<Player, Player, Integer> _underNameFunction;
|
private BiFunction<Player, Player, Integer> _underNameFunction;
|
||||||
@ -225,6 +227,12 @@ public class CustomScoreboardModule extends Module
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CustomScoreboardModule setNameTagVisibility(BiFunction<Player, Player, NameTagVisibility> function)
|
||||||
|
{
|
||||||
|
_nameTagVisibilityFunction = function;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refreshes all player's scoreboards.
|
* Refreshes all player's scoreboards.
|
||||||
*/
|
*/
|
||||||
@ -289,6 +297,7 @@ public class CustomScoreboardModule extends Module
|
|||||||
|
|
||||||
String prefix = _prefixFunction == null ? null : _prefixFunction.apply(getOwner(), subject);
|
String prefix = _prefixFunction == null ? null : _prefixFunction.apply(getOwner(), subject);
|
||||||
String suffix = _suffixFunction == null ? null : _suffixFunction.apply(getOwner(), subject);
|
String suffix = _suffixFunction == null ? null : _suffixFunction.apply(getOwner(), subject);
|
||||||
|
NameTagVisibility visibility = _nameTagVisibilityFunction == null ? null : _nameTagVisibilityFunction.apply(getOwner(), subject);
|
||||||
|
|
||||||
if (team == null)
|
if (team == null)
|
||||||
{
|
{
|
||||||
@ -310,6 +319,13 @@ public class CustomScoreboardModule extends Module
|
|||||||
team.setSuffix(suffix);
|
team.setSuffix(suffix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (visibility != null)
|
||||||
|
{
|
||||||
|
if (!visibility.equals(team.getNameTagVisibility()))
|
||||||
|
{
|
||||||
|
team.setNameTagVisibility(visibility);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateTabList(Player subject)
|
private void updateTabList(Player subject)
|
||||||
|
@ -3,7 +3,6 @@ package nautilus.game.arcade.game.modules;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.Effect;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -23,6 +22,7 @@ import mineplex.core.common.util.UtilEvent.ActionType;
|
|||||||
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.ItemBuilder;
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
|
|
||||||
public class ThrowableTNTModule extends Module
|
public class ThrowableTNTModule extends Module
|
||||||
{
|
{
|
||||||
@ -92,7 +92,7 @@ public class ThrowableTNTModule extends Module
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
ItemStack itemStack = player.getItemInHand();
|
ItemStack itemStack = player.getItemInHand();
|
||||||
|
|
||||||
if (UtilPlayer.isSpectator(player) || itemStack == null || itemStack.getType() != Material.TNT || UtilBlock.usable(event.getClickedBlock()))
|
if (UtilPlayer.isSpectator(player) || itemStack == null || itemStack.getType() != Material.TNT || UtilBlock.usable(event.getClickedBlock()) || !Recharge.Instance.use(player, "Throw TNT", 500, false, true))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -109,7 +109,6 @@ public class ThrowableTNTModule extends Module
|
|||||||
if (!_throwAndDrop || UtilEvent.isAction(event, ActionType.L))
|
if (!_throwAndDrop || UtilEvent.isAction(event, ActionType.L))
|
||||||
{
|
{
|
||||||
UtilAction.velocity(tntPrimed, location.getDirection(), _throwStrength, false, 0, 0.3, 1, false);
|
UtilAction.velocity(tntPrimed, location.getDirection(), _throwStrength, false, 0, 0.3, 1, false);
|
||||||
player.playEffect(location, Effect.GHAST_SHOOT, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_throwers.put(tntPrimed, player);
|
_throwers.put(tntPrimed, player);
|
||||||
|
@ -9,6 +9,7 @@ import java.util.Map;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -20,6 +21,7 @@ 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 org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import mineplex.core.common.util.MapUtil;
|
import mineplex.core.common.util.MapUtil;
|
||||||
@ -27,7 +29,7 @@ import mineplex.core.common.util.UtilAlg;
|
|||||||
import mineplex.core.common.util.UtilBlock;
|
import mineplex.core.common.util.UtilBlock;
|
||||||
import mineplex.core.common.util.UtilEvent;
|
import mineplex.core.common.util.UtilEvent;
|
||||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.titles.tracks.standard.LuckyTrack;
|
import mineplex.core.titles.tracks.standard.LuckyTrack;
|
||||||
import mineplex.core.titles.tracks.standard.UnluckyTrack;
|
import mineplex.core.titles.tracks.standard.UnluckyTrack;
|
||||||
@ -35,6 +37,7 @@ import mineplex.core.updater.UpdateType;
|
|||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
|
||||||
import nautilus.game.arcade.ArcadeManager;
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
|
import nautilus.game.arcade.events.ChestRefillEvent;
|
||||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
import nautilus.game.arcade.game.Game.GameState;
|
import nautilus.game.arcade.game.Game.GameState;
|
||||||
import nautilus.game.arcade.game.modules.Module;
|
import nautilus.game.arcade.game.modules.Module;
|
||||||
@ -42,13 +45,6 @@ import nautilus.game.arcade.game.modules.Module;
|
|||||||
public class ChestLootModule extends Module
|
public class ChestLootModule extends Module
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final BlockFace[] FACES = {
|
|
||||||
BlockFace.NORTH,
|
|
||||||
BlockFace.SOUTH,
|
|
||||||
BlockFace.WEST,
|
|
||||||
BlockFace.EAST
|
|
||||||
};
|
|
||||||
|
|
||||||
private final Map<ChestType, Set<ChestMetadata>> _chests;
|
private final Map<ChestType, Set<ChestMetadata>> _chests;
|
||||||
|
|
||||||
private long _destroyAfterOpened;
|
private long _destroyAfterOpened;
|
||||||
@ -119,6 +115,11 @@ public class ChestLootModule extends Module
|
|||||||
public void refill()
|
public void refill()
|
||||||
{
|
{
|
||||||
_chests.forEach((type, metadataSet) -> metadataSet.forEach(metadata -> metadata.Opened = false));
|
_chests.forEach((type, metadataSet) -> metadataSet.forEach(metadata -> metadata.Opened = false));
|
||||||
|
|
||||||
|
List<Location> chests = new ArrayList<>();
|
||||||
|
_chests.values().forEach(set -> set.forEach(chestMetadata -> chests.add(chestMetadata.Chest.getLocation())));
|
||||||
|
|
||||||
|
UtilServer.CallEvent(new ChestRefillEvent(chests));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refill(String typeName)
|
public void refill(String typeName)
|
||||||
@ -131,6 +132,9 @@ public class ChestLootModule extends Module
|
|||||||
}
|
}
|
||||||
|
|
||||||
metadataSet.forEach(metadata -> metadata.Opened = false);
|
metadataSet.forEach(metadata -> metadata.Opened = false);
|
||||||
|
UtilServer.CallEvent(new ChestRefillEvent(metadataSet.stream()
|
||||||
|
.map(chestMetadata -> chestMetadata.Chest.getLocation())
|
||||||
|
.collect(Collectors.toList())));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,9 +179,9 @@ public class ChestLootModule extends Module
|
|||||||
|
|
||||||
if (_autoRotateChests)
|
if (_autoRotateChests)
|
||||||
{
|
{
|
||||||
List<BlockFace> faces = new ArrayList<>(FACES.length);
|
List<BlockFace> faces = new ArrayList<>(UtilBlock.horizontals.size());
|
||||||
|
|
||||||
for (BlockFace face : FACES)
|
for (BlockFace face : UtilBlock.horizontals)
|
||||||
{
|
{
|
||||||
if (UtilBlock.airFoliage(block.getRelative(face)))
|
if (UtilBlock.airFoliage(block.getRelative(face)))
|
||||||
{
|
{
|
||||||
@ -196,6 +200,10 @@ public class ChestLootModule extends Module
|
|||||||
metadata.populateChest((Chest) block.getState());
|
metadata.populateChest((Chest) block.getState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MapUtil.QuickChangeBlockAt(location, Material.AIR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_chests.put(chestType, metadataSet);
|
_chests.put(chestType, metadataSet);
|
||||||
@ -293,13 +301,11 @@ public class ChestLootModule extends Module
|
|||||||
|
|
||||||
private ChestMetadata getFromBlock(Block block)
|
private ChestMetadata getFromBlock(Block block)
|
||||||
{
|
{
|
||||||
Location blockLocation = block.getLocation();
|
|
||||||
|
|
||||||
for (Set<ChestMetadata> metadataSet : _chests.values())
|
for (Set<ChestMetadata> metadataSet : _chests.values())
|
||||||
{
|
{
|
||||||
for (ChestMetadata metadata : metadataSet)
|
for (ChestMetadata metadata : metadataSet)
|
||||||
{
|
{
|
||||||
if (UtilMath.offsetSquared(blockLocation, metadata.Chest.getLocation()) < 4)
|
if (metadata.Chest.getLocation().getBlock().equals(block))
|
||||||
{
|
{
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
@ -371,13 +377,20 @@ public class ChestLootModule extends Module
|
|||||||
|
|
||||||
void populateChest(Chest chest)
|
void populateChest(Chest chest)
|
||||||
{
|
{
|
||||||
chest.getBlockInventory().clear();
|
Inventory inventory = chest.getBlockInventory();
|
||||||
|
inventory.clear();
|
||||||
|
List<Integer> slots = new ArrayList<>(chest.getBlockInventory().getSize());
|
||||||
|
|
||||||
|
for (int i = 0; i < inventory.getSize(); i++)
|
||||||
|
{
|
||||||
|
slots.add(i);
|
||||||
|
}
|
||||||
|
|
||||||
for (ChestLootPool pool : Type.Pools)
|
for (ChestLootPool pool : Type.Pools)
|
||||||
{
|
{
|
||||||
if (pool.getProbability() == 1 || Math.random() < pool.getProbability())
|
if (pool.getProbability() == 1 || Math.random() < pool.getProbability())
|
||||||
{
|
{
|
||||||
pool.populateChest(chest);
|
pool.populateChest(chest, slots);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -398,6 +411,4 @@ public class ChestLootModule extends Module
|
|||||||
ChestSpawns = chestLocations;
|
ChestSpawns = chestLocations;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package nautilus.game.arcade.game.modules.chest;
|
package nautilus.game.arcade.game.modules.chest;
|
||||||
|
|
||||||
import java.util.AbstractMap.SimpleEntry;
|
import java.util.AbstractMap.SimpleEntry;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.bukkit.block.Chest;
|
import org.bukkit.block.Chest;
|
||||||
@ -8,6 +9,7 @@ import org.bukkit.enchantments.Enchantment;
|
|||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilItem;
|
||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.weight.WeightSet;
|
import mineplex.core.common.weight.WeightSet;
|
||||||
|
|
||||||
@ -18,9 +20,9 @@ public class ChestLootPool
|
|||||||
|
|
||||||
private final WeightSet<ChestLootItem> _items;
|
private final WeightSet<ChestLootItem> _items;
|
||||||
private final WeightSet<Entry<Enchantment, Integer>> _enchantments;
|
private final WeightSet<Entry<Enchantment, Integer>> _enchantments;
|
||||||
private int _minimumPerChest;
|
private int _minimumPerChest, _maximumPerChest;
|
||||||
private int _maximumPerChest;
|
|
||||||
private double _rarity, _enchantmentRarity;
|
private double _rarity, _enchantmentRarity;
|
||||||
|
private boolean _unbreakable;
|
||||||
|
|
||||||
public ChestLootPool()
|
public ChestLootPool()
|
||||||
{
|
{
|
||||||
@ -82,13 +84,20 @@ public class ChestLootPool
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void populateChest(Chest chest)
|
public ChestLootPool setUnbreakable(boolean unbreakable)
|
||||||
|
{
|
||||||
|
_unbreakable = unbreakable;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void populateChest(Chest chest, List<Integer> slots)
|
||||||
{
|
{
|
||||||
Inventory inventory = chest.getBlockInventory();
|
Inventory inventory = chest.getBlockInventory();
|
||||||
|
|
||||||
for (int i = 0; i < UtilMath.rRange(_minimumPerChest, _maximumPerChest); i++)
|
for (int i = 0; i < UtilMath.rRange(_minimumPerChest, _maximumPerChest); i++)
|
||||||
{
|
{
|
||||||
int slot = UtilMath.r(inventory.getSize());
|
int slot = UtilMath.r(slots.size());
|
||||||
|
slots.remove(slot);
|
||||||
inventory.setItem(slot, getRandomItem());
|
inventory.setItem(slot, getRandomItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,6 +122,11 @@ public class ChestLootPool
|
|||||||
itemStack.addUnsafeEnchantment(enchantment.getKey(), UtilMath.r(enchantment.getValue()) + 1);
|
itemStack.addUnsafeEnchantment(enchantment.getKey(), UtilMath.r(enchantment.getValue()) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_unbreakable && itemStack.getType().getMaxDurability() > 0)
|
||||||
|
{
|
||||||
|
UtilItem.makeUnbreakable(itemStack);
|
||||||
|
}
|
||||||
|
|
||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package nautilus.game.arcade.game.modules.combattracker;
|
||||||
|
|
||||||
|
public class CombatData
|
||||||
|
{
|
||||||
|
|
||||||
|
private int _kills, _assits;
|
||||||
|
|
||||||
|
public void incrementKills()
|
||||||
|
{
|
||||||
|
_kills++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getKills()
|
||||||
|
{
|
||||||
|
return _kills;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void incrementAssists()
|
||||||
|
{
|
||||||
|
_assits++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getAssits()
|
||||||
|
{
|
||||||
|
return _assits;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
package nautilus.game.arcade.game.modules.combattracker;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.minecraft.game.core.combat.CombatComponent;
|
||||||
|
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.game.modules.Module;
|
||||||
|
|
||||||
|
public class CombatTrackerModule extends Module
|
||||||
|
{
|
||||||
|
|
||||||
|
private final Map<UUID, CombatData> _combatData;
|
||||||
|
|
||||||
|
public CombatTrackerModule()
|
||||||
|
{
|
||||||
|
_combatData = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CombatData getCombatData(Player player)
|
||||||
|
{
|
||||||
|
return _combatData.computeIfAbsent(player.getUniqueId(), k -> new CombatData());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cleanup()
|
||||||
|
{
|
||||||
|
_combatData.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void combatDeath(CombatDeathEvent event)
|
||||||
|
{
|
||||||
|
if (!(event.GetEvent().getEntity() instanceof Player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player killed = (Player) event.GetEvent().getEntity();
|
||||||
|
|
||||||
|
if (event.GetLog().GetKiller() != null)
|
||||||
|
{
|
||||||
|
Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
|
||||||
|
|
||||||
|
if (killer != null && !killer.equals(killed))
|
||||||
|
{
|
||||||
|
getCombatData(killer).incrementKills();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (CombatComponent log : event.GetLog().GetAttackers())
|
||||||
|
{
|
||||||
|
if (event.GetLog().GetKiller() != null && log.equals(event.GetLog().GetKiller()))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player assist = UtilPlayer.searchExact(log.GetName());
|
||||||
|
|
||||||
|
if (assist != null)
|
||||||
|
{
|
||||||
|
getCombatData(assist).incrementAssists();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,546 @@
|
|||||||
|
package nautilus.game.arcade.game.modules.worldmap;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.AbstractMap.SimpleEntry;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_8_R3.Block;
|
||||||
|
import net.minecraft.server.v1_8_R3.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_8_R3.IBlockData;
|
||||||
|
import net.minecraft.server.v1_8_R3.MaterialMapColor;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_8_R3.CraftChunk;
|
||||||
|
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.inventory.ItemStack;
|
||||||
|
import org.bukkit.map.MapRenderer;
|
||||||
|
import org.bukkit.map.MapView;
|
||||||
|
|
||||||
|
import com.google.common.collect.HashMultiset;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Multisets;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilInv;
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.game.modules.Module;
|
||||||
|
import nautilus.game.arcade.world.WorldData;
|
||||||
|
|
||||||
|
public class WorldMapModule extends Module
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final int BLOCK_SCAN_INTERVAL = 16;
|
||||||
|
|
||||||
|
private int _halfMapSize;
|
||||||
|
private final int[][] _heightMap;
|
||||||
|
private boolean _loadWorld = true;
|
||||||
|
private Map<Integer, Byte[][]> _map = new HashMap<>();
|
||||||
|
private short _mapId = (short) UtilMath.r(Short.MAX_VALUE);
|
||||||
|
private final List<Entry<Integer, Integer>> _scanList = new ArrayList<>();
|
||||||
|
private World _world;
|
||||||
|
private int _centerX, _centerZ, _scale;
|
||||||
|
|
||||||
|
private final WorldMapRenderer _renderer;
|
||||||
|
|
||||||
|
public WorldMapModule(WorldData worldData, WorldMapRenderer renderer)
|
||||||
|
{
|
||||||
|
this(worldData.World, worldData.MinX, worldData.MinZ, worldData.MaxX, worldData.MaxZ, renderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorldMapModule(World world, int minX, int minZ, int maxX, int maxZ, WorldMapRenderer renderer)
|
||||||
|
{
|
||||||
|
_centerX = minX + ((maxX - minX) / 2);
|
||||||
|
_centerZ = minZ + ((maxZ - minZ) / 2);
|
||||||
|
_centerX = (int) (Math.round(_centerX / 16D) * 16);
|
||||||
|
_centerZ = (int) (Math.round(_centerZ / 16D) * 16);
|
||||||
|
_renderer = renderer;
|
||||||
|
renderer.setManager(this);
|
||||||
|
|
||||||
|
_halfMapSize = (int) (Math.ceil(Math.max((maxX - minX) / 2D, (maxZ - minZ) / 2D) / 16D) * 16);
|
||||||
|
|
||||||
|
List<Entry<Integer, Integer>> list = new ArrayList<>();
|
||||||
|
|
||||||
|
for (int scale = 1; scale <= 16; scale++)
|
||||||
|
{
|
||||||
|
int s = _halfMapSize;
|
||||||
|
|
||||||
|
if ((s / scale) > 127)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (s < 10000 && (s % 16 != 0 || s % scale != 0))
|
||||||
|
{
|
||||||
|
s += 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s < 10000)
|
||||||
|
{
|
||||||
|
list.add(new SimpleEntry<>(scale, s));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (list.isEmpty())
|
||||||
|
{
|
||||||
|
_scale = 16;
|
||||||
|
_halfMapSize = 127 * 8;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
list.sort(Comparator.comparingInt(Entry::getValue));
|
||||||
|
|
||||||
|
_scale = list.get(0).getKey();
|
||||||
|
_halfMapSize = list.get(0).getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
_heightMap = new int[(_halfMapSize * 2) + 16][];
|
||||||
|
|
||||||
|
for (int x = -_halfMapSize; x < _halfMapSize; x += BLOCK_SCAN_INTERVAL)
|
||||||
|
{
|
||||||
|
for (int z = -_halfMapSize - 16; z < _halfMapSize; z += (z < -_halfMapSize ? 16 : BLOCK_SCAN_INTERVAL))
|
||||||
|
{
|
||||||
|
_scanList.add(new SimpleEntry<>(x, z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int s = 1; s <= 2; s++)
|
||||||
|
{
|
||||||
|
if (s == 2)
|
||||||
|
{
|
||||||
|
s = getScale();
|
||||||
|
|
||||||
|
if (s == 1)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
int size = (_halfMapSize * 2) / s;
|
||||||
|
Byte[][] bytes = new Byte[size][];
|
||||||
|
|
||||||
|
for (int i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
bytes[i] = new Byte[size];
|
||||||
|
}
|
||||||
|
|
||||||
|
_map.put(s, bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < _heightMap.length; i++)
|
||||||
|
{
|
||||||
|
_heightMap[i] = new int[_heightMap.length];
|
||||||
|
}
|
||||||
|
|
||||||
|
_world = world;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File dataFolder = new File("world/data");
|
||||||
|
|
||||||
|
if (dataFolder.exists())
|
||||||
|
{
|
||||||
|
for (File file : dataFolder.listFiles())
|
||||||
|
{
|
||||||
|
if (file.getName().startsWith("map_"))
|
||||||
|
{
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MapView view = Bukkit.createMap(_world);
|
||||||
|
_mapId = view.getId();
|
||||||
|
setupRenderer(view);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
rebuildScan();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupRenderer(MapView view)
|
||||||
|
{
|
||||||
|
for (MapRenderer renderer : view.getRenderers())
|
||||||
|
{
|
||||||
|
view.removeRenderer(renderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
view.addRenderer(_renderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getScale()
|
||||||
|
{
|
||||||
|
return _scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getX()
|
||||||
|
{
|
||||||
|
return _centerX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getZ()
|
||||||
|
{
|
||||||
|
return _centerZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void colorWorldHeight(int zoom, int startingX, int startingZ)
|
||||||
|
{
|
||||||
|
zoom = Math.max(zoom, 1);
|
||||||
|
|
||||||
|
Byte[][] map = _map.get(zoom);
|
||||||
|
|
||||||
|
for (int x = startingX; x < startingX + BLOCK_SCAN_INTERVAL; x += zoom)
|
||||||
|
{
|
||||||
|
double d0 = 0;
|
||||||
|
|
||||||
|
// Prevents ugly lines for the first line of Z
|
||||||
|
for (int addX = 0; addX < zoom; addX++)
|
||||||
|
{
|
||||||
|
for (int addZ = 0; addZ < zoom; addZ++)
|
||||||
|
{
|
||||||
|
int hX = x + addX + _halfMapSize;
|
||||||
|
int hZ = (startingZ - zoom) + addZ + _halfMapSize;
|
||||||
|
|
||||||
|
if (hX >= _halfMapSize * 2 || hZ >= _halfMapSize * 2)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
d0 += _heightMap[hX + 16][hZ + 16] / (zoom * zoom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int z = startingZ; z < startingZ + BLOCK_SCAN_INTERVAL; z += zoom)
|
||||||
|
{
|
||||||
|
double d1 = 0;
|
||||||
|
|
||||||
|
for (int addX = 0; addX < zoom; addX++)
|
||||||
|
{
|
||||||
|
for (int addZ = 0; addZ < zoom; addZ++)
|
||||||
|
{
|
||||||
|
int hX = x + addX + _halfMapSize;
|
||||||
|
int hZ = z + addZ + _halfMapSize;
|
||||||
|
|
||||||
|
if (hX >= _halfMapSize * 2 || hZ >= _halfMapSize * 2)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
d1 += _heightMap[hX + 16][hZ + 16] / (zoom * zoom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double d2 = (d1 - d0) * 4.0D / (zoom + 4) + ((x + z & 0x1) - 0.5D) * 0.4D;
|
||||||
|
byte b0 = 1;
|
||||||
|
|
||||||
|
d0 = d1;
|
||||||
|
|
||||||
|
if (d2 > 0.6D)
|
||||||
|
{
|
||||||
|
b0 = 2;
|
||||||
|
}
|
||||||
|
else if (d2 > 1.2D)
|
||||||
|
{
|
||||||
|
b0 = 3;
|
||||||
|
}
|
||||||
|
else if (d2 < -0.6D)
|
||||||
|
{
|
||||||
|
b0 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int origColor = map[(x + _halfMapSize) / zoom][(z + _halfMapSize) / zoom] - 1;
|
||||||
|
byte color = (byte) (origColor + b0);
|
||||||
|
map[(x + _halfMapSize) / zoom][(z + _halfMapSize) / zoom] = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawWorldScale(int zoom, int startingX, int startingZ)
|
||||||
|
{
|
||||||
|
Byte[][] first = _map.get(1);
|
||||||
|
Byte[][] second = _map.get(zoom);
|
||||||
|
|
||||||
|
for (int x = startingX; x < startingX + BLOCK_SCAN_INTERVAL; x += zoom)
|
||||||
|
{
|
||||||
|
for (int z = startingZ; z < startingZ + BLOCK_SCAN_INTERVAL; z += zoom)
|
||||||
|
{
|
||||||
|
HashMultiset<Byte> hashmultiset = HashMultiset.create();
|
||||||
|
|
||||||
|
for (int addX = 0; addX < zoom; addX++)
|
||||||
|
{
|
||||||
|
for (int addZ = 0; addZ < zoom; addZ++)
|
||||||
|
{
|
||||||
|
int pX = x + addX + _halfMapSize;
|
||||||
|
int pZ = z + addZ + _halfMapSize;
|
||||||
|
|
||||||
|
if (pX >= first.length || pZ >= first.length)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte b = first[pX][pZ];
|
||||||
|
|
||||||
|
if (b == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
hashmultiset.add(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte color = Iterables.getFirst(Multisets.copyHighestCountFirst(hashmultiset), (byte) 0);
|
||||||
|
|
||||||
|
second[(x + _halfMapSize) / zoom][(z + _halfMapSize) / zoom] = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private double getDistance(double x1, double z1, double x2, double z2)
|
||||||
|
{
|
||||||
|
x1 = (x1 - x2);
|
||||||
|
z1 = (z1 - z2);
|
||||||
|
|
||||||
|
return (x1 * x1) + (z1 * z1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private double getDistance(Entry<Integer, Integer> entry, double x1, double z1)
|
||||||
|
{
|
||||||
|
return getDistance(x1 + _centerX, z1 + _centerZ, entry.getKey() + (BLOCK_SCAN_INTERVAL / 2), entry.getValue() + (BLOCK_SCAN_INTERVAL / 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte[][] getMap(int scale)
|
||||||
|
{
|
||||||
|
return _map.get(scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rebuildScan()
|
||||||
|
{
|
||||||
|
for (int x = -_halfMapSize; x < _halfMapSize; x += BLOCK_SCAN_INTERVAL)
|
||||||
|
{
|
||||||
|
for (int z = -_halfMapSize - 16; z < _halfMapSize; z += (z < -_halfMapSize ? 16 : BLOCK_SCAN_INTERVAL))
|
||||||
|
{
|
||||||
|
_scanList.add(new SimpleEntry<>(x, z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_loadWorld)
|
||||||
|
{
|
||||||
|
_scanList.removeIf(entry ->
|
||||||
|
{
|
||||||
|
for (Player player : UtilServer.getPlayers())
|
||||||
|
{
|
||||||
|
Location location = player.getLocation();
|
||||||
|
|
||||||
|
if (getDistance(entry, location.getX(), location.getZ()) < 6400)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void renderMap(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.TICK)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_renderer.renderTick();
|
||||||
|
|
||||||
|
if (_scanList.isEmpty())
|
||||||
|
{
|
||||||
|
if (_loadWorld)
|
||||||
|
{
|
||||||
|
_loadWorld = false;
|
||||||
|
System.out.println("Finished rendering the map.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (UtilServer.getPlayersCollection().size() == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
rebuildScan();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Entry<Integer, Integer> entry = _scanList.remove(0);
|
||||||
|
|
||||||
|
int startingX = entry.getKey();
|
||||||
|
int startingZ = entry.getValue();
|
||||||
|
|
||||||
|
boolean outsideMap = startingZ < -_halfMapSize;
|
||||||
|
|
||||||
|
scanWorldMap(startingX, startingZ, !outsideMap);
|
||||||
|
|
||||||
|
if (outsideMap)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int s = 1; s <= 2; s++)
|
||||||
|
{
|
||||||
|
if (s == 2)
|
||||||
|
{
|
||||||
|
s = getScale();
|
||||||
|
|
||||||
|
if (s == 1)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s == 13 && _loadWorld)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
drawWorldScale(s, startingX, startingZ);
|
||||||
|
colorWorldHeight(s, startingX, startingZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
colorWorldHeight(0, startingX, startingZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void scanWorldMap(int startingX, int startingZ, boolean setColors)
|
||||||
|
{
|
||||||
|
Byte[][] map = _map.get(1);
|
||||||
|
|
||||||
|
for (int beginX = startingX; beginX < startingX + BLOCK_SCAN_INTERVAL; beginX += 16)
|
||||||
|
{
|
||||||
|
for (int beginZ = startingZ - (startingZ > -_halfMapSize ? 16 : 0); beginZ < startingZ + (setColors ? BLOCK_SCAN_INTERVAL : 16); beginZ += 16)
|
||||||
|
{
|
||||||
|
Chunk chunk = _world.getChunkAt((beginX + _centerX) / 16, (beginZ + _centerZ) / 16);
|
||||||
|
boolean loaded = false;
|
||||||
|
|
||||||
|
if (!chunk.isLoaded())
|
||||||
|
{
|
||||||
|
if (_loadWorld)
|
||||||
|
{
|
||||||
|
loaded = chunk.load();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
net.minecraft.server.v1_8_R3.Chunk nmsChunk = ((CraftChunk) chunk).getHandle();
|
||||||
|
|
||||||
|
for (int x = beginX; x < beginX + 16; x++)
|
||||||
|
{
|
||||||
|
for (int z = beginZ; z < beginZ + 16; z++)
|
||||||
|
{
|
||||||
|
int color = 0;
|
||||||
|
|
||||||
|
if (!nmsChunk.isEmpty())
|
||||||
|
{
|
||||||
|
int k3 = x & 0xF;
|
||||||
|
int l3 = z & 0xF;
|
||||||
|
|
||||||
|
int l4 = nmsChunk.b(k3, l3) + 1;
|
||||||
|
IBlockData iblockdata;
|
||||||
|
|
||||||
|
if (l4 > 1)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
l4--;
|
||||||
|
iblockdata = nmsChunk.getBlockData(new BlockPosition(k3, l4, l3));
|
||||||
|
}
|
||||||
|
while (iblockdata.getBlock().g(iblockdata) == MaterialMapColor.b && (l4 > 0));
|
||||||
|
|
||||||
|
if ((l4 > 0) && (iblockdata.getBlock().getMaterial().isLiquid()))
|
||||||
|
{
|
||||||
|
int j5 = l4 - 1;
|
||||||
|
Block block1;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
block1 = nmsChunk.getType(new BlockPosition(k3, j5--, l3));
|
||||||
|
}
|
||||||
|
while ((j5 > 0) && (block1.getMaterial().isLiquid()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_heightMap[x + _halfMapSize + 16][z + _halfMapSize + 16] = l4;
|
||||||
|
|
||||||
|
if (setColors)
|
||||||
|
{
|
||||||
|
IBlockData data = nmsChunk.getBlockData(new BlockPosition(k3, l4, l3));
|
||||||
|
color = data.getBlock().g(data).M;
|
||||||
|
|
||||||
|
color = (byte) ((color * 4) + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setColors && beginZ >= startingZ)
|
||||||
|
{
|
||||||
|
map[x + _halfMapSize][z + _halfMapSize] = (byte) color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loaded)
|
||||||
|
{
|
||||||
|
chunk.unload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void dropItem(PlayerDropItemEvent event)
|
||||||
|
{
|
||||||
|
ItemStack itemStack = event.getItemDrop().getItemStack();
|
||||||
|
|
||||||
|
if (itemStack.getType() == Material.MAP)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
event.getPlayer().sendMessage(F.main("Game", "You cannot drop this map."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void inventoryClick(InventoryClickEvent event)
|
||||||
|
{
|
||||||
|
if (event.isCancelled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UtilInv.DisallowMovementOf(event, null, Material.MAP, (byte) _mapId, false);
|
||||||
|
|
||||||
|
if (event.isCancelled())
|
||||||
|
{
|
||||||
|
event.getWhoClicked().sendMessage(F.main("Game", "You cannot move this map from your inventory."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder getMapItem()
|
||||||
|
{
|
||||||
|
return new ItemBuilder(Material.MAP, 1, _mapId);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,117 @@
|
|||||||
|
package nautilus.game.arcade.game.modules.worldmap;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.map.MapCanvas;
|
||||||
|
import org.bukkit.map.MapCursor;
|
||||||
|
import org.bukkit.map.MapCursorCollection;
|
||||||
|
import org.bukkit.map.MapRenderer;
|
||||||
|
import org.bukkit.map.MapView;
|
||||||
|
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.game.Game;
|
||||||
|
|
||||||
|
public abstract class WorldMapRenderer<T extends Game> extends MapRenderer
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final long DRAW_RATE = TimeUnit.SECONDS.toMillis(4);
|
||||||
|
|
||||||
|
protected final T _game;
|
||||||
|
protected WorldMapModule _manager;
|
||||||
|
|
||||||
|
public WorldMapRenderer(T game)
|
||||||
|
{
|
||||||
|
_game = game;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setManager(WorldMapModule manager)
|
||||||
|
{
|
||||||
|
_manager = manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(MapView mapView, MapCanvas canvas, Player player)
|
||||||
|
{
|
||||||
|
preRender(player);
|
||||||
|
|
||||||
|
int zoom = _manager.getScale();
|
||||||
|
Byte[][] map = _manager.getMap(zoom);
|
||||||
|
|
||||||
|
int centerX = 0;
|
||||||
|
int centerZ = 0;
|
||||||
|
|
||||||
|
if (Recharge.Instance.use(player, "Draw Map", DRAW_RATE, false, false))
|
||||||
|
{
|
||||||
|
for (int mapX = 0; mapX < 128; mapX++)
|
||||||
|
{
|
||||||
|
for (int mapZ = 0; mapZ < 128; mapZ++)
|
||||||
|
{
|
||||||
|
int blockX = centerX + (mapX - 64);
|
||||||
|
int blockZ = centerZ + (mapZ - 64);
|
||||||
|
|
||||||
|
int pixelX = blockX + (map.length / 2);
|
||||||
|
int pixelZ = blockZ + (map.length / 2);
|
||||||
|
|
||||||
|
Byte color;
|
||||||
|
|
||||||
|
if (!(pixelX < 0 || pixelZ < 0 || pixelX >= map.length || pixelZ >= map.length) && map[pixelX][pixelZ] != null)
|
||||||
|
{
|
||||||
|
color = map[pixelX][pixelZ];
|
||||||
|
|
||||||
|
blockX *= zoom;
|
||||||
|
blockZ *= zoom;
|
||||||
|
|
||||||
|
color = renderBlock(player, color, mapX, mapZ, blockX, blockZ);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
color = (byte) 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
canvas.setPixel(mapX, mapZ, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
player.sendMap(mapView);
|
||||||
|
}
|
||||||
|
|
||||||
|
MapCursorCollection cursors = canvas.getCursors();
|
||||||
|
|
||||||
|
while (cursors.size() > 0)
|
||||||
|
{
|
||||||
|
cursors.removeCursor(cursors.getCursor(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
renderCursors(canvas, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addCursor(MapCanvas canvas, Location location, MapCursor.Type type)
|
||||||
|
{
|
||||||
|
MapCursorCollection cursors = canvas.getCursors();
|
||||||
|
int zoom = _manager.getScale();
|
||||||
|
double mapX = (location.getX() - _manager.getX()) / zoom;
|
||||||
|
double mapZ = (location.getZ() - _manager.getZ()) / zoom;
|
||||||
|
|
||||||
|
if (mapX > -64 && mapX < 64 && mapZ > -64 && mapZ < 64)
|
||||||
|
{
|
||||||
|
byte b0 = (byte) (int) Math.min(127, mapX * 2F + 0.5D);
|
||||||
|
byte b1 = (byte) (int) Math.max(-127, mapZ * 2F + 0.5D);
|
||||||
|
byte rotation = (byte) (int) (location.getYaw() * 16D / 360D);
|
||||||
|
|
||||||
|
MapCursor cursor = new MapCursor(b0, b1, (byte) (rotation & 0xF), type.getValue(), true);
|
||||||
|
|
||||||
|
cursors.addCursor(cursor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void renderTick();
|
||||||
|
|
||||||
|
protected abstract void preRender(Player player);
|
||||||
|
|
||||||
|
protected abstract byte renderBlock(Player player, byte color, int mapX, int mapZ, int blockX, int blockZ);
|
||||||
|
|
||||||
|
protected abstract void renderCursors(MapCanvas canvas, Player player);
|
||||||
|
}
|
@ -11,15 +11,19 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
|||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilAction;
|
import mineplex.core.common.util.UtilAction;
|
||||||
import mineplex.core.common.util.UtilBlock;
|
import mineplex.core.common.util.UtilBlock;
|
||||||
import mineplex.core.common.util.UtilEnt;
|
import mineplex.core.common.util.UtilEnt;
|
||||||
import mineplex.core.common.util.UtilEvent;
|
import mineplex.core.common.util.UtilEvent;
|
||||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||||
import mineplex.core.common.util.UtilInv;
|
import mineplex.core.common.util.UtilInv;
|
||||||
|
import mineplex.core.common.util.UtilItem;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
import mineplex.core.projectile.IThrown;
|
import mineplex.core.projectile.IThrown;
|
||||||
import mineplex.core.projectile.ProjectileUser;
|
import mineplex.core.projectile.ProjectileUser;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
|
|
||||||
import nautilus.game.arcade.kit.Perk;
|
import nautilus.game.arcade.kit.Perk;
|
||||||
|
|
||||||
public class PerkAxeThrower extends Perk implements IThrown
|
public class PerkAxeThrower extends Perk implements IThrown
|
||||||
@ -38,25 +42,21 @@ public class PerkAxeThrower extends Perk implements IThrown
|
|||||||
if (!UtilEvent.isAction(event, ActionType.R))
|
if (!UtilEvent.isAction(event, ActionType.R))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (event.getPlayer().getItemInHand() == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (UtilBlock.usable(event.getClickedBlock()))
|
if (UtilBlock.usable(event.getClickedBlock()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (!Kit.HasKit(player))
|
if (!UtilItem.isAxe(player.getItemInHand()) || !Kit.HasKit(player) || !Recharge.Instance.use(player, GetName(), 1000, false, true))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
org.bukkit.entity.Item ent = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(player.getItemInHand().getType()));
|
Item ent = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(player.getItemInHand().getType()));
|
||||||
UtilAction.velocity(ent, player.getLocation().getDirection(), 1.2, false, 0, 0.2, 10, false);
|
UtilAction.velocity(ent, player.getLocation().getDirection(), 1.2, false, 0, 0.2, 10, false);
|
||||||
Manager.GetProjectile().AddThrow(ent, player, this, -1, true, true, true, false, 0.6f);
|
Manager.GetProjectile().AddThrow(ent, player, this, -1, true, false, false, true, 0.7f);
|
||||||
|
|
||||||
//Remove Axe
|
//Remove Axe
|
||||||
player.setItemInHand(null);
|
player.setItemInHand(null);
|
||||||
@ -66,14 +66,10 @@ public class PerkAxeThrower extends Perk implements IThrown
|
|||||||
@Override
|
@Override
|
||||||
public void Collide(LivingEntity target, Block block, ProjectileUser data)
|
public void Collide(LivingEntity target, Block block, ProjectileUser data)
|
||||||
{
|
{
|
||||||
if (target == null)
|
if (!Manager.GetGame().IsAlive(target))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (target instanceof Player)
|
Item item = (Item) data.getThrown();
|
||||||
if (!Manager.GetGame().IsAlive((Player)target))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Item item = (Item)data.getThrown();
|
|
||||||
|
|
||||||
int damage = 4;
|
int damage = 4;
|
||||||
if (item.getItemStack().getType() == Material.STONE_AXE) damage = 5;
|
if (item.getItemStack().getType() == Material.STONE_AXE) damage = 5;
|
||||||
@ -88,17 +84,21 @@ public class PerkAxeThrower extends Perk implements IThrown
|
|||||||
//Effect
|
//Effect
|
||||||
data.getThrown().getWorld().playSound(data.getThrown().getLocation(), Sound.ZOMBIE_WOOD, 1f, 1.6f);
|
data.getThrown().getWorld().playSound(data.getThrown().getLocation(), Sound.ZOMBIE_WOOD, 1f, 1.6f);
|
||||||
|
|
||||||
//Re-Drop
|
UtilAction.zeroVelocity(item);
|
||||||
data.getThrown().getWorld().dropItem(data.getThrown().getLocation(), ItemStackFactory.Instance.CreateStack(item.getItemStack().getType())).setPickupDelay(60);
|
item.setPickupDelay(60);
|
||||||
|
|
||||||
//Remove
|
|
||||||
data.getThrown().remove();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void Idle(ProjectileUser data)
|
public void Idle(ProjectileUser data)
|
||||||
{
|
{
|
||||||
|
if (Math.random() < 0.15)
|
||||||
|
{
|
||||||
|
Player thrower = (Player) data.getThrower();
|
||||||
|
|
||||||
|
thrower.sendMessage(F.main("Skill", "Your " + F.item("Axe") + " returned to your inventory."));
|
||||||
|
thrower.getInventory().addItem(((Item) data.getThrown()).getItemStack());
|
||||||
|
data.getThrown().remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,6 +4,8 @@ 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 mineplex.core.common.util.UtilItem;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import nautilus.game.arcade.kit.Perk;
|
import nautilus.game.arcade.kit.Perk;
|
||||||
@ -27,14 +29,15 @@ public class PerkAxeman extends Perk
|
|||||||
Player damager = event.GetDamagerPlayer(false);
|
Player damager = event.GetDamagerPlayer(false);
|
||||||
if (damager == null) return;
|
if (damager == null) return;
|
||||||
|
|
||||||
if (damager.getItemInHand() == null)
|
if (!UtilItem.isAxe(damager.getItemInHand()))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!damager.getItemInHand().getType().toString().contains("_AXE"))
|
if (!Kit.HasKit(damager) || !Recharge.Instance.usable(damager, GetName()))
|
||||||
return;
|
{
|
||||||
|
|
||||||
if (!Kit.HasKit(damager))
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
event.AddMod(damager.getName(), GetName(), 1, false);
|
event.AddMod(damager.getName(), GetName(), 1, false);
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
import nautilus.game.arcade.kit.Perk;
|
import nautilus.game.arcade.kit.Perk;
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ public class PerkBackstab extends Perk
|
|||||||
Player damager = event.GetDamagerPlayer(false);
|
Player damager = event.GetDamagerPlayer(false);
|
||||||
if (damager == null) return;
|
if (damager == null) return;
|
||||||
|
|
||||||
if (!Kit.HasKit(damager))
|
if (!Kit.HasKit(damager) || !Recharge.Instance.usable(damager, GetName()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LivingEntity damagee = event.GetDamageeEntity();
|
LivingEntity damagee = event.GetDamageeEntity();
|
||||||
|
@ -27,14 +27,8 @@ public class PerkBomberHG extends Perk
|
|||||||
{
|
{
|
||||||
private int _spawnRate;
|
private int _spawnRate;
|
||||||
private int _max;
|
private int _max;
|
||||||
private boolean _onlyRestrictNamed;
|
|
||||||
|
|
||||||
public PerkBomberHG(int spawnRate, int max)
|
public PerkBomberHG(int spawnRate, int max)
|
||||||
{
|
|
||||||
this(spawnRate, max, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PerkBomberHG(int spawnRate, int max, boolean onlyRestrictNamed)
|
|
||||||
{
|
{
|
||||||
super("Explosives", new String[]
|
super("Explosives", new String[]
|
||||||
{
|
{
|
||||||
@ -43,7 +37,6 @@ public class PerkBomberHG extends Perk
|
|||||||
|
|
||||||
_spawnRate = spawnRate;
|
_spawnRate = spawnRate;
|
||||||
_max = max;
|
_max = max;
|
||||||
_onlyRestrictNamed = onlyRestrictNamed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Apply(Player player)
|
public void Apply(Player player)
|
||||||
@ -71,14 +64,14 @@ public class PerkBomberHG extends Perk
|
|||||||
if (!Recharge.Instance.use(cur, GetName(), _spawnRate*1000, false, false))
|
if (!Recharge.Instance.use(cur, GetName(), _spawnRate*1000, false, false))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (_onlyRestrictNamed ? UtilInv.contains(cur, F.item("Throwing TNT"), Material.TNT, (byte)0, _max) : UtilInv.contains(cur, Material.TNT, (byte)0, _max))
|
if (UtilInv.contains(cur, Material.TNT, (byte)0, _max))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (UtilPlayer.isSpectator(cur))
|
if (UtilPlayer.isSpectator(cur))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//Add
|
//Add
|
||||||
cur.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.TNT, (byte)0, 1, F.item("Throwing TNT")));
|
cur.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.TNT, (byte)0, 1, F.item(C.Bold + "Throwable TNT")));
|
||||||
|
|
||||||
cur.playSound(cur.getLocation(), Sound.ITEM_PICKUP, 2f, 1f);
|
cur.playSound(cur.getLocation(), Sound.ITEM_PICKUP, 2f, 1f);
|
||||||
}
|
}
|
||||||
@ -90,26 +83,27 @@ public class PerkBomberHG extends Perk
|
|||||||
if (event.isCancelled())
|
if (event.isCancelled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_onlyRestrictNamed ? !UtilInv.IsItem(event.getItemDrop().getItemStack(), F.item("Throwing TNT"), Material.TNT, (byte)0) : !UtilInv.IsItem(event.getItemDrop().getItemStack(), Material.TNT, (byte)0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!Kit.HasKit(event.getPlayer()))
|
if (!Kit.HasKit(event.getPlayer()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!hasPerk(event.getPlayer()))
|
if (!hasPerk(event.getPlayer()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (event.getItemDrop().getItemStack().getType() != Material.TNT)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//Cancel
|
//Cancel
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
//Inform
|
//Inform
|
||||||
UtilPlayer.message(event.getPlayer(), F.main(GetName(), "You cannot drop " + F.item("Throwing TNT") + "."));
|
UtilPlayer.message(event.getPlayer(), F.main(GetName(), "You cannot drop " + F.item("Throwable TNT") + "."));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void TNTInvClick(InventoryClickEvent event)
|
public void TNTInvClick(InventoryClickEvent event)
|
||||||
{
|
{
|
||||||
//boolean containerOpen = !(event.getView().getTopInventory().getHolder() instanceof Player);
|
|
||||||
boolean clickInContainer = event.getClickedInventory() != null && !(event.getClickedInventory().getHolder() instanceof Player);
|
boolean clickInContainer = event.getClickedInventory() != null && !(event.getClickedInventory().getHolder() instanceof Player);
|
||||||
|
|
||||||
if (clickInContainer)
|
if (clickInContainer)
|
||||||
@ -126,7 +120,7 @@ public class PerkBomberHG extends Perk
|
|||||||
if (!hasPerk((Player)event.getWhoClicked()))
|
if (!hasPerk((Player)event.getWhoClicked()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
UtilInv.DisallowMovementOf(event, "Throwing TNT", Material.TNT, (byte) 0, true);
|
UtilInv.DisallowMovementOf(event, "Throwable TNT", Material.TNT, (byte) 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -135,7 +129,7 @@ public class PerkBomberHG extends Perk
|
|||||||
Set<ItemStack> remove = new HashSet<>();
|
Set<ItemStack> remove = new HashSet<>();
|
||||||
|
|
||||||
for (ItemStack item : event.getDrops())
|
for (ItemStack item : event.getDrops())
|
||||||
if (_onlyRestrictNamed ? UtilInv.IsItem(item, "Throwing TNT", Material.TNT, (byte)0) : UtilInv.IsItem(item, Material.TNT, (byte)0))
|
if (UtilInv.IsItem(item, Material.TNT, (byte)0))
|
||||||
remove.add(item);
|
remove.add(item);
|
||||||
|
|
||||||
for (ItemStack item : remove)
|
for (ItemStack item : remove)
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
package nautilus.game.arcade.kit.perks;
|
package nautilus.game.arcade.kit.perks;
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.common.util.UtilGear;
|
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
|
||||||
import mineplex.core.common.util.UtilTime;
|
|
||||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
|
||||||
import nautilus.game.arcade.kit.Perk;
|
|
||||||
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
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 org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.UtilGear;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.kit.Perk;
|
||||||
|
|
||||||
public class PerkCleave extends Perk
|
public class PerkCleave extends Perk
|
||||||
{
|
{
|
||||||
private boolean _axeOnly;
|
private boolean _axeOnly;
|
||||||
@ -21,7 +22,7 @@ public class PerkCleave extends Perk
|
|||||||
{
|
{
|
||||||
super("Cleave", new String[]
|
super("Cleave", new String[]
|
||||||
{
|
{
|
||||||
C.cGray + "Attacks deal " + (int)(100*splash) + "% damage to nearby enemies",
|
C.cGray + "Attacks deal " + (int) (100 * splash) + "% damage to nearby enemies",
|
||||||
});
|
});
|
||||||
|
|
||||||
_axeOnly = axeOnly;
|
_axeOnly = axeOnly;
|
||||||
@ -30,8 +31,10 @@ public class PerkCleave extends Perk
|
|||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void Skill(CustomDamageEvent event)
|
public void Skill(CustomDamageEvent event)
|
||||||
{
|
{
|
||||||
if (event.IsCancelled())
|
if (event.IsCancelled() || event.GetDamageePlayer() == null || event.GetCause() != DamageCause.ENTITY_ATTACK)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (event.GetCause() != DamageCause.ENTITY_ATTACK)
|
if (event.GetCause() != DamageCause.ENTITY_ATTACK)
|
||||||
return;
|
return;
|
||||||
@ -39,13 +42,12 @@ public class PerkCleave extends Perk
|
|||||||
if (event.GetReason() != null)
|
if (event.GetReason() != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//Dont allow usage in early game
|
|
||||||
if (!UtilTime.elapsed(Manager.GetGame().GetStateTime(), 30000))
|
|
||||||
return;
|
|
||||||
|
|
||||||
//Damager
|
//Damager
|
||||||
Player damager = event.GetDamagerPlayer(false);
|
Player damager = event.GetDamagerPlayer(false);
|
||||||
if (damager == null) return;
|
if (damager == null || !Recharge.Instance.usable(damager, GetName()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (_axeOnly && !UtilGear.isAxe(damager.getItemInHand()))
|
if (_axeOnly && !UtilGear.isAxe(damager.getItemInHand()))
|
||||||
return;
|
return;
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package nautilus.game.arcade.kit.perks;
|
package nautilus.game.arcade.kit.perks;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -18,11 +16,11 @@ import mineplex.core.common.util.UtilMath;
|
|||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
|
|
||||||
import nautilus.game.arcade.kit.Perk;
|
import nautilus.game.arcade.kit.Perk;
|
||||||
|
|
||||||
public class PerkHiltSmash extends Perk
|
public class PerkHiltSmash extends Perk
|
||||||
{
|
{
|
||||||
private HashSet<Player> _used = new HashSet<Player>();
|
|
||||||
|
|
||||||
public PerkHiltSmash()
|
public PerkHiltSmash()
|
||||||
{
|
{
|
||||||
@ -32,7 +30,7 @@ public class PerkHiltSmash extends Perk
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean CanUse(Player player)
|
private boolean CanUse(Player player)
|
||||||
{
|
{
|
||||||
if (!Kit.HasKit(player))
|
if (!Kit.HasKit(player))
|
||||||
return false;
|
return false;
|
||||||
@ -74,12 +72,9 @@ public class PerkHiltSmash extends Perk
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set Used
|
|
||||||
_used.add(player);
|
|
||||||
|
|
||||||
//Damage Event
|
//Damage Event
|
||||||
Manager.GetDamage().NewDamageEvent((LivingEntity)ent, player, null,
|
Manager.GetDamage().NewDamageEvent((LivingEntity)ent, player, null,
|
||||||
DamageCause.ENTITY_ATTACK, 5, false, true, false,
|
DamageCause.ENTITY_ATTACK, 2, false, true, true,
|
||||||
player.getName(), GetName());
|
player.getName(), GetName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +98,6 @@ public class PerkHiltSmash extends Perk
|
|||||||
|
|
||||||
//Condition
|
//Condition
|
||||||
Manager.GetCondition().Factory().Slow(GetName(), damagee, damager, 2, 1, false, false, true, true);
|
Manager.GetCondition().Factory().Slow(GetName(), damagee, damager, 2, 1, false, false, true, true);
|
||||||
Manager.GetCondition().Factory().Blind(GetName(), damagee, damager, 2, 1, false, false, false);
|
|
||||||
|
|
||||||
//Effect
|
//Effect
|
||||||
damagee.getWorld().playSound(damagee.getLocation(), Sound.ZOMBIE_WOOD, 1f, 1.2f);
|
damagee.getWorld().playSound(damagee.getLocation(), Sound.ZOMBIE_WOOD, 1f, 1.2f);
|
||||||
|
@ -2,6 +2,7 @@ package nautilus.game.arcade.kit.perks;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@ -31,9 +32,8 @@ import mineplex.core.updater.UpdateType;
|
|||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.core.utils.UtilVariant;
|
import mineplex.core.utils.UtilVariant;
|
||||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
|
||||||
import nautilus.game.arcade.events.PlayerStateChangeEvent;
|
import nautilus.game.arcade.events.PlayerStateChangeEvent;
|
||||||
import nautilus.game.arcade.game.Game;
|
|
||||||
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
||||||
import nautilus.game.arcade.kit.Perk;
|
import nautilus.game.arcade.kit.Perk;
|
||||||
|
|
||||||
@ -41,8 +41,8 @@ public class PerkHorsePet extends Perk
|
|||||||
{
|
{
|
||||||
private static final ItemStack SADDLE_ITEM = new ItemBuilder(Material.SADDLE).setTitle(C.cGreenB + "Saddle").build();
|
private static final ItemStack SADDLE_ITEM = new ItemBuilder(Material.SADDLE).setTitle(C.cGreenB + "Saddle").build();
|
||||||
|
|
||||||
private HashMap<Player, Horse> _horseMap = new HashMap<Player, Horse>();
|
private final Map<Player, Horse> _horseMap = new HashMap<>();
|
||||||
private HashMap<Player, Long> _deathTime = new HashMap<Player, Long>();
|
private final Map<Player, Long> _deathTime = new HashMap<>();
|
||||||
|
|
||||||
public PerkHorsePet()
|
public PerkHorsePet()
|
||||||
{
|
{
|
||||||
@ -55,7 +55,16 @@ public class PerkHorsePet extends Perk
|
|||||||
@Override
|
@Override
|
||||||
public void Apply(Player player)
|
public void Apply(Player player)
|
||||||
{
|
{
|
||||||
spawnHorse(player, false);
|
Manager.runSyncLater(() -> spawnHorse(player, false), 45 * 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unregisteredEvents()
|
||||||
|
{
|
||||||
|
for (Player player : Manager.GetGame().GetPlayers(true))
|
||||||
|
{
|
||||||
|
despawnHorse(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnHorse(Player player, boolean baby)
|
public void spawnHorse(Player player, boolean baby)
|
||||||
@ -85,20 +94,6 @@ public class PerkHorsePet extends Perk
|
|||||||
Manager.GetGame().CreatureAllowOverride = false;
|
Manager.GetGame().CreatureAllowOverride = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onGameEnd(GameStateChangeEvent event)
|
|
||||||
{
|
|
||||||
if (event.GetState() == Game.GameState.End)
|
|
||||||
{
|
|
||||||
// Players alive at the end of the game don't die, so their horse sticks around.
|
|
||||||
// We need to iterate through them just in case they have a horse to kill.
|
|
||||||
for (Player player : event.GetGame().GetPlayers(true))
|
|
||||||
{
|
|
||||||
despawnHorse(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void horseUpdate(UpdateEvent event)
|
public void horseUpdate(UpdateEvent event)
|
||||||
{
|
{
|
||||||
@ -263,7 +258,6 @@ public class PerkHorsePet extends Perk
|
|||||||
{
|
{
|
||||||
UtilPlayer.message(player, F.main("Mount", "This is not your Horse!"));
|
UtilPlayer.message(player, F.main("Mount", "This is not your Horse!"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,17 +10,25 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||||||
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.UtilBlock;
|
import mineplex.core.common.util.UtilBlock;
|
||||||
|
import mineplex.core.common.util.UtilInv;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
|
|
||||||
import nautilus.game.arcade.kit.Perk;
|
import nautilus.game.arcade.kit.Perk;
|
||||||
|
|
||||||
public class PerkQuickshot extends Perk
|
public class PerkQuickshot extends Perk
|
||||||
{
|
{
|
||||||
private String _name;
|
private final String _name;
|
||||||
private double _power;
|
private final double _power;
|
||||||
private long _recharge;
|
private final long _recharge;
|
||||||
|
private final boolean _useArrow;
|
||||||
|
|
||||||
public PerkQuickshot(String name, double power, long recharge)
|
public PerkQuickshot(String name, double power, long recharge)
|
||||||
|
{
|
||||||
|
this(name, power, recharge, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PerkQuickshot(String name, double power, long recharge, boolean useArrow)
|
||||||
{
|
{
|
||||||
super("Quickshot", new String[]
|
super("Quickshot", new String[]
|
||||||
{
|
{
|
||||||
@ -30,6 +38,7 @@ public class PerkQuickshot extends Perk
|
|||||||
_name = name;
|
_name = name;
|
||||||
_power = power;
|
_power = power;
|
||||||
_recharge = recharge;
|
_recharge = recharge;
|
||||||
|
_useArrow = useArrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -55,9 +64,17 @@ public class PerkQuickshot extends Perk
|
|||||||
if (!Kit.HasKit(player))
|
if (!Kit.HasKit(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (_useArrow && !player.getInventory().contains(Material.ARROW, 1))
|
||||||
|
{
|
||||||
|
player.sendMessage(F.main("Game", "You need an " + F.name("Arrow") + " to use " + F.name(GetName()) + "."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Recharge.Instance.use(player, _name, _recharge, true, true))
|
if (!Recharge.Instance.use(player, _name, _recharge, true, true))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
UtilInv.remove(player, Material.ARROW, (byte) 0, 1);
|
||||||
|
|
||||||
Arrow arrow = player.launchProjectile(Arrow.class);
|
Arrow arrow = player.launchProjectile(Arrow.class);
|
||||||
arrow.setVelocity(player.getLocation().getDirection().multiply(_power));
|
arrow.setVelocity(player.getLocation().getDirection().multiply(_power));
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ import mineplex.core.common.util.UtilAction;
|
|||||||
import mineplex.core.common.util.UtilAlg;
|
import mineplex.core.common.util.UtilAlg;
|
||||||
import mineplex.core.common.util.UtilBlock;
|
import mineplex.core.common.util.UtilBlock;
|
||||||
import mineplex.core.common.util.UtilEnt;
|
import mineplex.core.common.util.UtilEnt;
|
||||||
|
import mineplex.core.common.util.UtilItem;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
import nautilus.game.arcade.kit.Perk;
|
import nautilus.game.arcade.kit.Perk;
|
||||||
@ -45,19 +46,17 @@ public class PerkSeismicSlamHG extends Perk
|
|||||||
if (UtilBlock.usable(event.getClickedBlock()))
|
if (UtilBlock.usable(event.getClickedBlock()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (event.getPlayer().getItemInHand() == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!event.getPlayer().getItemInHand().getType().toString().contains("_SWORD") && !event.getPlayer().getItemInHand().getType().toString().contains("_AXE"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (!Kit.HasKit(player))
|
if (!UtilItem.isAxe(player.getItemInHand()) && !UtilItem.isSword(player.getItemInHand()))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Recharge.Instance.use(player, GetName(), 10000, true, true))
|
if (!Kit.HasKit(player) || !Recharge.Instance.use(player, GetName(), 14000, true, true))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//Action
|
//Action
|
||||||
double range = 6;
|
double range = 6;
|
||||||
@ -73,14 +72,13 @@ public class PerkSeismicSlamHG extends Perk
|
|||||||
//Velocity
|
//Velocity
|
||||||
UtilAction.velocity(cur,
|
UtilAction.velocity(cur,
|
||||||
UtilAlg.getTrajectory2d(player.getLocation().toVector(), cur.getLocation().toVector()),
|
UtilAlg.getTrajectory2d(player.getLocation().toVector(), cur.getLocation().toVector()),
|
||||||
2.2 * targets.get(cur), true, 0, 0.3 + 0.9 * targets.get(cur), 1.2, true);
|
1.8 * targets.get(cur), true, 0, 0.3 + 0.9 * targets.get(cur), 1.2, true);
|
||||||
|
|
||||||
//Condition
|
//Condition
|
||||||
Manager.GetCondition().Factory().Falling(GetName(), cur, player, 10, false, true);
|
Manager.GetCondition().Factory().Falling(GetName(), cur, player, 10, false, true);
|
||||||
|
|
||||||
//Inform
|
//Inform
|
||||||
if (cur instanceof Player)
|
UtilPlayer.message(cur, F.main("Game", F.name(player.getName()) +" hit you with " + F.skill(GetName()) + "."));
|
||||||
UtilPlayer.message((Player)cur, F.main("Game", F.name(player.getName()) +" hit you with " + F.skill(GetName()) + "."));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Effect
|
//Effect
|
||||||
|
@ -9,12 +9,10 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature;
|
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftSkeleton;
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftSkeleton;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -25,6 +23,7 @@ import org.bukkit.event.entity.EntityCombustEvent;
|
|||||||
import org.bukkit.event.entity.EntityTargetEvent;
|
import org.bukkit.event.entity.EntityTargetEvent;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.event.player.PlayerEvent;
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.UtilAlg;
|
import mineplex.core.common.util.UtilAlg;
|
||||||
@ -32,16 +31,16 @@ import mineplex.core.common.util.UtilBlock;
|
|||||||
import mineplex.core.common.util.UtilEnt;
|
import mineplex.core.common.util.UtilEnt;
|
||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
|
|
||||||
import nautilus.game.arcade.events.PlayerStateChangeEvent;
|
import nautilus.game.arcade.events.PlayerStateChangeEvent;
|
||||||
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
||||||
import nautilus.game.arcade.game.games.survivalgames.SurvivalGames;
|
import nautilus.game.arcade.game.games.survivalgames.kit.necroinventory.NecroInventoryMenu;
|
||||||
import nautilus.game.arcade.kit.Perk;
|
import nautilus.game.arcade.kit.Perk;
|
||||||
import net.minecraft.server.v1_8_R3.EntityCreature;
|
|
||||||
import net.minecraft.server.v1_8_R3.NavigationAbstract;
|
|
||||||
|
|
||||||
public class PerkSkeletons extends Perk
|
public class PerkSkeletons extends Perk
|
||||||
{
|
{
|
||||||
@ -56,7 +55,7 @@ public class PerkSkeletons extends Perk
|
|||||||
|
|
||||||
private final PerkSkeletons _perkSkeletons;
|
private final PerkSkeletons _perkSkeletons;
|
||||||
|
|
||||||
public MinionSpawnEvent(Player who, PerkSkeletons perkSkeletons)
|
MinionSpawnEvent(Player who, PerkSkeletons perkSkeletons)
|
||||||
{
|
{
|
||||||
super(who);
|
super(who);
|
||||||
|
|
||||||
@ -75,7 +74,8 @@ public class PerkSkeletons extends Perk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<Player, List<Skeleton>> _minions = new HashMap<>();
|
private final Map<Player, List<Skeleton>> _minions = new HashMap<>();
|
||||||
|
private final NecroInventoryMenu _menu;
|
||||||
|
|
||||||
private boolean _name;
|
private boolean _name;
|
||||||
private int _maxDist = 8;
|
private int _maxDist = 8;
|
||||||
@ -88,6 +88,19 @@ public class PerkSkeletons extends Perk
|
|||||||
C.cGray + "Killing an opponent summons a skeletal minion."
|
C.cGray + "Killing an opponent summons a skeletal minion."
|
||||||
});
|
});
|
||||||
_name = name;
|
_name = name;
|
||||||
|
_menu = new NecroInventoryMenu(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registeredEvents()
|
||||||
|
{
|
||||||
|
_menu.activate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unregisteredEvents()
|
||||||
|
{
|
||||||
|
_menu.deactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -97,21 +110,13 @@ public class PerkSkeletons extends Perk
|
|||||||
* A location is valid if it meets the following
|
* A location is valid if it meets the following
|
||||||
* criteria:
|
* criteria:
|
||||||
* - The block at and 1 y-value above are both air
|
* - The block at and 1 y-value above are both air
|
||||||
* - It is within the border on X, Y, and Z
|
|
||||||
* @param location - The location at which you want to spawn a skeleton.
|
* @param location - The location at which you want to spawn a skeleton.
|
||||||
* @return Whether the location is valid or not
|
* @return Whether the location is valid or not
|
||||||
*/
|
*/
|
||||||
private boolean isValidSpawn(Location location)
|
private boolean isValidSpawn(Location location)
|
||||||
{
|
{
|
||||||
return location.getBlock().getType() == Material.AIR
|
return location.getBlock().getType() == Material.AIR
|
||||||
&& location.clone().add(0, 1, 0).getBlock().getType() == Material.AIR
|
&& location.clone().add(0, 1, 0).getBlock().getType() == Material.AIR;
|
||||||
&& !((SurvivalGames) Manager.GetGame()).isOutsideBorder(location);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private double vectorDistance(Location a, Location b)
|
|
||||||
{
|
|
||||||
return a.toVector().distance(b.toVector());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Location getMinionLocation(Location deathLocation)
|
private Location getMinionLocation(Location deathLocation)
|
||||||
@ -132,7 +137,7 @@ public class PerkSkeletons extends Perk
|
|||||||
List<Block> nearbyBlocks = UtilBlock.getBlocksInRadius(deathLocation, MAX_SPAWN_RADIUS, deathLocation.getBlockY())
|
List<Block> nearbyBlocks = UtilBlock.getBlocksInRadius(deathLocation, MAX_SPAWN_RADIUS, deathLocation.getBlockY())
|
||||||
.stream()
|
.stream()
|
||||||
.filter(b -> isValidSpawn(b.getLocation()))
|
.filter(b -> isValidSpawn(b.getLocation()))
|
||||||
.sorted(Comparator.comparingDouble(a -> vectorDistance(a.getLocation(), deathLocation)))
|
.sorted(Comparator.comparingDouble(a -> UtilMath.offsetSquared(a.getLocation(), deathLocation)))
|
||||||
.collect(Collectors.toCollection(LinkedList::new));
|
.collect(Collectors.toCollection(LinkedList::new));
|
||||||
|
|
||||||
if (nearbyBlocks.size() > 0)
|
if (nearbyBlocks.size() > 0)
|
||||||
@ -181,7 +186,14 @@ public class PerkSkeletons extends Perk
|
|||||||
skel.setMaxHealth(30);
|
skel.setMaxHealth(30);
|
||||||
skel.setHealth(skel.getMaxHealth());
|
skel.setHealth(skel.getMaxHealth());
|
||||||
|
|
||||||
skel.getEquipment().setItemInHand(killed.getItemInHand());
|
ItemStack inHand = killed.getItemInHand();
|
||||||
|
|
||||||
|
if (inHand != null && inHand.getType() == Material.MAP)
|
||||||
|
{
|
||||||
|
inHand = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
skel.getEquipment().setItemInHand(inHand);
|
||||||
skel.getEquipment().setHelmet(killed.getInventory().getHelmet());
|
skel.getEquipment().setHelmet(killed.getInventory().getHelmet());
|
||||||
skel.getEquipment().setChestplate(killed.getInventory().getChestplate());
|
skel.getEquipment().setChestplate(killed.getInventory().getChestplate());
|
||||||
skel.getEquipment().setLeggings(killed.getInventory().getLeggings());
|
skel.getEquipment().setLeggings(killed.getInventory().getLeggings());
|
||||||
@ -205,14 +217,11 @@ public class PerkSkeletons extends Perk
|
|||||||
skel.setCustomNameVisible(true);
|
skel.setCustomNameVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_minions.containsKey(killer))
|
_minions.computeIfAbsent(killer, k -> new ArrayList<>()).add(skel);
|
||||||
_minions.put(killer, new ArrayList<>());
|
|
||||||
|
|
||||||
_minions.get(killer).add(skel);
|
|
||||||
|
|
||||||
killer.playSound(killer.getLocation(), Sound.SKELETON_HURT, 1f, 1f);
|
killer.playSound(killer.getLocation(), Sound.SKELETON_HURT, 1f, 1f);
|
||||||
|
|
||||||
Bukkit.getPluginManager().callEvent(new MinionSpawnEvent(killer, this));
|
UtilServer.CallEvent(new MinionSpawnEvent(killer, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -287,12 +296,8 @@ public class PerkSkeletons extends Perk
|
|||||||
//Move
|
//Move
|
||||||
Location target = skel.getLocation().add(UtilAlg.getTrajectory(skel, player).multiply(3));
|
Location target = skel.getLocation().add(UtilAlg.getTrajectory(skel, player).multiply(3));
|
||||||
|
|
||||||
EntityCreature ec = ((CraftCreature) skel).getHandle();
|
|
||||||
NavigationAbstract nav = ec.getNavigation();
|
|
||||||
nav.a(target.getX(), target.getY(), target.getZ(), speed);
|
|
||||||
|
|
||||||
skel.setTarget(null);
|
skel.setTarget(null);
|
||||||
((CraftSkeleton) skel).getHandle().setGoalTarget(null);
|
UtilEnt.CreatureMove(skel, target, speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it's VERY far from the player
|
// If it's VERY far from the player
|
||||||
|
@ -3,6 +3,7 @@ package nautilus.game.arcade.kit.perks;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -11,13 +12,12 @@ import org.bukkit.entity.Arrow;
|
|||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Projectile;
|
import org.bukkit.entity.Projectile;
|
||||||
import org.bukkit.entity.TNTPrimed;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
@ -26,19 +26,21 @@ import mineplex.core.common.util.UtilAction;
|
|||||||
import mineplex.core.common.util.UtilAlg;
|
import mineplex.core.common.util.UtilAlg;
|
||||||
import mineplex.core.common.util.UtilInv;
|
import mineplex.core.common.util.UtilInv;
|
||||||
import mineplex.core.common.util.UtilParticle;
|
import mineplex.core.common.util.UtilParticle;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
|
||||||
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.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
|
|
||||||
import nautilus.game.arcade.kit.Perk;
|
import nautilus.game.arcade.kit.Perk;
|
||||||
|
|
||||||
public class PerkTNTArrow extends Perk
|
public class PerkTNTArrow extends Perk
|
||||||
{
|
{
|
||||||
private HashSet<Player> _active = new HashSet<Player>();
|
private final Set<Player> _active = new HashSet<>();
|
||||||
private HashSet<Arrow> _arrows = new HashSet<Arrow>();
|
private final Set<Arrow> _arrows = new HashSet<>();
|
||||||
|
|
||||||
public PerkTNTArrow()
|
public PerkTNTArrow()
|
||||||
{
|
{
|
||||||
@ -65,7 +67,7 @@ public class PerkTNTArrow extends Perk
|
|||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (!Kit.HasKit(player))
|
if (!Kit.HasKit(player) || !Recharge.Instance.usable(player, GetName(), true))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -104,8 +106,10 @@ public class PerkTNTArrow extends Perk
|
|||||||
|
|
||||||
Player player = (Player)event.getEntity();
|
Player player = (Player)event.getEntity();
|
||||||
|
|
||||||
if (!_active.remove(player))
|
if (!_active.remove(player) || !Recharge.Instance.use(player, GetName(), 8000, true, true))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//Inform
|
//Inform
|
||||||
UtilPlayer.message(player, F.main("Game", "You fired " + F.skill(GetName()) + "."));
|
UtilPlayer.message(player, F.main("Game", "You fired " + F.skill(GetName()) + "."));
|
||||||
@ -152,9 +156,7 @@ public class PerkTNTArrow extends Perk
|
|||||||
|
|
||||||
final Arrow arrow = (Arrow)proj;
|
final Arrow arrow = (Arrow)proj;
|
||||||
|
|
||||||
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
|
Manager.runSyncLater(() ->
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -166,7 +168,6 @@ public class PerkTNTArrow extends Perk
|
|||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
//Remove
|
//Remove
|
||||||
@ -223,8 +224,7 @@ public class PerkTNTArrow extends Perk
|
|||||||
0.4 + 0.8 * range, false, 0, 0.2 + 0.5 * range, 1.2, true);
|
0.4 + 0.8 * range, false, 0, 0.2 + 0.5 * range, 1.2, true);
|
||||||
|
|
||||||
//Inform
|
//Inform
|
||||||
if (cur instanceof Player)
|
UtilPlayer.message(cur, F.main("Game", F.name(player.getName()) +" hit you with " + F.skill(GetName()) + "."));
|
||||||
UtilPlayer.message((Player)cur, F.main("Game", F.name(player.getName()) +" hit you with " + F.skill(GetName()) + "."));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, loc, 0, 0, 0, 0, 1,
|
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, loc, 0, 0, 0, 0, 1,
|
||||||
@ -239,7 +239,6 @@ public class PerkTNTArrow extends Perk
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
for (Entity ent : _arrows)
|
for (Entity ent : _arrows)
|
||||||
UtilParticle.PlayParticle(ParticleType.LAVA, ent.getLocation(), 0, 0, 0, 0, 1,
|
UtilParticle.PlayParticleToAll(ParticleType.LAVA, ent.getLocation(), 0, 0, 0, 0, 1, ViewDist.LONG);
|
||||||
ViewDist.MAX, UtilServer.getPlayers());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import org.bukkit.DyeColor;
|
|||||||
import org.bukkit.EntityEffect;
|
import org.bukkit.EntityEffect;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature;
|
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftWolf;
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftWolf;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -16,7 +15,9 @@ import org.bukkit.entity.LivingEntity;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Wolf;
|
import org.bukkit.entity.Wolf;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.event.entity.EntityTargetEvent;
|
import org.bukkit.event.entity.EntityTargetEvent;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
@ -28,6 +29,7 @@ import mineplex.core.common.util.SpigotUtil;
|
|||||||
import mineplex.core.common.util.UtilAction;
|
import mineplex.core.common.util.UtilAction;
|
||||||
import mineplex.core.common.util.UtilBlock;
|
import mineplex.core.common.util.UtilBlock;
|
||||||
import mineplex.core.common.util.UtilEnt;
|
import mineplex.core.common.util.UtilEnt;
|
||||||
|
import mineplex.core.common.util.UtilItem;
|
||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
@ -36,12 +38,11 @@ import mineplex.core.recharge.Recharge;
|
|||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
|
|
||||||
import nautilus.game.arcade.events.PlayerStateChangeEvent;
|
import nautilus.game.arcade.events.PlayerStateChangeEvent;
|
||||||
import nautilus.game.arcade.game.GameTeam;
|
import nautilus.game.arcade.game.GameTeam;
|
||||||
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
||||||
import nautilus.game.arcade.kit.Perk;
|
import nautilus.game.arcade.kit.Perk;
|
||||||
import net.minecraft.server.v1_8_R3.EntityCreature;
|
|
||||||
import net.minecraft.server.v1_8_R3.NavigationAbstract;
|
|
||||||
|
|
||||||
public class PerkWolfPet extends Perk
|
public class PerkWolfPet extends Perk
|
||||||
{
|
{
|
||||||
@ -191,23 +192,24 @@ public class PerkWolfPet extends Perk
|
|||||||
//Return to Owner
|
//Return to Owner
|
||||||
double range = 0.5;
|
double range = 0.5;
|
||||||
if (wolf.getTarget() != null)
|
if (wolf.getTarget() != null)
|
||||||
range = 12;
|
range = 9;
|
||||||
|
|
||||||
Location target = player.getLocation().add(player.getLocation().getDirection().multiply(3));
|
Location target = player.getLocation().add(player.getLocation().getDirection().multiply(3));
|
||||||
target.setY(player.getLocation().getY());
|
target.setY(player.getLocation().getY());
|
||||||
|
|
||||||
if (UtilMath.offset(wolf.getLocation(), target) > range)
|
if (UtilMath.offset(wolf.getLocation(), target) > range)
|
||||||
{
|
{
|
||||||
float speed = 1f;
|
float speed = 1.2f;
|
||||||
if (player.isSprinting())
|
if (player.isSprinting())
|
||||||
speed = 1.4f;
|
speed = 1.6f;
|
||||||
|
|
||||||
//Move
|
|
||||||
EntityCreature ec = ((CraftCreature) wolf).getHandle();
|
|
||||||
NavigationAbstract nav = ec.getNavigation();
|
|
||||||
nav.a(target.getX(), target.getY(), target.getZ(), speed);
|
|
||||||
|
|
||||||
wolf.setTarget(null);
|
wolf.setTarget(null);
|
||||||
|
wolf.setAngry(false);
|
||||||
|
UtilEnt.CreatureMove(wolf, target, speed);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wolf.setAngry(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -225,14 +227,13 @@ public class PerkWolfPet extends Perk
|
|||||||
if (UtilBlock.usable(event.getClickedBlock()))
|
if (UtilBlock.usable(event.getClickedBlock()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (event.getPlayer().getItemInHand() == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE") && !event.getPlayer().getItemInHand().getType().toString().contains("_SWORD"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (!UtilItem.isAxe(player.getItemInHand()) && !UtilItem.isSword(player.getItemInHand()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Kit.HasKit(player))
|
if (!Kit.HasKit(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -242,7 +243,7 @@ public class PerkWolfPet extends Perk
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Recharge.Instance.use(player, "Cub Strike", 4000, true, true))
|
if (!Recharge.Instance.use(player, "Cub Strike", 10000, true, true))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Wolf wolf = _petMap.get(player).get(UtilMath.r(_petMap.get(player).size()));
|
Wolf wolf = _petMap.get(player).get(UtilMath.r(_petMap.get(player).size()));
|
||||||
@ -380,18 +381,28 @@ public class PerkWolfPet extends Perk
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void damage(CustomDamageEvent event)
|
public void damage(CustomDamageEvent event)
|
||||||
{
|
{
|
||||||
if (event.GetDamagerEntity(true) == null)
|
if (event.IsCancelled())
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isMinion(event.GetDamagerEntity(true)))
|
LivingEntity damagee = event.GetDamageeEntity();
|
||||||
return;
|
LivingEntity damager = event.GetDamagerEntity(true);
|
||||||
|
|
||||||
|
if (isMinion(damagee) && event.GetCause() == DamageCause.FALL)
|
||||||
|
{
|
||||||
|
event.SetCancelled("Wolf Fall Damage");
|
||||||
|
}
|
||||||
|
else if (damager != null && isMinion(damager))
|
||||||
|
{
|
||||||
double damage = 3;
|
double damage = 3;
|
||||||
|
|
||||||
|
event.GetDamageeEntity().getWorld().playSound(event.GetDamageeEntity().getLocation(), Sound.SUCCESSFUL_HIT, 1, 1);
|
||||||
event.AddMod("Wolf Minion", "Negate", -event.GetDamageInitial(), false);
|
event.AddMod("Wolf Minion", "Negate", -event.GetDamageInitial(), false);
|
||||||
event.AddMod("Wolf Minion", "Damage", damage, false);
|
event.AddMod("Wolf Minion", "Damage", damage, false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,13 +42,10 @@ public class CollectQuestTracker extends QuestTracker<Game>
|
|||||||
super(game, TriggerType.COLLECT);
|
super(game, TriggerType.COLLECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority=EventPriority.LOWEST)
|
@EventHandler(priority=EventPriority.MONITOR)
|
||||||
public void chestRefill(ChestRefillEvent event)
|
public void chestRefill(ChestRefillEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled())
|
_usedChests.removeAll(event.getChests());
|
||||||
return;
|
|
||||||
|
|
||||||
_usedChests.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority=EventPriority.HIGHEST)
|
@EventHandler(priority=EventPriority.HIGHEST)
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
package nautilus.game.arcade.stats;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import nautilus.game.arcade.game.Game;
|
|
||||||
import nautilus.game.arcade.game.games.survivalgames.SupplyChestOpenEvent;
|
|
||||||
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
|
|
||||||
public class FirstSupplyDropOpenStatTracker extends StatTracker<Game>
|
|
||||||
{
|
|
||||||
private Set<Block> _opened = new HashSet<Block>();
|
|
||||||
|
|
||||||
public FirstSupplyDropOpenStatTracker(Game game)
|
|
||||||
{
|
|
||||||
super(game);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
|
||||||
public void onSupplyChestOpen(SupplyChestOpenEvent event)
|
|
||||||
{
|
|
||||||
if (getGame().GetState() != Game.GameState.Live)
|
|
||||||
return;
|
|
||||||
System.out.println("DEBUG 1");
|
|
||||||
if (_opened.contains(event.getChest()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
_opened.add(event.getChest());
|
|
||||||
System.out.println("DEBUG 2");
|
|
||||||
addStat(event.getPlayer(), "SupplyDropsOpened", 1, false, false);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user