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

This commit is contained in:
CoderTim 2014-11-07 18:33:46 -05:00
commit 4c98d833e0
131 changed files with 3864 additions and 1334 deletions

3
.gitignore vendored
View File

@ -26,3 +26,6 @@ Servers
Debug
*.gitignore
/Maps/GRASER UHC
/MutualNDA (1)-signed.pdf
/MutualNDA - signed-signed.pdf
/MutualNDA - signed.pdf

View File

@ -4,6 +4,7 @@ import mineplex.bungee.lobbyBalancer.LobbyBalancer;
import mineplex.bungee.motd.MotdManager;
import mineplex.bungee.playerCount.PlayerCount;
import mineplex.bungee.playerStats.PlayerStats;
import mineplex.bungee.playerTracker.PlayerTracker;
import mineplex.bungee.status.InternetStatus;
import net.md_5.bungee.api.plugin.Plugin;
@ -18,5 +19,6 @@ public class Mineplexer extends Plugin
new FileUpdater(this);
new PlayerStats(this);
new InternetStatus(this);
new PlayerTracker(this);
}
}

View File

@ -45,6 +45,6 @@ public class PlayerCount implements Listener, Runnable
{
net.md_5.bungee.api.ServerPing serverPing = event.getResponse();
event.setResponse(new net.md_5.bungee.api.ServerPing(serverPing.getVersion(), new Players(_totalMaxPlayers, _totalPlayers, null), serverPing.getDescription(), serverPing.getFaviconObject()));
event.setResponse(new net.md_5.bungee.api.ServerPing(serverPing.getVersion(), new Players(_totalPlayers + 1, _totalPlayers, null), serverPing.getDescription(), serverPing.getFaviconObject()));
}
}

View File

@ -0,0 +1,49 @@
package mineplex.bungee.playerTracker;
import java.io.File;
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.event.ServerSwitchEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.event.EventHandler;
public class PlayerTracker implements Listener
{
private Plugin _plugin;
private PlayerTrackerRepository _repository = null;
public PlayerTracker(Plugin plugin)
{
_plugin = plugin;
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
_repository = new PlayerTrackerRepository();
_repository.initialize(!new File("eu.dat").exists());
}
@EventHandler
public void playerConnect(final ServerSwitchEvent event)
{
_plugin.getProxy().getScheduler().runAsync(_plugin, new Runnable()
{
public void run()
{
_repository.updatePlayerServer(event.getPlayer().getName(), event.getPlayer().getServer().getInfo().getName());
}
});
}
@EventHandler
public void playerDisconnect(final PlayerDisconnectEvent event)
{
_plugin.getProxy().getScheduler().runAsync(_plugin, new Runnable()
{
public void run()
{
_repository.deleteServerTransfers(event.getPlayer().getName());
}
});
}
}

View File

