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

This commit is contained in:
CoderTim 2014-07-01 21:39:03 -04:00
commit 44a57a485f
34 changed files with 1136 additions and 256 deletions

View File

@ -544,6 +544,11 @@ public class UtilEnt
}
public static boolean CreatureMoveFast(Entity ent, Location target, float speed)
{
return CreatureMoveFast(ent, target, speed, true);
}
public static boolean CreatureMoveFast(Entity ent, Location target, float speed, boolean slow)
{
if (!(ent instanceof Creature))
return false;

View File

@ -85,9 +85,9 @@ public class UtilTime
if (trim == 0)
{
if (type == TimeUnit.DAYS) return (int)UtilMath.trim(trim, (time)/86400000d) + " Days";
if (type == TimeUnit.HOURS) return (int)UtilMath.trim(trim, (time)/3600000d) + " Hours";
if (type == TimeUnit.MINUTES) return (int)UtilMath.trim(trim, (time)/60000d) + " Minutes";
if (type == TimeUnit.DAYS) return UtilMath.trim(trim, (time)/86400000d) + " Days";
if (type == TimeUnit.HOURS) return UtilMath.trim(trim, (time)/3600000d) + " Hours";
if (type == TimeUnit.MINUTES) return UtilMath.trim(trim, (time)/60000d) + " Minutes";
if (type == TimeUnit.SECONDS) return (int)UtilMath.trim(trim, (time)/1000d) + " Seconds";
else return (int)UtilMath.trim(trim, time) + " Milliseconds";
}

View File

@ -1,16 +0,0 @@
package mineplex.core;
import org.bukkit.Server;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
public interface INautilusPlugin
{
JavaPlugin GetPlugin();
String GetWebServerAddress();
Server GetRealServer();
PluginManager GetPluginManager();
}

View File

@ -5,6 +5,8 @@ import java.util.Iterator;
import java.util.Map.Entry;
import java.util.UUID;
import mineplex.core.MiniPlugin;
import mineplex.core.account.command.UpdateRank;
import mineplex.core.account.event.AsyncClientLoadEvent;
import mineplex.core.account.event.ClientUnloadEvent;
import mineplex.core.account.event.ClientWebResponseEvent;
@ -24,7 +26,6 @@ import org.bukkit.craftbukkit.libs.com.google.gson.Gson;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result;
import org.bukkit.event.player.PlayerKickEvent;
@ -32,10 +33,8 @@ import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class CoreClientManager implements Listener
public class CoreClientManager extends MiniPlugin
{
private static CoreClientManager _instance;
private JavaPlugin _plugin;
private AccountRepository _repository;
private NautHashMap<String, CoreClient> _clientList;
@ -43,26 +42,25 @@ public class CoreClientManager implements Listener
private Object _clientLock = new Object();
protected CoreClientManager(JavaPlugin plugin, String webServer)
public CoreClientManager(JavaPlugin plugin, String webServer)
{
_instance = this;
super("Client Manager", plugin);
_plugin = plugin;
_repository = new AccountRepository(webServer);
_clientList = new NautHashMap<String, CoreClient>();
_duplicateLoginGlitchPreventionList = new HashSet<String>();
_plugin.getServer().getPluginManager().registerEvents(this, _plugin);
}
public static CoreClientManager Initialize(JavaPlugin plugin, String webServer)
public AccountRepository getRepository()
{
if (_instance == null)
{
_instance = new CoreClientManager(plugin, webServer);
}
return _instance;
return _repository;
}
@Override
public void AddCommands()
{
AddCommand(new UpdateRank(this));
}
public CoreClient Add(String name)
@ -155,7 +153,7 @@ public class CoreClientManager implements Listener
client.SetAccountId(token.AccountId);
client.SetRank(Rank.valueOf(token.Rank));
// JSON sql response
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response));
@ -198,14 +196,14 @@ public class CoreClientManager implements Listener
// Reserved Slot Check
if (Bukkit.getOnlinePlayers().length >= Bukkit.getServer().getMaxPlayers())
{
if (client.GetRank().Has(event.getPlayer(), Rank.ULTRA, false))
if (client.GetRank().Has(event.getPlayer(), Rank.HELPER, false))
{
event.allow();
event.setResult(PlayerLoginEvent.Result.ALLOWED);
return;
}
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server Full > Purchase Ultra at www.mineplex.com/shop");
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "This server is full and no longer accepts players.");
}
}

View File

@ -0,0 +1,104 @@
package mineplex.core.account.command;
import java.util.Iterator;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
public class UpdateRank extends CommandBase<CoreClientManager>
{
public UpdateRank(CoreClientManager plugin)
{
super(plugin, Rank.ADMIN, "updateRank");
}
@Override
public void Execute(final Player caller, String[] args)
{
if (args == null)
{
UtilPlayer.message(caller, F.main(Plugin.GetName(), "/" + AliasUsed + " joeschmo MODERATOR"));
}
else
{
if (args.length == 0)
{
UtilPlayer.message(caller, F.main(Plugin.GetName(), "Player argument missing."));
return;
}
final String playerName = args[0];
Rank tempRank = null;
try
{
tempRank = Rank.valueOf(args[1]);
}
catch (Exception ex)
{
UtilPlayer.message(caller, F.main(Plugin.GetName(), ChatColor.RED + "" + ChatColor.BOLD + "Invalid rank!"));
return;
}
final Rank rank = tempRank;
if (rank == Rank.MODERATOR || rank == Rank.HELPER || rank == Rank.ALL || rank == Rank.MAPDEV)
{
Plugin.getRepository().MatchPlayerName(new Callback<List<String>>()
{
public void run(List<String> matches)
{
boolean matchedExact = false;
for (String match : matches)
{
if (match.equalsIgnoreCase(playerName))
{
matchedExact = true;
}
}
if (matchedExact)
{
for (Iterator<String> matchIterator = matches.iterator(); matchIterator.hasNext();)
{
if (!matchIterator.next().equalsIgnoreCase(playerName))
{
matchIterator.remove();
}
}
}
UtilPlayer.searchOffline(matches, new Callback<String>()
{
public void run(final String target)
{
if (target == null)
{
return;
}
Plugin.getRepository().SaveRank(new Callback<Rank>()
{
public void run(Rank rank)
{
caller.sendMessage(F.main(Plugin.GetName(), target + "'s rank has been updated to " + rank.Name + "!"));
}
}, target, rank, true);
}
}, caller, playerName, true);
}
}, playerName);
}
}
}
}

View File

