Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex

This commit is contained in:
Jonathan Williams 2014-08-19 21:37:11 -04:00
commit 24f984a365
99 changed files with 4029 additions and 847 deletions

View File

@ -12,6 +12,11 @@
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/httpclient-4.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-codec-1.6.jar" path-in-jar="/" />
<element id="file-copy" path="$PROJECT_DIR$/Mineplex.Hub/plugin.yml" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-logging-1.1.1.jar" path-in-jar="/" />
<element id="module-output" name="Mineplex.ServerData" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-pool2-2.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jedis-2.4.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/gson-2.2.1.jar" path-in-jar="/" />
</root>
</artifact>
</component>

View File

@ -1,5 +1,5 @@
<component name="ArtifactManager">
<artifact type="jar" build-on-make="true" name="Mineplex.Hub:test">
<artifact type="jar" name="Mineplex.Hub:test">
<output-path>$PROJECT_DIR$/../Testing/Hub/plugins</output-path>
<root id="archive" name="Hub.jar">
<element id="module-output" name="Mineplex.Core" />
@ -12,6 +12,11 @@
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/httpclient-4.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/httpcore-4.2.jar" path-in-jar="/" />
<element id="file-copy" path="$PROJECT_DIR$/Mineplex.Hub/plugin.yml" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-logging-1.1.1.jar" path-in-jar="/" />
<element id="module-output" name="Mineplex.ServerData" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-pool2-2.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jedis-2.4.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/gson-2.2.1.jar" path-in-jar="/" />
</root>
</artifact>
</component>

View File

@ -0,0 +1,10 @@
<component name="ArtifactManager">
<artifact type="jar" name="Mineplex.MapParser:jar">
<output-path>$PROJECT_DIR$/bin</output-path>
<root id="archive" name="MapParser.jar">
<element id="module-output" name="Mineplex.MapParser" />
<element id="file-copy" path="$PROJECT_DIR$/Mineplex.MapParser/plugin.yml" />
<element id="module-output" name="Mineplex.Core.Common" />
</root>
</artifact>
</component>

View File

@ -0,0 +1,8 @@
<component name="ArtifactManager">
<artifact name="Mineplex.MapParser:test">
<output-path>$PROJECT_DIR$/../Testing/MapParser/plugins</output-path>
<root id="root">
<element id="artifact" artifact-name="Mineplex.MapParser:jar" />
</root>
</artifact>
</component>

View File

@ -5,7 +5,20 @@
<value>
<option name="FIELD_NAME_PREFIX" value="_" />
<option name="STATIC_FIELD_NAME_PREFIX" value="_" />
<option name="USE_SINGLE_CLASS_IMPORTS" value="false" />
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="20" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="10" />
<option name="IMPORT_LAYOUT_TABLE">
<value>
<package name="javax" withSubpackages="true" static="false" />
<package name="java" withSubpackages="true" static="false" />
<emptyLine />
<package name="org.bukkit" withSubpackages="true" static="false" />
<package name="net.minecraft" withSubpackages="true" static="false" />
<emptyLine />
<package name="" withSubpackages="true" static="false" />
<package name="" withSubpackages="true" static="true" />
</value>
</option>
<XML>
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
</XML>

View File

@ -6,6 +6,7 @@
<module fileurl="file://$PROJECT_DIR$/Mineplex.Core/Mineplex.Core.iml" filepath="$PROJECT_DIR$/Mineplex.Core/Mineplex.Core.iml" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.Core.Common/Mineplex.Core.Common.iml" filepath="$PROJECT_DIR$/Mineplex.Core.Common/Mineplex.Core.Common.iml" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.Hub/Mineplex.Hub.iml" filepath="$PROJECT_DIR$/Mineplex.Hub/Mineplex.Hub.iml" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.MapParser/Mineplex.MapParser.iml" filepath="$PROJECT_DIR$/Mineplex.MapParser/Mineplex.MapParser.iml" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.Minecraft.BungeeSigns/Mineplex.Minecraft.BungeeSigns.iml" filepath="$PROJECT_DIR$/Mineplex.Minecraft.BungeeSigns/Mineplex.Minecraft.BungeeSigns.iml" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.Minecraft.Game.ClassCombat/Mineplex.Minecraft.Game.ClassCombat.iml" filepath="$PROJECT_DIR$/Mineplex.Minecraft.Game.ClassCombat/Mineplex.Minecraft.Game.ClassCombat.iml" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml" filepath="$PROJECT_DIR$/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml" />

View File

@ -0,0 +1,27 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Hub" type="Application" factoryName="Application" singleton="true">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" value="org.bukkit.craftbukkit.Main" />
<option name="VM_PARAMETERS" value="" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/../Testing/Hub" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" value="" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="Nautilus.Core.CraftBukkit" />
<envs />
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value="" />
<option name="TRANSPORT" value="0" />
<option name="LOCAL" value="true" />
</RunnerSettings>
<ConfigurationWrapper RunnerId="Debug" />
<method>
<option name="BuildArtifacts" enabled="true">
<artifact name="Mineplex.Hub:test" />
</option>
</method>
</configuration>
</component>

View File

@ -0,0 +1,27 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="MapParser" type="Application" factoryName="Application" singleton="true">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" value="org.bukkit.craftbukkit.Main" />
<option name="VM_PARAMETERS" value="" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/../Testing/MapParser" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" value="" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="Nautilus.Core.CraftBukkit" />
<envs />
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value="" />
<option name="TRANSPORT" value="0" />
<option name="LOCAL" value="true" />
</RunnerSettings>
<ConfigurationWrapper RunnerId="Debug" />
<method>
<option name="BuildArtifacts" enabled="true">
<artifact name="Mineplex.MapParser:test" />
</option>
</method>
</configuration>
</component>

Binary file not shown.

View File

@ -8,6 +8,7 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="Nautilus.Core.CraftBukkit" />
<orderEntry type="library" name="bukkit" level="project" />
<orderEntry type="library" name="craftbukkit" level="project" />
</component>
</module>

View File

@ -146,7 +146,7 @@ public class MapUtil
if (changeChunkBlock(x & 15, y, z & 15, ((CraftWorld) world).getHandle().getChunkAt(x >> 4, z >> 4),
Block.getById(id), data))
{
((CraftWorld) world).getHandle().notify(x, y, z);
//((CraftWorld) world).getHandle().notify(x, y, z);
}
}

View File

@ -1,7 +1,5 @@
package mineplex.core.common.util;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

View File

@ -11,7 +11,7 @@ public class UtilServer
{
return getServer().getOnlinePlayers();
}
public static Server getServer()
{
return Bukkit.getServer();

View File

@ -10,12 +10,13 @@
<orderEntry type="library" name="httpclient" level="project" />
<orderEntry type="library" name="httpcore" level="project" />
<orderEntry type="library" name="commons-codec" level="project" />
<orderEntry type="module" module-name="Mineplex.Core.Common" />
<orderEntry type="module" module-name="Nautilus.Core.CraftBukkit" />
<orderEntry type="library" name="craftbukkit" level="project" />
<orderEntry type="module" module-name="Mineplex.ServerData" />
<orderEntry type="library" name="jedis" level="project" />
<orderEntry type="library" name="commons-pool2" level="project" />
<orderEntry type="module" module-name="Mineplex.Core.Common" />
<orderEntry type="module" module-name="Nautilus.Core.CraftBukkit" />
<orderEntry type="module" module-name="Mineplex.ServerData" />
<orderEntry type="library" name="bukkit" level="project" />
<orderEntry type="library" name="craftbukkit" level="project" />
</component>
</module>

View File

@ -1,13 +1,15 @@
package mineplex.core;
import mineplex.core.account.event.ClientUnloadEvent;
import mineplex.core.account.event.RetrieveClientInformationEvent;
import mineplex.core.common.util.NautHashMap;
import java.util.Collection;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.account.event.ClientUnloadEvent;
import mineplex.core.account.event.RetrieveClientInformationEvent;
import mineplex.core.common.util.NautHashMap;
public abstract class MiniClientPlugin<DataType extends Object> extends MiniPlugin
{
private static Object _clientDataLock = new Object();
@ -48,6 +50,11 @@ public abstract class MiniClientPlugin<DataType extends Object> extends MiniPlug
{
return Get(player.getName());
}
protected Collection<DataType> GetValues()
{
return _clientData.values();
}
protected void Set(Player player, DataType data)
{

View File

@ -15,6 +15,7 @@ import mineplex.core.MiniClientPlugin;
import mineplex.core.account.event.RetrieveClientInformationEvent;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilServer;
import mineplex.core.friend.command.AddFriend;
import mineplex.core.friend.command.DeleteFriend;
import mineplex.core.friend.data.FriendData;
@ -100,7 +101,7 @@ public class FriendManager extends MiniClientPlugin<FriendData> implements IPack
{
public void run()
{
final NautHashMap<String, FriendData> newData = _repository.getFriendsForAll(Bukkit.getOnlinePlayers());
final NautHashMap<String, FriendData> newData = _repository.getFriendsForAll(UtilServer.getPlayers());
Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable()
{

View File

@ -14,6 +14,7 @@
<orderEntry type="module" module-name="Mineplex.Minecraft.Game.ClassCombat" />
<orderEntry type="module" module-name="Mineplex.Minecraft.Game.Core" />
<orderEntry type="module" module-name="Nautilus.Core.CraftBukkit" />
<orderEntry type="library" name="bukkit" level="project" />
<orderEntry type="library" name="craftbukkit" level="project" />
<orderEntry type="module" module-name="Mineplex.ServerData" />
</component>

View File

@ -1,5 +1,8 @@
package mineplex.hub;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.antihack.AntiHack;
import mineplex.core.antistack.AntiStack;
@ -11,7 +14,6 @@ import mineplex.core.disguise.DisguiseManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.elo.EloManager;
import mineplex.core.energy.Energy;
import mineplex.core.friend.FriendManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.logger.Logger;
import mineplex.core.memory.MemoryFix;
@ -35,6 +37,7 @@ import mineplex.core.updater.FileUpdater;
import mineplex.core.updater.Updater;
import mineplex.hub.modules.StackerManager;
import mineplex.hub.party.PartyManager;
import mineplex.hub.poll.PollManager;
import mineplex.hub.queue.QueueManager;
import mineplex.hub.server.ServerManager;
import mineplex.minecraft.game.classcombat.Class.ClassManager;
@ -49,9 +52,6 @@ import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.minecraft.game.core.damage.DamageManager;
import mineplex.minecraft.game.core.fire.Fire;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class Hub extends JavaPlugin implements IRelation
{
private String WEB_CONFIG = "webServer";
@ -86,6 +86,7 @@ public class Hub extends JavaPlugin implements IRelation
NpcManager npcManager = new NpcManager(this, creature);
PetManager petManager = new PetManager(this, clientManager, donationManager, creature, webServerAddress);
new AntiStack(this);
PollManager pollManager = new PollManager(this, donationManager);
//Main Modules
ServerStatusManager serverStatusManager = new ServerStatusManager(this, new LagMeter(this, clientManager));
@ -94,9 +95,9 @@ public class Hub extends JavaPlugin implements IRelation
PartyManager partyManager = new PartyManager(this, clientManager, preferenceManager);
Portal portal = new Portal(this, serverStatusManager.getCurrentServerName());
AntiHack.Initialize(this, punish, portal);
HubManager hubManager = new HubManager(this, new BlockRestore(this), clientManager, donationManager, new ConditionManager(this), new DisguiseManager(this, packetHandler), new TaskManager(this, webServerAddress), portal, partyManager, preferenceManager, petManager);
HubManager hubManager = new HubManager(this, new BlockRestore(this), clientManager, donationManager, new ConditionManager(this), new DisguiseManager(this, packetHandler), new TaskManager(this, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager);
new PlayerTracker(this, serverStatusManager.getCurrentServerName(), serverStatusManager.getUs());
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this), partyManager);
new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, new StackerManager(hubManager), queueManager);

View File

@ -18,8 +18,8 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
@ -48,19 +48,15 @@ import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.disguise.disguises.DisguiseSlime;
import mineplex.core.donation.DonationManager;
import mineplex.core.donation.Donor;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
import mineplex.core.inventory.InventoryManager;
@ -76,9 +72,17 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.commands.ForcefieldRadius;
import mineplex.hub.commands.NewsCommand;
import mineplex.hub.modules.*;
import mineplex.hub.modules.ForcefieldManager;
import mineplex.hub.modules.JumpManager;
import mineplex.hub.modules.MapManager;
import mineplex.hub.modules.NewsManager;
import mineplex.hub.modules.ParkourManager;
import mineplex.hub.modules.TextManager;
import mineplex.hub.modules.VisibilityManager;
import mineplex.hub.modules.WorldManager;
import mineplex.hub.party.Party;
import mineplex.hub.party.PartyManager;
import mineplex.hub.poll.PollManager;
import mineplex.hub.tutorial.TutorialManager;
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent;
@ -107,6 +111,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
private PreferencesManager _preferences;
private InventoryManager _inventoryManager;
private NewsManager _news;
private PollManager _pollManager;
private Location _spawn;
private int _scoreboardTick = 0;
@ -124,7 +129,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
//Admin
private boolean _gadgetsEnabled = true;
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager)
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager)
{
super("Hub Manager", plugin);
@ -154,6 +159,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
_partyManager = partyManager;
_preferences = preferences;
_pollManager = pollManager;
_tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator);
_visibilityManager = new VisibilityManager(this);
@ -460,6 +466,15 @@ public class HubManager extends MiniClientPlugin<HubClient>
event.allow();
}
@EventHandler(priority = EventPriority.LOW)
public void AdminOP(PlayerJoinEvent event)
{
if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.ADMIN))
event.getPlayer().setOp(true);
else
event.getPlayer().setOp(false);
}
@EventHandler(priority = EventPriority.LOW)
public void PlayerJoin(PlayerJoinEvent event)
{

View File

@ -42,6 +42,8 @@ import mineplex.core.task.TaskManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.HubManager;
import mineplex.hub.modules.parkour.ParkourData;
import mineplex.hub.modules.parkour.ParkourSnake;
public class ParkourManager extends MiniPlugin
{
@ -51,6 +53,7 @@ public class ParkourManager extends MiniPlugin
private HashSet<ParkourData> _parkour = new HashSet<ParkourData>();
private Location _snakeParkourReturn;
private Location _lavaParkourReturn;
private WeakHashMap<Player, Location> _lavaLocation = new WeakHashMap<Player, Location>();
private WeakHashMap<Player, Long> _lavaTimer = new WeakHashMap<Player, Long>();
@ -85,9 +88,20 @@ public class ParkourManager extends MiniPlugin
"or you will die in flames!"
}, 4000, new Location(Manager.GetSpawn().getWorld(), -93,67,38),
new Location(Manager.GetSpawn().getWorld(), -86,100,42), new Location(Manager.GetSpawn().getWorld(), -120,50,-17)));
_parkour.add(new ParkourSnake("Snake Parkour", new String[]
{
"This parkour requires incredible timing",
"and great agility! Some say it was created",
"by the devil as a cruel joke!"
}, 8000, new Location(Manager.GetSpawn().getWorld(), 22,70,-54),
new Location(Manager.GetSpawn().getWorld(), 28,-50,-88), new Location(Manager.GetSpawn().getWorld(), -24,90,-46)));
_lavaParkourReturn = new Location(Manager.GetSpawn().getWorld(), -89.5,68,36.5);
_lavaParkourReturn.setYaw(90);
_snakeParkourReturn = new Location(Manager.GetSpawn().getWorld(), 16.5,72,-52.5);
_snakeParkourReturn.setYaw(180);
}
public boolean isParkourMode(Player player)
@ -145,7 +159,7 @@ public class ParkourManager extends MiniPlugin
for (ParkourData data : _parkour)
if (UtilMath.offset(player.getLocation(), data.NPC) < 6)
if (Recharge.Instance.use(player, data.Name+" Info", 60000, false, false))
if (Recharge.Instance.use(player, data.Name+" Info", 300000, false, false))
data.Inform(player);
}
}
@ -229,6 +243,25 @@ public class ParkourManager extends MiniPlugin
event.getEntity().leaveVehicle();
event.getEntity().teleport(_lavaParkourReturn);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void snakeReturn(EntityDamageEvent event)
{
if (event.getCause() != DamageCause.VOID)
return;
if (!(event.getEntity() instanceof Player))
return;
Player player = (Player)event.getEntity();
if (!isParkourMode(player))
return;
event.getEntity().eject();
event.getEntity().leaveVehicle();
event.getEntity().teleport(_snakeParkourReturn);
}
@EventHandler
public void lavaBlockReturn(UpdateEvent event)
@ -385,4 +418,16 @@ public class ParkourManager extends MiniPlugin
return false;
}
@EventHandler
public void snakeUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTER)
return;
for (ParkourData parkour : _parkour)
if (parkour instanceof ParkourSnake)
((ParkourSnake)parkour).Update();
}
}

View File

@ -5,11 +5,16 @@ import java.util.Iterator;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -25,7 +30,9 @@ import org.bukkit.entity.Boat;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Cow;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Pig;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
@ -42,6 +49,7 @@ import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;

View File

@ -1,4 +1,4 @@
package mineplex.hub.modules;
package mineplex.hub.modules.parkour;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAlg;
@ -7,6 +7,7 @@ import mineplex.core.common.util.UtilPlayer;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.entity.Player;
public class ParkourData
@ -55,4 +56,9 @@ public class ParkourData
{
return (UtilAlg.inBoundingBox(loc, CornerA, CornerB));
}
public World getWorld()
{
return CornerA.getWorld();
}
}

View File