@ -1,4 +1,4 @@
package mineplex.core.playerTracker;
package mineplex.bungee.playerTracker;
import java.sql.Connection;
import java.sql.DriverManager;
@ -6,29 +6,37 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import mineplex.core.database.DBPool;
public class PlayerTrackerRepository
{
private String _serverName = "";
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 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 static String DELETE_PLAYERMAP = "DELETE FROM playerMap WHERE playerName = ? AND us = ?;";
public void initialize(String serverName, boolean us)
private Connection _connection = null;
public void initialize(boolean us)
{
_serverName = serverName;
_us = us;
PreparedStatement preparedStatement = null;
try (Connection connection = DBPool.ACCOUNT.getConnection())
try
{
Class.forName("com.mysql.jdbc.Driver");
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
// Create table
preparedStatement = connection.prepareStatement(CREATE_PLAYERMAP_TABLE);
preparedStatement = _connection.prepareStatement(CREATE_PLAYERMAP_TABLE);
preparedStatement.execute();
}
catch (Exception exception)
@ -57,17 +65,25 @@ public class PlayerTrackerRepository
PreparedStatement preparedStatement = null;
String server = "N/A";
try (Connection connection = DBPool.ACCOUNT.getConnection())
try
{
preparedStatement = connection.prepareStatement(RETRIEVE_PLAYERMAP);
preparedStatement.setString(1, playerName);
preparedStatement.setBoolean(2, _us);
resultSet = preparedStatement.executeQuery();
while (resultSet.next())
synchronized (_connectionLock)
{
server = resultSet.getString(1);
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)
@ -108,14 +124,21 @@ public class PlayerTrackerRepository
{
PreparedStatement preparedStatement = null;
try (Connection connection = DBPool.ACCOUNT.getConnection())
try
{
preparedStatement = connection.prepareStatement(DELETE_PLAYERMAP);
preparedStatement.setString(1, playerName);
preparedStatement.setString(2, _serverName);
preparedStatement.setBoolean(3, _us);
synchronized (_connectionLock)
{
if (_connection.isClosed())
{
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
}
preparedStatement.executeUpdate();
preparedStatement = _connection.prepareStatement(DELETE_PLAYERMAP);
preparedStatement.setString(1, playerName);
preparedStatement.setBoolean(2, _us);
preparedStatement.executeUpdate();
}
}
catch (Exception exception)
{
@ -137,18 +160,26 @@ public class PlayerTrackerRepository
}
}
public void updatePlayerServer(String playerName)
public void updatePlayerServer(String playerName, String serverName)
{
PreparedStatement preparedStatement = null;
try (Connection connection = DBPool.ACCOUNT.getConnection())
try
{
preparedStatement = connection.prepareStatement(INSERT_PLAYERMAP);
preparedStatement.setString(1, playerName);
preparedStatement.setString(2, _serverName);
preparedStatement.setBoolean(3, _us);
synchronized (_connectionLock)
{
if (_connection.isClosed())
{
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
}
preparedStatement.executeUpdate();
preparedStatement = _connection.prepareStatement(INSERT_PLAYERMAP);
preparedStatement.setString(1, playerName);
preparedStatement.setString(2, serverName);
preparedStatement.setBoolean(3, _us);
preparedStatement.executeUpdate();
}
}
catch (Exception exception)
{

View File

@ -45,11 +45,17 @@ public class BungeeRotator
{
if (usServers.size() < maxRecordCount && server.US)
{
if (usServers.size() >= 2 && server.Players > 900)
continue;
System.out.println("SELECTED " + server.Address + " " + (server.US ? "us" : "eu") + " " + server.Players + "/" + server.MaxPlayers);
usServers.add(server.Address);
}
else if (euServers.size() < maxRecordCount && !server.US)
{
if (euServers.size() >= 2 && server.Players > 900)
continue;
System.out.println("SELECTED " + server.Address + " " + (server.US ? "us" : "eu") + " " + server.Players + "/" + server.MaxPlayers);
euServers.add(server.Address);
}

View File

@ -22,6 +22,11 @@ public class UtilAlg
return sortedSet;
}
public static Location getMidpoint(Location a, Location b)
{
return a.add(b.subtract(a).multiply(0.5));
}
public static Vector getTrajectory(Entity from, Entity to)
{
return getTrajectory(from.getLocation().toVector(), to.getLocation().toVector());
@ -179,4 +184,6 @@ public class UtilAlg
{
return cross(vec, getRight(vec));
}
}

View File

@ -5,6 +5,10 @@ import java.util.HashSet;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.event.RetrieveClientInformationEvent;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.inventory.InventoryManager;
import org.bukkit.Bukkit;
@ -19,7 +23,7 @@ public class RankBenefitsGiver9000 extends MiniPlugin
private InventoryManager _inventoryManager;
private RankBenefitsGiver9000Repository _repository;
private HashSet<String> _playersNeedingBenefit = new HashSet<String>();
private NautHashMap<String, String> _playersNeedingBenefit = new NautHashMap<String, String>();
public RankBenefitsGiver9000(JavaPlugin plugin, CoreClientManager clientManager, InventoryManager inventoryManager)
{
@ -34,48 +38,85 @@ public class RankBenefitsGiver9000 extends MiniPlugin
public void loadPlayer(RetrieveClientInformationEvent event)
{
boolean treasureUpdate = false;
boolean horrorUpdate = false;
for (String benefit : _repository.retrievePlayerBenefits(event.getUniqueId().toString()))
{
if (benefit.equalsIgnoreCase("TreasureUpdate"))
treasureUpdate = true;
if (benefit.equalsIgnoreCase("HalloweenHorror"))
horrorUpdate = true;
}
if (!horrorUpdate)
{
_playersNeedingBenefit.put(event.getPlayerName(), "Horror");
}
if (!treasureUpdate)
{
_playersNeedingBenefit.add(event.getPlayerName());
_playersNeedingBenefit.put(event.getPlayerName(), "Treasure");
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void giveBenefit(final PlayerJoinEvent event)
{
if (!_playersNeedingBenefit.contains(event.getPlayer().getName()))
if (!_playersNeedingBenefit.containsKey(event.getPlayer().getName()))
return;
if (_clientManager.Get(event.getPlayer()).GetRank() == Rank.ALL)
if (_playersNeedingBenefit.get(event.getPlayer().getName()).contains("Horror"))
{
_inventoryManager.addItemToInventory(event.getPlayer(), "Utility", "Treasure Chest", 1);
_inventoryManager.addItemToInventory(event.getPlayer(), "Treasure", "Treasure Key", 1);
}
else if (_clientManager.Get(event.getPlayer()).GetRank() == Rank.ULTRA)
{
_inventoryManager.addItemToInventory(event.getPlayer(), "Utility", "Treasure Chest", 20);
_inventoryManager.addItemToInventory(event.getPlayer(), "Treasure", "Treasure Key", 5);
}
else
{
_inventoryManager.addItemToInventory(event.getPlayer(), "Utility", "Treasure Chest", 40);
_inventoryManager.addItemToInventory(event.getPlayer(), "Treasure", "Treasure Key", 10);
}
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
{
public void run()
_inventoryManager.addItemToInventory(event.getPlayer(), "Treasure", "Treasure Key", 2);
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
{
_repository.addBenefit(event.getPlayer().getUniqueId().toString(), "TreasureUpdate");
public void run()
{
_repository.addBenefit(event.getPlayer().getUniqueId().toString(), "HalloweenHorror");
}
});
Bukkit.getServer().getScheduler().runTaskLater(GetPlugin(), new Runnable()
{
public void run()
{
UtilPlayer.message(event.getPlayer(), C.cPurple + C.Strike + "=============================================");
UtilPlayer.message(event.getPlayer(), "");
UtilPlayer.message(event.getPlayer(), C.cGold + C.Strike + "HAPPY HALLOWEEN");
UtilPlayer.message(event.getPlayer(), "You received 2 Treasure Keys!");
UtilPlayer.message(event.getPlayer(), "");
UtilPlayer.message(event.getPlayer(), C.cPurple + C.Strike + "=============================================");
}
}, 5L);
}
else if (_playersNeedingBenefit.get(event.getPlayer().getName()).contains("Treasure"))
{
if (_clientManager.Get(event.getPlayer()).GetRank() == Rank.ALL)
{
_inventoryManager.addItemToInventory(event.getPlayer(), "Utility", "Treasure Chest", 1);
_inventoryManager.addItemToInventory(event.getPlayer(), "Treasure", "Treasure Key", 1);
}
});
else if (_clientManager.Get(event.getPlayer()).GetRank() == Rank.ULTRA)
{
_inventoryManager.addItemToInventory(event.getPlayer(), "Utility", "Treasure Chest", 20);
_inventoryManager.addItemToInventory(event.getPlayer(), "Treasure", "Treasure Key", 5);
}
else
{
_inventoryManager.addItemToInventory(event.getPlayer(), "Utility", "Treasure Chest", 40);
_inventoryManager.addItemToInventory(event.getPlayer(), "Treasure", "Treasure Key", 10);
}
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
{
public void run()
{
_repository.addBenefit(event.getPlayer().getUniqueId().toString(), "TreasureUpdate");
}
});
}
_playersNeedingBenefit.remove(event.getPlayer().getName());
}

View File

@ -15,20 +15,20 @@ import org.bukkit.plugin.java.JavaPlugin;
public class RankBenefitsGiver9000Repository extends RepositoryBase
{
private static String CREATE_BENEFIT_TABLE = "CREATE TABLE IF NOT EXISTS rankBenefits (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(100), benefit VARCHAR(100), PRIMARY KEY (id), INDEX rankUuid (uuid));";
// private static String CREATE_BENEFIT_TABLE = "CREATE TABLE IF NOT EXISTS rankBenefits (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(100), benefit VARCHAR(100), PRIMARY KEY (id), INDEX rankUuid (uuid));";
private static String INSERT_BENEFIT = "INSERT INTO rankBenefits (uuid, benefit) VALUES (?, ?);";
private static String RETRIEVE_BENEFITS = "SELECT benefit FROM rankBenefits WHERE uuid = ?;";
public RankBenefitsGiver9000Repository(Plugin plugin)
public RankBenefitsGiver9000Repository(JavaPlugin plugin)
{
super(plugin, DBPool.ACCOUNT);
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
}
@Override
protected void initialize()
{
executeUpdate(CREATE_BENEFIT_TABLE);
// executeUpdate(CREATE_BENEFIT_TABLE);
}
@Override

View File

@ -5,7 +5,6 @@ import java.util.List;
import java.util.UUID;
import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.account.repository.token.LoginToken;
@ -13,7 +12,6 @@ import mineplex.core.account.repository.token.RankUpdateToken;
import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.database.DBPool;
import mineplex.core.database.DatabaseRunnable;
import mineplex.core.database.RepositoryBase;
import mineplex.core.database.column.ColumnBoolean;
@ -34,9 +32,9 @@ public class AccountRepository extends RepositoryBase
private String _webAddress;
public AccountRepository(Plugin plugin, String webAddress)
public AccountRepository(JavaPlugin plugin, String webAddress)
{
super(plugin, DBPool.ACCOUNT);
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
_webAddress = webAddress;
}

View File

@ -1,7 +1,15 @@
package mineplex.core.achievement;
import mineplex.core.common.util.C;
public enum Achievement
{
GLOBAL_MINEPLEX_LEVEL("Mineplex Level", 20000,
new String[]{"Global.ExpEarned"},
new String[]{"Level up by doing well in games!"},
getExperienceLevels(),
AchievementCategory.GLOBAL),
GLOBAL_GEM_HUNTER("Gem Hunter", 10000,
new String[]{"Global.GemsEarned"},
new String[]{"+1 for every Gem earned in any game."},
@ -172,7 +180,7 @@ public enum Achievement
DRAW_MY_THING_PURE_LUCK("Pure Luck", 800,
new String[]{"Draw My Thing.PureLuck"},
new String[]{"Guess a word in the first 5 seconds"},
new String[]{"Guess a word in the first 8 seconds"},
new int[]{1},
AchievementCategory.DRAW_MY_THING),
@ -492,14 +500,14 @@ public enum Achievement
SNEAK_ASSASSINS_INCOMPETENCE("Incompetence", 600,
new String[]{"Sneaky Assassins.Incompetence"},
new String[]{"Kill 500 NPCs."},
new int[]{500},
new String[]{"Kill 200 NPCs."},
new int[]{200},
AchievementCategory.SNEAKY_ASSASSINS),
SNEAK_ASSASSINS_I_SEE_YOU("I See You", 800,
new String[]{"Sneaky Assassins.ISeeYou"},
new String[]{"Reveal 250 players."},
new int[]{250},
new String[]{"Reveal 50 players."},
new int[]{50},
AchievementCategory.SNEAKY_ASSASSINS),
//Micro Battle
@ -582,6 +590,62 @@ public enum Achievement
_category = category;
}
private static int[] getExperienceLevels()
{
int[] levels = new int[100];
int expReq = 0;
for (int i=0 ; i<20 ; i++)
{
expReq += 2000;
levels[i] = expReq;
}
for (int i=20 ; i<40 ; i++)
{
expReq += 3000;
levels[i] = expReq;
}
for (int i=40 ; i<60 ; i++)
{
expReq += 4000;
levels[i] = expReq;
}
for (int i=60 ; i<80 ; i++)
{
expReq += 5000;
levels[i] = expReq;
}
for (int i=80 ; i<levels.length ; i++)
{
expReq += 6000;
levels[i] = expReq;
}
return levels;
}
public static String getExperienceString(int level)
{
if (level < 20)
return C.cGray + level;
if (level < 40)
return C.cBlue + level;
if (level < 60)
return C.cDGreen + level;
if (level < 80)
return C.cGold + level;
return C.cRed + level;
}
public String getName()
{
return _name;

View File

@ -12,6 +12,7 @@ import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.command.StatsCommand;
import mineplex.core.achievement.ui.AchievementShop;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilGear;
@ -190,4 +191,19 @@ public class AchievementManager extends MiniPlugin
return true;
}
public String getMineplexLevel(Player sender, Rank rank)
{
int level = get(sender, Achievement.GLOBAL_MINEPLEX_LEVEL).getLevel();
if (rank.Has(Rank.OWNER))
level = Math.max(level, 50 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
else if (rank.Has(Rank.ADMIN))
level = Math.max(level, 30 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
else if (rank.Has(Rank.MODERATOR))
level = Math.max(level, 5);
return Achievement.getExperienceString(level) + " " + ChatColor.RESET;
}
}

View File

@ -29,6 +29,7 @@ import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
@ -45,7 +46,7 @@ public class AntiHack extends MiniPlugin
public static AntiHack Instance;
private boolean _enabled = true;
private boolean _strict = true;
private boolean _strict = false;
private boolean _kick = true;
public Punish Punish;
@ -195,11 +196,28 @@ public class AntiHack extends MiniPlugin
public boolean isValid(Player player, boolean groundValid)
{
//Near Other Player
for (Player other : UtilServer.getPlayers())
{
if (player.equals(other))
continue;
if (other.getGameMode() != GameMode.SURVIVAL)
continue;
if (other.getVehicle() != null)
continue;
if (UtilMath.offset(player, other) < 2)
return true;
}
if (player.isFlying() || player.isInsideVehicle() || player.getGameMode() != GameMode.SURVIVAL)
{
return true;
}
//On Ground
if (groundValid)
{
if (UtilEnt.onBlock(player) || player.getLocation().getBlock().getType() != Material.AIR)

View File

@ -0,0 +1,25 @@
package mineplex.core.data;
import org.bukkit.block.Block;
import org.bukkit.Material;
public class BlockData
{
public Block Block;
public Material Material;
public byte Data;
public long Time;
public BlockData(Block block)
{
Block = block;
Material = block.getType();
Data = block.getData();
Time = System.currentTimeMillis();
}
public void restore()
{
Block.setTypeIdAndData(Material.getId(), Data, true);
}
}

View File

@ -23,7 +23,7 @@ public final class DBPool
source.setUrl(url);
source.setUsername(username);
source.setPassword(password);
source.setMaxTotal(-1);
source.setMaxTotal(10);
source.setMaxIdle(3);
source.setTimeBetweenEvictionRunsMillis(180 * 1000);
source.setSoftMinEvictableIdleTimeMillis(180 * 1000);

View File

@ -1,6 +0,0 @@
package mineplex.core.database;
public class DatabaseManager
{
}

View File

@ -1,73 +1,99 @@
package mineplex.core.database;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.database.column.Column;
import mineplex.core.logger.Logger;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
public abstract class RepositoryBase implements Listener
{
protected static Object _connectionLock = new Object();
private Connection _connection = null;
private static Object _queueLock = new Object();
private NautHashMap<DatabaseRunnable, String> _failedQueue = new NautHashMap<DatabaseRunnable, String>();
private final Plugin _plugin;
private final DataSource _dataSource;
public RepositoryBase(Plugin plugin, DataSource dataSource)
private String _connectionString;
private String _userName;
private String _password;
protected JavaPlugin Plugin;
public RepositoryBase(JavaPlugin plugin, String connectionString, String username, String password)
{
_plugin = plugin;
_dataSource = dataSource;
Plugin = plugin;
_connectionString = connectionString;
_userName = username;
_password = password;
Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable()
{
public void run()
{
initialize();
update();
synchronized (_connectionLock)
{
initialize();
update();
}
}
});
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
protected abstract void initialize();
protected abstract void update();
protected Connection getConnection() throws SQLException
protected Connection getConnection()
{
return getDataSource().getConnection();
try
{
if (_connection == null || !_connection.isValid(1))
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
}
catch (SQLException e)
{
e.printStackTrace();
}
return _connection;
}
protected int executeUpdate(String query, Column<?>... columns)
protected int executeUpdate(String query, Column<?>...columns)
{
PreparedStatement preparedStatement = null;
int affectedRows = 0;
try (Connection connection = getConnection())
try
{
preparedStatement = connection.prepareStatement(query);
for (int i = 0; i < columns.length; i++)
if (_connection == null || !_connection.isValid(1))
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
preparedStatement = _connection.prepareStatement(query);
for (int i=0; i < columns.length; i++)
{
columns[i].setValue(preparedStatement, i + 1);
columns[i].setValue(preparedStatement, i+1);
}
affectedRows = preparedStatement.executeUpdate();
}
catch (Exception exception)
@ -81,30 +107,30 @@ public abstract class RepositoryBase implements Listener
try
{
preparedStatement.close();
}
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}
return affectedRows;
}
protected void executeQuery(PreparedStatement statement, ResultSetCallable callable, Column<?>... columns)
protected void executeQuery(PreparedStatement statement, ResultSetCallable callable, Column<?>...columns)
{
ResultSet resultSet = null;
try
{
for (int i = 0; i < columns.length; i++)
for (int i=0; i < columns.length; i++)
{
columns[i].setValue(statement, i + 1);
columns[i].setValue(statement, i+1);
}
resultSet = statement.executeQuery();
callable.processResultSet(resultSet);
}
catch (Exception exception)
@ -112,13 +138,13 @@ public abstract class RepositoryBase implements Listener
exception.printStackTrace();
}
finally
{
{
if (resultSet != null)
{
try
{
resultSet.close();
}
}
catch (SQLException e)
{
e.printStackTrace();
@ -126,15 +152,18 @@ public abstract class RepositoryBase implements Listener
}
}
}
protected void executeQuery(String query, ResultSetCallable callable, Column<?>... columns)
protected void executeQuery(String query, ResultSetCallable callable, Column<?>...columns)
{
PreparedStatement preparedStatement = null;
try (Connection connection = getConnection())
try
{
preparedStatement = connection.prepareStatement(query);
if (_connection == null || !_connection.isValid(1))
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
preparedStatement = _connection.prepareStatement(query);
executeQuery(preparedStatement, callable, columns);
}
catch (Exception exception)
@ -148,7 +177,7 @@ public abstract class RepositoryBase implements Listener
try
{
preparedStatement.close();
}
}
catch (SQLException e)
{
e.printStackTrace();
@ -156,112 +185,102 @@ public abstract class RepositoryBase implements Listener
}
}
}
protected int executeUpdate(PreparedStatement preparedStatement, Column<?>... columns)
protected int executeUpdate(PreparedStatement preparedStatement, Column<?>...columns)
{
int affectedRows = 0;
try
{
for (int i = 0; i < columns.length; i++)
for (int i=0; i < columns.length; i++)
{
columns[i].setValue(preparedStatement, i + 1);
columns[i].setValue(preparedStatement, i+1);
}
affectedRows = preparedStatement.executeUpdate();
}
catch (Exception exception)
{
exception.printStackTrace();
}
return affectedRows;
}
protected void handleDatabaseCall(final DatabaseRunnable databaseRunnable, final String errorMessage)
{
Thread asyncThread = new Thread(new Runnable()
{
public void run()
{
try
{
databaseRunnable.run();
}
catch (Exception exception)
{
Logger.Instance.log(errorMessage + exception.getMessage());
databaseRunnable.incrementFailCount();
synchronized (_queueLock)
{
_failedQueue.put(databaseRunnable, errorMessage);
}
}
}
});
Thread asyncThread = new Thread(new Runnable()
{
public void run()
{
try
{
databaseRunnable.run();
}
catch (Exception exception)
{
Logger.Instance.log(errorMessage + exception.getMessage());
databaseRunnable.incrementFailCount();
synchronized (_queueLock)
{
_failedQueue.put(databaseRunnable, errorMessage);
}
}
}
});
asyncThread.start();
}
@EventHandler
public void processDatabaseQueue(UpdateEvent event)
{
if (event.getType() != UpdateType.MIN_01)
return;
processFailedQueue();
}
private void processFailedQueue()
{
synchronized (_queueLock)
{
for (Iterator<DatabaseRunnable> runnablesIterator = _failedQueue.keySet().iterator(); runnablesIterator.hasNext(); )
for (Iterator<DatabaseRunnable> runnablesIterator = _failedQueue.keySet().iterator(); runnablesIterator.hasNext();)
{
final DatabaseRunnable databaseRunnable = runnablesIterator.next();
Thread asyncThread = new Thread(new Runnable()
{
public void run()
{
try
{
databaseRunnable.run();
}
catch (Exception exception)
{
Logger.Instance.log(_failedQueue.get(databaseRunnable) + exception.getMessage());
if (databaseRunnable.getFailedCounts() < 4)
{
synchronized (_queueLock)
{
_failedQueue.put(databaseRunnable, _failedQueue.get(databaseRunnable));
}
}
else
{
Logger.Instance.log("Abandoning database call : " + _failedQueue.get(databaseRunnable));
}
}
}
});
runnablesIterator.remove();
Thread asyncThread = new Thread(new Runnable()
{
public void run()
{
try
{
databaseRunnable.run();
}
catch (Exception exception)
{
Logger.Instance.log(_failedQueue.get(databaseRunnable) + exception.getMessage());
if (databaseRunnable.getFailedCounts() < 4)
{
synchronized (_queueLock)
{
_failedQueue.put(databaseRunnable, _failedQueue.get(databaseRunnable));
}
}
else
{
Logger.Instance.log("Abandoning database call : " + _failedQueue.get(databaseRunnable));
}
}
}
});
runnablesIterator.remove();
asyncThread.start();
}
}
}
public Plugin getPlugin()
{
return _plugin;
}
public DataSource getDataSource()
{
return _dataSource;
}
}

View File

@ -28,6 +28,7 @@ public class DonationManager extends MiniPlugin
private Object _donorLock = new Object();
private NautHashMap<Player, NautHashMap<String, Integer>> _gemQueue = new NautHashMap<Player, NautHashMap<String, Integer>>();
private NautHashMap<Player, NautHashMap<String, Integer>> _coinQueue = new NautHashMap<Player, NautHashMap<String, Integer>>();
public DonationManager(JavaPlugin plugin, String webAddress)
{
@ -247,4 +248,56 @@ public class DonationManager extends MiniPlugin
}
}, caller, name, uuid.toString(), amount);
}
public void RewardCoinsLater(final String caller, final Player player, final int amount)
{
if (!_coinQueue.containsKey(player))
_coinQueue.put(player, new NautHashMap<String, Integer>());
int totalAmount = amount;
if (_coinQueue.get(player).containsKey(caller))
totalAmount += _coinQueue.get(player).get(caller);
_coinQueue.get(player).put(caller, totalAmount);
//Do Temp Change
Donor donor = Get(player.getName());
if (donor != null)
donor.addCoins(amount);
}
@EventHandler
public void UpdateCoinQueue(UpdateEvent event)
{
if (event.getType() != UpdateType.SLOWER)
return;
for (Player player : _coinQueue.keySet())
{
String caller = null;
int total = 0;
for (String curCaller : _coinQueue.get(player).keySet())
{
caller = curCaller;
total += _coinQueue.get(player).get(curCaller);
}
if (caller == null)
continue;
//Actually Add Gems
RewardCoins(null, caller, player.getName(), player.getUniqueId(), total, false);
System.out.println("Queue Added [" + player + "] with Coins [" + total + "] for [" + caller + "]");
//Clean
_coinQueue.get(player).clear();
}
//Clean
_coinQueue.clear();
}
}

View File

@ -2,12 +2,10 @@ package mineplex.core.donation.repository;
import java.util.UUID;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.database.DBPool;
import mineplex.core.database.DatabaseRunnable;
import mineplex.core.database.RepositoryBase;
import mineplex.core.database.column.ColumnInt;
@ -30,9 +28,9 @@ public class DonationRepository extends RepositoryBase
private String _webAddress;
public DonationRepository(Plugin plugin, String webAddress)
public DonationRepository(JavaPlugin plugin, String webAddress)
{
super(plugin, DBPool.ACCOUNT);
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
_webAddress = webAddress;
}

View File

@ -22,11 +22,27 @@ public class EloManager extends MiniPlugin
{
super("Elo Rating", plugin);
_repository = new EloRepository();
setupConfigValues(plugin);
_repository = new EloRepository(plugin.getConfig().getString("elo.connectionurl"));
_ratingSystem = new EloRatingSystem(new KFactor(0, 1200, 25), new KFactor(1201, 1600, 20), new KFactor(1601, 2000, 15), new KFactor(2001, 2500, 10));
_playerElos = new NautHashMap<String, NautHashMap<String, Integer>>();
}
private void setupConfigValues(JavaPlugin plugin)
{
try
{
plugin.getConfig().addDefault("elo.connectionurl", "jdbc:mysql://sqlstats.mineplex.com:3306/Mineplex?autoReconnect=true&failOverReadOnly=false&maxReconnects=10");
plugin.getConfig().set("elo.connectionurl", plugin.getConfig().getString("elo.connectionurl"));
plugin.saveConfig();
}
catch (Exception e)
{
e.printStackTrace();
}
}
@EventHandler
public void retrievePlayersElos(final RetrieveClientInformationEvent event)
{

View File

@ -7,18 +7,24 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.UUID;
import mineplex.core.common.util.C;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.database.DBPool;
public class EloRepository
{
private String _connectionString;
private String _userName = "root";
private String _password = "tAbechAk3wR7tuTh";
private static String CREATE_ELO_TABLE = "CREATE TABLE IF NOT EXISTS eloRating (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), gameType VARCHAR(256), elo INT, PRIMARY KEY (id), UNIQUE INDEX uuid_gameType_index (uuid, gameType));";
private static String INSERT_ELO = "INSERT INTO eloRating (uuid, gameType, elo) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE elo=VALUES(elo);";
private static String RETRIEVE_ELO = "SELECT gameType, elo FROM eloRating WHERE uuid = ?;";
public EloRepository()
private Connection _connection = null;
public EloRepository(String connectionUrl)
{
_connectionString = connectionUrl;
initialize();
}
@ -26,10 +32,12 @@ public class EloRepository
{
PreparedStatement preparedStatement = null;
try (Connection connection = DBPool.STATS_MINEPLEX.getConnection())
try
{
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
// Create table
preparedStatement = connection.prepareStatement(CREATE_ELO_TABLE);
preparedStatement = _connection.prepareStatement(CREATE_ELO_TABLE);
preparedStatement.execute();
}
catch (Exception exception)
@ -58,9 +66,14 @@ public class EloRepository
int affectedRows = 0;
try (Connection connection = DBPool.STATS_MINEPLEX.getConnection())
try
{
preparedStatement = connection.prepareStatement(INSERT_ELO);
if (_connection.isClosed())
{
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
}
preparedStatement = _connection.prepareStatement(INSERT_ELO);
preparedStatement.setString(1, uuid);
preparedStatement.setString(2, gameType);
@ -105,9 +118,14 @@ public class EloRepository
ResultSet resultSet = null;
PreparedStatement preparedStatement = null;
try (Connection connection = DBPool.STATS_MINEPLEX.getConnection())
try
{
preparedStatement = connection.prepareStatement(RETRIEVE_ELO);
if (_connection.isClosed())
{
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
}
preparedStatement = _connection.prepareStatement(RETRIEVE_ELO);
preparedStatement.setString(1, uuid.toString());
resultSet = preparedStatement.executeQuery();

View File

@ -12,7 +12,9 @@ import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.event.RetrieveClientInformationEvent;
import mineplex.core.common.Rank;
import mineplex.core.common.jsonchat.ChildJsonMessage;
import mineplex.core.common.jsonchat.JsonMessage;
import mineplex.core.common.util.C;
@ -33,13 +35,15 @@ public class FriendManager extends MiniClientPlugin<FriendData>
{
private static FriendSorter _friendSorter = new FriendSorter();
private CoreClientManager _clientManager;
private PreferencesManager _preferenceManager;
private FriendRepository _repository;
public FriendManager(JavaPlugin plugin, PreferencesManager preferences)
public FriendManager(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences)
{
super("Friends", plugin);
_clientManager = clientManager;
_preferenceManager = preferences;
_repository = new FriendRepository(plugin);
}
@ -258,6 +262,7 @@ public class FriendManager extends MiniClientPlugin<FriendData>
public void showFriends(Player caller)
{
boolean isStaff = _clientManager.Get(caller).GetRank().Has(Rank.HELPER);
boolean gotAFriend = false;
List<FriendStatus> friendStatuses = Get(caller).Friends;
Collections.sort(friendStatuses, _friendSorter);
@ -286,13 +291,31 @@ public class FriendManager extends MiniClientPlugin<FriendData>
//Online Friend
if (friend.Online)
{
message.add("Teleport").color("green").bold().click("run_command", "/server " + friend.ServerName).hover("show_text", "Teleport to " + friend.Name + "'s server.");
if (friend.ServerName.contains("STAFF") || friend.ServerName.contains("CUST"))
{
if (isStaff && friend.ServerName.contains("STAFF"))
message.add("Teleport").color("green").bold().click("run_command", "/server " + friend.ServerName).hover("show_text", "Teleport to " + friend.Name + "'s server.");
else
message.add("No Teleport").color("yellow").bold();
}
else
message.add("Teleport").color("green").bold().click("run_command", "/server " + friend.ServerName).hover("show_text", "Teleport to " + friend.Name + "'s server.");
message.add(" - ").color("white");
message.add("Delete").color("red").bold().click("run_command", "/unfriend " + friend.Name).hover("show_text", "Remove " + friend.Name + " from your friends list.");
message.add(" - ").color("white");
message.add(friend.Name).color(friend.Online ? "green" : "gray");
message.add(" - ").color("white");
message.add(friend.ServerName).color("dark_green");
if (friend.ServerName.contains("STAFF") || friend.ServerName.contains("CUST"))
{
if (isStaff && friend.ServerName.contains("STAFF"))
message.add(friend.ServerName).color("dark_green");
else
message.add("Private Staff Server").color("dark_green");
}
else
message.add(friend.ServerName).color("dark_green");
onlineLines.add(message);
}

View File

@ -5,11 +5,9 @@ import java.sql.SQLException;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.database.DBPool;
import mineplex.core.database.RepositoryBase;
import mineplex.core.database.ResultSetCallable;
import mineplex.core.database.column.ColumnVarChar;
@ -28,9 +26,9 @@ public class FriendRepository extends RepositoryBase
// Not mutual, need to drop accountFriend to recreate with constraint.
// On add record need to check for a reverse uuidsource/uuidtarget and set mutual
public FriendRepository(Plugin plugin)
public FriendRepository(JavaPlugin plugin)
{
super(plugin, DBPool.ACCOUNT);
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
}
@Override

View File

@ -125,6 +125,8 @@ public class GadgetManager extends MiniPlugin
addGadget(new ParticleRain(this));
addGadget(new ParticleHelix(this));
addGadget(new ParticleGreen(this));
addGadget(new ParticleHeart(this));
addGadget(new ParticleFairy(this));
// Music
addGadget(new MusicGadget(this, "13 Disc", new String[] {""}, -2, 2256, 178000));

View File

@ -110,7 +110,7 @@ public class ItemCoinBomb extends ItemGadget
event.setCancelled(true);
event.getItem().remove();
Manager.getDonationManager().RewardCoins(null, this.GetName() + " Pickup", event.getPlayer().getName(), event.getPlayer().getUniqueId(), 4);
Manager.getDonationManager().RewardCoinsLater(GetName() + " Pickup", event.getPlayer(), 4);
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1f, 2f);

View File

@ -189,7 +189,7 @@ public class ItemGemBomb extends ItemGadget
event.setCancelled(true);
event.getItem().remove();
Manager.getDonationManager().RewardGems(null, this.GetName() + " Pickup", event.getPlayer().getName(), event.getPlayer().getUniqueId(), 4);
Manager.getDonationManager().RewardGemsLater(GetName() + " Pickup", event.getPlayer(), 4);
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1f, 2f);
}

View File

@ -16,6 +16,7 @@ import org.bukkit.event.player.*;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import mineplex.core.common.CurrencyType;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
@ -70,7 +71,7 @@ public class MorphVillager extends MorphGadget implements IThrown
}
@EventHandler
public void Audio(PlayerInteractEvent event)
public void skill(PlayerInteractEvent event)
{
Player player = event.getPlayer();
@ -80,6 +81,12 @@ public class MorphVillager extends MorphGadget implements IThrown
if (!UtilEvent.isAction(event, ActionType.L))
return;
if (Manager.getDonationManager().Get(player.getName()).GetBalance(CurrencyType.Gems) < 20)
{
UtilPlayer.message(player, F.main("Gadget", "You do not have enough Gems."));
return;
}
if (!Recharge.Instance.use(player, GetName(), 800, false, false))
return;
@ -143,7 +150,7 @@ public class MorphVillager extends MorphGadget implements IThrown
event.setCancelled(true);
event.getItem().remove();
Manager.getDonationManager().RewardGems(null, this.GetName() + " Pickup", event.getPlayer().getName(), event.getPlayer().getUniqueId(), 16);
Manager.getDonationManager().RewardGemsLater(GetName() + " Pickup", event.getPlayer(), 16);
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1f, 2f);
}

View File

@ -0,0 +1,73 @@
package mineplex.core.gadget.gadgets;
import java.util.HashMap;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerQuitEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.gadget.GadgetManager;
public class ParticleFairy extends ParticleGadget
{
private HashMap<Player, ParticleFairyData> _fairy = new HashMap<Player, ParticleFairyData>();
public ParticleFairy(GadgetManager manager)
{
super(manager, "Flame Fairy", new String[]
{
C.cWhite + "HEY! LISTEN!",
C.cWhite + "HEY! LISTEN!",
C.cWhite + "HEY! LISTEN!",
},
-2,
Material.BLAZE_POWDER, (byte)0);
}
@EventHandler
public void playParticle(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
//Launch
for (Player player : GetActive())
{
if (!shouldDisplay(player))
continue;
//Create
if (!_fairy.containsKey(player))
_fairy.put(player, new ParticleFairyData(player));
_fairy.get(player).Update();
}
}
@Override
public void DisableCustom(Player player)
{
if (_active.remove(player))
UtilPlayer.message(player, F.main("Gadget", "You unsummoned " + F.elem(GetName()) + "."));
clean(player);
}
@EventHandler
public void quit(PlayerQuitEvent event)
{
clean(event.getPlayer());
}
private void clean(Player player)
{
_fairy.remove(player);
}
}

View File

@ -0,0 +1,87 @@
package mineplex.core.gadget.gadgets;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class ParticleFairyData
{
public Player Player;
public Location Fairy;
public Vector Direction;
public Location Target;
public double Speed;
public long IdleTime;
public ParticleFairyData(Player player)
{
Player = player;
Direction = new Vector(1,0,0);
Fairy = player.getEyeLocation();
Target = getNewTarget();
Speed = 0.2;
IdleTime = 0;
}
public void Update()
{
//Update Target
if (UtilMath.offset(Player.getEyeLocation(), Target) > 3 || UtilMath.offset(Fairy, Target) < 1)
Target = getNewTarget();
//Pause?
if (Math.random() > 0.98)
IdleTime = System.currentTimeMillis() + (long)(Math.random() * 3000);
//Speed
if (UtilMath.offset(Player.getEyeLocation(), Fairy) < 3)
{
if (IdleTime > System.currentTimeMillis())
{
Speed = Math.max(0, Speed - 0.005);
}
else
{
Speed = Math.min(0.15, Speed + 0.005);
}
}
else
{
IdleTime = 0;
Speed = Math.min(0.15 + UtilMath.offset(Player.getEyeLocation(), Fairy) * 0.05, Speed + 0.02);
}
//Modify Direction
Direction.add(UtilAlg.getTrajectory(Fairy, Target).multiply(0.15));
if (Direction.length() < 1)
Speed = Speed * Direction.length();
UtilAlg.Normalize(Direction);
//Move
if (UtilMath.offset(Fairy, Target) > 0.1)
Fairy.add(Direction.clone().multiply(Speed));
//Particle
UtilParticle.PlayParticle(ParticleType.FLAME, Fairy, 0, 0, 0, 0, 1);
UtilParticle.PlayParticle(ParticleType.LAVA, Fairy, 0, 0, 0, 0, 1);
//Sound
Fairy.getWorld().playSound(Fairy, Sound.CAT_PURREOW, 0.1f, 3f);
}
private Location getNewTarget()
{
return Player.getEyeLocation().add(Math.random() * 6 - 3, Math.random() * 1.5, Math.random() * 6 - 3);
}
}

View File

@ -2,6 +2,7 @@ package mineplex.core.gadget.gadgets;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import org.bukkit.GameMode;
import org.bukkit.Location;
@ -91,7 +92,7 @@ public class ParticleFoot extends ParticleGadget
UtilParticle.PlayParticle(ParticleType.FOOTSTEP, loc, 0f, 0f, 0f, 0, 1);
UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, loc.add(0, 0.1, 0), 0f, 0f, 0f, 0, 1);
UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, loc.clone().add(0, 0.1, 0), 0f, 0f, 0f, 0, 1);
}
}
@ -100,14 +101,13 @@ public class ParticleFoot extends ParticleGadget
if (_steps.isEmpty())
return;
Iterator<Location> stepIterator = _steps.keySet().iterator();
Iterator<Entry<Location, Long>> stepIterator = _steps.entrySet().iterator();
while (stepIterator.hasNext())
{
Location step = stepIterator.next();
long time = _steps.get(step);
if (UtilTime.elapsed(time, 10000))
Entry<Location, Long> entry = stepIterator.next();
if (UtilTime.elapsed(entry.getValue(), 10000))
stepIterator.remove();
}
}

View File