@ -1,7 +1,10 @@
package mineplex.core.account.repository;
import java.util.List;
import java.util.UUID;
import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
import mineplex.core.account.repository.token.LoginToken;
import mineplex.core.account.repository.token.RankUpdateToken;
import mineplex.core.common.Rank;
@ -37,4 +40,18 @@ public class AccountRepository
new AsyncJsonWebCall(_webAddress + "PlayerAccount/RankUpdate").Execute(Rank.class, callback, token);
}
public void MatchPlayerName(final Callback<List<String>> callback, final String userName)
{
Thread asyncThread = new Thread(new Runnable()
{
public void run()
{
List<String> tokenList = new JsonWebCall(_webAddress + "PlayerAccount/GetMatches").Execute(new TypeToken<List<String>>(){}.getType(), userName);
callback.run(tokenList);
}
});
asyncThread.start();
}
}

View File

@ -8,4 +8,5 @@ public class ClientToken
public int EconomyBalance;
public AccountToken AccountToken;
public long LastLogin;
}

View File

@ -18,10 +18,10 @@ public class CommandCenter implements Listener
protected CoreClientManager ClientManager;
protected NautHashMap<String, ICommand> Commands;
public static void Initialize(JavaPlugin plugin, CoreClientManager clientManager)
public static void Initialize(JavaPlugin plugin)
{
if (Instance == null)
Instance = new CommandCenter(plugin, clientManager);
Instance = new CommandCenter(plugin);
}
public CoreClientManager GetClientManager()
@ -29,14 +29,18 @@ public class CommandCenter implements Listener
return ClientManager;
}
private CommandCenter(JavaPlugin instance, CoreClientManager manager)
private CommandCenter(JavaPlugin instance)
{
Plugin = instance;
ClientManager = manager;
Commands = new NautHashMap<String, ICommand>();
Plugin.getServer().getPluginManager().registerEvents(this, Plugin);
}
public void setClientManager(CoreClientManager clientManager)
{
ClientManager = clientManager;
}
@EventHandler
public void OnPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{

View File

@ -0,0 +1,33 @@
package mineplex.core.playerTracker;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.event.ClientUnloadEvent;
public class PlayerTracker extends MiniPlugin
{
private PlayerTrackerRepository _repository = null;
public PlayerTracker(JavaPlugin plugin, String serverName, boolean us)
{
super("Player Tracker", plugin);
_repository = new PlayerTrackerRepository();
_repository.initialize(serverName, us);
}
@EventHandler
public void trackPlayer(PlayerJoinEvent event)
{
_repository.updatePlayerServer(event.getPlayer().getName());
}
@EventHandler
public void untrackPlayer(ClientUnloadEvent event)
{
_repository.deleteServerTransfers(event.GetName());
}
}

View File

@ -0,0 +1,206 @@
package mineplex.core.playerTracker;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class PlayerTrackerRepository
{
private static Object _connectionLock = new Object();
private String _connectionString = "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
private String _userName = "root";
private String _password = "tAbechAk3wR7tuTh";
private String _serverName = "";
private boolean _us = true;
private static String CREATE_PLAYERMAP_TABLE = "CREATE TABLE IF NOT EXISTS playerMap (id INT NOT NULL AUTO_INCREMENT, playerName VARCHAR(256), serverName VARCHAR(256), us BOOLEAN NOT NULL DEFAULT 1, PRIMARY KEY (id), UNIQUE INDEX playerIndex (playerName));";
private static String RETRIEVE_PLAYERMAP = "SELECT playerName, serverName FROM playerMap WHERE playerName = ? AND us = ?;";
private static String INSERT_PLAYERMAP = "INSERT INTO playerMap (playerName, serverName, us) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE serverName = VALUES(serverName), us = VALUES(us);";
private static String DELETE_PLAYERMAP = "DELETE FROM playerMap WHERE playerName = ? AND serverName = ? AND us = ?;";
private Connection _connection = null;
public void initialize(String serverName, boolean us)
{
_serverName = serverName;
_us = us;
PreparedStatement preparedStatement = null;
try
{
Class.forName("com.mysql.jdbc.Driver");
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
// Create table
preparedStatement = _connection.prepareStatement(CREATE_PLAYERMAP_TABLE);
preparedStatement.execute();
}
catch (Exception exception)
{
exception.printStackTrace();
}
finally
{
if (preparedStatement != null)
{
try
{
preparedStatement.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}
}
public String retrievePlayerServer(String playerName)
{
ResultSet resultSet = null;
PreparedStatement preparedStatement = null;
String server = "N/A";
try
{
synchronized (_connectionLock)
{
if (_connection.isClosed())
{
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
}
preparedStatement = _connection.prepareStatement(RETRIEVE_PLAYERMAP);
preparedStatement.setString(1, playerName);
preparedStatement.setBoolean(2, _us);
resultSet = preparedStatement.executeQuery();
while (resultSet.next())
{
server = resultSet.getString(1);
}
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
finally
{
if (preparedStatement != null)
{
try
{
preparedStatement.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
if (resultSet != null)
{
try
{
resultSet.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}
return server;
}
public void deleteServerTransfers(String playerName)
{
PreparedStatement preparedStatement = null;
try
{
synchronized (_connectionLock)
{
if (_connection.isClosed())
{
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
}
preparedStatement = _connection.prepareStatement(DELETE_PLAYERMAP);
preparedStatement.setString(1, playerName);
preparedStatement.setString(2, _serverName);
preparedStatement.setBoolean(3, _us);
preparedStatement.executeUpdate();
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
finally
{
if (preparedStatement != null)
{
try
{
preparedStatement.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}
}
public void updatePlayerServer(String playerName)
{
PreparedStatement preparedStatement = null;
try
{
synchronized (_connectionLock)
{
if (_connection.isClosed())
{
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
}
preparedStatement = _connection.prepareStatement(INSERT_PLAYERMAP);
preparedStatement.setString(1, playerName);
preparedStatement.setString(2, _serverName);
preparedStatement.setBoolean(3, _us);
preparedStatement.executeUpdate();
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
finally
{
if (preparedStatement != null)
{
try
{
preparedStatement.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}
}
}

View File

@ -39,7 +39,7 @@ public class Portal extends MiniPlugin implements PluginMessageListener
private CoreClientManager _clientier;
private String serverName = "";
public Portal(JavaPlugin plugin)
public Portal(JavaPlugin plugin, CoreClientManager clientManager)
{
super("Portal", plugin);
@ -47,7 +47,7 @@ public class Portal extends MiniPlugin implements PluginMessageListener
Bukkit.getMessenger().registerIncomingPluginChannel(GetPlugin(), "BungeeCord", this);
_repository.initialize(plugin.getConfig().getBoolean("serverstatus.us"));
_clientier = CoreClientManager.Initialize(plugin, plugin.getConfig().getString("webServer"));
_clientier = clientManager;
}
public void SendAllPlayers(String serverName)
@ -196,6 +196,7 @@ public class Portal extends MiniPlugin implements PluginMessageListener
@EventHandler
public void onPreCommand(PlayerCommandPreprocessEvent e)
{
/*
String[] baseArgs = e.getMessage().split(" ");
String command = baseArgs[0];
String[] args = new String[baseArgs.length - 1];
@ -289,6 +290,7 @@ public class Portal extends MiniPlugin implements PluginMessageListener
return;
}
}
*/
}
@Override

View File

@ -58,49 +58,6 @@ public class Punish extends MiniPlugin
@EventHandler
public void OnClientWebResponse(ClientWebResponseEvent event)
{
/*
JsonReader reader = null;
try
{
while (reader.hasNext())
{
if (reader.nextName().equalsIgnoreCase("Punish"))
{
reader.beginObject();
// TODO Parse infractions/punishments here
// PunishClient client = new PunishClient();
// client.AddInfraction(token.Category, new Infraction(token.Reason, token.Admin, token.Time));
// client.AddPunishment(token.Category, new Punishment(token.PunishmentSentence, token.Reason, token.Admin, token.Hours, token.Time));
// _punishClients.put(event.GetClient().GetPlayerName(), client);
break;
}
reader.endObject();
}
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
if (reader != null)
{
try
{
reader.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
*/
PunishClientToken token = new Gson().fromJson(event.GetResponse(), PunishClientToken.class);
LoadClient(token);
}
@ -121,7 +78,7 @@ public class Punish extends MiniPlugin
if (client.IsBanned())
{
Punishment punishment = client.GetPunishment(PunishmentSentence.Ban);
String time = F.time(UtilTime.convertString((long)(punishment.GetHours() * 3600000), 0, TimeUnit.FIT));
String time = F.time(UtilTime.convertString(punishment.GetRemaining(), 0, TimeUnit.FIT));
if (punishment.GetHours() == -1)
time = C.cRed + "Permanent";
@ -234,16 +191,20 @@ public class Punish extends MiniPlugin
}
}
}
}, playerName, category.toString(), sentence, reason, duration, caller == null ? "Mineplex Anti-Cheat" : caller.getName(), severity, System.currentTimeMillis());
}, playerName, category.toString(), sentence, reason, duration, caller == null ? "Mineplex Anti-Cheat" : caller.getName(), severity);
}
public void LoadClient(PunishClientToken token)
{
PunishClient client = new PunishClient();
long timeDifference = System.currentTimeMillis() - token.Time;
System.out.println("TimeDifference : " + timeDifference);
for (PunishmentToken punishment : token.Punishments)
{
client.AddPunishment(Category.valueOf(punishment.Category), new Punishment(punishment.PunishmentId, PunishmentSentence.valueOf(punishment.Sentence), Category.valueOf(punishment.Category), punishment.Reason, punishment.Admin, punishment.Duration, punishment.Severity, punishment.Time, punishment.Active, punishment.Removed, punishment.RemoveAdmin, punishment.RemoveReason));
client.AddPunishment(Category.valueOf(punishment.Category), new Punishment(punishment.PunishmentId, PunishmentSentence.valueOf(punishment.Sentence), Category.valueOf(punishment.Category), punishment.Reason, punishment.Admin, punishment.Duration, punishment.Severity, punishment.Time + timeDifference, punishment.Active, punishment.Removed, punishment.RemoveAdmin, punishment.RemoveReason));
}
_punishClients.put(token.Name.toLowerCase(), client);

View File

@ -20,7 +20,7 @@ public class PunishRepository
_webAddress = webServerAddress;
}
public void Punish(Callback<String> callback, String target, String category, PunishmentSentence punishment, String reason, double duration, String admin, int severity, long time)
public void Punish(Callback<String> callback, String target, String category, PunishmentSentence punishment, String reason, double duration, String admin, int severity)
{
PunishToken token = new PunishToken();
token.Target = target;
@ -29,7 +29,6 @@ public class PunishRepository
token.Reason = reason;
token.Duration = duration;
token.Admin = admin;
token.Time = time;
token.Severity = severity;
new AsyncJsonWebCall(_webAddress + "PlayerAccount/Punish").Execute(String.class, callback, token);

View File

@ -5,5 +5,6 @@ import java.util.List;
public class PunishClientToken
{
public String Name;
public long Time;
public List<PunishmentToken> Punishments;
}

View File

@ -20,6 +20,7 @@ public class ServerStatusManager extends MiniPlugin
private LagMeter _lagMeter;
private String _name;
private boolean _us;
private boolean _alternateSeconds;
private boolean _enabled = true;
@ -42,6 +43,7 @@ public class ServerStatusManager extends MiniPlugin
String address = Bukkit.getServer().getIp().isEmpty() ? "localhost" : Bukkit.getServer().getIp();
_name = plugin.getConfig().getString("serverstatus.name");
_us = plugin.getConfig().getBoolean("serverstatus.us");
try
{
@ -49,7 +51,7 @@ public class ServerStatusManager extends MiniPlugin
plugin.getConfig().getString("serverstatus.connectionurl"),
plugin.getConfig().getString("serverstatus.username"),
plugin.getConfig().getString("serverstatus.password"),
plugin.getConfig().getBoolean("serverstatus.us"),
_us,
_name,
plugin.getConfig().getString("serverstatus.group"),
address,
@ -144,4 +146,9 @@ public class ServerStatusManager extends MiniPlugin
{
return _name;
}
public boolean getUs()
{
return _us;
}
}

View File

@ -19,11 +19,13 @@ public class EnjinTranslator extends JavaPlugin
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
saveConfig();
//Core Modules
CoreClientManager clientManager = CoreClientManager.Initialize(this, GetWebServerAddress());
//Static Modules
CommandCenter.Initialize(this, clientManager);
CommandCenter.Initialize(this);
//Core Modules
CoreClientManager clientManager = new CoreClientManager(this, GetWebServerAddress());
CommandCenter.Instance.setClientManager(clientManager);
DonationManager donationManager = new DonationManager(this, GetWebServerAddress());
//Other Modules
Punish punish = new Punish(this, GetWebServerAddress(), clientManager);

View File

@ -11,6 +11,7 @@
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value=""/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="true"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${BUILD_FILES}\common.xml"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,clean"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>

View File

@ -1,6 +1,5 @@
package mineplex.hub;
import mineplex.core.INautilusPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.antihack.AntiHack;
import mineplex.core.antistack.AntiStack;
@ -20,6 +19,7 @@ import mineplex.core.monitor.LagMeter;
import mineplex.core.movement.Movement;
import mineplex.core.npc.NpcManager;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.playerTracker.PlayerTracker;
import mineplex.core.portal.Portal;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.projectile.ProjectileManager;
@ -48,12 +48,10 @@ import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.minecraft.game.core.damage.DamageManager;
import mineplex.minecraft.game.core.fire.Fire;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
public class Hub extends JavaPlugin implements INautilusPlugin, IRelation
public class Hub extends JavaPlugin implements IRelation
{
private String WEB_CONFIG = "webServer";
@ -61,39 +59,41 @@ public class Hub extends JavaPlugin implements INautilusPlugin, IRelation
public void onEnable()
{
getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/");
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
saveConfig();
String webServerAddress = getConfig().getString(WEB_CONFIG);
Logger.initialize(this);
//Core Modules
CoreClientManager clientManager = CoreClientManager.Initialize(this, GetWebServerAddress());
//Static Modules
CommandCenter.Initialize(this, clientManager);
CommandCenter.Initialize(this);
CoreClientManager clientManager = new CoreClientManager(this, webServerAddress);
CommandCenter.Instance.setClientManager(clientManager);
ItemStackFactory.Initialize(this, false);
Recharge.Initialize(this);
Punish punish = new Punish(this, GetWebServerAddress(), clientManager);
Portal portal = new Portal(this);
Punish punish = new Punish(this, webServerAddress, clientManager);
Portal portal = new Portal(this, clientManager);
AntiHack.Initialize(this, punish, portal);
DonationManager donationManager = new DonationManager(this, GetWebServerAddress());
DonationManager donationManager = new DonationManager(this, webServerAddress);
//Other Modules
PreferencesManager preferenceManager = new PreferencesManager(this, clientManager, donationManager);
preferenceManager.GiveItem = true;
new MessageManager(this, clientManager, preferenceManager);
Creature creature = new Creature(this);
Creature creature = new Creature(this);
NpcManager npcManager = new NpcManager(this, creature);
PetManager petManager = new PetManager(this, clientManager, donationManager, creature, GetWebServerAddress());
PetManager petManager = new PetManager(this, clientManager, donationManager, creature, webServerAddress);
new AntiStack(this);
//Main Modules
PacketHandler packetHandler = new PacketHandler(this);
PartyManager partyManager = new PartyManager(this, clientManager, preferenceManager);
HubManager hubManager = new HubManager(this, new BlockRestore(this), clientManager, donationManager, new ConditionManager(this), new DisguiseManager(this, packetHandler), new TaskManager(this, GetWebServerAddress()), 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);
ServerStatusManager serverStatusManager = new ServerStatusManager(this, new LagMeter(this, clientManager));
PlayerTracker tracker = new PlayerTracker(this, serverStatusManager.getCurrentServerName(), serverStatusManager.getUs());
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this), partyManager);
@ -112,9 +112,9 @@ public class Hub extends JavaPlugin implements INautilusPlugin, IRelation
Teleport teleport = new Teleport(this, clientManager, new Spawn(this));
Energy energy = new Energy(this);
ItemFactory itemFactory = new ItemFactory(this, blockRestore, conditionManager, damage, energy, fire, throwManager, GetWebServerAddress());
SkillFactory skillManager = new SkillFactory(this, damage, this, combatManager, conditionManager, throwManager, blockRestore, fire, new Movement(this), teleport, energy, GetWebServerAddress());
ClassManager classManager = new ClassManager(this, clientManager, donationManager, skillManager, itemFactory, GetWebServerAddress());
ItemFactory itemFactory = new ItemFactory(this, blockRestore, conditionManager, damage, energy, fire, throwManager, webServerAddress);
SkillFactory skillManager = new SkillFactory(this, damage, this, combatManager, conditionManager, throwManager, blockRestore, fire, new Movement(this), teleport, energy, webServerAddress);
ClassManager classManager = new ClassManager(this, clientManager, donationManager, skillManager, itemFactory, webServerAddress);
ClassShopManager shopManager = new ClassShopManager(this, classManager, skillManager, itemFactory);
@ -133,32 +133,6 @@ public class Hub extends JavaPlugin implements INautilusPlugin, IRelation
{
}
@Override
public JavaPlugin GetPlugin()
{
return this;
}
@Override
public String GetWebServerAddress()
{
String webServerAddress = getConfig().getString(WEB_CONFIG);
return webServerAddress;
}
@Override
public Server GetRealServer()
{
return getServer();
}
@Override
public PluginManager GetPluginManager()
{
return GetRealServer().getPluginManager();
}
@Override
public boolean CanHurt(Player a, Player b)

View File

@ -44,7 +44,7 @@ public class GroupStatusData
// Lobby joinable checking
if (existingServer.Motd.isEmpty() || existingServer.Motd.equals(""))
{
if (existingServer.Players / existingServer.MaxPlayers < 10)
if (serverStatusData.MaxPlayers - serverStatusData.Players > 15)
_joinableCount--;
}
else
@ -66,8 +66,10 @@ public class GroupStatusData
// Lobby joinable checking
if (serverStatusData.Motd.isEmpty() || serverStatusData.Motd.equals(""))
{
if (serverStatusData.Players / serverStatusData.MaxPlayers < 10)
if (serverStatusData.MaxPlayers - serverStatusData.Players > 15)
{
_joinableCount++;
}
}
else
{

View File

@ -15,6 +15,7 @@ import java.util.Map.Entry;
public class ServerMonitor
{
private static boolean _us = true;
private static Repository _repository = new Repository();
private static int _count = 0;
private static HashSet<ProcessRunner> _processes = new HashSet<ProcessRunner>();
@ -22,9 +23,9 @@ public class ServerMonitor
public static void main (String args[])
{
boolean us = !new File("eu.dat").exists();
_us = !new File("eu.dat").exists();
_repository.initialize(us);
_repository.initialize(_us);
HashMap<String, Entry<String, Long>> serverTracker = new HashMap<String, Entry<String, Long>>();
while (true)
@ -34,6 +35,7 @@ public class ServerMonitor
for (ServerStatusData statusData : _repository.retrieveOldServerStatuses())
{
/*
if (us)
{
if (!serverTracker.containsKey(statusData.Name))
@ -48,9 +50,12 @@ public class ServerMonitor
}
}
else
killServer(statusData);
*/
killServer(statusData);
}
/*
if (us)
{
// Remove successfully restarted US servers
@ -65,6 +70,7 @@ public class ServerMonitor
}
else
{
*/
List<DynamicServerData> dynamicServers = new ArrayList<DynamicServerData>(_repository.retrieveDynamicServers());
if (_count % 15 == 0)
@ -165,7 +171,7 @@ public class ServerMonitor
serversToKill--;
}
}
}
//}
int processWaits = 0;

View File

@ -8,7 +8,6 @@ import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.InputStreamReader;
import mineplex.core.INautilusPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.antihack.AntiHack;
import mineplex.core.antistack.AntiStack;
@ -39,12 +38,10 @@ import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.damage.DamageManager;
import nautilus.game.arcade.game.GameServerConfig;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
public class Arcade extends JavaPlugin implements INautilusPlugin
public class Arcade extends JavaPlugin
{
private String WEB_CONFIG = "webServer";
@ -64,28 +61,31 @@ public class Arcade extends JavaPlugin implements INautilusPlugin
//Configs
getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/");
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
saveConfig();
saveConfig();
String webServerAddress = getConfig().getString(WEB_CONFIG);
Logger.initialize(this);
_clientManager = CoreClientManager.Initialize(this, GetWebServerAddress());
CommandCenter.Initialize(this, _clientManager);
//Static Modules
CommandCenter.Initialize(this);
CoreClientManager clientManager = new CoreClientManager(this, webServerAddress);
CommandCenter.Instance.setClientManager(clientManager);
ItemStackFactory.Initialize(this, false);
Recharge.Initialize(this);
_donationManager = new DonationManager(this, GetWebServerAddress());
_donationManager = new DonationManager(this, webServerAddress);
PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager);
new MessageManager(this, _clientManager, preferenceManager);
AntiStack antistack = new AntiStack(this);
Portal portal = new Portal(this, clientManager);
Creature creature = new Creature(this);
Spawn spawn = new Spawn(this);
Teleport teleport = new Teleport(this, _clientManager, spawn);
new FileUpdater(this, new Portal(this));
new FileUpdater(this, portal);
ServerStatusManager serverStatusManager = new ServerStatusManager(this, new LagMeter(this, _clientManager));
PacketHandler packetHandler = new PacketHandler(this);
@ -93,12 +93,11 @@ public class Arcade extends JavaPlugin implements INautilusPlugin
_damageManager = new DamageManager(this, new CombatManager(this), new NpcManager(this, creature), disguiseManager);
Portal portal = new Portal(this);
Punish punish = new Punish(this, GetWebServerAddress(), _clientManager);
Punish punish = new Punish(this, webServerAddress, _clientManager);
AntiHack.Initialize(this, punish, portal);
//Arcade Manager
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), antistack, portal, packetHandler, preferenceManager, GetWebServerAddress());
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), antistack, portal, packetHandler, preferenceManager, webServerAddress);
new MemoryFix(this);
@ -250,30 +249,4 @@ public class Arcade extends JavaPlugin implements INautilusPlugin
System.out.println("Deleted Old Game: " + file.getName());
}
}
@Override
public JavaPlugin GetPlugin()
{
return this;
}
@Override
public String GetWebServerAddress()
{
String webServerAddress = getConfig().getString(WEB_CONFIG);
return webServerAddress;
}
@Override
public Server GetRealServer()
{
return getServer();
}
@Override
public PluginManager GetPluginManager()
{
return GetRealServer().getPluginManager();
}
}

View File

@ -42,6 +42,7 @@ import nautilus.game.arcade.game.games.stacker.Stacker;
import nautilus.game.arcade.game.games.survivalgames.SurvivalGames;
import nautilus.game.arcade.game.games.survivalgames.SurvivalGamesTeams;
import nautilus.game.arcade.game.games.paintball.Paintball;
import nautilus.game.arcade.game.games.tug.Tug;
import nautilus.game.arcade.game.games.turfforts.TurfForts;
import nautilus.game.arcade.game.games.uhc.UHC;
import nautilus.game.arcade.game.games.zombiesurvival.ZombieSurvival;
@ -94,6 +95,7 @@ public class GameFactory
else if (gameType == GameType.Stacker) return new Stacker(_manager);
else if (gameType == GameType.SurvivalGames) return new SurvivalGames(_manager);
else if (gameType == GameType.SurvivalGamesTeams) return new SurvivalGamesTeams(_manager);
else if (gameType == GameType.Tug) return new Tug(_manager);
else if (gameType == GameType.TurfWars) return new TurfForts(_manager);
else if (gameType == GameType.UHC) return new UHC(_manager);
else if (gameType == GameType.ZombieSurvival) return new ZombieSurvival(_manager);

View File

@ -43,6 +43,7 @@ public enum GameType
SpleefTeams("Super Spleef Teams"),
Stacker("Super Stacker"),
SquidShooter("Squid Shooter"),
Tug("Tug of Wool"),
TurfWars("Turf Wars"),
UHC("Ultra Hardcore"),
ZombieSurvival("Zombie Survival");

View File

@ -52,13 +52,9 @@ public class TeamDeathmatch extends TeamGame
private Objective _healthObj;
private boolean _beaconEnabled = false;
private CapturePointTDM _beacon = null;
private long _beaconTime = 180000;
//Scores
private int _victoryScore = 120;
private int _redScore = 0;
private int _blueScore = 0;
public TeamDeathmatch(ArcadeManager manager, GameType type, Kit[] kits)
{
@ -216,16 +212,18 @@ public class TeamDeathmatch extends TeamGame
if (event.getType() != UpdateType.TICK)
return;
if (_beaconEnabled)
if (_beacon != null)
return;
if (UtilTime.elapsed(GetStateTime(), _beaconTime))
{
_beaconEnabled = true;
_beacon = _points.get(UtilMath.r(_points.size()));
Announce(C.cWhite + C.Bold + "Capture Point is active!");
_points.get(UtilMath.r(_points.size())).Enable();
_beacon.Enable();
Announce(C.cWhite + C.Bold + _beacon.GetName() + " Capture Point is active!");
for (Player player : UtilServer.getPlayers())
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, 1f);
@ -249,11 +247,20 @@ public class TeamDeathmatch extends TeamGame
for (GameTeam team : this.GetTeamList())
{
//Display Individual Players
if (this.GetPlayers(true).size() < 10)
if (this.GetPlayers(false).size() < 10)
{
Scoreboard.WriteBlank();
for (Player player : team.GetPlayers(true))
{
Scoreboard.Write(team.GetColor() + player.getName());
int kills = 0;
if (_kills.containsKey(player))
kills = _kills.get(player);
if (IsAlive(player))
Scoreboard.Write(kills + " " + team.GetColor() + player.getName());
else
Scoreboard.Write(kills + " " + C.cGray + player.getName());
}
}
@ -262,59 +269,36 @@ public class TeamDeathmatch extends TeamGame
{
Scoreboard.WriteBlank();
Scoreboard.Write(team.GetColor() + team.GetName() + " Alive");
Scoreboard.Write("" + team.GetPlayers(true).size());
Scoreboard.Write(team.GetColor() + team.GetName() + " Team");
Scoreboard.Write("" + team.GetPlayers(true).size() + team.GetColor() + "Alive");
}
}
if (_beaconEnabled)
if (_beacon != null)
{
Scoreboard.WriteBlank();
Scoreboard.Write(C.cYellow + C.Bold + " Beacon");
Scoreboard.Write(C.cRed + _redScore + C.cWhite + " " + C.cAqua + _blueScore);
Scoreboard.Write(C.cYellow + C.Bold + _beacon.GetName());
Scoreboard.Write(_beacon.GetOwnership());
}
else
{
long timeLeft = _beaconTime - (System.currentTimeMillis() - GetStateTime());
Scoreboard.WriteBlank();
Scoreboard.Write(C.cYellow + C.Bold + " Beacon Spawn");
Scoreboard.Write(C.cYellow + C.Bold + "Beacon");
Scoreboard.Write(UtilTime.MakeStr(timeLeft, 0));
}
Scoreboard.Draw();
}
public void AddScore(GameTeam team, int score)
{
if (team == null)
return;
if (team.GetColor() == ChatColor.RED)
{
_redScore = Math.min(_victoryScore, _redScore + score);
}
else
{
_blueScore = Math.min(_victoryScore, _blueScore + score);
}
EndCheckScore();
}
public void EndCheckScore()
{
if (!IsLive())
return;
GameTeam winner = null;
if (_redScore >= _victoryScore)
winner = GetTeam(ChatColor.RED);
else if (_blueScore >= _victoryScore)
winner = GetTeam(ChatColor.AQUA);
GameTeam winner = _beacon.GetWinner();
if (winner == null)
return;

View File

@ -31,9 +31,13 @@ public class CapturePointTDM
private int _indicatorTick = 0;
private boolean _enabled = false;
private GameTeam _captureTeam = null;
private int _captureAmount = 0;
private int _captureMax = 60;
public CapturePointTDM(TeamDeathmatch host, String name, Location loc)
{
@ -56,20 +60,20 @@ public class CapturePointTDM
//Floors
if (Math.abs(x) <= 2 && Math.abs(z) <= 2)
{
Block floor = loc.getBlock().getRelative(x, -2, z);
floor.setType(Material.WOOL);
_floor.add(floor);
}
//Glass
if (Math.abs(x) <= 2 && Math.abs(z) <= 2)
{
Block block = loc.getBlock().getRelative(x, -1, z);
block.setType(Material.GLASS);
}
//Iron
if (Math.abs(x) <= 1 && Math.abs(z) <= 1)
{
@ -104,7 +108,7 @@ public class CapturePointTDM
{
if (player.getGameMode() != GameMode.SURVIVAL)
continue;
if (Math.abs(_loc.getX() - player.getLocation().getX()) > 2.5)
continue;
@ -130,7 +134,7 @@ public class CapturePointTDM
//Capture
if (teamB == null && teamA != null)
Capture(teamA, playersA.size(), playersA);
else if (teamA == null && teamB != null)
Capture(teamB, playersB.size(), playersB);
@ -145,10 +149,27 @@ public class CapturePointTDM
{
if (team == null)
return;
if (_captureTeam == null)
SetTeam(team);
if (_captureTeam.equals(team))
{
_captureAmount = Math.min(_captureMax, (_captureAmount + 1));
}
else
{
_captureAmount = Math.max(0, (_captureAmount - 1));
if (_captureAmount == 0)
{
SetTeam(team);
}
}
//Score Add
Host.AddScore(team, 1);
Host.EndCheckScore();
//Color
Color color = Color.BLUE;
if (team.GetColor() == ChatColor.RED)
@ -157,6 +178,27 @@ public class CapturePointTDM
Indicate(color);
}
public void SetTeam(GameTeam team)
{
_captureTeam = team;
for (Block block : _floor)
{
if (team.GetColor() == ChatColor.RED)
block.setData((byte) 14);
else
block.setData((byte) 11);
}
for (Block block : _indicators)
{
if (team.GetColor() == ChatColor.RED)
block.setData((byte) 14);
else
block.setData((byte) 11);
}
}
public void Firework(Location loc, Color color, boolean major)
{
if (!major)
@ -173,18 +215,42 @@ public class CapturePointTDM
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, 152);
else
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, 22);
//for (Block block : _indicators)
//Firework(_indicators.get(_indicatorTick).getLocation().add(0.5, 0.5, 0.5), color, false);
_indicatorTick = (_indicatorTick + 1)%_indicators.size();
}
public void Enable()
{
Block block = _loc.getBlock().getRelative(0, -2, 0);
block.setType(Material.BEACON);
_enabled = true;
}
public String GetName()
{
return _name;
}
public String GetOwnership()
{
if (_captureTeam != null)
return _captureTeam.GetColor() + "" + _captureAmount + "/" + _captureMax;
return "0/" + _captureMax;
}
public GameTeam GetWinner()
{
if (_captureTeam == null)
return null;
if (_captureAmount >= _captureMax)
return _captureTeam;
return null;
}
}

View File

@ -0,0 +1,341 @@
package nautilus.game.arcade.game.games.tug;
import java.util.ArrayList;
import java.util.Iterator;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Effect;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Pig;
import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityInteractEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.timing.TimingManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.tug.kits.*;
import nautilus.game.arcade.kit.Kit;
public class Tug extends TeamGame
{
private ArrayList<Location> _redMobs;
private ArrayList<Location> _blueMobs;
private ArrayList<Block> _redLives = new ArrayList<Block>();
private ArrayList<Block> _blueLives = new ArrayList<Block>();
private ArrayList<TugCreature> _redCreatures = new ArrayList<TugCreature>();
private ArrayList<TugCreature> _blueCreatures = new ArrayList<TugCreature>();
public Tug(ArcadeManager manager)
{
super(manager, GameType.Tug,
new Kit[]
{
new KitSmasher(manager),
new KitArcher(manager),
},
new String[]
{
"Your animals are hungry",
"Guide them to enemy crops",
"Eat all enemy crops to win!"
});
this.HungerSet = 20;
this.DeathOut = false;
this.DeathSpectateSecs = 20;
}
@Override
public void ParseData()
{
_redMobs = WorldData.GetDataLocs("RED");
for (Location loc : WorldData.GetDataLocs("PINK"))
{
_redLives.add(loc.getBlock());
loc.getBlock().getRelative(BlockFace.DOWN).setTypeIdAndData(60, (byte)0, true);
loc.getBlock().setTypeIdAndData(59, (byte)7, true);
}
_blueMobs = WorldData.GetDataLocs("BLUE");
for (Location loc : WorldData.GetDataLocs("LIGHT_BLUE"))
{
_blueLives.add(loc.getBlock());
loc.getBlock().getRelative(BlockFace.DOWN).setTypeIdAndData(60, (byte)0, true);
loc.getBlock().setTypeIdAndData(141, (byte)7, true);
}
}
@EventHandler
public void CreatureTarget(EntityTargetEvent event)
{
event.setCancelled(true);
}
/*
@EventHandler
public void LivesFix(UpdateEvent event)
{
if (!IsLive())
return;
if (event.getType() != UpdateType.TICK)
return;
for (Block block : _redLives)
{
if (block.getTypeId() != 59)
{
block.getRelative(BlockFace.DOWN).setTypeIdAndData(60, (byte)0, true);
block.setTypeIdAndData(59, (byte)7, true);
}
}
for (Block block : _blueLives)
{
if (block.getTypeId() != 141)
{
block.getRelative(BlockFace.DOWN).setTypeIdAndData(60, (byte)0, true);
block.setTypeIdAndData(141, (byte)7, true);
}
}
}
*/
@EventHandler
public void CreatureUpdate(UpdateEvent event)
{
if (!IsLive())
return;
if (event.getType() == UpdateType.FAST)
{
if (_redCreatures.size() < 30)
{
this.CreatureAllowOverride = true;
Location loc = UtilAlg.Random(_redMobs);
Creature ent = loc.getWorld().spawn(loc, Pig.class);
ent.setMaxHealth(10);
ent.setHealth(10);
this.CreatureAllowOverride = false;
_redCreatures.add(new TugCreature(this, ent, _blueLives));
}
if (_blueCreatures.size() < 30)
{
this.CreatureAllowOverride = true;
Location loc = UtilAlg.Random(_blueMobs);
Creature ent = loc.getWorld().spawn(loc, Sheep.class);
ent.setMaxHealth(10);
ent.setHealth(10);
this.CreatureAllowOverride = false;
_blueCreatures.add(new TugCreature(this, ent, _redLives));
}
}
if (event.getType() == UpdateType.TICK)
{
//TimingManager.start("Creature Move");
//Target
for (TugCreature ent : _redCreatures)
{
ent.Move(_blueLives);
}
//Target
for (TugCreature ent : _blueCreatures)
{
ent.Move(_redLives);
}
//TimingManager.stop("Creature Move");
}
else if (event.getType() == UpdateType.FAST)
{
//Target
for (TugCreature ent : _redCreatures)
{
ent.FindTarget(_blueCreatures, GetTeam(ChatColor.AQUA).GetPlayers(true));
}
//Target
for (TugCreature ent : _blueCreatures)
{
ent.FindTarget(_redCreatures, GetTeam(ChatColor.RED).GetPlayers(true));
}
//Eat
Eat(_redCreatures, _blueLives);
Eat(_blueCreatures, _redLives);
}
}
public void Eat(ArrayList<TugCreature> ents, ArrayList<Block> lives)
{
Iterator<TugCreature> entIterator = ents.iterator();
while (entIterator.hasNext())
{
TugCreature ent = entIterator.next();
if (!ent.Entity.isValid())
{
ent.Entity.remove();
entIterator.remove();
continue;
}
Iterator<Block> blockIterator = lives.iterator();
while (blockIterator.hasNext())
{
Block block = blockIterator.next();
if (UtilMath.offset(ent.Entity.getLocation(), block.getLocation().add(0.5, 0, 0.5)) < 1)
{
blockIterator.remove();
entIterator.remove();
//Effect
ent.Entity.getWorld().playSound(ent.Entity.getLocation(), Sound.EAT, 2f, 1f);
ent.Entity.getWorld().playSound(ent.Entity.getLocation(), Sound.EAT, 2f, 1f);
ent.Entity.remove();
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
block.setType(Material.AIR);
//Firework
if (ent instanceof Pig)
UtilFirework.playFirework(block.getLocation().add(0.5, 0.5, 0.5),
FireworkEffect.builder().flicker(false).withColor(Color.AQUA).with(Type.BURST).trail(true).build());
else
UtilFirework.playFirework(block.getLocation().add(0.5, 0.5, 0.5),
FireworkEffect.builder().flicker(false).withColor(Color.RED).with(Type.BURST).trail(true).build());
EndLivesCheck();
break;
}
}
}
}
public void EndLivesCheck()
{
if (_redLives.isEmpty())
{
AnnounceEnd(GetTeam(ChatColor.AQUA));
SetState(GameState.End);
}
else if (_blueLives.isEmpty())
{
AnnounceEnd(GetTeam(ChatColor.RED));
SetState(GameState.End);
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void CropTrample(PlayerInteractEvent event)
{
if (event.getAction() != Action.PHYSICAL)
return;
if (event.getPlayer().getLocation().getBlock().getRelative(BlockFace.DOWN).getType() != Material.SOIL)
return;
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.LOWEST)
public void CropTrample(EntityInteractEvent event)
{
if (event.getBlock() == null)
return;
System.out.println(event.getBlock().getType());
if (event.getBlock().getType() != Material.SOIL)
return;
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.LOWEST)
public void CropTrample(EntityChangeBlockEvent event)
{
event.setCancelled(true);
}
@EventHandler
public void CreatureDeath(EntityDeathEvent event)
{
event.getDrops().clear();
}
@Override
@EventHandler
public void ScoreboardUpdate(UpdateEvent event)
{
if (event != null && event.getType() != UpdateType.FAST)
return;
ScoreboardWrite();
}
public void ScoreboardWrite()
{
Scoreboard.Reset();
Scoreboard.WriteBlank();
Scoreboard.Write(C.cRed + "Pig Team");
Scoreboard.Write(_redLives.size() + " Wheat");
Scoreboard.WriteBlank();
Scoreboard.Write(C.cAqua + "Sheep Team");
Scoreboard.Write(_blueLives.size() + " Carrots");
Scoreboard.Draw();
}
}

View File

@ -0,0 +1,107 @@
package nautilus.game.arcade.game.games.tug;
import java.util.ArrayList;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime;
import nautilus.game.arcade.game.Game;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Creature;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
public class TugCreature
{
public Game Host;
public Creature Entity;
public LivingEntity Target;
public Block Destination;
public long lastAttack = 0;
public TugCreature(Game host, Creature ent, ArrayList<Block> lives)
{
Host = host;
Entity = ent;
Move(lives);
}
public void Move(ArrayList<Block> lives)
{
if (Destination == null || !lives.contains(Destination))
{
Destination = UtilAlg.Random(lives);
}
if (Target != null)
{
if (UtilMath.offset(Entity, Target) < 2 && UtilTime.elapsed(lastAttack, 400))
{
//Damage Event
Host.Manager.GetDamage().NewDamageEvent(Target, Entity, null,
DamageCause.ENTITY_ATTACK, 3, true, false, false,
UtilEnt.getName(Entity), "Headbutt");
lastAttack = System.currentTimeMillis();
}
if (UtilMath.offset(Entity, Target) > 1)
{
UtilEnt.CreatureMoveFast(Entity, Target.getLocation().add(UtilAlg.getTrajectory2d(Target, Entity).multiply(1.5)), 1.5f, false);
}
}
else
{
Location loc = Destination.getLocation().add(0.5, 0, 0.5);
UtilEnt.CreatureMoveFast(Entity, loc.add(UtilAlg.getTrajectory2d(loc, Entity.getLocation()).multiply(0.5)), 1.5f, false);
}
}
public void FindTarget(ArrayList<TugCreature> mobs, ArrayList<Player> enemyPlayers)
{
if (Target == null || !Target.isValid() || UtilMath.offset(Target, Entity) > 6)
{
Target = null;
double bestDist = 0;
for (TugCreature mob : mobs)
{
double dist = UtilMath.offset(mob.Entity, Entity);
if (Target == null || dist < bestDist)
{
Target = mob.Entity;
bestDist = dist;
}
}
/*
for (Player player : enemyPlayers)
{
double dist = UtilMath.offset(player, Entity);
if (Target == null || dist < bestDist)
{
Target = player;
bestDist = dist;
}
}
*/
if (Target == null || !Target.isValid() || UtilMath.offset(Target, Entity) > 4)
{
Target = null;
}
}
}
}

View File

@ -0,0 +1,47 @@
package nautilus.game.arcade.game.games.tug.kits;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.*;
public class KitArcher extends Kit
{
public KitArcher(ArcadeManager manager)
{
super(manager, "Archer", KitAvailability.Free,
new String[]
{
"Passively crafts arrows from surrounding terrain."
},
new Perk[]
{
new PerkFletcher(20, 3, true),
new PerkBarrage(5, 250, true, false),
},
EntityType.ZOMBIE,
new ItemStack(Material.BOW));
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(new ItemStack(Material.STONE_SWORD));
player.getInventory().addItem(new ItemStack(Material.BOW));
player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET));
player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE));
player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS));
player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS));
}
}