@ -0,0 +1,213 @@
package mineplex.hub.modules.parkour;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import org.bukkit.Location;
import mineplex.core.common.util.UtilMath;
public class ParkourSnake extends ParkourData
{
private ArrayList<SnakePart> _snakes;
public ParkourSnake(String name, String[] desc, int gems, Location npc, Location cornerA, Location cornerB)
{
super(name, desc, gems, npc, cornerA, cornerB);
//THIS SHOULD BE COMMENTED OUT
//parseSnakes();
loadSnakes();
}
public void loadSnakes()
{
_snakes = new ArrayList<SnakePart>();
try
{
BufferedReader br = new BufferedReader(new FileReader("SnakeRoutes.dat"));
try
{
String line = br.readLine();
while (line != null)
{
if (line.length() > 6)
_snakes.add(loadSnake(line));
line = br.readLine();
}
}
finally
{
br.close();
}
}
catch (Exception e)
{
e.printStackTrace();
}
System.out.println("Done");
}
public SnakePart loadSnake(String locString)
{
ArrayList<Location> locs = new ArrayList<Location>();
for (String cur : locString.split(":"))
{
String[] tokens = cur.split(",");
try
{
Location loc = new Location(getWorld(), Integer.parseInt(tokens[0]), Integer.parseInt(tokens[1]), Integer.parseInt(tokens[2]));
if (InBoundary(loc))
locs.add(loc);
}
catch (Exception e)
{
System.out.println("Invalid Hub Snake Location: " + cur);
}
}
return new SnakePart(locs);
}
public void parseSnakes()
{
String locString = "-22,78,-72:-22,79,-72:-22,80,-72:-22,80,-71:-22,80,-70:-22,80,-69:-22,78,-68:-22,79,-68:-22,80,-68:-22,79,-57:-22,79,-56:-22,79,-55:-22,79,-54:-22,79,-53:-21,75,-78:-21,76,-78:-21,77,-78:-21,75,-77:-21,75,-76:-21,75,-75:-21,75,-74:-21,76,-74:-21,77,-74:-21,78,-74:-21,78,-73:-21,78,-72:-21,76,-68:-21,77,-68:-21,78,-68:-21,76,-67:-21,76,-66:-21,76,-65:-21,76,-64:-21,77,-64:-21,78,-64:-21,79,-64:-21,79,-63:-21,77,-62:-21,78,-62:-21,79,-62:-21,79,-57:-21,79,-56:-21,79,-55:-21,79,-54:-21,79,-53:-20,77,-78:-20,77,-62:-20,79,-57:-20,79,-56:-20,79,-55:-20,79,-54:-20,79,-53:-19,75,-78:-19,76,-78:-19,77,-78:-19,75,-77:-19,75,-76:-19,75,-75:-19,75,-74:-19,77,-74:-19,78,-74:-19,79,-74:-19,75,-73:-19,76,-73:-19,77,-73:-19,77,-62:-18,79,-74:-18,77,-62:-17,79,-74:-17,77,-62:-16,79,-74:-16,77,-62:-15,77,-74:-15,78,-74:-15,79,-74:-15,75,-73:-15,76,-73:-15,77,-73:-15,75,-72:-15,75,-71:-15,75,-70:-15,75,-69:-15,76,-69:-15,77,-69:-15,77,-68:-15,77,-67:-15,77,-66:-15,77,-65:-15,77,-64:-15,77,-63:-15,77,-62:-11,77,-68:-11,78,-68:-11,79,-68:-11,77,-67:-11,77,-66:-11,77,-65:-11,78,-65:-11,79,-65:-10,79,-68:-10,79,-65:-9,79,-68:-9,79,-65:-8,77,-68:-8,78,-68:-8,79,-68:-8,77,-67:-8,77,-66:-8,77,-65:-8,78,-65:-8,79,-65:-7,75,-75:-7,75,-74:-7,75,-73:-7,76,-73:-7,77,-73:-7,73,-71:-7,74,-71:-7,75,-71:-7,73,-70:-7,73,-69:-7,72,-66:-7,73,-66:-7,74,-66:-7,72,-65:-7,72,-64:-7,72,-63:-7,73,-63:-7,74,-63:-7,75,-63:-6,71,-79:-6,72,-79:-6,73,-79:-6,74,-79:-6,75,-79:-6,75,-78:-6,76,-78:-6,77,-78:-6,75,-75:-6,77,-73:-6,75,-71:-6,73,-69:-6,74,-66:-6,75,-63:-5,71,-79:-5,77,-78:-5,75,-75:-5,75,-74:-5,75,-73:-5,76,-73:-5,77,-73:-5,73,-71:-5,74,-71:-5,75,-71:-5,73,-70:-5,73,-69:-5,77,-69:-5,77,-68:-5,77,-67:-5,74,-66:-5,75,-66:-5,76,-66:-5,77,-66:-5,72,-63:-5,73,-63:-5,74,-63:-5,75,-63:-4,71,-79:-4,77,-78:-4,77,-69:-4,72,-63:-3,71,-79:-3,77,-78:-3,77,-69:-3,72,-63:-2,71,-79:-2,73,-79:-2,74,-79:-2,75,-79:-2,75,-78:-2,76,-78:-2,77,-78:-2,74,-69:-2,75,-69:-2,76,-69:-2,77,-69:-2,74,-68:-2,74,-67:-2,74,-66:-2,74,-65:-2,75,-65:-2,76,-65:-2,76,-64:-2,72,-63:-2,73,-63:-2,74,-63:-2,75,-63:-2,76,-63:-1,71,-79:-1,73,-79:0,71,-79:0,73,-79:1,71,-79:1,73,-79:1,74,-79:1,75,-79:1,75,-78:1,76,-78:1,77,-78:2,71,-79:2,77,-78:3,71,-79:3,77,-78:4,71,-79:4,73,-79:4,74,-79:4,75,-79:4,75,-78:4,76,-78:4,77,-78:5,71,-79:5,73,-79:6,71,-79:6,73,-79:7,71,-79:7,73,-79:7,74,-79:7,75,-79:7,75,-78:7,76,-78:7,77,-78:7,69,-67:7,70,-67:7,71,-67:7,71,-66:7,71,-65:7,69,-64:7,70,-64:7,71,-64:8,71,-79:8,77,-78:8,66,-74:8,67,-74:8,68,-74:8,68,-73:8,68,-72:8,68,-71:8,68,-70:8,68,-69:8,69,-69:8,70,-69:8,71,-69:8,69,-67:8,69,-64:9,71,-79:9,77,-78:9,66,-74:9,71,-69:9,69,-67:9,69,-64:10,71,-79:10,72,-79:10,73,-79:10,74,-79:10,75,-79:10,75,-78:10,76,-78:10,77,-78:10,66,-74:10,68,-74:10,69,-74:10,70,-74:10,71,-74:10,71,-73:10,69,-72:10,70,-72:10,71,-72:10,69,-71:10,69,-70:10,69,-69:10,70,-69:10,71,-69:10,69,-67:10,70,-67:10,71,-67:10,71,-66:10,71,-65:10,69,-64:10,70,-64:10,71,-64:11,66,-74:11,68,-74:12,66,-74:12,68,-74:13,75,-80:13,76,-80:13,77,-80:13,75,-79:13,75,-78:13,75,-77:13,76,-77:13,77,-77:13,66,-74:13,68,-74:13,69,-74:13,70,-74:13,71,-74:13,72,-74:13,71,-67:13,71,-66:13,71,-65:13,69,-64:13,70,-64:13,71,-64:13,69,-63:13,69,-62:13,69,-61:13,69,-60:13,69,-59:13,69,-58:14,77,-80:14,77,-77:14,66,-74:14,72,-74:14,71,-67:14,69,-58:15,77,-80:15,77,-77:15,66,-74:15,71,-74:15,72,-74:15,69,-67:15,70,-67:15,71,-67:15,69,-58:16,75,-80:16,76,-80:16,77,-80:16,75,-79:16,75,-78:16,75,-77:16,76,-77:16,77,-77:16,66,-74:16,71,-74:16,69,-67:16,69,-58:17,66,-74:17,71,-74:17,69,-67:17,69,-58:18,66,-74:18,71,-74:18,72,-74:18,73,-74:18,69,-67:18,70,-67:18,69,-58:19,74,-79:19,74,-78:19,74,-77:19,66,-74:19,73,-74:19,70,-67:19,67,-62:19,68,-62:19,69,-62:19,69,-61:19,69,-60:19,69,-59:19,69,-58:20,74,-79:20,74,-77:20,66,-74:20,67,-74:20,68,-74:20,69,-74:20,70,-74:20,71,-74:20,72,-74:20,73,-74:20,68,-67:20,69,-67:20,70,-67:20,67,-62:21,72,-79:21,73,-79:21,74,-79:21,72,-78:21,72,-77:21,73,-77:21,74,-77:21,68,-67:21,67,-62:22,68,-67:22,69,-67:22,70,-67:22,70,-66:22,69,-65:22,70,-65:22,69,-64:22,69,-63:22,67,-62:22,68,-62:22,69,-62:";
ArrayList<Location> locs = new ArrayList<Location>();
for (String cur : locString.split(":"))
{
String[] tokens = cur.split(",");
try
{
Location loc = new Location(getWorld(), Integer.parseInt(tokens[0]), Integer.parseInt(tokens[1]), Integer.parseInt(tokens[2]));
if (InBoundary(loc))
locs.add(loc);
}
catch (Exception e)
{
System.out.println("Invalid Hub Snake Location: " + cur);
}
}
ArrayList<ArrayList<Location>> snakes = new ArrayList<ArrayList<Location>>();
//Get Blacks
Iterator<Location> locIterator = locs.iterator();
while (locIterator.hasNext())
{
Location loc = locIterator.next();
if (loc.getBlock().getData() != 0)
continue;
ArrayList<Location> newSnake = new ArrayList<Location>();
newSnake.add(loc);
snakes.add(newSnake);
locIterator.remove();
}
//Get Body
int partsAdded = 1;
while (partsAdded > 0)
{
partsAdded = 0;
locIterator = locs.iterator();
while (locIterator.hasNext())
{
Location loc = locIterator.next();
if (loc.getBlock().getData() == 15)
continue;
for (ArrayList<Location> snake : snakes)
{
if (UtilMath.offset(loc, snake.get(snake.size() - 1)) != 1)
continue;
snake.add(loc);
locIterator.remove();
partsAdded++;
}
}
}
//Get Tail
try
{
locIterator = locs.iterator();
while (locIterator.hasNext())
{
Location loc = locIterator.next();
for (ArrayList<Location> snake : snakes)
{
if (UtilMath.offset(loc, snake.get(snake.size() - 1)) != 1)
continue;
snake.add(loc);
locIterator.remove();
partsAdded++;
}
}
}
catch (Exception e)
{
e.printStackTrace();
}
//Write
try
{
File file = new File("SnakeRoutes.dat");
if (!file.exists())
file.createNewFile();
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
for (ArrayList<Location> snake : snakes)
{
String out = "";
for (Location loc : snake)
out += loc.getBlockX() + "," + loc.getBlockY() + "," + loc.getBlockZ() + ":";
bw.write(out + "\n\n\n");
}
bw.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
public void Update()
{
for (SnakePart snake : _snakes)
snake.Update();
}
}

View File

@ -0,0 +1,99 @@
package mineplex.hub.modules.parkour;
import java.util.ArrayList;
import java.util.Iterator;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
public class SnakePart
{
private ArrayList<Location> _path = new ArrayList<Location>();
private byte _color = 0;
private int _index = 0;
private boolean _colorTick = false;
private int _pathId = 39;
public SnakePart(ArrayList<Location> path)
{
_path = path;
_color = path.get(1).getBlock().getData();
for (Location loc : path)
MapUtil.QuickChangeBlockAt(loc, 35, _color);
}
public void Update()
{
if (_path.isEmpty())
return;
//Set Block
sendBlock(_path.get(_index), 35, GetColor());
int back = _index - 10;
while (back < 0)
back += _path.size();
//Unset Tail
sendBlock(_path.get(back), _pathId, (byte) 0);
//ALT
if (_path.size() > 50)
{
int newIndex = (_index + (_path.size()/2))%_path.size();
//Set Block
sendBlock(_path.get(newIndex), 35, GetColor());
back = newIndex - 10;
if (back < 0)
back += _path.size();
//Unset Tail
sendBlock(_path.get(back), _pathId, (byte) 0);
}
_index = (_index+1)%_path.size();
_colorTick = !_colorTick;
/*
for (Location loc : _path)
if (loc.getBlock().getType() == Material.AIR)
UtilParticle.PlayParticle(ParticleType.CRIT, loc, 0, 0, 0, 0, 1);
*/
}
public void sendBlock(Location loc, int id, byte data)
{
MapUtil.ChunkBlockChange(loc, id, data);
for (Player player : UtilServer.getPlayers())
{
if (UtilMath.offset(player.getLocation(), loc) < 64)
{
player.sendBlockChange(loc, Material.getMaterial(id), data);
}
}
}
public byte GetColor()
{
if (_colorTick)
return _color;
return _color;
}
}

View File

@ -0,0 +1,46 @@
package mineplex.hub.poll;
import mineplex.core.common.util.NautHashMap;
/**
* Created by Shaun on 8/17/2014.
*/
public class PlayerPollData
{
// Cooldown for next poll if the player doesn't answer
private static long POLL_COOLDOWN = 180000;
private NautHashMap<Integer, Integer> _pollAnswers;
private long _nextPollTime;
public PlayerPollData()
{
_pollAnswers = new NautHashMap<Integer, Integer>();
}
public boolean hasAnswered(Poll poll)
{
return _pollAnswers.containsKey(poll.getId());
}
public void addAnswer(int pollId, int answer)
{
_pollAnswers.put(pollId, answer);
}
public void updatePollCooldown()
{
_nextPollTime = System.currentTimeMillis() + POLL_COOLDOWN;
}
public void setPollCooldown(long cooldown)
{
_nextPollTime = System.currentTimeMillis() + cooldown;
}
public boolean shouldPoll()
{
return System.currentTimeMillis() > _nextPollTime;
}
}

View File

@ -0,0 +1,59 @@
package mineplex.hub.poll;
/**
* Created by Shaun on 8/16/2014.
*/
public class Poll
{
private int _id;
private int _coinReward;
private String _question;
private String[] _answers;
public Poll(int id, int coinReward, String question, String answerA, String answerB, String answerC, String answerD)
{
_id = id;
_coinReward = coinReward;
_question = question;
_answers = new String[4];
_answers[0] = answerA;
_answers[1] = answerB;
_answers[2] = answerC;
_answers[3] = answerD;
}
public int getId()
{
return _id;
}
public String getQuestion()
{
return _question;
}
public String[] getAnswers()
{
return _answers;
}
public boolean hasAnswer(int number)
{
return number > 0 && number <= _answers.length && _answers[number - 1] != null && _answers[number - 1].length() > 0;
}
public int getCoinReward()
{
return _coinReward;
}
@Override
public boolean equals(Object object)
{
if (object instanceof Poll)
{
return ((Poll) object).getId() == getId();
}
return false;
}
}

View File

@ -0,0 +1,212 @@
package mineplex.hub.poll;
import java.util.List;
import java.util.UUID;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import net.minecraft.server.v1_7_R4.ChatSerializer;
import net.minecraft.server.v1_7_R4.PacketPlayOutChat;
import net.minecraft.util.com.google.gson.JsonObject;
import mineplex.core.MiniClientPlugin;
import mineplex.core.account.event.RetrieveClientInformationEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.poll.command.PollCommand;
/**
* Created by Shaun on 8/16/2014.
*/
public class PollManager extends MiniClientPlugin<PlayerPollData>
{
private PollRepository _repository;
private DonationManager _donationManager;
private List<Poll> _polls;
public PollManager(JavaPlugin plugin, DonationManager donationManager)
{
super("PollManager", plugin);
_repository = new PollRepository(plugin);
_donationManager = donationManager;
plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable()
{
@Override
public void run()
{
_polls = _repository.retrievePolls();
}
}, 1L, 1200L);
}
@Override
protected PlayerPollData AddPlayer(String player)
{
return new PlayerPollData();
}
@Override
protected void loadClientInformation(final RetrieveClientInformationEvent event)
{
event.incrementProcessingCount();
_plugin.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable()
{
@Override
public void run()
{
Set(event.getPlayerName(), _repository.loadPollData(event.getUniqueId()));
event.decreaseProcessingCount();
}
});
}
@EventHandler
public void join(PlayerJoinEvent event)
{
PlayerPollData pollData = Get(event.getPlayer());
pollData.setPollCooldown(5000);
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.SLOW)
return;
for (Player player : _plugin.getServer().getOnlinePlayers())
{
PlayerPollData pollData = Get(player);
if (pollData.shouldPoll())
{
Poll nextPoll = getNextPoll(pollData);
if (nextPoll != null)
displayPoll(player, nextPoll);
// Update the poll cooldown even if there isn't a poll available
pollData.updatePollCooldown();
}
}
}
public Poll getNextPoll(PlayerPollData pollData)
{
for (Poll poll : _polls)
{
if (!pollData.hasAnswered(poll))
return poll;
}
return null;
}
public void displayPoll(Player player, Poll poll)
{
String[] answers = poll.getAnswers();
player.sendMessage(C.cGold + C.Bold + "-----------" + C.cYellow + C.Bold + "POLL" + C.cGold + C.Bold + "-----------");
player.sendMessage(poll.getQuestion());
player.sendMessage("");
for (int i = 1; i <= answers.length; i++)
{
if (answers[i-1] != null && answers[i-1].length() > 0)
{
String message = C.cGreen + i + ". " + answers[i - 1];
// Base message object
JsonObject textObject = new JsonObject();
textObject.addProperty("text", message);
// Object for click event
JsonObject clickObject = new JsonObject();
clickObject.addProperty("action", "run_command");
clickObject.addProperty("value", "/poll " + poll.getId() + " " + i);
// Object for hover event
JsonObject hoverObject = new JsonObject();
hoverObject.addProperty("action", "show_text");
hoverObject.addProperty("value", "Click to Select " + F.elem("#" + i));
// Add the event objects to the base message
textObject.add("clickEvent", clickObject);
textObject.add("hoverEvent", hoverObject);
PacketPlayOutChat chatPacket = new PacketPlayOutChat(ChatSerializer.a(textObject.toString()), true);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(chatPacket);
}
}
player.sendMessage("");
player.sendMessage("Click an answer to receive " + C.cYellow + poll.getCoinReward() + " Coins");
player.sendMessage(C.cGold + C.Bold + "--------------------------");
player.playSound(player.getEyeLocation(), Sound.ORB_PICKUP, 2f, 0f);
}
public void answerPoll(final Player player, final Poll poll, final int answer)
{
final String name = player.getName();
final UUID uuid = player.getUniqueId();
// First update answer locally so we know it was answered
Get(player).addAnswer(poll.getId(), answer);
UtilPlayer.message(player, F.main("Poll", "Thanks for your response!"));
player.playSound(player.getEyeLocation(), Sound.LEVEL_UP, 1F, 0);
// Here we add the answer into the database, and once that is successful we give the coin reward
_plugin.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable()
{
@Override
public void run()
{
if (_repository.addPollAnswer(uuid, poll.getId(), answer))
{
// Poll response successful, give coins
_donationManager.RewardCoins(new Callback<Boolean>()
{
@Override
public void run(Boolean completed)
{
// Need to get out of Async code
_plugin.getServer().getScheduler().runTask(_plugin, new Runnable()
{
@Override
public void run()
{
UtilPlayer.message(player, F.main("Coin", "You received " + F.elem(poll.getCoinReward() + "") + " coins!"));
}
});
}
}, "Poll", name, poll.getCoinReward());
}
}
});
}
public Poll getPoll(int pollId)
{
for (Poll poll : _polls)
{
if (poll.getId() == pollId)
return poll;
}
return null;
}
@Override
public void AddCommands()
{
AddCommand(new PollCommand(this));
}
}