@ -40,17 +40,31 @@ public class ParticleGreen extends ParticleGadget
if (!shouldDisplay(player))
continue;
if (Manager.isMoving(player))
{
UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, player.getLocation().add(0, 1f, 0), 0f, 0f, 0f, 0, 1);
}
else
{
float x = (float) (Math.sin(player.getTicksLived()/5d) * 1f);
float z = (float) (Math.cos(player.getTicksLived()/5d) * 1f);
UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, player.getLocation().add(x, 1, z), 0f, 0f, 0f, 0, 1);
}
float x = (float) (Math.sin(player.getTicksLived()/7d) * 1f);
float z = (float) (Math.cos(player.getTicksLived()/7d) * 1f);
float y = (float) (Math.cos(player.getTicksLived()/17d) * 1f + 1f);
UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, player.getLocation().add(x, y, z), 0f, 0f, 0f, 0, 1);
// if (Manager.isMoving(player))
// {
// UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, player.getLocation().add(0, 1f, 0), 0f, 0f, 0f, 0, 1);
// }
// else
// {
// float scale = Math.abs((float) (Math.sin(player.getTicksLived()/30d) * 2f)) + 1;
// // float vertical = (float) (Math.cos(player.getTicksLived()/50d) * 1f);
//
// int dir = player.isSneaking() ? 1 : -1;
//
// for (double i=0 ; i<Math.PI * 2 ; i += 0.2)
// {
// double x = Math.sin(i + (dir * player.getTicksLived()/50d)) * (i%(Math.PI/2d));
// double z = Math.cos(i + (dir * player.getTicksLived()/50d)) * (i%(Math.PI/2d));
//
// UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, player.getLocation().add(x, 1, z), 0f, 0f, 0f, 0, 1);
// }
// }
}
}
}

View File

@ -0,0 +1,129 @@
package mineplex.core.gadget.gadgets;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerQuitEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg;
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.UtilParticle.ParticleType;
import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.gadget.GadgetManager;
public class ParticleHeart extends ParticleGadget {
private HashMap<Player, HashMap<Player, Location>> _target = new HashMap<Player, HashMap<Player, Location>>();
public ParticleHeart(GadgetManager manager)
{
super(manager, "I Heart You", new String[]
{
C.cWhite + "With these particles, you can",
C.cWhite + "show off how much you heart",
C.cWhite + "everyone on Mineplex!",
},
-2,
Material.APPLE, (byte)0);
}
@EventHandler
public void playParticle(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTEST)
return;
//Launch
for (Player player : GetActive())
{
if (!shouldDisplay(player))
continue;
if (!_target.containsKey(player))
_target.put(player, new HashMap<Player, Location>());
if (Recharge.Instance.use(player, GetName(), 500, false, false))
{
for (Player other : UtilServer.getPlayers())
{
if (other.equals(player))
continue;
if (other.getGameMode() != GameMode.SURVIVAL)
continue;
if (_target.get(player).containsKey(other))
continue;
if (UtilMath.offset(player, other) > 6)
continue;
_target.get(player).put(other, player.getLocation().add(0, 1, 0));
break;
}
}
if (Manager.isMoving(player))
UtilParticle.PlayParticle(ParticleType.HEART, player.getLocation().add(0, 1, 0), 0f, 0f, 0f, 0, 1);
else
UtilParticle.PlayParticle(ParticleType.HEART, player.getLocation().add(0, 1, 0), 0.5f, 0.5f, 0.5f, 0, 1);
}
//Particle
for (HashMap<Player, Location> heart : _target.values())
{
Iterator<Entry<Player, Location>> heartIterator = heart.entrySet().iterator();
while (heartIterator.hasNext())
{
Entry<Player, Location> entry = heartIterator.next();
entry.getValue().add(UtilAlg.getTrajectory(entry.getValue(), entry.getKey().getEyeLocation()).multiply(0.6));
UtilParticle.PlayParticle(ParticleType.HEART, entry.getValue(), 0, 0, 0, 0, 1);
if (UtilMath.offset(entry.getValue(), entry.getKey().getEyeLocation()) < 0.6)
heartIterator.remove();
}
}
}
@Override
public void DisableCustom(Player player)
{
if (_active.remove(player))
UtilPlayer.message(player, F.main("Gadget", "You unsummoned " + F.elem(GetName()) + "."));
clean(player);
}
@EventHandler
public void quit(PlayerQuitEvent event)
{
clean(event.getPlayer());
}
private void clean(Player player)
{
_target.remove(player);
for (HashMap<Player, Location> map : _target.values())
map.remove(player);
}
}

View File

@ -1,6 +1,7 @@
package mineplex.core.inventory;
import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -75,9 +76,26 @@ public class InventoryManager extends MiniClientPlugin<ClientInventory>
addItemToInventoryForOffline(player.getUniqueId().toString(), category, item, count);
}
public Item getItem(String itemName)
{
Item item = null;
for (Map.Entry<String, Item> entry : _items.entrySet())
{
String name = entry.getKey();
if (name.equalsIgnoreCase(itemName))
item = entry.getValue();
System.out.println(name + " " + entry.getValue().Category);
}
return item;
}
public void addItemToInventoryForOffline(final String uuidString, final String category, final String item, final int count)
{
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
{
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
{
public void run()
{
@ -89,9 +107,9 @@ public class InventoryManager extends MiniClientPlugin<ClientInventory>
System.out.println("InventoryManager Adding Category : " + category);
}
}
updateCategories();
synchronized (_inventoryLock)
{
if (!_items.containsKey(item))
@ -100,12 +118,12 @@ public class InventoryManager extends MiniClientPlugin<ClientInventory>
System.out.println("InventoryManager Adding Item : " + item);
}
}
updateItems();
synchronized (_inventoryLock)
{
_repository.incrementClientInventoryItem(uuidString, _items.get(item).Id, count);
_repository.incrementClientInventoryItem(uuidString, _items.get(item).Id, count);
}
}
});

View File

@ -10,6 +10,7 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.inventory.data.Item;
/**
* Created by Shaun on 10/26/2014.
@ -18,7 +19,7 @@ public class GiveItemCommand extends CommandBase<InventoryManager>
{
public GiveItemCommand(InventoryManager plugin)
{
super(plugin, Rank.ADMIN, "giveitem");
super(plugin, Rank.DEVELOPER, "giveitem");
}
@Override
@ -32,18 +33,24 @@ public class GiveItemCommand extends CommandBase<InventoryManager>
final String playerName = args[0];
final int amount = Integer.parseInt(args[1]);
String tempItemName = "";
String itemName = "";
for (int i = 2; i < args.length; i++)
{
tempItemName += args[i] + " ";
itemName += args[i] + " ";
}
final String itemName = tempItemName.trim();
itemName = itemName.trim();
Item item = Plugin.getItem(itemName);
Player player = UtilPlayer.searchExact(playerName);
if (player != null)
if (item == null)
{
Plugin.addItemToInventory(player, "Item", itemName, amount);
UtilPlayer.message(caller, F.main("Item", "Item with the name " + F.item(itemName) + " not found!"));
}
else if (player != null)
{
Plugin.addItemToInventory(player, item.Category, item.Name, amount);
UtilPlayer.message(caller, F.main("Item", "You gave " + F.elem(amount + " " + itemName) + " to player " + F.name(playerName)));
UtilPlayer.message(player, F.main("Item", F.name(caller.getName()) + " gave you " + F.elem(amount + " " + itemName)));
}
@ -52,7 +59,7 @@ public class GiveItemCommand extends CommandBase<InventoryManager>
UUID uuid = UUIDFetcher.getUUIDOf(playerName);
if (uuid != null)
{
Plugin.addItemToInventoryForOffline(uuid.toString(), "Item", itemName, amount);
Plugin.addItemToInventoryForOffline(uuid.toString(), item.Category, item.Name, amount);
UtilPlayer.message(caller, F.main("Item", "You gave " + F.elem(amount + " " + itemName) + " to offline player " + F.name(playerName)));
}
else
@ -64,6 +71,6 @@ public class GiveItemCommand extends CommandBase<InventoryManager>
private void displayUsage(Player caller)
{
UtilPlayer.message(caller, F.main("Item", "Usage: " + F.elem("/giveitem <playername> <item name> <amount>")));
UtilPlayer.message(caller, F.main("Item", "Usage: " + F.elem("/giveitem <playername> <amount> <item name>")));
}
}

View File

@ -5,10 +5,8 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.database.DBPool;
import mineplex.core.database.RepositoryBase;
import mineplex.core.database.ResultSetCallable;
import mineplex.core.database.column.ColumnInt;
@ -31,9 +29,9 @@ public class InventoryRepository extends RepositoryBase
private static String INSERT_CLIENT_INVENTORY = "INSERT INTO accountInventory (accountId, itemId, count) SELECT accounts.id, ?, ? FROM accounts WHERE accounts.uuid = ? ON DUPLICATE KEY UPDATE count=count + VALUES(count);";
private static String RETRIEVE_CLIENT_INVENTORY = "SELECT items.name, ic.name as category, count FROM accountInventory AS ai INNER JOIN items ON items.id = ai.itemId INNER JOIN itemCategories AS ic ON ic.id = items.categoryId INNER JOIN accounts ON accounts.id = ai.accountId WHERE accounts.uuid = ?;";
public InventoryRepository(Plugin plugin)
public InventoryRepository(JavaPlugin plugin)
{
super(plugin, DBPool.ACCOUNT);
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
}
@Override

View File

@ -21,7 +21,9 @@ public class Logger
public Logger(JavaPlugin plugin)
{
_repository = new LoggerRepository(plugin.getConfig().getString("serverstatus.name"));
setupConfigValues(plugin);
_repository = new LoggerRepository(plugin.getConfig().getString("log.connectionurl"), plugin.getConfig().getString("serverstatus.name"));
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler()
{
@ -34,6 +36,20 @@ public class Logger
});
}
private void setupConfigValues(JavaPlugin plugin)
{
try
{
plugin.getConfig().addDefault("log.connectionurl", "jdbc:mysql://sqlstats.mineplex.com:3306/Mineplex?autoReconnect=true&failOverReadOnly=false&maxReconnects=10");
plugin.getConfig().set("log.connectionurl", plugin.getConfig().getString("log.connectionurl"));
plugin.saveConfig();
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void log(final String message)
{
System.out.println(message);

View File

@ -5,17 +5,23 @@ import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import mineplex.core.database.DBPool;
public class LoggerRepository
{
private static Object _connectionLock = new Object();
private String _connectionString;
private String _userName = "root";
private String _password = "tAbechAk3wR7tuTh";
private static String CREATE_LOG_TABLE = "CREATE TABLE IF NOT EXISTS errorLog (id INT NOT NULL AUTO_INCREMENT, server VARCHAR(256), message VARCHAR(256), date LONG, PRIMARY KEY (id));";
private static String INSERT_LOG = "INSERT INTO errorLog (server, message, date) VALUES (?, ?, now());";
private Connection _connection = null;
private String _serverName;
public LoggerRepository(String serverName)
public LoggerRepository(String connectionUrl, String serverName)
{
_connectionString = connectionUrl;
_serverName = serverName;
initialize();
@ -25,10 +31,12 @@ public class LoggerRepository
{
PreparedStatement preparedStatement = null;
try (Connection connection = DBPool.STATS_MINEPLEX.getConnection())
try
{
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
// Create table
preparedStatement = connection.prepareStatement(CREATE_LOG_TABLE);
preparedStatement = _connection.prepareStatement(CREATE_LOG_TABLE);
preparedStatement.execute();
}
catch (Exception exception)
@ -55,18 +63,26 @@ public class LoggerRepository
{
PreparedStatement preparedStatement = null;
try (Connection connection = DBPool.STATS_MINEPLEX.getConnection())
try
{
preparedStatement = connection.prepareStatement(INSERT_LOG);
for (String msg : message)
synchronized (_connectionLock)
{
preparedStatement.setString(1, _serverName);
preparedStatement.setString(2, msg.substring(0, Math.min(257, msg.length())));
preparedStatement.addBatch();
if (_connection.isClosed())
{
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
}
preparedStatement = _connection.prepareStatement(INSERT_LOG);
for (String msg : message)
{
preparedStatement.setString(1, _serverName);
preparedStatement.setString(2, msg.substring(0, Math.min(257, msg.length())));
preparedStatement.addBatch();
}
preparedStatement.executeBatch();
}
preparedStatement.executeBatch();
}
catch (Exception exception)
{

View File

@ -76,7 +76,7 @@ public class MountDragon extends DragonMount
continue;
}
if (!data.Dragon.isValid() || data.Dragon.getPassenger().getPassenger() == null)
if (!data.Dragon.isValid() || data.Dragon.getPassenger() == null || data.Dragon.getPassenger().getPassenger() == null)
{
data.Dragon.remove();
toRemove.add(player);

View File

@ -1,7 +1,6 @@
package mineplex.core.npc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
@ -39,7 +38,6 @@ import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
@ -104,7 +102,6 @@ public class NpcManager extends MiniPlugin
private final List<Npc> _npcs = new ArrayList<>();
final Map<UUID, Npc> _npcMap = new HashMap<>();
private final Set<UUID> _npcDeletingPlayers = new HashSet<>();
private Connection _connection;
public NpcManager(JavaPlugin plugin, Creature creature)
{
@ -597,8 +594,6 @@ public class NpcManager extends MiniPlugin
if (event.getType() != UpdateType.TICK)
return;
long now = System.currentTimeMillis();
for (Player player : Bukkit.getOnlinePlayers())
{
for (Npc npc : _npcs)

View File

@ -2,7 +2,6 @@ package mineplex.core.npc.command;
import java.sql.SQLException;
import org.bukkit.ChatColor;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;

View File

@ -1,46 +0,0 @@
package mineplex.core.playerTracker;
import org.bukkit.Bukkit;
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(final PlayerJoinEvent event)
{
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
{
public void run()
{
_repository.updatePlayerServer(event.getPlayer().getName());
}
});
}
@EventHandler
public void untrackPlayer(final ClientUnloadEvent event)
{
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
{
public void run()
{
_repository.deleteServerTransfers(event.GetName());
}
});
}
}

View File

@ -36,13 +36,28 @@ public class PreferencesManager extends MiniClientPlugin<UserPreferences>
{
super("Preferences", plugin);
_repository = new PreferencesRepository(plugin);
setupConfigValues();
_repository = new PreferencesRepository(plugin, plugin.getConfig().getString("preferences.connectionurl"));
_shop = new PreferencesShop(this, clientManager, donationManager);
AddCommand(new PreferencesCommand(this));
}
private void setupConfigValues()
{
try
{
GetPlugin().getConfig().addDefault("preferences.connectionurl", "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10");
GetPlugin().getConfig().set("preferences.connectionurl", GetPlugin().getConfig().getString("preferences.connectionurl"));
GetPlugin().saveConfig();
}
catch (Exception e)
{
e.printStackTrace();
}
}
@Override
protected UserPreferences AddPlayer(String player)
{

View File

@ -1,17 +1,14 @@
package mineplex.core.preferences;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map.Entry;
import java.util.UUID;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.database.DBPool;
import mineplex.core.database.RepositoryBase;
import mineplex.core.database.ResultSetCallable;
import mineplex.core.database.column.ColumnVarChar;
@ -23,9 +20,9 @@ public class PreferencesRepository extends RepositoryBase
private static String RETRIEVE_ACCOUNT_PREFERENCES = "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests FROM accountPreferences WHERE uuid = ?;";
private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ? WHERE uuid=?;";
public PreferencesRepository(Plugin plugin)
public PreferencesRepository(JavaPlugin plugin, String connectionString)
{
super(plugin, DBPool.ACCOUNT);
super(plugin, connectionString, "root", "tAbechAk3wR7tuTh");
}
@Override
@ -43,9 +40,9 @@ public class PreferencesRepository extends RepositoryBase
{
PreparedStatement preparedStatement = null;
try (Connection connection = getConnection())
try
{
preparedStatement = connection.prepareStatement(UPDATE_ACCOUNT_PREFERENCES);
preparedStatement = getConnection().prepareStatement(UPDATE_ACCOUNT_PREFERENCES);
for (Entry<String, UserPreferences> entry : preferences.entrySet())
{

View File

@ -18,6 +18,7 @@ import mineplex.core.punish.Tokens.PunishClientToken;
import mineplex.core.punish.Tokens.PunishmentToken;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.libs.com.google.gson.Gson;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -154,7 +155,7 @@ public class Punish extends MiniPlugin
}
else if (banResult == PunishmentResponse.Punished)
{
final String durationString = F.time(UtilTime.convertString(finalDuration < 0 ? -1 : (long)(finalDuration * 3600000), 1, TimeUnit.FIT));
final String durationString = UtilTime.convertString(finalDuration < 0 ? -1 : (long)(finalDuration * 3600000), 1, TimeUnit.FIT);
if (sentence == PunishmentSentence.Ban)
{
@ -170,7 +171,7 @@ public class Punish extends MiniPlugin
}
});
UtilServer.broadcast(F.main(GetName(), F.elem(caller == null ? "Mineplex Anti-Cheat" : caller.getName()) + " banned " + F.elem(playerName) + " because of " + F.elem(reason) + " for " + durationString + "."));
UtilServer.broadcast(F.main(GetName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " banned " + playerName + " for " + durationString + "."));
}
else
{
@ -178,8 +179,19 @@ public class Punish extends MiniPlugin
System.out.println(F.main(GetName(), F.elem(caller == null ? "Mineplex Anti-Cheat" : caller.getName()) + " muted " + F.elem(playerName) + " because of " + F.elem(reason) + " for " +
durationString + "."));
UtilServer.broadcast(F.main(GetName(), F.elem(caller == null ? "Mineplex Anti-Cheat" : caller.getName()) + " muted " + F.elem(playerName) + " because of " + F.elem(reason) + " for " +
durationString + "."));
//Warning
if (finalDuration == 0)
UtilServer.broadcast(F.main(GetName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " issued a warning to " + playerName + "."));
else
UtilServer.broadcast(F.main(GetName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " muted " + playerName + " for " + durationString + "."));
//Inform
Player target = UtilPlayer.searchExact(playerName);
if (target != null)
{
UtilPlayer.message(target, F.main("Punish", F.elem(C.cGray + C.Bold + "Reason: ") + reason));
target.playSound(target.getLocation(), Sound.CAT_MEOW, 1f, 1f);
}
_repository.LoadPunishClient(playerName, new Callback<PunishClientToken>()
{

View File

@ -12,6 +12,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.account.event.ClientUnloadEvent;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer;
@ -91,17 +92,6 @@ public class Recharge extends MiniPlugin
}
}
}
/*
public boolean use(Player player, String ability, long recharge, boolean inform)
{
return use(player, ability, ability, recharge, inform, false);
}
public boolean use(Player player, String ability, String abilityFull, long recharge, boolean inform)
{
return use(player, ability, ability, recharge, inform, false);
}
*/
public boolean use(Player player, String ability, long recharge, boolean inform, boolean attachItem)
{
@ -150,7 +140,12 @@ public class Recharge extends MiniPlugin
public void useForce(Player player, String ability, long recharge)
{
UseRecharge(player, ability, recharge, false, false);
useForce(player, ability, recharge, false);
}
public void useForce(Player player, String ability, long recharge, boolean attachItem)
{
UseRecharge(player, ability, recharge, attachItem, false);
}
public boolean usable(Player player, String ability)
@ -183,10 +178,8 @@ public class Recharge extends MiniPlugin
RechargeEvent rechargeEvent = new RechargeEvent(player, ability, recharge);
UtilServer.getServer().getPluginManager().callEvent(rechargeEvent);
if (attachItem || attachDurability)
Get(player).put(ability, new RechargeData(this, player, ability, player.getItemInHand(), rechargeEvent.GetRecharge(), attachItem, attachDurability));
else
Get(player).put(ability, new RechargeData(System.currentTimeMillis()+rechargeEvent.GetRecharge()));
Get(player).put(ability, new RechargeData(this, player, ability, player.getItemInHand(),
rechargeEvent.GetRecharge(), attachItem, attachDurability));
}
public void recharge(Player player, String ability)
@ -195,13 +188,41 @@ public class Recharge extends MiniPlugin
}
@EventHandler
public void clearPlayer(PlayerQuitEvent event)
public void clearPlayer(ClientUnloadEvent event)
{
_recharge.remove(event.getPlayer().getName());
_recharge.remove(event.GetName());
}
public void setDisplayForce(Player player, String ability, boolean displayForce)
{
if (!_recharge.containsKey(player.getName()))
return;
if (!_recharge.get(player.getName()).containsKey(ability))
return;
_recharge.get(player.getName()).get(ability).DisplayForce = displayForce;
}
public void Reset(Player player)
{
_recharge.put(player.getName(), new NautHashMap<String, RechargeData>());
}
public void debug(Player player, String ability)
{
if (!_recharge.containsKey(player.getName()))
{
player.sendMessage("No Recharge Map.");
return;
}
if (!_recharge.get(player.getName()).containsKey(ability))
{
player.sendMessage("Ability Not Found.");
return;
}
_recharge.get(player.getName()).get(ability).debug(player);
}
}

View File

