Merge master code into clans
This commit is contained in:
commit
f8ef46abde
11
.gitignore
vendored
11
.gitignore
vendored
@ -39,3 +39,14 @@ zBench
|
||||
zMyst
|
||||
zSotanna
|
||||
zSotanna2
|
||||
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.fdt
|
||||
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.fdx
|
||||
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.fnm
|
||||
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.frq
|
||||
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.nrm
|
||||
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.prx
|
||||
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.tii
|
||||
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.tis
|
||||
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/segments.gen
|
||||
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/segments_1
|
||||
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/write.lock
|
||||
|
@ -20,6 +20,7 @@
|
||||
<element id="module-output" name="Mineplex.Database" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.5.2.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-dbcp2-2.0.1.jar" path-in-jar="/" />
|
||||
<element id="module-output" name="Mineplex.PlayerCache" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
@ -19,6 +19,7 @@
|
||||
<element id="module-output" name="Mineplex.Database" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.5.2.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-dbcp2-2.0.1.jar" path-in-jar="/" />
|
||||
<element id="module-output" name="Mineplex.PlayerCache" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
@ -5,6 +5,7 @@
|
||||
<excludeFromCompile>
|
||||
<directory url="file://$PROJECT_DIR$/Nautilus.Game.PvP" includeSubdirectories="true" />
|
||||
<directory url="file://$PROJECT_DIR$/Mineplex.ServerMonitor" includeSubdirectories="true" />
|
||||
<directory url="file://$PROJECT_DIR$/Mineplex.Game.Clans" includeSubdirectories="true" />
|
||||
</excludeFromCompile>
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
@ -28,7 +29,9 @@
|
||||
<processorPath useClasspath="true" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
<bytecodeTargetLevel target="1.7" />
|
||||
<bytecodeTargetLevel target="1.7">
|
||||
<module name="bungee" target="1.7" />
|
||||
</bytecodeTargetLevel>
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="GENERATE_NO_WARNINGS" value="true" />
|
||||
|
@ -86,6 +86,9 @@
|
||||
<fileset dir="../Mineplex.ServerData/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Mineplex.PlayerCache/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
|
||||
<zipfileset src="../Libraries/jooq-3.5.2.jar" />
|
||||
<zipfileset src="../Libraries/httpclient-4.2.jar" />
|
||||
@ -155,6 +158,9 @@
|
||||
<fileset dir="../Mineplex.Database/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Mineplex.PlayerCache/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Mineplex.ServerData/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
@ -204,6 +210,9 @@
|
||||
<fileset dir="../Mineplex.ServerData/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Mineplex.PlayerCache/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
|
||||
<zipfileset src="../Libraries/jooq-3.5.2.jar" />
|
||||
<zipfileset src="../Libraries/httpclient-4.2.jar" />
|
||||
@ -240,6 +249,9 @@
|
||||
<fileset dir="../Mineplex.ServerData/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Mineplex.PlayerCache/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
|
||||
<zipfileset src="../Libraries/jooq-3.5.2.jar" />
|
||||
<zipfileset src="../Libraries/httpclient-4.2.jar" />
|
||||
@ -446,6 +458,34 @@
|
||||
</jar>
|
||||
<copy file="../bin/TaskConverter.jar" todir="../../Testing/ChestConverter/"/>
|
||||
</target>
|
||||
<target name ="PetConverter" description="PetConverter">
|
||||
<jar jarfile="../bin/PetConverter.jar">
|
||||
<fileset dir="../Mineplex.Core.Common/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Mineplex.PetConverter/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
|
||||
<zipfileset src="../Libraries/mysql.zip" />
|
||||
|
||||
<manifest>
|
||||
<attribute name="Main-Class"
|
||||
value="mineplex.chestConverter.PetConverter"/>
|
||||
</manifest>
|
||||
|
||||
<zipfileset src="../Libraries/httpclient-4.2.jar" />
|
||||
<zipfileset src="../Libraries/httpcore-4.2.jar" />
|
||||
<zipfileset src="../Libraries/httpclient-cache-4.2.jar" />
|
||||
<zipfileset src="../Libraries/httpmime-4.2.jar" />
|
||||
<zipfileset src="../Libraries/gson-2.2.1.jar" />
|
||||
<zipfileset src="../Libraries/craftbukkit.jar" />
|
||||
<zipfileset src="../Libraries/commons-logging-1.1.1.jar" />
|
||||
<zipfileset src="../Libraries/commons-codec-1.6.jar" />
|
||||
<zipfileset src="../Libraries/commons-pool2-2.2.jar" />
|
||||
</jar>
|
||||
<copy file="../bin/PetConverter.jar" todir="../../Testing/PetConverter/"/>
|
||||
</target>
|
||||
<target name ="Queuer" description="Queuer">
|
||||
<jar jarfile="../bin/Queuer.jar">
|
||||
<fileset dir="../Mineplex.Core.Common/bin">
|
||||
|
Binary file not shown.
@ -96,6 +96,8 @@ public class LobbyBalancer implements Listener, Runnable
|
||||
|
||||
if (timeSpentInLock > 50)
|
||||
System.out.println("[==] TIMING [==] Locked loading servers for " + timeSpentInLock + "ms");
|
||||
|
||||
_lobbyIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.bungee.motd;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -7,9 +8,13 @@ import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.data.BungeeServer;
|
||||
import mineplex.serverdata.data.DataRepository;
|
||||
import mineplex.serverdata.redis.RedisDataRepository;
|
||||
import mineplex.serverdata.servers.ConnectionData;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
import mineplex.serverdata.servers.ConnectionData.ConnectionType;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
@ -20,7 +25,9 @@ public class MotdManager implements Listener, Runnable
|
||||
private Plugin _plugin;
|
||||
|
||||
private DataRepository<GlobalMotd> _repository;
|
||||
|
||||
private DataRepository<GlobalMotd> _secondRepository;
|
||||
private Region _region;
|
||||
|
||||
private Random _random = new Random();
|
||||
private String _firstLine = " §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r";
|
||||
private List<String> _motdLines;
|
||||
@ -28,6 +35,7 @@ public class MotdManager implements Listener, Runnable
|
||||
public MotdManager(Plugin plugin)
|
||||
{
|
||||
_plugin = plugin;
|
||||
_region = !new File("eu.dat").exists() ? Region.US : Region.EU;
|
||||
|
||||
_plugin.getProxy().getScheduler().schedule(_plugin, this, 5L, 30L, TimeUnit.SECONDS);
|
||||
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
|
||||
@ -38,12 +46,21 @@ public class MotdManager implements Listener, Runnable
|
||||
|
||||
if (new File("updateMOTD.dat").exists())
|
||||
{
|
||||
List<String> lines = new ArrayList<String>();
|
||||
lines.add(" §f§l◄ §6§lNEW §f§l▬ §c§lSSM/SG/SW Teams§f§l ▬ §c§lMPS Update §f§l►");
|
||||
//lines.add(" §d§lRank Sale §a§l40% Off");
|
||||
//lines.add(" §f§l◄§c§lMAINTENANCE§f§l►");
|
||||
if (_region == Region.US)
|
||||
_secondRepository = new RedisDataRepository<GlobalMotd>(new ConnectionData("10.81.1.156", 6379, ConnectionType.MASTER, "ServerStatus"), new ConnectionData("10.81.1.156", 6377, ConnectionType.SLAVE, "ServerStatus"),
|
||||
Region.ALL, GlobalMotd.class, "globalMotd");
|
||||
else
|
||||
_secondRepository = new RedisDataRepository<GlobalMotd>(new ConnectionData("10.33.53.16", 6379, ConnectionType.MASTER, "ServerStatus"), new ConnectionData("10.33.53.16", 6377, ConnectionType.SLAVE, "ServerStatus"),
|
||||
Region.ALL, GlobalMotd.class, "globalMotd");
|
||||
|
||||
updateMainMotd(" §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r", lines);
|
||||
//String motdLine = "§f§l◄ §c§lMaintenance§f§l ►";
|
||||
//String motdLine = "§f§l◄ §a§lCarl the Creeper§f§l ►";
|
||||
String motdLine = " §b§l◄§f§lNEW GAME§b§l► §f§l◄§b§lEVOLUTION§f§l► §b§l◄§f§lNEW GAME§b§l►";
|
||||
//String motdLine = " §f§l◄ §a§lCarl the Creeper§f§l ▬ §c§l75% OFF SALE§f§l ►";
|
||||
//String motdLine = " §d§lRank Sale §a§l40% Off");
|
||||
//String motdLine = " §f§l◄§c§lMAINTENANCE§f§l►");
|
||||
|
||||
updateMainMotd(" §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r", motdLine);
|
||||
System.out.println("Updated Bungee MOTD");
|
||||
}
|
||||
}
|
||||
@ -68,7 +85,7 @@ public class MotdManager implements Listener, Runnable
|
||||
GlobalMotd motd = _repository.getElement("MainMotd");
|
||||
|
||||
if (motd != null)
|
||||
{
|
||||
{
|
||||
_motdLines = motd.getMotd();
|
||||
_firstLine = motd.getHeadline();
|
||||
}
|
||||
@ -78,9 +95,14 @@ public class MotdManager implements Listener, Runnable
|
||||
* Update the main {@link GlobalMotd} determining the MOTD for Bungee instances.
|
||||
* @param motdLines - the lines to update the MOTD to.
|
||||
*/
|
||||
public void updateMainMotd(String headline, List<String> motdLines)
|
||||
public void updateMainMotd(String headline, String motdLine)
|
||||
{
|
||||
List<String> motdLines = new ArrayList<String>();
|
||||
|
||||
motdLines.add(motdLine);
|
||||
|
||||
_repository.addElement(new GlobalMotd("MainMotd", headline, motdLines));
|
||||
_secondRepository.addElement(new GlobalMotd("MainMotd", headline, motdLines));
|
||||
}
|
||||
|
||||
public List<String> getMotdLines()
|
||||
|
@ -24,7 +24,6 @@ public class PlayerCount implements Listener, Runnable
|
||||
{
|
||||
private DataRepository<BungeeServer> _repository;
|
||||
private DataRepository<BungeeServer> _secondRepository;
|
||||
private UUID _uuid;
|
||||
private Region _region;
|
||||
|
||||
private ListenerInfo _listenerInfo;
|
||||
@ -34,7 +33,6 @@ public class PlayerCount implements Listener, Runnable
|
||||
|
||||
public PlayerCount(Plugin plugin)
|
||||
{
|
||||
_uuid = UUID.randomUUID();
|
||||
_region = !new File("eu.dat").exists() ? Region.US : Region.EU;
|
||||
_plugin = plugin;
|
||||
|
||||
@ -86,7 +84,7 @@ public class PlayerCount implements Listener, Runnable
|
||||
*/
|
||||
private BungeeServer generateSnapshot()
|
||||
{
|
||||
String name = _uuid.toString(); // Use random UUID for unique id name.
|
||||
String name = _listenerInfo.getHost().getAddress().getHostAddress();
|
||||
String host = _listenerInfo.getHost().getAddress().getHostAddress();
|
||||
int port = _listenerInfo.getHost().getPort();
|
||||
boolean connected = InternetStatus.isConnected();
|
||||
|
@ -1,6 +1,5 @@
|
||||
package mineplex.bungee.playerStats;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -17,9 +16,8 @@ import net.md_5.bungee.event.EventHandler;
|
||||
public class PlayerStats implements Listener, Runnable
|
||||
{
|
||||
private Plugin _plugin;
|
||||
private PlayerStatsRepository _repository;
|
||||
private PlayerStatsRepository _repository;
|
||||
|
||||
private PlayerCache _playerCache = new PlayerCache();
|
||||
private HashSet<UUID> _retrievingPlayerInfo = new HashSet<UUID>();
|
||||
|
||||
public PlayerStats(Plugin plugin)
|
||||
@ -52,7 +50,7 @@ public class PlayerStats implements Listener, Runnable
|
||||
|
||||
boolean addOrUpdatePlayer = false;
|
||||
|
||||
playerInfo = _playerCache.getPlayer(uuid);
|
||||
playerInfo = PlayerCache.getInstance().getPlayer(uuid);
|
||||
|
||||
if (playerInfo == null)
|
||||
{
|
||||
@ -80,11 +78,11 @@ public class PlayerStats implements Listener, Runnable
|
||||
}
|
||||
else
|
||||
playerInfo = updatedPlayerInfo;
|
||||
|
||||
_playerCache.addPlayer(playerInfo);
|
||||
}
|
||||
|
||||
playerInfo.setSessionId(_repository.updatePlayerStats(playerInfo.getId(), ipInfo.id));
|
||||
playerInfo.updateLoginTime();
|
||||
PlayerCache.getInstance().addPlayer(playerInfo);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -105,13 +103,13 @@ public class PlayerStats implements Listener, Runnable
|
||||
|
||||
PlayerInfo playerInfo = null;
|
||||
|
||||
playerInfo = _playerCache.getPlayer(uuid);
|
||||
playerInfo = PlayerCache.getInstance().getPlayer(uuid);
|
||||
|
||||
int timeout = 5;
|
||||
|
||||
while (playerInfo == null && _retrievingPlayerInfo.contains(uuid) && timeout <= 5)
|
||||
{
|
||||
playerInfo = _playerCache.getPlayer(uuid);
|
||||
playerInfo = PlayerCache.getInstance().getPlayer(uuid);
|
||||
|
||||
if (playerInfo != null)
|
||||
break;
|
||||
@ -130,6 +128,7 @@ public class PlayerStats implements Listener, Runnable
|
||||
timeout++;
|
||||
}
|
||||
|
||||
System.out.println(playerInfo.getName() + ":" + playerInfo.getSessionId());
|
||||
_repository.updatePlayerSession(playerInfo.getSessionId());
|
||||
}
|
||||
});
|
||||
@ -138,6 +137,6 @@ public class PlayerStats implements Listener, Runnable
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
_playerCache.clean();
|
||||
PlayerCache.getInstance().clean();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
package mineplex.bungee.playerTracker;
|
||||
|
||||
import mineplex.serverdata.commands.CommandCallback;
|
||||
import mineplex.serverdata.commands.PlayerJoinCommand;
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class PlayerJoinHandler implements CommandCallback
|
||||
{
|
||||
private PlayerTracker _playerTracker;
|
||||
|
||||
public PlayerJoinHandler(PlayerTracker playerTracker)
|
||||
{
|
||||
_playerTracker = playerTracker;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void run(ServerCommand command)
|
||||
{
|
||||
if (command instanceof PlayerJoinCommand)
|
||||
{
|
||||
PlayerJoinCommand joinCommand = (PlayerJoinCommand)command;
|
||||
|
||||
_playerTracker.kickPlayerIfOnline(joinCommand.getUuid());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +1,25 @@
|
||||
package mineplex.bungee.playerTracker;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.commands.ServerCommandManager;
|
||||
import mineplex.serverdata.data.DataRepository;
|
||||
import mineplex.serverdata.data.PlayerStatus;
|
||||
import mineplex.serverdata.redis.RedisDataRepository;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.api.event.ServerConnectedEvent;
|
||||
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
|
||||
public class PlayerTracker implements Listener, Runnable
|
||||
{
|
||||
// Default period before status expiry (8 hours)
|
||||
private static final int DEFAULT_STATUS_TIMEOUT = 60 * 60 * 8;
|
||||
@ -21,6 +27,8 @@ public class PlayerTracker implements Listener
|
||||
// Repository storing player status' across network.
|
||||
private DataRepository<PlayerStatus> _repository;
|
||||
|
||||
private HashSet<String> _onlineUUIDs = new HashSet<String>();
|
||||
|
||||
private Plugin _plugin;
|
||||
|
||||
public PlayerTracker(Plugin plugin)
|
||||
@ -28,11 +36,14 @@ public class PlayerTracker implements Listener
|
||||
_plugin = plugin;
|
||||
|
||||
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
|
||||
_plugin.getProxy().getScheduler().schedule(_plugin, this, 1L, 1L, TimeUnit.MINUTES);
|
||||
|
||||
Region region = !new File("eu.dat").exists() ? Region.US : Region.EU;
|
||||
_repository = new RedisDataRepository<PlayerStatus>(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(),
|
||||
region, PlayerStatus.class, "playerStatus");
|
||||
|
||||
ServerCommandManager.getInstance().registerCommandType("PlayerJoinCommand", mineplex.serverdata.commands.PlayerJoinCommand.class, new PlayerJoinHandler(this));
|
||||
|
||||
System.out.println("Initialized PlayerTracker.");
|
||||
}
|
||||
|
||||
@ -59,5 +70,42 @@ public class PlayerTracker implements Listener
|
||||
_repository.removeElement(event.getPlayer().getName().toLowerCase());
|
||||
}
|
||||
});
|
||||
|
||||
_onlineUUIDs.remove(event.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerConnect(final PostLoginEvent event)
|
||||
{
|
||||
_onlineUUIDs.add(event.getPlayer().getUniqueId().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
HashSet<String> onlineUUIDs = new HashSet<String>();
|
||||
|
||||
for (ProxiedPlayer player : _plugin.getProxy().getPlayers())
|
||||
{
|
||||
onlineUUIDs.add(player.getUniqueId().toString());
|
||||
}
|
||||
|
||||
_onlineUUIDs = onlineUUIDs;
|
||||
}
|
||||
|
||||
public boolean isPlayerOnline(String uuid)
|
||||
{
|
||||
return _onlineUUIDs.contains(uuid);
|
||||
}
|
||||
|
||||
public void kickPlayerIfOnline(String uuid)
|
||||
{
|
||||
if (_onlineUUIDs.contains(uuid))
|
||||
{
|
||||
ProxiedPlayer player = _plugin.getProxy().getPlayer(UUID.fromString(uuid));
|
||||
|
||||
if (player != null)
|
||||
player.disconnect("You have logged in from another location.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ public class BungeeRotator
|
||||
else
|
||||
euPlayers += server.getPlayerCount();
|
||||
|
||||
System.out.println(server.getRegion().toString() + " " + server.getPublicAddress() + " " + server.getPlayerCount() + "/" + server.getPlayerCount());
|
||||
System.out.println(server.getRegion().toString() + " " + server.getName() + " " + server.getPublicAddress() + " " + server.getPlayerCount() + "/" + server.getPlayerCount());
|
||||
}
|
||||
|
||||
System.out.println("US Players : " + usPlayers);
|
||||
@ -247,6 +247,9 @@ public class BungeeRotator
|
||||
new ApiDeleteCall("https://api.dnsmadeeasy.com/V2.0/dns/managed/", 962728, "/records?" + idBuilder.toString()).Execute();
|
||||
log("Deleted " + recordsToDelete.size() + " records.");
|
||||
}
|
||||
|
||||
_repository.clean();
|
||||
_secondRepository.clean();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -10,6 +10,7 @@
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value=""/>
|
||||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${BUILD_FILES}/common.xml"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/>
|
||||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
|
||||
|
@ -1,11 +1,20 @@
|
||||
package mineplex.chestConverter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.FileHandler;
|
||||
import java.util.logging.Formatter;
|
||||
import java.util.logging.LogRecord;
|
||||
@ -18,8 +27,23 @@ public class ChestConverter
|
||||
|
||||
private static Logger _logger = Logger.getLogger("Converter");
|
||||
|
||||
private static String _connectionString = "jdbc:mysql://db.mineplex.com:3306/Account?allowMultiQueries=true";
|
||||
private static String _userName = "MilitaryPolice";
|
||||
private static String _password = "CUPr6Wuw2Rus$qap";
|
||||
|
||||
private static Connection _connection;
|
||||
|
||||
public static void main (String args[])
|
||||
{
|
||||
try
|
||||
{
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
}
|
||||
catch (ClassNotFoundException e1)
|
||||
{
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
FileHandler fileHandler = new FileHandler("converter.log", true);
|
||||
@ -38,72 +62,138 @@ public class ChestConverter
|
||||
{
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
_repository = new ChestConverterRepository();
|
||||
int lastId = 18279475;
|
||||
int count = 50000;
|
||||
int numOfRowsProcessed = lastId;
|
||||
|
||||
HashMap<String, Integer> tasks = _repository.getTaskList();
|
||||
int limit = 50000;
|
||||
HashSet<AccountStat> accountStats = new HashSet<AccountStat>();
|
||||
|
||||
try
|
||||
while (true)
|
||||
{
|
||||
while (true)
|
||||
accountStats.clear();
|
||||
|
||||
try
|
||||
{
|
||||
long time = System.currentTimeMillis();
|
||||
HashMap<String, List<Integer>> playerMap = new HashMap<String, List<Integer>>();
|
||||
Statement statement = null;
|
||||
|
||||
|
||||
List<AccountTask> taskList = _repository.getTasks(lastId, count);
|
||||
|
||||
if (taskList != null && taskList.size() > 0)
|
||||
try
|
||||
{
|
||||
for (AccountTask task : taskList)
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
statement = _connection.createStatement();
|
||||
|
||||
statement.execute("SELECT accountId, statId, value FROM Account.accountStats LIMIT " + limit + ";");
|
||||
|
||||
ResultSet resultSet = statement.getResultSet();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
if (!playerMap.containsKey(task.UUID))
|
||||
playerMap.put(task.UUID, new ArrayList<Integer>());
|
||||
accountStats.add(new AccountStat(resultSet.getInt(1), resultSet.getInt(2), resultSet.getInt(3)));
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (statement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (accountStats.size() == 0)
|
||||
{
|
||||
System.out.println("No accounts.");
|
||||
return;
|
||||
}
|
||||
|
||||
PreparedStatement updateStatement = null;
|
||||
PreparedStatement insertStatement = null;
|
||||
Statement deleteStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
_connection.setAutoCommit(true);
|
||||
updateStatement = _connection.prepareStatement("UPDATE accountStat SET value = value + ? WHERE accountId = ? AND statId = ? AND value < ?;");
|
||||
|
||||
for (AccountStat stat : accountStats)
|
||||
{
|
||||
updateStatement.setLong(1, stat.value);
|
||||
updateStatement.setInt(2, stat.accountId);
|
||||
updateStatement.setInt(3, stat.statId);
|
||||
updateStatement.setLong(4, stat.value);
|
||||
|
||||
playerMap.get(task.UUID).add(tasks.get(task.Task));
|
||||
|
||||
if (task.Id > lastId)
|
||||
lastId = task.Id;
|
||||
updateStatement.addBatch();
|
||||
}
|
||||
|
||||
_repository.incrementClients(playerMap);
|
||||
try
|
||||
int[] rowsAffected = updateStatement.executeBatch();
|
||||
_connection.setAutoCommit(false);
|
||||
int i = 0;
|
||||
int count = 0;
|
||||
|
||||
log("Updated rows - " + limit);
|
||||
|
||||
insertStatement = _connection.prepareStatement("INSERT IGNORE accountStat(accountId, statId, value) VALUES (?, ?, ?);");
|
||||
|
||||
for (AccountStat stat : accountStats)
|
||||
{
|
||||
numOfRowsProcessed += count;
|
||||
log("Natural sleep. " + count + " took " + (System.currentTimeMillis() - time) / 1000 + " seconds. Count = " + + numOfRowsProcessed);
|
||||
Thread.sleep(100);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
if (rowsAffected[i] < 1)
|
||||
{
|
||||
insertStatement.setInt(1, stat.accountId);
|
||||
insertStatement.setInt(2, stat.statId);
|
||||
insertStatement.setLong(3, stat.value);
|
||||
|
||||
insertStatement.addBatch();
|
||||
count++;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
insertStatement.executeBatch();
|
||||
log("Inserted rows - " + count);
|
||||
|
||||
deleteStatement = _connection.createStatement();
|
||||
deleteStatement.executeUpdate("DELETE FROM accountStats LIMIT " + limit + ";");
|
||||
|
||||
_connection.commit();
|
||||
|
||||
log("Deleted rows - " + limit);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (statement != null)
|
||||
{
|
||||
e.printStackTrace();
|
||||
try
|
||||
{
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (numOfRowsProcessed > 17000000)
|
||||
{
|
||||
System.out.println("Count : " + numOfRowsProcessed);
|
||||
_logger.info("Count : " + numOfRowsProcessed);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("No greater than 17 mil");
|
||||
_logger.info("No greater than 17 mil");
|
||||
System.out.println("Count : " + numOfRowsProcessed);
|
||||
_logger.info("Count : " + numOfRowsProcessed);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.info(e.getMessage());
|
||||
}
|
||||
finally
|
||||
{
|
||||
System.out.println("Count : " + numOfRowsProcessed);
|
||||
_logger.info("Count : " + numOfRowsProcessed);
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.info(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
public enum Rank
|
||||
{
|
||||
//Staff
|
||||
LT("LT", ChatColor.DARK_RED),
|
||||
OWNER("Owner", ChatColor.DARK_RED),
|
||||
DEVELOPER("Dev", ChatColor.RED),
|
||||
@ -21,36 +22,48 @@ public enum Rank
|
||||
MEDIA("Media", ChatColor.BLUE),
|
||||
|
||||
EVENT("Event", ChatColor.WHITE),
|
||||
|
||||
//Staff ^^
|
||||
|
||||
|
||||
//Media
|
||||
YOUTUBE("YouTube", ChatColor.RED),
|
||||
YOUTUBE_SMALL("MooTube", ChatColor.DARK_PURPLE),
|
||||
TWITCH("Twitch", ChatColor.DARK_PURPLE),
|
||||
LEGEND("Legend", ChatColor.GREEN),
|
||||
HERO("Hero", ChatColor.LIGHT_PURPLE),
|
||||
ULTRA("Ultra", ChatColor.AQUA),
|
||||
|
||||
//Player
|
||||
LEGEND("Legend", ChatColor.GREEN, true),
|
||||
HERO("Hero", ChatColor.LIGHT_PURPLE, true),
|
||||
ULTRA("Ultra", ChatColor.AQUA, true),
|
||||
ALL("", ChatColor.WHITE);
|
||||
|
||||
private ChatColor Color;
|
||||
private ChatColor _color;
|
||||
private boolean _donor;
|
||||
|
||||
public String Name;
|
||||
|
||||
Rank(String name, ChatColor color)
|
||||
{
|
||||
Color = color;
|
||||
_color = color;
|
||||
Name = name;
|
||||
_donor = false;
|
||||
}
|
||||
|
||||
public boolean Has(Rank rank)
|
||||
Rank(String name, ChatColor color, boolean donor)
|
||||
{
|
||||
return Has(null, rank, false);
|
||||
_color = color;
|
||||
Name = name;
|
||||
_donor = donor;
|
||||
}
|
||||
|
||||
public boolean Has(Player player, Rank rank, boolean inform)
|
||||
public boolean has(Rank rank)
|
||||
{
|
||||
return Has(player, rank, null, inform);
|
||||
return has(null, rank, false);
|
||||
}
|
||||
|
||||
public boolean Has(Player player, Rank rank, Rank[] specific, boolean inform)
|
||||
public boolean has(Player player, Rank rank, boolean inform)
|
||||
{
|
||||
return has(player, rank, null, inform);
|
||||
}
|
||||
|
||||
public boolean has(Player player, Rank rank, Rank[] specific, boolean inform)
|
||||
{
|
||||
//Specific Rank
|
||||
if (specific != null)
|
||||
@ -79,7 +92,7 @@ public enum Rank
|
||||
return false;
|
||||
}
|
||||
|
||||
public String GetTag(boolean bold, boolean uppercase)
|
||||
public String getTag(boolean bold, boolean uppercase)
|
||||
{
|
||||
if (Name.equalsIgnoreCase("ALL"))
|
||||
return "";
|
||||
@ -88,12 +101,17 @@ public enum Rank
|
||||
if (uppercase)
|
||||
name = Name.toUpperCase();
|
||||
|
||||
if (bold) return Color + C.Bold + name;
|
||||
else return Color + name;
|
||||
if (bold) return _color + C.Bold + name;
|
||||
else return _color + name;
|
||||
}
|
||||
|
||||
public ChatColor GetColor()
|
||||
public ChatColor getColor()
|
||||
{
|
||||
return Color;
|
||||
return _color;
|
||||
}
|
||||
|
||||
public boolean isDonor()
|
||||
{
|
||||
return _donor;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
package mineplex.core.common.structs;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class ItemContainer
|
||||
{
|
||||
public Material Type;
|
||||
public byte Data;
|
||||
public String Name;
|
||||
|
||||
public ItemContainer(Material type, byte data, String name)
|
||||
{
|
||||
Type = type;
|
||||
Data = data;
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public ItemContainer(int id, byte data, String name)
|
||||
{
|
||||
Type = Material.getMaterial(id);
|
||||
Data = data;
|
||||
Name = name;
|
||||
}
|
||||
}
|
@ -95,15 +95,15 @@ public class F
|
||||
|
||||
public static String help(String cmd, String body, Rank rank)
|
||||
{
|
||||
return rank.GetColor() + cmd + " " + C.mBody + body + " " + rank(rank);
|
||||
return rank.getColor() + cmd + " " + C.mBody + body + " " + rank(rank);
|
||||
}
|
||||
|
||||
public static String rank(Rank rank)
|
||||
{
|
||||
if (rank == Rank.ALL)
|
||||
return rank.GetColor() + "Player";
|
||||
return rank.getColor() + "Player";
|
||||
|
||||
return rank.GetTag(false, false);
|
||||
return rank.getTag(false, false);
|
||||
}
|
||||
|
||||
public static String value(String variable, String value)
|
||||
|
@ -69,6 +69,11 @@ public class MapUtil
|
||||
{
|
||||
QuickChangeBlockAt(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), setTo);
|
||||
}
|
||||
|
||||
public static void QuickChangeBlockAt(Location location, Material setTo, byte data)
|
||||
{
|
||||
QuickChangeBlockAt(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), setTo, data);
|
||||
}
|
||||
|
||||
public static void QuickChangeBlockAt(Location location, int id, byte data)
|
||||
{
|
||||
|
@ -7,10 +7,8 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
|
||||
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -263,6 +261,25 @@ public class UtilAlg
|
||||
return bestLoc;
|
||||
}
|
||||
|
||||
public static Location findFurthest(Location mid, ArrayList<Location> locs)
|
||||
{
|
||||
Location bestLoc = null;
|
||||
double bestDist = 0;
|
||||
|
||||
for (Location loc : locs)
|
||||
{
|
||||
double dist = UtilMath.offset(mid, loc);
|
||||
|
||||
if (bestLoc == null || dist > bestDist)
|
||||
{
|
||||
bestLoc = loc;
|
||||
bestDist = dist;
|
||||
}
|
||||
}
|
||||
|
||||
return bestLoc;
|
||||
}
|
||||
|
||||
public static boolean isInPyramid(Vector a, Vector b, double angleLimit)
|
||||
{
|
||||
return (Math.abs(GetPitch(a) - GetPitch(b)) < angleLimit) && (Math.abs(GetYaw(a) - GetYaw(b)) < angleLimit);
|
||||
@ -310,6 +327,42 @@ public class UtilAlg
|
||||
return bestLoc;
|
||||
}
|
||||
|
||||
public static Location getLocationAwayFromOtherLocations(ArrayList<Location> locs, ArrayList<Location> players)
|
||||
{
|
||||
Location bestLoc = null;
|
||||
double bestDist = 0;
|
||||
|
||||
for (Location loc : locs)
|
||||
{
|
||||
double closest = -1;
|
||||
|
||||
for (Location player : players)
|
||||
{
|
||||
//Different Worlds
|
||||
if (!player.getWorld().equals(loc.getWorld()))
|
||||
continue;
|
||||
|
||||
double dist = UtilMath.offsetSquared(player, loc);
|
||||
|
||||
if (closest == -1 || dist < closest)
|
||||
{
|
||||
closest = dist;
|
||||
}
|
||||
}
|
||||
|
||||
if (closest == -1)
|
||||
continue;
|
||||
|
||||
if (bestLoc == null || closest > bestDist)
|
||||
{
|
||||
bestLoc = loc;
|
||||
bestDist = closest;
|
||||
}
|
||||
}
|
||||
|
||||
return bestLoc;
|
||||
}
|
||||
|
||||
public static Location getLocationNearPlayers(ArrayList<Location> locs, ArrayList<Player> players, ArrayList<Player> dontOverlap)
|
||||
{
|
||||
Location bestLoc = null;
|
||||
@ -365,6 +418,23 @@ public class UtilAlg
|
||||
|
||||
return bestLoc;
|
||||
}
|
||||
|
||||
public static Location getNearestCornerLocation(Location near, Block block)
|
||||
{
|
||||
ArrayList<Location> corners = new ArrayList<Location>();
|
||||
|
||||
corners.add(block.getLocation().clone());
|
||||
corners.add(block.getLocation().clone().add(.999, 0, 0));
|
||||
corners.add(block.getLocation().clone().add(.999, 0, .999));
|
||||
corners.add(block.getLocation().clone().add(0, 0, .999));
|
||||
|
||||
corners.add(block.getLocation().clone().add(0, .999, 0));
|
||||
corners.add(block.getLocation().clone().add(.999, .999, 0));
|
||||
corners.add(block.getLocation().clone().add(.999, .999, .999));
|
||||
corners.add(block.getLocation().clone().add(0, .999, .999));
|
||||
|
||||
return UtilAlg.findClosest(near, corners);
|
||||
}
|
||||
|
||||
public static Vector calculateVelocity(Vector from, Vector to, double heightGain, Entity entity)
|
||||
{
|
||||
|
@ -5,6 +5,7 @@ import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_7_R4.EntityBat;
|
||||
import net.minecraft.server.v1_7_R4.EntityCreature;
|
||||
import net.minecraft.server.v1_7_R4.EntityEnderDragon;
|
||||
@ -26,7 +27,9 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftCreature;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity;
|
||||
import org.bukkit.entity.Creature;
|
||||
@ -36,8 +39,6 @@ import org.bukkit.entity.Giant;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftCreature;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
|
||||
public class UtilEnt
|
||||
{
|
||||
@ -495,10 +496,14 @@ public class UtilEnt
|
||||
|
||||
public static boolean isGrounded(Entity ent)
|
||||
{
|
||||
if (ent instanceof CraftEntity)
|
||||
return ((CraftEntity)ent).getHandle().onGround;
|
||||
|
||||
return UtilBlock.solid(ent.getLocation().getBlock().getRelative(BlockFace.DOWN));
|
||||
AxisAlignedBB box = ((CraftEntity)ent).getHandle().boundingBox;
|
||||
Location bottom_corner_1 = new Location(ent.getWorld(), box.a, ent.getLocation().getY()-0.1, box.c);
|
||||
Location bottom_corner_2 = new Location(ent.getWorld(), box.d, ent.getLocation().getY()-0.1, box.f);
|
||||
|
||||
for(Block b : UtilBlock.getInBoundingBox(bottom_corner_1, bottom_corner_2)){
|
||||
if(UtilBlock.solid(b)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void PlayDamageSound(LivingEntity damagee)
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
@ -8,6 +10,7 @@ import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftFirework;
|
||||
import org.bukkit.entity.Firework;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.meta.FireworkMeta;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@ -68,5 +71,29 @@ public class UtilFirework
|
||||
public static void playFirework(Location loc, Type type, Color color, boolean flicker, boolean trail)
|
||||
{
|
||||
playFirework(loc, FireworkEffect.builder().flicker(flicker).withColor(color).with(type).trail(trail).build());
|
||||
}
|
||||
|
||||
public static void packetPlayFirework(Player player, Location loc, Type type, Color color, boolean flicker, boolean trail)
|
||||
{
|
||||
Firework firework = (Firework) loc.getWorld().spawn(loc, Firework.class);
|
||||
FireworkEffect effect = FireworkEffect.builder().flicker(flicker).withColor(color).with(type).trail(trail).build();
|
||||
|
||||
FireworkMeta data = (FireworkMeta) firework.getFireworkMeta();
|
||||
data.clearEffects();
|
||||
data.setPower(1);
|
||||
data.addEffect(effect);
|
||||
firework.setFireworkMeta(data);
|
||||
|
||||
((CraftFirework) firework).getHandle().expectedLifespan = 1;
|
||||
|
||||
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(firework.getEntityId());
|
||||
|
||||
for (Player viewing : UtilServer.getPlayers())
|
||||
{
|
||||
if (player == viewing)
|
||||
continue;
|
||||
|
||||
UtilPlayer.sendPacket(viewing, packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,22 +4,28 @@ import java.util.AbstractMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import mineplex.core.common.structs.ItemContainer;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class UtilItem
|
||||
{
|
||||
public static LinkedList<Entry<Material, Byte>> matchItem(Player caller, String items, boolean inform)
|
||||
private static final Material[] FOOD_LIST = { Material.APPLE, Material.BAKED_POTATO, Material.BREAD, Material.CARROT, Material.CARROT_ITEM, Material.COOKED_CHICKEN,
|
||||
Material.COOKED_FISH, Material.GRILLED_PORK, Material.COOKIE, Material.GOLDEN_APPLE, Material.GOLDEN_CARROT, Material.MELON, Material.MUSHROOM_SOUP, Material.POISONOUS_POTATO,
|
||||
Material.PUMPKIN_PIE, Material.RAW_BEEF, Material.RAW_CHICKEN, Material.RAW_FISH, Material.PORK, Material.ROTTEN_FLESH, Material.SPIDER_EYE, Material.COOKED_BEEF};
|
||||
|
||||
public static LinkedList<ItemContainer> matchItem(Player caller, String items, boolean inform)
|
||||
{
|
||||
LinkedList<Entry<Material, Byte>> matchList = new LinkedList<Entry<Material, Byte>>();
|
||||
LinkedList<ItemContainer> matchList = new LinkedList<ItemContainer>();
|
||||
|
||||
String failList = "";
|
||||
|
||||
//Mass Search
|
||||
for (String cur : items.split(","))
|
||||
{
|
||||
Entry<Material, Byte> match = searchItem(caller, cur, inform);
|
||||
ItemContainer match = searchItem(caller, cur, inform);
|
||||
|
||||
if (match != null)
|
||||
matchList.add(match);
|
||||
@ -40,21 +46,27 @@ public class UtilItem
|
||||
return matchList;
|
||||
}
|
||||
|
||||
public static Entry<Material, Byte> searchItem(Player caller, String args, boolean inform)
|
||||
public static ItemContainer searchItem(Player caller, String args, boolean inform)
|
||||
{
|
||||
LinkedList<Entry<Material, Byte>> matchList = new LinkedList<Entry<Material, Byte>>();
|
||||
LinkedList<ItemContainer> matchList = new LinkedList<ItemContainer>();
|
||||
|
||||
for (Material cur : Material.values())
|
||||
{
|
||||
String[] arg = args.split(":");
|
||||
|
||||
//Get Selected Name
|
||||
String name = null;
|
||||
if (arg.length > 2)
|
||||
name = arg[2].replaceAll("_", " ");
|
||||
|
||||
//By Name
|
||||
if (cur.toString().equalsIgnoreCase(args))
|
||||
return new AbstractMap.SimpleEntry<Material, Byte>(cur, (byte)0);
|
||||
return new ItemContainer(cur, (byte)0, name);
|
||||
|
||||
if (cur.toString().toLowerCase().contains(args.toLowerCase()))
|
||||
matchList.add(new AbstractMap.SimpleEntry<Material, Byte>(cur, (byte)0));
|
||||
matchList.add(new ItemContainer(cur, (byte)0, name));
|
||||
|
||||
//By ID:Data
|
||||
String[] arg = args.split(":");
|
||||
//By ID:Data:Name
|
||||
|
||||
//ID
|
||||
int id = 0;
|
||||
@ -82,8 +94,8 @@ public class UtilItem
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
return new AbstractMap.SimpleEntry<Material, Byte>(cur, data);
|
||||
|
||||
return new ItemContainer(cur, data, name);
|
||||
}
|
||||
|
||||
//No / Non-Unique
|
||||
@ -102,8 +114,9 @@ public class UtilItem
|
||||
if (matchList.size() > 0)
|
||||
{
|
||||
String matchString = "";
|
||||
for (Entry<Material, Byte> cur : matchList)
|
||||
matchString += F.elem(cur.getKey().toString()) + ", ";
|
||||
for (ItemContainer cur : matchList)
|
||||
matchString += F.elem(cur.Type.toString()) + ", ";
|
||||
|
||||
if (matchString.length() > 1)
|
||||
matchString = matchString.substring(0 , matchString.length() - 2);
|
||||
|
||||
@ -128,6 +141,22 @@ public class UtilItem
|
||||
return item.getType() + ":" + item.getAmount() + ":" + item.getDurability() + ":" + data;
|
||||
}
|
||||
|
||||
public static boolean isFood(ItemStack item)
|
||||
{
|
||||
return item == null ? false : isFood(item.getType());
|
||||
}
|
||||
|
||||
public static boolean isFood(Material material)
|
||||
{
|
||||
for (Material food : FOOD_LIST)
|
||||
{
|
||||
if (food.equals(material))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item - the item to be checked for material type
|
||||
* @param material - the material to check if it matches
|
||||
|
@ -6,23 +6,23 @@ public class UtilSkull
|
||||
{
|
||||
public static byte getSkullData(Entity entity)
|
||||
{
|
||||
if (entity instanceof Skeleton)
|
||||
{
|
||||
Skeleton sk = ((Skeleton) entity);
|
||||
if (sk.getSkeletonType() == Skeleton.SkeletonType.WITHER)
|
||||
return 1;
|
||||
else return 0;
|
||||
}
|
||||
else if (entity instanceof Zombie || entity instanceof Giant)
|
||||
{
|
||||
if (entity == null)
|
||||
return 0;
|
||||
|
||||
return getSkullData(entity.getType());
|
||||
}
|
||||
|
||||
public static byte getSkullData(EntityType type)
|
||||
{
|
||||
if (type == EntityType.SKELETON)
|
||||
return 0;
|
||||
if (type == EntityType.WITHER)
|
||||
return 1;
|
||||
if (type == EntityType.ZOMBIE || type == EntityType.GIANT)
|
||||
return 2;
|
||||
}
|
||||
else if (entity instanceof Creeper)
|
||||
{
|
||||
if (type == EntityType.CREEPER)
|
||||
return 4;
|
||||
}
|
||||
else
|
||||
return 3;
|
||||
return 3;
|
||||
}
|
||||
|
||||
public static boolean isPlayerHead(byte data)
|
||||
@ -31,52 +31,54 @@ public class UtilSkull
|
||||
}
|
||||
|
||||
public static String getPlayerHeadName(Entity entity)
|
||||
{
|
||||
return getPlayerHeadName(entity.getType());
|
||||
}
|
||||
|
||||
public static String getPlayerHeadName(EntityType entity)
|
||||
{
|
||||
String name = "MHF_Alex";
|
||||
|
||||
// order is important for some of these
|
||||
if (entity instanceof Blaze)
|
||||
if (entity == EntityType.BLAZE)
|
||||
name = "MHF_Blaze";
|
||||
else if (entity instanceof CaveSpider)
|
||||
else if (entity == EntityType.CAVE_SPIDER)
|
||||
name = "MHF_CaveSpider";
|
||||
else if (entity instanceof Spider)
|
||||
else if (entity == EntityType.SPIDER)
|
||||
name = "MHF_Spider";
|
||||
else if (entity instanceof Chicken)
|
||||
else if (entity == EntityType.CHICKEN)
|
||||
name = "MHF_Chicken";
|
||||
else if (entity instanceof MushroomCow)
|
||||
else if (entity == EntityType.MUSHROOM_COW)
|
||||
name = "MHF_MushroomCow";
|
||||
else if (entity instanceof Cow)
|
||||
else if (entity == EntityType.COW)
|
||||
name = "MHF_Cow";
|
||||
else if (entity instanceof Creeper)
|
||||
else if (entity == EntityType.CREEPER)
|
||||
name = "MHF_Creeper";
|
||||
else if (entity instanceof Enderman)
|
||||
else if (entity == EntityType.ENDERMAN)
|
||||
name = "MHF_Enderman";
|
||||
else if (entity instanceof Ghast)
|
||||
else if (entity == EntityType.GHAST)
|
||||
name = "MHF_Ghast";
|
||||
else if (entity instanceof Golem)
|
||||
else if (entity == EntityType.IRON_GOLEM)
|
||||
name = "MHF_Golem";
|
||||
else if (entity instanceof PigZombie)
|
||||
else if (entity == EntityType.PIG_ZOMBIE)
|
||||
name = "MHF_PigZombie";
|
||||
else if (entity instanceof MagmaCube)
|
||||
else if (entity == EntityType.MAGMA_CUBE)
|
||||
name = "MHF_LavaSlime";
|
||||
else if (entity instanceof Slime)
|
||||
else if (entity == EntityType.SLIME)
|
||||
name = "MHF_Slime";
|
||||
else if (entity instanceof Ocelot)
|
||||
else if (entity == EntityType.OCELOT)
|
||||
name = "MHF_Ocelot";
|
||||
else if (entity instanceof PigZombie)
|
||||
name = "MHF_PigZombie";
|
||||
else if (entity instanceof Pig)
|
||||
else if (entity == EntityType.PIG)
|
||||
name = "MHF_Pig";
|
||||
else if (entity instanceof Sheep)
|
||||
name = "MHF_Pig";
|
||||
else if (entity instanceof Squid)
|
||||
else if (entity == EntityType.SHEEP)
|
||||
name = "MHF_Sheep";
|
||||
else if (entity == EntityType.SQUID)
|
||||
name = "MHF_Squid";
|
||||
else if (entity instanceof HumanEntity)
|
||||
else if (entity == EntityType.PLAYER)
|
||||
name = "MHF_Steve";
|
||||
else if (entity instanceof Villager)
|
||||
else if (entity == EntityType.VILLAGER)
|
||||
name = "MHF_Villager";
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,7 +12,8 @@
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Database"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/jooq-3.5.2.jar"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/NoCheatPlus.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/NoCheatPlus.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.PlayerCache"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
@ -1,5 +1,6 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
|
@ -20,5 +20,6 @@
|
||||
<orderEntry type="library" name="jooq" level="project" />
|
||||
<orderEntry type="library" name="commons-dbcp2" level="project" />
|
||||
<orderEntry type="library" name="NoCheatPlus" level="project" />
|
||||
<orderEntry type="module" module-name="Mineplex.PlayerCache" />
|
||||
</component>
|
||||
</module>
|
29
Plugins/Mineplex.Core/src/mineplex/core/FoodDupeFix.java
Normal file
29
Plugins/Mineplex.Core/src/mineplex/core/FoodDupeFix.java
Normal file
@ -0,0 +1,29 @@
|
||||
package mineplex.core;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
|
||||
public class FoodDupeFix extends MiniPlugin
|
||||
{
|
||||
public FoodDupeFix(JavaPlugin plugin)
|
||||
{
|
||||
super("Food Dupe Fix", plugin);
|
||||
}
|
||||
|
||||
// Use Lowest priority so we get called first event.getItem isn't changed
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void fixFoodDupe(PlayerItemConsumeEvent event)
|
||||
{
|
||||
if (UtilItem.isFood(event.getItem()))
|
||||
{
|
||||
if (!event.getItem().equals(event.getPlayer().getItemInHand()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package mineplex.core.account;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.serverdata.data.Data;
|
||||
|
||||
public class AccountCache implements Data
|
||||
{
|
||||
private UUID _uuid;
|
||||
private Integer _id;
|
||||
|
||||
public AccountCache(UUID uuid, int id)
|
||||
{
|
||||
_uuid = uuid;
|
||||
_id = id;
|
||||
}
|
||||
|
||||
public UUID getUUID()
|
||||
{
|
||||
return _uuid;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDataId()
|
||||
{
|
||||
return _uuid.toString();
|
||||
}
|
||||
}
|
@ -1,12 +1,14 @@
|
||||
package mineplex.core.account;
|
||||
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.serverdata.Utility;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CoreClient
|
||||
{
|
||||
private int _accountId = -1;
|
||||
private long _networkSessionLoginTime;
|
||||
private String _name;
|
||||
private String _disguisedAs;
|
||||
private Player _player;
|
||||
@ -18,6 +20,7 @@ public class CoreClient
|
||||
{
|
||||
_player = player;
|
||||
_name = player.getName();
|
||||
_networkSessionLoginTime = Utility.currentTimeMillis();
|
||||
}
|
||||
|
||||
public CoreClient(String name)
|
||||
@ -58,6 +61,9 @@ public class CoreClient
|
||||
|
||||
public Rank GetRank()
|
||||
{
|
||||
if (_rank == null)
|
||||
_rank = Rank.ALL;
|
||||
|
||||
return _rank;
|
||||
}
|
||||
|
||||
@ -65,6 +71,11 @@ public class CoreClient
|
||||
{
|
||||
_rank = rank;
|
||||
}
|
||||
|
||||
public long getNetworkSessionLoginTime()
|
||||
{
|
||||
return _networkSessionLoginTime;
|
||||
}
|
||||
|
||||
public String getDisguisedAs()
|
||||
{
|
||||
@ -95,4 +106,9 @@ public class CoreClient
|
||||
public void setDisguised(boolean disguised) {
|
||||
this._disguised = disguised;
|
||||
}
|
||||
|
||||
public void setNetworkSessionLoginTime(long loginTime)
|
||||
{
|
||||
_networkSessionLoginTime = loginTime;
|
||||
}
|
||||
}
|
||||
|
@ -22,10 +22,8 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.timing.TimingManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.data.BungeeServer;
|
||||
import mineplex.serverdata.redis.RedisDataRepository;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
import mineplex.playerCache.PlayerCache;
|
||||
import mineplex.playerCache.PlayerInfo;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -48,7 +46,6 @@ public class CoreClientManager extends MiniPlugin
|
||||
private AccountRepository _repository;
|
||||
private NautHashMap<String, CoreClient> _clientList;
|
||||
private HashSet<String> _duplicateLoginGlitchPreventionList;
|
||||
private RedisDataRepository<AccountCache> _accountCacheRepository;
|
||||
|
||||
private NautHashMap<String, ILoginProcessor> _loginProcessors = new NautHashMap<String, ILoginProcessor>();
|
||||
private LinkedList<IQuerylessLoginProcessor> _querylessLoginProcessors = new LinkedList<IQuerylessLoginProcessor>();
|
||||
@ -66,9 +63,6 @@ public class CoreClientManager extends MiniPlugin
|
||||
_repository = new AccountRepository(plugin, webServer);
|
||||
_clientList = new NautHashMap<String, CoreClient>();
|
||||
_duplicateLoginGlitchPreventionList = new HashSet<String>();
|
||||
|
||||
_accountCacheRepository = new RedisDataRepository<AccountCache>(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(),
|
||||
Region.ALL, AccountCache.class, "accountCache");
|
||||
}
|
||||
|
||||
public AccountRepository getRepository()
|
||||
@ -126,7 +120,14 @@ public class CoreClientManager extends MiniPlugin
|
||||
if(client.getDisguisedAs().equalsIgnoreCase(name))
|
||||
return client;
|
||||
}
|
||||
return _clientList.get(name);
|
||||
CoreClient client = _clientList.get(name);
|
||||
|
||||
if (client == null)
|
||||
{
|
||||
client = new CoreClient(name);
|
||||
}
|
||||
|
||||
return client;
|
||||
}
|
||||
}
|
||||
|
||||
@ -185,7 +186,7 @@ public class CoreClientManager extends MiniPlugin
|
||||
_clientsProcessing.decrementAndGet();
|
||||
}
|
||||
|
||||
if (Bukkit.hasWhitelist() && !Get(event.getName()).GetRank().Has(Rank.MODERATOR))
|
||||
if (Bukkit.hasWhitelist() && !Get(event.getName()).GetRank().has(Rank.MODERATOR))
|
||||
{
|
||||
for (OfflinePlayer player : Bukkit.getWhitelistedPlayers())
|
||||
{
|
||||
@ -219,7 +220,16 @@ public class CoreClientManager extends MiniPlugin
|
||||
UUID uuid = loadUUIDFromDB(playerName);
|
||||
|
||||
if (uuid == null)
|
||||
uuid = UUIDFetcher.getUUIDOf(playerName);
|
||||
{
|
||||
try
|
||||
{
|
||||
uuid = UUIDFetcher.getUUIDOf(playerName);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
System.out.println("Error fetching uuid from mojang : " + exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
String response = "";
|
||||
|
||||
@ -242,7 +252,15 @@ public class CoreClientManager extends MiniPlugin
|
||||
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
||||
|
||||
if (client.getAccountId() > 0)
|
||||
_accountCacheRepository.addElement(new AccountCache(uuid, client.getAccountId()), 60 * 60 * 6);
|
||||
{
|
||||
PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid);
|
||||
|
||||
if (playerInfo != null)
|
||||
{
|
||||
playerInfo.setAccountId(client.getAccountId());
|
||||
PlayerCache.getInstance().addPlayer(playerInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -286,7 +304,7 @@ public class CoreClientManager extends MiniPlugin
|
||||
TimingManager.stop(client.GetPlayerName() + " GetClient.");
|
||||
|
||||
token = gson.fromJson(response, ClientToken.class);
|
||||
|
||||
|
||||
client.SetRank(Rank.valueOf(token.Rank));
|
||||
|
||||
// _repository.updateMysqlRank(uuid.toString(), token.Rank, token.RankPerm, new Timestamp(Date.parse(token.RankExpire)).toString());
|
||||
@ -313,17 +331,15 @@ public class CoreClientManager extends MiniPlugin
|
||||
|
||||
TimingManager.stop(client.GetPlayerName() + " LoadClient Total.");
|
||||
|
||||
System.out.println(client.GetPlayerName() + "'s account id = " + client.getAccountId());
|
||||
|
||||
if (client.getAccountId() > 0)
|
||||
{
|
||||
try
|
||||
PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid);
|
||||
|
||||
if (playerInfo != null)
|
||||
{
|
||||
_accountCacheRepository.addElement(new AccountCache(uuid, client.getAccountId()), 60 * 60 * 6);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
client.setNetworkSessionLoginTime(playerInfo.getLoginTime());
|
||||
playerInfo.setAccountId(client.getAccountId());
|
||||
PlayerCache.getInstance().addPlayer(playerInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@ -354,7 +370,7 @@ public class CoreClientManager extends MiniPlugin
|
||||
// Reserved Slot Check
|
||||
if (Bukkit.getOnlinePlayers().size() >= Bukkit.getServer().getMaxPlayers())
|
||||
{
|
||||
// if (client.GetRank().Has(event.getPlayer(), Rank.ULTRA, false))
|
||||
// if (client.GetRank().has(event.getPlayer(), Rank.ULTRA, false))
|
||||
// {
|
||||
// event.allow();
|
||||
// event.setResult(PlayerLoginEvent.Result.ALLOWED);
|
||||
@ -533,11 +549,6 @@ public class CoreClientManager extends MiniPlugin
|
||||
if (client == null)
|
||||
return false;
|
||||
|
||||
return client.GetRank().Has(rank);
|
||||
}
|
||||
|
||||
public int getCachedClientAccountId(UUID uuid)
|
||||
{
|
||||
return _accountCacheRepository.getElement(uuid.toString()).getId();
|
||||
return client.GetRank().has(rank);
|
||||
}
|
||||
}
|
@ -29,7 +29,7 @@ public class UpdateRank extends CommandBase<CoreClientManager>
|
||||
|
||||
if (Plugin.Get(caller).GetRank() == Rank.JNR_DEV && !testServer)
|
||||
{
|
||||
F.main(Plugin.getName(), F.elem(Rank.JNR_DEV.GetTag(true, true)) + "s are only permitted to set ranks on test servers!");
|
||||
F.main(Plugin.getName(), F.elem(Rank.JNR_DEV.getTag(true, true)) + "s are only permitted to set ranks on test servers!");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -60,10 +60,9 @@ public class UpdateRank extends CommandBase<CoreClientManager>
|
||||
|
||||
final Rank rank = tempRank;
|
||||
|
||||
if (rank == Rank.ADMIN || rank == Rank.YOUTUBE || rank == Rank.TWITCH || rank == Rank.MODERATOR || rank == Rank.JNR_DEV || rank == Rank.HELPER || rank == Rank.ALL || rank == Rank.MAPDEV || rank == Rank.SNR_MODERATOR)
|
||||
if (rank == Rank.ADMIN || rank == Rank.YOUTUBE || rank == Rank.TWITCH || rank == Rank.MODERATOR || rank == Rank.JNR_DEV || rank == Rank.HELPER || rank == Rank.ALL || rank == Rank.MAPDEV || rank == Rank.SNR_MODERATOR)
|
||||
{
|
||||
if (!testServer && rank.Has(Rank.ADMIN) && !Plugin.hasRank(caller, Rank.LT))
|
||||
if (!testServer && rank.has(Rank.ADMIN) && !Plugin.hasRank(caller, Rank.LT))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), ChatColor.RED + "" + ChatColor.BOLD + "Insufficient privileges!"));
|
||||
return;
|
||||
|
@ -193,7 +193,7 @@ public class AccountRepository extends RepositoryBase
|
||||
}, new ColumnVarChar("name", 100, name));
|
||||
|
||||
if (uuids.size() > 0)
|
||||
return uuids.get(uuids.size() - 1);
|
||||
return uuids.get(0);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public enum Achievement
|
||||
//Survival Games
|
||||
SURVIVAL_GAMES_WINS("Katniss Everdeen", 600,
|
||||
new String[]{"Survival Games.Wins"},
|
||||
new String[]{"Win 20 games of Survival Games"},
|
||||
new String[]{"Win 30 games of Survival Games"},
|
||||
new int[]{30},
|
||||
AchievementCategory.SURVIVAL_GAMES),
|
||||
|
||||
@ -666,7 +666,49 @@ public enum Achievement
|
||||
new String[]{"Bomb Lobbers.Direct Hit"},
|
||||
new String[]{"Get 50 direct hits"},
|
||||
new int[]{50},
|
||||
AchievementCategory.BOMB_LOBBERS)
|
||||
AchievementCategory.BOMB_LOBBERS),
|
||||
|
||||
EVOLUTION_WINS("Expert Evolver", 1200,
|
||||
new String[]{"Evolution.Wins"},
|
||||
new String[]{"Win 20 games of Evolution"},
|
||||
new int[]{20},
|
||||
AchievementCategory.EVOLUTION),
|
||||
|
||||
EVOLUTION_NO_DEATHS("Perfect Game", 2000,
|
||||
new String[]{"Evolution.NoDeaths"},
|
||||
new String[]{"Win a game without dying"},
|
||||
new int[]{1},
|
||||
AchievementCategory.EVOLUTION),
|
||||
|
||||
EVOLUTION_STEALTH("Stealth Mastah", 1000,
|
||||
new String[]{"Evolution.Stealth"},
|
||||
new String[]{"Win without taking any", "damage while evolving"},
|
||||
new int[]{1},
|
||||
AchievementCategory.EVOLUTION),
|
||||
|
||||
EVOLUTION_RAMPAGE("Rampage", 800,
|
||||
new String[]{"Evolution.Rampage"},
|
||||
new String[]{"Get 3 kills within 5 seconds", "of each other"},
|
||||
new int[]{1},
|
||||
AchievementCategory.EVOLUTION),
|
||||
|
||||
EVOLUTION_MELEE("Melee Monster", 1000,
|
||||
new String[]{"Evolution.MeleeOnly"},
|
||||
new String[]{"Win without using any abilities"},
|
||||
new int[]{1},
|
||||
AchievementCategory.EVOLUTION),
|
||||
|
||||
EVOLUTION_SKILLS("Ability Assassin", 1000,
|
||||
new String[]{"Evolution.AbilityOnly"},
|
||||
new String[]{"Win without any melee attacks"},
|
||||
new int[]{1},
|
||||
AchievementCategory.EVOLUTION),
|
||||
|
||||
EVOLUTION_EVOLVEKILL("No Evolve 5 U", 800,
|
||||
new String[]{"Evolution.EvolveKill"},
|
||||
new String[]{"Kill 25 people while they", "Are trying to evolve"},
|
||||
new int[]{25},
|
||||
AchievementCategory.EVOLUTION)
|
||||
|
||||
;
|
||||
|
||||
|
@ -2,9 +2,6 @@ package mineplex.core.achievement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
@ -12,10 +9,14 @@ import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.stats.PlayerStats;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public enum AchievementCategory
|
||||
{
|
||||
GLOBAL("Global", null,
|
||||
new StatDisplay[] { StatDisplay.GEMS_EARNED, null, new StatDisplay("Games Played", "GamesPlayed"), StatDisplay.TIME_IN_GAME, null, new StatDisplay("Daily Rewards", "DailyReward"), new StatDisplay("Times Voted", "DailyVote") },
|
||||
new StatDisplay[] { StatDisplay.GEMS_EARNED, null, new StatDisplay("Games Played", "GamesPlayed"), StatDisplay.TIME_IN_GAME, null,
|
||||
new StatDisplay("Daily Rewards", "DailyReward"), new StatDisplay("Times Voted", "DailyVote"), null, new StatDisplay("Chests Opened", "Treasure.Old", "Treasure.Ancient", "Treasure.Mythical") },
|
||||
Material.EMERALD, 0, GameCategory.GLOBAL, "None"),
|
||||
|
||||
BRIDGES("The Bridges", null,
|
||||
@ -122,7 +123,11 @@ public enum AchievementCategory
|
||||
|
||||
BOMB_LOBBERS("Bomb Lobbers", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.FIREBALL, 0, GameCategory.ARCADE, "Waller Kit");
|
||||
Material.FIREBALL, 0, GameCategory.ARCADE, "Waller Kit"),
|
||||
|
||||
EVOLUTION("Evolution", null,
|
||||
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED},
|
||||
Material.MONSTER_EGG, 0, GameCategory.ARCADE, "Harvester Kit");
|
||||
|
||||
private String _name;
|
||||
private String[] _statsToPull;
|
||||
@ -202,7 +207,7 @@ public enum AchievementCategory
|
||||
String displayName = _statDisplays[i].getDisplayName();
|
||||
|
||||
// Skip showing Losses, Kills, Deaths for other players
|
||||
if (!clientManager.Get(player).GetRank().Has(Rank.MODERATOR) && !player.equals(target) && (displayName.contains("Losses") || displayName.contains("Kills") || displayName.contains("Deaths") || displayName.equals("Time In Game") || displayName.equals("Games Played")))
|
||||
if (!clientManager.Get(player).GetRank().has(Rank.MODERATOR) && !player.equals(target) && (displayName.contains("Losses") || displayName.contains("Kills") || displayName.contains("Deaths") || displayName.equals("Time In Game") || displayName.equals("Games Played")))
|
||||
continue;
|
||||
|
||||
int statNumber = 0;
|
||||
|
@ -187,15 +187,15 @@ public class AchievementManager extends MiniPlugin
|
||||
if (sender.getName().equalsIgnoreCase("B2_mp"))
|
||||
return 101;
|
||||
|
||||
if (rank.Has(Rank.MODERATOR))
|
||||
if (rank.has(Rank.MODERATOR))
|
||||
level = Math.max(level, 5);
|
||||
if (rank.Has(Rank.SNR_MODERATOR))
|
||||
if (rank.has(Rank.SNR_MODERATOR))
|
||||
level = Math.max(level, 15);
|
||||
if (rank.Has(Rank.JNR_DEV))
|
||||
if (rank.has(Rank.JNR_DEV))
|
||||
level = Math.max(level, 25);
|
||||
if (rank.Has(Rank.ADMIN))
|
||||
if (rank.has(Rank.ADMIN))
|
||||
level = Math.max(level, 30 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
|
||||
if (rank.Has(Rank.OWNER))
|
||||
if (rank.has(Rank.OWNER))
|
||||
level = Math.max(level, 50 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
|
||||
|
||||
if (sender.getName().equalsIgnoreCase("Phinary"))
|
||||
|
@ -17,7 +17,7 @@ public class StatsCommand extends CommandBase<AchievementManager>
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args == null || args.length == 0)
|
||||
if (args.length == 0)
|
||||
{
|
||||
Plugin.openShop(caller);
|
||||
}
|
||||
|
@ -61,7 +61,6 @@ public class AchievementMainPage extends ShopPageBase<AchievementManager, Achiev
|
||||
getPlayer(), _target);
|
||||
lore.add(" ");
|
||||
addAchievements(category, lore, 9);
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.RESET + "Click for more details!");
|
||||
|
||||
ShopItem shopItem = new ShopItem(category.getIcon(), category.getIconData(), C.Bold + category.getFriendlyName(),
|
||||
@ -100,5 +99,8 @@ public class AchievementMainPage extends ShopPageBase<AchievementManager, Achiev
|
||||
achievementCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (achievementCount > 0)
|
||||
lore.add(" ");
|
||||
}
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ public class AntiHack extends MiniPlugin
|
||||
|
||||
//Inform
|
||||
for (Player admin : UtilServer.getPlayers())
|
||||
if (_clientManager.Get(admin).GetRank().Has(Rank.MODERATOR) && _preferences.Get(admin).ShowMacReports)
|
||||
if (_clientManager.Get(admin).GetRank().has(Rank.MODERATOR) && _preferences.Get(admin).ShowMacReports)
|
||||
{
|
||||
UtilPlayer.message(admin, "#" + total + ": " + C.cRed + C.Bold + player.getName() + " suspected for " + type + ".");
|
||||
}
|
||||
@ -335,7 +335,7 @@ public class AntiHack extends MiniPlugin
|
||||
boolean handled = false;
|
||||
for (Player staff : UtilServer.getPlayers())
|
||||
{
|
||||
if (_clientManager.Get(staff).GetRank().Has(Rank.MODERATOR))
|
||||
if (_clientManager.Get(staff).GetRank().has(Rank.MODERATOR))
|
||||
{
|
||||
UtilPlayer.message(staff, C.cAqua + C.Scramble + "A" + ChatColor.RESET + C.cRed + C.Bold + " MAC > " + ChatColor.RESET + C.cYellow + report);
|
||||
UtilPlayer.message(staff, C.cAqua + C.Scramble + "A" + ChatColor.RESET + C.cRed + C.Bold + " MAC > " + ChatColor.RESET + C.cGold + player.getName() + C.cYellow + " has extreme violation. Please investigate.");
|
||||
|
@ -13,7 +13,7 @@ public class AntiHackRepository
|
||||
{
|
||||
private String _serverName;
|
||||
|
||||
private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS AntiHack_Kick_Log (id INT NOT NULL AUTO_INCREMENT, updated LONG, playerName VARCHAR(256), motd VARCHAR(56), gameType VARCHAR(56), map VARCHAR(256), serverName VARCHAR(256), report VARCHAR(256), ping VARCHAR(25), PRIMARY KEY (id));";
|
||||
//private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS AntiHack_Kick_Log (id INT NOT NULL AUTO_INCREMENT, updated LONG, playerName VARCHAR(256), motd VARCHAR(56), gameType VARCHAR(56), map VARCHAR(256), serverName VARCHAR(256), report VARCHAR(256), ping VARCHAR(25), PRIMARY KEY (id));";
|
||||
private static String UPDATE_PLAYER_OFFENSES = "INSERT INTO AntiHack_Kick_Log (updated, playerName, motd, gameType, map, serverName, report, ping) VALUES (now(), ?, ?, ?, ?, ?, ?, ?);";
|
||||
|
||||
public AntiHackRepository(String serverName)
|
||||
@ -23,32 +23,6 @@ public class AntiHackRepository
|
||||
|
||||
public void initialize()
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try (Connection connection = DBPool.STATS_MINEPLEX.getConnection())
|
||||
{
|
||||
// Create table
|
||||
preparedStatement = connection.prepareStatement(CREATE_TABLE);
|
||||
preparedStatement.execute();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void saveOffense(final Player player, final String motd, final String game, final String map, final String report)
|
||||
|
@ -156,6 +156,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
_voteList = new ArrayList<String>();
|
||||
_voteList.add("http://vote1.mineplex.com");
|
||||
_voteList.add("http://vote2.mineplex.com");
|
||||
_voteList.add("http://vote3.mineplex.com");
|
||||
|
||||
_coinQueue = new LinkedList<GiveDonorData>();
|
||||
_gemQueue = new LinkedList<GiveDonorData>();
|
||||
@ -185,6 +186,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
_voteList = new ArrayList<String>();
|
||||
_voteList.add("http://vote1.mineplex.com");
|
||||
_voteList.add("http://vote2.mineplex.com");
|
||||
_voteList.add("http://vote3.mineplex.com");
|
||||
|
||||
_canVote = true;
|
||||
_coinQueue = new LinkedList<GiveDonorData>();
|
||||
@ -278,7 +280,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
return _voteStreak;
|
||||
}
|
||||
|
||||
public void handleVote(final Player player, final int gemsRecieved)
|
||||
public void handleVote(final Player player, final int gemsReceived)
|
||||
{
|
||||
final int accountId = _clientManager.getAccountId(player);
|
||||
|
||||
@ -297,11 +299,14 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
BonusClientData oldData = Get(player);
|
||||
if (oldData != null) data.setHologram(oldData.getHologram());
|
||||
Set(player, data);
|
||||
|
||||
_statsManager.incrementStat(player, "Global.DailyVote", 1);
|
||||
addPendingExplosion(player, player.getName());
|
||||
UtilPlayer.message(player, F.main("Carl", "Thanks for voting for Mineplex!"));
|
||||
UtilPlayer.message(player, F.main("Carl", "You received " + F.elem(gemsRecieved + " Gems") + " and " + F.elem("1 Carl Spinner Ticket") + "!"));
|
||||
UtilPlayer.message(player, F.main("Carl", "You received " + F.elem(gemsReceived + " Gems") + " and " + F.elem("1 Carl Spinner Ticket") + "!"));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -482,7 +487,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
{
|
||||
final BonusClientData clientData = Get(player);
|
||||
|
||||
if (clientData.getTickets() > 0)
|
||||
if (Recharge.Instance.use(player, "Carl Spin", 5000, false, false) && clientData.getTickets() > 0)
|
||||
{
|
||||
CarlSpinnerEvent event = new CarlSpinnerEvent(player);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
@ -666,19 +671,19 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
|
||||
BonusAmount data = new BonusAmount();
|
||||
|
||||
if (rank.Has(Rank.MODERATOR))
|
||||
if (rank.has(Rank.MODERATOR))
|
||||
{
|
||||
data.setCoins(35000);
|
||||
}
|
||||
if (rank.Has(Rank.LEGEND))
|
||||
if (rank.has(Rank.LEGEND))
|
||||
{
|
||||
data.setCoins(30000);
|
||||
}
|
||||
else if (rank.Has(Rank.HERO))
|
||||
else if (rank.has(Rank.HERO))
|
||||
{
|
||||
data.setCoins(15000);
|
||||
}
|
||||
else if (rank.Has(Rank.ULTRA))
|
||||
else if (rank.has(Rank.ULTRA))
|
||||
{
|
||||
data.setCoins(7500);
|
||||
}
|
||||
|
@ -9,9 +9,9 @@ import mineplex.core.reward.RewardType;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
|
||||
public class AnimationCommand extends CommandBase<BonusManager>{
|
||||
|
||||
|
||||
private BonusManager _plugin;
|
||||
|
||||
|
||||
public AnimationCommand(BonusManager plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "animation");
|
||||
@ -21,17 +21,14 @@ public class AnimationCommand extends CommandBase<BonusManager>{
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
|
||||
if(args != null)
|
||||
{
|
||||
caller = Bukkit.getPlayer(args[0]);
|
||||
_plugin.addPendingExplosion(caller, _plugin.getRewardManager().nextReward(caller, null, false, RewardType.SpinnerFiller, true));
|
||||
}
|
||||
if(args.length >= 2)
|
||||
caller = Bukkit.getPlayer(args[0]);
|
||||
_plugin.addPendingExplosion(caller, _plugin.getRewardManager().nextReward(caller, null, false, RewardType.SpinnerFiller, true));
|
||||
|
||||
if (args.length >= 2)
|
||||
{
|
||||
_plugin.addPendingExplosion(caller, args[1]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -197,7 +197,7 @@ public class PollButton extends SimpleGui implements GuiItem {
|
||||
{
|
||||
_create = true;
|
||||
|
||||
_pollManager.answerPoll(getPlayer(), _poll, num);
|
||||
_pollManager.answerPoll(getPlayer(), _poll, num + 1);
|
||||
|
||||
getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f);
|
||||
|
||||
|
@ -0,0 +1,164 @@
|
||||
package mineplex.core.botspam;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.message.PrivateMessageEvent;
|
||||
import mineplex.core.punish.Category;
|
||||
import mineplex.core.punish.Punish;
|
||||
import mineplex.core.botspam.command.BotSpamCommand;
|
||||
import mineplex.core.botspam.repository.BotSpamRepository;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class BotSpamManager extends MiniPlugin
|
||||
{
|
||||
private Punish _punish;
|
||||
private CoreClientManager _clientManager;
|
||||
private BotSpamRepository _repository;
|
||||
private volatile ArrayList<SpamText> _spam = new ArrayList<SpamText>();
|
||||
|
||||
public BotSpamManager(JavaPlugin plugin, CoreClientManager clientManager, Punish punish)
|
||||
{
|
||||
super("SpamBot Manager", plugin);
|
||||
|
||||
_punish = punish;
|
||||
_clientManager = clientManager;
|
||||
_repository = new BotSpamRepository(plugin);
|
||||
_spam = _repository.getSpamText();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPrivateMessage(PrivateMessageEvent event)
|
||||
{
|
||||
Player recipient = event.getRecipient();
|
||||
// Ignore messages sent to staff members
|
||||
if (_clientManager.hasRank(recipient, Rank.HELPER))
|
||||
return;
|
||||
|
||||
for (SpamText spamText : _spam)
|
||||
{
|
||||
if (spamText.isEnabled() && spamText.isSpam(event.getMessage()))
|
||||
{
|
||||
punishBot(event.getSender(), spamText);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void punishBot(Player player, final SpamText botText)
|
||||
{
|
||||
_punish.AddPunishment(player.getName(), Category.Other, "Bot Spam #" + botText.getId(), "Chiss", 1, true, -1, true);
|
||||
|
||||
// Update bot text count
|
||||
runAsync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
_repository.addPunishment(botText);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void addSpamText(final String caller, final String text, final Runnable callback)
|
||||
{
|
||||
runAsync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
_repository.addSpamText(caller, text);
|
||||
_spam = _repository.getSpamText();
|
||||
|
||||
if (callback != null)
|
||||
runSync(callback);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void enableSpamText(final String caller, final SpamText spamText, final Runnable callback)
|
||||
{
|
||||
runAsync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
_repository.enableSpamText(caller, spamText);
|
||||
|
||||
runSync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
spamText.setEnabled(true);
|
||||
spamText.setEnabledBy(caller);
|
||||
|
||||
if (callback != null)
|
||||
callback.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void disableSpamText(final String caller, final SpamText spamText, final Runnable callback)
|
||||
{
|
||||
runAsync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
_repository.disableSpamText(caller, spamText);
|
||||
|
||||
runSync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
spamText.setEnabled(false);
|
||||
spamText.setDisabledBy(caller);
|
||||
|
||||
if (callback != null)
|
||||
callback.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public List<SpamText> getSpamTexts()
|
||||
{
|
||||
return _spam;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateText(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() == UpdateType.MIN_01)
|
||||
{
|
||||
runAsync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
_spam = _repository.getSpamText();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new BotSpamCommand(this));
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package mineplex.core.botspam;
|
||||
|
||||
public class SpamText
|
||||
{
|
||||
private int _id;
|
||||
private String _text;
|
||||
private int _punishments;
|
||||
private boolean _enabled;
|
||||
private String _createdBy;
|
||||
private String _disabledBy;
|
||||
private String _enabledBy;
|
||||
|
||||
public SpamText(int id, String text, int punishments, boolean enabled, String createdBy, String enabledBy, String disabledBy)
|
||||
{
|
||||
_id = id;
|
||||
_text = text;
|
||||
_punishments = punishments;
|
||||
_enabled = enabled;
|
||||
_createdBy = createdBy;
|
||||
_enabledBy = enabledBy;
|
||||
_disabledBy = disabledBy;
|
||||
}
|
||||
|
||||
public boolean isSpam(String message)
|
||||
{
|
||||
return message.toLowerCase().contains(_text.toLowerCase());
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public String getText()
|
||||
{
|
||||
return _text;
|
||||
}
|
||||
|
||||
public int getPunishments()
|
||||
{
|
||||
return _punishments;
|
||||
}
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled)
|
||||
{
|
||||
_enabled = enabled;
|
||||
}
|
||||
|
||||
public String getCreatedBy()
|
||||
{
|
||||
return _createdBy;
|
||||
}
|
||||
|
||||
public String getEnabledBy()
|
||||
{
|
||||
return _enabledBy;
|
||||
}
|
||||
|
||||
public String getDisabledBy()
|
||||
{
|
||||
return _disabledBy;
|
||||
}
|
||||
|
||||
public void setEnabledBy(String enabledBy)
|
||||
{
|
||||
_enabledBy = enabledBy;
|
||||
}
|
||||
|
||||
public void setDisabledBy(String disabledBy)
|
||||
{
|
||||
_disabledBy = disabledBy;
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package mineplex.core.botspam.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.botspam.SpamText;
|
||||
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.botspam.BotSpamManager;
|
||||
|
||||
public class BotSpamAddCommand extends CommandBase<BotSpamManager>
|
||||
{
|
||||
public BotSpamAddCommand(BotSpamManager plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "add");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(final Player caller, String[] args)
|
||||
{
|
||||
if (args != null && args.length >= 1)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < args.length; i++)
|
||||
{
|
||||
if (i > 0) sb.append(" ");
|
||||
|
||||
sb.append(args[i]);
|
||||
}
|
||||
|
||||
final String text = sb.toString();
|
||||
|
||||
if (text.length() < 8)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("BotSpam", "Spam text must be at least 8 characters"));
|
||||
return;
|
||||
}
|
||||
|
||||
for (SpamText spamText : Plugin.getSpamTexts())
|
||||
{
|
||||
if (text.equalsIgnoreCase(spamText.getText()))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("BotSpam", "That Spam Text already exists. Type " + F.elem("/botspam list") + " to view"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Plugin.addSpamText(caller.getName(), text, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (caller.isOnline())
|
||||
UtilPlayer.message(caller, F.main("BotSpam", "Added Spam Text: " + F.elem(text)));
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("BotSpam", "/botspam add <text>"));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package mineplex.core.botspam.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.MultiCommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.botspam.BotSpamManager;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
public class BotSpamCommand extends MultiCommandBase<BotSpamManager>
|
||||
{
|
||||
public BotSpamCommand(BotSpamManager plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "botban", "botspam");
|
||||
|
||||
AddCommand(new BotSpamAddCommand(Plugin));
|
||||
AddCommand(new BotSpamEnableCommand(Plugin));
|
||||
AddCommand(new BotSpamDisableCommand(Plugin));
|
||||
AddCommand(new BotSpamListCommand(Plugin));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void Help(Player caller, String[] args)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("BotSpam", "/botspam list"));
|
||||
UtilPlayer.message(caller, F.main("BotSpam", "/botspam add <text>"));
|
||||
UtilPlayer.message(caller, F.main("BotSpam", "/botspam enable <text id>"));
|
||||
UtilPlayer.message(caller, F.main("BotSpam", "/botspam disable <text id>"));
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package mineplex.core.botspam.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.botspam.SpamText;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.botspam.BotSpamManager;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
public class BotSpamDisableCommand extends CommandBase<BotSpamManager>
|
||||
{
|
||||
public BotSpamDisableCommand(BotSpamManager plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "disable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(final Player caller, String[] args)
|
||||
{
|
||||
if (args != null && args.length == 1)
|
||||
{
|
||||
final int spamId;
|
||||
|
||||
try
|
||||
{
|
||||
spamId = Integer.parseInt(args[0]);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("BotSpam", "/botspam disable <text id>"));
|
||||
return;
|
||||
}
|
||||
|
||||
SpamText text = null;
|
||||
for (SpamText spamText : Plugin.getSpamTexts())
|
||||
{
|
||||
if (spamText.getId() == spamId)
|
||||
text = spamText;
|
||||
}
|
||||
|
||||
if (text == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("BotSpam", "Could not find a spam text with the id " + F.elem("" + spamId)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!text.isEnabled())
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("BotSpam", "That spam text is already disabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
final SpamText finalText = text;
|
||||
Plugin.disableSpamText(caller.getName(), text, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("BotSpam", "Disabled Spam Text " + F.elem(finalText.getText())));
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("BotSpam", "/botspam disable <text id>"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package mineplex.core.botspam.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.botspam.SpamText;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.botspam.BotSpamManager;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
public class BotSpamEnableCommand extends CommandBase<BotSpamManager>
|
||||
{
|
||||
public BotSpamEnableCommand(BotSpamManager plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "enable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(final Player caller, String[] args)
|
||||
{
|
||||
if (args != null && args.length == 1)
|
||||
{
|
||||
final int spamId;
|
||||
|
||||
try
|
||||
{
|
||||
spamId = Integer.parseInt(args[0]);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("BotSpam", "/botspam enable <text id>"));
|
||||
return;
|
||||
}
|
||||
|
||||
SpamText text = null;
|
||||
for (SpamText spamText : Plugin.getSpamTexts())
|
||||
{
|
||||
if (spamText.getId() == spamId)
|
||||
text = spamText;
|
||||
}
|
||||
|
||||
if (text == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("BotSpam", "Could not find a spam text with the id " + F.elem("" + spamId)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (text.isEnabled())
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("BotSpam", "That spam text is already enabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
final SpamText finalText = text;
|
||||
Plugin.enableSpamText(caller.getName(), text, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("BotSpam", "Enabled Spam Text " + F.elem(finalText.getText())));
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("BotSpam", "/botspam enable <text id>"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package mineplex.core.botspam.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.botspam.SpamText;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.botspam.BotSpamManager;
|
||||
import mineplex.core.common.jsonchat.ClickEvent;
|
||||
import mineplex.core.common.jsonchat.HoverEvent;
|
||||
import mineplex.core.common.jsonchat.JsonMessage;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
public class BotSpamListCommand extends CommandBase<BotSpamManager>
|
||||
{
|
||||
public BotSpamListCommand(BotSpamManager plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "list");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("BotSpam", "Listing Spam Texts. Hover for more details"));
|
||||
UtilPlayer.message(caller, ""); // Blank Line!
|
||||
|
||||
for (SpamText spamText : Plugin.getSpamTexts())
|
||||
{
|
||||
String modifyMessage = spamText.isEnabled() ? C.cRed + "Click To Disable" : C.cGreen + "Click To Enable";
|
||||
String hoverMessage = C.cYellow + "Spam Id: " + C.cWhite + spamText.getId() + "\\n" + C.cYellow + "Ban Count: " + C.cWhite + spamText.getPunishments() + "\\n" + C.cYellow + "Enabled: " + C.cWhite + spamText.isEnabled();
|
||||
hoverMessage += "\\n\\n" + C.cYellow + "Created By: " + C.cWhite + spamText.getCreatedBy();
|
||||
if (spamText.getEnabledBy() != null)
|
||||
hoverMessage += "\\n" + C.cYellow + "Enabled By: " + C.cWhite + spamText.getEnabledBy();
|
||||
if (spamText.getDisabledBy() != null)
|
||||
hoverMessage += "\\n" + C.cYellow + "Disabled By: " + C.cWhite + spamText.getDisabledBy();
|
||||
hoverMessage += "\\n\\n" + modifyMessage;
|
||||
|
||||
JsonMessage message = new JsonMessage((spamText.isEnabled() ? "" : C.cRed) + spamText.getText());
|
||||
message.hover(HoverEvent.SHOW_TEXT, hoverMessage);
|
||||
message.click(ClickEvent.RUN_COMMAND, "/botspam " + (spamText.isEnabled() ? "disable" : "enable") + " " + spamText.getId());
|
||||
message.send(JsonMessage.MessageType.SYSTEM_MESSAGE, caller);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
package mineplex.core.botspam.repository;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.botspam.SpamText;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.column.ColumnInt;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
|
||||
public class BotSpamRepository extends RepositoryBase
|
||||
{
|
||||
private static final String GET_SPAM_TEXT = "SELECT * FROM botSpam";
|
||||
private static final String ADD_SPAM_TEXT = "INSERT INTO botSpam (text, createdBy, enabledBy) VALUES (?, ?, ?)";
|
||||
private static final String DELETE_SPAM_TEXT = "DELETE FROM botSpam WHERE id = ?";
|
||||
private static final String ENABLE_SPAM_TEXT = "UPDATE botSpam SET enabled = 1, enabledBy = ? WHERE id = ?";
|
||||
private static final String DISABLE_SPAM_TEXT = "UPDATE botSpam SET enabled = 0 AND disabledBy = ? WHERE id = ?";
|
||||
private static final String ADD_PUNISHMENT = "UPDATE botSpam SET punishments = punishments + 1 WHERE id = ?";
|
||||
|
||||
public BotSpamRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
}
|
||||
|
||||
public ArrayList<SpamText> getSpamText()
|
||||
{
|
||||
final ArrayList<SpamText> list = new ArrayList<SpamText>();
|
||||
|
||||
executeQuery(GET_SPAM_TEXT, new ResultSetCallable()
|
||||
{
|
||||
@Override
|
||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||
{
|
||||
while (resultSet.next())
|
||||
{
|
||||
int id = resultSet.getInt(1);
|
||||
String text = resultSet.getString(2);
|
||||
int punishments = resultSet.getInt(3);
|
||||
boolean enabled = resultSet.getBoolean(4);
|
||||
String createdBy = resultSet.getString(5);
|
||||
String enabledBy = resultSet.getString(6);
|
||||
String disabledBy = resultSet.getString(7);
|
||||
|
||||
list.add(new SpamText(id, text, punishments, enabled, createdBy, enabledBy, disabledBy));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public void addPunishment(SpamText text)
|
||||
{
|
||||
executeUpdate(ADD_PUNISHMENT, new ColumnInt("id", text.getId()));
|
||||
}
|
||||
|
||||
public void disableSpamText(String caller, SpamText text)
|
||||
{
|
||||
executeUpdate(DISABLE_SPAM_TEXT, new ColumnVarChar("disabledBy", 100, caller), new ColumnInt("id", text.getId()));
|
||||
}
|
||||
|
||||
public void enableSpamText(String caller, SpamText text)
|
||||
{
|
||||
executeUpdate(ENABLE_SPAM_TEXT, new ColumnVarChar("enabledBy", 100, caller), new ColumnInt("id", text.getId()));
|
||||
}
|
||||
|
||||
public void addSpamText(String caller, String spamText)
|
||||
{
|
||||
executeInsert(ADD_SPAM_TEXT, null, new ColumnVarChar("text", 200, spamText), new ColumnVarChar("createdBy", 100, caller), new ColumnVarChar("enabledBy", 100, caller));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -176,7 +176,7 @@ public class Chat extends MiniPlugin
|
||||
if (_silenced == 0)
|
||||
return false;
|
||||
|
||||
if (_clientManager.Get(player).GetRank().Has(player, Rank.MODERATOR, false))
|
||||
if (_clientManager.Get(player).GetRank().has(player, Rank.MODERATOR, false))
|
||||
return false;
|
||||
|
||||
if (_silenced == -1)
|
||||
@ -210,7 +210,7 @@ public class Chat extends MiniPlugin
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onSignChange(SignChangeEvent event)
|
||||
{
|
||||
if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.ADMIN)) return;
|
||||
if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.ADMIN)) return;
|
||||
|
||||
// Prevent silenced players from using signs
|
||||
if (SilenceCheck(event.getPlayer()))
|
||||
@ -317,13 +317,13 @@ public class Chat extends MiniPlugin
|
||||
UtilPlayer.message(sender, C.cYellow + "Buy a Rank at " + C.cGreen + "www.mineplex.com/shop" + C.cYellow + " to remove this limit!");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (!_clientManager.Get(sender).GetRank().Has(Rank.MODERATOR) &&
|
||||
else if (!_clientManager.Get(sender).GetRank().has(Rank.MODERATOR) &&
|
||||
!Recharge.Instance.use(sender, "Chat Message", 400, false, false))
|
||||
{
|
||||
UtilPlayer.message(sender, F.main("Chat", "You are sending messages too fast."));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (!_clientManager.Get(sender).GetRank().Has(Rank.HELPER) &&
|
||||
else if (!_clientManager.Get(sender).GetRank().has(Rank.HELPER) &&
|
||||
msgContainsHack(event.getMessage()))
|
||||
{
|
||||
UtilPlayer.message(sender, F.main("Chat",
|
||||
@ -337,12 +337,12 @@ public class Chat extends MiniPlugin
|
||||
MessageData lastMessage = _playerLastMessage.get(sender.getUniqueId());
|
||||
long chatSlowTime = 1000L * _chatSlow;
|
||||
long timeDiff = System.currentTimeMillis() - lastMessage.getTimeSent();
|
||||
if (timeDiff < chatSlowTime && !_clientManager.Get(sender).GetRank().Has(Rank.HELPER))
|
||||
if (timeDiff < chatSlowTime && !_clientManager.Get(sender).GetRank().has(Rank.HELPER))
|
||||
{
|
||||
UtilPlayer.message(sender, F.main("Chat", "Chat slow enabled. Please wait " + F.time(UtilTime.convertString(chatSlowTime - timeDiff, 1, UtilTime.TimeUnit.FIT))));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (!_clientManager.Get(sender).GetRank().Has(Rank.MODERATOR) &&
|
||||
else if (!_clientManager.Get(sender).GetRank().has(Rank.MODERATOR) &&
|
||||
UtilText.isStringSimilar(event.getMessage(), lastMessage.getMessage(), 0.8f))
|
||||
{
|
||||
UtilPlayer.message(sender, F.main("Chat", "This message is too similar to your previous message."));
|
||||
|
@ -18,7 +18,7 @@ public class ChatSlowCommand extends CommandBase<Chat>
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args != null && args.length == 1)
|
||||
if (args.length == 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ public class CommandCenter implements Listener
|
||||
public void OnPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
String commandName = event.getMessage().substring(1);
|
||||
String[] args = null;
|
||||
String[] args = new String[] {};
|
||||
|
||||
if (commandName.contains(" "))
|
||||
{
|
||||
@ -62,7 +62,7 @@ public class CommandCenter implements Listener
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
if (ClientManager.Get(event.getPlayer()).GetRank().Has(event.getPlayer(), command.GetRequiredRank(), command.GetSpecificRanks(), true))
|
||||
if (ClientManager.Get(event.getPlayer()).GetRank().has(event.getPlayer(), command.GetRequiredRank(), command.GetSpecificRanks(), true))
|
||||
{
|
||||
if (!Recharge.Instance.use(event.getPlayer(), "Command", 500, false, false))
|
||||
{
|
||||
@ -76,19 +76,6 @@ public class CommandCenter implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTabComplete(TabCompleteEvent event)
|
||||
{
|
||||
ICommand command = Commands.get(event.getCommand().toLowerCase());
|
||||
|
||||
if (command != null)
|
||||
{
|
||||
List<String> suggestions = command.onTabComplete(event.getSender(), event.getCommand(), event.getArgs());
|
||||
|
||||
if (suggestions != null)
|
||||
event.setSuggestions(suggestions);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddCommand(ICommand command)
|
||||
{
|
||||
|
@ -40,7 +40,7 @@ public abstract class MultiCommandBase<PluginType extends MiniPlugin> extends Co
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
String commandName = null;
|
||||
String[] newArgs = null;
|
||||
String[] newArgs = new String[] {};
|
||||
|
||||
if (args != null && args.length > 0)
|
||||
{
|
||||
@ -59,7 +59,7 @@ public abstract class MultiCommandBase<PluginType extends MiniPlugin> extends Co
|
||||
|
||||
ICommand command = Commands.get(commandName);
|
||||
|
||||
if (command != null && CommandCenter.ClientManager.Get(caller).GetRank().Has(caller, command.GetRequiredRank(), command.GetSpecificRanks(), true))
|
||||
if (command != null && CommandCenter.ClientManager.Get(caller).GetRank().has(caller, command.GetRequiredRank(), command.GetSpecificRanks(), true))
|
||||
{
|
||||
command.SetAliasUsed(commandName);
|
||||
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
@ -20,6 +21,7 @@ import mineplex.core.cosmetic.ui.button.OpenMusic;
|
||||
import mineplex.core.cosmetic.ui.button.OpenParticles;
|
||||
import mineplex.core.cosmetic.ui.button.OpenPets;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.donation.Donor;
|
||||
import mineplex.core.gadget.types.Gadget;
|
||||
import mineplex.core.gadget.types.GadgetType;
|
||||
import mineplex.core.mount.Mount;
|
||||
@ -40,7 +42,14 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
|
||||
@Override
|
||||
protected void buildPage()
|
||||
{
|
||||
{
|
||||
Donor donor = getDonationManager().Get(getPlayer());
|
||||
|
||||
// addItem(2, new ShopItem(CurrencyType.Gems.GetDisplayMaterial(), donor.GetGems() + " Gems", new String[] {
|
||||
// " "
|
||||
// }, 1, false));
|
||||
|
||||
|
||||
addItem(4, new ShopItem(175, getDonationManager().Get(getPlayer().getName()).getCoins() + " Coins", new String[]
|
||||
{
|
||||
" ",
|
||||
@ -54,9 +63,13 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
ChatColor.RESET + "Receives 15000 Coins per Month",
|
||||
" ",
|
||||
ChatColor.RESET + C.cGreen + "Legend Rank",
|
||||
ChatColor.RESET + "Recieves 30000 Coins per Month"
|
||||
ChatColor.RESET + "Receives 30000 Coins per Month"
|
||||
}, 1, false));
|
||||
|
||||
// addItem(6, new ShopItem(Material.GOLD_INGOT, donor.getGold() + " Gold", new String[] {
|
||||
// " "
|
||||
// }, 1, false));
|
||||
|
||||
addButton(18, new ShopItem(Material.NETHER_STAR, "Particle Effects", 1, false), new OpenParticles(this));
|
||||
addButton(20, new ShopItem(Material.BOW, "Gadgets", 1, false), new OpenGadgets(this));
|
||||
addButton(22, new ShopItem(Material.LEATHER, "Morphs", 1, false), new OpenMorphs(this));
|
||||
|
@ -75,7 +75,7 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
if (pet.GetPetType() == EntityType.WITHER)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(ChatColor.RESET + C.cYellow + "Unlocked with Legend Rank");
|
||||
itemLore.add(ChatColor.RESET + C.cGreen + "Unlocked with Legend Rank");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class MobCommand extends MultiCommandBase<Creature>
|
||||
@Override
|
||||
protected void Help(Player caller, String[] args)
|
||||
{
|
||||
if (args == null)
|
||||
if (args == null || args.length == 0)
|
||||
{
|
||||
HashMap<EntityType, Integer> entMap = new HashMap<EntityType, Integer>();
|
||||
|
||||
|
@ -442,7 +442,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
|
||||
return new PacketPlayOutMapChunk(_bedChunk, true, 0, UtilPlayer.is1_8(player) ? 48 : 0);
|
||||
}
|
||||
|
||||
private Packet[] getBedPackets(Location recieving, DisguisePlayer playerDisguise)
|
||||
private Packet[] getBedPackets(Location recieving, DisguisePlayer playerDisguise, boolean is18)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -458,7 +458,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
|
||||
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(playerDisguise.GetEntity());
|
||||
|
||||
teleportPacket.c += (int) (0.35D * 32);
|
||||
teleportPacket.c += (int) ((is18 ? 0.07D : 0.25D) * 32);
|
||||
|
||||
return new Packet[]
|
||||
{
|
||||
@ -502,7 +502,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
|
||||
&& ((DisguisePlayer) entry.getKey()).getSleepingDirection() != null)
|
||||
{
|
||||
|
||||
packets.addAll(Arrays.asList(getBedPackets(newLoc, (DisguisePlayer) entry.getKey())));
|
||||
packets.addAll(Arrays.asList(getBedPackets(newLoc, (DisguisePlayer) entry.getKey(), UtilPlayer.is1_8(player))));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -869,7 +869,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
|
||||
|
||||
if (pDisguise.getSleepingDirection() != null)
|
||||
{
|
||||
for (Packet packet : getBedPackets(player.getLocation(), pDisguise))
|
||||
for (Packet packet : getBedPackets(player.getLocation(), pDisguise, UtilPlayer.is1_8(player)))
|
||||
{
|
||||
handlePacket(packet, packetVerifier);
|
||||
}
|
||||
|
@ -30,9 +30,9 @@ public abstract class DisguiseInsentient extends DisguiseLiving
|
||||
{
|
||||
if (rank != null)
|
||||
{
|
||||
if (rank.Has(Rank.ULTRA))
|
||||
if (rank.has(Rank.ULTRA))
|
||||
{
|
||||
name = rank.GetTag(true, true) + " " + ChatColor.RESET + name;
|
||||
name = rank.getTag(true, true) + " " + ChatColor.RESET + name;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ import mineplex.core.donation.repository.token.DonorTokenWrapper;
|
||||
import mineplex.core.server.util.TransactionResponse;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.playerCache.PlayerCache;
|
||||
|
||||
public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
{
|
||||
@ -280,7 +281,7 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
RewardCoins(null, caller, player.getName(), ClientManager.getCachedClientAccountId(player.getUniqueId()), total, false);
|
||||
RewardCoins(null, caller, player.getName(), PlayerCache.getInstance().getPlayer(player.getUniqueId()).getAccountId(), total, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class GemCommand extends CommandBase<DonationManager>
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("gem", "Missing Args: " + F.elem("/gem <player> <amount>")));
|
||||
UtilPlayer.message(caller, F.main("Gem", "Missing Args: " + F.elem("/gem <player> <amount>")));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ public class GemCommand extends CommandBase<DonationManager>
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("gem", "Invalid gems Amount"));
|
||||
UtilPlayer.message(caller, F.main("Gem", "Invalid gems Amount"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,16 +71,16 @@ public class GemCommand extends CommandBase<DonationManager>
|
||||
{
|
||||
if (completed)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("gem", "You gave " + F.elem(gems + " gems") + " to " + F.name(targetName) + "."));
|
||||
UtilPlayer.message(caller, F.main("Gem", "You gave " + F.elem(gems + " gems") + " to " + F.name(targetName) + "."));
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
UtilPlayer.message(target, F.main("gem", F.name(caller.getName()) + " gave you " + F.elem(gems + " gems") + "."));
|
||||
UtilPlayer.message(target, F.main("Gem", F.name(caller.getName()) + " gave you " + F.elem(gems + " gems") + "."));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("gem", "There was an error giving " + F.elem(gems + " gems") + " to " + F.name(targetName) + "."));
|
||||
UtilPlayer.message(caller, F.main("Gem", "There was an error giving " + F.elem(gems + " gems") + " to " + F.name(targetName) + "."));
|
||||
}
|
||||
}
|
||||
}, caller.getName(), targetName, uuid, gems);
|
||||
|
@ -23,6 +23,7 @@ public class GoldCommand extends CommandBase<DonationManager>
|
||||
if (args == null || args.length == 0)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Gold", "Your Gold: " + F.elem("" + Plugin.Get(caller).getGold())));
|
||||
return;
|
||||
}
|
||||
else if (args.length < 2)
|
||||
{
|
||||
|
@ -251,7 +251,7 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
|
||||
|
||||
public void showFriends(Player caller)
|
||||
{
|
||||
boolean isStaff = ClientManager.Get(caller).GetRank().Has(Rank.HELPER);
|
||||
boolean isStaff = ClientManager.Get(caller).GetRank().has(Rank.HELPER);
|
||||
boolean gotAFriend = false;
|
||||
List<FriendStatus> friendStatuses = Get(caller).getFriends();
|
||||
Collections.sort(friendStatuses, _friendSorter);
|
||||
|
@ -166,11 +166,11 @@ public class GadgetManager extends MiniPlugin
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.MODERATOR))
|
||||
if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.MODERATOR))
|
||||
{
|
||||
for (GadgetType gadgetType : _gadgets.keySet())
|
||||
{
|
||||
if (gadgetType == GadgetType.Particle && _clientManager.Get(event.getPlayer()).GetRank().Has(Rank.ADMIN))
|
||||
if (gadgetType == GadgetType.Particle && _clientManager.Get(event.getPlayer()).GetRank().has(Rank.ADMIN))
|
||||
{
|
||||
for (Gadget gadget : _gadgets.get(gadgetType))
|
||||
{
|
||||
@ -455,12 +455,16 @@ public class GadgetManager extends MiniPlugin
|
||||
@EventHandler
|
||||
public void chissMeow(PlayerToggleSneakEvent event)
|
||||
{
|
||||
if (event.getPlayer().getName().equals("Chiss"))
|
||||
{
|
||||
if (!event.getPlayer().isSneaking())
|
||||
{
|
||||
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.CAT_MEOW, 1f, 1f);
|
||||
}
|
||||
}
|
||||
if (event.getPlayer().isSneaking())
|
||||
return;
|
||||
|
||||
if (event.getPlayer().getName().equalsIgnoreCase("Chiss"))
|
||||
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.CAT_MEOW, 1f, 1f);
|
||||
|
||||
if (event.getPlayer().getName().equalsIgnoreCase("defek7"))
|
||||
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.WOLF_BARK, 1f, 1f);
|
||||
|
||||
if (event.getPlayer().getName().equalsIgnoreCase("sterling_"))
|
||||
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.PIG_IDLE, 1f, 1f);
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ public class MorphBlaze extends MorphGadget
|
||||
@EventHandler
|
||||
public void HeroOwner(PlayerJoinEvent event)
|
||||
{
|
||||
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().Has(Rank.HERO))
|
||||
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.HERO))
|
||||
{
|
||||
Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName());
|
||||
}
|
||||
|
@ -59,8 +59,7 @@ public class MorphBunny extends MorphGadget
|
||||
" ",
|
||||
C.cRed +C.Bold + "WARNING: " + ChatColor.RESET + "Hide Easter Egg uses 500 Coins" ,
|
||||
" ",
|
||||
C.cPurple + "Special Limited Time Morph",
|
||||
C.cPurple + "Purchase at www.mineplex.com/shop",
|
||||
C.cPurple + "No longer available",
|
||||
},
|
||||
-1,
|
||||
Material.MONSTER_EGG, (byte)98);
|
||||
|
@ -170,7 +170,7 @@ public class MorphCreeper extends MorphGadget
|
||||
@EventHandler
|
||||
public void HeroOwner(PlayerJoinEvent event)
|
||||
{
|
||||
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().Has(Rank.HERO))
|
||||
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.HERO))
|
||||
{
|
||||
Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName());
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class MorphPig extends MorphGadget
|
||||
C.cYellow + "Left Click" + C.cGray + " to use " + C.cGreen + "Oink",
|
||||
C.cYellow + "Collide" + C.cGray + " to use " + C.cGreen + "Pig Bounce",
|
||||
" ",
|
||||
C.cPurple + "Unlocked with Ultra Rank",
|
||||
C.cAqua + "Unlocked with Ultra Rank",
|
||||
},
|
||||
-1,
|
||||
Material.PORK, (byte)0);
|
||||
@ -83,7 +83,7 @@ public class MorphPig extends MorphGadget
|
||||
@EventHandler
|
||||
public void HeroOwner(PlayerJoinEvent event)
|
||||
{
|
||||
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().Has(Rank.ULTRA))
|
||||
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.ULTRA))
|
||||
{
|
||||
Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName());
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class MorphWither extends MorphGadget
|
||||
" ",
|
||||
C.cYellow + "Left Click" + C.cGray + " to use " + C.cGreen + "Wither Skull",
|
||||
" ",
|
||||
C.cPurple + "Unlocked with Legend Rank",
|
||||
C.cGreen + "Unlocked with Legend Rank",
|
||||
},
|
||||
-1,
|
||||
Material.SKULL_ITEM, (byte)1);
|
||||
@ -177,10 +177,7 @@ public class MorphWither extends MorphGadget
|
||||
@EventHandler
|
||||
public void legendOwner(PlayerJoinEvent event)
|
||||
{
|
||||
if (Manager.getClientManager().Get(event.getPlayer()).GetRank() == Rank.LEGEND ||
|
||||
Manager.getClientManager().Get(event.getPlayer()).GetRank() == Rank.ADMIN ||
|
||||
Manager.getClientManager().Get(event.getPlayer()).GetRank() == Rank.DEVELOPER ||
|
||||
Manager.getClientManager().Get(event.getPlayer()).GetRank() == Rank.OWNER)
|
||||
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.LEGEND))
|
||||
{
|
||||
Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName());
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public class ParticleLegend extends ParticleGadget
|
||||
C.cWhite + "These mystic particle attach to",
|
||||
C.cWhite + "only the most legendary of players!",
|
||||
" ",
|
||||
C.cPurple + "Unlocked with Legend Rank",
|
||||
C.cGreen + "Unlocked with Legend Rank",
|
||||
},
|
||||
-2,
|
||||
Material.ENDER_PORTAL, (byte)0);
|
||||
@ -46,7 +46,7 @@ public class ParticleLegend extends ParticleGadget
|
||||
@EventHandler
|
||||
public void legendOwner(PlayerJoinEvent event)
|
||||
{
|
||||
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().Has(Rank.LEGEND))
|
||||
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.LEGEND))
|
||||
{
|
||||
Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName());
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.structs.ItemContainer;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
@ -65,7 +66,7 @@ public class Give extends MiniPlugin
|
||||
public void give(Player player, String target, String itemNames, String amount, String enchants)
|
||||
{
|
||||
//Item
|
||||
LinkedList<Entry<Material, Byte>> itemList = new LinkedList<Entry<Material, Byte>>();
|
||||
LinkedList<ItemContainer> itemList = new LinkedList<ItemContainer>();
|
||||
itemList = UtilItem.matchItem(player, itemNames, true);
|
||||
if (itemList.isEmpty())
|
||||
return;
|
||||
@ -128,11 +129,15 @@ public class Give extends MiniPlugin
|
||||
if (givenList.length() > 0)
|
||||
givenList = givenList.substring(0, givenList.length()-1);
|
||||
|
||||
for (Entry<Material, Byte> curItem : itemList)
|
||||
for (ItemContainer curItem : itemList)
|
||||
{
|
||||
for (Player cur : giveList)
|
||||
{
|
||||
ItemStack stack = ItemStackFactory.Instance.CreateStack(curItem.getKey(), curItem.getValue(), count);
|
||||
ItemStack stack;
|
||||
if (curItem.Name == null)
|
||||
stack = ItemStackFactory.Instance.CreateStack(curItem.Type, curItem.Data, count);
|
||||
else
|
||||
stack = ItemStackFactory.Instance.CreateStack(curItem.Type, curItem.Data, count, curItem.Name);
|
||||
|
||||
//Enchants
|
||||
stack.addUnsafeEnchantments(enchs);
|
||||
@ -142,18 +147,18 @@ public class Give extends MiniPlugin
|
||||
{
|
||||
//Inform
|
||||
if (!cur.equals(player))
|
||||
UtilPlayer.message(cur, F.main("Give", "You received " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.getKey(), curItem.getValue(), false)) + " from " + F.elem(player.getName()) + "."));
|
||||
UtilPlayer.message(cur, F.main("Give", "You received " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.Type, curItem.Data, false)) + " from " + F.elem(player.getName()) + "."));
|
||||
}
|
||||
}
|
||||
|
||||
if (target.equalsIgnoreCase("all"))
|
||||
UtilPlayer.message(player, F.main("Give", "You gave " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.getKey(), curItem.getValue(), false)) + " to " + F.elem("ALL")) + ".");
|
||||
UtilPlayer.message(player, F.main("Give", "You gave " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.Type, curItem.Data, false)) + " to " + F.elem("ALL")) + ".");
|
||||
|
||||
else if (giveList.size() > 1)
|
||||
UtilPlayer.message(player, F.main("Give", "You gave " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.getKey(), curItem.getValue(), false)) + " to " + F.elem(givenList) + "."));
|
||||
UtilPlayer.message(player, F.main("Give", "You gave " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.Type, curItem.Data, false)) + " to " + F.elem(givenList) + "."));
|
||||
|
||||
else
|
||||
UtilPlayer.message(player, F.main("Give", "You gave " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.getKey(), curItem.getValue(), false)) + " to " + F.elem(giveList.getFirst().getName()) + "."));
|
||||
UtilPlayer.message(player, F.main("Give", "You gave " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.Type, curItem.Data, false)) + " to " + F.elem(giveList.getFirst().getName()) + "."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -151,21 +151,47 @@ public class LoadingWindow implements Runnable, Listener {
|
||||
{
|
||||
Player player = Bukkit.getPlayer(_playersUUID);
|
||||
|
||||
if (player == null || _inv == null ? !player.getOpenInventory().equals(_currentInventory) : (_inv != null && !player.getOpenInventory().getTopInventory().equals(_inv))) {
|
||||
end();
|
||||
return;
|
||||
}
|
||||
if (_inv == null) {
|
||||
_inv = Bukkit.createInventory(null, _size, _title);
|
||||
try
|
||||
{
|
||||
if (player == null || player.getOpenInventory() == null || player.getOpenInventory().getTopInventory() == null || _inv == null ? !player.getOpenInventory().equals(_currentInventory) : (!player.getOpenInventory().getTopInventory().equals(_inv)))
|
||||
{
|
||||
end();
|
||||
return;
|
||||
}
|
||||
|
||||
setBackGround();
|
||||
setLoadingBarItems();
|
||||
UtilPlayer.swapToInventory(player, _inv);
|
||||
Bukkit.getPluginManager().registerEvents(this, _plugin);
|
||||
} else
|
||||
setLoadingBarItems();
|
||||
|
||||
_ticker++;
|
||||
if (_inv == null)
|
||||
{
|
||||
_inv = Bukkit.createInventory(null, _size, _title);
|
||||
|
||||
setBackGround();
|
||||
setLoadingBarItems();
|
||||
UtilPlayer.swapToInventory(player, _inv);
|
||||
Bukkit.getPluginManager().registerEvents(this, _plugin);
|
||||
}
|
||||
else
|
||||
setLoadingBarItems();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
try
|
||||
{
|
||||
System.out.println("player ? " + (player == null));
|
||||
System.out.println("player.getOpenInventory() ? " + (player.getOpenInventory() == null));
|
||||
System.out.println("player.getOpenInventory().getTopInventory() ? " + (player.getOpenInventory().getTopInventory() == null));
|
||||
System.out.println("_inv ? " + (_inv == null));
|
||||
exception.printStackTrace();
|
||||
}
|
||||
catch (Exception exception2)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
end();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_ticker++;
|
||||
}
|
||||
}
|
||||
|
||||
public void end() {
|
||||
|
@ -532,8 +532,6 @@ public class Hologram
|
||||
if (newText.equals(_hologramText))
|
||||
return this;
|
||||
|
||||
_makeSpawnPackets = true;
|
||||
|
||||
if (isInUse())
|
||||
{
|
||||
int[] destroy1_7 = new int[0];
|
||||
@ -632,6 +630,7 @@ public class Hologram
|
||||
}
|
||||
|
||||
_hologramText = newText;
|
||||
makeSpawnPackets();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class IgnoreManager extends MiniDbClientPlugin<IgnoreData>
|
||||
@EventHandler
|
||||
public void onChat(AsyncPlayerChatEvent event)
|
||||
{
|
||||
if (ClientManager.Get(event.getPlayer()).GetRank().Has(Rank.HELPER))
|
||||
if (ClientManager.Get(event.getPlayer()).GetRank().has(Rank.HELPER))
|
||||
return;
|
||||
|
||||
Iterator<Player> itel = event.getRecipients().iterator();
|
||||
|
@ -21,6 +21,7 @@ import mineplex.core.inventory.data.InventoryRepository;
|
||||
import mineplex.core.inventory.data.Item;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.playerCache.PlayerCache;
|
||||
|
||||
public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
|
||||
{
|
||||
@ -180,7 +181,7 @@ public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
|
||||
|
||||
synchronized (_inventoryLock)
|
||||
{
|
||||
final boolean success = _repository.incrementClientInventoryItem(ClientManager.getCachedClientAccountId(uuid), _items.get(item).Id, count);
|
||||
final boolean success = _repository.incrementClientInventoryItem(PlayerCache.getInstance().getPlayer(uuid).getAccountId(), _items.get(item).Id, count);
|
||||
|
||||
if (callback != null)
|
||||
{
|
||||
|
@ -308,9 +308,10 @@ public class ItemBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setData(short newData)
|
||||
public ItemBuilder setData(short newData)
|
||||
{
|
||||
this._data = newData;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder setPotion(Potion potion)
|
||||
|
@ -191,7 +191,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
||||
|
||||
// My attempt at trying to mitigate some of the spam bots - Phinary
|
||||
// Triggers if they are whispering a new player
|
||||
if (!GetClientManager().Get(from).GetRank().Has(Rank.HELPER) && Get(from).LastTo != null
|
||||
if (!GetClientManager().Get(from).GetRank().has(Rank.HELPER) && Get(from).LastTo != null
|
||||
&& !Get(from).LastTo.equalsIgnoreCase(to.getName()))
|
||||
{
|
||||
long delta = System.currentTimeMillis() - Get(from).LastToTime;
|
||||
@ -252,7 +252,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
||||
{
|
||||
if (!to.equals(staff) && !from.equals(staff))
|
||||
{
|
||||
if (_clientManager.Get(staff).GetRank().Has(Rank.HELPER))
|
||||
if (_clientManager.Get(staff).GetRank().has(Rank.HELPER))
|
||||
{
|
||||
UtilPlayer.message(staff, F.rank(_clientManager.Get(from).GetRank()) + " " + from.getName() + C.cPurple
|
||||
+ " -> " + F.rank(_clientManager.Get(to).GetRank()) + " " + to.getName() + " " + C.cPurple + message);
|
||||
@ -369,7 +369,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
||||
{
|
||||
if (!to.equals(staff))
|
||||
{
|
||||
if (_clientManager.Get(staff).GetRank().Has(Rank.HELPER))
|
||||
if (_clientManager.Get(staff).GetRank().has(Rank.HELPER))
|
||||
{
|
||||
UtilPlayer.message(staff,
|
||||
|
||||
@ -447,7 +447,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
||||
{
|
||||
if (!target.equals(staff))
|
||||
{
|
||||
if (_clientManager.Get(staff).GetRank().Has(Rank.HELPER))
|
||||
if (_clientManager.Get(staff).GetRank().has(Rank.HELPER))
|
||||
{
|
||||
UtilPlayer.message(staff,
|
||||
|
||||
|
@ -21,7 +21,7 @@ public class AdminCommand extends CommandBase<MessageManager>
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args == null)
|
||||
if (args == null || args.length == 0)
|
||||
{
|
||||
Plugin.Help(caller);
|
||||
}
|
||||
@ -48,7 +48,7 @@ public class AdminCommand extends CommandBase<MessageManager>
|
||||
boolean staff = false;
|
||||
for (Player to : UtilServer.getPlayers())
|
||||
{
|
||||
if (Plugin.GetClientManager().Get(to).GetRank().Has(Rank.HELPER))
|
||||
if (Plugin.GetClientManager().Get(to).GetRank().has(Rank.HELPER))
|
||||
{
|
||||
if (!to.equals(caller))
|
||||
UtilPlayer.message(to, F.rank(Plugin.GetClientManager().Get(caller).GetRank()) + " " + caller.getName() + " " + C.cPurple + message);
|
||||
|
@ -18,7 +18,7 @@ public class AdminMessageCommand extends CommandBase<MessageManager>
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args == null)
|
||||
if (args == null || args.length == 0)
|
||||
{
|
||||
Plugin.Help(caller);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public class AnnounceCommand extends CommandBase<MessageManager>
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args == null)
|
||||
if (args == null || args.length == 0)
|
||||
{
|
||||
Plugin.Help(caller);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public class GlobalCommand extends CommandBase<MessageManager>
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args == null)
|
||||
if (args == null || args.length == 0)
|
||||
{
|
||||
Plugin.Help(caller);
|
||||
}
|
||||
|
@ -18,13 +18,13 @@ public class MessageAdminCommand extends CommandBase<MessageManager>
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args == null)
|
||||
if (args == null || args.length == 0)
|
||||
{
|
||||
Plugin.Help(caller);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Plugin.GetClientManager().Get(caller).GetRank().Has(caller, Rank.HELPER, true))
|
||||
if (!Plugin.GetClientManager().Get(caller).GetRank().has(caller, Rank.HELPER, true))
|
||||
return;
|
||||
|
||||
if (args.length == 0)
|
||||
|
@ -18,7 +18,7 @@ public class MessageCommand extends CommandBase<MessageManager>
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args == null)
|
||||
if (args == null || args.length == 0)
|
||||
{
|
||||
Plugin.Help(caller);
|
||||
}
|
||||
|
@ -18,13 +18,13 @@ public class ResendAdminCommand extends CommandBase<MessageManager>
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args == null)
|
||||
if (args == null || args.length == 0)
|
||||
{
|
||||
Plugin.Help(caller);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Plugin.GetClientManager().Get(caller).GetRank().Has(caller, Rank.HELPER, true))
|
||||
if (!Plugin.GetClientManager().Get(caller).GetRank().has(caller, Rank.HELPER, true))
|
||||
return;
|
||||
|
||||
String lastTo = Plugin.Get(caller).LastAdminTo;
|
||||
|
@ -18,7 +18,7 @@ public class ResendCommand extends CommandBase<MessageManager>
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args == null)
|
||||
if (args == null || args.length == 0)
|
||||
{
|
||||
Plugin.Help(caller);
|
||||
}
|
||||
|
@ -9,7 +9,9 @@ import mineplex.core.common.util.F;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -25,9 +27,14 @@ public class LagMeter extends MiniPlugin
|
||||
private double _ticksPerSecond;
|
||||
private double _ticksPerSecondAverage;
|
||||
private long _lastAverage;
|
||||
private long _start;
|
||||
|
||||
private long _lastTick = 0;
|
||||
|
||||
private boolean _timingsRunning;
|
||||
private boolean _timingsPasted;
|
||||
private long _timingsStarted;
|
||||
|
||||
private HashSet<Player> _monitoring = new HashSet<Player>();
|
||||
|
||||
public LagMeter(JavaPlugin plugin, CoreClientManager clientManager)
|
||||
@ -37,12 +44,14 @@ public class LagMeter extends MiniPlugin
|
||||
_clientManager = clientManager;
|
||||
_lastRun = System.currentTimeMillis();
|
||||
_lastAverage = System.currentTimeMillis();
|
||||
|
||||
_start = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerCommandPreProcess(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.MODERATOR))
|
||||
if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.MODERATOR))
|
||||
{
|
||||
if (event.getMessage().trim().equalsIgnoreCase("/lag"))
|
||||
{
|
||||
@ -87,6 +96,24 @@ public class LagMeter extends MiniPlugin
|
||||
_lastRun = now;
|
||||
|
||||
_count++;
|
||||
|
||||
if (System.currentTimeMillis() - _start > 60000)
|
||||
{
|
||||
if (_timingsRunning)
|
||||
{
|
||||
if (_ticksPerSecond > 15 || System.currentTimeMillis() - _timingsStarted > 60000)
|
||||
{
|
||||
getPlugin().getServer().dispatchCommand(Bukkit.getConsoleSender(), "timings paste");
|
||||
_timingsRunning = false;
|
||||
}
|
||||
}
|
||||
else if (_ticksPerSecond < 10)
|
||||
{
|
||||
_timingsRunning = true;
|
||||
_timingsStarted = System.currentTimeMillis();
|
||||
getPlugin().getServer().dispatchCommand(Bukkit.getConsoleSender(), "timings on");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double getTicksPerSecond()
|
||||
|
@ -110,7 +110,7 @@ public class MountDragon extends DragonMount
|
||||
@EventHandler
|
||||
public void HeroOwner(PlayerJoinEvent event)
|
||||
{
|
||||
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().Has(Rank.HERO))
|
||||
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.HERO))
|
||||
{
|
||||
Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName());
|
||||
}
|
||||
|
@ -22,12 +22,12 @@ public class NotificationManager extends MiniPlugin
|
||||
private CoreClientManager _clientManager;
|
||||
|
||||
private String _summerLine =
|
||||
C.cYellow + "█" + C.cGold + "█" + C.cYellow + "█" + C.cGold + "█" + C.cYellow + "█" + C.cGold + "█" +
|
||||
C.cYellow + "█" + C.cGold + "█" + C.cYellow + "█" + C.cGold + "█" + C.cYellow + "█" + C.cGold + "█" +
|
||||
C.cYellow + "█" + C.cGold + "█" + C.cYellow + "█" + C.cGold + "█" + C.cYellow + "█" + C.cGold + "█" +
|
||||
C.cYellow + "█" + C.cGold + "█" + C.cYellow + "█" + C.cGold + "█" + C.cYellow + "█" + C.cGold + "█" +
|
||||
C.cYellow + "█" + C.cGold + "█" + C.cYellow + "█" + C.cGold + "█" + C.cYellow + "█" + C.cGold + "█" +
|
||||
C.cYellow + "█" + C.cGold + "█" + C.cYellow + "█" + C.cGold + "█" + C.cYellow + "█";
|
||||
C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" +
|
||||
C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" +
|
||||
C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" +
|
||||
C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" +
|
||||
C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" +
|
||||
C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█";
|
||||
|
||||
public NotificationManager(JavaPlugin plugin, CoreClientManager client)
|
||||
{
|
||||
@ -42,11 +42,11 @@ public class NotificationManager extends MiniPlugin
|
||||
if (!_enabled)
|
||||
return;
|
||||
|
||||
if (event.getType() == UpdateType.MIN_08)
|
||||
hugeSale();
|
||||
// if (event.getType() == UpdateType.MIN_08)
|
||||
// hugeSale();
|
||||
|
||||
// if (event.getType() == UpdateType.MIN_16)
|
||||
// sale();
|
||||
if (event.getType() == UpdateType.MIN_16)
|
||||
sale();
|
||||
}
|
||||
|
||||
private void sale()
|
||||
@ -55,20 +55,20 @@ public class NotificationManager extends MiniPlugin
|
||||
{
|
||||
Rank rank = _clientManager.Get(player).GetRank();
|
||||
|
||||
if (rank.Has(Rank.LEGEND))
|
||||
if (rank.has(Rank.LEGEND))
|
||||
continue;
|
||||
|
||||
if (rank == Rank.ALL)
|
||||
{
|
||||
UtilPlayer.message(player, C.cWhite + "Summer Sale! " + " Purchase " + C.cAqua + C.Bold + "Ultra RANK" + C.cWhite + " for $15");
|
||||
UtilPlayer.message(player, C.cWhite + "50% Off Sale! " + " Purchase " + C.cAqua + C.Bold + "Ultra Rank" + C.cWhite + " for $15");
|
||||
}
|
||||
else if (rank == Rank.ULTRA)
|
||||
{
|
||||
UtilPlayer.message(player, C.cWhite + "Summer Sale! " + " Upgrade to " + C.cPurple + C.Bold + "HERO RANK" + C.cWhite + " for $15!");
|
||||
UtilPlayer.message(player, C.cWhite + "50% Off Sale! " + " Upgrade to " + C.cPurple + C.Bold + "Hero Rank" + C.cWhite + " for $15!");
|
||||
}
|
||||
else if (rank == Rank.HERO)
|
||||
{
|
||||
UtilPlayer.message(player, C.cWhite + "Summer Sale! " + "Upgrade to " + C.cGreen + C.Bold + "LEGEND RANK" + C.cWhite + " for $15!");
|
||||
UtilPlayer.message(player, C.cWhite + "50% Off Sale! " + "Upgrade to " + C.cGreen + C.Bold + "Legend Rank" + C.cWhite + " for $15!");
|
||||
}
|
||||
|
||||
UtilPlayer.message(player, C.cWhite + " Visit " + F.link("www.mineplex.com/shop") + " for 50% Off Ranks!");
|
||||
@ -81,7 +81,7 @@ public class NotificationManager extends MiniPlugin
|
||||
{
|
||||
Rank rank = _clientManager.Get(player).GetRank();
|
||||
|
||||
if (rank.Has(Rank.LEGEND))
|
||||
if (rank.has(Rank.LEGEND))
|
||||
continue;
|
||||
|
||||
UtilPlayer.message(player, _summerLine);
|
||||
|
@ -19,7 +19,7 @@ public class AddCommand extends CommandBase<NpcManager>
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args == null)
|
||||
if (args == null || args.length == 0)
|
||||
Plugin.help(caller);
|
||||
else
|
||||
{
|
||||
|
@ -20,7 +20,7 @@ public class ClearCommand extends CommandBase<NpcManager>
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args != null)
|
||||
if (args.length > 0)
|
||||
Plugin.help(caller);
|
||||
else
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ public class DeleteCommand extends CommandBase<NpcManager>
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args != null)
|
||||
if (args.length > 0)
|
||||
Plugin.help(caller);
|
||||
else
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ public class HomeCommand extends CommandBase<NpcManager>
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args != null)
|
||||
if (args.length > 0)
|
||||
Plugin.help(caller);
|
||||
else
|
||||
{
|
||||
|
@ -20,7 +20,7 @@ public class RefreshCommand extends CommandBase<NpcManager>
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args != null)
|
||||
if (args.length > 0)
|
||||
Plugin.help(caller);
|
||||
else
|
||||
{
|
||||
|
@ -47,9 +47,21 @@ public class PacketHandler extends MiniPlugin
|
||||
EnumProtocol.PLAY.a().put(2, PacketPlayUseEntity.class);
|
||||
EnumProtocol.PLAY.a().put(PacketPlayUseEntity.class, 2);
|
||||
|
||||
// NBT Overflow Exploit Handlers
|
||||
EnumProtocol.PLAY.a().put(8, PacketPlayInBlockPace.class);
|
||||
EnumProtocol.PLAY.a().put(PacketPlayInBlockPace.class, 8);
|
||||
|
||||
EnumProtocol.PLAY.a().put(14, PacketPlayInWindowClick.class);
|
||||
EnumProtocol.PLAY.a().put(PacketPlayInWindowClick.class, 14);
|
||||
|
||||
EnumProtocol.PLAY.a().put(16, PacketPlayInSetCreativeSlot.class);
|
||||
EnumProtocol.PLAY.a().put(PacketPlayInSetCreativeSlot.class, 16);
|
||||
// ----------------------------
|
||||
|
||||
Method method = ProtocolInjector.class.getDeclaredMethod("addPacket", EnumProtocol.class,boolean.class, int.class, Class.class);
|
||||
method.setAccessible(true);
|
||||
|
||||
|
||||
method.invoke(null, EnumProtocol.PLAY, true, 67, PacketPlayOutCamera.class);
|
||||
method.invoke(null, EnumProtocol.PLAY, true, 68, PacketPlayOutWorldBorder.class);
|
||||
|
||||
// EnumProtocol.PLAY.b().put(68, PacketPlayOutWorldBorder.class);
|
||||
|
@ -0,0 +1,15 @@
|
||||
package mineplex.core.packethandler;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.PacketDataSerializer;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayInBlockPlace;
|
||||
|
||||
public class PacketPlayInBlockPace extends PacketPlayInBlockPlace
|
||||
{
|
||||
|
||||
@Override
|
||||
public void a(PacketDataSerializer data)
|
||||
{
|
||||
super.a(WrappedPacketDataSerializer.wrapDataSerializer(data));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package mineplex.core.packethandler;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.PacketDataSerializer;
|
||||
|
||||
public class PacketPlayInSetCreativeSlot extends net.minecraft.server.v1_7_R4.PacketPlayInSetCreativeSlot
|
||||
{
|
||||
|
||||
@Override
|
||||
public void a(PacketDataSerializer data)
|
||||
{
|
||||
super.a(WrappedPacketDataSerializer.wrapDataSerializer(data));
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package mineplex.core.packethandler;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.PacketDataSerializer;
|
||||
|
||||
public class PacketPlayInWindowClick extends net.minecraft.server.v1_7_R4.PacketPlayInWindowClick
|
||||
{
|
||||
|
||||
@Override
|
||||
public void a(PacketDataSerializer data)
|
||||
{
|
||||
super.a(WrappedPacketDataSerializer.wrapDataSerializer(data));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package mineplex.core.packethandler;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.Packet;
|
||||
import net.minecraft.server.v1_7_R4.PacketDataSerializer;
|
||||
import net.minecraft.server.v1_7_R4.PacketListener;
|
||||
|
||||
public class PacketPlayOutCamera extends Packet
|
||||
{
|
||||
public int a;
|
||||
|
||||
public PacketPlayOutCamera()
|
||||
{
|
||||
}
|
||||
|
||||
public PacketPlayOutCamera(int id)
|
||||
{
|
||||
a = id;
|
||||
}
|
||||
|
||||
public PacketPlayOutCamera(Entity paramEntity)
|
||||
{
|
||||
this.a = paramEntity.getEntityId();
|
||||
}
|
||||
|
||||
public void a(PacketDataSerializer paramPacketDataSerializer)
|
||||
{
|
||||
}
|
||||
|
||||
public void b(PacketDataSerializer paramPacketDataSerializer)
|
||||
{
|
||||
paramPacketDataSerializer.b(this.a);
|
||||
}
|
||||
|
||||
public void a(PacketListener paramPacketListenerPlayOut)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketListener arg0)
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package mineplex.core.packethandler;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
|
||||
import org.spigotmc.LimitStream;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.Item;
|
||||
import net.minecraft.server.v1_7_R4.ItemStack;
|
||||
import net.minecraft.server.v1_7_R4.NBTCompressedStreamTools;
|
||||
import net.minecraft.server.v1_7_R4.NBTReadLimiter;
|
||||
import net.minecraft.server.v1_7_R4.NBTTagCompound;
|
||||
import net.minecraft.server.v1_7_R4.PacketDataSerializer;
|
||||
import net.minecraft.util.io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.util.io.netty.buffer.ByteBufInputStream;
|
||||
|
||||
public class WrappedPacketDataSerializer extends PacketDataSerializer
|
||||
{
|
||||
|
||||
public WrappedPacketDataSerializer(ByteBuf bytebuf)
|
||||
{
|
||||
super(bytebuf);
|
||||
}
|
||||
|
||||
public WrappedPacketDataSerializer(ByteBuf bytebuf, int version)
|
||||
{
|
||||
super(bytebuf, version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack c()
|
||||
{
|
||||
try {
|
||||
ItemStack itemstack = null;
|
||||
short short0 = readShort();
|
||||
if (short0 >= 0)
|
||||
{
|
||||
byte b0 = readByte();
|
||||
short short1 = readShort();
|
||||
|
||||
itemstack = new ItemStack(Item.getById(short0), b0, short1);
|
||||
itemstack.setTag(b());
|
||||
if (itemstack.getTag() != null) {
|
||||
CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
|
||||
}
|
||||
}
|
||||
return itemstack;
|
||||
} catch (Exception e) {
|
||||
this.clear();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound b()
|
||||
{
|
||||
int i = readerIndex();
|
||||
byte b0 = readByte();
|
||||
if (b0 == 0) {
|
||||
return null;
|
||||
}
|
||||
readerIndex(i);
|
||||
ByteBufInputStream data = new ByteBufInputStream(this);
|
||||
NBTReadLimiter nbtreadlimiter = new NBTReadLimiter(2097152L);
|
||||
return NBTCompressedStreamTools.a(new DataInputStream(new LimitStream((InputStream)data, nbtreadlimiter)), nbtreadlimiter);
|
||||
}
|
||||
|
||||
public static WrappedPacketDataSerializer wrapDataSerializer(PacketDataSerializer data) {
|
||||
try
|
||||
{
|
||||
Field a = data.getClass().getDeclaredField("a");
|
||||
a.setAccessible(true);
|
||||
ByteBuf buff = (ByteBuf) a.get(data);
|
||||
WrappedPacketDataSerializer w = new WrappedPacketDataSerializer(buff, data.version);
|
||||
return w;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user