View File

@ -0,0 +1,98 @@
package mineplex.hub.poll;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.database.RepositoryBase;
import mineplex.core.database.ResultSetCallable;
import mineplex.core.database.column.ColumnInt;
import mineplex.core.database.column.ColumnVarChar;
/**
* Created by Shaun on 8/16/2014.
*/
public class PollRepository extends RepositoryBase
{
private static String CREATE_POLL_TABLE = "CREATE TABLE IF NOT EXISTS polls (id INT NOT NULL AUTO_INCREMENT, enabled BIT(1), question VARCHAR(256) NOT NULL, answerA VARCHAR(256) NOT NULL, answerB VARCHAR(256), answerC VARCHAR(256), answerD VARCHAR(256), coinReward INT NOT NULL, PRIMARY KEY (id));";
private static String CREATE_RELATION_TABLE = "CREATE TABLE IF NOT EXISTS accountPolls (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, pollId INT NOT NULL, value TINYINT(1) NOT NULL, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (pollId) REFERENCES polls(id), UNIQUE INDEX accountPollIndex (accountId, pollId));";
private static String RETRIEVE_POLLS = "SELECT id, question, answerA, answerB, answerC, answerD, coinReward FROM polls WHERE enabled IS TRUE ORDER BY coinReward DESC";
private static String RETRIEVE_PLAYER_DATA = "SELECT pollId, value FROM accountPolls INNER JOIN accounts ON accountPolls.accountId = accounts.id WHERE accounts.uuid = ?;";
private static String INSERT_POLL_ANSWER = "INSERT INTO accountPolls (accountId, pollId, value) SELECT accounts.id, ?, ? FROM accounts WHERE accounts.uuid = ?;";
public PollRepository(JavaPlugin plugin)
{
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
}
@Override
protected void initialize()
{
executeUpdate(CREATE_POLL_TABLE);
executeUpdate(CREATE_RELATION_TABLE);
}
@Override
protected void update()
{
}
public List<Poll> retrievePolls()
{
final List<Poll> polls = new ArrayList<Poll>();
executeQuery(RETRIEVE_POLLS, new ResultSetCallable()
{
@Override
public void processResultSet(ResultSet resultSet) throws SQLException
{
while (resultSet.next())
{
int pollId = resultSet.getInt(1);
String question = resultSet.getString(2);
String answerA = resultSet.getString(3);
String answerB = resultSet.getString(4);
String answerC = resultSet.getString(5);
String answerD = resultSet.getString(6);
int coinReward = resultSet.getInt(7);
Poll poll = new Poll(pollId, coinReward, question, answerA, answerB, answerC, answerD);
polls.add(poll);
}
}
});
return polls;
}
public PlayerPollData loadPollData(UUID uuid)
{
final PlayerPollData pollData = new PlayerPollData();
executeQuery(RETRIEVE_PLAYER_DATA, new ResultSetCallable()
{
public void processResultSet(ResultSet resultSet) throws SQLException
{
while (resultSet.next())
{
pollData.addAnswer(resultSet.getInt(1), resultSet.getInt(2));
}
}
}, new ColumnVarChar("uuid", 100, uuid.toString()));
return pollData;
}
public boolean addPollAnswer(UUID uuid, int pollId, int answer)
{
int update = executeUpdate(INSERT_POLL_ANSWER, new ColumnInt("pollId", pollId), new ColumnInt("answer", answer), new ColumnVarChar("uuid", 100, uuid.toString()));
return update == 1;
}
}

View File

@ -0,0 +1,71 @@
package mineplex.hub.poll.command;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.hub.poll.PlayerPollData;
import mineplex.hub.poll.Poll;
import mineplex.hub.poll.PollManager;
/**
* Created by Shaun on 8/17/2014.
*/
public class PollCommand extends CommandBase<PollManager>
{
public PollCommand(PollManager plugin)
{
super(plugin, Rank.ALL, "poll");
}
@Override
public void Execute(Player caller, String[] args)
{
PlayerPollData pollData = Plugin.Get(caller);
if (args == null || args.length != 2)
{
UtilPlayer.message(caller, F.main("Poll", "There was an error processing your poll request"));
return;
}
int pollId = 0;
int answer = 0;
try
{
pollId = Integer.parseInt(args[0]);
answer = Integer.parseInt(args[1]);
}
catch (NumberFormatException e)
{
UtilPlayer.message(caller, F.main("Poll", "Failed to parse your response. Please try again later."));
return;
}
Poll poll = Plugin.getPoll(pollId);
if (poll == null)
{
UtilPlayer.message(caller, F.main("Poll", "That poll no longer exists. Sorry!"));
return;
}
if (!poll.hasAnswer(answer))
{
UtilPlayer.message(caller, F.main("Poll", "That is not a valid response for that poll"));
return;
}
if (pollData.hasAnswered(poll))
{
UtilPlayer.message(caller, F.main("Poll", "You already answered that poll!"));
return;
}
Plugin.answerPoll(caller, poll, answer);
// They answered the poll, queue up the next poll for 5 seconds from now
pollData.setPollCooldown(5000);
}
}

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="Mineplex.Core.Common" />
<orderEntry type="library" name="bukkit" level="project" />
<orderEntry type="library" name="craftbukkit" level="project" />
</component>
</module>

View File

@ -47,7 +47,8 @@ public enum GameType
Tug("Tug of Wool"),
TurfWars("Turf Wars"),
UHC("Ultra Hardcore"),
ZombieSurvival("Zombie Survival");
ZombieSurvival("Zombie Survival"),
None("None");
String _name;
String _lobbyName;
@ -73,4 +74,18 @@ public enum GameType
{
return _lobbyName;
}
public static GameType match(String string)
{
GameType gameType = null;
string = string.toLowerCase();
for (GameType type : values())
{
if (type.name().toLowerCase().startsWith(string) || type.GetName().toLowerCase().startsWith(string))
{
gameType = type;
}
}
return gameType;
}
}

View File

@ -15,19 +15,17 @@ public class MapData
{
public String MapFolder;
public String GameType = "null";
public GameType GameType = null;
public String MapName = "null";
public String MapCreator = "null";
public HashSet<String> WhiteList;
public HashSet<String> BuildList;
public HashSet<String> AdminList;
public MapData(String mapFolder)
{
MapFolder = mapFolder;
WhiteList = new HashSet<String>();
BuildList = new HashSet<String>();
AdminList = new HashSet<String>();
if ((new File(MapFolder + File.separator + "Map.dat")).exists())
Read();
@ -66,17 +64,12 @@ public class MapData
}
else if (tokens[0].equalsIgnoreCase("GAME_TYPE"))
{
GameType = tokens[1];
GameType = GameType.valueOf(tokens[1] == null ? "Null" : tokens[1]);
}
else if (tokens[0].equalsIgnoreCase("WHITE_LIST"))
else if (tokens[0].equalsIgnoreCase("ADMIN_LIST"))
{
for (String cur : tokens[1].split(","))
WhiteList.add(cur);
}
else if (tokens[0].equalsIgnoreCase("BUILD_LIST"))
{
for (String cur : tokens[1].split(","))
BuildList.add(cur);
AdminList.add(cur);
}
}
@ -103,19 +96,12 @@ public class MapData
out.write("\n");
out.write("GAME_TYPE:"+GameType);
String whiteList = "";
for (String cur : WhiteList)
whiteList += cur + ",";
String adminList = "";
for (String cur : AdminList)
adminList += cur + ",";
out.write("\n");
out.write("WHITE_LIST:"+whiteList);
String buildList = "";
for (String cur : BuildList)
buildList += cur + ",";
out.write("\n");
out.write("BUILD_LIST:"+buildList);
out.write("ADMIN_LIST:"+adminList);
out.close();
}
@ -125,13 +111,18 @@ public class MapData
}
}
public boolean CanBuild(Player player)
public boolean HasAccess(Player player)
{
return BuildList.contains(player.getName()) || player.isOp();
return AdminList.contains(player.getName()) || player.isOp();
}
public boolean CanJoin(Player player)
{
return BuildList.contains(player.getName()) || WhiteList.contains(player.getName()) || player.isOp();
return true;
}
public boolean CanRename(Player player)
{
return true;
}
}

View File