@ -2,6 +2,7 @@ package mineplex.core.recharge;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
@ -28,14 +29,10 @@ public class RechargeData
public ItemStack Item;
public boolean DisplayForce = false;
public boolean AttachItem;
public boolean AttachDurability;
public RechargeData(long time)
{
Time = time;
}
public RechargeData(Recharge host, Player player, String name, ItemStack stack, long rechargeTime, boolean attachitem, boolean attachDurability)
{
Host = host;
@ -52,16 +49,16 @@ public class RechargeData
public boolean Update()
{
if (Item != null && Name != null && Player != null)
if ((DisplayForce || Item != null) && Name != null && Player != null)
{
//Holding Recharge Item
double percent = (double)(System.currentTimeMillis() - Time)/(double)Recharge;
if (AttachItem)
if (DisplayForce || AttachItem)
{
try
{
if (Player.getItemInHand().getType() == Item.getType())
if (DisplayForce || (Item != null && UtilGear.isMat(Player.getItemInHand(), Item.getType())))
{
if (!UtilTime.elapsed(Time, Recharge))
{
@ -84,27 +81,10 @@ public class RechargeData
}
}
if (AttachDurability)
if (AttachDurability && Item != null)
{
Item.setDurability((short) (Item.getType().getMaxDurability() - (Item.getType().getMaxDurability() * percent)));
}
/*
ItemMeta itemMeta = Item.getItemMeta();
if (System.currentTimeMillis() < Time)
itemMeta.setDisplayName(C.cRed + C.Bold + Name + ChatColor.RESET + " - " + C.cYellow + C.Bold + UtilTime.MakeStr(Time - System.currentTimeMillis()));
else
itemMeta.setDisplayName(C.cGreen + C.Bold + Name);
Item.setItemMeta(itemMeta);
if (System.currentTimeMillis() < Time)
Item.removeEnchantment(Enchantment.DURABILITY);
else
Item.addEnchantment(Enchantment.DURABILITY, 1);
*/
}
@ -115,4 +95,12 @@ public class RechargeData
{
return Recharge - (System.currentTimeMillis() - Time);
}
public void debug(Player player)
{
player.sendMessage("Recharge: " + Recharge);
player.sendMessage("Time: " + Time);
player.sendMessage("Elapsed: " + (System.currentTimeMillis() - Time));
player.sendMessage("Remaining: " + GetRemaining());
}
}

View File

@ -269,6 +269,10 @@ public class RewardManager
new ItemStack(Material.REDSTONE), rarity, 10));
addReward(new UnknownPackageReward(this, donationManager, "Emerald Twirl Particles", "Green Ring",
new ItemStack(Material.EMERALD), rarity, 8));
addReward(new UnknownPackageReward(this, donationManager, "Flame Fairy Particles", "Flame Fairy",
new ItemStack(Material.APPLE), rarity, 4));
addReward(new UnknownPackageReward(this, donationManager, "Heart Particles", "I Heart You",
new ItemStack(Material.BLAZE_POWDER), rarity, 2));
}
public void addReward(Reward reward)

View File

@ -1,13 +1,8 @@
package mineplex.core.reward;
import java.sql.Connection;
import java.sql.SQLException;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.database.DBPool;
import mineplex.core.database.RepositoryBase;
import mineplex.database.Tables;
import org.jooq.DSLContext;
@ -18,9 +13,9 @@ import org.jooq.impl.DSL;
*/
public class RewardRepository extends RepositoryBase
{
public RewardRepository(Plugin plugin)
public RewardRepository(JavaPlugin plugin)
{
super(plugin, DBPool.ACCOUNT);
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
}
@Override
@ -37,26 +32,21 @@ public class RewardRepository extends RepositoryBase
public void logReward(Player player, String type, String rarity, String reward)
{
try
{
try (Connection connection = getConnection())
{
DSLContext context = DSL.using(connection);
DSLContext context;
context.insertInto(Tables.rewardLog)
.set(Tables.rewardLog.accountId, DSL.select(Tables.accounts.id)
.from(Tables.accounts)
.where(Tables.accounts.uuid.eq(player.getUniqueId().toString())))
.set(Tables.rewardLog.date, DSL.currentTimestamp())
.set(Tables.rewardLog.type, type)
.set(Tables.rewardLog.rarity, rarity)
.set(Tables.rewardLog.reward, reward)
.execute();
}
}
catch (SQLException e)
synchronized (this)
{
e.printStackTrace();
context = DSL.using(getConnection());
}
context.insertInto(Tables.rewardLog)
.set(Tables.rewardLog.accountId, DSL.select(Tables.accounts.id)
.from(Tables.accounts)
.where(Tables.accounts.uuid.eq(player.getUniqueId().toString())))
.set(Tables.rewardLog.date, DSL.currentTimestamp())
.set(Tables.rewardLog.type, type)
.set(Tables.rewardLog.rarity, rarity)
.set(Tables.rewardLog.reward, reward)
.execute();
}
}

View File

@ -0,0 +1,58 @@
package mineplex.core.serverConfig;
import java.lang.reflect.Field;
import net.minecraft.server.v1_7_R4.PlayerList;
import org.bukkit.craftbukkit.v1_7_R4.CraftServer;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.serverdata.Region;
import mineplex.serverdata.ServerGroup;
import mineplex.serverdata.ServerManager;
public class ServerConfiguration extends MiniPlugin
{
private Field _playerListMaxPlayers;
private ServerGroup _serverGroup;
public ServerConfiguration(JavaPlugin plugin)
{
super("Server Configuration", plugin);
Region region = plugin.getConfig().getBoolean("serverstatus.us") ? Region.US : Region.EU;
for (ServerGroup serverGroup : ServerManager.getServerRepository(region).getServerGroups(false))
{
if (serverGroup.getName().equalsIgnoreCase(plugin.getConfig().getString("serverstatus.group")))
{
_serverGroup = serverGroup;
break;
}
}
if (_serverGroup == null)
return;
try
{
_playerListMaxPlayers = PlayerList.class.getDeclaredField("maxPlayers");
_playerListMaxPlayers.setAccessible(true);
_playerListMaxPlayers.setInt(((CraftServer)_plugin.getServer()).getHandle(), _serverGroup.getMaxPlayers());
}
catch (Exception e)
{
e.printStackTrace();
}
_plugin.getServer().setWhitelist(_serverGroup.getWhitelist());
((CraftServer)_plugin.getServer()).getServer().setPvP(_serverGroup.getPvp());
((CraftServer)_plugin.getServer()).getServer().setTexturePack(_serverGroup.getResourcePack());
}
public ServerGroup getServerGroup()
{
return _serverGroup;
}
}

View File

@ -6,25 +6,35 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import mineplex.core.common.util.C;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.database.DBPool;
public class SimpleStatsRepository
{
private static Object _connectionLock = new Object();
private String _connectionString = "jdbc:mysql://sqlstats.mineplex.com:3306/Mineplex?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
private String _userName = "root";
private String _password = "tAbechAk3wR7tuTh"; //try to obfuscate this in the future!
private static String CREATE_STATS_TABLE = "CREATE TABLE IF NOT EXISTS simpleStats (id INT NOT NULL AUTO_INCREMENT, statName VARCHAR(64), statValue VARCHAR(64), PRIMARY KEY (id));";
private static String RETRIEVE_STATS_RECORDS = "SELECT simpleStats.statName, simpleStats.statValue FROM simpleStats;";
private static String STORE_STATS_RECORD = "INSERT INTO simpleStats (statName,statValue) VALUES(?,?);";
private static String RETRIEVE_STAT_RECORD = "SELECT simpleStats.statName, simpleStats.statValue FROM simpleStats WHERE statName = '?';";
private Connection _connection = null;
public void initialize()
{
PreparedStatement preparedStatement = null;
try (Connection connection = DBPool.STATS_MINEPLEX.getConnection())
try
{
Class.forName("com.mysql.jdbc.Driver");
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
// Create table
preparedStatement = connection.prepareStatement(CREATE_STATS_TABLE);
preparedStatement = _connection.prepareStatement(CREATE_STATS_TABLE);
preparedStatement.execute();
}
catch (Exception exception)
@ -53,15 +63,23 @@ public class SimpleStatsRepository
PreparedStatement preparedStatement = null;
NautHashMap<String, String> statRecords = new NautHashMap<String, String>();
try (Connection connection = DBPool.STATS_MINEPLEX.getConnection())
try
{
preparedStatement = connection.prepareStatement(RETRIEVE_STATS_RECORDS);
resultSet = preparedStatement.executeQuery();
while (resultSet.next())
synchronized (_connectionLock)
{
statRecords.put(resultSet.getString(1), resultSet.getString(2));
if (_connection.isClosed())
{
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
}
preparedStatement = _connection.prepareStatement(RETRIEVE_STATS_RECORDS);
resultSet = preparedStatement.executeQuery();
while (resultSet.next())
{
statRecords.put(resultSet.getString(1), resultSet.getString(2));
}
}
}
catch (Exception exception)
@ -102,13 +120,21 @@ public class SimpleStatsRepository
{
PreparedStatement preparedStatement = null;
try (Connection connection = DBPool.STATS_MINEPLEX.getConnection())
try
{
preparedStatement = connection.prepareStatement(STORE_STATS_RECORD);
preparedStatement.setString(1, statName);
preparedStatement.setString(2, statValue);
preparedStatement.executeUpdate();
synchronized (_connectionLock)
{
if (_connection.isClosed())
{
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
}
preparedStatement = _connection.prepareStatement(STORE_STATS_RECORD);
preparedStatement.setString(1, statName);
preparedStatement.setString(2, statValue);
preparedStatement.executeUpdate();
}
}
catch (Exception exception)
{
@ -136,16 +162,24 @@ public class SimpleStatsRepository
PreparedStatement preparedStatement = null;
NautHashMap<String, String> statRecords = new NautHashMap<String, String>();
try (Connection connection = DBPool.STATS_MINEPLEX.getConnection())
try
{
preparedStatement = connection.prepareStatement(RETRIEVE_STAT_RECORD);
preparedStatement.setString(1, statName);
resultSet = preparedStatement.executeQuery();
while (resultSet.next())
synchronized (_connectionLock)
{
statRecords.put(resultSet.getString(1), resultSet.getString(2));
if (_connection.isClosed())
{
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
}
preparedStatement = _connection.prepareStatement(RETRIEVE_STAT_RECORD);
preparedStatement.setString(1, statName);
resultSet = preparedStatement.executeQuery();
while (resultSet.next())
{
statRecords.put(resultSet.getString(1), resultSet.getString(2));
}
}
}
catch (Exception exception)

View File

@ -11,6 +11,7 @@ import mineplex.core.MiniClientPlugin;
import mineplex.core.account.event.RetrieveClientInformationEvent;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilServer;
import mineplex.core.stats.command.GiveStatCommand;
import mineplex.core.stats.command.TimeCommand;
import mineplex.core.stats.event.StatChangeEvent;
@ -182,5 +183,6 @@ public class StatsManager extends MiniClientPlugin<PlayerStats>
public void AddCommands()
{
AddCommand(new TimeCommand(this));
AddCommand(new GiveStatCommand(this));
}
}

View File

@ -1,6 +1,5 @@
package mineplex.core.stats;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -8,11 +7,9 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.database.DBPool;
import mineplex.core.database.RepositoryBase;
import mineplex.core.database.ResultSetCallable;
import mineplex.core.database.column.ColumnVarChar;
@ -39,9 +36,9 @@ public class StatsRepository extends RepositoryBase
private static String RETRIEVE_STATS = "SELECT id, name FROM stats;";
private static String INSERT_STAT = "INSERT INTO stats (name) VALUES (?);";
public StatsRepository(Plugin plugin)
public StatsRepository(JavaPlugin plugin)
{
super(plugin, DBPool.ACCOUNT);
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
}
@Override
@ -88,9 +85,9 @@ public class StatsRepository extends RepositoryBase
{
System.out.println("saving stats.");
try (Connection connection = getConnection())
try
{
DSLContext context = DSL.using(connection);
DSLContext context = DSL.using(getConnection());
List<Update> updates = new ArrayList<>();
List<Insert> inserts = new ArrayList<>();
@ -137,33 +134,36 @@ public class StatsRepository extends RepositoryBase
}
}
public PlayerStats loadOfflinePlayerStats(String playerName) throws SQLException
public PlayerStats loadOfflinePlayerStats(String playerName)
{
try (Connection connection = getConnection())
PlayerStats playerStats = null;
DSLContext context;
synchronized (this)
{
PlayerStats playerStats = null;
DSLContext context = DSL.using(connection);
Result<Record2<String, Integer>> result = context.select(Tables.stats.name, Tables.accountStats.value).from(Tables.accountStats)
.join(Tables.stats)
.on(Tables.stats.id.eq(Tables.accountStats.statId))
.where(Tables.accountStats.accountId.eq(DSL.select(Tables.accounts.id)
.from(Tables.accounts)
.where(Tables.accounts.name.eq(playerName)))
).fetch();
if (result.isNotEmpty())
{
playerStats = new PlayerStats();
for (Record2<String, Integer> record : result)
{
playerStats.addStat(record.value1(), record.value2());
}
}
return playerStats;
context = DSL.using(getConnection());
}
Result<Record2<String, Integer>> result = context.select(Tables.stats.name, Tables.accountStats.value).from(Tables.accountStats)
.join(Tables.stats)
.on(Tables.stats.id.eq(Tables.accountStats.statId))
.where(Tables.accountStats.accountId.eq(DSL.select(Tables.accounts.id)
.from(Tables.accounts)
.where(Tables.accounts.name.eq(playerName)))
).fetch();
if (result.isNotEmpty())
{
playerStats = new PlayerStats();
for (Record2<String, Integer> record : result)
{
playerStats.addStat(record.value1(), record.value2());
}
}
return playerStats;
}
public PlayerStats loadClientInformation(String uuid)

View File

@ -0,0 +1,42 @@
package mineplex.core.stats.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.core.stats.StatsManager;
public class GiveStatCommand extends CommandBase<StatsManager>
{
public GiveStatCommand(StatsManager plugin)
{
super(plugin, Rank.OWNER, "givestat");
}
@Override
public void Execute(final Player caller, final String[] args)
{
if (args.length < 3)
{
UtilPlayer.message(caller, F.main("Stats", "/givestat <Target> <Name> <Amount>"));
return;
}
try
{
Player player = UtilPlayer.searchOnline(caller, args[0], true);
if (player == null)
return;
Plugin.incrementStat(player, args[1], Integer.parseInt(args[2]));
UtilPlayer.message(caller, F.main("Stats", "Applied " + F.elem(Integer.parseInt(args[2]) + " " + args[1]) + " to " + F.elem(player.getName()) + "."));
}
catch (Exception e)
{
UtilPlayer.message(caller, F.main("Stats", "/givestat <Name> <Amount>"));
}
}
}

View File

@ -1,9 +1,7 @@
package mineplex.enjinTranslator;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.database.DBPool;
import mineplex.core.database.RepositoryBase;
import mineplex.core.database.column.ColumnInt;
import mineplex.core.database.column.ColumnVarChar;
@ -12,9 +10,9 @@ public class TempRepository extends RepositoryBase
{
private static String INSERT_CLIENT_INVENTORY = "INSERT INTO accountInventory (accountId, itemId, count) SELECT accounts.id, 5, ? FROM accounts WHERE accounts.name = ? ON DUPLICATE KEY UPDATE count=count + VALUES(count);";
public TempRepository(Plugin plugin)
public TempRepository(JavaPlugin plugin)
{
super(plugin, DBPool.ACCOUNT);
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
}
public void addGemBooster(String name, int amount)

View File

@ -4,7 +4,6 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.CustomTagFix;
import mineplex.core.Replay;
import mineplex.core.account.CoreClientManager;
import mineplex.core.antihack.AntiHack;
import mineplex.core.antistack.AntiStack;
@ -26,12 +25,12 @@ import mineplex.core.movement.Movement;
import mineplex.core.npc.NpcManager;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.pet.PetManager;
import mineplex.core.playerTracker.PlayerTracker;
import mineplex.core.portal.Portal;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.projectile.ProjectileManager;
import mineplex.core.punish.Punish;
import mineplex.core.recharge.Recharge;
import mineplex.core.serverConfig.ServerConfiguration;
import mineplex.core.spawn.Spawn;
import mineplex.core.status.ServerStatusManager;
import mineplex.core.task.TaskManager;
@ -61,7 +60,7 @@ public class Hub extends JavaPlugin implements IRelation
@Override
public void onEnable()
{
{
getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/");
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
saveConfig();
@ -80,6 +79,8 @@ public class Hub extends JavaPlugin implements IRelation
Punish punish = new Punish(this, webServerAddress, clientManager);
DonationManager donationManager = new DonationManager(this, webServerAddress);
new ServerConfiguration(this);
//Other Modules
PreferencesManager preferenceManager = new PreferencesManager(this, clientManager, donationManager);
@ -100,7 +101,6 @@ public class Hub extends JavaPlugin implements IRelation
PacketHandler packetHandler = new PacketHandler(this);
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
HubManager hubManager = new HubManager(this, new BlockRestore(this), clientManager, donationManager, new ConditionManager(this), disguiseManager, 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);
@ -134,7 +134,7 @@ public class Hub extends JavaPlugin implements IRelation
new ClassCombatShop(shopManager, clientManager, donationManager, "Knight", classManager.GetClass("Knight"));
new ClassCombatShop(shopManager, clientManager, donationManager, "Assassin", classManager.GetClass("Assassin"));
new FriendManager(this, preferenceManager);
new FriendManager(this, clientManager, preferenceManager);
//Updates
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);

View File

@ -1,5 +1,6 @@
package mineplex.hub;
import java.util.ArrayList;
import java.util.HashMap;
import org.bukkit.Bukkit;
@ -13,12 +14,10 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.Sheep;
import org.bukkit.entity.Snowball;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.ItemSpawnEvent;
@ -26,8 +25,6 @@ import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
@ -47,6 +44,7 @@ import mineplex.core.RankBenefitsGiver9000;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.event.RetrieveClientInformationEvent;
import mineplex.core.achievement.Achievement;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.Rank;
@ -54,7 +52,6 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
@ -69,7 +66,6 @@ import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetActivateEvent;
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
import mineplex.core.hologram.ArmorStandHologram;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.mount.MountManager;
@ -93,7 +89,6 @@ import mineplex.hub.modules.MapManager;
import mineplex.hub.modules.NewsManager;
import mineplex.hub.modules.ParkourManager;
import mineplex.hub.modules.TextManager;
import mineplex.hub.modules.TournamentInviter;
import mineplex.hub.modules.UHCManager;
import mineplex.hub.modules.VisibilityManager;
import mineplex.hub.modules.WorldManager;
@ -109,7 +104,7 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
public class HubManager extends MiniClientPlugin<HubClient>
{
// Snowman!
public HubType Type = HubType.Halloween;
public HubType Type = HubType.Normal;
private BlockRestore _blockRestore;
private CoreClientManager _clientManager;
@ -127,7 +122,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
private TextManager _textCreator;
private ParkourManager _parkour;
private PreferencesManager _preferences;
private InventoryManager _inventoryManager;
private InventoryManager _inventoryManager;
private NewsManager _news;
private AchievementManager _achievementManager;
private TreasureManager _treasureManager;
@ -144,6 +139,8 @@ public class HubManager extends MiniClientPlugin<HubClient>
private boolean _shuttingDown;
private HashMap<String, Long> _portalTime = new HashMap<String, Long>();
private HashMap<String, ArrayList<String>> _creativeAdmin = new HashMap<String, ArrayList<String>>();
//Admin
private boolean _gadgetsEnabled = true;
@ -321,7 +318,11 @@ public class HubManager extends MiniClientPlugin<HubClient>
+ "\n"
+ "\n"
+ " §c§lH§6§lA§a§lV§9§lE §c§lF§6§lU§a§lN§9§l!\n");
// These are needed or 1.8 clients will not show book correctly
meta.setTitle("Rule Book");
meta.setAuthor("Mineplex");
_ruleBook.setItemMeta(meta);
}
@ -613,6 +614,9 @@ public class HubManager extends MiniClientPlugin<HubClient>
boolean ownsUltra = _donationManager.Get(player.getName()).OwnsUltraPackage();
//Level Prefix
String levelStr = _achievementManager.getMineplexLevel(player, rank);
//Rank Prefix
String rankStr = "";
if (rank != Rank.ALL)
@ -630,7 +634,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
event.getRecipients().clear();
event.setMessage(event.getMessage().substring(1, event.getMessage().length()));
event.setFormat(C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + "%1$s " + C.cPurple + "%2$s");
event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + "%1$s " + C.cPurple + "%2$s");
for (String name : party.GetPlayers())
{
@ -659,7 +663,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
}
event.setMessage(event.getMessage());
event.setFormat(rankStr + C.cYellow + "%1$s " + C.cWhite + "%2$s");
event.setFormat(levelStr + rankStr + C.cYellow + "%1$s " + C.cWhite + "%2$s");
}
}
}
@ -999,4 +1003,39 @@ public class HubManager extends MiniClientPlugin<HubClient>
if (!_gadgetsEnabled)
event.setCancelled(true);
}
public void addGameMode(Player caller, Player target)
{
if (!_creativeAdmin.containsKey(caller.getName()))
_creativeAdmin.put(caller.getName(), new ArrayList<String>());
if (target.getGameMode() == GameMode.CREATIVE)
{
_creativeAdmin.get(caller.getName()).add(target.getName());
}
else
{
_creativeAdmin.get(caller.getName()).remove(target.getName());
}
}
@EventHandler
public void clearGameMode(PlayerQuitEvent event)
{
ArrayList<String> creative = _creativeAdmin.remove(event.getPlayer().getName());
if (creative == null)
return;
for (String name : creative)
{
Player player = UtilPlayer.searchExact(name);
if (player == null)
continue;
player.setGameMode(GameMode.SURVIVAL);
UtilPlayer.message(player, F.main("Game Mode", event.getPlayer().getName() + " left the game. Creative Mode: " + F.tf(false)));
}
}
}

View File

