Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex
This commit is contained in:
commit
7535f39d18
@ -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>
|
@ -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>
|
10
Plugins/.idea/artifacts/Mineplex_MapParser_jar.xml
Normal file
10
Plugins/.idea/artifacts/Mineplex_MapParser_jar.xml
Normal 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>
|
8
Plugins/.idea/artifacts/Mineplex_MapParser_test.xml
Normal file
8
Plugins/.idea/artifacts/Mineplex_MapParser_test.xml
Normal 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>
|
@ -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>
|
||||
|
@ -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" />
|
||||
|
27
Plugins/.idea/runConfigurations/Hub.xml
Normal file
27
Plugins/.idea/runConfigurations/Hub.xml
Normal 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>
|
27
Plugins/.idea/runConfigurations/MapParser.xml
Normal file
27
Plugins/.idea/runConfigurations/MapParser.xml
Normal 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.
@ -58,11 +58,12 @@ public class LobbyBalancer implements Listener, Runnable
|
||||
|
||||
while (_bestServerIndex < _sortedLobbies.size())
|
||||
{
|
||||
_bestServerIndex++;
|
||||
_maxPlayersToSendToBestServer = (_sortedLobbies.get(_bestServerIndex).getMaxPlayerCount() - _sortedLobbies.get(_bestServerIndex).getPlayerCount()) / bungeeBufferNumber;
|
||||
|
||||
if (_maxPlayersToSendToBestServer > 0)
|
||||
break;
|
||||
|
||||
_bestServerIndex++;
|
||||
}
|
||||
|
||||
if (_maxPlayersToSendToBestServer == 0)
|
||||
|
@ -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>
|
||||
|
@ -9,9 +9,9 @@ public class UtilServer
|
||||
{
|
||||
public static Player[] getPlayers()
|
||||
{
|
||||
return getServer().getOnlinePlayers();
|
||||
return getServer().getOnlinePlayers().toArray(new Player[0]);
|
||||
}
|
||||
|
||||
|
||||
public static Server getServer()
|
||||
{
|
||||
return Bukkit.getServer();
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -217,7 +217,7 @@ public class CoreClientManager extends MiniPlugin
|
||||
client.SetPlayer(event.getPlayer());
|
||||
|
||||
// Reserved Slot Check
|
||||
if (Bukkit.getOnlinePlayers().length >= Bukkit.getServer().getMaxPlayers())
|
||||
if (Bukkit.getOnlinePlayers().size() >= Bukkit.getServer().getMaxPlayers())
|
||||
{
|
||||
if (client.GetRank().Has(event.getPlayer(), Rank.ULTRA, false))
|
||||
{
|
||||
|
@ -357,7 +357,7 @@ public class AntiHack extends MiniPlugin
|
||||
|
||||
UtilServer.broadcast(F.main("MAC", player.getName() + " was kicked for suspicious movement."));
|
||||
|
||||
ServerListPingEvent event = new ServerListPingEvent(null, Bukkit.getServer().getMotd(), Bukkit.getServer().getOnlinePlayers().length, Bukkit.getServer().getMaxPlayers());
|
||||
ServerListPingEvent event = new ServerListPingEvent(null, Bukkit.getServer().getMotd(), Bukkit.getServer().getOnlinePlayers().size(), Bukkit.getServer().getMaxPlayers());
|
||||
GetPluginManager().callEvent(event);
|
||||
|
||||
String motd = event.getMotd();
|
||||
|
@ -5,7 +5,6 @@ import java.util.UUID;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.timing.TimingManager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -52,9 +51,7 @@ public class EloManager extends MiniPlugin
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
TimingManager.start(event.getPlayerName() + " elo Account call.");
|
||||
NautHashMap<String, Integer> eloMap = _repository.loadClientInformation(event.getUniqueId());
|
||||
TimingManager.stop(event.getPlayerName() + " elo Account call.");
|
||||
|
||||
synchronized (_playerEloLock)
|
||||
{
|
||||
|
@ -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;
|
||||
@ -93,14 +94,14 @@ public class FriendManager extends MiniClientPlugin<FriendData> implements IPack
|
||||
@EventHandler
|
||||
public void updateFriends(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SLOW || Bukkit.getOnlinePlayers().length == 0)
|
||||
if (event.getType() != UpdateType.SLOW || Bukkit.getOnlinePlayers().size() == 0)
|
||||
return;
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable()
|
||||
{
|
||||
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()
|
||||
{
|
||||
|
@ -153,7 +153,7 @@ public class Portal extends MiniPlugin
|
||||
@EventHandler
|
||||
public void checkForServerTransfers(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC || Bukkit.getOnlinePlayers().length == 0)
|
||||
if (event.getType() != UpdateType.SEC || Bukkit.getOnlinePlayers().size() == 0)
|
||||
return;
|
||||
|
||||
_retrieve = !_retrieve;
|
||||
|
@ -20,7 +20,6 @@ import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.preferences.command.PreferencesCommand;
|
||||
import mineplex.core.preferences.ui.PreferencesShop;
|
||||
import mineplex.core.timing.TimingManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
@ -73,9 +72,7 @@ public class PreferencesManager extends MiniClientPlugin<UserPreferences>
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
TimingManager.start(event.getPlayerName() + " pref Account call.");
|
||||
Set(event.getPlayerName(), _repository.loadClientInformation(event.getUniqueId()));
|
||||
TimingManager.stop(event.getPlayerName() + " pref Account call.");
|
||||
event.decreaseProcessingCount();
|
||||
}
|
||||
});
|
||||
|
@ -200,8 +200,6 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
|
||||
SetCurrentPageForPlayer(player, page);
|
||||
|
||||
player.openInventory(page);
|
||||
|
||||
System.out.println(this.getClass().getName() + " - player.openInventory(page);");
|
||||
}
|
||||
|
||||
public void SetCurrentPageForPlayer(Player player, ShopPageBase<PluginType, ? extends ShopBase<PluginType>> page)
|
||||
|
@ -131,11 +131,11 @@ public class ServerStatusManager extends MiniPlugin
|
||||
*/
|
||||
private MinecraftServer generateServerSnapshot()
|
||||
{
|
||||
ServerListPingEvent event = new ServerListPingEvent(null, GetPlugin().getServer().getMotd(), GetPlugin().getServer().getOnlinePlayers().length, GetPlugin().getServer().getMaxPlayers());
|
||||
ServerListPingEvent event = new ServerListPingEvent(null, GetPlugin().getServer().getMotd(), GetPlugin().getServer().getOnlinePlayers().size(), GetPlugin().getServer().getMaxPlayers());
|
||||
GetPluginManager().callEvent(event);
|
||||
|
||||
String motd = event.getMotd();
|
||||
int playerCount = Bukkit.getOnlinePlayers().length;
|
||||
int playerCount = Bukkit.getOnlinePlayers().size();
|
||||
int maxPlayerCount = event.getMaxPlayers();
|
||||
int tps = (int) _lagMeter.getTicksPerSecond();
|
||||
String address = Bukkit.getServer().getIp().isEmpty() ? "localhost" : Bukkit.getServer().getIp();
|
||||
|
@ -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>
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
@ -441,7 +447,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
CoreClient client = _clientManager.Get(event.getPlayer().getName());
|
||||
|
||||
// Reserved Slot Check
|
||||
if (Bukkit.getOnlinePlayers().length - Bukkit.getServer().getMaxPlayers() >= 20)
|
||||
if (Bukkit.getOnlinePlayers().size() - Bukkit.getServer().getMaxPlayers() >= 20)
|
||||
{
|
||||
if (!client.GetRank().Has(Rank.ULTRA))
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
59
Plugins/Mineplex.Hub/src/mineplex/hub/poll/Poll.java
Normal file
59
Plugins/Mineplex.Hub/src/mineplex/hub/poll/Poll.java
Normal 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;
|
||||
}
|
||||
}
|
212
Plugins/Mineplex.Hub/src/mineplex/hub/poll/PollManager.java
Normal file
212
Plugins/Mineplex.Hub/src/mineplex/hub/poll/PollManager.java
Normal 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));
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -86,6 +86,7 @@ public class LobbyMenu extends ShopPageBase<ServerManager, LobbyShop> implements
|
||||
public void Update()
|
||||
{
|
||||
clear();
|
||||
ButtonMap.clear();
|
||||
BuildPage();
|
||||
}
|
||||
|
||||
|
15
Plugins/Mineplex.MapParser/Mineplex.MapParser.iml
Normal file
15
Plugins/Mineplex.MapParser/Mineplex.MapParser.iml
Normal 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>
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -15,18 +15,16 @@ 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 MapData(String mapFolder)
|
||||
{
|
||||
MapFolder = mapFolder;
|
||||
|
||||
WhiteList = new HashSet<String>();
|
||||
BuildList = new HashSet<String>();
|
||||
|
||||
if ((new File(MapFolder + File.separator + "Map.dat")).exists())
|
||||
@ -66,12 +64,7 @@ public class MapData
|
||||
}
|
||||
else if (tokens[0].equalsIgnoreCase("GAME_TYPE"))
|
||||
{
|
||||
GameType = tokens[1];
|
||||
}
|
||||
else if (tokens[0].equalsIgnoreCase("WHITE_LIST"))
|
||||
{
|
||||
for (String cur : tokens[1].split(","))
|
||||
WhiteList.add(cur);
|
||||
GameType = GameType.valueOf(tokens[1] == null ? "Null" : tokens[1]);
|
||||
}
|
||||
else if (tokens[0].equalsIgnoreCase("BUILD_LIST"))
|
||||
{
|
||||
@ -103,13 +96,6 @@ public class MapData
|
||||
out.write("\n");
|
||||
out.write("GAME_TYPE:"+GameType);
|
||||
|
||||
String whiteList = "";
|
||||
for (String cur : WhiteList)
|
||||
whiteList += cur + ",";
|
||||
|
||||
out.write("\n");
|
||||
out.write("WHITE_LIST:"+whiteList);
|
||||
|
||||
String buildList = "";
|
||||
for (String cur : BuildList)
|
||||
buildList += cur + ",";
|
||||
@ -132,6 +118,11 @@ public class MapData
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -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.BuildCommand;
|
||||
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 BuildCommand(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,11 +114,12 @@ 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("/create <name> [gametype]", "Creates a new map"));
|
||||
UtilPlayer.message(player, F.value("/delete <name> [gametype]", "Deletes an existing map"));
|
||||
UtilPlayer.message(player, F.value("/map <name> [gametype]", "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, " ");
|
||||
@ -95,7 +128,7 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
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, 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,6 +396,11 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public Location getSpawnLocation()
|
||||
{
|
||||
return _spawnLocation;
|
||||
}
|
||||
|
||||
public void ResetInventory(Player player)
|
||||
{
|
||||
@ -757,13 +412,25 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
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()))
|
||||
|
@ -69,9 +69,6 @@ public class Parse
|
||||
//Take BlockID Arguments
|
||||
for (String arg : _args)
|
||||
{
|
||||
if (arg.equals("/parse"))
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
_dataId.add(Integer.parseInt(arg));
|
||||
@ -507,7 +504,7 @@ public class Parse
|
||||
return out;
|
||||
}
|
||||
|
||||
public String getGameType()
|
||||
public GameType getGameType()
|
||||
{
|
||||
return _mapData.GameType;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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()).CanBuild(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;
|
||||
}
|
||||
}
|
@ -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));
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
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/16/2014.
|
||||
*/
|
||||
public class BuildCommand extends BaseCommand
|
||||
{
|
||||
public BuildCommand(MapParser plugin)
|
||||
{
|
||||
super(plugin, "build");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(Player player, String alias, String[] args)
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
message(player, "Invalid Input. " + F.elem("/build <Name>"));
|
||||
return true;
|
||||
}
|
||||
|
||||
World world = player.getWorld();
|
||||
|
||||
if (world.getName().equals("world"))
|
||||
{
|
||||
message(player, "Cannot change Build-List for Lobby.");
|
||||
return true;
|
||||
}
|
||||
|
||||
//Permission
|
||||
if (!getPlugin().GetData(world.getName()).CanBuild(player))
|
||||
{
|
||||
message(player, "You do not have Build-Access on this Map.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player other = UtilPlayer.searchOnline(player, args[0], true);
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
MapData data = getPlugin().GetData(world.getName());
|
||||
|
||||
if (data.BuildList.contains(other.getName()))
|
||||
{
|
||||
data.BuildList.remove(other.getName());
|
||||
data.Write();
|
||||
|
||||
getPlugin().Announce("Build-List for " + F.elem(world.getName()) + " (" + other.getName() + " = " + F.tf(false) + ")");
|
||||
}
|
||||
else
|
||||
{
|
||||
data.BuildList.add(other.getName());
|
||||
data.Write();
|
||||
|
||||
getPlugin().Announce("Build-List for " + F.elem(world.getName()) + " (" + other.getName() + " = " + F.tf(true) + ")");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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>"));
|
||||
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.BuildList.add(player.getName());
|
||||
mapData.GameType = gameType;
|
||||
mapData.Write();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -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).CanBuild(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;
|
||||
}
|
||||
}
|
@ -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()).CanBuild(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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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()).CanBuild(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;
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package mineplex.mapparser.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
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;
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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).CanBuild(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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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)
|
||||
{
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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; }
|
||||
|
@ -126,6 +126,9 @@ public class ServerMonitor
|
||||
for (MinecraftServer minecraftServer : _repository.getServerStatuses())
|
||||
{
|
||||
onlineServers.add(minecraftServer.getName());
|
||||
|
||||
if (minecraftServer.getTps() <= 17)
|
||||
System.out.println("[Performance] " + minecraftServer.getName() + ":" + minecraftServer.getPublicAddress() + "] Running poorly at " + minecraftServer.getTps() + " TPS");
|
||||
}
|
||||
|
||||
for (Iterator<Entry<String, Entry<String, Long>>> iterator = serverTracker.entrySet().iterator(); iterator.hasNext();)
|
||||
@ -259,7 +262,6 @@ public class ServerMonitor
|
||||
{
|
||||
List<MinecraftServer> emptyServers = new ArrayList<MinecraftServer>(serverGroup.getEmptyServers());
|
||||
MinecraftServer emptyServer = emptyServers.get(serversToKill - 1);
|
||||
System.out.println("[" + emptyServer.getName() + ":" + emptyServer.getPublicAddress() + "] Killing " + serverGroup.getName() + " Req Total: " + serverGroup.getRequiredTotalServers() + " Req Joinable: " + serverGroup.getRequiredJoinableServers() + " | Actual Total: " + serverGroup.getServerCount() + " Actual Joinable: " + serverGroup.getJoinableCount());
|
||||
killServer(emptyServer);
|
||||
serversToKill--;
|
||||
}
|
||||
|
@ -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>
|
||||
|
@ -61,7 +61,7 @@ public class Arcade extends JavaPlugin
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
{
|
||||
//Delete Old Games Folders
|
||||
DeleteFolders();
|
||||
|
||||
|
@ -565,7 +565,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
}
|
||||
|
||||
// Reserved Slot Check
|
||||
if (Bukkit.getOnlinePlayers().length >= Bukkit.getServer().getMaxPlayers())
|
||||
if (Bukkit.getOnlinePlayers().size() >= Bukkit.getServer().getMaxPlayers())
|
||||
{
|
||||
if (_serverStatusManager.getCurrentServerName().contains("BETA"))
|
||||
{
|
||||
|
@ -226,7 +226,7 @@ public class PowerUpManager implements Listener
|
||||
if (getGame().GetState() != GameState.Live)
|
||||
return;
|
||||
|
||||
Player[] players = Bukkit.getOnlinePlayers();
|
||||
Collection<? extends Player> players = Bukkit.getOnlinePlayers();
|
||||
|
||||
for (Player player : players)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user