@ -1,26 +1,17 @@
package mineplex.mapparser;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import net.minecraft.util.org.apache.commons.io.FileUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.WorldCreator;
import org.bukkit.WorldType;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -40,13 +31,37 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.mapparser.command.AuthorCommand;
import mineplex.mapparser.command.BaseCommand;
import mineplex.mapparser.command.AdminCommand;
import mineplex.mapparser.command.CopyCommand;
import mineplex.mapparser.command.CopySchematicsCommand;
import mineplex.mapparser.command.CreateCommand;
import mineplex.mapparser.command.DeleteCommand;
import mineplex.mapparser.command.GameTypeCommand;
import mineplex.mapparser.command.HubCommand;
import mineplex.mapparser.command.ListCommand;
import mineplex.mapparser.command.MapCommand;
import mineplex.mapparser.command.NameCommand;
import mineplex.mapparser.command.ParseCommand;
import mineplex.mapparser.command.RenameCommand;
import mineplex.mapparser.command.SaveCommand;
import mineplex.mapparser.command.WorldsCommand;
public class MapParser extends JavaPlugin implements Listener
{
private WorldManager _worldManager;
private Parse _curParse = null;
private HashMap<String, MapData> _mapData = new HashMap<String, MapData>();
private List<BaseCommand> _commands = new ArrayList<BaseCommand>();
private Location _spawnLocation;
@Override
public void onEnable()
@ -56,9 +71,26 @@ public class MapParser extends JavaPlugin implements Listener
getServer().getPluginManager().registerEvents(this, this);
getServer().getWorlds().get(0).setSpawnLocation(0, 106, 0);
_spawnLocation = new Location(getServer().getWorlds().get(0), 0, 106, 0);
//Updates
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Ticker(this), 1, 1);
_commands.add(new AuthorCommand(this));
_commands.add(new AdminCommand(this));
_commands.add(new CopySchematicsCommand(this));
_commands.add(new CreateCommand(this));
_commands.add(new DeleteCommand(this));
_commands.add(new GameTypeCommand(this));
_commands.add(new HubCommand(this));
_commands.add(new ListCommand(this));
_commands.add(new MapCommand(this));
_commands.add(new NameCommand(this));
_commands.add(new ParseCommand(this));
_commands.add(new RenameCommand(this));
_commands.add(new SaveCommand(this));
_commands.add(new WorldsCommand(this));
_commands.add(new CopyCommand(this));
}
@Override
@ -72,7 +104,7 @@ public class MapParser extends JavaPlugin implements Listener
{
Player player = event.getPlayer();
player.teleport(new Location(getServer().getWorlds().get(0), 0, 106, 0));
player.teleport(getSpawnLocation());
ResetInventory(event.getPlayer());
@ -82,20 +114,21 @@ public class MapParser extends JavaPlugin implements Listener
public void DisplayHelp(Player player)
{
UtilPlayer.message(player, F.main("Parser", "Listing Commands;"));
UtilPlayer.message(player, F.value("Parameters", "Parameters: <?> = Required, [?] = Optional"));
UtilPlayer.message(player, F.value("/hub", "Return to hub world"));
UtilPlayer.message(player, " ");
UtilPlayer.message(player, F.value("/create <name>", "Creates a new map"));
UtilPlayer.message(player, F.value("/delete <name>", "Deletes an existing map"));
UtilPlayer.message(player, F.value("/map <name>", "Teleport to a map"));
UtilPlayer.message(player, F.value("/list", "List maps"));
UtilPlayer.message(player, F.value("/parse", "Parse your current map!"));
UtilPlayer.message(player, " ");
UtilPlayer.message(player, F.value("/join <name>", "Toggle join for player on map"));
UtilPlayer.message(player, F.value("/build <name>", "Toggle build for player on map"));
UtilPlayer.message(player, " ");
UtilPlayer.message(player, F.value("/name <name>", "Set name for current map"));
UtilPlayer.message(player, F.value("/author <name>", "Set author for current map"));
UtilPlayer.message(player, F.value("/gametype <type", "Set gametype for current map"));
UtilPlayer.message(player, F.value("/gametype <type>", "Set gametype for current map"));
UtilPlayer.message(player, " ");
UtilPlayer.message(player, F.value("/admin <name>", "Toggle admin for player on map"));
UtilPlayer.message(player, " ");
UtilPlayer.message(player, F.value("/create <name> [gametype]", "Creates a new map"));
UtilPlayer.message(player, F.value("/delete <name> [gametype]", "Deletes an existing map"));
UtilPlayer.message(player, F.value("/copy <name> <copy name>", "Copies an existing map"));
UtilPlayer.message(player, " ");
UtilPlayer.message(player, F.value("/list", "List maps"));
UtilPlayer.message(player, F.value("/map <name> [gametype]", "Teleport to a map"));
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cYellow + "Documentation: " + C.cGreen + "http://tinyurl.com/mpxmaps");
@ -104,508 +137,58 @@ public class MapParser extends JavaPlugin implements Listener
@EventHandler
public void Command(PlayerCommandPreprocessEvent event)
{
Player caller = event.getPlayer();
Player player = event.getPlayer();
String[] parts = event.getMessage().split(" ");
String commandLabel = parts[0].substring(1);
String[] args = new String[parts.length - 1];
System.arraycopy(parts, 1, args, 0, parts.length - 1);
if (_curParse != null)
{
UtilPlayer.message(caller, F.main("Parse", "Cannot use commands during Map Parse!"));
UtilPlayer.message(player, F.main("Parser", "Cannot use commands during Map Parse!"));
return;
}
if (event.getMessage().toLowerCase().startsWith("/help"))
{
event.setCancelled(true);
DisplayHelp(caller);
DisplayHelp(player);
}
else if (event.getMessage().toLowerCase().startsWith("/copyschematics"))
{
event.setCancelled(true);
try
{
FileUtils.copyDirectory(new File(".." + File.separator + "Build-1" + File.separator + "plugins" + File.separator + "WorldEdit" + File.separator + "schematics"),
new File("plugins" + File.separator + "WorldEdit" + File.separator + "schematics"));
UtilPlayer.message(caller, F.main("Parser", "Schematics Copied."));
}
catch (IOException e)
{
e.printStackTrace();
UtilPlayer.message(caller, F.main("Parser", "Schematics Copy Failed! Contact Jonalon."));
}
}
else if (event.getMessage().toLowerCase().startsWith("/create"))
{
event.setCancelled(true);
if (event.getMessage().split(" ").length < 2)
{
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/create <MapName>")));
return;
}
String[] args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ");
String worldName = "map_" + args[0];
if (DoesMapExist(worldName))
{
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Map name is already in use!"));
return;
}
Announce("Creating World: " + F.elem(worldName));
WorldCreator worldCreator = new WorldCreator(worldName);
worldCreator.environment(Environment.NORMAL);
worldCreator.type(WorldType.FLAT);
worldCreator.generateStructures(false);
World world = Bukkit.getServer().createWorld(worldCreator);
UtilPlayer.message(caller, F.main("Parser", "Teleporting to World: " + F.elem(worldName)));
event.getPlayer().teleport(new Location(world, 0, 100, 0));
//Give Access
GetData(world.getName()).WhiteList.add(event.getPlayer().getName());
GetData(world.getName()).BuildList.add(event.getPlayer().getName());
GetData(world.getName()).Write();
}
else if (event.getMessage().toLowerCase().startsWith("/delete"))
for (BaseCommand command : _commands)
{
event.setCancelled(true);
if (event.getMessage().split(" ").length < 2)
for (String alias : command.getAliases())
{
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/delete <MapName>")));
return;
}
String[] args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ");
String worldName = "map_" + args[0];
if (!DoesMapExist(worldName))
{
UtilPlayer.message(caller, F.main("Parser", "Map does not exist: " + F.elem(worldName)));
return;
}
if (!GetData(worldName).CanBuild(event.getPlayer()))
{
UtilPlayer.message(caller, F.main("Parser", "You do not have Build-Access on this Map."));
return;
}
if (GetMapWorld(worldName) != null)
{
World world = GetMapWorld(worldName);
//Teleport Out
for (Player other : world.getPlayers())
other.teleport(new Location(getServer().getWorlds().get(0), 0, 106, 0));
//Unload World
MapUtil.UnloadWorld(this, world);
}
//Delete
FileUtils.deleteQuietly(new File(worldName));
Announce("Deleted World: " + F.elem(args[0]));
}
else if (event.getMessage().toLowerCase().startsWith("/save"))
{
event.setCancelled(true);
if (event.getMessage().split(" ").length < 2)
{
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/save <MapName>")));
return;
}
String[] args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ");
String worldName = "map_" + args[0];
if (GetMapWorld(worldName) != null)
{
World world = GetMapWorld(worldName);
if (!GetData(worldName).CanBuild(event.getPlayer()))
if (alias.equalsIgnoreCase(commandLabel))
{
UtilPlayer.message(caller, F.main("Parser", "You do not have Build-Access on this Map."));
if (!command.execute(player, commandLabel, args))
{
UtilPlayer.message(player, F.main("Parser", "Invalid Input."));
UtilPlayer.message(player, F.elem(command.getUsage()));
}
event.setCancelled(true);
return;
}
//Teleport Out
for (Player other : world.getPlayers())
other.teleport(new Location(getServer().getWorlds().get(0), 0, 106, 0));
//Unload World
MapUtil.UnloadWorld(this, world, true);
}
else
{
UtilPlayer.message(caller, F.main("Parser", "World is not loaded: " + F.elem(worldName)));
return;
}
Announce("Saved World: " + F.elem(args[0]));
}
else if (event.getMessage().toLowerCase().startsWith("/hub"))
{
event.setCancelled(true);
event.getPlayer().teleport(new Location(getServer().getWorlds().get(0), 0, 106, 0));
}
else if (event.getMessage().toLowerCase().startsWith("/map"))
{
event.setCancelled(true);
if (event.getMessage().split(" ").length < 2)
{
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/map <MapName>")));
return;
}
String[] args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ");
String worldName = "map_" + args[0];
World world = GetMapWorld(worldName);
if (world == null)
{
if (DoesMapExist(worldName))
{
world = Bukkit.createWorld(new WorldCreator(worldName));
}
else
{
UtilPlayer.message(caller, F.main("Parser", "Map Not Found: " + F.elem(worldName)));
return;
}
}
//Error (This should not occur!)
if (world == null)
{
UtilPlayer.message(caller, F.main("Parser", "Null World Error: " + F.elem(worldName)));
return;
}
//Permission
if (!GetData(world.getName()).CanJoin(event.getPlayer()))
{
UtilPlayer.message(caller, F.main("Parser", "You do not have Join-Access on this Map."));
return;
}
//Teleport
UtilPlayer.message(caller, F.main("Parser", "Teleporting to World: " + F.elem(worldName)));
event.getPlayer().teleport(new Location(world, 0, 100, 0));
MapData data = GetData(worldName);
UtilPlayer.message(event.getPlayer(), F.value("Map Name", data.MapName));
UtilPlayer.message(event.getPlayer(), F.value("Author", data.MapCreator));
UtilPlayer.message(event.getPlayer(), F.value("Game Type", data.GameType));
}
else if (event.getMessage().toLowerCase().startsWith("/list"))
{
event.setCancelled(true);
UtilPlayer.message(caller, F.main("Parser", "Listing Maps;"));
String maps = "";
ChatColor color = ChatColor.YELLOW;
File mapsFolder = new File(".");
for (File file : mapsFolder.listFiles())
{
if (!file.isDirectory())
continue;
if (!file.getName().toLowerCase().startsWith("map_"))
continue;
maps += color + file.getName().substring(4) + " ";
if (color == ChatColor.YELLOW)
color = ChatColor.GOLD;
else
color = ChatColor.YELLOW;
}
event.getPlayer().sendMessage(maps);
}
else if (event.getMessage().toLowerCase().startsWith("/parse"))
{
event.setCancelled(true);
Location parseLoc = event.getPlayer().getLocation();
World world = caller.getWorld();
MapData data = GetData(caller.getWorld().getName());
if (data.MapName.equals("null") || data.MapCreator.equals("null") || data.GameType.equals("null"))
{
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Map Name/Author/GameType are not set!"));
return;
}
//Teleport Players Out
for (Player worldPlayer : world.getPlayers())
{
worldPlayer.teleport(new Location(Bukkit.getWorlds().get(0), 0, 100, 0));
UtilPlayer.message(event.getPlayer(), F.main("Parser", "World " + F.elem(world.getName()) + " is preparing to be parsed."));
}
//Unload World > Copy
World parseableWorld = _worldManager.prepMapParse(world);
if (parseableWorld == null)
{
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Could not prepare world for parsing!"));
return;
}
//Parse the World
_curParse = new Parse(this, parseableWorld, event.getMessage().split(" "), parseLoc, GetData(parseLoc.getWorld().getName()));
}
else if (event.getMessage().toLowerCase().startsWith("/worlds"))
{
event.setCancelled(true);
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Listing Active Worlds;"));
for (World world : this.getServer().getWorlds())
{
event.getPlayer().sendMessage(world.getName());
}
}
//XXX Set Map Data
else if (event.getMessage().toLowerCase().startsWith("/name"))
{
event.setCancelled(true);
if (event.getMessage().split(" ").length < 2)
{
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/name <MapName>")));
return;
}
String input = event.getMessage().substring(event.getMessage().indexOf(' ') + 1);
if (event.getPlayer().getWorld().getName().equals("world"))
{
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Cannot set name for Lobby."));
return;
}
//Permission
if (!GetData(event.getPlayer().getWorld().getName()).CanBuild(event.getPlayer()))
{
UtilPlayer.message(caller, F.main("Parser", "You do not have Build-Access on this Map."));
return;
}
MapData data = GetData(event.getPlayer().getWorld().getName());
data.MapName = input;
data.Write();
Announce("Map Name for " + F.elem(event.getPlayer().getWorld().getName()) + " set to " + F.elem(input) + ".");
}
else if (event.getMessage().toLowerCase().startsWith("/author"))
{
event.setCancelled(true);
if (event.getMessage().split(" ").length < 2)
{
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/author <MapAuthor>")));
return;
}
String input = event.getMessage().substring(event.getMessage().indexOf(' ') + 1);
if (event.getPlayer().getWorld().getName().equals("world"))
{
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Cannot set author for Lobby."));
return;
}
//Permission
if (!GetData(event.getPlayer().getWorld().getName()).CanBuild(event.getPlayer()))
{
UtilPlayer.message(caller, F.main("Parser", "You do not have Build-Access on this Map."));
return;
}
MapData data = GetData(event.getPlayer().getWorld().getName());
data.MapCreator = input;
data.Write();
Announce("Map Author for " + F.elem(event.getPlayer().getWorld().getName()) + " set to " + F.elem(input) + ".");
}
else if (event.getMessage().toLowerCase().startsWith("/gametype"))
{
event.setCancelled(true);
if (event.getMessage().split(" ").length < 2)
{
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/gametype <GameType>")));
return;
}
String[] args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ");
if (event.getPlayer().getWorld().getName().equals("world"))
{
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Cannot set GameType for Lobby."));
return;
}
//Permission
if (!GetData(event.getPlayer().getWorld().getName()).CanBuild(event.getPlayer()))
{
UtilPlayer.message(caller, F.main("Parser", "You do not have Build-Access on this Map."));
return;
}
//Check Gametype
try
{
GameType.valueOf(args[0]);
}
catch (Exception ex)
{
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Valid Game Types;"));
String gameTypes = "";
for (GameType game : GameType.values())
{
gameTypes += game.toString() + " ";
}
event.getPlayer().sendMessage(gameTypes);
return;
}
MapData data = GetData(event.getPlayer().getWorld().getName());
data.GameType = args[0];
data.Write();
Announce("GameType for " + F.elem(event.getPlayer().getWorld().getName()) + " set to " + F.elem(args[0]) + ".");
}
else if (event.getMessage().toLowerCase().startsWith("/join"))
{
event.setCancelled(true);
if (event.getMessage().split(" ").length < 2)
{
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/join <Name>")));
return;
}
String input = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ")[0];
if (event.getPlayer().getWorld().getName().equals("world"))
{
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Cannot change Join-List for Lobby."));
return;
}
//Permission
if (!GetData(event.getPlayer().getWorld().getName()).CanBuild(event.getPlayer()))
{
UtilPlayer.message(caller, F.main("Parser", "You do not have Build-Access on this Map."));
return;
}
Player player = UtilPlayer.searchOnline(event.getPlayer(), input, true);
if (player != null)
{
MapData data = GetData(event.getPlayer().getWorld().getName());
if (data.WhiteList.contains(player.getName()))
{
data.WhiteList.remove(player.getName());
data.Write();
Announce("Join-List for " + F.elem(event.getPlayer().getWorld().getName()) + " (" + player.getName() + " = " + F.tf(false) + ")");
}
else
{
data.WhiteList.add(player.getName());
data.Write();
Announce("Join-List for " + F.elem(event.getPlayer().getWorld().getName()) + " (" + player.getName() + " = " + F.tf(true) + ")");
}
}
}
else if (event.getMessage().toLowerCase().startsWith("/build"))
{
event.setCancelled(true);
if (event.getMessage().split(" ").length < 2)
{
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/build <Name>")));
return;
}
String input = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ")[0];
if (event.getPlayer().getWorld().getName().equals("world"))
{
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Cannot change Build-List for Lobby."));
return;
}
//Permission
if (!GetData(event.getPlayer().getWorld().getName()).CanBuild(event.getPlayer()))
{
UtilPlayer.message(caller, F.main("Parser", "You do not have Build-Access on this Map."));
return;
}
Player player = UtilPlayer.searchOnline(event.getPlayer(), input, true);
if (player != null)
{
MapData data = GetData(event.getPlayer().getWorld().getName());
if (data.BuildList.contains(player.getName()))
{
data.BuildList.remove(player.getName());
data.Write();
Announce("Build-List for " + F.elem(event.getPlayer().getWorld().getName()) + " (" + player.getName() + " = " + F.tf(false) + ")");
}
else
{
data.BuildList.add(player.getName());
data.Write();
Announce("Build-List for " + F.elem(event.getPlayer().getWorld().getName()) + " (" + player.getName() + " = " + F.tf(true) + ")");
}
}
}
}
public void sendValidGameTypes(Player player)
{
UtilPlayer.message(player, F.main("Parser", "Valid Game Types;"));
String gameTypes = "";
for (GameType game : GameType.values())
{
gameTypes += game.toString() + " ";
}
player.sendMessage(gameTypes);
}
@EventHandler
public void ParseUpdate(TickEvent event)
{
@ -688,12 +271,12 @@ public class MapParser extends JavaPlugin implements Listener
if (world.getName().startsWith("parse_"))
continue;
if (!world.getName().startsWith("map_"))
if (!world.getName().startsWith("map"))
continue;
if (world.getPlayers().isEmpty())
{
Announce("Saving & Closing World: " + F.elem(world.getName()));
Announce("Saving & Closing World: " + F.elem(world.getName()));
MapUtil.UnloadWorld(this, world, true);
}
}
@ -709,31 +292,98 @@ public class MapParser extends JavaPlugin implements Listener
}
}
public boolean DoesMapExist(String name)
public boolean DoesMapExist(String mapName, GameType gameType)
{
File mapsFolder = new File(".");
for (File file : mapsFolder.listFiles())
{
if (!file.isDirectory())
continue;
if (file.getName().equals(name))
return true;
}
return DoesMapExist(getWorldString(mapName, gameType));
}
public boolean DoesMapExist(String worldName)
{
File file = new File(worldName);
if (file.exists() && file.isDirectory())
return true;
return false;
}
public World GetMapWorld(String name)
public String getShortWorldName(String worldName)
{
int lastIndexOfSeperator = worldName.lastIndexOf('/');
if (lastIndexOfSeperator != -1)
return worldName.substring(lastIndexOfSeperator + 1);
return worldName;
}
public World GetMapWorld(String mapName, GameType gameType)
{
return GetMapWorld(getWorldString(mapName, gameType));
}
public World GetMapWorld(String worldName)
{
for (World world : this.getServer().getWorlds())
{
if (world.getName().equals(name))
if (world.getName().equals(worldName))
return world;
}
return null;
}
public String getWorldString(String mapName, GameType type)
{
return "map" + "/" + type.GetName() + "/" + mapName;
}
public List<String> getMapsByName(String name)
{
name = name.toLowerCase();
List<String> maps = new LinkedList<String>();
boolean matchesExact = false;
for (GameType type : GameType.values())
{
ChatColor color = ChatColor.YELLOW;
File mapsFolder = new File("map" + File.separator + type.GetName());
if (!mapsFolder.exists())
continue;
for (File file : mapsFolder.listFiles())
{
if (!file.isDirectory())
continue;
if (!file.getName().toLowerCase().contains(name))
continue;
if (file.getName().equalsIgnoreCase(name))
matchesExact = true;
maps.add(getWorldString(file.getName(), type));
}
}
if (matchesExact)
{
Iterator<String> it = maps.iterator();
while (it.hasNext())
{
String mapString = it.next();
if (!mapString.toLowerCase().endsWith(name))
{
it.remove();
}
}
}
return maps;
}
public MapData GetData(String mapName)
{
@ -746,26 +396,44 @@ public class MapParser extends JavaPlugin implements Listener
return data;
}
public Location getSpawnLocation()
{
return _spawnLocation;
}
public void ResetInventory(Player player)
{
UtilInv.Clear(player);
UtilInv.Clear(player);
player.getInventory().addItem(new ItemStack(Material.STONE_SWORD));
player.getInventory().addItem(new ItemStack(Material.STONE_SPADE));
player.getInventory().addItem(new ItemStack(Material.STONE_PICKAXE));
player.getInventory().addItem(new ItemStack(Material.STONE_AXE));
player.getInventory().addItem(new ItemStack(Material.WOOD_AXE));
}
public WorldManager getWorldManager()
{
return _worldManager;
}
public void setCurrentParse(Parse parse)
{
_curParse = parse;
}
@EventHandler
public void Chat(AsyncPlayerChatEvent event)
{
event.setCancelled(true);
String world = C.cDGreen + C.Bold + event.getPlayer().getWorld().getName();
String world = C.cDGreen + C.Bold + getShortWorldName(event.getPlayer().getWorld().getName());
String name = C.cYellow + event.getPlayer().getName();
if (GetData(event.getPlayer().getWorld().getName()).CanBuild(event.getPlayer()))
if (GetData(event.getPlayer().getWorld().getName()).HasAccess(event.getPlayer()))
name = C.cGreen + event.getPlayer().getName();
String grayName = C.cBlue + event.getPlayer().getName();
@ -791,7 +459,7 @@ public class MapParser extends JavaPlugin implements Listener
public void InteractCancel(PlayerInteractEvent event)
{
//Permission
if (!GetData(event.getPlayer().getWorld().getName()).CanBuild(event.getPlayer()))
if (!GetData(event.getPlayer().getWorld().getName()).HasAccess(event.getPlayer()))
{
event.setCancelled(true);
}
@ -803,7 +471,7 @@ public class MapParser extends JavaPlugin implements Listener
if (event.getMessage().startsWith("//"))
{
//Permission
if (!GetData(event.getPlayer().getWorld().getName()).CanBuild(event.getPlayer()))
if (!GetData(event.getPlayer().getWorld().getName()).HasAccess(event.getPlayer()))
{
UtilPlayer.message(event.getPlayer(), F.main("Parser", "You do not have Build-Access for this Map."));
event.setCancelled(true);

View File

@ -8,7 +8,6 @@ import java.util.HashMap;
import java.util.HashSet;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
@ -18,7 +17,6 @@ import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.material.Wool;
public class Parse
@ -29,7 +27,7 @@ public class Parse
private String[] _args;
private Location _callLoc;
private int _size = 500;
private int _size = 600;
private int _x = 0;
private int _y = 0;
private int _z = 0;
@ -71,9 +69,6 @@ public class Parse
//Take BlockID Arguments
for (String arg : _args)
{
if (arg.equals("/parse"))
continue;
try
{
_dataId.add(Integer.parseInt(arg));
@ -509,7 +504,7 @@ public class Parse
return out;
}
public String getGameType()
public GameType getGameType()
{
return _mapData.GameType;
}

View File

@ -4,17 +4,14 @@ import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.WorldUtil;
import mineplex.core.common.util.ZipUtil;
import net.minecraft.util.org.apache.commons.io.FileUtils;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.plugin.java.JavaPlugin;
import net.minecraft.util.org.apache.commons.io.FileUtils;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.ZipUtil;
public class WorldManager
{
@ -49,11 +46,14 @@ public class WorldManager
FileUtils.deleteQuietly(new File(world.getName() + File.separator + fileName));
}
//Copy for Parsing
//Copy for Parsing
String parseWorldName = "parse" + world.getName().replaceFirst("map", "");
try
{
//Delete if already exists
File destination = new File("parse_" + world.getName());
File destination = new File(parseWorldName);
if (destination.exists())
FileUtils.deleteDirectory(destination);
@ -65,7 +65,7 @@ public class WorldManager
return null;
}
return Bukkit.createWorld(new WorldCreator("parse_" + world.getName()));
return Bukkit.createWorld(new WorldCreator(parseWorldName));
}
public void finalizeParsedWorld(World world)
@ -99,10 +99,9 @@ public class WorldManager
FileUtils.deleteQuietly(new File(world.getName() + File.separator + file.getName()));
}
MapData data = Host.GetData(world.getName().substring(6));
String fileName = data.GameType + "_" + data.MapName + ".zip";
GameType gameType = GameType.valueOf(data.GameType);
MapData data = Host.GetData(world.getName().replace("parse", "map"));
GameType gameType = data.GameType;
String fileName = gameType + "_" + data.MapName + ".zip";
ZipUtil.ZipFolders(Paths.get(world.getName()).toAbsolutePath().toString(), fileName, dirList, fileList);

View File

@ -0,0 +1,59 @@
package mineplex.mapparser.command;
import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/15/2014.
*/
public class AuthorCommand extends BaseCommand
{
public AuthorCommand(MapParser plugin)
{
super(plugin, "author");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
World world = player.getWorld();
if (args.length < 1)
{
message(player, "Invalid Input. " + F.elem("/author <MapAuthor>"));
return true;
}
String authorName = "";
for (String arg : args)
authorName += arg + " ";
authorName = authorName.trim();
if (world.getName().equals("world"))
{
message(player, "Cannot set author for Lobby.");
return true;
}
//Permission
if (!getPlugin().GetData(world.getName()).HasAccess(player))
{
message(player, "You do not have Build-Access on this Map.");
return true;
}
MapData data = getPlugin().GetData(world.getName());
data.MapCreator = authorName;
data.Write();
getPlugin().Announce("Map Author for " + F.elem(world.getName()) + " set to " + F.elem(authorName) + ".");
return true;
}
}

View File

@ -0,0 +1,64 @@
package mineplex.mapparser.command;
import java.util.Arrays;
import java.util.List;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/15/2014.
*/
public abstract class BaseCommand
{
private MapParser _plugin;
private List<String> _aliases;
private String _description = "Null";
private String _usage = "Undefined";
public BaseCommand(MapParser plugin, String... aliases)
{
_plugin = plugin;
_aliases = Arrays.asList(aliases);
}
public abstract boolean execute(Player player, String alias, String[] args);
public String getDescription()
{
return _description;
}
protected void setDescription(String description)
{
_description = description;
}
public String getUsage()
{
return _usage;
}
protected void setUsage(String usage)
{
_usage = usage;
}
public List<String> getAliases()
{
return _aliases;
}
protected MapParser getPlugin()
{
return _plugin;
}
protected void message(Player player, String message)
{
UtilPlayer.message(player, F.main("Parser", message));
}
}

View File

@ -0,0 +1,94 @@
package mineplex.mapparser.command;
import java.io.File;
import java.io.IOException;
import org.bukkit.World;
import org.bukkit.entity.Player;
import net.minecraft.util.org.apache.commons.io.FileUtils;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.mapparser.GameType;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/16/2014.
*/
public class CopyCommand extends BaseCommand
{
public CopyCommand(MapParser plugin)
{
super(plugin, "copy");
setUsage("/copy <map name> <game type> <copy map name> <copy game time>");
setDescription("Copy the data of a map into a new map. This preserves Build List.");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
if (args.length != 4)
return false;
String originalMapName = args[0];
String newMapName = args[2];
GameType originalGametype = null;
GameType newGameType = null;
try
{
originalGametype = GameType.valueOf(args[1]);
newGameType = GameType.valueOf(args[3]);
}
catch (Exception e)
{
getPlugin().sendValidGameTypes(player);
return true;
}
String worldName = getPlugin().getWorldString(originalMapName, originalGametype);
String newWorldName = getPlugin().getWorldString(newMapName, newGameType);
if (!getPlugin().DoesMapExist(worldName))
{
message(player, "Could not find a map with the name " + F.elem(originalMapName) + " of type " + F.elem(originalGametype.toString()));
return true;
}
if (getPlugin().DoesMapExist(newWorldName))
{
message(player, "Destination map already exists " + F.elem(newMapName) + " of type " + F.elem(newGameType.toString()));
return true;
}
World world = getPlugin().GetMapWorld(worldName);
if (world != null)
{
// World is loaded, save and unload it.
for (Player other : world.getPlayers())
{
other.teleport(getPlugin().getSpawnLocation());
message(other, "Unloading world for copy...");
}
MapUtil.UnloadWorld(getPlugin(), world, true);
}
File source = new File(worldName);
File destination = new File(newWorldName);
try
{
FileUtils.copyDirectory(source, destination);
message(player, "Copy completed successfully!");
}
catch (IOException e)
{
e.printStackTrace();
message(player, "An error occurred during map copy!");
}
return true;
}
}

View File

@ -0,0 +1,40 @@
package mineplex.mapparser.command;
import java.io.File;
import java.io.IOException;
import org.bukkit.entity.Player;
import net.minecraft.util.org.apache.commons.io.FileUtils;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/16/2014.
*/
public class CopySchematicsCommand extends BaseCommand
{
public CopySchematicsCommand(MapParser plugin)
{
super(plugin, "copyschematics");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
try
{
FileUtils.copyDirectory(new File(".." + File.separator + "Build-1" + File.separator + "plugins" + File.separator + "WorldEdit" + File.separator + "schematics"),
new File("plugins" + File.separator + "WorldEdit" + File.separator + "schematics"));
message(player, "Schematics Copied.");
}
catch (IOException e)
{
e.printStackTrace();
message(player, "Schematics Copy Failed! Contact Jonalon.");
}
return true;
}
}

View File

@ -0,0 +1,75 @@
package mineplex.mapparser.command;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.WorldType;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.GameType;
import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/16/2014.
*/
public class CreateCommand extends BaseCommand
{
public CreateCommand(MapParser plugin)
{
super(plugin, "create");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
if (args.length < 2)
{
message(player, "Invalid Input. " + F.elem("/create <MapName> <GameType>"));
return true;
}
GameType gameType = null;
try
{
gameType = GameType.valueOf(args[1]);
}
catch (Exception e)
{
getPlugin().sendValidGameTypes(player);
}
String worldName = "map/" + gameType.GetName() + "/" + args[0];
if (getPlugin().DoesMapExist(worldName))
{
message(player, "Map name is already in use!");
return true;
}
getPlugin().Announce("Creating World: " + F.elem(worldName));
WorldCreator worldCreator = new WorldCreator(worldName);
worldCreator.environment(World.Environment.NORMAL);
worldCreator.type(WorldType.FLAT);
worldCreator.generateStructures(false);
World world = Bukkit.getServer().createWorld(worldCreator);
message(player, "Teleporting to World: " + F.elem(worldName));
player.teleport(getPlugin().getSpawnLocation());
//Give Access
MapData mapData = getPlugin().GetData(worldName);
mapData.AdminList.add(player.getName());
mapData.GameType = gameType;
mapData.Write();
return true;
}
}

View File

@ -0,0 +1,82 @@
package mineplex.mapparser.command;
import java.io.File;
import org.bukkit.World;
import org.bukkit.entity.Player;
import net.minecraft.util.org.apache.commons.io.FileUtils;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.mapparser.GameType;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/16/2014.
*/
public class DeleteCommand extends BaseCommand
{
public DeleteCommand(MapParser plugin)
{
super(plugin, "delete");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
if (args.length < 2)
{
message(player, "Invalid Input. " + F.elem("/delete <MapName> [GameType]"));
return true;
}
String mapName = args[0];
GameType gameType = null;
try
{
gameType = GameType.valueOf(args[1]);
}
catch (Exception e)
{
getPlugin().sendValidGameTypes(player);
}
final String worldName = getPlugin().getWorldString(mapName, gameType);
if (!getPlugin().DoesMapExist(worldName))
{
message(player, "Map does not exist: " + F.elem(worldName));
return true;
}
if (!getPlugin().GetData(worldName).HasAccess(player))
{
message(player, "You do not have Build-Access on this Map.");
return true;
}
if (getPlugin().GetMapWorld(worldName) != null)
{
World world = getPlugin().GetMapWorld(worldName);
//Teleport Out
for (Player other : world.getPlayers())
other.teleport(getPlugin().getSpawnLocation());
//Unload World
//Things break if this isn't set to true for saving the world
MapUtil.UnloadWorld(getPlugin(), world, true);
}
//Delete
boolean deleted = FileUtils.deleteQuietly(new File(worldName));
if (deleted)
getPlugin().Announce("Deleted World: " + F.elem(worldName));
else
getPlugin().Announce("Failed to delete World: " + F.elem(worldName));
return true;
}
}

View File

@ -0,0 +1,96 @@
package mineplex.mapparser.command;
import java.io.File;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.GameType;
import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/16/2014.
*/
public class GameTypeCommand extends BaseCommand
{
public GameTypeCommand(MapParser plugin)
{
super(plugin, "gametype");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
World world = player.getWorld();
if (args.length != 1)
{
message(player, "Invalid Input. " + F.elem("/gametype <GameType>"));
return true;
}
if (world.getName().equals("world"))
{
message(player, "Cannot set GameType for Lobby.");
return true;
}
//Permission
if (!getPlugin().GetData(world.getName()).HasAccess(player))
{
message(player, "You do not have Build-Access on this Map.");
return true;
}
//Check Gametype
GameType type = null;
try
{
type = GameType.valueOf(args[0]);
}
catch (Exception ex)
{
getPlugin().sendValidGameTypes(player);
return true;
}
if (getPlugin().DoesMapExist(getPlugin().getShortWorldName(world.getName()), type))
{
message(player, "A world with the same name already exists for the new gametype: " + type.GetName());
return true;
}
// Rename world
for (Player other : world.getPlayers())
{
other.teleport(getPlugin().getSpawnLocation());
message(player, "Unloading world for rename...");
}
MapUtil.UnloadWorld(getPlugin(), world, true);
File typeFolder = new File("map/" + type.GetName());
if (!typeFolder.exists())
typeFolder.mkdir();
File mapFolder = new File(world.getName());
String newName = "map/" + type.GetName() + "/" + getPlugin().getShortWorldName(world.getName());
File newFolder = new File(newName);
mapFolder.renameTo(newFolder);
message(player, "Map " + world.getName() + " renamed to " + newName);
MapData data = getPlugin().GetData(newName);
data.GameType = type;
data.Write();
getPlugin().Announce("GameType for " + F.elem(newName) + " set to " + F.elem(args[0]) + ".");
return true;
}
}

View File

@ -0,0 +1,24 @@
package mineplex.mapparser.command;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/15/2014.
*/
public class HubCommand extends BaseCommand
{
public HubCommand(MapParser plugin)
{
super(plugin, "hub");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
player.teleport(getPlugin().getSpawnLocation());
return true;
}
}

View File

@ -0,0 +1,84 @@
package mineplex.mapparser.command;
import java.io.File;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.GameType;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/15/2014.
*/
public class ListCommand extends BaseCommand
{
public ListCommand(MapParser plugin)
{
super(plugin, "list");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
if (args.length == 0)
{
UtilPlayer.message(player, F.main("Parser", "Listing Maps;"));
for (GameType gameType : GameType.values())
{
listMaps(player, gameType);
}
}
else if (args.length == 1)
{
GameType gameType = null;
try
{
gameType = GameType.valueOf(args[0]);
}
catch (Exception e)
{
getPlugin().sendValidGameTypes(player);
}
UtilPlayer.message(player, F.main("Parser", "Listing Maps for gametype " + F.elem(gameType.GetName())));
listMaps(player, gameType);
}
return true;
}
private void listMaps(Player player, GameType gameType)
{
String maps = "";
ChatColor color = ChatColor.YELLOW;
File mapsFolder = new File("map" + File.separator + gameType.GetName());
if (!mapsFolder.exists())
return;
for (File file : mapsFolder.listFiles())
{
if (!file.isDirectory())
continue;
maps += color + file.getName() + " ";
if (color == ChatColor.YELLOW)
color = ChatColor.GOLD;
else
color = ChatColor.YELLOW;
}
// Print line of maps for specific gametype
if (maps.length() > 0)
{
maps = F.elem(gameType.name()) + "> " + maps;
player.sendMessage(maps);
}
}
}

View File

@ -0,0 +1,115 @@
package mineplex.mapparser.command;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.GameType;
import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/15/2014.
*/
public class MapCommand extends BaseCommand
{
public MapCommand(MapParser plugin)
{
super(plugin, "map");
setDescription("Teleport to a map");
setUsage("/map <name> [gametype]");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
if (args.length < 1)
{
//UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/map <MapName> [GameType]")));
return false;
}
String worldName = null;
// Look up maps without a specific game type
if (args.length == 1)
{
List<String> possibleMaps = getPlugin().getMapsByName(args[0]);
if (possibleMaps.size() == 0)
{
message(player, "No maps found with the name: " + F.elem(args[0]));
}
else if (possibleMaps.size() > 1)
{
message(player, "Found more than one possible match:");
for (String s : possibleMaps)
UtilPlayer.message(player, s);
return true;
}
worldName = possibleMaps.get(0);
}
else // Get map with specified name and gametype
{
GameType gameType = null;
try
{
gameType = GameType.valueOf(args[1]);
}
catch (Exception e)
{
getPlugin().sendValidGameTypes(player);
return true;
}
worldName = getPlugin().getWorldString(args[0], gameType);
}
World world = getPlugin().GetMapWorld(worldName);
if (world == null)
{
if (getPlugin().DoesMapExist(worldName))
{
world = Bukkit.createWorld(new WorldCreator(worldName));
}
else
{
message(player, "Map Not Found: " + F.elem(worldName));
return true;
}
}
//Error (This should not occur!)
if (world == null)
{
message(player, "Null World Error: " + F.elem(worldName));
return true;
}
//Permission
if (!getPlugin().GetData(world.getName()).CanJoin(player))
{
message(player, "You do not have Join-Access on this Map.");
return true;
}
//Teleport
message(player, "Teleporting to World: " + F.elem(worldName));
player.teleport(new Location(world, 0, 106, 0));
MapData data = getPlugin().GetData(worldName);
UtilPlayer.message(player, F.value("Map Name", data.MapName));
UtilPlayer.message(player, F.value("Author", data.MapCreator));
UtilPlayer.message(player, F.value("Game Type", data.GameType.GetName()));
return true;
}
}

View File

@ -0,0 +1,61 @@
package mineplex.mapparser.command;
import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/15/2014.
*/
public class NameCommand extends BaseCommand
{
public NameCommand(MapParser plugin)
{
super(plugin, "name");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
World world = player.getWorld();
if (args.length < 1)
{
message(player, "Invalid Input. " + F.elem("/name <MapName>"));
return true;
}
if (world.equals("world"))
{
message(player, "Cannot set name for Lobby.");
return true;
}
String mapName = "";
for(String arg : args)
mapName += arg + " ";
mapName = mapName.trim();
//Permission
if (!getPlugin().GetData(world.getName()).HasAccess(player))
{
message(player, "You do not have Build-Access on this Map.");
return true;
}
MapData data = getPlugin().GetData(world.getName());
data.MapName = mapName;
data.Write();
getPlugin().Announce("Map Name for " + F.elem(world.getName()) + " set to " + F.elem(mapName) + ".");
return true;
}
}

View File

@ -0,0 +1,64 @@
package mineplex.mapparser.command;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser;
import mineplex.mapparser.Parse;
/**
* Created by Shaun on 8/15/2014.
*/
public class ParseCommand extends BaseCommand
{
public ParseCommand(MapParser plugin)
{
super(plugin, "parse");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
if (!player.isOp())
{
message(player, "Only OPs can parse maps!");
return true;
}
Location parseLoc = player.getLocation();
World world = parseLoc.getWorld();
MapData data = getPlugin().GetData(world.getName());
if (data.MapName.equals("null") || data.MapCreator.equals("null") || data.GameType.equals("null"))
{
message(player, "Map Name/Author/GameType are not set!");
return true;
}
//Teleport Players Out
for (Player worldPlayer : world.getPlayers())
{
worldPlayer.teleport(getPlugin().getSpawnLocation());
message(player, "World " + F.elem(world.getName()) + " is preparing to be parsed.");
}
//Unload World > Copy
World parseableWorld = getPlugin().getWorldManager().prepMapParse(world);
if (parseableWorld == null)
{
message(player, "Could not prepare world for parsing!");
return true;
}
//Parse the World
getPlugin().setCurrentParse(new Parse(getPlugin(), parseableWorld, args, parseLoc, getPlugin().GetData(parseLoc.getWorld().getName())));
return true;
}
}

View File

@ -0,0 +1,65 @@
package mineplex.mapparser.command;
import java.io.File;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/16/2014.
*/
public class RenameCommand extends BaseCommand
{
public RenameCommand(MapParser plugin)
{
super(plugin, "rename");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
World world = player.getWorld();
MapData data = getPlugin().GetData(world.getName());
if (data == null)
{
message(player, "Map not found: " + F.elem(args[0]));
return true;
}
else if (!data.CanRename(player))
{
message(player, "You do not have access to rename this map");
return true;
}
else if (args.length != 1)
{
message(player, "Usage: /rename <new name>");
return true;
}
String newName = args[0];
for (Player other : world.getPlayers())
{
other.teleport(getPlugin().getSpawnLocation());
message(other, "Unloading world for rename...");
}
MapUtil.UnloadWorld(getPlugin(), world, true);
message(player, "World unloaded!");
File mapFolder = new File(world.getName());
File newFolder = new File("map" + File.separator + data.GameType.GetName() + File.separator + newName);
mapFolder.renameTo(newFolder);
message(player, "Map " + world.getName() + " renamed to " + newFolder.getName());
return true;
}
}

View File

@ -0,0 +1,78 @@
package mineplex.mapparser.command;
import java.util.List;
import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/16/2014.
*/
public class SaveCommand extends BaseCommand
{
public SaveCommand(MapParser plugin)
{
super(plugin, "save");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
if (args.length < 1)
{
message(player, "Invalid Input. " + F.elem("/save <MapName>"));
return true;
}
String name = args[0];
List<String> possibleMaps = getPlugin().getMapsByName(name);
if (possibleMaps.size() > 1)
{
message(player, "More than one map found:");
for (String s : possibleMaps)
UtilPlayer.message(player, s);
return true;
}
else if (possibleMaps.size() == 0)
{
message(player, "No maps found with the name: " + F.elem(name));
return true;
}
String worldName = possibleMaps.get(0);
World world = getPlugin().GetMapWorld(worldName);
if (world != null)
{
if (!getPlugin().GetData(worldName).HasAccess(player))
{
message(player, "You do not have Build-Access on this Map.");
return true;
}
//Teleport Out
for (Player other : world.getPlayers())
other.teleport(getPlugin().getSpawnLocation());
//Unload World
MapUtil.UnloadWorld(getPlugin(), world, true);
}
else
{
message(player, "World is not loaded: " + F.elem(worldName));
return true;
}
getPlugin().Announce("Saved World: " + F.elem(args[0]));
return true;
}
}

View File

@ -0,0 +1,31 @@
package mineplex.mapparser.command;
import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/15/2014.
*/
public class WorldsCommand extends BaseCommand
{
public WorldsCommand(MapParser plugin)
{
super(plugin, "worlds");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
message(player, "Listing Active Worlds;");
for (World world : getPlugin().getServer().getWorlds())
{
player.sendMessage(world.getName());
}
return true;
}
}

View File

@ -190,7 +190,7 @@ public class BungeeSigns extends JavaPlugin implements Listener, PluginMessageLi
public void run()
{
if (getServer().getOnlinePlayers().length > 0)
if (getServer().getOnlinePlayers().size() > 0)
{
for (String serverName : _signs.keySet())
{
@ -211,7 +211,7 @@ public class BungeeSigns extends JavaPlugin implements Listener, PluginMessageLi
e.printStackTrace();
}
getServer().getOnlinePlayers()[0].sendPluginMessage(this, "BungeeSigns", b.toByteArray());
getServer().getOnlinePlayers().iterator().next().sendPluginMessage(this, "BungeeSigns", b.toByteArray());
if (_signUpdate.get(serverName) != -1L && System.currentTimeMillis() - _signUpdate.get(serverName) > 5000)
{

View File

@ -11,6 +11,7 @@
<orderEntry type="module" module-name="Mineplex.Core.Common" />
<orderEntry type="module" module-name="Mineplex.Minecraft.Game.Core" />
<orderEntry type="module" module-name="Nautilus.Core.CraftBukkit" />
<orderEntry type="library" name="bukkit" level="project" />
<orderEntry type="library" name="craftbukkit" level="project" />
</component>
</module>

View File

@ -1,18 +1,16 @@
package mineplex.minecraft.game.classcombat.Skill.Brute;
import java.util.HashMap;
import java.util.*;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.entity.*;
import org.bukkit.event.*;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.*;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.*;
import org.bukkit.util.Vector;
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
@ -33,6 +31,36 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
public class SeismicSlam extends SkillActive
{
public static class SeismicSlamEvent extends PlayerEvent
{
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList()
{
return handlers;
}
@Override
public HandlerList getHandlers()
{
return getHandlerList();
}
private final List<LivingEntity> _targets;
public SeismicSlamEvent(Player who, Collection<LivingEntity> targets)
{
super(who);
_targets = new ArrayList<>(targets);
}
public List<LivingEntity> getTargets()
{
return _targets;
}
}
private HashMap<LivingEntity, Long> _live = new HashMap<LivingEntity, Long>();
public SeismicSlam(SkillFactory skills, String name, ClassType classType, SkillType skillType,
@ -141,6 +169,8 @@ public class SeismicSlam extends SkillActive
//Event
UtilServer.getServer().getPluginManager().callEvent(new SkillEvent(player, GetName(), ClassType.Brute, targets.keySet()));
Bukkit.getPluginManager().callEvent(new SeismicSlamEvent(player, targets.keySet()));
}
}

View File

@ -1,14 +1,13 @@
package mineplex.minecraft.game.classcombat.Skill.Mage;
import java.util.HashMap;
import java.util.*;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.*;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
@ -24,9 +23,40 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.minecraft.game.classcombat.Skill.SkillActive;
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
import org.bukkit.event.player.*;
public class LightningOrb extends SkillActive implements IThrown
{
public static class LightningOrbEvent extends PlayerEvent
{
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList()
{
return handlers;
}
@Override
public HandlerList getHandlers()
{
return getHandlerList();
}
private final List<Player> _struck;
public LightningOrbEvent(Player who, List<Player> struck)
{
super(who);
_struck = struck;
}
public List<Player> getStruck()
{
return _struck;
}
}
public LightningOrb(SkillFactory skills, String name, ClassType classType, SkillType skillType,
int cost, int levels,
int energy, int energyMod,
@ -121,6 +151,8 @@ public class LightningOrb extends SkillActive implements IThrown
Factory.Condition().Factory().Lightning(GetName(), cur, player, 0, 0.5, false, true);
}
List<Player> struck = new ArrayList<>();
//Lightning
for (Player cur : hit.keySet())
{
@ -132,6 +164,8 @@ public class LightningOrb extends SkillActive implements IThrown
//Lightning
cur.getWorld().strikeLightning(cur.getLocation());
struck.add(cur);
}
//Apply Conditions
@ -142,6 +176,8 @@ public class LightningOrb extends SkillActive implements IThrown
Factory.Condition().Factory().Slow(GetName(), cur, player, 2 + (1 * level), 2, false, true, true, true);
}
Bukkit.getPluginManager().callEvent(new LightningOrbEvent(player, struck));
}
@EventHandler

View File

@ -3,13 +3,12 @@ package mineplex.minecraft.game.classcombat.Skill.Ranger;
import java.util.HashMap;
import java.util.Iterator;
import org.bukkit.Location;
import org.bukkit.*;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.*;
import org.bukkit.event.entity.*;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
@ -19,9 +18,40 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.common.util.UtilMath;
import mineplex.minecraft.game.classcombat.Skill.Skill;
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
import org.bukkit.event.player.*;
public class Longshot extends Skill
{
public static class LongshotHitEvent extends ProjectileHitEvent
{
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList()
{
return handlers;
}
@Override
public HandlerList getHandlers()
{
return getHandlerList();
}
private final double _length;
public LongshotHitEvent(Projectile projectile, double length)
{
super(projectile);
_length = length;
}
public double getLength()
{
return _length;
}
}
private HashMap<Entity, Location> _arrows = new HashMap<Entity, Location>();
public Longshot(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels)
@ -79,6 +109,8 @@ public class Longshot extends Skill
double damage = Math.min(5 + 5 * level, (length / (4 - 0.5 * level)) - 3);
event.AddMod(damager.getName(), GetName(), damage, damage > 0);
Bukkit.getPluginManager().callEvent(new LongshotHitEvent(projectile, length));
}
@EventHandler

View File

@ -10,6 +10,7 @@
<orderEntry type="module" module-name="Mineplex.Core" />
<orderEntry type="module" module-name="Mineplex.Core.Common" />
<orderEntry type="module" module-name="Nautilus.Core.CraftBukkit" />
<orderEntry type="library" name="bukkit" level="project" />
<orderEntry type="library" name="craftbukkit" level="project" />
</component>
</module>

View File

@ -29,7 +29,7 @@ public class MinecraftServer
// The maximum number of players allowed on the server.
private int _maxPlayerCount;
public int getMaxPlayerCount() { return _maxPlayerCount; }
// The ticks per second (TPS) of the server.
private int _tps;
public int getTps() { return _tps; }

View File

@ -12,6 +12,7 @@
<orderEntry type="module" module-name="Mineplex.Minecraft.Game.Core" />
<orderEntry type="module" module-name="Mineplex.Minecraft.Game.ClassCombat" />
<orderEntry type="module" module-name="Nautilus.Core.CraftBukkit" />
<orderEntry type="library" name="bukkit" level="project" />
<orderEntry type="library" name="craftbukkit" level="project" />
</component>
</module>

View File

@ -61,7 +61,7 @@ public class Arcade extends JavaPlugin
@Override
public void onEnable()
{
{
//Delete Old Games Folders
DeleteFolders();

View File

@ -1,18 +1,10 @@
package nautilus.game.arcade.game;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.*;
import mineplex.core.common.util.*;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.minecraft.game.core.combat.DeathMessageType;
import nautilus.game.arcade.ArcadeFormat;
import nautilus.game.arcade.ArcadeManager;
@ -898,7 +890,7 @@ public abstract class Game implements Listener
Manager.GetChat().Silence(5000, false);
}
public void AnnounceEnd(ArrayList<Player> places)
public void AnnounceEnd(List<Player> places)
{
for (Player player : UtilServer.getPlayers())
{
@ -1074,9 +1066,13 @@ public abstract class Game implements Listener
if (_stats.get(player).containsKey(stat))
past = _stats.get(player).get(stat);
_stats.get(player).put(stat, limitTo1 ? Math.max(1, past + amount) : past + amount);
_stats.get(player).put(stat, limitTo1 ? Math.min(1, past + amount) : past + amount);
}
public abstract List<Player> getWinners();
public abstract List<Player> getLosers();
public NautHashMap<Player, HashMap<String, Integer>> GetStats()
{
return _stats;

View File

@ -1,6 +1,6 @@
package nautilus.game.arcade.game;
import java.util.ArrayList;
import java.util.*;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -123,4 +123,38 @@ public abstract class SoloGame extends Game
{
return 0;
}
@Override
public List<Player> getWinners()
{
if (!IsLive())
return null;
if (GetPlayers(true).size() <= 1)
{
List<Player> places = _players.GetPlacements(true);
if (places.isEmpty())
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 = _players.GetPlayers(false);
losers.removeAll(winners);
return losers;
}
}

View File

@ -1,75 +1,64 @@
package nautilus.game.arcade.game;
import java.util.ArrayList;
import java.util.Iterator;
import mineplex.core.common.util.*;
import mineplex.core.common.util.UtilTime.*;
import mineplex.core.updater.*;
import mineplex.core.updater.event.*;
import nautilus.game.arcade.*;
import nautilus.game.arcade.events.*;
import nautilus.game.arcade.game.GameTeam.*;
import nautilus.game.arcade.kit.*;
import org.bukkit.entity.*;
import org.bukkit.event.*;
import org.bukkit.event.player.*;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
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.PlayerStateChangeEvent;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.kit.Kit;
import java.util.*;
public abstract class TeamGame extends Game
{
protected ArrayList<GameTeam> _places = new ArrayList<GameTeam>();
private NautHashMap<String, Long> _rejoinTime = new NautHashMap<String, Long>();
protected NautHashMap<String, GameTeam> RejoinTeam = new NautHashMap<String, GameTeam>();
protected NautHashMap<String, Kit> RejoinKit = new NautHashMap<String, Kit>();
protected long RejoinTime = 180000;
public TeamGame(ArcadeManager manager, GameType gameType, Kit[] kits, String[] gameDesc)
public TeamGame(ArcadeManager manager, GameType gameType, Kit[] kits, String[] gameDesc)
{
super(manager, gameType, kits, gameDesc);
}
@EventHandler
public void EndStateChange(PlayerStateChangeEvent event)
{
GameTeam team = this.GetTeam(event.GetPlayer());
if (team == null)
return;
if (event.GetState() == PlayerState.OUT)
if (!team.IsTeamAlive())
_places.add(0, team);
else
_places.remove(team);
_places.add(0, team);
else
_places.remove(team);
}
public ArrayList<GameTeam> GetPlaces()
{
return _places;
}
@EventHandler(priority = EventPriority.LOWEST)
public void PlayerQuit(PlayerQuitEvent event)
{
if (!InProgress())
return;
Player player = event.getPlayer();
GameTeam team = GetTeam(player);
if (team == null) return;
if (team == null) return;
if (!team.IsAlive(player))
return;
@ -84,35 +73,35 @@ public abstract class TeamGame extends Game
//Store
_rejoinTime.put(player.getName(), System.currentTimeMillis());
RejoinTeam.put(player.getName(), team);
if (GetKit(player) != null)
RejoinKit.put(player.getName(), GetKit(player));
GetLocationStore().put(player.getName(), player.getLocation());
//Announcement
Announce(team.GetColor() + C.Bold + player.getName() + " has disconnected! " + UtilTime.convert(RejoinTime, 0, TimeUnit.MINUTES) + " minutes to rejoin.", false);
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void PlayerLoginAllow(PlayerLoginEvent event)
{
{
if (!InProgress() || QuitOut)
return;
//Rejoined
GameTeam team = RejoinTeam.remove(event.getPlayer().getName());
if (team != null && _rejoinTime.remove(event.getPlayer().getName()) != null)
if (team != null && _rejoinTime.remove(event.getPlayer().getName()) != null)
{
team.AddPlayer(event.getPlayer());
Announce(team.GetColor() + C.Bold + event.getPlayer().getName() + " has reconnected!", false);
Kit kit = RejoinKit.remove(event.getPlayer().getName());
if (kit != null)
_playerKit.put(event.getPlayer(), kit);
return;
}
@ -148,11 +137,11 @@ public abstract class TeamGame extends Game
GameTeam team = RejoinTeam.remove(name);
if (team != null)
Announce(team.GetColor() + C.Bold + name + " did not reconnect in time!", false);
RejoinKit.remove(name);
}
}
@EventHandler
public void RejoinCommand(PlayerCommandPreprocessEvent event)
{
@ -173,7 +162,7 @@ public abstract class TeamGame extends Game
event.setCancelled(true);
}
}
public void EndCheck()
{
if (!IsLive())
@ -191,13 +180,13 @@ public abstract class TeamGame extends Game
for (GameTeam team : RejoinTeam.values())
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))
@ -205,52 +194,78 @@ public abstract class TeamGame extends Game
for (Player player : team.GetPlayers(false))
AddGems(player, 10, "Winning Team", false);
}
for (Player player : team.GetPlayers(false))
if (player.isOnline())
AddGems(player, 10, "Participation", false);
}
//End
SetState(GameState.End);
SetState(GameState.End);
}
}
@Override
@EventHandler
public void ScoreboardUpdate(UpdateEvent event)
{
if (event != null && event.getType() != UpdateType.FAST)
return;
Scoreboard.Reset();
for (GameTeam team : this.GetTeamList())
{
{
//Display Individual Players
if (this.GetPlayers(true).size() < 13)
{
if (!team.IsTeamAlive())
continue;
Scoreboard.WriteBlank();
for (Player player : team.GetPlayers(true))
{
Scoreboard.Write(team.GetColor() + player.getName());
}
}
//Display Players Alive
else
{
Scoreboard.WriteBlank();
Scoreboard.Write(team.GetColor() + team.GetName());
Scoreboard.Write(team.GetPlayers(true).size() + "" + team.GetColor() + " Alive");
}
}
Scoreboard.Draw();
}
@Override
public List<Player> getWinners()
{
if (WinnerTeam == null)
return null;
return WinnerTeam.GetPlayers(true);
}
@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;
}
}

View File

@ -1347,4 +1347,9 @@ public class Bridge extends TeamGame implements OreObsfucation
SetState(GameState.End);
}
}
public boolean isBridgesDown()
{
return _bridgesDown;
}
}