@ -5,6 +5,8 @@ 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.HubManager;
public class GameModeCommand extends CommandBase<HubManager>
@ -17,9 +19,27 @@ public class GameModeCommand extends CommandBase<HubManager>
@Override
public void Execute(Player caller, String[] args)
{
if (caller.getGameMode() == GameMode.SURVIVAL)
caller.setGameMode(GameMode.CREATIVE);
Player target = caller;
if (args != null && args.length >= 1)
{
target = UtilPlayer.searchOnline(caller, args[0], true);
if (target == null)
return;
}
if (target.getGameMode() == GameMode.SURVIVAL)
target.setGameMode(GameMode.CREATIVE);
else
caller.setGameMode(GameMode.SURVIVAL);
target.setGameMode(GameMode.SURVIVAL);
if (!target.equals(caller))
{
Plugin.addGameMode(caller, target);
UtilPlayer.message(target, F.main("Game Mode", caller.getName() + " toggled your Creative Mode: " + F.tf(target.getGameMode() == GameMode.CREATIVE)));
}
UtilPlayer.message(caller, F.main("Game Mode", target.getName() + " Creative Mode: " + F.tf(target.getGameMode() == GameMode.CREATIVE)));
}
}

View File

@ -20,6 +20,7 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
@ -192,8 +193,11 @@ public class ParkourManager extends MiniPlugin
}
else
{
for (PotionEffectType type : PotionEffectType.values())
player.removePotionEffect(type);
for (Iterator<PotionEffect> iterator = player.getActivePotionEffects().iterator(); iterator.hasNext();)
{
player.removePotionEffect(iterator.next().getType());
}
}
}
}

View File

@ -8,7 +8,6 @@ import java.util.UUID;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.database.DBPool;
import mineplex.core.database.RepositoryBase;
import mineplex.core.database.ResultSetCallable;
import mineplex.core.database.column.ColumnInt;
@ -29,7 +28,7 @@ public class PollRepository extends RepositoryBase
public PollRepository(JavaPlugin plugin)
{
super(plugin, DBPool.ACCOUNT);
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
}
@Override

View File

@ -231,7 +231,7 @@ public class MapParser extends JavaPlugin implements Listener
}
}
//@EventHandler
@EventHandler
public void DisableCreatures(EntitySpawnEvent event)
{
if (event.getEntityType() == EntityType.DROPPED_ITEM || event.getEntity() instanceof LivingEntity)

View File

@ -1,6 +1,8 @@
package mineplex.minecraft.game.classcombat.Skill.Knight;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.WeakHashMap;
import org.bukkit.entity.Player;
@ -21,7 +23,7 @@ import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
public class Fortitude extends Skill
{
private WeakHashMap<Player, Double> _preHealth = new WeakHashMap<Player, Double>();
private WeakHashMap<Player, Integer> _health = new WeakHashMap<Player, Integer>();
private WeakHashMap<Player, Double> _health = new WeakHashMap<Player, Double>();
private WeakHashMap<Player, Long> _last = new WeakHashMap<Player, Long>();
public Fortitude(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels)
@ -34,7 +36,7 @@ public class Fortitude extends Skill
"up to #0#1 of the health you lost.",
"",
"You restore health at a rate of",
"1 health per #3.5#-0.5 seconds.",
"1 health per #3#-0.5 seconds.",
"",
"This does not stack, and is reset if",
"you are hit again."
@ -74,7 +76,7 @@ public class Fortitude extends Skill
double diff = _preHealth.remove(damagee) - damagee.getHealth();
_health.put(damagee, Math.min(level,(int)(diff + 0.5)));
_health.put(damagee, Math.min(level, diff));
_last.put(damagee, System.currentTimeMillis());
}
@ -84,33 +86,35 @@ public class Fortitude extends Skill
if (event.getType() != UpdateType.FASTER)
return;
HashSet<Player> remove = new HashSet<Player>();
for (Player cur : _health.keySet())
Iterator<Entry<Player, Double>> healthIterator = _health.entrySet().iterator();
while (healthIterator.hasNext())
{
int level = getLevel(cur);
if (level == 0) continue;
if (UtilTime.elapsed(_last.get(cur), 3500 - (500 * level)))
{
_health.put(cur, _health.get(cur) - 1);
_last.put(cur, System.currentTimeMillis());
if (_health.get(cur) <= 0)
remove.add(cur);
//Heal
UtilPlayer.health(cur, 1);
//Effect
UtilParticle.PlayParticle(ParticleType.HEART, cur.getEyeLocation(), 0, 0.2f, 0, 0, 1);
}
}
for (Player cur : remove)
{
_health.remove(cur);
_last.remove(cur);
Entry<Player, Double> entry = healthIterator.next();
int level = getLevel(entry.getKey());
if (level == 0)
continue;
if (!UtilTime.elapsed(_last.get(entry.getKey()), 3000 - (500 * level)))
continue;
//Work out healing
double toHeal = Math.min(entry.getValue(), 1);
entry.setValue(entry.getValue() - toHeal);
//Heal
UtilPlayer.health(entry.getKey(), toHeal);
//Effect
UtilParticle.PlayParticle(ParticleType.HEART, entry.getKey().getEyeLocation(), 0, 0.2f, 0, 0, 1);
//Finished
if (entry.getValue() <= 0)
healthIterator.remove();
//Last Tick
_last.put(entry.getKey(), System.currentTimeMillis());
}
}

View File

@ -3,6 +3,7 @@ package mineplex.minecraft.game.classcombat.Skill.Mage;
import java.util.HashMap;
import java.util.HashSet;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
@ -10,6 +11,7 @@ import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerDropItemEvent;
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
@ -18,6 +20,7 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
@ -127,7 +130,6 @@ public class ArcticArmor extends Skill
Remove(cur);
continue;
}
//Check Allowed
SkillTriggerEvent trigger = new SkillTriggerEvent(cur, GetName(), GetClassType());
@ -176,6 +178,44 @@ public class ArcticArmor extends Skill
Factory.Condition().Factory().Protection(GetName(), other, cur, 1.9, 1, false, true, true);
}
}
@EventHandler
public void Damage(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
for (Player cur : UtilServer.getPlayers())
{
if (cur.getGameMode() != GameMode.SURVIVAL)
continue;
if (cur.getEyeLocation().getBlock().getType() == Material.ICE)
{
Player damager = null;
double closest = 0;
for (Player player : _active)
{
if (player.equals(cur))
continue;
double dist = UtilMath.offset(player, cur);
if (dist < 5 && (damager == null || dist < closest))
{
damager = player;
closest = dist;
}
}
//Damage Event
Factory.Damage().NewDamageEvent(cur, damager, null,
DamageCause.CUSTOM, 2, false, true, false,
damager == null ? null : damager.getName(), "Arctic Ice");
}
}
}
@EventHandler
public void Slow(UpdateEvent event)

View File

@ -70,7 +70,7 @@ public class Fissure extends SkillActive
@Override
public void Skill(Player player, int level)
{
FissureData data = new FissureData(this, player, level, player.getLocation().getDirection(), player.getLocation().add(0, -0.5, 0));
FissureData data = new FissureData(this, player, level, player.getLocation().getDirection(), player.getLocation().add(0, -0.4, 0));
_active.add(data);
//Inform

View File

@ -48,7 +48,7 @@ public class Agility extends SkillActive
"Speed I for #3#1 seconds. You take",
"#45#5 % less damage and take no knockback.",
"",
"Agility ends if you interact."
"Agility ends if you Left-Click."
});
}

View File

@ -61,7 +61,7 @@ public class WolfsPounce extends SkillChargeSword
public void DoSkillCustom(Player player, float charge)
{
//Action
UtilAction.velocity(player, 0.4 + (1.2*charge), 0.2, 0.2 + (0.6*charge), true);
UtilAction.velocity(player, 0.4 + (1.4*charge), 0.2, 0.2 + (0.7*charge), true);
_live.put(player, System.currentTimeMillis());
//Inform

View File

@ -435,7 +435,7 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory
AddSkill(new Agility(this, "Agility", ClassType.Ranger, SkillType.Axe,
1, 4,
0, 0,
20000, 2000, true,
14000, 1000, true,
new Material[] {Material.IRON_AXE, Material.GOLD_AXE, Material.DIAMOND_AXE},
new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK}));

View File

@ -1,5 +1,8 @@
package mineplex.minecraft.game.classcombat.shop.page;
import java.util.ArrayList;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -15,6 +18,7 @@ import mineplex.minecraft.game.classcombat.shop.button.EditAndSaveCustomBuildBut
import mineplex.minecraft.game.classcombat.shop.button.SelectCustomBuildButton;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.donation.DonationManager;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase;
@ -85,7 +89,35 @@ public class CustomBuildPage extends ShopPageBase<ClassShopManager, ClassCombatS
if (customBuild != null)
{
AddButton(slot, new ShopItem(Material.INK_SACK, itemData, "Apply " + customBuild.Name, lockedText, 1, locked, true), new SelectCustomBuildButton(this, customBuild));
String[] skills = new String[7];
skills[0] = C.cYellow + " ";
skills[1] = C.cYellow + "Sword: " + ChatColor.RESET +
((customBuild.SwordSkillLevel != null && customBuild.SwordSkillLevel > 0) ?
(customBuild.SwordSkill + " " + customBuild.SwordSkillLevel) : "None");
skills[2] = C.cYellow + "Axe: " + ChatColor.RESET +
((customBuild.AxeSkillLevel != null && customBuild.AxeSkillLevel > 0) ?
(customBuild.AxeSkill + " " + customBuild.AxeSkillLevel) : "None");
skills[3] = C.cYellow + "Bow: " + ChatColor.RESET +
((customBuild.BowSkillLevel != null && customBuild.BowSkillLevel > 0) ?
(customBuild.BowSkill + " " + customBuild.BowSkillLevel) : "None");
skills[4] = C.cYellow + "Passive A: " + ChatColor.RESET +
((customBuild.ClassPassiveASkillLevel != null && customBuild.ClassPassiveASkillLevel > 0) ?
(customBuild.ClassPassiveASkill + " " + customBuild.ClassPassiveASkillLevel) : "None");
skills[5] = C.cYellow + "Passive B: " + ChatColor.RESET +
((customBuild.ClassPassiveBSkillLevel != null && customBuild.ClassPassiveBSkillLevel > 0) ?
(customBuild.ClassPassiveBSkill + " " + customBuild.ClassPassiveBSkillLevel) : "None");
skills[6] = C.cYellow + "Passive C: " + ChatColor.RESET +
((customBuild.GlobalPassiveSkillLevel != null && customBuild.GlobalPassiveSkillLevel > 0) ?
(customBuild.GlobalPassiveSkill + " " + customBuild.GlobalPassiveSkillLevel) : "None");
AddButton(slot, new ShopItem(Material.INK_SACK, itemData, "Apply " + customBuild.Name, skills, 1, locked, true), new SelectCustomBuildButton(this, customBuild));
}
else
{

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AFTER_CLEAN_TARGETS" value="ServerData,"/>
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="ServerData,"/>
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="ServerData,"/>
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AFTER_CLEAN_TARGETS" value="Hub,Arcade,StaffServer,"/>
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="Arcade,Hub,StaffServer,"/>
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="Arcade,Hub,StaffServer,"/>
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${resource}"/>
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/>
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>

View File

@ -241,7 +241,6 @@ public class RedisServerRepository implements ServerRepository
servers.add(server);
}
}
}
catch (JedisConnectionException exception)
{
@ -261,21 +260,31 @@ public class RedisServerRepository implements ServerRepository
}
@Override
public Collection<ServerGroup> getServerGroups()
public Collection<ServerGroup> getServerGroups(boolean fetch)
{
Collection<ServerGroup> servers = new HashSet<ServerGroup>();
Jedis jedis = _jedisPool.getResource();
try
{
String key = "servergroups";
Set<String> names = jedis.smembers(key);
for (String groupName : names)
Set<Response<Map<String, String>>> serverDatas = new HashSet<Response<Map<String, String>>>();
Pipeline pipeline = jedis.pipelined();
for (String serverName : names)
{
String dataKey = concatenate(key, groupName);
Map<String, String> data = jedis.hgetAll(dataKey);
servers.add(new ServerGroup(data, _region));
String dataKey = concatenate(key, serverName);
serverDatas.add(pipeline.hgetAll(dataKey));
}
pipeline.sync();
for (Response<Map<String, String>> response : serverDatas)
{
Map<String, String> data = response.get();
servers.add(new ServerGroup(data, _region, fetch));
}
}
catch (JedisConnectionException exception)

View File

@ -68,6 +68,9 @@ public class ServerGroup
private boolean _tournament;
public boolean getTournament() { return _tournament; }
private boolean _tournamentPoints;
public boolean getTournamentPoints() { return _tournamentPoints; }
private boolean _teamRejoin;
public boolean getTeamRejoin() { return _teamRejoin; }
@ -116,6 +119,14 @@ public class ServerGroup
private boolean _addNoCheat;
public boolean getAddNoCheat() { return _addNoCheat; }
private boolean _whitelist;
public boolean getWhitelist() { return _whitelist; }
private boolean _staffOnly;
public boolean getStaffOnly() { return _staffOnly; }
private String _resourcePack = "";
public String getResourcePack() { return _resourcePack; }
// The set of active MinecraftServers that belong to this server group
private Set<MinecraftServer> _servers;
public Set<MinecraftServer> getServers() { return _servers; }
@ -126,7 +137,7 @@ public class ServerGroup
* the internal state of this ServerGroup.
* @param region - the region from which to fetch active {@link MinecraftServer}s.
*/
public ServerGroup(Map<String, String> data, Region region)
public ServerGroup(Map<String, String> data, Region region, boolean fetch)
{
_name = data.get("name");
_prefix = data.get("prefix");
@ -144,6 +155,7 @@ public class ServerGroup
_maxPlayers = Integer.valueOf(data.get("maxPlayers"));
_pvp = Boolean.valueOf(data.get("pvp"));
_tournament = Boolean.valueOf(data.get("tournament"));
_tournamentPoints = Boolean.valueOf(data.get("tournamentPoints"));
_generateFreeVersions = Boolean.valueOf(data.get("generateFreeVersions"));
_games = data.get("games");
_serverType = data.get("serverType");
@ -160,8 +172,12 @@ public class ServerGroup
_hotbarInventory = Boolean.valueOf(data.get("hotbarInventory"));
_hotbarHubClock = Boolean.valueOf(data.get("hotbarHubClock"));
_playerKickIdle = Boolean.valueOf(data.get("playerKickIdle"));
_staffOnly = Boolean.valueOf(data.get("staffOnly"));
_whitelist = Boolean.valueOf(data.get("whitelist"));
_resourcePack = data.containsKey("resourcePack") ? data.get("resourcePack") : "";
fetchServers(region);
if (fetch)
fetchServers(region);
}
/**

View File

@ -61,7 +61,7 @@ public interface ServerRepository
* @return a newly instanced snapshot {@link Collection} of all the
* currently active {@link ServerGroup}s in the repository.
*/
public Collection<ServerGroup> getServerGroups();
public Collection<ServerGroup> getServerGroups(boolean fetch);
public Collection<MinecraftServer> getDeadServers();

View File

@ -74,7 +74,7 @@ public class ServerMonitor
while (true)
{
Collection<ServerGroup> serverGroups = _repository.getServerGroups();
Collection<ServerGroup> serverGroups = _repository.getServerGroups(true);
Collection<MinecraftServer> serverStatuses = _repository.getServerStatuses();
for (MinecraftServer deadServer : _repository.getDeadServers())
@ -416,12 +416,12 @@ public class ServerMonitor
private static void startServer(final DedicatedServer serverSpace, final ServerGroup serverGroup, final int serverNum, final boolean free)
{
String cmd = "/home/mineplex/easyRemoteStartServer.sh";
String cmd = "/home/mineplex/easyRemoteStartServerCustom.sh";
final String groupPrefix = serverGroup.getPrefix();
final String serverName = serverSpace.getName();
final String serverAddress = serverSpace.getPublicAddress();
ProcessRunner pr = new ProcessRunner(new String[] {"/bin/sh", cmd, serverAddress, serverSpace.getPrivateAddress(), (serverGroup.getPortSection() + serverNum) + "", serverGroup.getRequiredRam() + "", serverGroup.getWorldZip(), serverGroup.getPlugin(), serverGroup.getConfigPath(), serverGroup.getName(), serverGroup.getPrefix() + "-" + serverNum, serverGroup.getMinPlayers() + "", serverGroup.getMaxPlayers() + "", serverGroup.getPvp() + "", serverGroup.getTournament() + "", free + "", serverSpace.isUsRegion() ? "true" : "false", serverGroup.getArcadeGroup() + "", serverGroup.getGames(), serverGroup.getServerType(), serverGroup.getAddNoCheat() + "", serverGroup.getTeamAutoJoin() + "", serverGroup.getTeamForceBalance() + "", serverGroup.getTeamRejoin() + "", serverGroup.getGameAutoStart() + "", serverGroup.getGameTimeout() + "", serverGroup.getHotbarHubClock() + "", serverGroup.getHotbarInventory() + "", serverGroup.getPlayerKickIdle() + "", serverGroup.getRewardGems() + "", serverGroup.getRewardItems() + "", serverGroup.getRewardAchievements() + "", serverGroup.getRewardStats() + ""});
ProcessRunner pr = new ProcessRunner(new String[] {"/bin/sh", cmd, serverAddress, serverSpace.getPrivateAddress(), (serverGroup.getPortSection() + serverNum) + "", serverGroup.getRequiredRam() + "", serverGroup.getWorldZip(), serverGroup.getPlugin(), serverGroup.getConfigPath(), serverGroup.getName(), serverGroup.getPrefix() + "-" + serverNum, serverSpace.isUsRegion() ? "true" : "false", serverGroup.getAddNoCheat() + "" });
pr.start(new GenericRunnable<Boolean>()
{
public void run(Boolean error)

View File

@ -9,7 +9,6 @@ import mineplex.core.inventory.InventoryManager;
import mineplex.core.memory.MemoryFix;
import mineplex.core.monitor.LagMeter;
import mineplex.core.npc.NpcManager;
import mineplex.core.playerTracker.PlayerTracker;
import mineplex.core.portal.Portal;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.recharge.Recharge;

View File

@ -111,7 +111,7 @@ public class CustomerSupport extends MiniPlugin
for (CoinTransactionToken transaction : donor.getCoinTransactions())
{
if (transaction.Source.equalsIgnoreCase("Poll") || transaction.Source.equalsIgnoreCase("Coin Party Bomb Pickup") || transaction.Source.contains("Reward") || transaction.Source.contains("purchase"))
if (transaction.Source.equalsIgnoreCase("Poll") || transaction.Source.equalsIgnoreCase("Halloween Pumpkin") || transaction.Source.equalsIgnoreCase("Treasure Chest") || transaction.Source.equalsIgnoreCase("Coin Party Bomb Pickup") || transaction.Source.contains("Reward") || transaction.Source.contains("purchase"))
{
coinTransactionTotal += transaction.Amount;

View File

@ -1,12 +1,6 @@
package nautilus.game.arcade;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.InputStreamReader;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
@ -37,12 +31,12 @@ import mineplex.core.mount.MountManager;
import mineplex.core.npc.NpcManager;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.pet.PetManager;
import mineplex.core.playerTracker.PlayerTracker;
import mineplex.core.portal.Portal;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.projectile.ProjectileManager;
import mineplex.core.punish.Punish;
import mineplex.core.recharge.Recharge;
import mineplex.core.serverConfig.ServerConfiguration;
import mineplex.core.spawn.Spawn;
import mineplex.core.status.ServerStatusManager;
import mineplex.core.teleport.Teleport;
@ -62,6 +56,8 @@ public class Arcade extends JavaPlugin
private DamageManager _damageManager;
private ArcadeManager _gameManager;
private ServerConfiguration _serverConfiguration;
@Override
public void onEnable()
@ -88,6 +84,8 @@ public class Arcade extends JavaPlugin
_donationManager = new DonationManager(this, webServerAddress);
_serverConfiguration = new ServerConfiguration(this);
PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager);
new MessageManager(this, _clientManager, preferenceManager);
@ -122,12 +120,11 @@ public class Arcade extends JavaPlugin
//Arcade Manager
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), antistack, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, webServerAddress);
new PlayerTracker(this, serverStatusManager.getCurrentServerName(), serverStatusManager.getUs());
new MemoryFix(this);
new CustomTagFix(this, packetHandler);
new FriendManager(this, preferenceManager);
new FriendManager(this, _clientManager, preferenceManager);
//Updates
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);
@ -135,7 +132,6 @@ public class Arcade extends JavaPlugin
MinecraftServer.getServer().getPropertyManager().setProperty("debug", true);
}
@Override
public void onDisable()
{
@ -151,124 +147,47 @@ public class Arcade extends JavaPlugin
{
GameServerConfig config = new GameServerConfig();
//Load Track Data
String line = null;
try
{
File file = new File("ArcadeSettings.config");
if (!file.exists())
WriteServerConfig(GetDefaultConfig());
FileInputStream fstream = new FileInputStream("ArcadeSettings.config");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
while ((line = br.readLine()) != null)
config.ServerType = _serverConfiguration.getServerGroup().getServerType();
config.MinPlayers = _serverConfiguration.getServerGroup().getMinPlayers();
config.MaxPlayers = _serverConfiguration.getServerGroup().getMaxPlayers();
config.Tournament = _serverConfiguration.getServerGroup().getTournament();
config.TournamentPoints = _serverConfiguration.getServerGroup().getTournamentPoints();
config.TeamRejoin = _serverConfiguration.getServerGroup().getTeamRejoin();
config.TeamAutoJoin = _serverConfiguration.getServerGroup().getTeamAutoJoin();
config.TeamForceBalance = _serverConfiguration.getServerGroup().getTeamForceBalance();
config.GameAutoStart = _serverConfiguration.getServerGroup().getGameAutoStart();
config.GameTimeout = _serverConfiguration.getServerGroup().getGameTimeout();
config.RewardGems = _serverConfiguration.getServerGroup().getRewardGems();
config.RewardItems = _serverConfiguration.getServerGroup().getRewardItems();
config.RewardStats = _serverConfiguration.getServerGroup().getRewardStats();
config.RewardAchievements = _serverConfiguration.getServerGroup().getRewardAchievements();
config.HotbarInventory = _serverConfiguration.getServerGroup().getHotbarInventory();
config.HotbarHubClock = _serverConfiguration.getServerGroup().getHotbarHubClock();
config.PlayerKickIdle = _serverConfiguration.getServerGroup().getPlayerKickIdle();
for (String gameName : _serverConfiguration.getServerGroup().getGames().split(","))
{
String[] tokens = line.split("=");
if (tokens.length < 2)
continue;
if (tokens[0].equals("SERVER_TYPE"))
try
{
config.ServerType = tokens[1];
GameType type = GameType.valueOf(gameName);
config.GameList.add(type);
}
else if (tokens[0].equals("PLAYERS_MIN"))
catch (Exception e)
{
config.MinPlayers = Integer.parseInt(tokens[1]);
}
else if (tokens[0].equals("PLAYERS_MAX"))
{
config.MaxPlayers = Integer.parseInt(tokens[1]);
}
else if (tokens[0].equals("TOURNAMENT"))
{
config.Tournament = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("TOURNAMENT_POINTS"))
{
config.TournamentPoints = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("TEAM_REJOIN"))
{
config.TeamRejoin = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("TEAM_AUTO_JOIN"))
{
config.TeamAutoJoin = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("TEAM_FORCE_BALANCE"))
{
config.TeamForceBalance = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("GAME_AUTO_START"))
{
config.GameAutoStart = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("GAME_TIMEOUT"))
{
config.GameTimeout = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("REWARD_GEMS"))
{
config.RewardGems = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("REWARD_ITEMS"))
{
config.RewardItems = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("REWARD_STATS"))
{
config.RewardStats = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("REWARD_ACHIEVEMENTS"))
{
config.RewardAchievements = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("HOTBAR_INVENTORY"))
{
config.HotbarInventory = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("HOTBAR_HUB_CLOCK"))
{
config.HotbarHubClock = Boolean.parseBoolean(tokens[1]);
}
else if (tokens[0].equals("PLAYER_KICK_IDLE"))
{
config.PlayerKickIdle = Boolean.parseBoolean(tokens[1]);
}
//Games
else
{
try
{
GameType type = GameType.valueOf(tokens[0]);
boolean enabled = Boolean.valueOf(tokens[1]);
if (enabled)
config.GameList.add(type);
}
catch (Exception e)
{
}
}
}
in.close();
}
catch (Exception e)
catch (Exception ex)
{
System.out.println("Error reading ServerConfiguration values : " + ex.getMessage());
}
if (!config.IsValid())
config = GetDefaultConfig();
WriteServerConfig(config);
return config;
}
@ -284,53 +203,6 @@ public class Arcade extends JavaPlugin
return config;
}
public void WriteServerConfig(GameServerConfig config)
{
try
{
FileWriter fstream = new FileWriter("ArcadeSettings.config");
BufferedWriter out = new BufferedWriter(fstream);
out.write("SERVER_TYPE=" + config.ServerType + "\n");
out.write("PLAYERS_MIN=" + config.MinPlayers + "\n");
out.write("PLAYERS_MAX=" + config.MaxPlayers + "\n");
out.write("\nTOURNAMENT=" + config.Tournament + "\n");
out.write("\nTOURNAMENT_POINTS=" + config.TournamentPoints + "\n");
out.write("\nTEAM_REJOIN=" + config.TeamRejoin + "\n");
out.write("TEAM_AUTO_JOIN=" + config.TeamAutoJoin + "\n");
out.write("TEAM_FORCE_BALANCE=" + config.TeamForceBalance + "\n");
out.write("\nGAME_AUTO_START=" + config.GameAutoStart + "\n");
out.write("GAME_TIMEOUT=" + config.GameTimeout + "\n");
out.write("\nREWARD_GEMS=" + config.RewardGems + "\n");
out.write("REWARD_ITEMS=" + config.RewardItems + "\n");
out.write("REWARD_STATS=" + config.RewardStats + "\n");
out.write("REWARD_ACHIEVEMENTS=" + config.RewardAchievements + "\n");
out.write("\nHOTBAR_INVENTORY=" + config.HotbarInventory + "\n");
out.write("HOTBAR_HUB_CLOCK=" + config.HotbarHubClock + "\n");
out.write("\nPLAYER_KICK_IDLE=" + config.PlayerKickIdle + "\n");
out.write("\n\nGames List;\n");
for (GameType type : GameType.values())
{
out.write(type.toString() + "=" + config.GameList.contains(type) + "\n");
}
out.close();
}
catch (Exception e)
{
}
}
private void DeleteFolders()
{
File curDir = new File(".");

View File

@ -99,6 +99,7 @@ import nautilus.game.arcade.managers.GameChatManager;
import nautilus.game.arcade.managers.GameCreationManager;
import nautilus.game.arcade.managers.GameFlagManager;
import nautilus.game.arcade.managers.GameGemManager;
import nautilus.game.arcade.managers.GameHostManager;
import nautilus.game.arcade.managers.GameLobbyManager;
import nautilus.game.arcade.managers.GameLootManager;
import nautilus.game.arcade.managers.GameManager;
@ -140,6 +141,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
private GamePlayerManager _gamePlayerManager;
private GameTournamentManager _gameTournamentManager;
private GameWorldManager _gameWorldManager;
private GameHostManager _gameHostManager;
private ServerStatusManager _serverStatusManager;
private InventoryManager _inventoryManager;
private CosmeticManager _cosmeticManager;
@ -254,6 +256,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_gameGemManager = new GameGemManager(this);
_gameManager = new GameManager(this);
_gameLobbyManager = new GameLobbyManager(this, packetHandler);
_gameHostManager = new GameHostManager(this);
new GameFlagManager(this);
_gamePlayerManager = new GamePlayerManager(this);
new GameAchievementManager(this);
@ -263,7 +266,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_gameWorldManager = new GameWorldManager(this);
new MiscManager(this);
_idleManager = new IdleManager(this);
new HalloweenManager(this);
//new HalloweenManager(this);
_arcadeRepository = new ArcadeRepository(plugin);
// Game Addons
@ -395,6 +398,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation
return _gameCreationManager;
}
public GameHostManager GetGameHostManager()
{
return _gameHostManager;
}
public GameFactory GetGameFactory()
{
return _gameFactory;
@ -500,6 +508,13 @@ public class ArcadeManager extends MiniPlugin implements IRelation
@EventHandler
public void MessageMOTD(ServerListPingEvent event)
{
//Mineplex Private Servers
// if (_gameHostManager.isHostExpired())
// {
// event.setMotd(ChatColor.RED + "Finished");
// return;
// }
String extrainformation = "|" + _serverConfig.ServerType + "|" + (_game == null ? "Unknown" : _game.GetName())
+ "|" + ((_game == null || _game.WorldData == null) ? "Unknown" : _game.WorldData.MapName);
@ -943,6 +958,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation
{
return _serverConfig.MaxPlayers;
}
public String GetHost()
{
return _serverConfig.HostName;
}
@EventHandler
public void ObserverQuit(GameStateChangeEvent event)
@ -999,14 +1019,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
@Override
public void run()
{
try
{
getArcadeRepository().saveBasicStats(game.GetType(), IsTournamentServer(), (int) (System.currentTimeMillis() - game.getGameLiveTime()), data);
}
catch (SQLException e)
{
e.printStackTrace();
}
getArcadeRepository().saveBasicStats(game.GetType(), IsTournamentServer(), (int) (System.currentTimeMillis() - game.getGameLiveTime()), data);
}
});
}
@ -1030,14 +1043,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
@Override
public void run()
{
try
{
getArcadeRepository().saveLeaderboardStats(0, type.ordinal(), data);
}
catch (SQLException e)
{
e.printStackTrace();
}
getArcadeRepository().saveLeaderboardStats(0, type.ordinal(), data);
}
});
}