View File

@ -0,0 +1,46 @@
package nautilus.game.arcade.game.games.tug.kits;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.*;
public class KitSmasher extends Kit
{
public KitSmasher(ArcadeManager manager)
{
super(manager, "Smasher", KitAvailability.Free,
new String[]
{
"Giant and muscular, easily smacks others around."
},
new Perk[]
{
new PerkMammoth(),
new PerkSeismicSlamHG()
},
EntityType.ZOMBIE,
new ItemStack(Material.IRON_SWORD));
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(new ItemStack(Material.IRON_SWORD));
player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(Material.IRON_HELMET));
player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(Material.IRON_CHESTPLATE));
player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(Material.IRON_LEGGINGS));
player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(Material.IRON_BOOTS));
}
}

View File

@ -366,7 +366,7 @@ public class ZombieSurvival extends SoloGame
Scoreboard.WriteBlank();
Scoreboard.Write(team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName());
}
Scoreboard.Draw();
}

View File

@ -27,17 +27,21 @@ public class GameScoreboard
private ArrayList<ScoreboardElement> _elements = new ArrayList<ScoreboardElement>();
private String _space = " ";
private String _title;
public GameScoreboard(Game game)
{
Game = game;
_title = " MINEPLEX ";
//Scoreboard
_scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
_sideObjective = _scoreboard.registerNewObjective("Obj"+UtilMath.r(999999999), "dummy");
_sideObjective.setDisplaySlot(DisplaySlot.SIDEBAR);
_sideObjective.setDisplayName(C.Bold + " MINEPLEX ");
_sideObjective.setDisplayName(C.Bold + _title);
}
public Scoreboard GetScoreboard()
@ -50,6 +54,11 @@ public class GameScoreboard
return _sideObjective;
}
public void UpdateTitle()
{
}
public String ParseTeamName(String name)
{
return name.substring(0, Math.min(16, name.length()));

View File

@ -20,6 +20,7 @@
Name = account.Name;
Uuid = account.Uuid;
Rank = account.Rank.Name;
Time = (long)TimeUtil.GetCurrentMilliseconds();
EconomyBalance = account.EconomyBalance;
@ -118,6 +119,8 @@
public string Rank { get; set; }
public long Time { get; set; }
public int EconomyBalance { get; set; }
public List<Punishment> Punishments { get; set; }

View File

@ -69,7 +69,7 @@
{
var account = repository.Where<Account>(x => x.Uuid == loginToken.Uuid).FirstOrDefault() ?? CreateAccount(loginToken, repository);
account.LoadNavigationProperties(repository.Context);
var edited = false;
account.LastLogin = (long)TimeUtil.GetCurrentMilliseconds();
// Expire punishments
if (account.Punishments != null)
@ -77,7 +77,6 @@
foreach (var expiredPunishment in account.Punishments.Where(x => x.Active && (x.Duration - 0d) > 0 && TimeUtil.GetCurrentMilliseconds() > (x.Time + (x.Duration * 3600000))))
{
expiredPunishment.Active = false;
edited = true;
}
}
@ -85,7 +84,6 @@
if (String.IsNullOrEmpty(account.Uuid) && !String.IsNullOrEmpty(loginToken.Uuid))
{
account.Uuid = loginToken.Uuid;
edited = true;
}
// Expire ranks
@ -93,13 +91,9 @@
{
account.Rank = repository.Where<Rank>(x => x.Name == "ALL").First();
repository.Attach(account.Rank);
edited = true;
}
if (edited)
{
repository.CommitChanges();
}
repository.CommitChanges();
return account;
}
@ -268,7 +262,7 @@
Admin = punish.Admin,
Category = punish.Category,
Sentence = punish.Sentence,
Time = punish.Time,
Time = (long)TimeUtil.GetCurrentMilliseconds(),
Reason = punish.Reason,
Duration = punish.Duration,
Severity = punish.Severity,
@ -308,7 +302,7 @@
punishment.Active = false;
punishment.Removed = true;
punishment.RemoveAdmin = token.Admin;
punishment.RemoveTime = DateTime.Now.Ticks;
punishment.RemoveTime = (long)TimeUtil.GetCurrentMilliseconds();
punishment.RemoveReason = token.Reason;
repository.Edit(punishment);
@ -517,7 +511,7 @@
repository.CommitChanges();
return rank.ToString();
return rank.Name;
}
}

Binary file not shown.