View File

@ -185,7 +185,9 @@ public class Draw extends SoloGame
//End Round
if (_round != null && (_round.IsDone() || _drawers.GetPlayers(true).isEmpty() || _round.AllGuessed(_guessers.GetPlayers(true))))
{
Announce(C.cGold + C.Bold + "Round " + (_roundCount+1) + " Ended: " + C.cYellow + C.Bold + "The word was " + _round.Word + "!");
Bukkit.getPluginManager().callEvent(new DrawRoundEndEvent(_round));
Announce(C.cGold + C.Bold + "Round " + (_roundCount + 1) + " Ended: " + C.cYellow + C.Bold + "The word was " + _round.Word + "!");
_textBlocks = UtilText.MakeText(_round.Word, _textLocation, BlockFace.WEST, 159, (byte)15, TextAlign.CENTER);
_roundTime = System.currentTimeMillis();

View File

@ -0,0 +1,42 @@
package nautilus.game.arcade.game.games.draw;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
public class DrawGuessCorrectlyEvent extends PlayerEvent
{
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList()
{
return handlers;
}
@Override
public HandlerList getHandlers()
{
return getHandlerList();
}
private final DrawRound _drawRound;
private final int _rank;
public DrawGuessCorrectlyEvent(Player who, DrawRound drawRound, int rank)
{
super(who);
_drawRound = drawRound;
_rank = rank;
}
public DrawRound getDrawRound()
{
return _drawRound;
}
public int getRank()
{
return _rank;
}
}

View File

@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.draw;
import java.util.ArrayList;
import java.util.HashSet;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@ -41,6 +42,9 @@ public class DrawRound
if (Guessed.add(player.getName()))
{
TimeMax -= 5;
Bukkit.getPluginManager().callEvent(new DrawGuessCorrectlyEvent(player, this, Guessed.size()));
return true;
}
@ -122,4 +126,9 @@ public class DrawRound
return true;
}
public Player getDrawer()
{
return Drawer;
}
}