View File

@ -1,16 +1,12 @@
package nautilus.game.arcade;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.database.DBPool;
import mineplex.core.database.RepositoryBase;
import mineplex.database.Tables;
import mineplex.database.tables.records.GamesRecord;
@ -22,9 +18,9 @@ public class ArcadeRepository extends RepositoryBase
{
private final String serverName;
public ArcadeRepository(Plugin plugin)
public ArcadeRepository(JavaPlugin plugin)
{
super(plugin, DBPool.ACCOUNT);
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
serverName = plugin.getConfig().getString("serverstatus.name");
}
@ -41,67 +37,71 @@ public class ArcadeRepository extends RepositoryBase
}
public void saveBasicStats(GameType type, boolean tournament, int duration, Map<UUID, Boolean> players) throws SQLException
public void saveBasicStats(GameType type, boolean tournament, int duration, Map<UUID, Boolean> players)
{
try (Connection connection = getConnection())
DSLContext context;
synchronized (this)
{
DSLContext context = DSL.using(connection);
GamesRecord record = context.newRecord(Tables.games);
record.setDuration(duration);
record.setTournament(tournament);
record.setType(type.name());
record.setServer(serverName);
record.store();
List<Query> queryList = new ArrayList<>(players.size());
for (Map.Entry<UUID, Boolean> entry : players.entrySet())
{
Query query = context
.insertInto(Tables.gamePlayers)
.set(Tables.gamePlayers.gameId, record.getId())
.set(Tables.gamePlayers.accountId, DSL.select(Tables.accounts.id)
.from(Tables.accounts)
.where(Tables.accounts.uuid.eq(entry.getKey().toString())))
.set(Tables.gamePlayers.winner, entry.getValue());
queryList.add(query);
}
context.batch(queryList).execute();
context = DSL.using(getConnection());
}
GamesRecord record = context.newRecord(Tables.games);
record.setDuration(duration);
record.setTournament(tournament);
record.setType(type.name());
record.setServer(serverName);
record.store();
List<Query> queryList = new ArrayList<>(players.size());
for (Map.Entry<UUID, Boolean> entry : players.entrySet())
{
Query query = context
.insertInto(Tables.gamePlayers)
.set(Tables.gamePlayers.gameId, record.getId())
.set(Tables.gamePlayers.accountId, DSL.select(Tables.accounts.id)
.from(Tables.accounts)
.where(Tables.accounts.uuid.eq(entry.getKey().toString())))
.set(Tables.gamePlayers.winner, entry.getValue());
queryList.add(query);
}
context.batch(queryList).execute();
}
public void saveLeaderboardStats(int tournamentId, int gameId, Map<UUID, Boolean> players) throws SQLException
public void saveLeaderboardStats(int tournamentId, int gameId, Map<UUID, Boolean> players)
{
try (Connection connection = getConnection())
DSLContext context;
synchronized (this)
{
DSLContext context = DSL.using(connection);
List<Query> queryList = new ArrayList<>(players.size());
for (Map.Entry<UUID, Boolean> entry : players.entrySet())
{
int winIncrement = entry.getValue() ? 1 : 0;
Query query = context
.insertInto(Tables.tournamentLeaderboard)
.set(Tables.tournamentLeaderboard.tournamentId, tournamentId)
.set(Tables.tournamentLeaderboard.gameId, gameId)
.set(Tables.tournamentLeaderboard.accountId, DSL.select(Tables.accounts.id)
.from(Tables.accounts)
.where(Tables.accounts.uuid.eq(entry.getKey().toString())))
.set(Tables.tournamentLeaderboard.wins, winIncrement)
.set(Tables.tournamentLeaderboard.total, 1)
.onDuplicateKeyUpdate()
.set(Tables.tournamentLeaderboard.wins, Tables.tournamentLeaderboard.wins.plus(winIncrement))
.set(Tables.tournamentLeaderboard.total, Tables.tournamentLeaderboard.total.plus(1));
queryList.add(query);
}
context.batch(queryList).execute();
context = DSL.using(getConnection());
}
List<Query> queryList = new ArrayList<>(players.size());
for (Map.Entry<UUID, Boolean> entry : players.entrySet())
{
int winIncrement = entry.getValue() ? 1 : 0;
Query query = context
.insertInto(Tables.tournamentLeaderboard)
.set(Tables.tournamentLeaderboard.tournamentId, tournamentId)
.set(Tables.tournamentLeaderboard.gameId, gameId)
.set(Tables.tournamentLeaderboard.accountId, DSL.select(Tables.accounts.id)
.from(Tables.accounts)
.where(Tables.accounts.uuid.eq(entry.getKey().toString())))
.set(Tables.tournamentLeaderboard.wins, winIncrement)
.set(Tables.tournamentLeaderboard.total, 1)
.onDuplicateKeyUpdate()
.set(Tables.tournamentLeaderboard.wins, Tables.tournamentLeaderboard.wins.plus(winIncrement))
.set(Tables.tournamentLeaderboard.total, Tables.tournamentLeaderboard.total.plus(1));
queryList.add(query);
}
context.batch(queryList).execute();
}
}

View File

@ -215,6 +215,8 @@ public abstract class Game implements Listener
public boolean TeamArmorHotbar = false;
public boolean GiveClock = true;
public boolean AllowParticles = true;
public double GemMultiplier = 1;
public boolean GemHunterEnabled = true;
@ -284,6 +286,7 @@ public abstract class Game implements Listener
new KillsStatTracker(this),
new DeathsStatTracker(this),
new AssistsStatTracker(this),
new ExperienceStatTracker(this),
new WinStatTracker(this),
new LoseStatTracker(this),
new DamageDealtStatTracker(this),

View File

@ -12,6 +12,8 @@ public class GameServerConfig
public ArrayList<GameType> GameList = new ArrayList<GameType>();
//Flags
public String HostName = "";
public boolean Tournament = false;
public boolean TournamentPoints = false;

View File

@ -13,6 +13,7 @@ import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Chest;
import org.bukkit.entity.Boat;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Cow;
import org.bukkit.entity.Entity;
@ -28,11 +29,13 @@ import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.vehicle.VehicleEnterEvent;
import org.bukkit.inventory.CraftingInventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
@ -42,6 +45,7 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilMath;
@ -1567,6 +1571,42 @@ public class Bridge extends TeamGame implements OreObsfucation
{
if (!_bridgesDown)
{
if (!event.getToBlock().getRelative(BlockFace.UP).equals(event.getBlock()))
{
event.setCancelled(true);
}
}
}
// @EventHandler
// public void liquidBlockDeny(BlockBreakEvent event)
// {
// if (_bridgesDown)
// return;
//
// if (!IsAlive(event.getPlayer()))
// return;
//
// if (event.getBlock().getRelative(BlockFace.UP).isLiquid() || event.getBlock().getRelative(BlockFace.UP).getRelative(BlockFace.UP).isLiquid())
// {
// UtilPlayer.message(event.getPlayer(), F.main("Game",
// "Cannot tunnel under liquids."));
//
// event.setCancelled(true);
// }
// }
@EventHandler
public void boatDeny(PlayerInteractEvent event)
{
if (!UtilEvent.isAction(event, ActionType.R))
return;
if (UtilGear.isMat(event.getPlayer().getItemInHand(), Material.BOAT))
{
UtilPlayer.message(event.getPlayer(), F.main("Game",
"You cannot place boats."));
event.setCancelled(true);
}
}

View File

@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.champions;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.minecraft.game.core.combat.DeathMessageType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.GameTeam;
@ -20,7 +21,9 @@ import nautilus.game.arcade.stats.TheLongestShotStatTracker;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.inventory.InventoryType;
public class ChampionsDominate extends Domination
{
@ -52,6 +55,7 @@ public class ChampionsDominate extends Domination
};
Manager.GetDamage().UseSimpleWeaponDamage = false;
Manager.getCosmeticManager().setHideParticles(true);
this.StrictAntiHack = true;
@ -59,6 +63,8 @@ public class ChampionsDominate extends Domination
EloRanking = false;
EloStart = 1000;
this.DisableKillCommand = false;
registerStatTrackers(
new KillReasonStatTracker(this, "Backstab", "Assassination"),
@ -94,4 +100,24 @@ public class ChampionsDominate extends Domination
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void InventoryDamageCancel(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
Player player = event.GetDamageePlayer();
if (player == null)
return;
if (!IsAlive(player))
return;
if (player.getOpenInventory() == null || player.getOpenInventory().getTopInventory() == null)
return;
if (player.getOpenInventory().getTopInventory().getType() == InventoryType.CHEST)
player.closeInventory();
}
}

View File

@ -2,11 +2,14 @@ package nautilus.game.arcade.game.games.champions;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.inventory.InventoryType;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.minecraft.game.core.combat.DeathMessageType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.GameTeam;
@ -53,11 +56,14 @@ public class ChampionsTDM extends TeamDeathmatch
};
this.Manager.GetDamage().UseSimpleWeaponDamage = false;
Manager.getCosmeticManager().setHideParticles(true);
this.StrictAntiHack = true;
InventoryOpenChest = true;
this.DisableKillCommand = false;
registerStatTrackers(
new WinWithoutLosingTeammateStatTracker(this, "FlawlessVictory"),
new KillAllOpposingStatTracker(this),
@ -94,4 +100,24 @@ public class ChampionsTDM extends TeamDeathmatch
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void InventoryDamageCancel(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
Player player = event.GetDamageePlayer();
if (player == null)
return;
if (!IsAlive(player))
return;
if (player.getOpenInventory() == null || player.getOpenInventory().getTopInventory() == null)
return;
if (player.getOpenInventory().getTopInventory().getType() == InventoryType.CHEST)
player.closeInventory();
}
}

View File

@ -22,6 +22,7 @@ import org.bukkit.Material;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
public class CapturePoint
@ -43,9 +44,9 @@ public class CapturePoint
private boolean _captured = false;
private ArrayList<Block> _captureFloor = new ArrayList<Block>();
private long _decayDelay = 0;
private int _indicatorTick = 0;
private ChatColor _scoreboardColor = ChatColor.WHITE;
private int _scoreboardTick = 0;
@ -82,14 +83,14 @@ public class CapturePoint
block.setType(Material.BEACON);
}
}
//Glass
if (Math.abs(x) <= 2 && Math.abs(z) <= 2)
{
Block block = loc.getBlock().getRelative(x, -1, z);
block.setType(Material.GLASS);
block.setType(Material.STAINED_GLASS);
}
//Iron
if (Math.abs(x) <= 1 && Math.abs(z) <= 1)
{
@ -132,7 +133,7 @@ public class CapturePoint
{
if (player.getGameMode() != GameMode.SURVIVAL)
continue;
if (Math.abs(_loc.getX() - player.getLocation().getX()) > 2.5)
continue;
@ -163,7 +164,6 @@ public class CapturePoint
return;
}
//Capture
if (teamB == null)
@ -180,7 +180,7 @@ public class CapturePoint
{
if (!UtilTime.elapsed(_decayDelay, 2000))
return;
//Degen
if (!_captured)
{
@ -193,13 +193,12 @@ public class CapturePoint
_floor.add(block);
block.setData((byte)0);
setWoolColor(block, null, false);
}
//Set Uncaptured
if (_captureAmount == 0)
{
_captured = false;
_owner = null;
//Indicators
@ -208,7 +207,7 @@ public class CapturePoint
block.setData((byte)0);
}
}
//Effect
for (Block block : _indicators)
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, 35);
@ -225,10 +224,9 @@ public class CapturePoint
_captureFloor.add(block);
if (_owner.GetColor() == ChatColor.RED) block.setData((byte)14);
else block.setData((byte)11);
setWoolColor(block, _owner.GetColor(), false);
}
//Effect
for (Block block : _indicators)
{
@ -237,21 +235,21 @@ public class CapturePoint
else
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, 22);
}
}
}
public void Capture(GameTeam team, int count, Collection<Player> capturers)
{
_scoreboardColor = team.GetColor();
//Decay Delay
_decayDelay = System.currentTimeMillis();
//Defend Score
//if (_captured)
// Host.AddScore(_owner, count);
//Color
Color color = Color.RED;
if (team.GetColor() == ChatColor.BLUE)
@ -264,7 +262,7 @@ public class CapturePoint
int bonus = 0;
if (_captured)
bonus = 1;
_captureAmount = Math.min(_captureMax, (_captureAmount + ((_captureRate*count)+bonus)));
//Floor Color
@ -274,8 +272,7 @@ public class CapturePoint
_captureFloor.add(block);
if (team.GetColor() == ChatColor.RED) block.setData((byte)14);
else block.setData((byte)11);
setWoolColor(block, team.GetColor(), false);
}
//Set Fully Captured
@ -284,7 +281,6 @@ public class CapturePoint
_captured = true;
//Firework
Firework(_loc, color, true);
//Indicators
@ -293,7 +289,10 @@ public class CapturePoint
if (team.GetColor() == ChatColor.RED) block.setData((byte)14);
else block.setData((byte)11);
}
//Center
setWoolColor(_loc.getBlock().getRelative(0, -2, 0), _owner.GetColor(), true);
//Reward Gems
if (capturers != null)
{
@ -311,7 +310,7 @@ public class CapturePoint
int bonus = 0;
if (!_captured)
bonus = 1;
_captureAmount = Math.max(0, (_captureAmount - ((_captureRate*count)+bonus)));
//Announce
@ -323,7 +322,7 @@ public class CapturePoint
player.playSound(player.getLocation(), Sound.GHAST_SCREAM2, 0.6f, 0.6f);
}
}
//Floor Color
while ((double)_captureFloor.size()/((double)_captureFloor.size() + (double)_floor.size()) > _captureAmount/_captureMax)
{
@ -331,7 +330,7 @@ public class CapturePoint
_floor.add(block);
block.setData((byte)0);
setWoolColor(block, null, false);
}
//Set Uncaptured
@ -339,6 +338,9 @@ public class CapturePoint
{
_captured = false;
_owner = team;
//Center
setWoolColor(_loc.getBlock().getRelative(0, -2, 0), null, true);
//Indicators
for (Block block : _indicators)
@ -358,10 +360,32 @@ public class CapturePoint
RewardCapture(player, 1);
}
}
Indicate(color);
}
}
private void setWoolColor(Block block, ChatColor color, boolean glassOnly)
{
if (color == null)
{
if (!glassOnly)
block.setData((byte)0);
block.getRelative(BlockFace.UP).setTypeIdAndData(95, (byte)0, true);
}
else if (color == ChatColor.RED)
{
if (!glassOnly)
block.setData((byte)14);
block.getRelative(BlockFace.UP).setTypeIdAndData(95, (byte)14, true);
}
else
{
if (!glassOnly)
block.setData((byte)11);
block.getRelative(BlockFace.UP).setTypeIdAndData(95, (byte)11, true);
}
}
public void Firework(Location loc, Color color, boolean major)
@ -380,24 +404,24 @@ public class CapturePoint
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 String GetScoreboardName()
{
_scoreboardTick = (_scoreboardTick + 1)%2;
String out = "";
if (_scoreboardColor != null && _scoreboardTick == 0)
{
if (_scoreboardColor == ChatColor.BLUE)
_scoreboardColor = ChatColor.AQUA;
out = _scoreboardColor + C.Bold + _name;
_scoreboardColor = null;
}
@ -410,17 +434,17 @@ public class CapturePoint
else
out = _owner.GetColor() + _name;
}
else
out = _name;
}
if (out.length() > 16)
out = out.substring(0, 16);
return out;
}
public void RewardCapture(Player player, int amount)
{
Host.AddGems(player, amount / 25d, "Control Point Score", true);

View File

@ -1,7 +1,9 @@
package nautilus.game.arcade.game.games.deathtag;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -26,6 +28,7 @@ import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.games.deathtag.kits.*;
import nautilus.game.arcade.game.games.sneakyassassins.powerups.PowerUpManager;
@ -377,4 +380,36 @@ public class DeathTag extends SoloGame
return 0;
}
@Override
public List<Player> getWinners()
{
if (GetState().ordinal() >= GameState.End.ordinal())
{
List<Player> places = _runners.GetPlayers(true);
if (places.isEmpty() || !places.get(0).isOnline())
return Arrays.asList();
else
return Arrays.asList(places.get(0));
}
else
return null;
}
@Override
public List<Player> getLosers()
{
if (GetState().ordinal() >= GameState.End.ordinal())
{
List<Player> places = _chasers.GetPlayers(true);
if (places.isEmpty() || !places.get(0).isOnline())
return Arrays.asList();
else
return Arrays.asList(places.get(0));
}
else
return null;
}
}