View File

@ -0,0 +1,32 @@
package nautilus.game.arcade.game.games.draw;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class DrawRoundEndEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList()
{
return handlers;
}
@Override
public HandlerList getHandlers()
{
return getHandlerList();
}
private final DrawRound _drawRound;
public DrawRoundEndEvent(DrawRound drawRound)
{
_drawRound = drawRound;
}
public DrawRound getDrawRound()
{
return _drawRound;
}
}

View File

@ -0,0 +1,36 @@
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;
}
}

View File

@ -1,20 +1,11 @@
package nautilus.game.arcade.game.games.survivalgames;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.*;
import java.util.Map.Entry;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Effect;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Material;
import mineplex.core.achievement.*;
import org.bukkit.*;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Chest;
@ -391,8 +382,8 @@ public class SurvivalGames extends SoloGame
chest.getBlockInventory().setItem(UtilMath.r(27), GetChestItem(_supplyChests.contains(event.getClickedBlock())));
_supplyChests.remove(event.getClickedBlock());
//Manager.GetStatsManager().addStat(event.getPlayer(), GetName(), "chestsOpened", 1);
Bukkit.getPluginManager().callEvent(new SupplyChestOpenEvent(event.getPlayer(), event.getClickedBlock()));
}
private ItemStack GetChestItem(boolean superChest)
@ -1689,6 +1680,4 @@ public class SurvivalGames extends SoloGame
Scoreboard.Draw();
}
}

View File

@ -7,14 +7,8 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Map.Entry;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Effect;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.*;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Chest;
@ -394,8 +388,8 @@ public class SurvivalGamesTeams extends TeamGame
chest.getBlockInventory().setItem(UtilMath.r(27), GetChestItem(_supplyChests.contains(event.getClickedBlock())));
_supplyChests.remove(event.getClickedBlock());
//Manager.GetStatsManager().addStat(event.getPlayer(), GetName(), "chestsOpened", 1);
Bukkit.getPluginManager().callEvent(new SupplyChestOpenEvent(event.getPlayer(), event.getClickedBlock()));
}
private ItemStack GetChestItem(boolean superChest)

View File

@ -1,59 +1,78 @@
package nautilus.game.arcade.kit.perks;
import java.util.HashMap;
import java.util.HashSet;
import mineplex.core.common.util.*;
import mineplex.core.itemstack.*;
import mineplex.core.recharge.*;
import mineplex.core.updater.*;
import mineplex.core.updater.event.*;
import nautilus.game.arcade.kit.*;
import org.bukkit.*;
import org.bukkit.block.*;
import org.bukkit.entity.*;
import org.bukkit.event.*;
import org.bukkit.event.block.*;
import org.bukkit.event.entity.*;
import org.bukkit.event.inventory.*;
import org.bukkit.event.player.*;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.updater.UpdateType;
import nautilus.game.arcade.kit.Perk;
import java.util.*;
public class PerkBomber extends Perk
{
public static class BomberExplodeDiamondBlock extends PlayerEvent
{
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList()
{
return handlers;
}
@Override
public HandlerList getHandlers()
{
return getHandlerList();
}
private final Block _block;
public BomberExplodeDiamondBlock(Player who, Block block)
{
super(who);
_block = block;
}
public Block getBlock()
{
return _block;
}
}
private HashMap<Entity, Player> _tntMap = new HashMap<Entity, Player>();
private int _spawnRate;
private int _max;
private int _fuse;
public PerkBomber(int spawnRate, int max, int fuse)
public PerkBomber(int spawnRate, int max, int fuse)
{
super("Bomber", new String[]
super("Bomber", new String[]
{
C.cGray + "Receive 1 TNT every " + spawnRate + " seconds. Maximum of " + max + ".",
C.cYellow + "Click" + C.cGray + " with TNT to " + C.cGreen + "Throw TNT"
C.cGray + "Receive 1 TNT every " + spawnRate + " seconds. Maximum of " + max + ".",
C.cYellow + "Click" + C.cGray + " with TNT to " + C.cGreen + "Throw TNT"
});
_spawnRate = spawnRate;
_max = max;
_fuse = fuse;
}
public void Apply(Player player)
public void Apply(Player player)
{
Recharge.Instance.use(player, GetName(), _spawnRate*1000, false, false);
Recharge.Instance.use(player, GetName(), _spawnRate * 1000, false, false);
}
@EventHandler
public void TNTSpawn(UpdateEvent event)
{
@ -64,18 +83,18 @@ public class PerkBomber extends Perk
{
if (!Kit.HasKit(cur))
continue;
if (!Manager.GetGame().IsAlive(cur))
continue;
if (!Recharge.Instance.use(cur, GetName(), _spawnRate*1000, false, false))
if (!Recharge.Instance.use(cur, GetName(), _spawnRate * 1000, false, false))
continue;
if (UtilInv.contains(cur, Material.TNT, (byte)0, _max))
if (UtilInv.contains(cur, Material.TNT, (byte) 0, _max))
continue;
//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("Throwing TNT")));
cur.playSound(cur.getLocation(), Sound.ITEM_PICKUP, 2f, 1f);
}
@ -86,8 +105,8 @@ public class PerkBomber extends Perk
{
if (event.isCancelled())
return;
if (!UtilInv.IsItem(event.getItemDrop().getItemStack(), Material.TNT, (byte)0))
if (!UtilInv.IsItem(event.getItemDrop().getItemStack(), Material.TNT, (byte) 0))
return;
//Cancel
@ -99,11 +118,11 @@ public class PerkBomber extends Perk
@EventHandler
public void TNTDeathRemove(PlayerDeathEvent event)
{
{
HashSet<org.bukkit.inventory.ItemStack> remove = new HashSet<org.bukkit.inventory.ItemStack>();
for (org.bukkit.inventory.ItemStack item : event.getDrops())
if (UtilInv.IsItem(item, Material.TNT, (byte)0))
if (UtilInv.IsItem(item, Material.TNT, (byte) 0))
remove.add(item);
for (org.bukkit.inventory.ItemStack item : remove)
@ -113,57 +132,84 @@ public class PerkBomber extends Perk
@EventHandler
public void TNTInvClick(InventoryClickEvent event)
{
UtilInv.DisallowMovementOf(event, "Throwing TNT", Material.TNT, (byte)0, true);
UtilInv.DisallowMovementOf(event, "Throwing TNT", Material.TNT, (byte) 0, true);
}
@EventHandler
public void TNTThrow(PlayerInteractEvent event)
{
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK &&
event.getAction() != Action.LEFT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_AIR)
event.getAction() != Action.LEFT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_AIR)
return;
Player player = event.getPlayer();
if (!UtilInv.IsItem(player.getItemInHand(), Material.TNT, (byte)0))
if (!UtilInv.IsItem(player.getItemInHand(), Material.TNT, (byte) 0))
return;
if (!Kit.HasKit(player))
return;
event.setCancelled(true);
if (!Manager.GetGame().CanThrowTNT(player.getLocation()))
{
//Inform
UtilPlayer.message(event.getPlayer(), F.main(GetName(), "You cannot use " + F.item("Throwing TNT") + " here."));
return;
}
UtilInv.remove(player, Material.TNT, (byte)0, 1);
UtilInv.remove(player, Material.TNT, (byte) 0, 1);
UtilInv.Update(player);
TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), TNTPrimed.class);
if (_fuse != -1)
tnt.setFuseTicks(_fuse);
UtilAction.velocity(tnt, player.getLocation().getDirection(), 0.5, false, 0, 0.1, 10, false);
_tntMap.put(tnt, player);
}
@EventHandler
public void ExplosionPrime(ExplosionPrimeEvent event)
{
if (!_tntMap.containsKey(event.getEntity()))
return;
Player player = _tntMap.remove(event.getEntity());
for (Player other : UtilPlayer.getNearby(event.getEntity().getLocation(), 14))
if (player != null)
{
Manager.GetCondition().Factory().Explosion("Throwing TNT", other, player, 50, 0.1, false, false);
for (Player other : UtilPlayer.getNearby(event.getEntity().getLocation(), 14))
{
Manager.GetCondition().Factory().Explosion("Throwing TNT", other, player, 50, 0.1, false, false);
}
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityExplode(EntityExplodeEvent event)
{
Player player = _tntMap.remove(event.getEntity());
if (player != null)
{
for (Iterator<Block> it = event.blockList().iterator(); it.hasNext(); )
{
Block block = it.next();
if (block.getType() == Material.DIAMOND_ORE)
{
it.remove();
if (Math.random() < event.getYield())
{
block.breakNaturally();
Bukkit.getPluginManager().callEvent(new BomberExplodeDiamondBlock(player, block));
}
else
block.setType(Material.AIR);
}
}
}
}
}

View File

@ -1,48 +1,66 @@
package nautilus.game.arcade.kit.perks;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.bukkit.Location;
import mineplex.core.common.util.*;
import mineplex.core.updater.*;
import mineplex.core.updater.event.*;
import mineplex.minecraft.game.core.combat.event.*;
import mineplex.minecraft.game.core.damage.*;
import nautilus.game.arcade.kit.*;
import net.minecraft.server.v1_7_R4.*;
import org.bukkit.*;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftSkeleton;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_7_R4.entity.*;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Wolf;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.entity.*;
import org.bukkit.event.*;
import org.bukkit.event.entity.*;
import org.bukkit.event.player.*;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.updater.UpdateType;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.kit.Perk;
import net.minecraft.server.v1_7_R4.EntityCreature;
import net.minecraft.server.v1_7_R4.Navigation;
import java.util.*;
public class PerkSkeletons extends Perk
{
public static class MinionSpawnEvent extends PlayerEvent
{
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList()
{
return handlers;
}
private final PerkSkeletons _perkSkeletons;
public MinionSpawnEvent(Player who, PerkSkeletons perkSkeletons)
{
super(who);
_perkSkeletons = perkSkeletons;
}
@Override
public HandlerList getHandlers()
{
return getHandlerList();
}
public PerkSkeletons getPerkSkeletons()
{
return _perkSkeletons;
}
}
private HashMap<Player, ArrayList<Skeleton>> _minions = new HashMap<Player, ArrayList<Skeleton>>();
private boolean _name;
private int _maxDist = 8;
public PerkSkeletons(boolean name)
public PerkSkeletons(boolean name)
{
super("Skeleton Minons", new String[]
super("Skeleton Minons", new String[]
{
C.cGray + "Killing an opponent summons a skeletal minion."
C.cGray + "Killing an opponent summons a skeletal minion."
});
_name = name;
@ -64,7 +82,7 @@ public class PerkSkeletons extends Perk
if (!Kit.HasKit(killer))
return;
Player killed = (Player)event.GetEvent().getEntity();
Player killed = (Player) event.GetEvent().getEntity();
Manager.GetGame().CreatureAllowOverride = true;
Skeleton skel = killer.getWorld().spawn(killed.getLocation(), Skeleton.class);
@ -105,6 +123,8 @@ public class PerkSkeletons extends Perk
_minions.get(killer).add(skel);
killer.playSound(killer.getLocation(), Sound.SKELETON_HURT, 1f, 1f);
Bukkit.getPluginManager().callEvent(new MinionSpawnEvent(killer, this));
}
@EventHandler
@ -124,7 +144,7 @@ public class PerkSkeletons extends Perk
{
if (UtilMath.offset(skel, player) > _maxDist)
{
}
}
}
@ -150,11 +170,11 @@ public class PerkSkeletons extends Perk
{
skelIterator.remove();
continue;
}
}
//Return to Owner
double range = 4;
if (skel.getTarget() != null || ((CraftSkeleton)skel).getHandle().getGoalTarget() != null)
if (skel.getTarget() != null || ((CraftSkeleton) skel).getHandle().getGoalTarget() != null)
{
range = _maxDist;
}
@ -168,12 +188,12 @@ public class PerkSkeletons extends Perk
//Move
Location target = skel.getLocation().add(UtilAlg.getTrajectory(skel, player).multiply(3));
EntityCreature ec = ((CraftCreature)skel).getHandle();
EntityCreature ec = ((CraftCreature) skel).getHandle();
Navigation nav = ec.getNavigation();
nav.a(target.getX(), target.getY(), target.getZ(), speed);
skel.setTarget(null);
((CraftSkeleton)skel).getHandle().setGoalTarget(null);
((CraftSkeleton) skel).getHandle().setGoalTarget(null);
}
}
}
@ -190,7 +210,7 @@ public class PerkSkeletons extends Perk
for (Skeleton skel : skels)
{
if (skel.getHealth() > 0)
skel.setHealth(Math.min(skel.getMaxHealth(), skel.getHealth()+1));
skel.setHealth(Math.min(skel.getMaxHealth(), skel.getHealth() + 1));
}
}
}
@ -231,18 +251,18 @@ public class PerkSkeletons extends Perk
if (event.GetDamagerEntity(true) instanceof Skeleton)
{
Skeleton skel = (Skeleton)event.GetDamagerEntity(true);
Skeleton skel = (Skeleton) event.GetDamagerEntity(true);
if (skel.getEquipment().getItemInHand() != null)
{
if (skel.getEquipment().getItemInHand().getType() == Material.STONE_SWORD) damage = 5;
else if (skel.getEquipment().getItemInHand().getType() == Material.IRON_SWORD) damage = 6;
else if (skel.getEquipment().getItemInHand().getType() == Material.GOLD_SWORD) damage = 6;
else if (skel.getEquipment().getItemInHand().getType() == Material.DIAMOND_SWORD) damage = 7;
if (skel.getEquipment().getItemInHand().getType() == Material.STONE_SWORD) damage = 5;
else if (skel.getEquipment().getItemInHand().getType() == Material.IRON_SWORD) damage = 6;
else if (skel.getEquipment().getItemInHand().getType() == Material.GOLD_SWORD) damage = 6;
else if (skel.getEquipment().getItemInHand().getType() == Material.DIAMOND_SWORD) damage = 7;
else if (skel.getEquipment().getItemInHand().getType() == Material.IRON_AXE) damage = 5;
else if (skel.getEquipment().getItemInHand().getType() == Material.GOLD_AXE) damage = 5;
else if (skel.getEquipment().getItemInHand().getType() == Material.DIAMOND_AXE) damage = 6;
else if (skel.getEquipment().getItemInHand().getType() == Material.IRON_AXE) damage = 5;
else if (skel.getEquipment().getItemInHand().getType() == Material.GOLD_AXE) damage = 5;
else if (skel.getEquipment().getItemInHand().getType() == Material.DIAMOND_AXE) damage = 6;
}
}
@ -252,18 +272,23 @@ public class PerkSkeletons extends Perk
event.AddMod("Skeleton Minion", "Negate", -event.GetDamageInitial(), false);
event.AddMod("Skeleton Minion", "Damage", damage, false);
}
@EventHandler
public void PlayerDeath(PlayerDeathEvent event)
{
ArrayList<Skeleton> skels = _minions.remove(event.getEntity());
if (skels == null)
return;
for (Skeleton skel : skels)
skel.remove();
skels.clear();
}
public List<Skeleton> getSkeletons(Player player)
{
return _minions.get(player);
}
}

View File