View File

@ -1,6 +1,7 @@
package nautilus.game.arcade.game.games.dragonescape;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
@ -35,12 +36,14 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.data.BlockData;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -81,7 +84,6 @@ public class DragonEscape extends SoloGame
}
private ArrayList<DragonScore> _ranks = new ArrayList<DragonScore>();
private ArrayList<String> _lastScoreboard = new ArrayList<String>();
private NautHashMap<Player, Long> _warpTime = new NautHashMap<Player, Long>();
@ -93,6 +95,8 @@ public class DragonEscape extends SoloGame
private Player _winner = null;
private double _speedMult = 1;
private HashMap<BlockData, Player> _tunneled = new HashMap<BlockData, Player>();
public DragonEscape(ArcadeManager manager)
{
@ -103,7 +107,7 @@ public class DragonEscape extends SoloGame
new KitLeaper(manager),
new KitDisruptor(manager),
new KitWarper(manager),
new KitTunneler(manager),
new KitDigger(manager),
},
new String[]
@ -474,6 +478,9 @@ public class DragonEscape extends SoloGame
@EventHandler
public void Warp(PlayerInteractEvent event)
{
if (!IsLive())
return;
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK &&
event.getAction() != Action.LEFT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_AIR)
return;
@ -553,6 +560,25 @@ public class DragonEscape extends SoloGame
if (!player.getInventory().contains(Material.DIAMOND_PICKAXE))
return;
if (!UtilTime.elapsed(GetStateTime(), 10000))
{
UtilPlayer.message(player, F.main("Game", "You cannot dig for " + F.elem(UtilTime.MakeStr(6000 - (System.currentTimeMillis() - GetStateTime())) + ".")));
return;
}
for (Player other : GetPlayers(true))
{
if (player.equals(other))
continue;
if (UtilMath.offset(event.getBlock().getLocation().add(0.5, 0.5, 0.5), other.getLocation()) < 1.5 ||
UtilMath.offset(event.getBlock().getLocation().add(0.5, 1, 0.5), other.getLocation()) < 1.5)
{
UtilPlayer.message(player, F.main("Game", "You cannot dig near other players."));
return;
}
}
if (!Recharge.Instance.use(player, "Tunneler", 100, false, false))
return;
@ -560,8 +586,10 @@ public class DragonEscape extends SoloGame
player.getInventory().addItem(new ItemStack(event.getBlock().getType()));
Manager.GetBlockRestore().Add(event.getBlock(), 0, (byte)0, 3000);
_tunneled.put(new BlockData(event.getBlock()), player);
Manager.GetBlockRestore().Add(event.getBlock(), 0, (byte)0, 2400);
UtilInv.remove(player, Material.DIAMOND_PICKAXE, (byte)0, 1);
}
@ -570,9 +598,31 @@ public class DragonEscape extends SoloGame
{
if (event.isCancelled())
return;
Manager.GetBlockRestore().Add(event.getBlock(),
event.getPlayer().getItemInHand().getType().getId(), event.getPlayer().getItemInHand().getData().getData(),
event.getBlockReplacedState().getTypeId(), event.getBlockReplacedState().getRawData(), 3000);
event.getBlockReplacedState().getTypeId(), event.getBlockReplacedState().getRawData(), 2400);
}
@EventHandler
public void TunnelerUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
Iterator<BlockData> tunnelIterator = _tunneled.keySet().iterator();
while (tunnelIterator.hasNext())
{
BlockData data = tunnelIterator.next();
if (data.Block.getType() != Material.AIR || UtilTime.elapsed(data.Time, 2400))
tunnelIterator.remove();
else
for (Player other : UtilServer.getPlayers())
if (!other.equals(_tunneled.get(data)))
other.sendBlockChange(data.Block.getLocation(), data.Material, data.Data);
}
}
}

View File

@ -12,9 +12,9 @@ import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
public class KitTunneler extends Kit
public class KitDigger extends Kit
{
public KitTunneler(ArcadeManager manager)
public KitDigger(ArcadeManager manager)
{
super(manager, "Digger", KitAvailability.Achievement, 5000,

View File

@ -1,9 +1,11 @@
package nautilus.game.arcade.game.games.draw;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -16,6 +18,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
@ -25,6 +28,8 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
@ -43,8 +48,10 @@ import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.games.GameScore;
import nautilus.game.arcade.game.games.draw.kits.KitPlayer;
import nautilus.game.arcade.game.games.draw.kits.*;
import nautilus.game.arcade.game.games.draw.tools.*;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.stats.KeenEyeStatTracker;
import nautilus.game.arcade.stats.MrSquiggleStatTracker;
@ -76,6 +83,7 @@ public class Draw extends SoloGame
private Collection<Block> _textBlocks = null;
private HashSet<Tool> _tools;
private String[] _words;
private HashSet<String> _usedWords = new HashSet<String>();
@ -85,7 +93,9 @@ public class Draw extends SoloGame
new Kit[]
{
new KitPlayer(manager),
new KitSlowAndSteady(manager),
new KitSelector(manager),
new KitTools(manager),
},
new String[]
@ -104,6 +114,11 @@ public class Draw extends SoloGame
{
"Bird", "Volcano", "Love", "Dance", "Hair", "Glasses", "Domino", "Dice", "Computer", "Top Hat", "Beard", "Wind", "Rain", "Minecraft", "Push", "Fighting", "Juggle", "Clown", "Miner", "Creeper", "Ghast", "Spider", "Punch", "Roll", "River", "Desert", "Cold", "Pregnant", "Photo", "Quick", "Mario", "Luigi", "Bridge", "Turtle", "Door Knob", "Mineplex", "Binoculars", "Telescope", "Planet", "Mountain Bike", "Moon", "Comet", "Flower", "Squirrel", "Horse Riding", "Chef", "Elephant", "Yoshi", "Shotgun", "Pistol", "James Bond", "Money", "Salt and Pepper", "Truck", "Helicopter", "Hot Air Balloon", "Sprout", "Yelling", "Muscles", "Skinny", "Zombie", "Lava", "Snake", "Motorbike", "Whale", "Boat", "Letterbox", "Window", "Lollipop", "Handcuffs", "Police", "Uppercut", "Windmill", "Eyepatch", "Campfire", "Rainbow", "Storm", "Pikachu", "Charmander", "Tornado", "Crying", "King", "Hobo", "Worm", "Snail", "XBox", "Playstation", "Nintendo", "Duck", "Pull", "Dinosaur", "Alligator", "Ankle", "Angel", "Acorn", "Bread", "Booty", "Bacon", "Crown", "Donut", "Drill", "Crack", "Leash", "Magic", "Wizard", "Igloo", "Plant", "Screw", "Rifle", "Puppy", "Stool", "Stamp", "Letter", "Witch", "Zebra", "Wagon", "Compass", "Watch", "Clock", "Time", "Cyclops", "Coconut", "Hang", "Penguin", "Confused", "Bucket", "Lion", "Rubbish", "Spaceship", "Bowl", "Shark", "Pizza", "Pyramid", "Dress", "Pants", "Shorts", "Boots", "Boy", "Girl", "Math", "Sunglasses", "Frog", "Chair", "Cake", "Grapes", "Kiss", "Snorlax", "Earth", "Spaghetti", "Couch", "Family", "Milk", "Blood", "Pig", "Giraffe", "Mouse", "Couch", "Fat", "Chocolate", "Camel", "Cheese", "Beans", "Water", "Chicken", "Cannibal", "Zipper", "Book", "Swimming", "Horse", "Paper", "Toaster", "Television", "Hammer", "Piano", "Sleeping", "Yawn", "Sheep", "Night", "Chest", "Lamp", "Redstone", "Grass", "Plane", "Ocean", "Lake", "Melon", "Pumpkin", "Gift", "Fishing", "Pirate", "Lightning", "Stomach", "Belly Button", "Fishing Rod", "Iron Ore", "Diamonds", "Emeralds", "Nether Portal", "Ender Dragon", "Rabbit", "Harry Potter", "Torch", "Light", "Battery", "Zombie Pigman", "Telephone", "Tent", "Hand", "Traffic Lights", "Anvil", "Tail", "Umbrella", "Piston", "Skeleton", "Spikes", "Bridge", "Bomb", "Spoon", "Rainbow", "Staircase", "Poop", "Dragon", "Fire", "Apple", "Shoe", "Squid", "Cookie", "Tooth", "Camera", "Sock", "Monkey", "Unicorn", "Smile", "Pool", "Rabbit", "Cupcake", "Pancake", "Princess", "Castle", "Flag", "Planet", "Stars", "Camp Fire", "Rose", "Spray", "Pencil", "Ice Cream", "Toilet", "Moose", "Bear", "Beer", "Batman", "Eggs", "Teapot", "Golf Club", "Tennis Racket", "Shield", "Crab", "Pot of Gold", "Cactus", "Television", "Pumpkin Pie", "Chimney", "Stable", "Nether", "Wither", "Beach", "Stop Sign", "Chestplate", "Pokeball", "Christmas Tree", "Present", "Snowflake", "Laptop", "Superman", "Football", "Basketball", "Creeper", "Tetris", "Jump", "Ninja", "Baby", "Troll Face", "Grim Reaper", "Temple", "Explosion", "Vomit", "Ants", "Barn", "Burn", "Baggage", "Frisbee", "Iceberg", "Sleeping", "Dream", "Snorlax", "Balloons", "Elevator", "Alligator", "Bikini", "Butterfly", "Bumblebee", "Pizza", "Jellyfish", "Sideburns", "Speedboat", "Treehouse", "Water Gun", "Drink", "Hook", "Dance", "Fall", "Summer", "Autumn", "Spring", "Winter", "Night Time", "Galaxy", "Sunrise", "Sunset", "Picnic", "Snowflake", "Holding Hands", "America", "Laptop", "Anvil", "Bagel", "Bench", "Cigar", "Darts", "Muffin", "Queen", "Wheat", "Dolphin", "Scarf", "Swing", "Thumb", "Tomato", "Alcohol", "Armor", "Alien", "Beans", "Cheek", "Phone", "Keyboard", "Orange", "Calculator", "Paper", "Desk", "Disco", "Elbow", "Drool", "Giant", "Golem", "Grave", "Llama", "Moose", "Party", "Panda", "Plumber", "Salsa", "Salad", "Skunk", "Skull", "Stump", "Sugar", "Ruler", "Bookcase", "Hamster", "Soup", "Teapot", "Towel", "Waist", "Archer", "Anchor", "Bamboo", "Branch", "Booger", "Carrot", "Cereal", "Coffee", "Wolf", "Crayon", "Finger", "Forest", "Hotdog", "Burger", "Obsidian", "Pillow", "Swing", "YouTube", "Farm", "Rain", "Cloud", "Frozen", "Garbage", "Music", "Twitter", "Facebook", "Santa Hat", "Rope", "Neck", "Sponge", "Sushi", "Noodles", "Soup", "Tower", "Berry", "Capture", "Prison", "Robot", "Trash", "School", "Skype", "Snowman", "Crowd", "Bank", "Mudkip", "Joker", "Lizard", "Tiger", "Royal", "Erupt", "Wizard", "Stain", "Cinema", "Notebook", "Blanket", "Paint", "Guard", "Astronaut" , "Slime" , "Mansion" , "Radar" , "Thorn" , "Tears" , "Tiny" , "Candy" , "Pepsi" , "Flint" , "Draw My Thing" , "Rice" , "Shout" , "Prize" , "Skirt" , "Thief" , "Syrup" , "Kirby" , "Brush" , "Violin",
};
_tools = new HashSet<Tool>();
_tools.add(new ToolLine(this));
_tools.add(new ToolSquare(this));
_tools.add(new ToolCircle(this));
registerStatTrackers(
new MrSquiggleStatTracker(this),
@ -194,6 +209,10 @@ public class Draw extends SoloGame
if (event.getType() != UpdateType.FAST)
return;
//Word Selection
if (_round != null && !_round.ChooseWordUpdate())
return;
//End Round
if (_round != null && (_round.IsDone() || _drawers.GetPlayers(true).isEmpty() || _round.AllGuessed(_guessers.GetPlayers(true))))
@ -225,6 +244,7 @@ public class Draw extends SoloGame
EndCheck();
}
//Reset Round
if ((_round == null && UtilTime.elapsed(_roundTime, 5000) && !_roundPlayer.isEmpty()))
{
Reset();
@ -234,13 +254,8 @@ public class Draw extends SoloGame
_guessers.RemovePlayer(drawer);
_drawers.AddPlayer(drawer, true);
//Get Word
String word = _words[UtilMath.r(_words.length)];
while (!_usedWords.add(word))
word = _words[UtilMath.r(_words.length)];
//Create Round
_round = new DrawRound(this, drawer, word);
_round = new DrawRound(this, drawer);
//Prep Drawer
drawer.teleport(_drawerLocation);
@ -251,15 +266,31 @@ public class Draw extends SoloGame
drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOD_SWORD, (byte)0, 1, "Thin Paint Brush"));
drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD, (byte)0, 1, "Thick Paint Brush"));
if (GetKit(drawer) instanceof KitTools)
{
drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_SWORD, (byte)0, 1, "Line Tool"));
drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD, (byte)0, 1, "Square Tool"));
drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD, (byte)0, 1, "Circle Tool"));
}
drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BUCKET, (byte)0, 1, "Paint Bucket"));
drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.TNT, (byte)0, 1, "Clear Canvas"));
Announce(C.cGold + C.Bold + "Round " + (_roundCount+1) + ": " + C.cYellow + C.Bold + drawer.getName() + " is drawing!");
UtilPlayer.message(drawer, C.cWhite + C.Bold + "You must draw: " + C.cGreen + C.Bold + _round.Word);
}
}
public String GetWord()
{
//Get Word
String word = _words[UtilMath.r(_words.length)];
while (!_usedWords.add(word))
word = _words[UtilMath.r(_words.length)];
return word;
}
@EventHandler(priority = EventPriority.LOWEST)
public void Guess(AsyncPlayerChatEvent event)
{
@ -269,6 +300,9 @@ public class Draw extends SoloGame
if (_round == null)
return;
if (!_round.IsReady())
return;
Player player = event.getPlayer();
if (event.getMessage().toLowerCase().contains(_round.Word.toLowerCase()))
@ -319,16 +353,22 @@ public class Draw extends SoloGame
if (_round == null)
return;
if (!_round.IsReady())
{
UtilTextBottom.displayProgress(C.Bold + "Word Selection", _round.GetTimePercent(), _round.GetTimeString(), UtilServer.getPlayers());
return;
}
for (Player player : UtilServer.getPlayers())
{
if (_drawers.HasPlayer(player))
{
UtilTextBottom.displayProgress(C.Bold + "Draw " + _round.Word, _round.GetTimePercent(), player);
UtilTextBottom.displayProgress(C.cYellow + C.Bold + "Draw: " + ChatColor.RESET + _round.Word, _round.GetTimePercent(), _round.GetTimeString(), player);
}
else
{
UtilTextBottom.displayProgress(C.cYellow + C.Bold + "Clue " + ChatColor.RESET + C.Bold + _round.GetRevealedWord(), _round.GetTimePercent(), player);
UtilTextBottom.display(_round.GetRevealedWord() + C.cYellow + C.Bold + " HINT " + ChatColor.RESET + _round.GetTimeString(), player);
}
}
}
@ -359,6 +399,29 @@ public class Draw extends SoloGame
}
}
@EventHandler
public void toolStart(PlayerInteractEvent event)
{
if (!IsLive())
return;
for (Tool tool : _tools)
tool.start(event);
}
@EventHandler
public void toolUpdate(UpdateEvent event)
{
if (!IsLive())
return;
if (event.getType() != UpdateType.TICK)
return;
for (Tool tool : _tools)
tool.update();
}
@EventHandler
public void Paint(UpdateEvent event)
{
@ -370,6 +433,9 @@ public class Draw extends SoloGame
for (Player player : _drawers.GetPlayers(true))
{
if (!UtilGear.isMat(player.getItemInHand(), Material.WOOD_SWORD) && !UtilGear.isMat(player.getItemInHand(), Material.IRON_SWORD))
continue;
if (!player.isBlocking())
{
_brushPrevious = null;
@ -434,7 +500,6 @@ public class Draw extends SoloGame
_brushPrevious = block.getLocation().add(0.5, 0.5, 0.5);
}
}
@EventHandler
public void PaintReset(PlayerInteractEvent event)
@ -583,6 +648,40 @@ public class Draw extends SoloGame
}
}
}
@Override
public List<Player> getWinners()
{
if (GetState().ordinal() >= GameState.End.ordinal())
{
SortScores();
//Set Places
ArrayList<Player> places = new ArrayList<Player>();
for (int i=0 ; i<_ranks.size() ; i++)
places.add(i, _ranks.get(i).Player);
if (places.isEmpty() || !places.get(0).isOnline())
return Arrays.asList();
else
return Arrays.asList(places.get(0));
}
else
return null;
}
@Override
public List<Player> getLosers()
{
List<Player> losers = getWinners();
if (losers == null)
return null;
losers.remove(0);
return losers;
}
@Override
public void EndCheck()
@ -655,4 +754,44 @@ public class Draw extends SoloGame
Scoreboard.Draw();
}
@EventHandler
public void selectionInput(PlayerCommandPreprocessEvent event)
{
if (!event.getMessage().startsWith("/selectword "))
return;
event.setCancelled(true);
if (_round == null)
return;
if (!_round.Drawer.equals(event.getPlayer()))
return;
if (event.getMessage().length() <= 12)
return;
_round.WordClicked(event.getMessage().substring(12));
}
public ArrayList<Block> getCanvas()
{
return _canvas;
}
public boolean isDrawer(Player player)
{
return _drawers.HasPlayer(player);
}
public byte getColor()
{
return _brushColor;
}
public void setLock(boolean b)
{
_lockDrawer = b;
}
}

View File