@ -0,0 +1,31 @@
package nautilus.game.arcade.stats;
import mineplex.core.common.util.*;
import mineplex.minecraft.game.core.combat.*;
import mineplex.minecraft.game.core.combat.event.*;
import nautilus.game.arcade.game.*;
import org.bukkit.entity.*;
import org.bukkit.event.*;
public class AssistsStatTracker extends StatTracker<Game>
{
public AssistsStatTracker(Game game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCombatDeath(CombatDeathEvent event)
{
for (CombatComponent log : event.GetLog().GetAttackers())
{
if (event.GetLog().GetKiller() != null && log.equals(event.GetLog().GetKiller()))
continue;
Player player = UtilPlayer.searchExact(log.GetName());
getGame().AddStat(player, "Assists", 1, false, false);
getGame().AddStat(player, getGame().GetKit(player).GetName() + " Assists", 1, false, false);
}
}
}

View File

@ -0,0 +1,51 @@
package nautilus.game.arcade.stats;
import mineplex.core.common.util.*;
import mineplex.minecraft.game.core.combat.event.*;
import nautilus.game.arcade.game.games.bridge.*;
import org.bukkit.entity.*;
import org.bukkit.event.*;
import org.bukkit.event.entity.*;
public class BridgesSniperStatTracker extends StatTracker<Bridge>
{
public BridgesSniperStatTracker(Bridge game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCombatDeath(CombatDeathEvent event)
{
if (getGame().isBridgesDown())
return;
if (event.GetLog().GetKiller() == null)
return;
if (!event.GetLog().GetKiller().IsPlayer())
return;
Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
if (killer == null)
return;
if (event.GetLog().GetPlayer() == null)
return;
if (!event.GetLog().GetPlayer().IsPlayer())
return;
Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName());
if (player == null)
return;
if (player.getLastDamageCause() instanceof EntityDamageByEntityEvent)
{
EntityDamageByEntityEvent edbee = (EntityDamageByEntityEvent) player.getLastDamageCause();
if (edbee.getDamager() instanceof Arrow)
getGame().AddStat(killer, "Sniper", 1, true, false);
}
}
}

View File

@ -0,0 +1,25 @@
package nautilus.game.arcade.stats;
import mineplex.minecraft.game.core.damage.*;
import nautilus.game.arcade.game.*;
import org.bukkit.entity.*;
import org.bukkit.event.*;
public class DamageDealtStatTracker extends StatTracker<Game>
{
public DamageDealtStatTracker(Game game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCustomDamage(CustomDamageEvent event)
{
Player damager = event.GetDamagerPlayer(false);
if (damager == null)
return;
getGame().AddStat(damager, "Damage Dealt", (int) Math.round(event.GetDamage()), false, false);
getGame().AddStat(damager, getGame().GetKit(damager).GetName() + " Damage Dealt", (int) Math.round(event.GetDamage()), false, false);
}
}

View File

@ -0,0 +1,25 @@
package nautilus.game.arcade.stats;
import mineplex.minecraft.game.core.damage.*;
import nautilus.game.arcade.game.*;
import org.bukkit.entity.*;
import org.bukkit.event.*;
public class DamageTakenStatTracker extends StatTracker<Game>
{
public DamageTakenStatTracker(Game game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCustomDamage(CustomDamageEvent event)
{
Player damagee = event.GetDamageePlayer();
if (damagee == null)
return;
getGame().AddStat(damagee, "Damage Taken", (int) Math.round(event.GetDamage()), false, false);
getGame().AddStat(damagee, getGame().GetKit(damagee).GetName() + " Damage Taken", (int) Math.round(event.GetDamage()), false, false);
}
}

View File

@ -0,0 +1,61 @@
package nautilus.game.arcade.stats;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import mineplex.core.common.util.UtilPlayer;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.game.Game;
public class DeathBomberStatTracker extends StatTracker<Game>
{
private final Map<UUID, Integer> _killCount = new HashMap<>();
public DeathBomberStatTracker(Game game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCombatDeath(CombatDeathEvent event)
{
if (event.GetLog().GetKiller() == null)
return;
if (!event.GetLog().GetKiller().IsPlayer())
return;
Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
if (killer == null)
return;
if (event.GetLog().GetPlayer() == null)
return;
if (!event.GetLog().GetPlayer().IsPlayer())
return;
Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName());
if (player == null)
return;
if (player.getLastDamageCause().getCause() == EntityDamageEvent.DamageCause.BLOCK_EXPLOSION
|| player.getLastDamageCause().getCause() == EntityDamageEvent.DamageCause.ENTITY_EXPLOSION)
{
Integer count = _killCount.get(killer.getUniqueId());
count = (count == null ? 0 : count) + 1;
_killCount.put(killer.getUniqueId(), count);
if (count >= 5)
getGame().AddStat(killer, "DeathBomber", 1, true, false);
}
}
}

View File

@ -0,0 +1,32 @@
package nautilus.game.arcade.stats;
import mineplex.core.common.util.*;
import mineplex.minecraft.game.core.combat.event.*;
import nautilus.game.arcade.game.*;
import org.bukkit.entity.*;
import org.bukkit.event.*;
public class DeathsStatTracker extends StatTracker<Game>
{
public DeathsStatTracker(Game game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCombatDeath(CombatDeathEvent event)
{
if (event.GetLog().GetPlayer() == null)
return;
if (!event.GetLog().GetPlayer().IsPlayer())
return;
Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName());
if (player == null)
return;
getGame().AddStat(player, "Deaths", 1, false, false);
getGame().AddStat(player, getGame().GetKit(player).GetName() + " Deaths", 1, false, false);
}
}

View File

@ -0,0 +1,20 @@
package nautilus.game.arcade.stats;
import mineplex.minecraft.game.classcombat.Skill.Mage.*;
import nautilus.game.arcade.game.*;
import org.bukkit.event.*;
public class ElectrocutionStatTracker extends StatTracker<Game>
{
public ElectrocutionStatTracker(Game game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onLightningOrb(LightningOrb.LightningOrbEvent event)
{
if (event.getStruck().size() >= 4)
getGame().AddStat(event.getPlayer(), "MassElectrocution", 1, true, false);
}
}

View File

@ -0,0 +1,89 @@
package nautilus.game.arcade.stats;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import mineplex.core.common.util.UtilPlayer;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.game.Game;
public class FastKillsStatTracker extends StatTracker<Game>
{
private final Map<UUID, Integer> _killCount = new HashMap<>();
private final Map<UUID, Long> _lastKillTime = new HashMap<>();
private final int _requiredKillCount;
private final int _timeBetweenKills;
public FastKillsStatTracker(Game game, int requiredKillCount, int timeBetweenKills)
{
super(game);
_requiredKillCount = requiredKillCount;
_timeBetweenKills = timeBetweenKills * 1000;
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCombatDeath(CombatDeathEvent event)
{
if (event.GetLog().GetKiller() == null)
return;
if (!event.GetLog().GetKiller().IsPlayer())
return;
Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
if (killer == null)
return;
if (event.GetLog().GetPlayer() == null)
return;
if (!event.GetLog().GetPlayer().IsPlayer())
return;
Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName());
if (player == null)
return;
Long lastTime = _lastKillTime.get(killer.getUniqueId());
long now = System.currentTimeMillis();
Integer killCount;
if (lastTime == null || now - lastTime > getTimeBetweenKills())
killCount = 0;
else
{
killCount = _killCount.get(killer.getUniqueId());
if (killCount == null)
killCount = 0;
}
killCount++;
_killCount.put(killer.getUniqueId(), killCount);
_lastKillTime.put(killer.getUniqueId(), now);
_killCount.remove(player.getUniqueId());
_lastKillTime.remove(player.getUniqueId());
if (killCount >= getRequiredKillCount())
getGame().AddStat(killer, "FastKills", 1, true, false);
}
public int getRequiredKillCount()
{
return _requiredKillCount;
}
public int getTimeBetweenKills()
{
return _timeBetweenKills;
}
}

View File

@ -0,0 +1,26 @@
package nautilus.game.arcade.stats;
import nautilus.game.arcade.game.*;
import nautilus.game.arcade.game.games.survivalgames.*;
import org.bukkit.event.*;
public class FirstSupplyDropOpenStatTracker extends StatTracker<Game>
{
private boolean first = true;
public FirstSupplyDropOpenStatTracker(Game game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onSupplyChestOpen(SupplyChestOpenEvent event)
{
if (first)
{
getGame().AddStat(event.getPlayer(), "SupplyDropsOpened", 1, false, false);
first = false;
}
}
}

View File

@ -0,0 +1,37 @@
package nautilus.game.arcade.stats;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.kit.KitAvailability;
public class FreeKitWinStatTracker extends StatTracker<Game>
{
public FreeKitWinStatTracker(Game game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onGameStateChange(GameStateChangeEvent event)
{
if (event.GetState() == Game.GameState.End)
{
List<Player> winners = getGame().getWinners();
if (winners != null)
{
for (Player winner : winners)
{
if (getGame().GetKit(winner).GetAvailability() == KitAvailability.Free)
getGame().AddStat(winner, "FreeKitsForever", 1, false, false);
}
}
}
}
}

View File

@ -0,0 +1,48 @@
package nautilus.game.arcade.stats;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.games.draw.Draw;
import nautilus.game.arcade.game.games.draw.DrawRoundEndEvent;
public class KeenEyeStatTracker extends StatTracker<Draw>
{
private final List<Player> _guessAll = new ArrayList<>();
public KeenEyeStatTracker(Draw game)
{
super(game);
}
@EventHandler
public void onDrawRoundEnd(DrawRoundEndEvent event)
{
for (Iterator<Player> it = _guessAll.iterator(); it.hasNext(); )
{
Player player = it.next();
if (player == event.getDrawRound().Drawer)
continue;
if (!event.getDrawRound().Guessed.contains(player.getName()))
it.remove();
}
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onGameStateChange(GameStateChangeEvent event)
{
if (event.GetState() == Game.GameState.End)
{
for (Player player : _guessAll)
getGame().AddStat(player, "KeenEye", 1, true, false);
}
}
}

View File

@ -0,0 +1,91 @@
package nautilus.game.arcade.stats;
import mineplex.core.common.util.*;
import mineplex.minecraft.game.core.combat.event.*;
import nautilus.game.arcade.events.*;
import nautilus.game.arcade.game.*;
import org.bukkit.entity.*;
import org.bukkit.event.*;
import java.util.*;
public class KillAllOpposingStatTracker extends StatTracker<TeamGame>
{
private final Map<UUID, Set<UUID>> _kills = new HashMap<>();
public KillAllOpposingStatTracker(TeamGame game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCombatDeath(CombatDeathEvent event)
{
if (event.GetLog().GetKiller() == null)
return;
if (!event.GetLog().GetKiller().IsPlayer())
return;
Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
if (killer == null)
return;
if (event.GetLog().GetPlayer() == null)
return;
if (!event.GetLog().GetPlayer().IsPlayer())
return;
Player killed = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName());
if (killed == null)
return;
Set<UUID> kills = _kills.get(killer.getUniqueId());
if (kills == null)
{
kills = new HashSet<>();
_kills.put(killer.getUniqueId(), kills);
}
kills.add(killed.getUniqueId());
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onGameStateChange(GameStateChangeEvent event)
{
if (event.GetState() == Game.GameState.End)
{
for (GameTeam team : getGame().GetTeamList())
{
for (Player player : team.GetPlayers(false))
{
Set<UUID> kills = _kills.get(player.getUniqueId());
if (kills == null)
continue;
for (GameTeam otherTeam : getGame().GetTeamList())
{
if (otherTeam == team)
continue;
boolean killedAll = true;
for (Player otherPlayer : otherTeam.GetPlayers(true))
{
if (!kills.contains(otherPlayer.getUniqueId()))
{
killedAll = false;
break;
}
}
if (killedAll)
getGame().AddStat(player, "Ace", 1, true, false);
}
}
}
}
}
}

View File

@ -0,0 +1,32 @@
package nautilus.game.arcade.stats;
import mineplex.core.common.util.*;
import mineplex.minecraft.game.core.combat.event.*;
import nautilus.game.arcade.game.*;
import org.bukkit.entity.*;
import org.bukkit.event.*;
public class KillsStatTracker extends StatTracker<Game>
{
public KillsStatTracker(Game game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCombatDeath(CombatDeathEvent event)
{
if (event.GetLog().GetKiller() == null)
return;
if (!event.GetLog().GetKiller().IsPlayer())
return;
Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
if (player == null)
return;
getGame().AddStat(player, "Kills", 1, false, false);
getGame().AddStat(player, getGame().GetKit(player).GetName() + " Kills", 1, false, false);
}
}

View File

@ -0,0 +1,58 @@
package nautilus.game.arcade.stats;
import mineplex.core.common.util.*;
import mineplex.minecraft.game.core.combat.event.*;
import nautilus.game.arcade.game.*;
import org.bukkit.entity.*;
import org.bukkit.event.*;
import java.util.*;
public class KillsWithinTimeLimitStatTracker extends StatTracker<Game>
{
private final int _killCount;
private final int _timeLimit;
private final Map<UUID, Integer> _kills = new HashMap<>();
public KillsWithinTimeLimitStatTracker(Game game, int killCount, int timeLimit)
{
super(game);
_killCount = killCount;
_timeLimit = timeLimit * 1000;
}
public int getKillCount()
{
return _killCount;
}
public int getTimeLimit()
{
return _timeLimit;
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCombatDeath(CombatDeathEvent event)
{
if (event.GetLog().GetKiller() == null)
return;
if (!event.GetLog().GetKiller().IsPlayer())
return;
Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
if (player == null)
return;
Integer killCount = _kills.get(player.getUniqueId());
killCount = (killCount == null ? 0 : killCount) + 1;
_kills.put(player.getUniqueId(), killCount);
if (killCount == getKillCount() && System.currentTimeMillis() - getGame().GetStateTime() < getTimeLimit())
getGame().AddStat(player, "Bloodlust", 1, true, false);
}
}

View File

@ -0,0 +1,34 @@
package nautilus.game.arcade.stats;
import nautilus.game.arcade.events.*;
import nautilus.game.arcade.game.*;
import org.bukkit.entity.*;
import org.bukkit.event.*;
import java.util.*;
public class LoseStatTracker extends StatTracker<Game>
{
public LoseStatTracker(Game game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onGameStateChange(GameStateChangeEvent event)
{
if (event.GetState() == Game.GameState.End)
{
List<Player> losers = getGame().getLosers();
if (losers != null)
{
for (Player loser : losers)
{
getGame().AddStat(loser, "Losses", 1, false, false);
getGame().AddStat(loser, getGame().GetKit(loser).GetName() + " Losses", 1, false, false);
}
}
}
}
}

View File

@ -0,0 +1,60 @@
package nautilus.game.arcade.stats;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import nautilus.game.arcade.game.games.draw.Draw;
import nautilus.game.arcade.game.games.draw.DrawGuessCorrectlyEvent;
public class MrSquiggleStatTracker extends StatTracker<Draw>
{
private final Map<UUID, List<Long>> _guessTimes = new HashMap<>();
public MrSquiggleStatTracker(Draw game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onDrawGuessCorrectly(DrawGuessCorrectlyEvent event)
{
if (event.getRank() != 1)
return;
Player drawer = event.getDrawRound().getDrawer();
List<Long> times = _guessTimes.get(drawer.getUniqueId());
if (times == null)
{
times = new ArrayList<>();
_guessTimes.put(drawer.getUniqueId(), times);
}
times.add(System.currentTimeMillis() - event.getDrawRound().Time);
if (times.size() >= 2)
{
boolean greaterThan15000 = false;
for (long time : times)
{
if (time > 15000)
{
greaterThan15000 = true;
break;
}
}
if (!greaterThan15000)
getGame().AddStat(drawer, "MrSquiggle", 1, true, false);
}
}
}

View File

@ -0,0 +1,76 @@
package nautilus.game.arcade.stats;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import mineplex.core.common.util.UtilPlayer;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
public class OneVThreeStatTracker extends StatTracker<Game>
{
private final Map<UUID, Integer> _killCount = new HashMap<>();
public OneVThreeStatTracker(Game game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCombatDeath(CombatDeathEvent event)
{
if (event.GetLog().GetKiller() == null)
return;
if (!event.GetLog().GetKiller().IsPlayer())
return;
Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
if (killer == null)
return;
if (event.GetLog().GetPlayer() == null)
return;
if (!event.GetLog().GetPlayer().IsPlayer())
return;
Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName());
if (player == null)
return;
Integer killCount = _killCount.get(killer.getUniqueId());
if (killCount == null)
killCount = 0;
killCount++;
_killCount.put(killer.getUniqueId(), killCount);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onGameStateChange(GameStateChangeEvent event)
{
if (event.GetState() == Game.GameState.End)
{
List<Player> players = getGame().GetPlayers(false);
if (players.size() >= 4)
return;
for (Player player : players)
{
Integer killCount = _killCount.get(player.getUniqueId());
if (killCount != null && killCount >= 10)
getGame().AddStat(player, "1v3", 1, true, false);
}
}
}
}

View File

@ -0,0 +1,22 @@
package nautilus.game.arcade.stats;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import nautilus.game.arcade.game.games.draw.Draw;
import nautilus.game.arcade.game.games.draw.DrawGuessCorrectlyEvent;
public class PureLuckStatTracker extends StatTracker<Draw>
{
public PureLuckStatTracker(Draw game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onDrawGuessCorrectly(DrawGuessCorrectlyEvent event)
{
if (System.currentTimeMillis() - event.getDrawRound().Time < 5000)
getGame().AddStat(event.getPlayer(), "PureLuck", 1, true, false);
}
}

View File

@ -0,0 +1,57 @@
package nautilus.game.arcade.stats;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import mineplex.core.common.util.UtilPlayer;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.Game;
public class RecoveryMasterStatTracker extends StatTracker<Game>
{
private final Map<UUID, Double> _damageTaken = new HashMap<>();
public RecoveryMasterStatTracker(Game game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCombatDeath(CombatDeathEvent event)
{
if (event.GetLog().GetPlayer() == null)
return;
if (!event.GetLog().GetPlayer().IsPlayer())
return;
Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName());
if (player == null)
return;
_damageTaken.remove(player.getUniqueId());
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCustomDamage(CustomDamageEvent event)
{
Player damagee = event.GetDamageePlayer();
if (damagee == null)
return;
Double damage = _damageTaken.get(damagee.getUniqueId());
damage = (damage == null ? 0 : damage) + event.GetDamage();
_damageTaken.put(damagee.getUniqueId(), damage);
if (damage >= 200)
getGame().AddStat(damagee, "RecoveryMaster", 1, true, false);
}
}

View File

@ -0,0 +1,20 @@
package nautilus.game.arcade.stats;
import mineplex.minecraft.game.classcombat.Skill.Brute.*;
import nautilus.game.arcade.game.*;
import org.bukkit.event.*;
public class SeismicSlamStatTracker extends StatTracker<Game>
{
public SeismicSlamStatTracker(Game game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onLongshotHit(SeismicSlam.SeismicSlamEvent event)
{
if (event.getTargets().size() >= 5)
getGame().AddStat(event.getPlayer(), "Earthquake", 1, true, false);
}
}

View File

@ -0,0 +1,45 @@
package nautilus.game.arcade.stats;
import nautilus.game.arcade.game.*;
import nautilus.game.arcade.kit.perks.*;
import org.bukkit.entity.*;
import org.bukkit.event.*;
import java.util.*;
public class SimultaneousSkeletonStatTracker extends StatTracker<Game>
{
private final int _requiredCount;
public SimultaneousSkeletonStatTracker(Game game, int requiredCount)
{
super(game);
_requiredCount = requiredCount;
}
@EventHandler
public void onMinionSpawn(PerkSkeletons.MinionSpawnEvent event)
{
List<Skeleton> skeletons = event.getPerkSkeletons().getSkeletons(event.getPlayer());
if (skeletons != null)
{
int aliveCount = 0;
for (Skeleton skeleton : skeletons)
{
if (!skeleton.isDead())
aliveCount++;
}
if (aliveCount >= getRequiredCount())
getGame().AddStat(event.getPlayer(), "Skeletons", 1, true, false);
}
}
public int getRequiredCount()
{
return _requiredCount;
}
}

View File

@ -0,0 +1,19 @@
package nautilus.game.arcade.stats;
import nautilus.game.arcade.game.*;
import org.bukkit.event.*;
public class StatTracker<G extends Game> implements Listener
{
private final G game;
public StatTracker(G game)
{
this.game = game;
}
public G getGame()
{
return game;
}
}

View File

@ -0,0 +1,19 @@
package nautilus.game.arcade.stats;
import nautilus.game.arcade.game.*;
import nautilus.game.arcade.kit.perks.*;
import org.bukkit.event.*;
public class TntMinerStatTracker extends StatTracker<Game>
{
public TntMinerStatTracker(Game game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onEntityExplode(PerkBomber.BomberExplodeDiamondBlock event)
{
getGame().AddStat(event.getPlayer(), "FortuneBomber", 1, false, false);
}
}

View File

@ -0,0 +1,34 @@
package nautilus.game.arcade.stats;
import nautilus.game.arcade.events.*;
import nautilus.game.arcade.game.*;
import org.bukkit.entity.*;
import org.bukkit.event.*;
import java.util.*;
public class WinStatTracker extends StatTracker<Game>
{
public WinStatTracker(Game game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onGameStateChange(GameStateChangeEvent event)
{
if (event.GetState() == Game.GameState.End)
{
List<Player> winners = getGame().getWinners();
if (winners != null)
{
for (Player winner : winners)
{
getGame().AddStat(winner, "Wins", 1, false, false);
getGame().AddStat(winner, getGame().GetKit(winner).GetName() + " Wins", 1, false, false);
}
}
}
}
}

View File

@ -0,0 +1,59 @@
package nautilus.game.arcade.stats;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import mineplex.core.common.util.UtilPlayer;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
public class WinWithoutDyingStatTracker extends StatTracker<Game>
{
private final Set<UUID> _hasDied = new HashSet<>();
public WinWithoutDyingStatTracker(Game game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCombatDeath(CombatDeathEvent event)
{
if (event.GetLog().GetPlayer() == null)
return;
if (!event.GetLog().GetPlayer().IsPlayer())
return;
Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName());
if (player == null)
return;
_hasDied.add(player.getUniqueId());
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onGameStateChange(GameStateChangeEvent event)
{
if (event.GetState() == Game.GameState.End)
{
List<Player> winners = getGame().getWinners();
if (winners != null)
{
for (Player winner : winners)
{
if (!_hasDied.contains(winner.getUniqueId()))
getGame().AddStat(winner, "MLGPro", 1, true, false);
}
}
}
}
}

View File

@ -0,0 +1,29 @@
package nautilus.game.arcade.stats;
import nautilus.game.arcade.events.*;
import nautilus.game.arcade.game.*;
import org.bukkit.entity.*;
import org.bukkit.event.*;
public class WinWithoutLosingTeammateStatTracker extends StatTracker<TeamGame>
{
public WinWithoutLosingTeammateStatTracker(TeamGame game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onGameStateChange(GameStateChangeEvent event)
{
if (event.GetState() == Game.GameState.End)
{
GameTeam winner = getGame().WinnerTeam;
if (winner.GetPlayers(true).size() == winner.GetPlayers(false).size())
{
for (Player player : winner.GetPlayers(true))
getGame().AddStat(player, "FlawlessVictory", 1, true, false);
}
}
}
}

View File

@ -0,0 +1,63 @@
package nautilus.game.arcade.stats;
import mineplex.core.updater.*;
import mineplex.core.updater.event.*;
import nautilus.game.arcade.events.*;
import nautilus.game.arcade.game.*;
import org.bukkit.*;
import org.bukkit.entity.*;
import org.bukkit.event.*;
import org.bukkit.inventory.*;
import java.util.*;
public class WinWithoutWearingArmorStatTracker extends StatTracker<Game>
{
private final Set<UUID> _armorWearers = new HashSet<>();
public WinWithoutWearingArmorStatTracker(Game game)
{
super(game);
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() == UpdateType.TICK && getGame().GetState() == Game.GameState.Live)
{
for (Player player : getGame().GetPlayers(true))
{
if (_armorWearers.contains(player.getUniqueId()))
continue;
for (ItemStack armor : player.getInventory().getArmorContents())
{
if (armor != null && armor.getType() != Material.AIR)
{
_armorWearers.add(player.getUniqueId());
break;
}
}
}
}
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onGameStateChange(GameStateChangeEvent event)
{
if (event.GetState() == Game.GameState.End)
{
List<Player> winners = getGame().getWinners();
if (winners != null)
{
for (Player winner : winners)
{
if (!_armorWearers.contains(winner.getUniqueId()))
getGame().AddStat(winner, "NoArmor", 1, true, false);
}
}
}
}
}