@ -3,13 +3,23 @@ package nautilus.game.arcade.game.games.draw;
import java.util.ArrayList;
import java.util.HashSet;
import nautilus.game.arcade.game.games.draw.kits.KitSelector;
import nautilus.game.arcade.game.games.draw.kits.KitSlowAndSteady;
import nautilus.game.arcade.kit.Kit;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import mineplex.core.common.jsonchat.ChildJsonMessage;
import mineplex.core.common.jsonchat.JsonMessage;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
public class DrawRound
@ -21,22 +31,75 @@ public class DrawRound
public int Revealed = 0;
public boolean[] WordReveal;
public long Time;
public double TimeMax = 50;
public double TimeMax;
public double TimeChooseMax = 10;
public HashSet<String> Guessed = new HashSet<String>();
public ArrayList<String> WordChoices;
public DrawRound(Draw draw, Player player, String word)
public DrawRound(Draw draw, Player player)
{
Host = draw;
Drawer = player;
Word = word;
Time = System.currentTimeMillis();
//Kit Modification
Kit kit = draw.GetKit(player);
//Time
if (kit != null && kit instanceof KitSlowAndSteady)
TimeMax = 60;
else
TimeMax = 50;
//Word
if (kit != null && kit instanceof KitSelector)
{
//Silence
Host.Manager.GetChat().Silence(12000, true);
WordChoices = new ArrayList<String>();
while (WordChoices.size() < 3)
WordChoices.add(draw.GetWord());
//Inform
UtilTextMiddle.display("Select Your Word", "Click on a word in Chat", 20, 60, 10, player);
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cGreen + C.Bold + "Select Your Word");
for (int i=0 ; i<WordChoices.size() ; i++)
{
ChildJsonMessage message = new JsonMessage("").color("white").extra("").color("white");
message.add("Option " + i + ": ").color("yellow");
message.add(WordChoices.get(i)).color("white").bold().click("run_command", "/selectword " + WordChoices.get(i)).hover("show_text", "Select " + WordChoices.get(i));
message.sendToPlayer(player);
}
Word = null;
}
else
{
SetWord(draw.GetWord());
}
}
public void SetWord(String word)
{
Word = word;
WordReveal = new boolean[word.length()];
for (int i=0 ; i< WordReveal.length ; i++)
WordReveal[i] = false;
Time = System.currentTimeMillis();
UtilPlayer.message(Drawer, C.cWhite + C.Bold + "You must draw: " + C.cGreen + C.Bold + Word);
Host.Manager.GetChat().SilenceEnd();
}
public boolean Guessed(Player player)
{
if (Guessed.add(player.getName()))
@ -115,7 +178,18 @@ public class DrawRound
public double GetTimePercent()
{
return (TimeMax - (double)(System.currentTimeMillis()-Time)/1000d)/45d;
if (!IsReady())
return (TimeChooseMax - (double)(System.currentTimeMillis()-Time)/1000d)/TimeChooseMax;
return (TimeMax - (double)(System.currentTimeMillis()-Time)/1000d)/TimeMax;
}
public String GetTimeString()
{
if (!IsReady())
return UtilTime.MakeStr((long)(TimeChooseMax*1000 - (double)(System.currentTimeMillis()-Time)));
return UtilTime.MakeStr((long)(TimeMax*1000 - (double)(System.currentTimeMillis()-Time)));
}
public boolean AllGuessed(ArrayList<Player> players)
@ -131,4 +205,37 @@ public class DrawRound
{
return Drawer;
}
public boolean ChooseWordUpdate()
{
if (Word == null && UtilTime.elapsed(Time, (long)(TimeChooseMax*1000)))
{
if (WordChoices.isEmpty())
{
SetWord(Host.GetWord());
}
else
{
SetWord(UtilAlg.Random(WordChoices));
}
}
return IsReady();
}
public boolean IsReady()
{
return Word != null;
}
public void WordClicked(String string)
{
if (IsReady())
return;
if (WordChoices.contains(string))
{
SetWord(string);
}
}
}

View File

@ -8,15 +8,15 @@ import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
public class KitPlayer extends Kit
public class KitSelector extends Kit
{
public KitPlayer(ArcadeManager manager)
public KitSelector(ArcadeManager manager)
{
super(manager, "Player", KitAvailability.Free,
super(manager, "Selector", KitAvailability.Gem, 4000,
new String[]
{
""
"Choose from one of three words to draw!"
},
new Perk[]

View File

@ -0,0 +1,38 @@
package nautilus.game.arcade.game.games.draw.kits;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
public class KitSlowAndSteady extends Kit
{
public KitSlowAndSteady(ArcadeManager manager)
{
super(manager, "Extra Time", KitAvailability.Free,
new String[]
{
"Receive +10 Seconds to draw!"
},
new Perk[]
{
},
EntityType.SKELETON,
new ItemStack(Material.WATCH));
}
@Override
public void GiveItems(Player player)
{
}
}

View File

@ -0,0 +1,44 @@
package nautilus.game.arcade.game.games.draw.kits;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import mineplex.core.achievement.Achievement;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
public class KitTools extends Kit
{
public KitTools(ArcadeManager manager)
{
super(manager, "Extra Tools", KitAvailability.Achievement,
new String[]
{
"Can draw lines, circles and squares!"
},
new Perk[]
{
},
EntityType.SKELETON,
null);
this.setAchievementRequirements(new Achievement[]
{
Achievement.DRAW_MY_THING_KEEN_EYE,
Achievement.DRAW_MY_THING_MR_SQUIGGLE,
Achievement.DRAW_MY_THING_PURE_LUCK,
Achievement.DRAW_MY_THING_WINS,
});
}
@Override
public void GiveItems(Player player)
{
}
}

View File

@ -0,0 +1,94 @@
package nautilus.game.arcade.game.games.draw.tools;
import java.util.HashMap;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilEvent.ActionType;
import nautilus.game.arcade.game.games.draw.Draw;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerInteractEvent;
public abstract class Tool
{
protected Draw Host;
protected Player _drawer;
protected Block _start;
protected Material _material;
protected HashMap<Block, Byte> _past = new HashMap<Block, Byte>();
protected HashMap<Block, Byte> _new = new HashMap<Block, Byte>();
public Tool(Draw host, Material mat)
{
Host = host;
_material = mat;
}
public void start(PlayerInteractEvent event)
{
if (!UtilEvent.isAction(event, ActionType.R))
return;
Block block = event.getPlayer().getTargetBlock(null, 60);
if (block == null)
return;
if (!Host.getCanvas().contains(block))
return;
if (!UtilGear.isMat(event.getPlayer().getItemInHand(), _material))
return;
_drawer = event.getPlayer();
_start = block;
Host.setLock(false);
}
public void update()
{
if (_start == null || _drawer == null)
return;
if (!_drawer.isOnline() || !Host.isDrawer(_drawer) || !_drawer.isBlocking())
{
_drawer = null;
_start = null;
_past.clear();
return;
}
_new = new HashMap<Block, Byte>();
//Calculate New
Block end = _drawer.getTargetBlock(null, 64);
if (end != null && Host.getCanvas().contains(end))
{
customDraw(end);
}
//Remove Old
for (Block block : _past.keySet())
{
if (!_new.containsKey(block))
block.setData(_past.get(block));
}
_past = _new;
_new = null;
for (Player other : UtilServer.getPlayers())
other.playSound(other.getLocation(), Sound.FIZZ, 0.2f, 2f);
}
public abstract void customDraw(Block end);
}

View File

@ -0,0 +1,57 @@
package nautilus.game.arcade.game.games.draw.tools;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import nautilus.game.arcade.game.games.draw.Draw;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
public class ToolCircle extends Tool
{
public ToolCircle(Draw host)
{
super(host, Material.DIAMOND_SWORD);
}
public void customDraw(Block end)
{
Location mid = UtilAlg.getMidpoint(_start.getLocation().add(0.5, 0.5, 0.5), end.getLocation().add(0.5, 0.5, 0.5));
double height = Math.max(_start.getY(), end.getY()) - mid.getY();
boolean planeIsZ = _start.getZ() == end.getZ();
double width = Math.max(_start.getX(), end.getX()) - mid.getX();
if (!planeIsZ)
width = Math.max(_start.getZ(), end.getZ()) - mid.getZ();
for (double i=0 ; i<Math.PI*2 ; i += 0.05)
{
double horizontal = Math.sin(i) * width;
double vertical = Math.cos(i) * height + 0.4;
color(mid.clone().add(planeIsZ ? horizontal : 0, vertical, planeIsZ ? 0 : horizontal));
}
}
public void color(Location loc)
{
Block block = loc.getBlock();
if (_new.containsKey(block))
return;
if (!Host.getCanvas().contains(block))
return;
byte color = block.getData();
if (_past.containsKey(block))
color = _past.get(block);
_new.put(block, color);
block.setData(Host.getColor());
}
}

View File

@ -0,0 +1,42 @@
package nautilus.game.arcade.game.games.draw.tools;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import nautilus.game.arcade.game.games.draw.Draw;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
public class ToolLine extends Tool
{
public ToolLine(Draw host)
{
super(host, Material.STONE_SWORD);
}
public void customDraw(Block end)
{
Location loc = _start.getLocation().add(0.5, 0.5, 0.5);
while (UtilMath.offset(loc, end.getLocation().add(0.5, 0.5, 0.5)) > 0.5)
{
loc.add(UtilAlg.getTrajectory(loc, end.getLocation().add(0.5, 0.5, 0.5)).multiply(0.5));
Block lineBlock = loc.getBlock();
if (_new.containsKey(lineBlock))
continue;
if (!Host.getCanvas().contains(lineBlock))
continue;
byte color = lineBlock.getData();
if (_past.containsKey(lineBlock))
color = _past.get(lineBlock);
_new.put(lineBlock, color);
lineBlock.setData(Host.getColor());
}
}
}

View File

@ -0,0 +1,82 @@
package nautilus.game.arcade.game.games.draw.tools;
import nautilus.game.arcade.game.games.draw.Draw;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
public class ToolSquare extends Tool
{
public ToolSquare(Draw host)
{
super(host, Material.GOLD_SWORD);
}
public void customDraw(Block end)
{
Location upper = new Location(end.getWorld(), Math.max(_start.getX(), end.getX()), Math.max(_start.getY(), end.getY()), Math.max(_start.getZ(), end.getZ()));
upper.add(0.5, 0.5, 0.5);
Location lower = new Location(end.getWorld(), Math.min(_start.getX(), end.getX()), Math.min(_start.getY(), end.getY()), Math.min(_start.getZ(), end.getZ()));
lower.add(0.5, 0.5, 0.5);
Location cur = upper.clone();
//Decrease
while (cur.getX() > lower.getX())
{
cur.setX(cur.getX() - 1);
color(cur);
}
while (cur.getY() > lower.getY())
{
cur.setY(cur.getY() - 1);
color(cur);
}
while (cur.getZ() > lower.getZ())
{
cur.setZ(cur.getZ() - 1);
color(cur);
}
//Increase
while (cur.getX() < upper.getX())
{
cur.setX(cur.getX() + 1);
color(cur);
}
while (cur.getY() < upper.getY())
{
cur.setY(cur.getY() + 1);
color(cur);
}
while (cur.getZ() < upper.getZ())
{
cur.setZ(cur.getZ() + 1);
color(cur);
}
}
public void color(Location loc)
{
Block block = loc.getBlock();
if (_new.containsKey(block))
return;
if (!Host.getCanvas().contains(block))
return;
byte color = block.getData();
if (_past.containsKey(block))
color = _past.get(block);
_new.put(block, color);
block.setData(Host.getColor());
}
}

View File

@ -1484,24 +1484,4 @@ public class HideSeek extends TeamGame
return ent.getVehicle() != null;
}
@EventHandler
public void UpdateMAC(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Player player : GetPlayers(true))
for (Player hider : GetPlayers(true))
{
if (player.equals(hider))
continue;
if (!getHiders().HasPlayer(hider))
continue;
if (UtilMath.offset(player, hider) < 2)
AntiHack.Instance.setIgnore(player, 1000);
}
}
}

View File

@ -1,7 +1,9 @@
package nautilus.game.arcade.game.games.quiver;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -25,11 +27,13 @@ import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.games.quiver.kits.*;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.stats.SharpShooterStatTracker;
@ -53,7 +57,8 @@ public class Quiver extends SoloGame
{
new KitLeaper(manager),
new KitBrawler(manager),
new KitElementalist(manager),
new KitEnchanter(manager),
new KitSlamShot(manager)
},
new String[]
@ -148,8 +153,18 @@ public class Quiver extends SoloGame
Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
if (player == null) return;
int amount = 1;
if (GetKit(player) instanceof KitSlamShot)
{
if (Manager.GetCondition().HasCondition(event.GetEvent().getEntity(), ConditionType.FALLING, null))
{
amount = 2;
}
}
//New Arrow
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(262, (byte)0, 1, F.item("Super Arrow")));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(262, (byte)0, amount, F.item("Super Arrow")));
player.playSound(player.getLocation(), Sound.PISTON_EXTEND, 3f, 2f);
//Score
@ -332,4 +347,25 @@ public class Quiver extends SoloGame
AnnounceEnd(places);
}
}
@Override
public List<Player> getWinners()
{
if (GetState().ordinal() >= GameState.End.ordinal())
{
SortScores();
//Set Places
ArrayList<Player> places = new ArrayList<Player>();
for (int i=0 ; i<_ranks.size() ; i++)
places.add(i, _ranks.get(i).Player);
if (places.isEmpty() || !places.get(0).isOnline())
return Arrays.asList();
else
return Arrays.asList(places.get(0));
}
else
return null;
}
}

View File

@ -16,9 +16,9 @@ import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.*;
public class KitElementalist extends Kit
public class KitEnchanter extends Kit
{
public KitElementalist(ArcadeManager manager)
public KitEnchanter(ArcadeManager manager)
{
super(manager, "Enchanter", KitAvailability.Gem, 5000,

View File

@ -0,0 +1,68 @@
package nautilus.game.arcade.game.games.quiver.kits;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.achievement.Achievement;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilServer;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.Game.GameState;
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 KitSlamShot extends Kit
{
public KitSlamShot(ArcadeManager manager)
{
super(manager, "Slam Shooter", KitAvailability.Achievement,
new String[]
{
"Gets 2 arrows for killing slammed players!"
},
new Perk[]
{
new PerkSeismicSlamOITQ()
},
EntityType.ZOMBIE,
new ItemStack(Material.IRON_SPADE));
this.setAchievementRequirements(new Achievement[]
{
Achievement.OITQ_PERFECTIONIST,
Achievement.OITQ_SHARPSHOOTER,
Achievement.OITQ_WHATS_A_BOW,
Achievement.OITQ_WINS,
});
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SPADE));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW));
if (Manager.GetGame().GetState() == GameState.Live)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(262, (byte)0, 1, F.item("Super Arrow")));
final Player fPlayer = player;
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
{
public void run()
{
UtilInv.Update(fPlayer);
}
}, 10);
}
}
}

View File

@ -36,6 +36,7 @@ import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTextTop;
import mineplex.core.common.util.UtilTime;
@ -140,8 +141,6 @@ public class SheepGame extends TeamGame
"Most sheep at 5 minutes wins!"
});
this.StrictAntiHack = true;
this.DeathOut = false;
this.DeathSpectateSecs = 8;
@ -233,35 +232,66 @@ public class SheepGame extends TeamGame
UtilFirework.playFirework(sheep.getLocation().add(0, 0.5, 0), FireworkEffect.builder().flicker(false).withColor(Color.WHITE).with(Type.BALL).trail(false).build());
}
// @EventHandler
// public void Stack(PlayerInteractEntityEvent event)
// {
// if (!IsLive())
// return;
//
// if (!(event.getRightClicked() instanceof Sheep))
// return;
//
// if (event.getRightClicked().getVehicle() != null)
// return;
//
// if (!Recharge.Instance.usable(event.getPlayer(), "Sheep Stack", true))
// return;
//
// SheepStack(event.getPlayer(), (Sheep)event.getRightClicked());
// }
@EventHandler
public void Stack(PlayerInteractEntityEvent event)
public void Stack(UpdateEvent event)
{
if (!IsLive())
if (event.getType() != UpdateType.TICK)
return;
if (!(event.getRightClicked() instanceof Sheep))
return;
if (event.getRightClicked().getVehicle() != null)
return;
Player player = event.getPlayer();
if (!Recharge.Instance.usable(player, "Sheep Stack"))
return;
for (Player player : GetPlayers(true))
{
if (!Recharge.Instance.usable(player, "Sheep Stack"))
return;
for (Entity ent : player.getWorld().getEntities())
{
if (!(ent instanceof Sheep))
continue;
if (ent.getVehicle() != null)
continue;
if (UtilMath.offset(player, ent) > 2.5)
continue;
if (SheepStack(player, (Sheep)ent))
break;
}
}
}
public boolean SheepStack(Player player, Sheep sheep)
{
if (player.getItemInHand() != null && player.getItemInHand().getType() != Material.SADDLE)
return;
return true;
if (event.getPlayer().getGameMode() != GameMode.SURVIVAL)
return;
if (player.getGameMode() != GameMode.SURVIVAL)
return true;
if (!IsAlive(event.getPlayer()))
return;
if (!IsAlive(player))
return true;
if (player.getPassenger() != null && player.getPassenger() instanceof Player)
{
DropSheep(player);
DropSheep(player, 500);
}
//Holding too many
@ -275,36 +305,41 @@ public class SheepGame extends TeamGame
if (count >= 3)
{
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot hold more than 3 Sheep!"));
return;
//UtilPlayer.message(player, F.main("Game", "You cannot hold more than 3 Sheep!"));
return true;
}
for (SheepData data : _sheep.values())
{
if (data.Sheep.equals(event.getRightClicked()))
if (data.Sheep.equals(sheep))
{
if (data.Owner != null && data.Owner.equals(GetTeam(event.getPlayer())) && data.IsInsideOwnPen())
if (data.Owner != null && data.Owner.equals(GetTeam(player)) && data.IsInsideOwnPen())
{
UtilPlayer.message(event.getPlayer(), F.main("Game", "You have already captured this Sheep!"));
return;
//UtilPlayer.message(player, F.main("Game", "You have already captured this Sheep!"));
return false;
}
data.SetHolder(event.getPlayer());
data.SetHolder(player);
}
}
//Put Wool in Inventory
player.getInventory().setItem(4 + count, ItemStackFactory.Instance.CreateStack(35, ((Sheep)event.getRightClicked()).getColor().getWoolData()));
player.getInventory().setItem(4 + count, ItemStackFactory.Instance.CreateStack(35, ((Sheep)sheep).getColor().getWoolData()));
UtilInv.Update(player);
//Effect
event.getRightClicked().getWorld().playEffect(event.getRightClicked().getLocation(), Effect.STEP_SOUND, 35);
sheep.getWorld().playEffect(sheep.getLocation(), Effect.STEP_SOUND, 35);
//Stack
top.setPassenger(event.getRightClicked());
top.setPassenger(sheep);
//Audio
player.playSound(player.getLocation(), Sound.SHEEP_IDLE, 2f, 3f);
//Cooldown
Recharge.Instance.useForce(player, "Sheep Stack", 500);
return true;
}
@EventHandler
@ -329,7 +364,7 @@ public class SheepGame extends TeamGame
return;
if (player.getPassenger() != null)
DropSheep(player);
DropSheep(player, 500);
if (!Recharge.Instance.usable(player, "Sheep Stack"))
return;
@ -350,22 +385,25 @@ public class SheepGame extends TeamGame
player.setPassenger(other);
//Audio
player.playSound(player.getLocation(), Sound.VILLAGER_YES, 2f, 3f);
other.playSound(player.getLocation(), Sound.VILLAGER_NO, 2f, 3f);
player.playSound(player.getLocation(), Sound.HORSE_ARMOR, 1f, 1f);
//Inform
UtilPlayer.message(other, F.main("Skill", F.elem(GetTeam(player).GetColor() + player.getName()) + " picked you up."));
UtilPlayer.message(player, F.main("Skill", "You picked up " + F.elem(GetTeam(player).GetColor() + player.getName()) + "."));
UtilPlayer.message(player, F.main("Skill", "You picked up " + F.elem(GetTeam(other).GetColor() + other.getName()) + "."));
}
@EventHandler
public void DeathDrop(PlayerDeathEvent event)
{
DropSheep(event.getEntity());
DropSheep(event.getEntity(), 0);
}
public void DropSheep(Player player)
public void DropSheep(Player player, long cooldown)
{
//Brute can only throw
if (GetKit(player) instanceof KitBrute)
return;
boolean hadSheep = false;
Entity top = player;
@ -388,12 +426,15 @@ public class SheepGame extends TeamGame
//Audio
player.playSound(player.getLocation(), Sound.SHEEP_IDLE, 2f, 1f);
//Recharge
Recharge.Instance.useForce(player, "Sheep Stack", cooldown);
}
@EventHandler
public void Drop(PlayerDropItemEvent event)
{
DropSheep(event.getPlayer());
DropSheep(event.getPlayer(), 500);
}
@EventHandler
@ -452,9 +493,24 @@ public class SheepGame extends TeamGame
UtilTextTop.displayProgress(C.Bold + "Return the Sheep to your Team Pen!", (float)count/3f, player);
}
}
@EventHandler(priority = EventPriority.LOW)
public void DamageSheepCancel(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
if (event.GetDamagerPlayer(true) != null)
{
if (event.GetDamagerPlayer(true).getPassenger() != null)
{
event.SetCancelled("SQ: Has Passenger");
}
}
}
@EventHandler(priority = EventPriority.LOW)
public void DamagePasson(CustomDamageEvent event)
public void DamagePassOn(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
@ -493,7 +549,7 @@ public class SheepGame extends TeamGame
Player player = event.GetDamageePlayer();
if (player == null) return;
DropSheep(player);
DropSheep(player, 2000);
Bukkit.getPluginManager().callEvent(new DropEnemySheepEvent(event.GetDamagerPlayer(true), player));
}

Some files were not shown because too many files have changed in this diff Show More