Merge branch 'master' into clans_custom_gear
This commit is contained in:
commit
6b3028605e
@ -5,7 +5,6 @@
|
||||
<element id="module-output" name="Mineplex.Core" />
|
||||
<element id="module-output" name="Mineplex.Core.Common" />
|
||||
<element id="module-output" name="Mineplex.Database" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.4.2.jar" path-in-jar="/" />
|
||||
<element id="module-output" name="Mineplex.Game.Clans" />
|
||||
<element id="module-output" name="Mineplex.Minecraft.Game.Core" />
|
||||
<element id="module-output" name="Mineplex.Minecraft.Game.ClassCombat" />
|
||||
@ -18,6 +17,7 @@
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/gson-2.2.1.jar" path-in-jar="/" />
|
||||
<element id="file-copy" path="$PROJECT_DIR$/Mineplex.Game.Clans/plugin.yml" />
|
||||
<element id="module-output" name="Mineplex.ServerData" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.5.2.jar" path-in-jar="/" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
@ -17,8 +17,8 @@
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-pool2-2.2.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jedis-2.4.2.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/gson-2.2.1.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.4.2.jar" path-in-jar="/" />
|
||||
<element id="module-output" name="Mineplex.Database" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.5.2.jar" path-in-jar="/" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
@ -17,7 +17,7 @@
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jedis-2.4.2.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/gson-2.2.1.jar" path-in-jar="/" />
|
||||
<element id="module-output" name="Mineplex.Database" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.4.2.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.5.2.jar" path-in-jar="/" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
@ -10,7 +10,4 @@
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="TaskProjectConfiguration">
|
||||
<server type="JIRA" url="http://184.154.0.242:8080" />
|
||||
</component>
|
||||
</project>
|
@ -14,6 +14,7 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/Mineplex.Minecraft.BungeeSigns/Mineplex.Minecraft.BungeeSigns.iml" filepath="$PROJECT_DIR$/Mineplex.Minecraft.BungeeSigns/Mineplex.Minecraft.BungeeSigns.iml" group="Bungee" />
|
||||
<module fileurl="file://$PROJECT_DIR$/Mineplex.Minecraft.Game.ClassCombat/Mineplex.Minecraft.Game.ClassCombat.iml" filepath="$PROJECT_DIR$/Mineplex.Minecraft.Game.ClassCombat/Mineplex.Minecraft.Game.ClassCombat.iml" group="Game" />
|
||||
<module fileurl="file://$PROJECT_DIR$/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml" filepath="$PROJECT_DIR$/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml" group="Game" />
|
||||
<module fileurl="file://$PROJECT_DIR$/Mineplex.PlayerCache/Mineplex.PlayerCache.iml" filepath="$PROJECT_DIR$/Mineplex.PlayerCache/Mineplex.PlayerCache.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/Mineplex.ServerData/Mineplex.ServerData.iml" filepath="$PROJECT_DIR$/Mineplex.ServerData/Mineplex.ServerData.iml" group="Core" />
|
||||
<module fileurl="file://$PROJECT_DIR$/Mineplex.ServerMonitor/Mineplex.ServerMonitor.iml" filepath="$PROJECT_DIR$/Mineplex.ServerMonitor/Mineplex.ServerMonitor.iml" group="Core" />
|
||||
<module fileurl="file://$PROJECT_DIR$/Nautilus.Game.Arcade/Nautilus.Game.Arcade.iml" filepath="$PROJECT_DIR$/Nautilus.Game.Arcade/Nautilus.Game.Arcade.iml" group="Game" />
|
||||
|
@ -18,6 +18,9 @@
|
||||
<fileset dir="../Mineplex.EnjinTranslator">
|
||||
<include name="*.yml"/>
|
||||
</fileset>
|
||||
<fileset dir="../Mineplex.ServerData/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
|
||||
<zipfileset src="../Libraries/jooq-3.5.2.jar" />
|
||||
<zipfileset src="../Libraries/httpclient-4.2.jar" />
|
||||
|
@ -1,5 +1,64 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="loc" default="default" basedir=".">
|
||||
<property name="lib.dir" value="../Libraries"/>
|
||||
<path id="classpath">
|
||||
<fileset dir="${lib.dir}" includes="**/*.jar"/>
|
||||
</path>
|
||||
<target name="compileArcade1" description="Arcade Compilation Step 1">
|
||||
<javac srcdir="../Mineplex.Core.Common/src" destdir="../Mineplex.Core.Common/bin" classpathref="classpath"/>
|
||||
<jar jarfile="../bin/Mineplex.Core.Common.jar">
|
||||
<fileset dir="../Mineplex.Core.Common/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
</jar>
|
||||
<copy file="../bin/Mineplex.Core.Common.jar" todir="../Libraries"/>
|
||||
</target>
|
||||
<target name="compileArcade2" description="Arcade Compilation Step 2">
|
||||
<path id="classpathCommon">
|
||||
<fileset dir="../Libraries" includes="**/*.jar"/>
|
||||
</path>
|
||||
<javac srcdir="../Mineplex.ServerData/src" destdir="../Mineplex.ServerData/bin" classpathref="classpathCommon"/>
|
||||
<jar jarfile="../bin/Mineplex.ServerData.jar">
|
||||
<fileset dir="../Mineplex.ServerData/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
</jar>
|
||||
<copy file="../bin/Mineplex.ServerData.jar" todir="../Libraries"/>
|
||||
</target>
|
||||
<target name="compileArcade3" description="Arcade Compilation Step 3">
|
||||
<path id="classpathCommon">
|
||||
<fileset dir="../Libraries" includes="**/*.jar"/>
|
||||
</path>
|
||||
<javac srcdir="../Mineplex.Database/src" destdir="../Mineplex.Database/bin" classpathref="classpathCommon"/>
|
||||
<jar jarfile="../bin/Mineplex.Database.jar">
|
||||
<fileset dir="../Mineplex.Database/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
</jar>
|
||||
<copy file="../bin/Mineplex.Database.jar" todir="../Libraries"/>
|
||||
</target>
|
||||
<target name="compileArcade4" description="Arcade Compilation Step 4">
|
||||
<path id="classpathCommon">
|
||||
<fileset dir="../Libraries" includes="**/*.jar"/>
|
||||
</path>
|
||||
<javac srcdir="../Mineplex.Core/src" destdir="../Mineplex.Core/bin" classpathref="classpathCommon"/>
|
||||
<jar jarfile="../bin/Mineplex.Core.jar">
|
||||
<fileset dir="../Mineplex.Core/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
</jar>
|
||||
<copy file="../bin/Mineplex.Core.jar" todir="../Libraries"/>
|
||||
</target>
|
||||
<target name="compileArcade" description="Arcade Compilation Step #">
|
||||
</target>
|
||||
<target name="compileArcade5" description="Arcade Compilation Step 5">
|
||||
<path id="classpathCommon">
|
||||
<fileset dir="../Libraries" includes="**/*.jar"/>
|
||||
</path>
|
||||
<javac srcdir="../Mineplex.Minecraft.Game.Core/src" destdir="../Mineplex.Minecraft.Game.Core/bin" classpathref="classpathCommon"/>
|
||||
<javac srcdir="../Mineplex.Minecraft.Game.ClassCombat/src" destdir="../Mineplex.Minecraft.Game.ClassCombat/bin" classpathref="classpathCommon"/>
|
||||
<javac srcdir="../Nautilus.Game.Arcade/src" destdir="../Nautilus.Game.Arcade/bin" classpathref="classpathCommon"/>
|
||||
</target>
|
||||
<target name ="Arcade" description="Arcade">
|
||||
<jar jarfile="../bin/Arcade.jar">
|
||||
<fileset dir="../Nautilus.Game.Arcade/bin">
|
||||
@ -42,6 +101,33 @@
|
||||
</jar>
|
||||
<copy file="../bin/Arcade.jar" todir="../../Testing/Arcade/plugins"/>
|
||||
</target>
|
||||
<target name="compileHub" description="Hub Compilation">
|
||||
<javac srcdir="../Mineplex.Core.Common/src" destdir="../Mineplex.Core.Common/bin" classpathref="classpath"/>
|
||||
<jar jarfile="../bin/Mineplex.Core.Common.jar">
|
||||
<fileset dir="../Mineplex.Core.Common/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
</jar>
|
||||
<copy file="../bin/Mineplex.Core.Common.jar" todir="../Libraries"/>
|
||||
<path id="classpathCommon">
|
||||
<fileset dir="../Libraries" includes="**/*.jar"/>
|
||||
</path>
|
||||
<javac srcdir="../Mineplex.Core/src" destdir="../Mineplex.Core/bin" classpathref="classpathCommon"/>
|
||||
<jar jarfile="../bin/Mineplex.Core.jar">
|
||||
<fileset dir="../Mineplex.Core/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
</jar>
|
||||
<copy file="../bin/Mineplex.Core.jar" todir="../Libraries"/>
|
||||
<path id="classpathCommon">
|
||||
<fileset dir="../Libraries" includes="**/*.jar"/>
|
||||
</path>
|
||||
<javac srcdir="../Mineplex.Minecraft.Game.Core/src" destdir="../Mineplex.Minecraft.Game.Core/bin" classpathref="classpathCommon"/>
|
||||
<javac srcdir="../Mineplex.Minecraft.Game.ClassCombat/src" destdir="../Mineplex.Minecraft.Game.ClassCombat/bin" classpathref="classpathCommon"/>
|
||||
<javac srcdir="../Mineplex.Database/src" destdir="../Mineplex.Database/bin" classpathref="classpathCommon"/>
|
||||
<javac srcdir="../Mineplex.ServerData/src" destdir="../Mineplex.ServerData/bin" classpathref="classpathCommon"/>
|
||||
<javac srcdir="../Mineplex.Hub/src" destdir="../Mineplex.Hub/bin" classpathref="classpathCommon"/>
|
||||
</target>
|
||||
<target name ="Hub" description="Hub">
|
||||
<jar jarfile="../bin/Hub.jar">
|
||||
<fileset dir="../Mineplex.Hub/bin">
|
||||
@ -224,6 +310,10 @@
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
|
||||
<fileset dir="../Mineplex.PlayerCache/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
|
||||
<zipfileset src="../Libraries/commons-codec-1.6.jar" />
|
||||
<zipfileset src="../Libraries/commons-io-2.4.jar" />
|
||||
<zipfileset src="../Libraries/jedis-2.4.2.jar" />
|
||||
@ -275,11 +365,11 @@
|
||||
value="mineplex.bungee.BungeeRotator"/>
|
||||
</manifest>
|
||||
|
||||
<zipfileset src="../Libraries/jooq-3.5.2.jar" />
|
||||
<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/jooq-3.5.2.jar" />
|
||||
<zipfileset src="../Libraries/gson-2.2.1.jar" />
|
||||
<zipfileset src="../Libraries/commons-logging-1.1.1.jar" />
|
||||
<zipfileset src="../Libraries/commons-codec-1.6.jar" />
|
||||
|
@ -6,6 +6,7 @@
|
||||
package net.minecraft.server.v1_7_R4;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_7_R4.scoreboard.CraftScoreboard;
|
||||
@ -16,6 +17,11 @@ import net.minecraft.util.com.mojang.authlib.properties.Property;
|
||||
import net.minecraft.util.com.mojang.authlib.properties.PropertyMap;
|
||||
|
||||
public class PacketPlayOutPlayerInfo extends Packet {
|
||||
|
||||
public static final String NOTCH_SKIN = "eyJ0aW1lc3RhbXAiOjE0Mjc4MjgyMzMwNDUsInByb2ZpbGVJZCI6IjA2OWE3OWY0NDRlOTQ3MjZhNWJlZmNhOTBlMzhhYWY1IiwicHJvZmlsZU5hbWUiOiJOb3RjaCIsImlzUHVibGljIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTExNmU2OWE4NDVlMjI3ZjdjYTFmZGRlOGMzNTdjOGM4MjFlYmQ0YmE2MTkzODJlYTRhMWY4N2Q0YWU5NCJ9LCJDQVBFIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2Y2ODhlMGU2OTliM2Q5ZmU0NDhiNWJiNTBhM2EyODhmOWM1ODk3NjJiM2RhZTgzMDg4NDIxMjJkY2I4MSJ9fX0=";
|
||||
public static final String NOTCH_SIGNATURE = "WrBmNqkpkjh6VJY26jOOMNS6oSOPi0MTm9WWc0t4EMUHchUbTd6/1sT2O2zz2s7xwmCeUxuIhvRREa+1bIPzIIbXJLjhxiBWMdTJbQhv6zBb1U2SZb7eb5cYrFTD6rvxy0rOarScxCBdeOXpr1coxrvN8a6VkgLhc/dGhFx0ZmORxELBLFiCNi+4WE//MI+KioAq84Gdf0ltT9ZLWdlHNFV2ynBgcx2MfNTA2lrpdKEUVOYD7xhPoOdHa5d1hzdDxbYPGDgM0FzYjzNUlBx8SLvHEpyBB7XyOsIGnfqrS0ltIDTq82wgLrEwDRncuQN18w6IiQbNK06MZBDyNnIp79mmUYvRj+Zl0dPBrZok2q2uQ08hZ87ufU3jhjY39kr+iEaPYMvfWaBxt3ALjopsZRCGSlEukMzITjeYxhfVKuQ0fhWKRfwWn/Jv2de2h+i+t7nulvN3MV3rJVrS6OXsx87p/vm9biU7Hs07T8VSGONfkxXmsgYEtY6m2egU5pmqFnsKM0MwwnZJ7Sxz2EjiPikoGzJzpv4ncj3rhelIKJKjDk9jSAz7nPzc8/UdOiTrfy4ezr3jFVAVatiKr+kS/HNXHWiCFdufhpG4DVCrSkwkFBJw030pJ6ICVhpuYq5yOswQB5QOp0JDWc2Rdth7SVmvxthSCL9G2ksfm+v7sKw=";
|
||||
|
||||
|
||||
public static final int ADD_PLAYER = 0;
|
||||
public static final int UPDATE_GAMEMODE = 1;
|
||||
public static final int UPDATE_LATENCY = 2;
|
||||
@ -38,6 +44,7 @@ public class PacketPlayOutPlayerInfo extends Packet {
|
||||
packet.player = player.getProfile();
|
||||
packet.ping = player.ping;
|
||||
packet.gamemode = player.playerInteractManager.getGameMode().getId();
|
||||
|
||||
packet._tabName = getFormattedName(player);
|
||||
return packet;
|
||||
}
|
||||
@ -87,6 +94,9 @@ public class PacketPlayOutPlayerInfo extends Packet {
|
||||
|
||||
public void b(PacketDataSerializer packetdataserializer) throws IOException {
|
||||
if(packetdataserializer.version >= 20) {
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
|
||||
packetdataserializer.b(this.action);
|
||||
packetdataserializer.b(1);
|
||||
packetdataserializer.writeUUID(this.player.getId());
|
||||
@ -94,16 +104,41 @@ public class PacketPlayOutPlayerInfo extends Packet {
|
||||
case 0:
|
||||
packetdataserializer.a(this.player.getName());
|
||||
PropertyMap properties = this.player.getProperties();
|
||||
|
||||
// April Fools
|
||||
if (isAprilFools() && properties.size() == 0)
|
||||
{
|
||||
// add texture if no textures exist
|
||||
properties.put("textures", new Property("textures", NOTCH_SKIN, NOTCH_SIGNATURE));
|
||||
|
||||
}
|
||||
|
||||
packetdataserializer.b(properties.size());
|
||||
Iterator var3 = properties.values().iterator();
|
||||
|
||||
while(var3.hasNext()) {
|
||||
Property property = (Property)var3.next();
|
||||
packetdataserializer.a(property.getName());
|
||||
packetdataserializer.a(property.getValue());
|
||||
packetdataserializer.writeBoolean(property.hasSignature());
|
||||
if(property.hasSignature()) {
|
||||
packetdataserializer.a(property.getSignature());
|
||||
|
||||
// April Fools
|
||||
if (isAprilFools() && property.getName().equalsIgnoreCase("textures"))
|
||||
{
|
||||
System.out.println("Applying notch texture for : " + property.getName());
|
||||
System.out.println("Skin: " + property.getValue());
|
||||
System.out.println("Signature: " + property.getSignature());
|
||||
packetdataserializer.a(property.getName());
|
||||
packetdataserializer.a(NOTCH_SKIN);
|
||||
packetdataserializer.writeBoolean(true);
|
||||
packetdataserializer.a(NOTCH_SIGNATURE);
|
||||
}
|
||||
else
|
||||
{
|
||||
packetdataserializer.a(property.getName());
|
||||
packetdataserializer.a(property.getValue());
|
||||
|
||||
packetdataserializer.writeBoolean(property.hasSignature());
|
||||
if(property.hasSignature()) {
|
||||
packetdataserializer.a(property.getSignature());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,6 +184,8 @@ public class PacketPlayOutPlayerInfo extends Packet {
|
||||
{
|
||||
String name = player.getName();
|
||||
|
||||
if (isAprilFools()) name = "Notch";
|
||||
|
||||
CraftScoreboard scoreboard = player.getBukkitEntity().getScoreboard();
|
||||
if (scoreboard != null)
|
||||
{
|
||||
@ -159,4 +196,12 @@ public class PacketPlayOutPlayerInfo extends Packet {
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
public static boolean isAprilFools()
|
||||
{
|
||||
Calendar c = Calendar.getInstance();
|
||||
|
||||
// return true;
|
||||
return c.get(Calendar.MONTH) == Calendar.APRIL && c.get(Calendar.DAY_OF_MONTH) == 1;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,179 @@
|
||||
package net.minecraft.server.v1_7_R4;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import net.minecraft.server.v1_7_R4.Packet;
|
||||
import net.minecraft.server.v1_7_R4.PacketDataSerializer;
|
||||
import net.minecraft.server.v1_7_R4.PacketListener;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutListener;
|
||||
|
||||
public class PacketPlayOutWorldParticles extends Packet {
|
||||
private String a;
|
||||
private float b;
|
||||
private float c;
|
||||
private float d;
|
||||
private float e;
|
||||
private float f;
|
||||
private float g;
|
||||
private float h;
|
||||
private int i;
|
||||
private boolean _displayFar;
|
||||
|
||||
public PacketPlayOutWorldParticles() {
|
||||
}
|
||||
|
||||
public PacketPlayOutWorldParticles(String s, float f, float f1, float f2, float f3, float f4, float f5, float f6, int i) {
|
||||
this(s, f, f1, f2, f3, f4, f5, f6, i, false);
|
||||
}
|
||||
|
||||
public PacketPlayOutWorldParticles(String s, float f, float f1, float f2, float f3, float f4, float f5, float f6, int i, boolean displayFar) {
|
||||
this.a = s;
|
||||
this.b = f;
|
||||
this.c = f1;
|
||||
this.d = f2;
|
||||
this.e = f3;
|
||||
this.f = f4;
|
||||
this.g = f5;
|
||||
this.h = f6;
|
||||
this.i = i;
|
||||
|
||||
_displayFar = displayFar;
|
||||
}
|
||||
|
||||
public void a(PacketDataSerializer packetdataserializer) throws IOException {
|
||||
this.a = packetdataserializer.c(64);
|
||||
this.b = packetdataserializer.readFloat();
|
||||
this.c = packetdataserializer.readFloat();
|
||||
this.d = packetdataserializer.readFloat();
|
||||
this.e = packetdataserializer.readFloat();
|
||||
this.f = packetdataserializer.readFloat();
|
||||
this.g = packetdataserializer.readFloat();
|
||||
this.h = packetdataserializer.readFloat();
|
||||
this.i = packetdataserializer.readInt();
|
||||
}
|
||||
|
||||
public void b(PacketDataSerializer packetdataserializer) throws IOException {
|
||||
String[] parts = this.a.split("_");
|
||||
PacketPlayOutWorldParticles.Particle particle = PacketPlayOutWorldParticles.Particle.find(parts[0]);
|
||||
if(particle == null) {
|
||||
particle = PacketPlayOutWorldParticles.Particle.CRIT;
|
||||
}
|
||||
|
||||
if(packetdataserializer.version < 17) {
|
||||
packetdataserializer.a(this.a);
|
||||
} else {
|
||||
packetdataserializer.writeInt(particle.ordinal());
|
||||
packetdataserializer.writeBoolean(_displayFar);
|
||||
}
|
||||
|
||||
packetdataserializer.writeFloat(this.b);
|
||||
packetdataserializer.writeFloat(this.c);
|
||||
packetdataserializer.writeFloat(this.d);
|
||||
packetdataserializer.writeFloat(this.e);
|
||||
packetdataserializer.writeFloat(this.f);
|
||||
packetdataserializer.writeFloat(this.g);
|
||||
packetdataserializer.writeFloat(this.h);
|
||||
packetdataserializer.writeInt(this.i);
|
||||
if(packetdataserializer.version >= 17) {
|
||||
for(int i = 0; i < particle.extra; ++i) {
|
||||
int toWrite = 0;
|
||||
if(parts.length - 1 > i) {
|
||||
try {
|
||||
toWrite = Integer.parseInt(parts[i + 1]);
|
||||
if(particle.extra == 1 && parts.length == 3) {
|
||||
++i;
|
||||
toWrite |= Integer.parseInt(parts[i + 1]) << 12;
|
||||
}
|
||||
} catch (NumberFormatException var7) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
packetdataserializer.b(toWrite);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void a(PacketPlayOutListener packetplayoutlistener) {
|
||||
packetplayoutlistener.a(this);
|
||||
}
|
||||
|
||||
public void handle(PacketListener packetlistener) {
|
||||
this.a((PacketPlayOutListener)packetlistener);
|
||||
}
|
||||
|
||||
private static enum Particle {
|
||||
EXPLOSION_NORMAL("explode"),
|
||||
EXPLOSION_LARGE("largeexplode"),
|
||||
EXPLOSION_HUGE("hugeexplosion"),
|
||||
FIREWORKS_SPARK("fireworksSpark"),
|
||||
WATER_BUBBLE("bubble"),
|
||||
WATER_SPLASH("splash"),
|
||||
WATER_WAKE("wake"),
|
||||
SUSPENDED("suspended"),
|
||||
SUSPENDED_DEPTH("depthsuspend"),
|
||||
CRIT("crit"),
|
||||
CRIT_MAGIC("magicCrit"),
|
||||
SMOKE_NORMAL("smoke"),
|
||||
SMOKE_LARGE("largesmoke"),
|
||||
SPELL("spell"),
|
||||
SPELL_INSTANT("instantSpell"),
|
||||
SPELL_MOB("mobSpell"),
|
||||
SPELL_MOB_AMBIENT("mobSpellAmbient"),
|
||||
SPELL_WITCH("witchMagic"),
|
||||
DRIP_WATER("dripWater"),
|
||||
DRIP_LAVA("dripLava"),
|
||||
VILLAGER_ANGRY("angryVillager"),
|
||||
VILLAGER_HAPPY("happyVillager"),
|
||||
TOWN_AURA("townaura"),
|
||||
NOTE("note"),
|
||||
PORTAL("portal"),
|
||||
ENCHANTMENT_TABLE("enchantmenttable"),
|
||||
FLAME("flame"),
|
||||
LAVA("lava"),
|
||||
FOOTSTEP("footstep"),
|
||||
CLOUD("cloud"),
|
||||
REDSTONE("reddust"),
|
||||
SNOWBALL("snowballpoof"),
|
||||
SNOW_SHOVEL("snowshovel"),
|
||||
SLIME("slime"),
|
||||
HEART("heart"),
|
||||
BARRIER("barrier"),
|
||||
ICON_CRACK("iconcrack", 2),
|
||||
BLOCK_CRACK("blockcrack", 1),
|
||||
BLOCK_DUST("blockdust", 1),
|
||||
WATER_DROP("droplet"),
|
||||
ITEM_TAKE("take"),
|
||||
MOB_APPEARANCE("mobappearance");
|
||||
|
||||
public final String name;
|
||||
public final int extra;
|
||||
private static final HashMap<String, PacketPlayOutWorldParticles.Particle> particleMap;
|
||||
|
||||
private Particle(String name) {
|
||||
this(name, 0);
|
||||
}
|
||||
|
||||
private Particle(String name, int extra) {
|
||||
this.name = name;
|
||||
this.extra = extra;
|
||||
}
|
||||
|
||||
public static PacketPlayOutWorldParticles.Particle find(String part) {
|
||||
return (PacketPlayOutWorldParticles.Particle)particleMap.get(part);
|
||||
}
|
||||
|
||||
static {
|
||||
particleMap = new HashMap();
|
||||
PacketPlayOutWorldParticles.Particle[] var0 = values();
|
||||
int var1 = var0.length;
|
||||
|
||||
for(int var2 = 0; var2 < var1; ++var2) {
|
||||
PacketPlayOutWorldParticles.Particle particle = var0[var2];
|
||||
particleMap.put(particle.name, particle);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
BIN
Plugins/Libraries/jackson-annotations-2.5.0.jar
Normal file
BIN
Plugins/Libraries/jackson-annotations-2.5.0.jar
Normal file
Binary file not shown.
BIN
Plugins/Libraries/jackson-core-2.5.1.jar
Normal file
BIN
Plugins/Libraries/jackson-core-2.5.1.jar
Normal file
Binary file not shown.
BIN
Plugins/Libraries/jackson-databind-2.5.1.jar
Normal file
BIN
Plugins/Libraries/jackson-databind-2.5.1.jar
Normal file
Binary file not shown.
BIN
Plugins/Libraries/jersey-apache-client-1.19.jar
Normal file
BIN
Plugins/Libraries/jersey-apache-client-1.19.jar
Normal file
Binary file not shown.
BIN
Plugins/Libraries/jersey-bundle-1.17.jar
Normal file
BIN
Plugins/Libraries/jersey-bundle-1.17.jar
Normal file
Binary file not shown.
BIN
Plugins/Libraries/jersey-multipart-1.19.jar
Normal file
BIN
Plugins/Libraries/jersey-multipart-1.19.jar
Normal file
Binary file not shown.
BIN
Plugins/Libraries/slf4j-api-1.7.10.jar
Normal file
BIN
Plugins/Libraries/slf4j-api-1.7.10.jar
Normal file
Binary file not shown.
@ -8,5 +8,6 @@
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.ServerData"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpclient-4.2.jar"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpcore-4.2.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.PlayerCache"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
@ -13,5 +13,6 @@
|
||||
<orderEntry type="module" module-name="Mineplex.ServerData" />
|
||||
<orderEntry type="library" name="httpcore" level="project" />
|
||||
<orderEntry type="library" name="httpclient" level="project" />
|
||||
<orderEntry type="module" module-name="Mineplex.PlayerCache" />
|
||||
</component>
|
||||
</module>
|
@ -1,6 +1,5 @@
|
||||
package mineplex.bungee;
|
||||
|
||||
import mineplex.bungee.account.AccountManager;
|
||||
import mineplex.bungee.lobbyBalancer.LobbyBalancer;
|
||||
import mineplex.bungee.motd.MotdManager;
|
||||
import mineplex.bungee.playerCount.PlayerCount;
|
||||
@ -21,6 +20,5 @@ public class Mineplexer extends Plugin
|
||||
new PlayerStats(this);
|
||||
//new InternetStatus(this);
|
||||
new PlayerTracker(this);
|
||||
new AccountManager(this, playerCount);
|
||||
}
|
||||
}
|
||||
|
@ -1,71 +0,0 @@
|
||||
package mineplex.bungee.account;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import mineplex.bungee.playerCount.PlayerCount;
|
||||
import net.md_5.bungee.api.event.LoginEvent;
|
||||
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 AccountManager implements Listener, Runnable
|
||||
{
|
||||
private Plugin _plugin;
|
||||
private PlayerCount _playerCount;
|
||||
private int _playerCap = -1;
|
||||
private AccountManagerRepository _repository;
|
||||
|
||||
private Gson _gson = new Gson();
|
||||
|
||||
public AccountManager(Plugin plugin, PlayerCount playerCount)
|
||||
{
|
||||
_plugin = plugin;
|
||||
_playerCount = playerCount;
|
||||
|
||||
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
|
||||
_plugin.getProxy().getScheduler().schedule(_plugin, this, 10L, 10L, TimeUnit.SECONDS);
|
||||
|
||||
_repository = new AccountManagerRepository();
|
||||
_repository.initialize();
|
||||
_playerCap = _repository.retrievePlayerCap();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void login(LoginEvent event)
|
||||
{
|
||||
if (_playerCap == -1 || _playerCount.getTotalPlayers() <= _playerCap)
|
||||
return;
|
||||
|
||||
String response = getClient(event.getConnection().getName(), event.getConnection().getUniqueId(), event.getConnection().getAddress().toString());
|
||||
|
||||
ClientToken token = _gson.fromJson(response, ClientToken.class);
|
||||
|
||||
if (token.Rank.equalsIgnoreCase("ALL"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
event.setCancelReason("§fDue to server issues, we have added a §cplayer limit§f.\n"
|
||||
+ "§fWe hope to have this resolved soon, §nplease be ptient§r.\n"
|
||||
+ "§fPlayers with Ranks can still join the server!\n\n"
|
||||
+ "§fPurchase Ranks at §awww.mineplex.com/shop");
|
||||
}
|
||||
}
|
||||
|
||||
public String getClient(String name, UUID uuid, String ipAddress)
|
||||
{
|
||||
LoginToken token = new LoginToken();
|
||||
token.Name = name;
|
||||
token.Uuid = uuid.toString();
|
||||
token.IpAddress = ipAddress;
|
||||
|
||||
return new JsonWebCall("http://accounts.mineplex.com/PlayerAccount/Login").ExecuteReturnStream(token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
_playerCap = _repository.retrievePlayerCap();
|
||||
}
|
||||
}
|
@ -1,105 +0,0 @@
|
||||
package mineplex.bungee.account;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class AccountManagerRepository
|
||||
{
|
||||
private Connection _connection = null;
|
||||
private String _connectionString = "jdbc:mysql://db.mineplex.com:3306/BungeeServers?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS playerCap (id INT NOT NULL AUTO_INCREMENT, playerCap INT, PRIMARY KEY (id));";
|
||||
private static String RETRIEVE_PLAYERCAP = "SELECT playerCap FROM playerCap;";
|
||||
|
||||
public void initialize()
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Initialized AccountManager.");
|
||||
}
|
||||
|
||||
public int retrievePlayerCap()
|
||||
{
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(RETRIEVE_PLAYERCAP);
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
return resultSet.getInt(1);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (resultSet != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package mineplex.bungee.account;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class AccountToken
|
||||
{
|
||||
public int AccountId;
|
||||
public String Name;
|
||||
public RankToken Rank;
|
||||
|
||||
public int LoginCount;
|
||||
public long LastLogin;
|
||||
public long TotalPlayingTime;
|
||||
public HashSet<String> IpAdddresses = new HashSet<String>();
|
||||
|
||||
public boolean Banned;
|
||||
public String Reason;
|
||||
|
||||
public int BlueGems;
|
||||
public int GreenGems;
|
||||
public List<Integer> SalesPackageIds;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package mineplex.bungee.account;
|
||||
|
||||
public interface Callback<T>
|
||||
{
|
||||
public void run(T data);
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package mineplex.bungee.account;
|
||||
|
||||
public class ClientToken
|
||||
{
|
||||
public int AccountId;
|
||||
public String Name;
|
||||
public String Rank;
|
||||
public boolean RankPerm;
|
||||
public String RankExpire;
|
||||
public int EconomyBalance;
|
||||
|
||||
public AccountToken AccountToken;
|
||||
public long LastLogin;
|
||||
}
|
@ -1,355 +0,0 @@
|
||||
package mineplex.bungee.account;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.conn.scheme.PlainSocketFactory;
|
||||
import org.apache.http.conn.scheme.Scheme;
|
||||
import org.apache.http.conn.scheme.SchemeRegistry;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.impl.conn.PoolingClientConnectionManager;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.apache.http.protocol.HTTP;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class JsonWebCall
|
||||
{
|
||||
private String _url;
|
||||
private PoolingClientConnectionManager _connectionManager;
|
||||
|
||||
public JsonWebCall(String url)
|
||||
{
|
||||
_url = url;
|
||||
|
||||
SchemeRegistry schemeRegistry = new SchemeRegistry();
|
||||
schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
|
||||
|
||||
_connectionManager = new PoolingClientConnectionManager(schemeRegistry);
|
||||
_connectionManager.setMaxTotal(200);
|
||||
_connectionManager.setDefaultMaxPerRoute(20);
|
||||
}
|
||||
|
||||
public String ExecuteReturnStream(Object argument)
|
||||
{
|
||||
HttpClient httpClient = new DefaultHttpClient(_connectionManager);
|
||||
InputStream in = null;
|
||||
String result = null;
|
||||
|
||||
try
|
||||
{
|
||||
HttpResponse response;
|
||||
|
||||
Gson gson = new Gson();
|
||||
HttpPost request = new HttpPost(_url);
|
||||
|
||||
if (argument != null)
|
||||
{
|
||||
StringEntity params = new StringEntity(gson.toJson(argument));
|
||||
params.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
|
||||
request.setEntity(params);
|
||||
}
|
||||
|
||||
response = httpClient.execute(request);
|
||||
|
||||
if (response != null)
|
||||
{
|
||||
in = response.getEntity().getContent();
|
||||
result = convertStreamToString(in);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.out.println("Error executing JsonWebCall: \n" + ex.getMessage());
|
||||
System.out.println("Result: \n" + result);
|
||||
|
||||
for (StackTraceElement trace : ex.getStackTrace())
|
||||
{
|
||||
System.out.println(trace);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
httpClient.getConnectionManager().shutdown();
|
||||
|
||||
if (in != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
Execute((Object)null);
|
||||
}
|
||||
|
||||
public void Execute(Object argument)
|
||||
{
|
||||
HttpClient httpClient = new DefaultHttpClient(_connectionManager);
|
||||
InputStream in = null;
|
||||
|
||||
try
|
||||
{
|
||||
Gson gson = new Gson();
|
||||
HttpPost request = new HttpPost(_url);
|
||||
|
||||
if (argument != null)
|
||||
{
|
||||
StringEntity params = new StringEntity(gson.toJson(argument));
|
||||
params.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
|
||||
request.setEntity(params);
|
||||
}
|
||||
|
||||
httpClient.execute(request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.out.println("JsonWebCall.Execute() Error:\n" + ex.getMessage());
|
||||
|
||||
for (StackTraceElement trace : ex.getStackTrace())
|
||||
{
|
||||
System.out.println(trace);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
httpClient.getConnectionManager().shutdown();
|
||||
|
||||
if (in != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public <T> T Execute(Class<T> returnClass)
|
||||
{
|
||||
return Execute(returnClass, (Object)null);
|
||||
}
|
||||
|
||||
public <T> T Execute(Type returnType, Object argument)
|
||||
{
|
||||
HttpClient httpClient = new DefaultHttpClient(_connectionManager);
|
||||
InputStream in = null;
|
||||
T returnData = null;
|
||||
String result = null;
|
||||
|
||||
try
|
||||
{
|
||||
HttpResponse response;
|
||||
|
||||
Gson gson = new Gson();
|
||||
HttpPost request = new HttpPost(_url);
|
||||
|
||||
if (argument != null)
|
||||
{
|
||||
StringEntity params = new StringEntity(gson.toJson(argument));
|
||||
params.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
|
||||
request.setEntity(params);
|
||||
}
|
||||
|
||||
response = httpClient.execute(request);
|
||||
|
||||
if (response != null)
|
||||
{
|
||||
in = response.getEntity().getContent();
|
||||
|
||||
result = convertStreamToString(in);
|
||||
returnData = new Gson().fromJson(result, returnType);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.out.println("Error executing JsonWebCall: \n" + ex.getMessage());
|
||||
System.out.println("Result: \n" + result);
|
||||
|
||||
for (StackTraceElement trace : ex.getStackTrace())
|
||||
{
|
||||
System.out.println(trace);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
httpClient.getConnectionManager().shutdown();
|
||||
|
||||
if (in != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
public <T> T Execute(Class<T> returnClass, Object argument)
|
||||
{
|
||||
HttpClient httpClient = new DefaultHttpClient(_connectionManager);
|
||||
InputStream in = null;
|
||||
T returnData = null;
|
||||
String result = null;
|
||||
|
||||
try
|
||||
{
|
||||
HttpResponse response;
|
||||
|
||||
Gson gson = new Gson();
|
||||
HttpPost request = new HttpPost(_url);
|
||||
|
||||
if (argument != null)
|
||||
{
|
||||
StringEntity params = new StringEntity(gson.toJson(argument));
|
||||
params.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
|
||||
request.setEntity(params);
|
||||
}
|
||||
|
||||
response = httpClient.execute(request);
|
||||
|
||||
if (response != null)
|
||||
{
|
||||
in = response.getEntity().getContent();
|
||||
|
||||
result = convertStreamToString(in);
|
||||
returnData = new Gson().fromJson(result, returnClass);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.out.println("Error executing JsonWebCall: \n" + ex.getMessage());
|
||||
System.out.println("Result: \n" + result);
|
||||
|
||||
for (StackTraceElement trace : ex.getStackTrace())
|
||||
{
|
||||
System.out.println(trace);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
httpClient.getConnectionManager().shutdown();
|
||||
|
||||
if (in != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
public <T> void Execute(Class<T> callbackClass, Callback<T> callback)
|
||||
{
|
||||
Execute(callbackClass, callback, (Object)null);
|
||||
}
|
||||
|
||||
public <T> void Execute(Class<T> callbackClass, Callback<T> callback, Object argument)
|
||||
{
|
||||
HttpClient httpClient = new DefaultHttpClient(_connectionManager);
|
||||
InputStream in = null;
|
||||
String result = null;
|
||||
|
||||
try
|
||||
{
|
||||
HttpResponse response;
|
||||
|
||||
Gson gson = new Gson();
|
||||
HttpPost request = new HttpPost(_url);
|
||||
|
||||
if (argument != null)
|
||||
{
|
||||
StringEntity params = new StringEntity(gson.toJson(argument));
|
||||
params.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
|
||||
request.setEntity(params);
|
||||
}
|
||||
|
||||
response = httpClient.execute(request);
|
||||
|
||||
if (response != null && callback != null)
|
||||
{
|
||||
in = response.getEntity().getContent();
|
||||
|
||||
result = convertStreamToString(in);
|
||||
callback.run(new Gson().fromJson(result, callbackClass));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.out.println("Error executing JsonWebCall: \n" + ex.getMessage());
|
||||
System.out.println("Result: \n" + result);
|
||||
}
|
||||
finally
|
||||
{
|
||||
httpClient.getConnectionManager().shutdown();
|
||||
|
||||
if (in != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected String convertStreamToString(InputStream is)
|
||||
{
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
String line = null;
|
||||
try {
|
||||
while ((line = reader.readLine()) != null) {
|
||||
sb.append(line + "\n");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package mineplex.bungee.account;
|
||||
|
||||
public class LoginToken
|
||||
{
|
||||
public String Name;
|
||||
public String IpAddress = "0.0.0.0";
|
||||
public String MacAddress = "00-00-00-00-00-00-00-00";
|
||||
public String Uuid;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package mineplex.bungee.account;
|
||||
|
||||
public class RankToken
|
||||
{
|
||||
public int RankId;
|
||||
|
||||
public String Name;
|
||||
}
|
@ -11,10 +11,12 @@ import mineplex.serverdata.data.Data;
|
||||
*/
|
||||
public class GlobalMotd implements Data
|
||||
{
|
||||
|
||||
// The unique name representing this MOTD set
|
||||
private String _name;
|
||||
|
||||
private String _headline;
|
||||
public String getHeadline() { return _headline; }
|
||||
|
||||
// List of lines describing the MOTD
|
||||
private List<String> _motd;
|
||||
public List<String> getMotd() { return _motd; }
|
||||
@ -24,9 +26,10 @@ public class GlobalMotd implements Data
|
||||
* @param name
|
||||
* @param motd
|
||||
*/
|
||||
public GlobalMotd(String name, List<String> motd)
|
||||
public GlobalMotd(String name, String headline, List<String> motd)
|
||||
{
|
||||
_name = name;
|
||||
_headline = headline;
|
||||
_motd = motd;
|
||||
}
|
||||
|
||||
|
@ -1,189 +0,0 @@
|
||||
package mineplex.bungee.motd;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.Favicon;
|
||||
import net.md_5.bungee.api.ServerPing;
|
||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||
import net.md_5.bungee.connection.CustomMotd;
|
||||
import net.md_5.bungee.connection.InitialHandler;
|
||||
import net.md_5.bungee.protocol.packet.PingPacket;
|
||||
import net.md_5.bungee.protocol.packet.StatusResponse;
|
||||
|
||||
public class Motd implements CustomMotd
|
||||
{
|
||||
private static final int MAX_TICKS = 30;
|
||||
private static final char SNOWFLAKE = '❅';
|
||||
private static final String SNOWMAN = ChatColor.WHITE + "☃" + ChatColor.RESET;
|
||||
private static final String LEFT_SWORD = "§b§l§m §8§l§m[ §r";
|
||||
private static final String RIGHT_SWORD = "§8§l§m ]§b§l§m §r";
|
||||
private static final ChatColor[] COLOR_ROTATION =
|
||||
{ChatColor.RED, ChatColor.LIGHT_PURPLE, ChatColor.GOLD, ChatColor.BLUE, ChatColor.YELLOW, ChatColor.GREEN, ChatColor.AQUA};
|
||||
private static List<Favicon> ICON_FRAMES;
|
||||
|
||||
private MotdManager _manager;
|
||||
private ScheduledFuture _task;
|
||||
private int _ticks = 0;
|
||||
|
||||
public Motd(MotdManager manager)
|
||||
{
|
||||
_manager = manager;
|
||||
}
|
||||
|
||||
public void handlePing(final ProxyPingEvent pingResult, final InitialHandler initialHandler)
|
||||
{
|
||||
BungeeCord.getInstance().getConnectionThrottle().unthrottle(initialHandler.getAddress().getAddress());
|
||||
final Gson gson = initialHandler.getHandshake().getProtocolVersion() == 4?BungeeCord.getInstance().gsonLegacy:BungeeCord.getInstance().gson;
|
||||
|
||||
_task = initialHandler.getChannelWrapper().getHandle().eventLoop().scheduleAtFixedRate(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (initialHandler.getChannelWrapper().getHandle().isOpen() && _ticks <= MAX_TICKS)
|
||||
{
|
||||
ServerPing ping = pingResult.getResponse();
|
||||
|
||||
String desc = getDesc();
|
||||
ping.setDescription(desc);
|
||||
|
||||
Favicon icon = getIcon();
|
||||
if (icon != null)
|
||||
ping.setFavicon(icon);
|
||||
|
||||
initialHandler.unsafe().sendPacket(new StatusResponse(gson.toJson(ping)));
|
||||
_ticks++;
|
||||
|
||||
if (_ticks > MAX_TICKS)
|
||||
{
|
||||
PingPacket packet = initialHandler.getPingPacket();
|
||||
if (packet != null)
|
||||
{
|
||||
initialHandler.unsafe().sendPacket(packet);
|
||||
initialHandler.setPingPacket(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (initialHandler.getChannelWrapper().getHandle().isOpen())
|
||||
initialHandler.getChannelWrapper().getHandle().close();
|
||||
_task.cancel(true);
|
||||
}
|
||||
}
|
||||
}, 0, 200, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
private String getDesc()
|
||||
{
|
||||
int insetSpaces = 8;
|
||||
int maxSpaces = 6;
|
||||
|
||||
ChatColor mineplexColor = COLOR_ROTATION[_ticks % COLOR_ROTATION.length];
|
||||
int spaceLeftCount;
|
||||
int spaceNumber = _ticks % (maxSpaces*2);
|
||||
if (spaceNumber > maxSpaces)
|
||||
spaceLeftCount = 2*maxSpaces - spaceNumber;
|
||||
else
|
||||
spaceLeftCount = spaceNumber;
|
||||
|
||||
String spacesLeft = getRepeatedCharacters(' ', spaceLeftCount);
|
||||
String spacesRight = getRepeatedCharacters(' ', maxSpaces - spaceLeftCount);
|
||||
String insets = getRepeatedCharacters(' ', insetSpaces);
|
||||
String desc = insets + spacesLeft + LEFT_SWORD + spacesRight + getMineplex(mineplexColor) + spacesRight + RIGHT_SWORD + spacesLeft;
|
||||
|
||||
List<String> lines = _manager.getMotdLines();
|
||||
if (lines != null && lines.size() > 0)
|
||||
{
|
||||
int index = _ticks / (MAX_TICKS / (lines.size()));
|
||||
String currentLine = index >= lines.size() ? lines.get(lines.size() - 1) : lines.get(index);
|
||||
desc += "\n" + currentLine;
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
private Favicon getIcon()
|
||||
{
|
||||
Favicon icon = null;
|
||||
|
||||
if (ICON_FRAMES.size() > 0)
|
||||
{
|
||||
icon = ICON_FRAMES.get(_ticks % ICON_FRAMES.size());
|
||||
}
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
private String getMineplex(ChatColor color)
|
||||
{
|
||||
return " " + color + ChatColor.BOLD.toString() + "Mineplex" + ChatColor.RESET + ChatColor.WHITE + ChatColor.BOLD + " Games" + ChatColor.RESET + " ";
|
||||
}
|
||||
|
||||
private String getRepeatedCharacters(char c, int count)
|
||||
{
|
||||
char[] spaces = new char[count];
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
spaces[i] = c;
|
||||
}
|
||||
return new String(spaces);
|
||||
}
|
||||
|
||||
private static Comparator<File> FILE_NUMBER_COMPARATOR = new Comparator<File>()
|
||||
{
|
||||
@Override
|
||||
public int compare(File f1, File f2)
|
||||
{
|
||||
int compareValue = 0;
|
||||
|
||||
try
|
||||
{
|
||||
int i1 = Integer.parseInt(f1.getName().substring(0, f1.getName().indexOf('.')));
|
||||
int i2 = Integer.parseInt(f2.getName().substring(0, f2.getName().indexOf('.')));
|
||||
return i1 - i2;
|
||||
}
|
||||
catch (Exception e) {}
|
||||
|
||||
return compareValue;
|
||||
}
|
||||
};
|
||||
|
||||
static
|
||||
{
|
||||
// Load icon animations
|
||||
ICON_FRAMES = new ArrayList<Favicon>();
|
||||
|
||||
File iconFolder = new File("server-icon");
|
||||
if (iconFolder.exists() && iconFolder.isDirectory())
|
||||
{
|
||||
File[] files = iconFolder.listFiles();
|
||||
Arrays.sort(files, FILE_NUMBER_COMPARATOR);
|
||||
for (int i = 0; i < files.length; i++)
|
||||
{
|
||||
File file = files[i];
|
||||
try
|
||||
{
|
||||
BufferedImage image = ImageIO.read(file);
|
||||
Favicon favicon = Favicon.create(image);
|
||||
ICON_FRAMES.add(favicon);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Just ignore extra files
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -2,28 +2,26 @@ package mineplex.bungee.motd;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
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.ServerManager;
|
||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.connection.CustomMotd;
|
||||
import net.md_5.bungee.connection.CustomMotdFactory;
|
||||
import net.md_5.bungee.connection.InitialHandler;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
public class MotdManager implements Listener, Runnable, CustomMotdFactory
|
||||
public class MotdManager implements Listener, Runnable
|
||||
{
|
||||
private Plugin _plugin;
|
||||
|
||||
private DataRepository<GlobalMotd> _repository;
|
||||
|
||||
private String firstLine = " §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r";
|
||||
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;
|
||||
|
||||
public MotdManager(Plugin plugin)
|
||||
@ -35,6 +33,7 @@ public class MotdManager implements Listener, Runnable, CustomMotdFactory
|
||||
|
||||
_repository = new RedisDataRepository<GlobalMotd>(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(),
|
||||
Region.ALL, GlobalMotd.class, "globalMotd");
|
||||
run();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -42,10 +41,10 @@ public class MotdManager implements Listener, Runnable, CustomMotdFactory
|
||||
{
|
||||
net.md_5.bungee.api.ServerPing serverPing = event.getResponse();
|
||||
|
||||
String motd = firstLine;
|
||||
String motd = _firstLine;
|
||||
if (_motdLines != null && _motdLines.size() > 0)
|
||||
{
|
||||
motd += "\n" + _motdLines.get(0);
|
||||
motd += "\n" + _motdLines.get(_random.nextInt(_motdLines.size()));
|
||||
}
|
||||
|
||||
event.setResponse(new net.md_5.bungee.api.ServerPing(serverPing.getVersion(), serverPing.getPlayers(), motd, serverPing.getFaviconObject()));
|
||||
@ -55,34 +54,33 @@ public class MotdManager implements Listener, Runnable, CustomMotdFactory
|
||||
public void run()
|
||||
{
|
||||
// Add in default MOTD listing to database
|
||||
if (!_repository.elementExists("MainMotd") || true)
|
||||
{
|
||||
|
||||
List<String> lines = new ArrayList<String>();
|
||||
lines.add(" §b§lUltra Sale §a§l50% Off"); // TODO: Implement in-game command to update MOTD?
|
||||
updateMainMotd(lines);
|
||||
}
|
||||
lines.add(" §d§lMaster Builders§f - §d§lWizards§f - §d§lGravity");
|
||||
//lines.add(" §d§lRank Sale §a§l40% Off");
|
||||
|
||||
updateMainMotd(" §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r", lines);
|
||||
|
||||
_motdLines = _repository.getElement("MainMotd").getMotd(); // Update MOTD lines
|
||||
InitialHandler.setCustomMotdFactory(this);
|
||||
GlobalMotd motd = _repository.getElement("MainMotd");
|
||||
|
||||
if (motd != null)
|
||||
{
|
||||
_motdLines = motd.getMotd();
|
||||
_firstLine = motd.getHeadline();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the main {@link GlobalMotd} determining the MOTD for Bungee instances.
|
||||
* @param motdLines - the lines to update the MOTD to.
|
||||
*/
|
||||
public void updateMainMotd(List<String> motdLines)
|
||||
public void updateMainMotd(String headline, List<String> motdLines)
|
||||
{
|
||||
_repository.addElement(new GlobalMotd("MainMotd", motdLines));
|
||||
_repository.addElement(new GlobalMotd("MainMotd", headline, motdLines));
|
||||
}
|
||||
|
||||
public List<String> getMotdLines()
|
||||
{
|
||||
return _motdLines;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomMotd makeMotd()
|
||||
{
|
||||
return new Motd(this);
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,32 @@
|
||||
package mineplex.bungee.playerStats;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import mineplex.bungee.playerStats.data.IpInfo;
|
||||
import mineplex.playerCache.PlayerCache;
|
||||
import mineplex.playerCache.PlayerInfo;
|
||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
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 PlayerStats implements Listener
|
||||
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)
|
||||
{
|
||||
_plugin = plugin;
|
||||
|
||||
_plugin.getProxy().getScheduler().schedule(_plugin, this, 5L, 5L, TimeUnit.MINUTES);
|
||||
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
|
||||
|
||||
_repository = new PlayerStatsRepository();
|
||||
@ -27,10 +40,104 @@ public class PlayerStats implements Listener
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_repository.addPlayer(event.getPlayer().getName());
|
||||
_repository.addPlayerVersion(event.getPlayer().getName(), event.getPlayer().getPendingConnection().getVersion());
|
||||
_repository.addPlayerIP(event.getPlayer().getName(), event.getPlayer().getPendingConnection().getAddress().getAddress().getHostAddress());
|
||||
String address = event.getPlayer().getPendingConnection().getAddress().getAddress().getHostAddress();
|
||||
UUID uuid = event.getPlayer().getUniqueId();
|
||||
String name = event.getPlayer().getName();
|
||||
int version = event.getPlayer().getPendingConnection().getVersion();
|
||||
|
||||
try
|
||||
{
|
||||
PlayerInfo playerInfo = null;
|
||||
IpInfo ipInfo = _repository.getIp(address);
|
||||
|
||||
boolean addOrUpdatePlayer = false;
|
||||
|
||||
playerInfo = _playerCache.getPlayer(uuid);
|
||||
|
||||
if (playerInfo == null)
|
||||
{
|
||||
addOrUpdatePlayer = true;
|
||||
_retrievingPlayerInfo.add(uuid);
|
||||
}
|
||||
|
||||
if (!addOrUpdatePlayer)
|
||||
{
|
||||
if (playerInfo.getVersion() != version)
|
||||
addOrUpdatePlayer = true;
|
||||
else if (!playerInfo.getName().equalsIgnoreCase(name))
|
||||
addOrUpdatePlayer = true;
|
||||
}
|
||||
|
||||
if (addOrUpdatePlayer)
|
||||
{
|
||||
// Just update? what about other properties?
|
||||
PlayerInfo updatedPlayerInfo = _repository.getPlayer(uuid, name, version);
|
||||
|
||||
if (playerInfo != null)
|
||||
{
|
||||
playerInfo.setName(updatedPlayerInfo.getName());
|
||||
playerInfo.setVersion(updatedPlayerInfo.getVersion());
|
||||
}
|
||||
else
|
||||
playerInfo = updatedPlayerInfo;
|
||||
|
||||
_playerCache.addPlayer(playerInfo);
|
||||
}
|
||||
|
||||
playerInfo.setSessionId(_repository.updatePlayerStats(playerInfo.getId(), ipInfo.id));
|
||||
}
|
||||
finally
|
||||
{
|
||||
_retrievingPlayerInfo.remove(uuid);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerDisconnect(final PlayerDisconnectEvent event)
|
||||
{
|
||||
_plugin.getProxy().getScheduler().runAsync(_plugin, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
UUID uuid = event.getPlayer().getUniqueId();
|
||||
|
||||
PlayerInfo playerInfo = null;
|
||||
|
||||
playerInfo = _playerCache.getPlayer(uuid);
|
||||
|
||||
int timeout = 5;
|
||||
|
||||
while (playerInfo == null && _retrievingPlayerInfo.contains(uuid) && timeout <= 5)
|
||||
{
|
||||
playerInfo = _playerCache.getPlayer(uuid);
|
||||
|
||||
if (playerInfo != null)
|
||||
break;
|
||||
|
||||
System.out.println("ERROR - Player disconnecting and isn't in cache... sleeping");
|
||||
|
||||
try
|
||||
{
|
||||
Thread.sleep(500);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
timeout++;
|
||||
}
|
||||
|
||||
_repository.updatePlayerSession(playerInfo.getSessionId());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
_playerCache.clean();
|
||||
}
|
||||
}
|
||||
|
@ -1,143 +1,108 @@
|
||||
package mineplex.bungee.playerStats;
|
||||
|
||||
import java.net.InetAddress;
|
||||
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.util.UUID;
|
||||
|
||||
import mineplex.bungee.playerStats.data.IpInfo;
|
||||
import mineplex.playerCache.PlayerInfo;
|
||||
|
||||
public class PlayerStatsRepository
|
||||
{
|
||||
private Connection _connection = null;
|
||||
private String _connectionString = "jdbc:mysql://sqlstats.mineplex.com:3306/PlayerStats?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _connectionString = "jdbc:mysql://sqlstats.mineplex.com:3306/PlayerStats?autoReconnect=true&failOverReadOnly=false&maxReconnects=10&allowMultiQueries=true";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS DailyUnique (id INT NOT NULL AUTO_INCREMENT, day VARCHAR(100), playerName VARCHAR(20), PRIMARY KEY (id), UNIQUE KEY unique_player_per_day (day, playerName));";
|
||||
private static String INSERT_PLAYER = "INSERT INTO DailyUnique (day, playerName) values(curdate(), ?) ON DUPLICATE KEY UPDATE playerName=playerName;";
|
||||
|
||||
private static String CREATE_VER_TABLE = "CREATE TABLE IF NOT EXISTS PlayerVersion (id INT NOT NULL AUTO_INCREMENT, playerName VARCHAR(20), version INT, PRIMARY KEY (id), UNIQUE KEY unique_player (playerName));";
|
||||
private static String INSERT_VER_PLAYER = "INSERT INTO PlayerVersion (playerName, version) values(?, ?);";
|
||||
private static String UPDATE_VER_PLAYER = "UPDATE PlayerVersion SET version = ? WHERE playerName = ?;";
|
||||
private static String INSERT_PLAYERINFO = "INSERT INTO playerInfo (uuid, name, version) VALUES (?, ?, ?);";
|
||||
private static String SELECT_PLAYERINFO = "SELECT id, name, version FROM playerInfo WHERE uuid = ?;";
|
||||
private static String UPDATE_PLAYERINFO = "UPDATE playerInfo SET name = ?, version = ? WHERE id = ?;";
|
||||
|
||||
private static String CREATE_IP_TABLE = "CREATE TABLE IF NOT EXISTS PlayerIP (id INT NOT NULL AUTO_INCREMENT, playerName VARCHAR(20), ip VARCHAR(20), PRIMARY KEY (id), UNIQUE INDEX unique_player_ip (playerName, ip));";
|
||||
private static String INSERT_IP_PLAYER = "INSERT IGNORE INTO PlayerIP (playerName, ip) values(?, ?);";
|
||||
private static String INSERT_IPINFO = "INSERT INTO ipInfo (ipAddress) VALUES (?);";
|
||||
private static String SELECT_IPINFO = "SELECT id FROM ipInfo WHERE ipAddress = ?;";
|
||||
|
||||
private static String UPDATE_PLAYERSTATS = "INSERT IGNORE INTO playerIps (playerInfoId, ipInfoId, date) VALUES (?, ?, curdate());"
|
||||
+ "INSERT IGNORE INTO playerUniqueLogins (playerInfoId, day) values(?, curdate());"
|
||||
+ "INSERT IGNORE INTO playerLoginSessions (playerInfoId, loginTime) values(?, now());";
|
||||
|
||||
private static String UPDATE_LOGINSESSION = "UPDATE playerLoginSessions SET timeInGame = TIME_TO_SEC(TIMEDIFF(now(), loginTime)) / 60 WHERE id = ?;";
|
||||
|
||||
public void initialize()
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
// Create table
|
||||
preparedStatement = _connection.prepareStatement(CREATE_TABLE);
|
||||
preparedStatement.execute();
|
||||
|
||||
preparedStatement.close();
|
||||
|
||||
preparedStatement = _connection.prepareStatement(CREATE_VER_TABLE);
|
||||
preparedStatement.execute();
|
||||
|
||||
preparedStatement.close();
|
||||
|
||||
preparedStatement = _connection.prepareStatement(CREATE_IP_TABLE);
|
||||
preparedStatement.execute();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Initialized PlayerStats.");
|
||||
}
|
||||
|
||||
public boolean addPlayer(String playerName)
|
||||
public PlayerInfo getPlayer(UUID uuid, String name, int version)
|
||||
{
|
||||
PlayerInfo playerInfo = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
ResultSet resultSet = null;
|
||||
|
||||
try
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(INSERT_PLAYER, Statement.RETURN_GENERATED_KEYS);
|
||||
preparedStatement = _connection.prepareStatement(SELECT_PLAYERINFO);
|
||||
|
||||
preparedStatement.setString(1, playerName);
|
||||
preparedStatement.setString(1, uuid.toString());
|
||||
|
||||
int affectedRows = preparedStatement.executeUpdate();
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
|
||||
if (affectedRows == 0)
|
||||
while (resultSet.next())
|
||||
{
|
||||
throw new SQLException("Adding unique player record failed, no rows affected.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
playerInfo = new PlayerInfo(resultSet.getInt(1), uuid, resultSet.getString(2), resultSet.getInt(3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addPlayerVersion(String playerName, int version)
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(UPDATE_VER_PLAYER);
|
||||
resultSet.close();
|
||||
preparedStatement.close();
|
||||
|
||||
preparedStatement.setInt(1, version);
|
||||
preparedStatement.setString(2, playerName);
|
||||
|
||||
int affectedRows = preparedStatement.executeUpdate();
|
||||
|
||||
if (affectedRows == 0)
|
||||
if (playerInfo == null)
|
||||
{
|
||||
preparedStatement.close();
|
||||
preparedStatement = _connection.prepareStatement(INSERT_VER_PLAYER, Statement.RETURN_GENERATED_KEYS);
|
||||
|
||||
preparedStatement.setString(1, playerName);
|
||||
preparedStatement.setInt(2, version);
|
||||
preparedStatement = _connection.prepareStatement(INSERT_PLAYERINFO, Statement.RETURN_GENERATED_KEYS);
|
||||
preparedStatement.setString(1, uuid.toString());
|
||||
preparedStatement.setString(2, name);
|
||||
preparedStatement.setInt(3, version);
|
||||
|
||||
preparedStatement.executeUpdate();
|
||||
|
||||
int id = 0;
|
||||
|
||||
resultSet = preparedStatement.getGeneratedKeys();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
id = resultSet.getInt(1);
|
||||
}
|
||||
|
||||
playerInfo = new PlayerInfo(id, uuid, name, version);
|
||||
|
||||
resultSet.close();
|
||||
preparedStatement.close();
|
||||
}
|
||||
else if (!playerInfo.getName().equalsIgnoreCase(name) || playerInfo.getVersion() != version)
|
||||
{
|
||||
preparedStatement = _connection.prepareStatement(UPDATE_PLAYERINFO);
|
||||
preparedStatement.setString(1, name);
|
||||
preparedStatement.setInt(2, version);
|
||||
preparedStatement.setInt(3, playerInfo.getId());
|
||||
|
||||
preparedStatement.executeUpdate();
|
||||
preparedStatement.close();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
@ -157,22 +122,177 @@ public class PlayerStatsRepository
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (resultSet != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return playerInfo;
|
||||
}
|
||||
|
||||
public void addPlayerIP(String playerName, String address)
|
||||
|
||||
public IpInfo getIp(String ipAddress)
|
||||
{
|
||||
IpInfo ipInfo = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
ResultSet resultSet = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(SELECT_IPINFO);
|
||||
preparedStatement.setString(1, ipAddress);
|
||||
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
ipInfo = new IpInfo();
|
||||
ipInfo.id = resultSet.getInt(1);
|
||||
ipInfo.ipAddress = ipAddress;
|
||||
}
|
||||
|
||||
resultSet.close();
|
||||
preparedStatement.close();
|
||||
|
||||
if (ipInfo == null)
|
||||
{
|
||||
preparedStatement = _connection.prepareStatement(INSERT_IPINFO, Statement.RETURN_GENERATED_KEYS);
|
||||
preparedStatement.setString(1, ipAddress);
|
||||
|
||||
preparedStatement.executeUpdate();
|
||||
|
||||
int id = 0;
|
||||
|
||||
resultSet = preparedStatement.getGeneratedKeys();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
id = resultSet.getInt(1);
|
||||
}
|
||||
|
||||
ipInfo = new IpInfo();
|
||||
ipInfo.id = id;
|
||||
ipInfo.ipAddress = ipAddress;
|
||||
|
||||
resultSet.close();
|
||||
preparedStatement.close();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (resultSet != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ipInfo;
|
||||
}
|
||||
|
||||
public int updatePlayerStats(int playerId, int ipId)
|
||||
{
|
||||
Statement statement = null;
|
||||
ResultSet resultSet= null;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(INSERT_IP_PLAYER, Statement.RETURN_GENERATED_KEYS);
|
||||
|
||||
preparedStatement.setString(1, playerName);
|
||||
preparedStatement.setString(2, address);
|
||||
statement = _connection.createStatement();
|
||||
|
||||
String queryString = UPDATE_PLAYERSTATS;
|
||||
queryString = queryString.replaceFirst("\\?", playerId + "");
|
||||
queryString = queryString.replaceFirst("\\?", ipId + "");
|
||||
queryString = queryString.replaceFirst("\\?", playerId + "");
|
||||
queryString = queryString.replaceFirst("\\?", playerId + "");
|
||||
|
||||
statement.executeUpdate(queryString, Statement.RETURN_GENERATED_KEYS);
|
||||
|
||||
statement.getMoreResults();
|
||||
statement.getMoreResults();
|
||||
resultSet = statement.getGeneratedKeys();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
return resultSet.getInt(1);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if (statement != null)
|
||||
statement.close();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (resultSet != null)
|
||||
resultSet.close();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void updatePlayerSession(int loginSessionId)
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(UPDATE_LOGINSESSION);
|
||||
preparedStatement.setInt(1, loginSessionId);
|
||||
|
||||
preparedStatement.executeUpdate();
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
package mineplex.bungee.playerStats.data;
|
||||
|
||||
public class IpInfo
|
||||
{
|
||||
public int id;
|
||||
public String ipAddress;
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package net.md_5.bungee.connection;
|
||||
|
||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||
import net.md_5.bungee.protocol.packet.PingPacket;
|
||||
|
||||
public interface CustomMotd
|
||||
{
|
||||
public void handlePing(ProxyPingEvent event, InitialHandler initialHandler);
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package net.md_5.bungee.connection;
|
||||
|
||||
public interface CustomMotdFactory
|
||||
{
|
||||
public CustomMotd makeMotd();
|
||||
}
|
@ -1,487 +0,0 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by Fernflower decompiler)
|
||||
//
|
||||
|
||||
package net.md_5.bungee.connection;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.gson.Gson;
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.math.BigInteger;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URLEncoder;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import javax.crypto.SecretKey;
|
||||
import net.md_5.bungee.BungeeCipher;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.BungeeServerInfo;
|
||||
import net.md_5.bungee.EncryptionUtil;
|
||||
import net.md_5.bungee.UserConnection;
|
||||
import net.md_5.bungee.Util;
|
||||
import net.md_5.bungee.api.AbstractReconnectHandler;
|
||||
import net.md_5.bungee.api.Callback;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.Favicon;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.ServerPing;
|
||||
import net.md_5.bungee.api.ServerPing.PlayerInfo;
|
||||
import net.md_5.bungee.api.ServerPing.Players;
|
||||
import net.md_5.bungee.api.ServerPing.Protocol;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.config.ListenerInfo;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.PendingConnection;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.LoginEvent;
|
||||
import net.md_5.bungee.api.event.PlayerHandshakeEvent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.api.event.PreLoginEvent;
|
||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||
import net.md_5.bungee.chat.ComponentSerializer;
|
||||
import net.md_5.bungee.http.HttpClient;
|
||||
import net.md_5.bungee.netty.ChannelWrapper;
|
||||
import net.md_5.bungee.netty.HandlerBoss;
|
||||
import net.md_5.bungee.netty.PacketHandler;
|
||||
import net.md_5.bungee.netty.cipher.CipherDecoder;
|
||||
import net.md_5.bungee.netty.cipher.CipherEncoder;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
||||
import net.md_5.bungee.protocol.packet.EncryptionResponse;
|
||||
import net.md_5.bungee.protocol.packet.Handshake;
|
||||
import net.md_5.bungee.protocol.packet.Kick;
|
||||
import net.md_5.bungee.protocol.packet.LegacyHandshake;
|
||||
import net.md_5.bungee.protocol.packet.LegacyPing;
|
||||
import net.md_5.bungee.protocol.packet.LoginRequest;
|
||||
import net.md_5.bungee.protocol.packet.LoginSuccess;
|
||||
import net.md_5.bungee.protocol.packet.PingPacket;
|
||||
import net.md_5.bungee.protocol.packet.PluginMessage;
|
||||
import net.md_5.bungee.protocol.packet.StatusRequest;
|
||||
import net.md_5.bungee.protocol.packet.StatusResponse;
|
||||
|
||||
public class InitialHandler extends PacketHandler implements PendingConnection {
|
||||
|
||||
private static CustomMotdFactory _customMotdFactory;
|
||||
|
||||
private PingPacket _pingPacket;
|
||||
private final ProxyServer bungee;
|
||||
private ChannelWrapper ch;
|
||||
private final ListenerInfo listener;
|
||||
private Handshake handshake;
|
||||
private LoginRequest loginRequest;
|
||||
private EncryptionRequest request;
|
||||
private final List<PluginMessage> registerMessages = new ArrayList();
|
||||
private InitialHandler.State thisState;
|
||||
private final Unsafe unsafe;
|
||||
private boolean onlineMode;
|
||||
private InetSocketAddress virtualHost;
|
||||
private UUID uniqueId;
|
||||
private UUID offlineId;
|
||||
private LoginResult loginProfile;
|
||||
private boolean legacy;
|
||||
|
||||
public void connected(ChannelWrapper channel) throws Exception {
|
||||
this.ch = channel;
|
||||
}
|
||||
|
||||
public void exception(Throwable t) throws Exception {
|
||||
this.disconnect((String)(ChatColor.RED + Util.exception(t)));
|
||||
}
|
||||
|
||||
public void handle(PluginMessage pluginMessage) throws Exception {
|
||||
if(pluginMessage.getTag().equals("REGISTER")) {
|
||||
Preconditions.checkState(this.registerMessages.size() < 128, "Too many channels registered");
|
||||
this.registerMessages.add(pluginMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void handle(LegacyHandshake legacyHandshake) throws Exception {
|
||||
this.legacy = true;
|
||||
this.ch.getHandle().writeAndFlush(this.bungee.getTranslation("outdated_client", new Object[0]));
|
||||
this.ch.close();
|
||||
}
|
||||
|
||||
public void handle(LegacyPing ping) throws Exception {
|
||||
this.legacy = true;
|
||||
final boolean v1_5 = ping.isV1_5();
|
||||
ServerPing legacy = new ServerPing(new Protocol(this.bungee.getName() + " " + this.bungee.getGameVersion(), this.bungee.getProtocolVersion()), new Players(this.listener.getMaxPlayers(), this.bungee.getOnlineCount(), (PlayerInfo[])null), this.listener.getMotd(), (Favicon)null);
|
||||
Callback callback = new Callback<ProxyPingEvent>() {
|
||||
public void done(ProxyPingEvent result, Throwable error) {
|
||||
if(!InitialHandler.this.ch.isClosed()) {
|
||||
ServerPing legacy = result.getResponse();
|
||||
String kickMessage;
|
||||
if(v1_5) {
|
||||
kickMessage = ChatColor.DARK_BLUE + "\u0000" + 127 + '\u0000' + legacy.getVersion().getName() + '\u0000' + InitialHandler.getFirstLine(legacy.getDescription()) + '\u0000' + legacy.getPlayers().getOnline() + '\u0000' + legacy.getPlayers().getMax();
|
||||
} else {
|
||||
kickMessage = ChatColor.stripColor(InitialHandler.getFirstLine(legacy.getDescription())) + '§' + legacy.getPlayers().getOnline() + '§' + legacy.getPlayers().getMax();
|
||||
}
|
||||
|
||||
InitialHandler.this.ch.getHandle().writeAndFlush(kickMessage);
|
||||
InitialHandler.this.ch.close();
|
||||
}
|
||||
}
|
||||
};
|
||||
this.bungee.getPluginManager().callEvent(new ProxyPingEvent(this, legacy, callback));
|
||||
}
|
||||
|
||||
private static String getFirstLine(String str) {
|
||||
int pos = str.indexOf(10);
|
||||
return pos == -1?str:str.substring(0, pos);
|
||||
}
|
||||
|
||||
public void handle(StatusRequest statusRequest) throws Exception {
|
||||
Preconditions.checkState(this.thisState == InitialHandler.State.STATUS, "Not expecting STATUS");
|
||||
ServerInfo forced = AbstractReconnectHandler.getForcedHost(this);
|
||||
String motd = forced != null?forced.getMotd():this.listener.getMotd();
|
||||
Callback pingBack = new Callback<ServerPing>() {
|
||||
public void done(ServerPing result, Throwable error) {
|
||||
if(error != null) {
|
||||
result = new ServerPing();
|
||||
result.setDescription(InitialHandler.this.bungee.getTranslation("ping_cannot_connect", new Object[0]));
|
||||
InitialHandler.this.bungee.getLogger().log(Level.WARNING, "Error pinging remote server", error);
|
||||
}
|
||||
|
||||
Callback callback = new Callback<ProxyPingEvent>() {
|
||||
public void done(ProxyPingEvent pingResult, Throwable error) {
|
||||
// MINEPLEX
|
||||
if (_customMotdFactory != null)
|
||||
{
|
||||
_customMotdFactory.makeMotd().handlePing(pingResult, InitialHandler.this);
|
||||
}
|
||||
else
|
||||
{
|
||||
BungeeCord.getInstance().getConnectionThrottle().unthrottle(InitialHandler.this.getAddress().getAddress());
|
||||
Gson gson = InitialHandler.this.handshake.getProtocolVersion() == 4?BungeeCord.getInstance().gsonLegacy:BungeeCord.getInstance().gson;
|
||||
InitialHandler.this.unsafe.sendPacket(new StatusResponse(gson.toJson(pingResult.getResponse())));
|
||||
}
|
||||
}
|
||||
};
|
||||
InitialHandler.this.bungee.getPluginManager().callEvent(new ProxyPingEvent(InitialHandler.this, result, callback));
|
||||
}
|
||||
};
|
||||
if(forced != null && this.listener.isPingPassthrough()) {
|
||||
((BungeeServerInfo)forced).ping(pingBack, this.handshake.getProtocolVersion());
|
||||
} else {
|
||||
int protocol = net.md_5.bungee.protocol.Protocol.supportedVersions.contains(Integer.valueOf(this.handshake.getProtocolVersion()))?this.handshake.getProtocolVersion():this.bungee.getProtocolVersion();
|
||||
pingBack.done(new ServerPing(new Protocol(this.bungee.getName() + " " + this.bungee.getGameVersion(), protocol), new Players(this.listener.getMaxPlayers(), this.bungee.getOnlineCount(), (PlayerInfo[])null), motd, BungeeCord.getInstance().config.getFaviconObject()), (Throwable)null);
|
||||
}
|
||||
|
||||
this.thisState = InitialHandler.State.PING;
|
||||
}
|
||||
|
||||
public void handle(final PingPacket ping) throws Exception {
|
||||
|
||||
_pingPacket = ping;
|
||||
// if (thisState == State.PING) return; // MINEPLEX
|
||||
// Preconditions.checkState(this.thisState == InitialHandler.State.PING, "Not expecting PING");
|
||||
// getChannelWrapper().getHandle().eventLoop().schedule(new Runnable()
|
||||
// {
|
||||
// @Override
|
||||
// public void run()
|
||||
// {
|
||||
// unsafe.sendPacket(ping);
|
||||
// }
|
||||
// }, 6, TimeUnit.SECONDS);
|
||||
//
|
||||
// this.unsafe.sendPacket(ping);
|
||||
// this.disconnect((String)"");
|
||||
}
|
||||
|
||||
public void handle(Handshake handshake) throws Exception {
|
||||
Preconditions.checkState(this.thisState == InitialHandler.State.HANDSHAKE, "Not expecting HANDSHAKE");
|
||||
this.handshake = handshake;
|
||||
this.ch.setVersion(handshake.getProtocolVersion());
|
||||
if(handshake.getHost().endsWith(".")) {
|
||||
handshake.setHost(handshake.getHost().substring(0, handshake.getHost().length() - 1));
|
||||
}
|
||||
|
||||
this.virtualHost = InetSocketAddress.createUnresolved(handshake.getHost(), handshake.getPort());
|
||||
this.bungee.getLogger().log(Level.INFO, "{0} has connected", this);
|
||||
this.bungee.getPluginManager().callEvent(new PlayerHandshakeEvent(this, handshake));
|
||||
switch(handshake.getRequestedProtocol()) {
|
||||
case 1:
|
||||
this.thisState = InitialHandler.State.STATUS;
|
||||
this.ch.setProtocol(net.md_5.bungee.protocol.Protocol.STATUS);
|
||||
break;
|
||||
case 2:
|
||||
this.thisState = InitialHandler.State.USERNAME;
|
||||
this.ch.setProtocol(net.md_5.bungee.protocol.Protocol.LOGIN);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Cannot request protocol " + handshake.getRequestedProtocol());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void handle(LoginRequest loginRequest) throws Exception {
|
||||
Preconditions.checkState(this.thisState == InitialHandler.State.USERNAME, "Not expecting USERNAME");
|
||||
this.loginRequest = loginRequest;
|
||||
if(!net.md_5.bungee.protocol.Protocol.supportedVersions.contains(Integer.valueOf(this.handshake.getProtocolVersion()))) {
|
||||
this.disconnect((String)this.bungee.getTranslation("outdated_server", new Object[0]));
|
||||
} else if(this.getName().contains(".")) {
|
||||
this.disconnect((String)this.bungee.getTranslation("name_invalid", new Object[0]));
|
||||
} else if(this.getName().length() > 16) {
|
||||
this.disconnect((String)this.bungee.getTranslation("name_too_long", new Object[0]));
|
||||
} else {
|
||||
int limit = BungeeCord.getInstance().config.getPlayerLimit();
|
||||
if(limit > 0 && this.bungee.getOnlineCount() > limit) {
|
||||
this.disconnect((String)this.bungee.getTranslation("proxy_full", new Object[0]));
|
||||
} else if(!this.isOnlineMode() && this.bungee.getPlayer(this.getName()) != null) {
|
||||
this.disconnect((String)this.bungee.getTranslation("already_connected", new Object[0]));
|
||||
} else {
|
||||
Callback callback = new Callback<PreLoginEvent>() {
|
||||
public void done(PreLoginEvent result, Throwable error) {
|
||||
if(result.isCancelled()) {
|
||||
InitialHandler.this.disconnect((String)result.getCancelReason());
|
||||
} else if(!InitialHandler.this.ch.isClosed()) {
|
||||
if(InitialHandler.this.onlineMode) {
|
||||
InitialHandler.this.unsafe().sendPacket(InitialHandler.this.request = EncryptionUtil.encryptRequest());
|
||||
} else {
|
||||
InitialHandler.this.finish();
|
||||
}
|
||||
|
||||
InitialHandler.this.thisState = InitialHandler.State.ENCRYPT;
|
||||
}
|
||||
}
|
||||
};
|
||||
this.bungee.getPluginManager().callEvent(new PreLoginEvent(this, callback));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void handle(EncryptionResponse encryptResponse) throws Exception {
|
||||
Preconditions.checkState(this.thisState == InitialHandler.State.ENCRYPT, "Not expecting ENCRYPT");
|
||||
SecretKey sharedKey = EncryptionUtil.getSecret(encryptResponse, this.request);
|
||||
BungeeCipher decrypt = EncryptionUtil.getCipher(false, sharedKey);
|
||||
this.ch.addBefore("frame-decoder", "decrypt", new CipherDecoder(decrypt));
|
||||
BungeeCipher encrypt = EncryptionUtil.getCipher(true, sharedKey);
|
||||
this.ch.addBefore("frame-prepender", "encrypt", new CipherEncoder(encrypt));
|
||||
String encName = URLEncoder.encode(this.getName(), "UTF-8");
|
||||
MessageDigest sha = MessageDigest.getInstance("SHA-1");
|
||||
byte[][] encodedHash = new byte[][]{this.request.getServerId().getBytes("ISO_8859_1"), sharedKey.getEncoded(), EncryptionUtil.keys.getPublic().getEncoded()};
|
||||
int authURL = encodedHash.length;
|
||||
|
||||
for(int handler = 0; handler < authURL; ++handler) {
|
||||
byte[] bit = encodedHash[handler];
|
||||
sha.update(bit);
|
||||
}
|
||||
|
||||
String var11 = URLEncoder.encode((new BigInteger(sha.digest())).toString(16), "UTF-8");
|
||||
String var12 = "https://sessionserver.mojang.com/session/minecraft/hasJoined?username=" + encName + "&serverId=" + var11;
|
||||
Callback var13 = new Callback<String>() {
|
||||
public void done(String result, Throwable error) {
|
||||
if(error == null) {
|
||||
LoginResult obj = (LoginResult)BungeeCord.getInstance().gson.fromJson(result, LoginResult.class);
|
||||
if(obj != null) {
|
||||
InitialHandler.this.loginProfile = obj;
|
||||
InitialHandler.this.uniqueId = Util.getUUID(obj.getId());
|
||||
InitialHandler.this.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
InitialHandler.this.disconnect((String)"Not authenticated with Minecraft.net");
|
||||
} else {
|
||||
InitialHandler.this.disconnect((String)InitialHandler.this.bungee.getTranslation("mojang_fail", new Object[0]));
|
||||
InitialHandler.this.bungee.getLogger().log(Level.SEVERE, "Error authenticating " + InitialHandler.this.getName() + " with minecraft.net", error);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
HttpClient.get(var12, this.ch.getHandle().eventLoop(), var13);
|
||||
}
|
||||
|
||||
private void finish() {
|
||||
ProxiedPlayer old = this.bungee.getPlayer(this.getName());
|
||||
if(old != null) {
|
||||
old.disconnect(this.bungee.getTranslation("already_connected", new Object[0]));
|
||||
}
|
||||
|
||||
this.offlineId = UUID.nameUUIDFromBytes(("OfflinePlayer:" + this.getName()).getBytes(Charsets.UTF_8));
|
||||
if(this.uniqueId == null) {
|
||||
this.uniqueId = this.offlineId;
|
||||
}
|
||||
|
||||
Callback complete = new Callback<LoginEvent>() {
|
||||
public void done(LoginEvent result, Throwable error) {
|
||||
if(result.isCancelled()) {
|
||||
InitialHandler.this.disconnect((String)result.getCancelReason());
|
||||
} else if(!InitialHandler.this.ch.isClosed()) {
|
||||
InitialHandler.this.ch.getHandle().eventLoop().execute(new Runnable() {
|
||||
public void run() {
|
||||
if(InitialHandler.this.ch.getHandle().isActive()) {
|
||||
if(InitialHandler.this.getVersion() >= 5) {
|
||||
InitialHandler.this.unsafe.sendPacket(new LoginSuccess(InitialHandler.this.getUniqueId().toString(), InitialHandler.this.getName()));
|
||||
} else {
|
||||
InitialHandler.this.unsafe.sendPacket(new LoginSuccess(InitialHandler.this.getUUID(), InitialHandler.this.getName()));
|
||||
}
|
||||
|
||||
InitialHandler.this.ch.setProtocol(net.md_5.bungee.protocol.Protocol.GAME);
|
||||
UserConnection userCon = new UserConnection(InitialHandler.this.bungee, InitialHandler.this.ch, InitialHandler.this.getName(), InitialHandler.this);
|
||||
userCon.init();
|
||||
InitialHandler.this.bungee.getPluginManager().callEvent(new PostLoginEvent(userCon));
|
||||
((HandlerBoss)InitialHandler.this.ch.getHandle().pipeline().get(HandlerBoss.class)).setHandler(new UpstreamBridge(InitialHandler.this.bungee, userCon));
|
||||
ServerInfo server;
|
||||
if(InitialHandler.this.bungee.getReconnectHandler() != null) {
|
||||
server = InitialHandler.this.bungee.getReconnectHandler().getServer(userCon);
|
||||
} else {
|
||||
server = AbstractReconnectHandler.getForcedHost(InitialHandler.this);
|
||||
}
|
||||
|
||||
if(server == null) {
|
||||
server = InitialHandler.this.bungee.getServerInfo(InitialHandler.this.listener.getDefaultServer());
|
||||
}
|
||||
|
||||
userCon.connect(server, (Callback)null, true);
|
||||
InitialHandler.this.thisState = InitialHandler.State.FINISHED;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
this.bungee.getPluginManager().callEvent(new LoginEvent(this, complete));
|
||||
}
|
||||
|
||||
public void disconnect(String reason) {
|
||||
this.disconnect((BaseComponent[])TextComponent.fromLegacyText(reason));
|
||||
}
|
||||
|
||||
public void disconnect(final BaseComponent... reason) {
|
||||
if(!this.ch.isClosed()) {
|
||||
this.ch.getHandle().eventLoop().schedule(new Runnable() {
|
||||
public void run() {
|
||||
InitialHandler.this.unsafe().sendPacket(new Kick(ComponentSerializer.toString(reason)));
|
||||
InitialHandler.this.ch.close();
|
||||
}
|
||||
}, 500L, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void disconnect(BaseComponent reason) {
|
||||
this.disconnect((BaseComponent[])(new BaseComponent[]{reason}));
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.loginRequest == null?null:this.loginRequest.getData();
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return this.handshake == null?-1:this.handshake.getProtocolVersion();
|
||||
}
|
||||
|
||||
public InetSocketAddress getAddress() {
|
||||
return (InetSocketAddress)this.ch.getHandle().remoteAddress();
|
||||
}
|
||||
|
||||
public Unsafe unsafe() {
|
||||
return this.unsafe;
|
||||
}
|
||||
|
||||
public void setOnlineMode(boolean onlineMode) {
|
||||
Preconditions.checkState(this.thisState == InitialHandler.State.USERNAME, "Can only set online mode status whilst state is username");
|
||||
this.onlineMode = onlineMode;
|
||||
}
|
||||
|
||||
public String getUUID() {
|
||||
return this.uniqueId.toString().replaceAll("-", "");
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "[" + (this.getName() != null?this.getName():this.getAddress()) + "] <-> InitialHandler";
|
||||
}
|
||||
|
||||
@ConstructorProperties({"bungee", "listener"})
|
||||
public InitialHandler(ProxyServer bungee, ListenerInfo listener) {
|
||||
this.thisState = InitialHandler.State.HANDSHAKE;
|
||||
this.unsafe = new Unsafe() {
|
||||
public void sendPacket(DefinedPacket packet) {
|
||||
InitialHandler.this.ch.write(packet);
|
||||
}
|
||||
};
|
||||
this.onlineMode = BungeeCord.getInstance().config.isOnlineMode();
|
||||
this.bungee = bungee;
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public ListenerInfo getListener() {
|
||||
return this.listener;
|
||||
}
|
||||
|
||||
public Handshake getHandshake() {
|
||||
return this.handshake;
|
||||
}
|
||||
|
||||
public LoginRequest getLoginRequest() {
|
||||
return this.loginRequest;
|
||||
}
|
||||
|
||||
public List<PluginMessage> getRegisterMessages() {
|
||||
return this.registerMessages;
|
||||
}
|
||||
|
||||
public boolean isOnlineMode() {
|
||||
return this.onlineMode;
|
||||
}
|
||||
|
||||
public InetSocketAddress getVirtualHost() {
|
||||
return this.virtualHost;
|
||||
}
|
||||
|
||||
public UUID getUniqueId() {
|
||||
return this.uniqueId;
|
||||
}
|
||||
|
||||
public UUID getOfflineId() {
|
||||
return this.offlineId;
|
||||
}
|
||||
|
||||
public LoginResult getLoginProfile() {
|
||||
return this.loginProfile;
|
||||
}
|
||||
|
||||
public boolean isLegacy() {
|
||||
return this.legacy;
|
||||
}
|
||||
|
||||
public ChannelWrapper getChannelWrapper()
|
||||
{
|
||||
return ch; //MINEPLEX
|
||||
}
|
||||
|
||||
public PingPacket getPingPacket()
|
||||
{
|
||||
return _pingPacket; // MINEPLEX
|
||||
}
|
||||
|
||||
public void setPingPacket(PingPacket packet)
|
||||
{
|
||||
_pingPacket = packet;
|
||||
}
|
||||
|
||||
private static enum State {
|
||||
HANDSHAKE,
|
||||
STATUS,
|
||||
PING,
|
||||
USERNAME,
|
||||
ENCRYPT,
|
||||
FINISHED;
|
||||
|
||||
private State() {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setCustomMotdFactory(CustomMotdFactory factory)
|
||||
{
|
||||
_customMotdFactory = factory;
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by Fernflower decompiler)
|
||||
//
|
||||
|
||||
package net.md_5.bungee.connection;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.Callback;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.ServerPing;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.netty.ChannelWrapper;
|
||||
import net.md_5.bungee.netty.PacketHandler;
|
||||
import net.md_5.bungee.protocol.MinecraftDecoder;
|
||||
import net.md_5.bungee.protocol.MinecraftEncoder;
|
||||
import net.md_5.bungee.protocol.Protocol;
|
||||
import net.md_5.bungee.protocol.packet.Handshake;
|
||||
import net.md_5.bungee.protocol.packet.StatusRequest;
|
||||
import net.md_5.bungee.protocol.packet.StatusResponse;
|
||||
|
||||
public class PingHandler extends PacketHandler {
|
||||
private final ServerInfo target;
|
||||
private final Callback<ServerPing> callback;
|
||||
private final int protocol;
|
||||
private ChannelWrapper channel;
|
||||
|
||||
public void connected(ChannelWrapper channel) throws Exception {
|
||||
this.channel = channel;
|
||||
MinecraftEncoder encoder = new MinecraftEncoder(Protocol.HANDSHAKE, false, this.protocol);
|
||||
channel.getHandle().pipeline().addAfter("frame-decoder", "packet-decoder", new MinecraftDecoder(Protocol.STATUS, false, ProxyServer.getInstance().getProtocolVersion()));
|
||||
channel.getHandle().pipeline().addAfter("frame-prepender", "packet-encoder", encoder);
|
||||
channel.write(new Handshake(this.protocol, this.target.getAddress().getHostString(), this.target.getAddress().getPort(), 1));
|
||||
encoder.setProtocol(Protocol.STATUS);
|
||||
channel.write(new StatusRequest());
|
||||
}
|
||||
|
||||
public void exception(Throwable t) throws Exception {
|
||||
this.callback.done(null, t);
|
||||
}
|
||||
|
||||
public void handle(StatusResponse statusResponse) throws Exception {
|
||||
Gson gson = this.protocol == 4?BungeeCord.getInstance().gsonLegacy:BungeeCord.getInstance().gson;
|
||||
this.callback.done(gson.fromJson(statusResponse.getResponse(), ServerPing.class), (Throwable)null);
|
||||
System.out.println("handle");
|
||||
// this.channel.close(); //MINEPLEX
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "[Ping Handler] -> " + this.target.getName();
|
||||
}
|
||||
|
||||
public PingHandler(ServerInfo target, Callback<ServerPing> callback, int protocol) {
|
||||
this.target = target;
|
||||
this.callback = callback;
|
||||
this.protocol = protocol;
|
||||
}
|
||||
}
|
@ -2,12 +2,12 @@
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpclient-4.2.jar"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpcore-4.2.jar"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/commons-codec-1.6.jar"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/gson-2.2.1.jar"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/javax.mail.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.ServerData"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpclient-4.2.jar"/>
|
||||
<classpathentry kind="var" path="REPO_DIR"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpcore-4.2.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
@ -17,6 +17,7 @@ import java.util.logging.Logger;
|
||||
import mineplex.bungee.api.ApiDeleteCall;
|
||||
import mineplex.bungee.api.ApiGetCall;
|
||||
import mineplex.bungee.api.ApiPostCall;
|
||||
import mineplex.bungee.api.HttpCallBase;
|
||||
import mineplex.bungee.api.token.ARecord;
|
||||
import mineplex.bungee.api.token.DnsRecord;
|
||||
import mineplex.bungee.api.token.DomainRecords;
|
||||
@ -25,11 +26,11 @@ import mineplex.serverdata.data.BungeeServer;
|
||||
import mineplex.serverdata.data.DataRepository;
|
||||
import mineplex.serverdata.redis.RedisDataRepository;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
import mineplex.serverdata.servers.ServerRepository;
|
||||
|
||||
public class BungeeRotator
|
||||
{
|
||||
private static DataRepository<BungeeServer> _repository;
|
||||
private static PlayerStatsRepository _ipRepository;
|
||||
//private static ServerRepository _repository = null;
|
||||
|
||||
private static SimpleDateFormat _dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
|
||||
@ -71,6 +72,8 @@ public class BungeeRotator
|
||||
_repository = new RedisDataRepository<BungeeServer>(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(),
|
||||
Region.ALL, BungeeServer.class, "bungeeServers");
|
||||
|
||||
_ipRepository = new PlayerStatsRepository();
|
||||
|
||||
BungeeSorter bungeeSorter = new BungeeSorter();
|
||||
int maxRecordCount = 10;
|
||||
|
||||
@ -89,6 +92,9 @@ public class BungeeRotator
|
||||
|
||||
for (BungeeServer server : bungeeServers)
|
||||
{
|
||||
if (server.getPublicAddress().equalsIgnoreCase("127.0.0.1") || server.getPublicAddress().equalsIgnoreCase("0.0.0.0"))
|
||||
continue;
|
||||
|
||||
totalPlayers += server.getPlayerCount();
|
||||
|
||||
if (server.getRegion() == Region.US)
|
||||
@ -112,6 +118,9 @@ public class BungeeRotator
|
||||
|
||||
for (BungeeServer server : bungeeServers)
|
||||
{
|
||||
if (server.getPublicAddress().equalsIgnoreCase("127.0.0.1"))
|
||||
continue;
|
||||
|
||||
if (usServers.size() < maxRecordCount && server.getRegion() == Region.US)
|
||||
{
|
||||
if (usServers.size() >= 2 && server.getPlayerCount() > 900)
|
||||
@ -200,7 +209,28 @@ public class BungeeRotator
|
||||
log("Deleted " + recordsToDelete.size() + " records.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
List<IpInfo> updatedAddresses = new ArrayList<IpInfo>(1000);
|
||||
|
||||
for (IpInfo ipInfo : _ipRepository.getIpAddresses())
|
||||
{
|
||||
IPGeoData recor = new HttpCallBase("http://www.freegeoip.net/json/" + ipInfo.ipAddress).Execute(IPGeoData.class);
|
||||
ipInfo.countryCode = recor.country_code;
|
||||
ipInfo.countryName = recor.country_name;
|
||||
ipInfo.regionCode = recor.region_code;
|
||||
ipInfo.regionName = recor.region_name;
|
||||
ipInfo.city = recor.city;
|
||||
ipInfo.zipCode = recor.zip_code;
|
||||
ipInfo.timeZone = recor.time_zone;
|
||||
ipInfo.latitude = recor.latitude;
|
||||
ipInfo.longitude = recor.longitude;
|
||||
ipInfo.metroCode = recor.metro_code;
|
||||
|
||||
updatedAddresses.add(ipInfo);
|
||||
}
|
||||
|
||||
_ipRepository.updateIps(updatedAddresses);
|
||||
|
||||
try
|
||||
{
|
||||
Thread.sleep(15000);
|
||||
@ -213,6 +243,7 @@ public class BungeeRotator
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
log("Error doing something : " + ex.getMessage());
|
||||
|
||||
try
|
||||
|
@ -0,0 +1,16 @@
|
||||
package mineplex.bungee;
|
||||
|
||||
public class IPGeoData
|
||||
{
|
||||
public String ip;
|
||||
public String country_code;
|
||||
public String country_name;
|
||||
public String region_code;
|
||||
public String region_name;
|
||||
public String city;
|
||||
public String zip_code;
|
||||
public String time_zone;
|
||||
public double latitude;
|
||||
public double longitude;
|
||||
public int metro_code;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package mineplex.bungee;
|
||||
|
||||
public class IpInfo
|
||||
{
|
||||
public int id;
|
||||
public String ipAddress;
|
||||
public String countryCode;
|
||||
public String countryName;
|
||||
public String regionCode;
|
||||
public String regionName;
|
||||
public String city;
|
||||
public String zipCode;
|
||||
public String timeZone;
|
||||
public double latitude;
|
||||
public double longitude;
|
||||
public int metroCode;
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
package mineplex.bungee;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerStatsRepository
|
||||
{
|
||||
private Connection _connection = null;
|
||||
private String _connectionString = "jdbc:mysql://sqlstats.mineplex.com:3306/PlayerStats?autoReconnect=true&failOverReadOnly=false&maxReconnects=10&allowMultiQueries=true";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
private static String SELECT_IPINFO = "SELECT id, ipAddress FROM ipInfo WHERE regionName IS NULL LIMIT 1000;";
|
||||
private static String UPDATE_IPINFO = "UPDATE ipInfo SET countryCode = ?, countryName = ?, regionCode = ?, regionName = ?, city = ?, zipCode = ?, timeZone = ?, latitude = ?, longitude = ?, metroCode = ? WHERE id = ?;";
|
||||
|
||||
public void initialize()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println("Initialized PlayerStats.");
|
||||
}
|
||||
|
||||
public List<IpInfo> getIpAddresses()
|
||||
{
|
||||
List<IpInfo> ipinfos = new ArrayList<IpInfo>(1000);
|
||||
PreparedStatement preparedStatement = null;
|
||||
ResultSet resultSet = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(SELECT_IPINFO);
|
||||
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
IpInfo ipInfo = new IpInfo();
|
||||
ipInfo.id = resultSet.getInt(1);
|
||||
ipInfo.ipAddress = resultSet.getString(2);
|
||||
|
||||
ipinfos.add(ipInfo);
|
||||
}
|
||||
|
||||
resultSet.close();
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (resultSet != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ipinfos;
|
||||
}
|
||||
|
||||
public void updateIps(List<IpInfo> ips)
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(UPDATE_IPINFO);
|
||||
|
||||
for (IpInfo ipInfo : ips)
|
||||
{
|
||||
preparedStatement.setString(1, ipInfo.countryCode);
|
||||
preparedStatement.setString(2, ipInfo.countryName);
|
||||
preparedStatement.setString(3, ipInfo.regionCode);
|
||||
preparedStatement.setString(4, ipInfo.regionName);
|
||||
preparedStatement.setString(5, ipInfo.city);
|
||||
preparedStatement.setString(6, ipInfo.zipCode);
|
||||
preparedStatement.setString(7, ipInfo.timeZone);
|
||||
preparedStatement.setDouble(8, ipInfo.latitude);
|
||||
preparedStatement.setDouble(9, ipInfo.longitude);
|
||||
preparedStatement.setInt(10, ipInfo.metroCode);
|
||||
preparedStatement.setInt(11, ipInfo.id);
|
||||
|
||||
preparedStatement.addBatch();
|
||||
}
|
||||
|
||||
preparedStatement.executeBatch();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
package mineplex.bungee.api;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpRequestBase;
|
||||
import org.apache.http.conn.scheme.PlainSocketFactory;
|
||||
import org.apache.http.conn.scheme.Scheme;
|
||||
import org.apache.http.conn.scheme.SchemeRegistry;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.impl.conn.PoolingClientConnectionManager;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class HttpCallBase
|
||||
{
|
||||
private String _url;
|
||||
|
||||
public HttpCallBase(String url)
|
||||
{
|
||||
_url = url;
|
||||
}
|
||||
|
||||
public <T> T Execute(Type returnType)
|
||||
{
|
||||
HttpGet request = new HttpGet(_url);
|
||||
|
||||
String response = execute(request);
|
||||
System.out.println(response);
|
||||
return new Gson().fromJson(response, returnType);
|
||||
}
|
||||
|
||||
protected String execute(HttpRequestBase request)
|
||||
{
|
||||
SchemeRegistry schemeRegistry = new SchemeRegistry();
|
||||
schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
|
||||
|
||||
PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager(schemeRegistry);
|
||||
connectionManager.setMaxTotal(200);
|
||||
connectionManager.setDefaultMaxPerRoute(20);
|
||||
|
||||
HttpClient httpClient = new DefaultHttpClient(connectionManager);
|
||||
InputStream in = null;
|
||||
String response = "";
|
||||
|
||||
try
|
||||
{
|
||||
request.addHeader("Content-Type", "application/json");
|
||||
HttpResponse httpResponse = httpClient.execute(request);
|
||||
|
||||
if (httpResponse != null)
|
||||
{
|
||||
in = httpResponse.getEntity().getContent();
|
||||
response = convertStreamToString(in);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.out.println("HttpCall Error:\n" + ex.getMessage());
|
||||
|
||||
for (StackTraceElement trace : ex.getStackTrace())
|
||||
{
|
||||
System.out.println(trace);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
httpClient.getConnectionManager().shutdown();
|
||||
|
||||
if (in != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
protected String convertStreamToString(InputStream is)
|
||||
{
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
String line = null;
|
||||
try
|
||||
{
|
||||
while ((line = reader.readLine()) != null)
|
||||
{
|
||||
sb.append(line + "\n");
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
is.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
11
Plugins/Mineplex.ChestConverter/.classpath
Normal file
11
Plugins/Mineplex.ChestConverter/.classpath
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/gson-2.2.1.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpclient-4.2.jar"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpcore-4.2.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.ServerData"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AFTER_CLEAN_TARGETS" value="ChestConverter,"/>
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="ChestConverter,"/>
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="ChestConverter,"/>
|
||||
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value=""/>
|
||||
<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"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/Mineplex.ChestConverter}"/>
|
||||
</launchConfiguration>
|
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AFTER_CLEAN_TARGETS" value="ServerMonitor,"/>
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="ServerMonitor,"/>
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="ServerMonitor,"/>
|
||||
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/>
|
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value=""/>
|
||||
<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"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/Mineplex.ServerMonitor}"/>
|
||||
</launchConfiguration>
|
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AFTER_CLEAN_TARGETS" value="ServerMonitor,"/>
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="ServerMonitor,"/>
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="ServerMonitor,"/>
|
||||
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/>
|
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value=""/>
|
||||
<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"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/Mineplex.ServerMonitor}"/>
|
||||
</launchConfiguration>
|
37
Plugins/Mineplex.ChestConverter/.project
Normal file
37
Plugins/Mineplex.ChestConverter/.project
Normal file
@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Mineplex.ChestConverter</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||
<triggers>auto,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>LaunchConfigHandle</key>
|
||||
<value><project>/.externalToolBuilders/ServerMonitor.launch</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||
<triggers>auto,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>LaunchConfigHandle</key>
|
||||
<value><project>/.externalToolBuilders/Chest.launch</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
@ -0,0 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
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
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
17
Plugins/Mineplex.ChestConverter/Mineplex.ServerMonitor.iml
Normal file
17
Plugins/Mineplex.ChestConverter/Mineplex.ServerMonitor.iml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="gson" level="project" />
|
||||
<orderEntry type="library" name="httpclient" level="project" />
|
||||
<orderEntry type="library" name="httpcore" level="project" />
|
||||
<orderEntry type="module" module-name="Mineplex.Core.Common" />
|
||||
<orderEntry type="module" module-name="Mineplex.ServerData" />
|
||||
</component>
|
||||
</module>
|
||||
|
@ -0,0 +1,46 @@
|
||||
package mineplex.chestConverter;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ChestConverter
|
||||
{
|
||||
private static ChestConverterRepository _repository = null;
|
||||
private static SimpleDateFormat _dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
|
||||
|
||||
public static void main (String args[])
|
||||
{
|
||||
_repository = new ChestConverterRepository();
|
||||
int count = 5000;
|
||||
|
||||
while (true)
|
||||
{
|
||||
long time = System.currentTimeMillis();
|
||||
HashMap<String, Integer> playerMap = _repository.retrieveKeyInventoryBatch(count);
|
||||
|
||||
if (playerMap.size() == 0)
|
||||
return;
|
||||
|
||||
_repository.incrementClient(playerMap, false);
|
||||
_repository.deleteKeys(count);
|
||||
try
|
||||
{
|
||||
log("Natural sleep. " + count + " took " + (System.currentTimeMillis() - time) / 1000 + " seconds.");
|
||||
Thread.sleep(250);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void log(String message)
|
||||
{
|
||||
System.out.println("[" + _dateFormat.format(new Date()) + "] " + message);
|
||||
}
|
||||
}
|
@ -0,0 +1,316 @@
|
||||
package mineplex.chestConverter;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class ChestConverterRepository
|
||||
{
|
||||
private String _connectionString = "jdbc:mysql://db.mineplex.com:3306/Account";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
private static String RETRIEVE_CHESTS = "SELECT A.uuid, count FROM accountInventory INNER JOIN accounts AS A ON A.id = accountInventory.accountId WHERE itemId = 56 AND count > 0 ORDER BY accountInventory.id LIMIT ?;";
|
||||
private static String RETRIEVE_KEYS = "SELECT A.uuid, count FROM accountInventory INNER JOIN accounts AS A ON A.id = accountInventory.accountId WHERE itemId = 67 AND count > 0 ORDER BY accountInventory.id LIMIT ?;";
|
||||
|
||||
private static String DELETE_CHESTS = "DELETE FROM accountInventory WHERE itemId = 56 ORDER BY accountInventory.id LIMIT ?";
|
||||
private static String DELETE_KEYS = "DELETE FROM accountInventory WHERE itemId = 67 ORDER BY accountInventory.id LIMIT ?";
|
||||
|
||||
private static String INSERT_CLIENT_INVENTORY = "INSERT INTO accountInventory (accountId, itemId, count) SELECT accounts.id, ?, ? FROM accounts WHERE accounts.uuid = ? ON DUPLICATE KEY UPDATE count=count + VALUES(count);";
|
||||
private static String UPDATE_CLIENT_INVENTORY = "UPDATE accountInventory AS AI INNER JOIN accounts ON AI.accountId = accounts.id SET AI.count = AI.count + ? WHERE accounts.uuid = ? AND AI.itemId = ?;";
|
||||
|
||||
private static Connection _connection;
|
||||
|
||||
public ChestConverterRepository()
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public HashMap<String, Integer> retrieveChestInventoryBatch(int count)
|
||||
{
|
||||
HashMap<String, Integer> playerList = new HashMap<String, Integer>();
|
||||
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(RETRIEVE_CHESTS);
|
||||
preparedStatement.setInt(1, count);
|
||||
ResultSet resultSet = preparedStatement.executeQuery();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
playerList.put(resultSet.getString(1), resultSet.getInt(2));
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return playerList;
|
||||
}
|
||||
|
||||
public HashMap<String, Integer> retrieveKeyInventoryBatch(int count)
|
||||
{
|
||||
HashMap<String, Integer> playerList = new HashMap<String, Integer>();
|
||||
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(RETRIEVE_KEYS);
|
||||
preparedStatement.setInt(1, count);
|
||||
ResultSet resultSet = preparedStatement.executeQuery();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
playerList.put(resultSet.getString(1), resultSet.getInt(2));
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return playerList;
|
||||
}
|
||||
|
||||
public void incrementClient(HashMap<String, Integer> playerList, boolean chest)
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(UPDATE_CLIENT_INVENTORY);
|
||||
|
||||
for (Entry<String, Integer> entry : playerList.entrySet())
|
||||
{
|
||||
preparedStatement.setInt(1, entry.getValue());
|
||||
preparedStatement.setString(2, entry.getKey());
|
||||
preparedStatement.setInt(3, chest ? 690 : 692);
|
||||
|
||||
preparedStatement.addBatch();
|
||||
|
||||
if (chest)
|
||||
{
|
||||
if (entry.getValue() > 20)
|
||||
{
|
||||
preparedStatement.setInt(1, 1);
|
||||
preparedStatement.setString(2, entry.getKey());
|
||||
preparedStatement.setInt(3, 692);
|
||||
|
||||
preparedStatement.addBatch();
|
||||
}
|
||||
|
||||
if (entry.getValue() > 50)
|
||||
{
|
||||
preparedStatement.setInt(1, 1);
|
||||
preparedStatement.setString(2, entry.getKey());
|
||||
preparedStatement.setInt(3, 691);
|
||||
|
||||
preparedStatement.addBatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int[] rowsAffected = preparedStatement.executeBatch();
|
||||
int i = 0;
|
||||
|
||||
preparedStatement.close();
|
||||
preparedStatement = _connection.prepareStatement(INSERT_CLIENT_INVENTORY);
|
||||
|
||||
for (Entry<String, Integer> entry : playerList.entrySet())
|
||||
{
|
||||
if (rowsAffected[i] < 1)
|
||||
{
|
||||
preparedStatement.setInt(1, chest ? 690 : 692);
|
||||
preparedStatement.setInt(2, entry.getValue());
|
||||
preparedStatement.setString(3, entry.getKey());
|
||||
|
||||
preparedStatement.addBatch();
|
||||
|
||||
if (chest)
|
||||
{
|
||||
if (entry.getValue() > 20)
|
||||
{
|
||||
preparedStatement.setInt(1, 692);
|
||||
preparedStatement.setInt(2, 1);
|
||||
preparedStatement.setString(3, entry.getKey());
|
||||
|
||||
preparedStatement.addBatch();
|
||||
}
|
||||
|
||||
if (entry.getValue() > 50)
|
||||
{
|
||||
preparedStatement.setInt(1, 691);
|
||||
preparedStatement.setInt(2, 1);
|
||||
preparedStatement.setString(3, entry.getKey());
|
||||
|
||||
preparedStatement.addBatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
preparedStatement.executeBatch();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteChests(int count)
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(DELETE_CHESTS);
|
||||
preparedStatement.setInt(1, count);
|
||||
preparedStatement.executeUpdate();
|
||||
|
||||
System.out.println("Deleting " + count + " inventory records.");
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteKeys(int count)
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(DELETE_KEYS);
|
||||
preparedStatement.setInt(1, count);
|
||||
preparedStatement.executeUpdate();
|
||||
|
||||
System.out.println("Deleting " + count + " inventory records.");
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package mineplex.chestConverter;
|
||||
|
||||
public interface GenericRunnable<T>
|
||||
{
|
||||
void run(T t);
|
||||
}
|
@ -14,12 +14,15 @@ public enum Rank
|
||||
SNR_MODERATOR("Sr.Mod", ChatColor.GOLD),
|
||||
MODERATOR("Mod", ChatColor.GOLD),
|
||||
HELPER("Helper", ChatColor.DARK_AQUA),
|
||||
MAPDEV("Mapper", ChatColor.BLUE),
|
||||
MAPLEAD("MapKing", ChatColor.DARK_PURPLE),
|
||||
MAPDEV("Builder", ChatColor.BLUE),
|
||||
MAPLEAD("MapLead", ChatColor.DARK_PURPLE),
|
||||
|
||||
EVENT("Event", ChatColor.WHITE),
|
||||
|
||||
//Staff ^^
|
||||
|
||||
YOUTUBE("YouTube", ChatColor.RED),
|
||||
TWITCH("Twitch", ChatColor.DARK_PURPLE),
|
||||
LEGEND("Legend", ChatColor.GREEN),
|
||||
HERO("Hero", ChatColor.LIGHT_PURPLE),
|
||||
ULTRA("Ultra", ChatColor.AQUA),
|
||||
|
@ -134,6 +134,13 @@ public class F
|
||||
if (on) return indent + C.listTitle + variable + ": " + C.listValueOn + value;
|
||||
else return indent + C.listTitle + variable + ": " + C.listValueOff + value;
|
||||
}
|
||||
|
||||
public static String ed(boolean var)
|
||||
{
|
||||
if (var)
|
||||
return C.listValueOn + "Enabled" + C.mBody;
|
||||
return C.listValueOff + "Disabled" + C.mBody;
|
||||
}
|
||||
|
||||
public static String oo(boolean var)
|
||||
{
|
||||
|
@ -6,6 +6,7 @@ import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -92,6 +93,10 @@ public class UtilAlg
|
||||
if (y <= 0) pitch += 90;
|
||||
else pitch -= 90;
|
||||
|
||||
//Fix for two vectors at same Y giving 180
|
||||
if (pitch == 180)
|
||||
pitch = 0;
|
||||
|
||||
return (float) pitch;
|
||||
}
|
||||
|
||||
@ -244,4 +249,15 @@ public class UtilAlg
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static boolean isTargetInPlayerPyramid(Player player, Player target, double angleLimit)
|
||||
{
|
||||
return isInPyramid(player.getLocation().getDirection(), UtilAlg.getTrajectory(player.getEyeLocation(), target.getEyeLocation()), angleLimit) ||
|
||||
isInPyramid(player.getLocation().getDirection(), UtilAlg.getTrajectory(player.getEyeLocation(), target.getLocation()), angleLimit);
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,16 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.Blocks;
|
||||
import net.minecraft.server.v1_7_R4.MathHelper;
|
||||
import net.minecraft.server.v1_7_R4.WorldServer;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class UtilBlock
|
||||
@ -304,7 +309,13 @@ public class UtilBlock
|
||||
return blockList;
|
||||
}
|
||||
|
||||
|
||||
public static HashMap<Block, Double> getInRadius(Block block, double dR)
|
||||
{
|
||||
return getInRadius(block, dR, false);
|
||||
}
|
||||
|
||||
public static HashMap<Block, Double> getInRadius(Block block, double dR, boolean hollow)
|
||||
{
|
||||
HashMap<Block, Double> blockList = new HashMap<Block, Double>();
|
||||
int iR = (int)dR + 1;
|
||||
@ -317,8 +328,10 @@ public class UtilBlock
|
||||
|
||||
double offset = UtilMath.offset(block.getLocation(), curBlock.getLocation());
|
||||
|
||||
if (offset <= dR)
|
||||
blockList.put(curBlock, 1 - (offset/dR));
|
||||
if (offset <= dR && !(hollow && offset < dR - 1))
|
||||
{
|
||||
blockList.put(curBlock, 1 - (offset / dR));
|
||||
}
|
||||
}
|
||||
|
||||
return blockList;
|
||||
@ -369,6 +382,74 @@ public class UtilBlock
|
||||
|
||||
return block.getRelative(BlockFace.UP);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param location of explosion
|
||||
* @param strength of explosion
|
||||
* @param damageBlocksEqually - Treat all blocks as durability of dirt
|
||||
* @param ensureDestruction - Ensure that the closest blocks are destroyed at least
|
||||
* @return
|
||||
*/
|
||||
public static ArrayList<Block> getExplosionBlocks(Location location, float strength, boolean damageBlocksEqually)
|
||||
{
|
||||
ArrayList<Block> toExplode = new ArrayList<Block>();
|
||||
WorldServer world = ((CraftWorld) location.getWorld()).getHandle();
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
for (int j = 0; j < 16; j++)
|
||||
{
|
||||
for (int k = 0; k < 16; k++)
|
||||
{
|
||||
if ((i == 0) || (i == 16 - 1) || (j == 0) || (j == 16 - 1) || (k == 0) || (k == 16 - 1))
|
||||
{
|
||||
double d3 = i / (16 - 1.0F) * 2.0F - 1.0F;
|
||||
double d4 = j / (16 - 1.0F) * 2.0F - 1.0F;
|
||||
double d5 = k / (16 - 1.0F) * 2.0F - 1.0F;
|
||||
double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
|
||||
|
||||
d3 /= d6;
|
||||
d4 /= d6;
|
||||
d5 /= d6;
|
||||
float f1 = strength * (0.7F + UtilMath.random.nextFloat() * 0.6F);
|
||||
|
||||
double d0 = location.getX();
|
||||
double d1 = location.getY();
|
||||
double d2 = location.getZ();
|
||||
|
||||
for (float f2 = 0.3F; f1 > 0.0F; f1 -= f2 * 0.75F)
|
||||
{
|
||||
int l = MathHelper.floor(d0);
|
||||
int i1 = MathHelper.floor(d1);
|
||||
int j1 = MathHelper.floor(d2);
|
||||
Block block = location.getWorld().getBlockAt(l, i1, j1);
|
||||
|
||||
if (block.getType() != Material.AIR)
|
||||
{
|
||||
float f3 = (damageBlocksEqually ? Blocks.DIRT : world.getType(block.getX(), block.getY(),
|
||||
block.getZ())).a((net.minecraft.server.v1_7_R4.Entity) null);
|
||||
|
||||
f1 -= (f3 + 0.3F) * f2;
|
||||
}
|
||||
|
||||
if ((f1 > 0.0F) && (i1 < 256) && (i1 >= 0))
|
||||
{
|
||||
toExplode.add(block);
|
||||
}
|
||||
|
||||
d0 += d3 * f2;
|
||||
d1 += d4 * f2;
|
||||
d2 += d5 * f2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return toExplode;
|
||||
}
|
||||
|
||||
public static ArrayList<Block> getSurrounding(Block block, boolean diagonals)
|
||||
{
|
||||
ArrayList<Block> blocks = new ArrayList<Block>();
|
||||
|
@ -4,22 +4,20 @@ import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.EntityBat;
|
||||
import net.minecraft.server.v1_7_R4.EntityCreature;
|
||||
import net.minecraft.server.v1_7_R4.EntityEnderDragon;
|
||||
import net.minecraft.server.v1_7_R4.EntityHuman;
|
||||
import net.minecraft.server.v1_7_R4.EntityInsentient;
|
||||
import net.minecraft.server.v1_7_R4.Navigation;
|
||||
import net.minecraft.server.v1_7_R4.PathfinderGoalLookAtPlayer;
|
||||
import net.minecraft.server.v1_7_R4.PathfinderGoalMoveTowardsRestriction;
|
||||
import net.minecraft.server.v1_7_R4.PathfinderGoalRandomLookaround;
|
||||
import net.minecraft.server.v1_7_R4.PathfinderGoalSelector;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity;
|
||||
@ -381,7 +379,7 @@ public class UtilEnt
|
||||
|
||||
for (Entity cur : loc.getWorld().getEntities())
|
||||
{
|
||||
if (!(cur instanceof LivingEntity) || (cur instanceof Player && ((Player)cur).getGameMode() == GameMode.CREATIVE))
|
||||
if (!(cur instanceof LivingEntity) || UtilPlayer.isSpectator(cur))
|
||||
continue;
|
||||
|
||||
LivingEntity ent = (LivingEntity)cur;
|
||||
@ -613,4 +611,25 @@ public class UtilEnt
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static Entity getEntityById(int entityId)
|
||||
{
|
||||
for (World world : Bukkit.getWorlds())
|
||||
{
|
||||
for (Entity entity : world.getEntities())
|
||||
{
|
||||
if (entity.getEntityId() == entityId)
|
||||
{
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean inWater(LivingEntity ent)
|
||||
{
|
||||
return ent.getLocation().getBlock().getTypeId() == 8 || ent.getLocation().getBlock().getTypeId() == 9;
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package mineplex.core.common.util;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@ -68,20 +67,28 @@ public class UtilInv
|
||||
{
|
||||
return contains(player, null, item, data, required);
|
||||
}
|
||||
|
||||
|
||||
public static boolean contains(Player player, String itemNameContains, Material item, byte data, int required)
|
||||
{
|
||||
return contains(player, itemNameContains, item, data, required, true, true);
|
||||
}
|
||||
|
||||
public static boolean contains(Player player, String itemNameContains, Material item, byte data, int required, boolean checkArmor, boolean checkCursor)
|
||||
{
|
||||
|
||||
for (int i : player.getInventory().all(item).keySet())
|
||||
for (ItemStack stack : getItems(player, checkArmor, checkCursor))
|
||||
{
|
||||
if (required <= 0)
|
||||
{
|
||||
return true;
|
||||
|
||||
ItemStack stack = player.getInventory().getItem(i);
|
||||
}
|
||||
|
||||
if (stack == null)
|
||||
continue;
|
||||
|
||||
if (stack.getType() != item)
|
||||
continue;
|
||||
|
||||
if (stack.getAmount() <= 0)
|
||||
continue;
|
||||
|
||||
@ -152,34 +159,45 @@ public class UtilInv
|
||||
|
||||
player.saveData();
|
||||
}
|
||||
|
||||
|
||||
public static ArrayList<ItemStack> getItems(Player player)
|
||||
{
|
||||
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
|
||||
PlayerInventory inv = player.getInventory();
|
||||
return getItems(player, true, true);
|
||||
}
|
||||
|
||||
for (ItemStack item : inv.getContents())
|
||||
{
|
||||
if (item != null && item.getType() != Material.AIR)
|
||||
{
|
||||
items.add(item.clone());
|
||||
}
|
||||
}
|
||||
|
||||
for (ItemStack item : inv.getArmorContents())
|
||||
{
|
||||
if (item != null && item.getType() != Material.AIR)
|
||||
{
|
||||
items.add(item.clone());
|
||||
}
|
||||
}
|
||||
public static ArrayList<ItemStack> getItems(Player player, boolean getArmor, boolean getCursor)
|
||||
{
|
||||
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
|
||||
PlayerInventory inv = player.getInventory();
|
||||
|
||||
ItemStack cursorItem = player.getItemOnCursor();
|
||||
for (ItemStack item : inv.getContents())
|
||||
{
|
||||
if (item != null && item.getType() != Material.AIR)
|
||||
{
|
||||
items.add(item.clone());
|
||||
}
|
||||
}
|
||||
|
||||
if (cursorItem != null && cursorItem.getType() != Material.AIR)
|
||||
items.add(cursorItem.clone());
|
||||
|
||||
return items;
|
||||
if (getArmor)
|
||||
{
|
||||
for (ItemStack item : inv.getArmorContents())
|
||||
{
|
||||
if (item != null && item.getType() != Material.AIR)
|
||||
{
|
||||
items.add(item.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getCursor)
|
||||
{
|
||||
ItemStack cursorItem = player.getItemOnCursor();
|
||||
|
||||
if (cursorItem != null && cursorItem.getType() != Material.AIR)
|
||||
items.add(cursorItem.clone());
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
public static void drop(Player player, boolean clear)
|
||||
@ -324,23 +342,6 @@ public class UtilInv
|
||||
}
|
||||
}
|
||||
|
||||
public static void refreshDurability(Player player, Material type)
|
||||
{
|
||||
for (ItemStack item : player.getInventory().getContents())
|
||||
if (item != null)
|
||||
if (item.getType() == type)
|
||||
{
|
||||
if (item.getDurability() == 0)
|
||||
{
|
||||
item.setDurability((short) 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.setDurability((short) 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void UseItemInHand(Player player)
|
||||
{
|
||||
if (player.getItemInHand().getAmount() > 1)
|
||||
|
@ -0,0 +1,130 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
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)
|
||||
{
|
||||
LinkedList<Entry<Material, Byte>> matchList = new LinkedList<Entry<Material, Byte>>();
|
||||
|
||||
String failList = "";
|
||||
|
||||
//Mass Search
|
||||
for (String cur : items.split(","))
|
||||
{
|
||||
Entry<Material, Byte> match = searchItem(caller, cur, inform);
|
||||
|
||||
if (match != null)
|
||||
matchList.add(match);
|
||||
|
||||
else
|
||||
failList += cur + " " ;
|
||||
}
|
||||
|
||||
if (inform && failList.length() > 0)
|
||||
{
|
||||
failList = failList.substring(0, failList.length() - 1);
|
||||
UtilPlayer.message(caller, F.main("Item(s) Search", "" +
|
||||
C.mBody + " Invalid [" +
|
||||
C.mElem + failList +
|
||||
C.mBody + "]."));
|
||||
}
|
||||
|
||||
return matchList;
|
||||
}
|
||||
|
||||
public static Entry<Material, Byte> searchItem(Player caller, String args, boolean inform)
|
||||
{
|
||||
LinkedList<Entry<Material, Byte>> matchList = new LinkedList<Entry<Material, Byte>>();
|
||||
|
||||
for (Material cur : Material.values())
|
||||
{
|
||||
//By Name
|
||||
if (cur.toString().equalsIgnoreCase(args))
|
||||
return new AbstractMap.SimpleEntry<Material, Byte>(cur, (byte)0);
|
||||
|
||||
if (cur.toString().toLowerCase().contains(args.toLowerCase()))
|
||||
matchList.add(new AbstractMap.SimpleEntry<Material, Byte>(cur, (byte)0));
|
||||
|
||||
//By ID:Data
|
||||
String[] arg = args.split(":");
|
||||
|
||||
//ID
|
||||
int id = 0;
|
||||
try
|
||||
{
|
||||
if (arg.length > 0)
|
||||
id = Integer.parseInt(arg[0]);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (id != cur.getId())
|
||||
continue;
|
||||
|
||||
//Data
|
||||
byte data = 0;
|
||||
try
|
||||
{
|
||||
if (arg.length > 1)
|
||||
data = Byte.parseByte(arg[1]);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
return new AbstractMap.SimpleEntry<Material, Byte>(cur, data);
|
||||
}
|
||||
|
||||
//No / Non-Unique
|
||||
if (matchList.size() != 1)
|
||||
{
|
||||
if (!inform)
|
||||
return null;
|
||||
|
||||
//Inform
|
||||
UtilPlayer.message(caller, F.main("Item Search", "" +
|
||||
C.mCount + matchList.size() +
|
||||
C.mBody + " matches for [" +
|
||||
C.mElem + args +
|
||||
C.mBody + "]."));
|
||||
|
||||
if (matchList.size() > 0)
|
||||
{
|
||||
String matchString = "";
|
||||
for (Entry<Material, Byte> cur : matchList)
|
||||
matchString += F.elem(cur.getKey().toString()) + ", ";
|
||||
if (matchString.length() > 1)
|
||||
matchString = matchString.substring(0 , matchString.length() - 2);
|
||||
|
||||
UtilPlayer.message(caller, F.main("Item Search", "" +
|
||||
C.mBody + "Matches [" +
|
||||
C.mElem + matchString +
|
||||
C.mBody + "]."));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return matchList.get(0);
|
||||
}
|
||||
|
||||
public static String itemToStr(ItemStack item)
|
||||
{
|
||||
String data = "0";
|
||||
if (item.getData() != null)
|
||||
data = item.getData().getData() + "";
|
||||
|
||||
return item.getType() + ":" + item.getAmount() + ":" + item.getDurability() + ":" + data;
|
||||
}
|
||||
}
|
@ -1,127 +1,231 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutWorldParticles;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class UtilParticle
|
||||
{
|
||||
public enum ParticleType
|
||||
public enum ViewDist
|
||||
{
|
||||
HUGE_EXPLOSION("hugeexplosion"),
|
||||
LARGE_EXPLODE("largeexplode"),
|
||||
FIREWORKS_SPARK("fireworksSpark"),
|
||||
BUBBLE("bubble"),
|
||||
SUSPEND("suspended"),
|
||||
DEPTH_SUSPEND("depthSuspend"),
|
||||
TOWN_AURA("townaura"),
|
||||
CRIT("crit"),
|
||||
MAGIC_CRIT("magicCrit"),
|
||||
MOB_SPELL("mobSpell"),
|
||||
MOB_SPELL_AMBIENT("mobSpellAmbient"),
|
||||
SPELL("spell"),
|
||||
INSTANT_SPELL("instantSpell"),
|
||||
WITCH_MAGIC("witchMagic"),
|
||||
NOTE("note"),
|
||||
PORTAL("portal"),
|
||||
ENCHANTMENT_TABLE("enchantmenttable"),
|
||||
EXPLODE("explode"),
|
||||
FLAME("flame"),
|
||||
LAVA("lava"),
|
||||
FOOTSTEP("footstep"),
|
||||
SPLASH("splash"),
|
||||
LARGE_SMOKE("largesmoke"),
|
||||
CLOUD("cloud"),
|
||||
RED_DUST("reddust"),
|
||||
SNOWBALL_POOF("snowballpoof"),
|
||||
DRIP_WATER("dripWater"),
|
||||
DRIP_LAVA("dripLava"),
|
||||
DROPLET("droplet"),
|
||||
SNOW_SHOVEL("snowshovel"),
|
||||
SLIME("slime"),
|
||||
HEART("heart"),
|
||||
ANGRY_VILLAGER("angryVillager"),
|
||||
HAPPY_VILLAGER("happyVillager");
|
||||
|
||||
public String particleName;
|
||||
|
||||
ParticleType(String particleName)
|
||||
{
|
||||
this.particleName = particleName;
|
||||
}
|
||||
SHORT(8),
|
||||
NORMAL(24),
|
||||
LONG(48),
|
||||
LONGER(96),
|
||||
MAX(256);
|
||||
|
||||
private int _dist;
|
||||
|
||||
ViewDist(int dist)
|
||||
{
|
||||
_dist = dist;
|
||||
}
|
||||
|
||||
public int getDist()
|
||||
{
|
||||
return _dist;
|
||||
}
|
||||
}
|
||||
|
||||
public static void PlayParticle(Player player, ParticleType type, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count)
|
||||
{
|
||||
PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles();
|
||||
|
||||
for (Field field : packet.getClass().getDeclaredFields())
|
||||
{
|
||||
try
|
||||
{
|
||||
field.setAccessible(true);
|
||||
String fieldName = field.getName();
|
||||
switch (fieldName)
|
||||
{
|
||||
case "a":
|
||||
field.set(packet, type.particleName); //Particle name
|
||||
break;
|
||||
case "b":
|
||||
field.setFloat(packet, (float)location.getX()); //Block X
|
||||
break;
|
||||
case "c":
|
||||
field.setFloat(packet, (float)location.getY()); //Block Y
|
||||
break;
|
||||
case "d":
|
||||
field.setFloat(packet, (float)location.getZ()); //Block Z
|
||||
break;
|
||||
case "e":
|
||||
field.setFloat(packet, offsetX); //Random X Offset
|
||||
break;
|
||||
case "f":
|
||||
field.setFloat(packet, offsetY); //Random Y Offset
|
||||
break;
|
||||
case "g":
|
||||
field.setFloat(packet, offsetZ); //Random Z Offset
|
||||
break;
|
||||
case "h":
|
||||
field.setFloat(packet, speed); //Speed/data of particles
|
||||
break;
|
||||
case "i":
|
||||
field.setInt(packet, count); //Amount of particles
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println(e.getMessage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
public static void PlayParticle(ParticleType type, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count)
|
||||
public enum ParticleType
|
||||
{
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
ANGRY_VILLAGER("angryVillager", "Lightning Cloud", Material.INK_SACK, (byte) 11),
|
||||
|
||||
BLOCK_CRACK("blockcrack_1_0")
|
||||
{
|
||||
//Dont send to players who cannot see it!
|
||||
if (type != ParticleType.FIREWORKS_SPARK &&
|
||||
type != ParticleType.LARGE_EXPLODE &&
|
||||
type != ParticleType.HUGE_EXPLOSION)
|
||||
@Override
|
||||
public String getParticle(Material type, int data)
|
||||
{
|
||||
if (UtilMath.offset(player.getLocation(), location) > 24)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return "blockcrack_" + type.getId() + "_" + data;
|
||||
}
|
||||
},
|
||||
|
||||
BLOCK_DUST("blockdust_1_0")
|
||||
{
|
||||
@Override
|
||||
public String getParticle(Material type, int data)
|
||||
{
|
||||
return "blockdust_" + type.getId() + "_" + data;
|
||||
}
|
||||
},
|
||||
|
||||
BUBBLE("bubble"),
|
||||
|
||||
CLOUD("cloud", "White Smoke", Material.INK_SACK, (byte) 7),
|
||||
|
||||
CRIT("crit", "Brown Magic", Material.INK_SACK, (byte) 14),
|
||||
|
||||
DEPTH_SUSPEND("depthSuspend"),
|
||||
|
||||
DRIP_LAVA("dripLava", "Lava Drip", Material.LAVA_BUCKET, (byte) 0),
|
||||
|
||||
DRIP_WATER("dripWater", "Water Drop", Material.WATER_BUCKET, (byte) 0),
|
||||
|
||||
DROPLET("droplet", "Water Splash", Material.INK_SACK, (byte) 4),
|
||||
|
||||
ENCHANTMENT_TABLE("enchantmenttable", "Enchantment Words", Material.BOOK, (byte) 0),
|
||||
|
||||
EXPLODE("explode", "Big White Smoke", Material.INK_SACK, (byte) 15),
|
||||
|
||||
FIREWORKS_SPARK("fireworksSpark", "White Sparkle", Material.GHAST_TEAR, (byte) 0),
|
||||
|
||||
FLAME("flame", "Flame", Material.BLAZE_POWDER, (byte) 0),
|
||||
|
||||
FOOTSTEP("footstep", "Foot Step", Material.LEATHER_BOOTS, (byte) 0),
|
||||
|
||||
HAPPY_VILLAGER("happyVillager", "Emerald Sparkle", Material.EMERALD, (byte) 0),
|
||||
|
||||
HEART("heart", "Love Heart", Material.APPLE, (byte) 0),
|
||||
|
||||
HUGE_EXPLOSION("hugeexplosion", "Huge Explosion", Material.TNT, (byte) 0),
|
||||
|
||||
ICON_CRACK("iconcrack_1_0")
|
||||
{
|
||||
@Override
|
||||
public String getParticle(Material type, int data)
|
||||
{
|
||||
return "iconcrack_" + type.getId() + "_" + data;
|
||||
}
|
||||
},
|
||||
|
||||
INSTANT_SPELL("instantSpell"),
|
||||
|
||||
LARGE_EXPLODE("largeexplode", "Explosion", Material.FIREBALL, (byte) 0),
|
||||
|
||||
LARGE_SMOKE("largesmoke", "Black Smoke", Material.INK_SACK, (byte) 0),
|
||||
|
||||
LAVA("lava", "Lava Debris", Material.LAVA, (byte) 0),
|
||||
|
||||
MAGIC_CRIT("magicCrit", "Teal Magic", Material.INK_SACK, (byte) 6),
|
||||
|
||||
/**
|
||||
* Can be colored if count is 0, color is RGB and depends on the offset of xyz
|
||||
*/
|
||||
MOB_SPELL("mobSpell", "Black Swirls", Material.getMaterial(2263), (byte) 0),
|
||||
|
||||
/**
|
||||
* Can be colored if count is 0, color is RGB and depends on the offset of xyz
|
||||
*/
|
||||
MOB_SPELL_AMBIENT("mobSpellAmbient", "Transparent Black Swirls", Material.getMaterial(2266), (byte) 0),
|
||||
|
||||
NOTE("note", "Musical Note", Material.JUKEBOX, (byte) 0),
|
||||
|
||||
PORTAL("portal", "Portal Effect", Material.INK_SACK, (byte) 5),
|
||||
|
||||
/**
|
||||
* Can be colored if count is 0, color is RGB and depends on the offset of xyz. Offset y if 0 will default to 1, counter by making it 0.0001
|
||||
*/
|
||||
RED_DUST("reddust", "Red Smoke", Material.INK_SACK, (byte) 1),
|
||||
|
||||
SLIME("slime", "Slime Particles", Material.SLIME_BALL, (byte) 0),
|
||||
|
||||
SNOW_SHOVEL("snowshovel", "Snow Puffs", Material.SNOW_BALL, (byte) 0),
|
||||
|
||||
SNOWBALL_POOF("snowballpoof"),
|
||||
|
||||
SPELL("spell", "White Swirls", Material.getMaterial(2264), (byte) 0),
|
||||
|
||||
SPLASH("splash"),
|
||||
|
||||
SUSPEND("suspended"),
|
||||
|
||||
TOWN_AURA("townaura", "Black Specks", Material.COAL, (byte) 0),
|
||||
|
||||
WITCH_MAGIC("witchMagic", "Purple Magic", Material.INK_SACK, (byte) 13);
|
||||
|
||||
public String particleName;
|
||||
private boolean _friendlyData;
|
||||
private String _friendlyName;
|
||||
private Material _material;
|
||||
private byte _data;
|
||||
|
||||
ParticleType(String particleName)
|
||||
{
|
||||
this.particleName = particleName;
|
||||
_friendlyData = false;
|
||||
}
|
||||
|
||||
ParticleType(String particleName, String friendlyName, Material material, byte data)
|
||||
{
|
||||
this.particleName = particleName;
|
||||
_friendlyData = true;
|
||||
_friendlyName = friendlyName;
|
||||
_material = material;
|
||||
_data = data;
|
||||
}
|
||||
|
||||
public String getParticle(Material type, int data)
|
||||
{
|
||||
return particleName;
|
||||
}
|
||||
|
||||
public boolean hasFriendlyData()
|
||||
{
|
||||
return _friendlyData;
|
||||
}
|
||||
|
||||
public String getFriendlyName()
|
||||
{
|
||||
if (_friendlyName == null)
|
||||
{
|
||||
return toString();
|
||||
}
|
||||
|
||||
PlayParticle(player, type, location, offsetX, offsetY, offsetZ, speed, count);
|
||||
return _friendlyName;
|
||||
}
|
||||
|
||||
public Material getMaterial()
|
||||
{
|
||||
return _material;
|
||||
}
|
||||
|
||||
public byte getData()
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
public static ParticleType getFromFriendlyName(String name)
|
||||
{
|
||||
for (ParticleType type : values())
|
||||
{
|
||||
if (type.hasFriendlyData() && type.getFriendlyName().equals(name))
|
||||
return type;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static PacketPlayOutWorldParticles getPacket(String particleName, Location location, float offsetX, float offsetY,
|
||||
float offsetZ, float speed, int count, boolean displayFar)
|
||||
{
|
||||
|
||||
PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleName, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count, displayFar);
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static void PlayParticle(ParticleType type,Location location, float offsetX, float offsetY, float offsetZ,
|
||||
float speed, int count, ViewDist dist, Player... players)
|
||||
{
|
||||
PlayParticle(type.particleName, location, offsetX, offsetY, offsetZ, speed, count, dist, players);
|
||||
}
|
||||
|
||||
public static void PlayParticle(String particle, Location location, float offsetX, float offsetY, float offsetZ,
|
||||
float speed, int count, ViewDist dist, Player... players)
|
||||
{
|
||||
PacketPlayOutWorldParticles packet = getPacket(particle, location, offsetX, offsetY, offsetZ, speed, count, true);
|
||||
|
||||
for (Player player : players)
|
||||
{
|
||||
//Out of range for player
|
||||
if (UtilMath.offset(player.getLocation(), location) > dist.getDist())
|
||||
continue;
|
||||
|
||||
UtilPlayer.sendPacket(player, packet);
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -9,181 +9,237 @@ import org.bukkit.util.Vector;
|
||||
|
||||
public class UtilShapes
|
||||
{
|
||||
private final static BlockFace[] diagonalFaces =
|
||||
{
|
||||
BlockFace.SOUTH_WEST, BlockFace.NORTH_WEST, BlockFace.NORTH_EAST, BlockFace.SOUTH_EAST
|
||||
};
|
||||
private final static BlockFace[] diagonalFaces =
|
||||
{
|
||||
BlockFace.SOUTH_WEST, BlockFace.NORTH_WEST, BlockFace.NORTH_EAST, BlockFace.SOUTH_EAST
|
||||
};
|
||||
|
||||
private final static BlockFace[] radial =
|
||||
{
|
||||
BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST, BlockFace.NORTH,
|
||||
BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST
|
||||
};
|
||||
private final static BlockFace[] radial =
|
||||
{
|
||||
BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST, BlockFace.NORTH,
|
||||
BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST
|
||||
};
|
||||
|
||||
private final static BlockFace[] squareFaces =
|
||||
{
|
||||
BlockFace.SOUTH, BlockFace.WEST, BlockFace.NORTH, BlockFace.EAST
|
||||
};
|
||||
private final static BlockFace[] squareFaces =
|
||||
{
|
||||
BlockFace.SOUTH, BlockFace.WEST, BlockFace.NORTH, BlockFace.EAST
|
||||
};
|
||||
|
||||
public static ArrayList<Location> getCircle(Location loc, double radius, boolean hollow)
|
||||
{
|
||||
return getCircleBlocks(loc, radius, 0, hollow, false);
|
||||
}
|
||||
public static ArrayList<Location> getCircle(Location loc, double radius, boolean hollow)
|
||||
{
|
||||
return getCircleBlocks(loc, radius, 0, hollow, false);
|
||||
}
|
||||
|
||||
public static ArrayList<Location> getSphereBlocks(Location loc, double radius, double height, boolean hollow)
|
||||
{
|
||||
return getCircleBlocks(loc, radius, height, hollow, true);
|
||||
}
|
||||
public static ArrayList<Location> getSphereBlocks(Location loc, double radius, double height, boolean hollow)
|
||||
{
|
||||
return getCircleBlocks(loc, radius, height, hollow, true);
|
||||
}
|
||||
|
||||
private static ArrayList<Location> getCircleBlocks(Location loc, double radius, double height, boolean hollow, boolean sphere)
|
||||
{
|
||||
ArrayList<Location> circleblocks = new ArrayList<Location>();
|
||||
double cx = loc.getBlockX();
|
||||
double cy = loc.getBlockY();
|
||||
double cz = loc.getBlockZ();
|
||||
private static ArrayList<Location> getCircleBlocks(Location loc, double radius, double height, boolean hollow, boolean sphere)
|
||||
{
|
||||
ArrayList<Location> circleblocks = new ArrayList<Location>();
|
||||
double cx = loc.getBlockX();
|
||||
double cy = loc.getBlockY();
|
||||
double cz = loc.getBlockZ();
|
||||
|
||||
for (double y = (sphere ? cy - radius : cy); y < (sphere ? cy + radius : cy + height + 1); y++)
|
||||
{
|
||||
for (double x = cx - radius; x <= cx + radius; x++)
|
||||
{
|
||||
for (double z = cz - radius; z <= cz + radius; z++)
|
||||
{
|
||||
double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z) + (sphere ? (cy - y) * (cy - y) : 0);
|
||||
for (double y = (sphere ? cy - radius : cy); y < (sphere ? cy + radius : cy + height + 1); y++)
|
||||
{
|
||||
for (double x = cx - radius; x <= cx + radius; x++)
|
||||
{
|
||||
for (double z = cz - radius; z <= cz + radius; z++)
|
||||
{
|
||||
double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z) + (sphere ? (cy - y) * (cy - y) : 0);
|
||||
|
||||
if (dist < radius * radius && !(hollow && dist < (radius - 1) * (radius - 1)))
|
||||
{
|
||||
Location l = new Location(loc.getWorld(), x, y, z);
|
||||
circleblocks.add(l);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dist < radius * radius && !(hollow && dist < (radius - 1) * (radius - 1)))
|
||||
{
|
||||
Location l = new Location(loc.getWorld(), x, y, z);
|
||||
circleblocks.add(l);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return circleblocks;
|
||||
}
|
||||
return circleblocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the block at the exact corners, will return a diagonal.
|
||||
*
|
||||
* @Yeah ik this code sucks.
|
||||
*/
|
||||
public static BlockFace[] getCornerBlockFaces(Block b, BlockFace facing)
|
||||
{
|
||||
BlockFace left = null;
|
||||
BlockFace right = null;
|
||||
for (int i = 0; i < radial.length; i++)
|
||||
{
|
||||
if (radial[i] == facing)
|
||||
{
|
||||
int high = i + 2;
|
||||
if (high >= radial.length)
|
||||
high = high - radial.length;
|
||||
int low = i - 2;
|
||||
if (low < 0)
|
||||
low = radial.length + low;
|
||||
left = radial[low];
|
||||
right = radial[high];
|
||||
return new BlockFace[]
|
||||
{
|
||||
left, right
|
||||
};
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Gets the block at the exact corners, will return a diagonal.
|
||||
*
|
||||
* @Yeah ik this code sucks.
|
||||
*/
|
||||
public static BlockFace[] getCornerBlockFaces(Block b, BlockFace facing)
|
||||
{
|
||||
BlockFace left = null;
|
||||
BlockFace right = null;
|
||||
for (int i = 0; i < radial.length; i++)
|
||||
{
|
||||
if (radial[i] == facing)
|
||||
{
|
||||
int high = i + 2;
|
||||
if (high >= radial.length)
|
||||
high = high - radial.length;
|
||||
int low = i - 2;
|
||||
if (low < 0)
|
||||
low = radial.length + low;
|
||||
left = radial[low];
|
||||
right = radial[high];
|
||||
return new BlockFace[]
|
||||
{
|
||||
left, right
|
||||
};
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Block[] getCornerBlocks(Block b, BlockFace facing)
|
||||
{
|
||||
BlockFace[] faces = getSideBlockFaces(b, facing);
|
||||
return new Block[]
|
||||
{
|
||||
b.getRelative(faces[0]), b.getRelative(faces[1])
|
||||
};
|
||||
}
|
||||
public static Block[] getCornerBlocks(Block b, BlockFace facing)
|
||||
{
|
||||
BlockFace[] faces = getSideBlockFaces(facing);
|
||||
return new Block[]
|
||||
{
|
||||
b.getRelative(faces[0]), b.getRelative(faces[1])
|
||||
};
|
||||
}
|
||||
|
||||
public static BlockFace getFacing(float yaw)
|
||||
{
|
||||
return radial[Math.round(yaw / 45f) & 0x7];
|
||||
}
|
||||
public static BlockFace getFacing(float yaw)
|
||||
{
|
||||
return radial[Math.round(yaw / 45f) & 0x7];
|
||||
}
|
||||
|
||||
public static ArrayList<Location> getLinesDistancedPoints(Location startingPoint, Location endingPoint,
|
||||
double distanceBetweenParticles)
|
||||
{
|
||||
return getLinesLimitedPoints(startingPoint, endingPoint,
|
||||
(int) Math.ceil(startingPoint.distance(endingPoint) / distanceBetweenParticles));
|
||||
}
|
||||
public static ArrayList<Location> getLinesDistancedPoints(Location startingPoint, Location endingPoint,
|
||||
double distanceBetweenParticles)
|
||||
{
|
||||
return getLinesLimitedPoints(startingPoint, endingPoint,
|
||||
(int) Math.ceil(startingPoint.distance(endingPoint) / distanceBetweenParticles));
|
||||
}
|
||||
|
||||
public static ArrayList<Location> getLinesLimitedPoints(Location startingPoint, Location endingPoint, int amountOfPoints)
|
||||
{
|
||||
startingPoint = startingPoint.clone();
|
||||
Vector vector = endingPoint.toVector().subtract(startingPoint.toVector());
|
||||
vector.normalize();
|
||||
vector.multiply(startingPoint.distance(endingPoint) / (amountOfPoints + 1D));
|
||||
public static ArrayList<Location> getLinesLimitedPoints(Location startingPoint, Location endingPoint, int amountOfPoints)
|
||||
{
|
||||
startingPoint = startingPoint.clone();
|
||||
Vector vector = endingPoint.toVector().subtract(startingPoint.toVector());
|
||||
vector.normalize();
|
||||
vector.multiply(startingPoint.distance(endingPoint) / (amountOfPoints + 1D));
|
||||
|
||||
ArrayList<Location> locs = new ArrayList<Location>();
|
||||
for (int i = 0; i < amountOfPoints; i++)
|
||||
{
|
||||
locs.add(startingPoint.add(vector).clone());
|
||||
}
|
||||
return locs;
|
||||
}
|
||||
ArrayList<Location> locs = new ArrayList<Location>();
|
||||
for (int i = 0; i < amountOfPoints; i++)
|
||||
{
|
||||
locs.add(startingPoint.add(vector).clone());
|
||||
}
|
||||
return locs;
|
||||
}
|
||||
|
||||
public static ArrayList<Location> getPointsInCircle(Location center, int pointsAmount, double circleRadius)
|
||||
{
|
||||
ArrayList<Location> locs = new ArrayList<Location>();
|
||||
public static ArrayList<Location> getPointsInCircle(Location center, int pointsAmount, double circleRadius)
|
||||
{
|
||||
ArrayList<Location> locs = new ArrayList<Location>();
|
||||
|
||||
for (int i = 0; i < pointsAmount; i++)
|
||||
{
|
||||
double angle = ((2 * Math.PI) / pointsAmount) * i;
|
||||
double x = circleRadius * Math.cos(angle);
|
||||
double z = circleRadius * Math.sin(angle);
|
||||
Location loc = center.clone().add(x, 0, z);
|
||||
locs.add(loc);
|
||||
}
|
||||
return locs;
|
||||
}
|
||||
for (int i = 0; i < pointsAmount; i++)
|
||||
{
|
||||
double angle = ((2 * Math.PI) / pointsAmount) * i;
|
||||
double x = circleRadius * Math.cos(angle);
|
||||
double z = circleRadius * Math.sin(angle);
|
||||
Location loc = center.clone().add(x, 0, z);
|
||||
locs.add(loc);
|
||||
}
|
||||
return locs;
|
||||
}
|
||||
|
||||
public static ArrayList<Location> getDistancedCircle(Location center, double pointsDistance, double circleRadius)
|
||||
{
|
||||
return getPointsInCircle(center, (int) ((circleRadius * Math.PI * 2) / pointsDistance), circleRadius);
|
||||
}
|
||||
public static ArrayList<Location> getDistancedCircle(Location center, double pointsDistance, double circleRadius)
|
||||
{
|
||||
return getPointsInCircle(center, (int) ((circleRadius * Math.PI * 2) / pointsDistance), circleRadius);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a north/west/east/south block, never a diagonal.
|
||||
*/
|
||||
public static BlockFace[] getSideBlockFaces(Block b, BlockFace facing)
|
||||
{
|
||||
BlockFace left = null;
|
||||
BlockFace right = null;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
int modifierUp = (diagonalFaces[i] == facing ? 2 : squareFaces[i] == facing ? 1 : 0);
|
||||
if (modifierUp != 0)
|
||||
{
|
||||
int high = i + modifierUp;
|
||||
if (high >= squareFaces.length)
|
||||
high = high - squareFaces.length;
|
||||
int low = i - 1;
|
||||
if (low < 0)
|
||||
low = squareFaces.length + low;
|
||||
left = squareFaces[low];
|
||||
right = squareFaces[high];
|
||||
return new BlockFace[]
|
||||
{
|
||||
left, right
|
||||
};
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Returns a north/west/east/south block, never a diagonal.
|
||||
*/
|
||||
public static BlockFace[] getSideBlockFaces(BlockFace facing)
|
||||
{
|
||||
return getSideBlockFaces(facing, true);
|
||||
}
|
||||
|
||||
public static Block[] getSideBlocks(Block b, BlockFace facing)
|
||||
{
|
||||
BlockFace[] faces = getSideBlockFaces(b, facing);
|
||||
return new Block[]
|
||||
{
|
||||
b.getRelative(faces[0]), b.getRelative(faces[1])
|
||||
};
|
||||
}
|
||||
public static BlockFace[] getSideBlockFaces(BlockFace facing, boolean allowDiagonal)
|
||||
{
|
||||
|
||||
int[][] facesXZ;
|
||||
allowDiagonal = !allowDiagonal && (facing.getModX() != 0 && facing.getModZ() != 0);
|
||||
|
||||
facesXZ = new int[][]
|
||||
{
|
||||
|
||||
new int[]
|
||||
{
|
||||
allowDiagonal ? facing.getModX() : facing.getModZ(), allowDiagonal ? 0 : -facing.getModX()
|
||||
},
|
||||
|
||||
new int[]
|
||||
{
|
||||
allowDiagonal ? 0 : -facing.getModZ(), allowDiagonal ? facing.getModZ() : facing.getModX()
|
||||
}
|
||||
};
|
||||
|
||||
BlockFace[] faces = new BlockFace[2];
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
int[] f = facesXZ[i];
|
||||
|
||||
for (BlockFace face : BlockFace.values())
|
||||
{
|
||||
if (face.getModY() == 0)
|
||||
{
|
||||
if (f[0] == face.getModX() && f[1] == face.getModZ())
|
||||
{
|
||||
faces[i] = face;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (allowDiagonal && (facing == BlockFace.NORTH_EAST || facing == BlockFace.SOUTH_WEST))
|
||||
{
|
||||
faces = new BlockFace[]
|
||||
{
|
||||
faces[1], faces[0]
|
||||
};
|
||||
}
|
||||
|
||||
return faces;
|
||||
}
|
||||
|
||||
public static ArrayList<Block> getDiagonalBlocks(Block block, BlockFace facing, int blockWidth)
|
||||
{
|
||||
ArrayList<Block> blocks = new ArrayList<Block>();
|
||||
|
||||
if (facing.getModX() == 0 || facing.getModZ() == 0)
|
||||
{
|
||||
return blocks;
|
||||
}
|
||||
|
||||
BlockFace[] faces = getSideBlockFaces(facing);
|
||||
|
||||
for (BlockFace face : faces)
|
||||
{
|
||||
Location loc = block.getLocation().add(0.5 + (facing.getModX() / 2D), 0, 0.5 + (facing.getModZ() / 2D));
|
||||
|
||||
blocks.add(loc.add(face.getModX() / 2D, 0, face.getModZ() / 2D).getBlock());
|
||||
|
||||
for (int i = 1; i < blockWidth; i++)
|
||||
{
|
||||
blocks.add(loc.add(face.getModX(), 0, face.getModZ()).getBlock());
|
||||
}
|
||||
}
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
public static Block[] getSideBlocks(Block b, BlockFace facing)
|
||||
{
|
||||
BlockFace[] faces = getSideBlockFaces(facing);
|
||||
|
||||
return new Block[]
|
||||
{
|
||||
b.getRelative(faces[0]), b.getRelative(faces[1])
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,82 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
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)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
else if (entity instanceof Creeper)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
else
|
||||
return 3;
|
||||
}
|
||||
|
||||
public static boolean isPlayerHead(byte data)
|
||||
{
|
||||
return data == 3;
|
||||
}
|
||||
|
||||
public static String getPlayerHeadName(Entity entity)
|
||||
{
|
||||
String name = "MHF_Alex";
|
||||
|
||||
// order is important for some of these
|
||||
if (entity instanceof Blaze)
|
||||
name = "MHF_Blaze";
|
||||
else if (entity instanceof CaveSpider)
|
||||
name = "MHF_CaveSpider";
|
||||
else if (entity instanceof Spider)
|
||||
name = "MHF_Spider";
|
||||
else if (entity instanceof Chicken)
|
||||
name = "MHF_Chicken";
|
||||
else if (entity instanceof MushroomCow)
|
||||
name = "MHF_MushroomCow";
|
||||
else if (entity instanceof Cow)
|
||||
name = "MHF_Cow";
|
||||
else if (entity instanceof Creeper)
|
||||
name = "MHF_Creeper";
|
||||
else if (entity instanceof Enderman)
|
||||
name = "MHF_Enderman";
|
||||
else if (entity instanceof Ghast)
|
||||
name = "MHF_Ghast";
|
||||
else if (entity instanceof Golem)
|
||||
name = "MHF_Golem";
|
||||
else if (entity instanceof PigZombie)
|
||||
name = "MHF_PigZombie";
|
||||
else if (entity instanceof MagmaCube)
|
||||
name = "MHF_LavaSlime";
|
||||
else if (entity instanceof Slime)
|
||||
name = "MHF_Slime";
|
||||
else if (entity instanceof Ocelot)
|
||||
name = "MHF_Ocelot";
|
||||
else if (entity instanceof PigZombie)
|
||||
name = "MHF_PigZombie";
|
||||
else if (entity instanceof Pig)
|
||||
name = "MHF_Pig";
|
||||
else if (entity instanceof Sheep)
|
||||
name = "MHF_Pig";
|
||||
else if (entity instanceof Squid)
|
||||
name = "MHF_Squid";
|
||||
else if (entity instanceof HumanEntity)
|
||||
name = "MHF_Steve";
|
||||
else if (entity instanceof Villager)
|
||||
name = "MHF_Villager";
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class UtilText
|
||||
{
|
||||
public static <T> String listToString(Collection<T> inputList, boolean comma)
|
||||
{
|
||||
String out = "";
|
||||
|
||||
for (T cur : inputList)
|
||||
{
|
||||
out += cur.toString() + (comma ? ", " : " ");
|
||||
}
|
||||
|
||||
if (out.length() > 0)
|
||||
{
|
||||
out = out.substring(0, out.length()-(comma ? 2 : 1));
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
@ -46,7 +46,7 @@ public class UtilTextBottom
|
||||
amount = 1 - amount;
|
||||
|
||||
//Generate Bar
|
||||
int bars = 52;
|
||||
int bars = 24;
|
||||
String progressBar = C.cGreen + "";
|
||||
boolean colorChange = false;
|
||||
for (int i=0 ; i<bars ; i++)
|
||||
@ -57,7 +57,7 @@ public class UtilTextBottom
|
||||
colorChange = true;
|
||||
}
|
||||
|
||||
progressBar += "|";
|
||||
progressBar += "▌";
|
||||
}
|
||||
|
||||
//Send to Player
|
||||
|
@ -90,8 +90,8 @@ public class UtilTime
|
||||
if (type == TimeUnit.DAYS) text = (num = UtilMath.trim(trim, time / 86400000d)) + " Day";
|
||||
else if (type == TimeUnit.HOURS) text = (num = UtilMath.trim(trim, time / 3600000d)) + " Hour";
|
||||
else if (type == TimeUnit.MINUTES) text = (num = UtilMath.trim(trim, time / 60000d)) + " Minute";
|
||||
else if (type == TimeUnit.SECONDS) text = (num = (int) UtilMath.trim(trim, time / 1000d)) + " Second";
|
||||
else text = (num = (int) UtilMath.trim(trim, time)) + " Millisecond";
|
||||
else if (type == TimeUnit.SECONDS) text = (int) (num = (int) UtilMath.trim(trim, time / 1000d)) + " Second";
|
||||
else text = (int) (num = (int) UtilMath.trim(trim, time)) + " Millisecond";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -22,4 +22,9 @@ public abstract class MiniDbClientPlugin<DataType extends Object> extends MiniCl
|
||||
}
|
||||
|
||||
public abstract void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException;
|
||||
|
||||
public CoreClientManager getClientManager()
|
||||
{
|
||||
return ClientManager;
|
||||
}
|
||||
}
|
||||
|
@ -16,12 +16,10 @@ import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
public abstract class MiniPlugin implements Listener
|
||||
{
|
||||
protected String _moduleName = "Default";
|
||||
|
||||
protected JavaPlugin _plugin;
|
||||
|
||||
protected NautHashMap<String, ICommand> _commands;
|
||||
|
||||
public MiniPlugin(String moduleName, JavaPlugin plugin)
|
||||
public MiniPlugin(String moduleName, JavaPlugin plugin)
|
||||
{
|
||||
_moduleName = moduleName;
|
||||
_plugin = plugin;
|
||||
|
@ -0,0 +1,33 @@
|
||||
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();
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class CoreClient
|
||||
{
|
||||
private int _accountId;
|
||||
private int _accountId = -1;
|
||||
private String _name;
|
||||
private Player _player;
|
||||
private Rank _rank;
|
||||
@ -37,7 +37,7 @@ public class CoreClient
|
||||
_player = player;
|
||||
}
|
||||
|
||||
public int GetAccountId()
|
||||
public int getAccountId()
|
||||
{
|
||||
return _accountId;
|
||||
}
|
||||
@ -48,7 +48,7 @@ public class CoreClient
|
||||
_player = null;
|
||||
}
|
||||
|
||||
public void SetAccountId(int accountId)
|
||||
public void setAccountId(int accountId)
|
||||
{
|
||||
_accountId = accountId;
|
||||
}
|
||||
|
@ -21,6 +21,10 @@ 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 org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -43,6 +47,7 @@ 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>();
|
||||
|
||||
@ -59,6 +64,9 @@ 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()
|
||||
@ -155,7 +163,7 @@ public class CoreClientManager extends MiniPlugin
|
||||
catch(Exception exception)
|
||||
{
|
||||
event.disallow(Result.KICK_OTHER, "Error retrieving information from web, please retry in a minute.");
|
||||
System.out.println(exception.getMessage());
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -189,34 +197,45 @@ public class CoreClientManager extends MiniPlugin
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
ClientToken token = null;
|
||||
Gson gson = new Gson();
|
||||
|
||||
// Fails if not in DB and if duplicate.
|
||||
UUID uuid = loadUUIDFromDB(playerName);
|
||||
|
||||
if (uuid == null)
|
||||
uuid = UUIDFetcher.getUUIDOf(playerName);
|
||||
|
||||
String response = _repository.getClientByUUID(uuid);
|
||||
token = gson.fromJson(response, ClientToken.class);
|
||||
|
||||
client.SetAccountId(token.AccountId);
|
||||
client.SetRank(Rank.valueOf(token.Rank));
|
||||
|
||||
_repository.login(_loginProcessors, uuid.toString(), client.GetPlayerName());
|
||||
|
||||
// JSON sql response
|
||||
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable()
|
||||
try
|
||||
{
|
||||
public void run()
|
||||
ClientToken token = null;
|
||||
Gson gson = new Gson();
|
||||
|
||||
// Fails if not in DB and if duplicate.
|
||||
UUID uuid = loadUUIDFromDB(playerName);
|
||||
|
||||
if (uuid == null)
|
||||
uuid = UUIDFetcher.getUUIDOf(playerName);
|
||||
|
||||
String response = _repository.getClientByUUID(uuid);
|
||||
token = gson.fromJson(response, ClientToken.class);
|
||||
|
||||
client.SetRank(Rank.valueOf(token.Rank));
|
||||
|
||||
client.setAccountId(_repository.login(_loginProcessors, uuid.toString(), client.GetPlayerName()));
|
||||
|
||||
// JSON sql response
|
||||
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
|
||||
|
||||
if (client.getAccountId() > 0)
|
||||
_accountCacheRepository.addElement(new AccountCache(uuid, client.getAccountId()));
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable()
|
||||
{
|
||||
if (runnable != null)
|
||||
runnable.run();
|
||||
}
|
||||
});
|
||||
public void run()
|
||||
{
|
||||
if (runnable != null)
|
||||
runnable.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -234,7 +253,7 @@ public class CoreClientManager extends MiniPlugin
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_repository.login(_loginProcessors, uuid.toString(), client.GetPlayerName());
|
||||
client.setAccountId(_repository.login(_loginProcessors, uuid.toString(), client.GetPlayerName()));
|
||||
_clientLoginLock.remove(client.GetPlayerName());
|
||||
}
|
||||
});
|
||||
@ -244,8 +263,7 @@ public class CoreClientManager extends MiniPlugin
|
||||
TimingManager.stop(client.GetPlayerName() + " GetClient.");
|
||||
|
||||
token = gson.fromJson(response, ClientToken.class);
|
||||
|
||||
client.SetAccountId(token.AccountId);
|
||||
|
||||
client.SetRank(Rank.valueOf(token.Rank));
|
||||
|
||||
// _repository.updateMysqlRank(uuid.toString(), token.Rank, token.RankPerm, new Timestamp(Date.parse(token.RankExpire)).toString());
|
||||
@ -272,6 +290,11 @@ 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)
|
||||
_accountCacheRepository.addElement(new AccountCache(uuid, client.getAccountId()));
|
||||
|
||||
return !_clientLoginLock.containsKey(client.GetPlayerName());
|
||||
}
|
||||
|
||||
@ -473,4 +496,9 @@ public class CoreClientManager extends MiniPlugin
|
||||
|
||||
return client.GetRank().Has(rank);
|
||||
}
|
||||
|
||||
public int getCachedClientAccountId(UUID uuid)
|
||||
{
|
||||
return _accountCacheRepository.getElement(uuid.toString()).getId();
|
||||
}
|
||||
}
|
@ -9,5 +9,5 @@ public interface ILoginProcessor
|
||||
|
||||
void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException;
|
||||
|
||||
String getQuery(String uuid, String name);
|
||||
String getQuery(int accountId, String uuid, String name);
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class UpdateRank extends CommandBase<CoreClientManager>
|
||||
|
||||
final Rank rank = tempRank;
|
||||
|
||||
if ((rank == Rank.YOUTUBE && Plugin.Get(caller).GetRank().Has(Rank.OWNER)) || rank == Rank.MODERATOR || rank == Rank.HELPER || rank == Rank.ALL || rank == Rank.MAPDEV || rank == Rank.SNR_MODERATOR)
|
||||
if (rank == Rank.YOUTUBE || rank == Rank.MODERATOR || rank == Rank.HELPER || rank == Rank.ALL || rank == Rank.MAPDEV || rank == Rank.SNR_MODERATOR)
|
||||
{
|
||||
Plugin.getRepository().matchPlayerName(new Callback<List<String>>()
|
||||
{
|
||||
|
@ -19,7 +19,6 @@ import mineplex.core.account.repository.token.RankUpdateToken;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UUIDFetcher;
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.DatabaseRunnable;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
@ -32,7 +31,7 @@ import mineplex.core.server.remotecall.JsonWebCall;
|
||||
public class AccountRepository extends RepositoryBase
|
||||
{
|
||||
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accounts (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(100), name VARCHAR(40), gems INT, rank VARCHAR(40), rankPerm BOOL, rankExpire LONG, lastLogin LONG, totalPlayTime LONG, PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuid), UNIQUE INDEX nameIndex (name), INDEX rankIndex (rank));";
|
||||
private static String ACCOUNT_LOGIN_NEW = "INSERT INTO accounts (uuid, name, lastLogin) values(?, ?, now()) ON DUPLICATE KEY UPDATE name=VALUES(name), lastLogin=VALUES(lastLogin);";
|
||||
private static String ACCOUNT_LOGIN_NEW = "INSERT INTO accounts (uuid, name, lastLogin) values(?, ?, now());";
|
||||
private static String UPDATE_ACCOUNT_RANK = "UPDATE accounts SET rank=?, rankPerm=false, rankExpire=now() + INTERVAL 1 MONTH WHERE uuid = ?;";
|
||||
private static String UPDATE_ACCOUNT_RANK_DONOR = "UPDATE accounts SET rank=?, donorRank=?, rankPerm=false, rankExpire=now() + INTERVAL 1 MONTH WHERE uuid = ?;";
|
||||
private static String UPDATE_ACCOUNT_RANK_PERM = "UPDATE accounts SET rank=?, rankPerm=true WHERE uuid = ?;";
|
||||
@ -56,13 +55,41 @@ public class AccountRepository extends RepositoryBase
|
||||
//executeUpdate(CREATE_ACCOUNT_TABLE);
|
||||
}
|
||||
|
||||
public void login(NautHashMap<String, ILoginProcessor> loginProcessors, String uuid, String name)
|
||||
public int login(NautHashMap<String, ILoginProcessor> loginProcessors, String uuid, String name)
|
||||
{
|
||||
int accountId = -1;
|
||||
try (
|
||||
Connection connection = getConnection();
|
||||
Statement statement = connection.createStatement()
|
||||
)
|
||||
{
|
||||
statement.execute("SELECT id FROM accounts WHERE accounts.uuid = '" + uuid + "' LIMIT 1;");
|
||||
ResultSet resultSet = statement.getResultSet();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
accountId = resultSet.getInt(1);
|
||||
}
|
||||
|
||||
if (accountId == -1)
|
||||
{
|
||||
final List<Integer> tempList = new ArrayList<Integer>(1);
|
||||
|
||||
executeInsert(ACCOUNT_LOGIN_NEW, new ResultSetCallable()
|
||||
{
|
||||
@Override
|
||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||
{
|
||||
while (resultSet.next())
|
||||
{
|
||||
tempList.add(resultSet.getInt(1));
|
||||
}
|
||||
}
|
||||
},new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("name", 100, name));
|
||||
|
||||
accountId = tempList.get(0);
|
||||
}
|
||||
|
||||
/*
|
||||
boolean statementStatus = statement.execute(
|
||||
"UPDATE accounts SET name='" + name + "', lastLogin=now() WHERE accounts.uuid = '" + uuid + "';"
|
||||
@ -75,10 +102,11 @@ public class AccountRepository extends RepositoryBase
|
||||
);
|
||||
*/
|
||||
|
||||
String loginString = "UPDATE accounts SET name='" + name + "', lastLogin=now() WHERE accounts.uuid = '" + uuid + "';";
|
||||
String loginString = "UPDATE accounts SET name='" + name + "', lastLogin=now() WHERE id = '" + accountId + "';";
|
||||
|
||||
for (ILoginProcessor loginProcessor : loginProcessors.values())
|
||||
{
|
||||
loginString += loginProcessor.getQuery(uuid, name);
|
||||
loginString += loginProcessor.getQuery(accountId, uuid, name);
|
||||
}
|
||||
|
||||
statement.execute(loginString);
|
||||
@ -108,25 +136,22 @@ public class AccountRepository extends RepositoryBase
|
||||
|
||||
System.out.println("Done");
|
||||
*/
|
||||
|
||||
boolean accountExists = statement.getUpdateCount() != 0;
|
||||
|
||||
statement.getUpdateCount();
|
||||
statement.getMoreResults();
|
||||
|
||||
for (ILoginProcessor loginProcessor : loginProcessors.values())
|
||||
{
|
||||
loginProcessor.processLoginResultSet(name, statement.getResultSet());
|
||||
statement.getMoreResults();
|
||||
}
|
||||
|
||||
if (!accountExists)
|
||||
{
|
||||
executeUpdate(ACCOUNT_LOGIN_NEW, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("name", 100, name));
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public String GetClient(String name, UUID uuid, String ipAddress)
|
||||
@ -160,10 +185,10 @@ public class AccountRepository extends RepositoryBase
|
||||
}
|
||||
}, new ColumnVarChar("name", 100, name));
|
||||
|
||||
if (uuids.size() > 1)
|
||||
return null;
|
||||
if (uuids.size() > 0)
|
||||
return uuids.get(uuids.size() - 1);
|
||||
else
|
||||
return uuids.size() == 1 ? uuids.get(0) : null;
|
||||
return null;
|
||||
}
|
||||
|
||||
public void saveRank(final Callback<Rank> callback, final String name, final UUID uuid, final Rank rank, final boolean perm)
|
||||
|
@ -84,12 +84,19 @@ public enum Achievement
|
||||
new int[]{1},
|
||||
AchievementCategory.SURVIVAL_GAMES),
|
||||
|
||||
//Survival Games
|
||||
//UHC
|
||||
UHC_WINS("Ultimate Winner", 600,
|
||||
new String[]{"Ultra Hardcore.Wins"},
|
||||
new String[]{"Win 10 games of Ultra Hardcore"},
|
||||
new int[]{10},
|
||||
AchievementCategory.UHC),
|
||||
|
||||
//UHC
|
||||
WIZARDS_WINS("Supreme Wizard", 600,
|
||||
new String[]{"Wizards.Wins"},
|
||||
new String[]{"Win 50 games of Wizards"},
|
||||
new int[]{10},
|
||||
AchievementCategory.WIZARDS),
|
||||
|
||||
//Smash Mobs
|
||||
SMASH_MOBS_WINS("SO SUPER!", 600,
|
||||
|
@ -34,6 +34,16 @@ public enum AchievementCategory
|
||||
new String[] { "Wins", "Losses", "Kills", "Deaths", "Gems Earned" },
|
||||
Material.IRON_SWORD, 0, GameCategory.SURVIVAL, "Horseman Kit"),
|
||||
|
||||
UHC("Ultra Hardcore", null,
|
||||
new String[] { "Wins", "Losses", "Kills", "Deaths", "GemsEarned" },
|
||||
new String[] { "Wins", "Losses", "Kills", "Deaths", "Gems Earned" },
|
||||
Material.GOLD_INGOT, 0, GameCategory.SURVIVAL, "Extra Class Skills"),
|
||||
|
||||
WIZARDS("Wizards", null,
|
||||
new String[] { "Wins", "Losses", "Kills", "Deaths", "GemsEarned" },
|
||||
new String[] { "Wins", "Losses", "Kills", "Deaths", "Gems Earned" },
|
||||
Material.GOLD_INGOT, 0, GameCategory.SURVIVAL, "Extra Class Skills"),
|
||||
|
||||
MINE_STRIKE("MineStrike", null,
|
||||
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"},
|
||||
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
|
||||
@ -66,10 +76,7 @@ public enum AchievementCategory
|
||||
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
|
||||
Material.BEACON, 0, GameCategory.CHAMPIONS, "Extra Class Skills"),
|
||||
|
||||
UHC("Ultra Hardcore", null,
|
||||
new String[] { "Wins", "Losses", "Kills", "Deaths", "GemsEarned" },
|
||||
new String[] { "Wins", "Losses", "Kills", "Deaths", "Gems Earned" },
|
||||
Material.GOLD_INGOT, 0, GameCategory.SURVIVAL, "Extra Class Skills"),
|
||||
|
||||
|
||||
//Arcade
|
||||
DRAGONS("Dragons", null,
|
||||
|
@ -34,6 +34,8 @@ public class AchievementManager extends MiniPlugin
|
||||
private boolean _giveInterfaceItem = false;
|
||||
|
||||
private NautHashMap<String, NautHashMap<Achievement, AchievementLog>> _log = new NautHashMap<String, NautHashMap<Achievement, AchievementLog>>();
|
||||
|
||||
private boolean _shopEnabled = true;
|
||||
|
||||
public AchievementManager(StatsManager statsManager, CoreClientManager clientManager, DonationManager donationManager)
|
||||
{
|
||||
@ -177,6 +179,9 @@ public class AchievementManager extends MiniPlugin
|
||||
@EventHandler
|
||||
public void openShop(PlayerInteractEvent event)
|
||||
{
|
||||
if (!_shopEnabled)
|
||||
return;
|
||||
|
||||
if (event.hasItem() && event.getItem().getType() == Material.SKULL_ITEM)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
@ -209,10 +214,17 @@ public class AchievementManager extends MiniPlugin
|
||||
level = Math.max(level, 50 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
|
||||
else if (rank.Has(Rank.ADMIN))
|
||||
level = Math.max(level, 30 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
|
||||
else if (rank.Has(Rank.SNR_MODERATOR))
|
||||
level = Math.max(level, 15);
|
||||
else if (rank.Has(Rank.MODERATOR))
|
||||
level = Math.max(level, 5);
|
||||
|
||||
|
||||
return Achievement.getExperienceString(level) + " " + ChatColor.RESET;
|
||||
}
|
||||
|
||||
public void setShopEnabled(boolean var)
|
||||
{
|
||||
_shopEnabled = var;
|
||||
}
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ public class AntiHack extends MiniPlugin
|
||||
if (player.equals(other))
|
||||
continue;
|
||||
|
||||
if (other.getGameMode() != GameMode.SURVIVAL)
|
||||
if (other.getGameMode() != GameMode.SURVIVAL || UtilPlayer.isSpectator(player))
|
||||
continue;
|
||||
|
||||
if (other.getVehicle() != null)
|
||||
@ -202,7 +202,7 @@ public class AntiHack extends MiniPlugin
|
||||
return true;
|
||||
}
|
||||
|
||||
if (player.isFlying() || player.isInsideVehicle() || player.getGameMode() != GameMode.SURVIVAL)
|
||||
if (player.isFlying() || player.isInsideVehicle() || player.getGameMode() != GameMode.SURVIVAL || UtilPlayer.isSpectator(player))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.antihack.Detector;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
@ -29,7 +30,7 @@ public class Reach extends MiniPlugin implements Detector
|
||||
|
||||
public Reach (AntiHack host)
|
||||
{
|
||||
super("Speed Detector", host.getPlugin());
|
||||
super("Reach Detector", host.getPlugin());
|
||||
Host = host;
|
||||
}
|
||||
|
||||
@ -44,7 +45,7 @@ public class Reach extends MiniPlugin implements Detector
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (player.getGameMode() != GameMode.SURVIVAL)
|
||||
if (player.getGameMode() != GameMode.SURVIVAL || UtilPlayer.isSpectator(player))
|
||||
continue;
|
||||
|
||||
if (!_history.containsKey(player))
|
||||
|
@ -0,0 +1,203 @@
|
||||
package mineplex.core.aprilfools;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.disguise.disguises.DisguiseCow;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class AprilFoolsManager extends MiniPlugin
|
||||
{
|
||||
public static AprilFoolsManager Instance;
|
||||
|
||||
private boolean _enabled;
|
||||
private DisguiseManager _disguiseManager;
|
||||
private CoreClientManager _clientManager;
|
||||
|
||||
protected AprilFoolsManager(JavaPlugin plugin, CoreClientManager clientManager, DisguiseManager disguiseManager)
|
||||
{
|
||||
super("April Fools", plugin);
|
||||
|
||||
_disguiseManager = disguiseManager;
|
||||
_clientManager = clientManager;
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
_enabled = (c.get(Calendar.MONTH) == Calendar.APRIL && c.get(Calendar.DAY_OF_MONTH) == 1);
|
||||
}
|
||||
|
||||
public static void Initialize(JavaPlugin plugin, CoreClientManager clientManager, DisguiseManager disguiseManager)
|
||||
{
|
||||
Instance = new AprilFoolsManager(plugin, clientManager, disguiseManager);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateEnabled(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SLOW)
|
||||
return;
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
_enabled = (c.get(Calendar.MONTH) == Calendar.APRIL && c.get(Calendar.DAY_OF_MONTH) == 1);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void chatAdd(AsyncPlayerChatEvent event)
|
||||
{
|
||||
if (!_enabled)
|
||||
return;
|
||||
|
||||
String[] words = event.getMessage().split(" ");
|
||||
|
||||
String out = "";
|
||||
for (String word : words)
|
||||
{
|
||||
//Prefix
|
||||
if (Math.random() > 0.85)
|
||||
{
|
||||
out += "moo";
|
||||
|
||||
for (int i=0 ; i<UtilMath.r(2) ; i++)
|
||||
out += "o";
|
||||
|
||||
out += " " + word + " ";
|
||||
|
||||
}
|
||||
|
||||
//Suffix
|
||||
else if (Math.random() > 0.85)
|
||||
{
|
||||
out += word + " ";
|
||||
|
||||
out += "moo";
|
||||
|
||||
for (int i=0 ; i<UtilMath.r(2) ; i++)
|
||||
out += "o";
|
||||
|
||||
out += " ";
|
||||
}
|
||||
|
||||
//Swap
|
||||
else if (Math.random() > 0.99)
|
||||
{
|
||||
out += "moo";
|
||||
|
||||
for (int i=3 ; i<word.length() ; i++)
|
||||
out += "o";
|
||||
|
||||
out += " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
out += word + " ";
|
||||
}
|
||||
}
|
||||
|
||||
event.setMessage(out);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateText(UpdateEvent event)
|
||||
{
|
||||
if (!_enabled)
|
||||
return;
|
||||
|
||||
if (event.getType() != UpdateType.SLOW)
|
||||
return;
|
||||
|
||||
if (Math.random() <= 0.99)
|
||||
return;
|
||||
|
||||
UtilTextMiddle.display("Moo", null, 5, 20, 5);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateCow(UpdateEvent event)
|
||||
{
|
||||
if (!_enabled)
|
||||
return;
|
||||
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
//Disguise
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (_disguiseManager.getDisguise(player) != null)
|
||||
{
|
||||
//Moo
|
||||
if (Math.random() > 0.8)
|
||||
{
|
||||
if (_disguiseManager.getDisguise(player) instanceof DisguiseCow)
|
||||
{
|
||||
player.getWorld().playSound(player.getLocation(), Sound.COW_IDLE, (float)Math.random() + 0.5f, (float)Math.random() + 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
//Disguise
|
||||
DisguiseCow disguise = new DisguiseCow(player);
|
||||
disguise.setName(getName(player), _clientManager.Get(player).GetRank());
|
||||
disguise.setCustomNameVisible(true);
|
||||
_disguiseManager.disguise(disguise);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isActive()
|
||||
{
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
public String getName(Player player)
|
||||
{
|
||||
//Name
|
||||
int index = 0;
|
||||
boolean hitVowel = false;
|
||||
for (int i=0 ; i<player.getName().length()-2 && i<5 ; i++)
|
||||
{
|
||||
//Detect vowel ;o
|
||||
if (player.getName().toLowerCase().charAt(i) == 'a' ||
|
||||
player.getName().toLowerCase().charAt(i) == 'e' ||
|
||||
player.getName().toLowerCase().charAt(i) == 'i' ||
|
||||
player.getName().toLowerCase().charAt(i) == 'o' ||
|
||||
player.getName().toLowerCase().charAt(i) == 'u')
|
||||
{
|
||||
hitVowel = true;
|
||||
}
|
||||
//Post vowel consonant - stop here
|
||||
else if (hitVowel)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
index = i+1;
|
||||
}
|
||||
|
||||
String name = "Moo" + player.getName().substring(index, player.getName().length());
|
||||
|
||||
if (name.length() > 16)
|
||||
name = name.substring(0, 16);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean b)
|
||||
{
|
||||
Calendar c = Calendar.getInstance();
|
||||
_enabled = b && (c.get(Calendar.MONTH) == Calendar.APRIL && c.get(Calendar.DAY_OF_MONTH) == 1);
|
||||
}
|
||||
}
|
@ -78,8 +78,8 @@ public class BenefitManager extends MiniDbClientPlugin<BenefitData>
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuery(String uuid, String name)
|
||||
public String getQuery(int accountId, String uuid, String name)
|
||||
{
|
||||
return "SELECT benefit FROM rankBenefits WHERE rankBenefits.uuid = '" + uuid + "';";
|
||||
return "SELECT benefit FROM rankBenefits WHERE rankBenefits.accountId = '" + accountId + "';";
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class BenefitManagerRepository extends RepositoryBase
|
||||
{
|
||||
// private static String CREATE_BENEFIT_TABLE = "CREATE TABLE IF NOT EXISTS rankBenefits (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(100), benefit VARCHAR(100), PRIMARY KEY (id), INDEX rankUuid (uuid));";
|
||||
private static String CREATE_BENEFIT_TABLE = "CREATE TABLE IF NOT EXISTS rankBenefits (id INT NOT NULL AUTO_INCREMENT, accountId INT, benefit VARCHAR(100), PRIMARY KEY (id), INDEX rankUuid (uuid));";
|
||||
|
||||
private static String INSERT_BENEFIT = "INSERT INTO rankBenefits (uuid, benefit) VALUES (?, ?);";
|
||||
|
||||
|
@ -5,7 +5,7 @@ import java.util.HashSet;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
|
||||
@ -57,10 +57,12 @@ public class Blood extends MiniPlugin
|
||||
for (int i = 0 ; i < event.getParticles() ; i++)
|
||||
{
|
||||
Item item = event.getLocation().getWorld().dropItem(event.getLocation(),
|
||||
ItemStackFactory.Instance.CreateStack(event.getMaterial(), event.getMaterialData()));
|
||||
new ItemBuilder(event.getMaterial(), 1, event.getMaterialData()).setTitle("" + System.nanoTime()).build());
|
||||
|
||||
item.setVelocity(new Vector((Math.random() - 0.5)*event.getVelocityMult(),Math.random()*event.getVelocityMult(),(Math.random() - 0.5)*event.getVelocityMult()));
|
||||
|
||||
item.setPickupDelay(999999);
|
||||
|
||||
_blood.put(item, event.getTicks());
|
||||
}
|
||||
|
||||
|
@ -207,82 +207,59 @@ public class Chat extends MiniPlugin
|
||||
|
||||
if (event.isAsynchronous())
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
//final String plyrname = player.toString();
|
||||
final String plyrname = player.getUniqueId().toString();
|
||||
final String msg = event.getMessage().replaceAll("[^\\x00-\\x7F]", "").trim();
|
||||
//final String filtertype = "chat";
|
||||
final String filtertype = "moderate";
|
||||
final String dname = player.getPlayerListName();
|
||||
|
||||
|
||||
JSONObject message = buildJsonChatObject(filtertype, dname, plyrname, msg, _serverName, 1);
|
||||
String response = getResponseFromCleanSpeak(message, filtertype);
|
||||
String filteredMessage = getFilteredMessage(event.getPlayer(), event.getMessage());
|
||||
|
||||
if (response == null)
|
||||
for (Player onlinePlayer : event.getRecipients())
|
||||
{
|
||||
System.out.println("[ERROR] Unable to filter chat message...thanks a lot CleanSpeak.");
|
||||
return;
|
||||
onlinePlayer.sendMessage(String.format(event.getFormat(), event.getPlayer().getDisplayName(), filteredMessage));
|
||||
}
|
||||
|
||||
/* TESTING OUTPUT - POSSIBLY USEFUL
|
||||
System.out.println(message);
|
||||
System.out.println(response);
|
||||
System.out.println(JSONValue.parse(response));
|
||||
//NullPointerException occasionally happening, JSONValue.parse(String) returns null randomly, why?
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public String getFilteredMessage(Player player, String originalMessage)
|
||||
{
|
||||
final String playerName = player.getUniqueId().toString();
|
||||
originalMessage = originalMessage.replaceAll("[^\\x00-\\x7F]", "").trim();
|
||||
final String filterType = "moderate";
|
||||
final String displayName = player.getPlayerListName();
|
||||
|
||||
JSONObject message = buildJsonChatObject(filterType, displayName, playerName, originalMessage, _serverName, 1);
|
||||
String response = getResponseFromCleanSpeak(message, filterType);
|
||||
|
||||
if (response == null)
|
||||
{
|
||||
System.out.println("[ERROR] Unable to filter chat message...thanks a lot CleanSpeak.");
|
||||
return originalMessage;
|
||||
}
|
||||
|
||||
/* TESTING OUTPUT - POSSIBLY USEFUL
|
||||
System.out.println(message);
|
||||
System.out.println(response);
|
||||
System.out.println(JSONValue.parse(response));
|
||||
//NullPointerException occasionally happening, JSONValue.parse(String) returns null randomly, why?
|
||||
|
||||
for (Object o : ((JSONObject)JSONValue.parse(response)).values())
|
||||
{
|
||||
System.out.println(o.toString());
|
||||
}
|
||||
*/
|
||||
|
||||
String filteredMsg = "";
|
||||
|
||||
filteredMsg = ((JSONObject) JSONValue.parse(response)).get("content").toString();
|
||||
if (filteredMsg.contains("parts"))
|
||||
{
|
||||
filteredMsg = ((JSONObject) JSONValue.parse(filteredMsg)).get("parts").toString();
|
||||
filteredMsg = filteredMsg.replace('[', ' ').replace(']', ' ').trim();
|
||||
filteredMsg = ((JSONObject) JSONValue.parse(filteredMsg)).get("replacement").toString();
|
||||
|
||||
for (Object o : ((JSONObject)JSONValue.parse(response)).values())
|
||||
{
|
||||
System.out.println(o.toString());
|
||||
}
|
||||
*/
|
||||
|
||||
String filteredMsg = "";
|
||||
|
||||
filteredMsg = ((JSONObject) JSONValue.parse(response)).get("content").toString();
|
||||
if (filteredMsg.contains("parts"))
|
||||
{
|
||||
filteredMsg = ((JSONObject) JSONValue.parse(filteredMsg)).get("parts").toString();
|
||||
filteredMsg = filteredMsg.replace('[', ' ').replace(']', ' ').trim();
|
||||
filteredMsg = ((JSONObject) JSONValue.parse(filteredMsg)).get("replacement").toString();
|
||||
|
||||
for (Player onlinePlayer : event.getRecipients())
|
||||
{
|
||||
onlinePlayer.sendMessage(String.format(event.getFormat(), event.getPlayer().getDisplayName(), filteredMsg));
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
/*
|
||||
int risk = Integer.parseInt(((JSONObject) JSONValue.parse(response)).get("risk").toString());
|
||||
|
||||
if (risk >= 5)
|
||||
{
|
||||
String filteredMessage = event.getMessage().replaceAll("[^\\x00-\\x7F]", "").trim();
|
||||
|
||||
if (parseHashes(response) == null)
|
||||
event.setMessage(ChatColor.RED + msg);
|
||||
else
|
||||
{
|
||||
JSONArray hashindex = parseHashes(response);
|
||||
String newmessage = hasher(hashindex, msg);
|
||||
String badmessage = (new StringBuilder().append(newmessage)).toString();
|
||||
|
||||
if (newmessage.contains("*"))
|
||||
{
|
||||
filteredMessage = badmessage;
|
||||
}
|
||||
}
|
||||
|
||||
for (Player onlinePlayer : event.getRecipients())
|
||||
{
|
||||
onlinePlayer.sendMessage(String.format(event.getFormat(), event.getPlayer().getDisplayName(), filteredMessage));
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
*/
|
||||
return filteredMsg;
|
||||
}
|
||||
else
|
||||
{
|
||||
return originalMessage;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,15 +154,22 @@ public class CosmeticManager extends MiniPlugin
|
||||
_gadgetManager.setActiveItemSlot(i-1);
|
||||
}
|
||||
|
||||
public void setActive(boolean b)
|
||||
public void setActive(boolean showInterface)
|
||||
{
|
||||
_showInterface = b;
|
||||
|
||||
if (!b)
|
||||
_showInterface = showInterface;
|
||||
|
||||
if (!showInterface)
|
||||
{
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
player.getOpenInventory().close();
|
||||
{
|
||||
if (player.getOpenInventory().getTopInventory().getHolder() != player)
|
||||
{
|
||||
player.closeInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void disableItemsForGame()
|
||||
{
|
||||
_gadgetManager.DisableAll();
|
||||
|
@ -7,9 +7,9 @@ import org.apache.commons.dbcp2.BasicDataSource;
|
||||
|
||||
public final class DBPool
|
||||
{
|
||||
public static final DataSource ACCOUNT = openDataSource("jdbc:mysql://db.mineplex.com/Account", "root", "tAbechAk3wR7tuTh");
|
||||
public static final DataSource QUEUE = openDataSource("jdbc:mysql://db.mineplex.com/Queue", "root", "tAbechAk3wR7tuTh");
|
||||
public static final DataSource MINEPLEX = openDataSource("jdbc:mysql://db.mineplex.com:3306/Mineplex", "root", "tAbechAk3wR7tuTh");
|
||||
public static final DataSource ACCOUNT = openDataSource("jdbc:mysql://db.mineplex.com/Account", "MilitaryPolice", "CUPr6Wuw2Rus$qap");
|
||||
public static final DataSource QUEUE = openDataSource("jdbc:mysql://db.mineplex.com/Queue", "MilitaryPolice", "CUPr6Wuw2Rus$qap");
|
||||
public static final DataSource MINEPLEX = openDataSource("jdbc:mysql://db.mineplex.com:3306/Mineplex", "MilitaryPolice", "CUPr6Wuw2Rus$qap");
|
||||
public static final DataSource STATS_MINEPLEX = openDataSource("jdbc:mysql://sqlstats.mineplex.com:3306/Mineplex", "root", "tAbechAk3wR7tuTh");
|
||||
|
||||
private static DataSource openDataSource(String url, String username, String password)
|
||||
|
@ -116,7 +116,7 @@ public abstract class RepositoryBase implements Listener
|
||||
}
|
||||
catch (SQLException exception)
|
||||
{
|
||||
executeInsert(query, callable, columns);
|
||||
exception.printStackTrace();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -142,7 +142,7 @@ public abstract class RepositoryBase implements Listener
|
||||
}
|
||||
catch (SQLException exception)
|
||||
{
|
||||
executeQuery(statement, callable, columns);
|
||||
exception.printStackTrace();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -162,7 +162,7 @@ public abstract class RepositoryBase implements Listener
|
||||
}
|
||||
catch (SQLException exception)
|
||||
{
|
||||
executeQuery(query, callable, columns);
|
||||
exception.printStackTrace();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,6 @@ package mineplex.core.disguise.disguises;
|
||||
import mineplex.core.common.*;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.DataWatcher;
|
||||
@ -11,8 +10,6 @@ import net.minecraft.server.v1_7_R4.Entity;
|
||||
import net.minecraft.server.v1_7_R4.Packet;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public abstract class DisguiseBase
|
||||
{
|
||||
protected Entity Entity;
|
||||
@ -23,9 +20,13 @@ public abstract class DisguiseBase
|
||||
public boolean Global = true;
|
||||
|
||||
public DisguiseBase(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
Entity = ((CraftEntity)entity).getHandle();
|
||||
DataWatcher = new DataWatcher(new DummyEntity(((CraftWorld)entity.getWorld()).getHandle()));
|
||||
{
|
||||
if (entity != null)
|
||||
{
|
||||
setEntity(entity);
|
||||
}
|
||||
|
||||
DataWatcher = new DataWatcher(new DummyEntity(null));
|
||||
|
||||
DataWatcher.a(0, Byte.valueOf((byte)0));
|
||||
DataWatcher.a(1, Short.valueOf((short)300));
|
||||
@ -33,6 +34,11 @@ public abstract class DisguiseBase
|
||||
_soundDisguise = this;
|
||||
}
|
||||
|
||||
public void setEntity(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
Entity = ((CraftEntity) entity).getHandle();
|
||||
}
|
||||
|
||||
public void UpdateDataWatcher()
|
||||
{
|
||||
DataWatcher.watch(0, Entity.getDataWatcher().getByte(0));
|
||||
@ -64,11 +70,6 @@ public abstract class DisguiseBase
|
||||
{
|
||||
Entity.world.makeSound(location.getX(), location.getY(), location.getZ(), _soundDisguise.getHurtSound(), _soundDisguise.getVolume(), _soundDisguise.getPitch());
|
||||
}
|
||||
|
||||
public void UpdateEntity(Entity entity)
|
||||
{
|
||||
Entity = entity;
|
||||
}
|
||||
|
||||
public Entity GetEntity()
|
||||
{
|
||||
|
@ -72,22 +72,4 @@ public abstract class DisguiseInsentient extends DisguiseLiving
|
||||
{
|
||||
_showArmor = false;
|
||||
}
|
||||
|
||||
public List<Packet> getArmorPackets()
|
||||
{
|
||||
List<PacketPlayOutEntityEquipment> p5 = new ArrayList<PacketPlayOutEntityEquipment>();
|
||||
net.minecraft.server.v1_7_R4.ItemStack[] armorContents = Entity.getEquipment();
|
||||
|
||||
for (short i=0; i < armorContents.length; i++)
|
||||
{
|
||||
net.minecraft.server.v1_7_R4.ItemStack armorSlot = armorContents[i];
|
||||
|
||||
if (armorSlot != null)
|
||||
{
|
||||
p5.add(new PacketPlayOutEntityEquipment(Entity.getId(), i, armorSlot));
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -2,52 +2,76 @@ package mineplex.core.disguise.disguises;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.EntityLiving;
|
||||
|
||||
public abstract class DisguiseLiving extends DisguiseBase
|
||||
{
|
||||
private static Random _random = new Random();
|
||||
|
||||
private boolean _invisible;
|
||||
|
||||
public DisguiseLiving(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(entity);
|
||||
|
||||
|
||||
DataWatcher.a(6, Float.valueOf(1.0F));
|
||||
DataWatcher.a(7, Integer.valueOf(0));
|
||||
DataWatcher.a(8, Byte.valueOf((byte)0));
|
||||
DataWatcher.a(9, Byte.valueOf((byte)0));
|
||||
DataWatcher.a(7, Integer.valueOf(0));
|
||||
DataWatcher.a(8, Byte.valueOf((byte) 0));
|
||||
DataWatcher.a(9, Byte.valueOf((byte) 0));
|
||||
}
|
||||
|
||||
|
||||
public void UpdateDataWatcher()
|
||||
{
|
||||
super.UpdateDataWatcher();
|
||||
byte b0 = DataWatcher.getByte(0);
|
||||
|
||||
DataWatcher.watch(6, Entity.getDataWatcher().getFloat(6));
|
||||
DataWatcher.watch(7, Entity.getDataWatcher().getInt(7));
|
||||
DataWatcher.watch(8, Entity.getDataWatcher().getByte(8));
|
||||
DataWatcher.watch(9, Entity.getDataWatcher().getByte(9));
|
||||
if (_invisible)
|
||||
DataWatcher.watch(0, Byte.valueOf((byte) (b0 | 1 << 5)));
|
||||
else
|
||||
DataWatcher.watch(0, Byte.valueOf((byte) (b0 & ~(1 << 5))));
|
||||
|
||||
if (Entity instanceof EntityLiving)
|
||||
{
|
||||
DataWatcher.watch(6, Entity.getDataWatcher().getFloat(6));
|
||||
DataWatcher.watch(7, Entity.getDataWatcher().getInt(7));
|
||||
DataWatcher.watch(8, Entity.getDataWatcher().getByte(8));
|
||||
DataWatcher.watch(9, Entity.getDataWatcher().getByte(9));
|
||||
}
|
||||
}
|
||||
|
||||
protected String getHurtSound()
|
||||
{
|
||||
return "damage.hit";
|
||||
}
|
||||
|
||||
protected float getVolume()
|
||||
{
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
protected float getPitch()
|
||||
{
|
||||
return (_random.nextFloat() - _random.nextFloat()) * 0.2F + 1.0F;
|
||||
}
|
||||
|
||||
public void setHealth(float health)
|
||||
{
|
||||
DataWatcher.watch(6, Float.valueOf(health));
|
||||
}
|
||||
|
||||
public float getHealth()
|
||||
{
|
||||
return DataWatcher.getFloat(6);
|
||||
}
|
||||
|
||||
public boolean isInvisible()
|
||||
{
|
||||
return _invisible;
|
||||
}
|
||||
|
||||
public void setInvisible(boolean invisible)
|
||||
{
|
||||
_invisible = invisible;
|
||||
}
|
||||
|
||||
protected String getHurtSound()
|
||||
{
|
||||
return "damage.hit";
|
||||
}
|
||||
|
||||
protected float getVolume()
|
||||
{
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
protected float getPitch()
|
||||
{
|
||||
return (_random.nextFloat() - _random.nextFloat()) * 0.2F + 1.0F;
|
||||
}
|
||||
|
||||
public void setHealth(float health)
|
||||
{
|
||||
DataWatcher.watch(6, Float.valueOf(health));
|
||||
}
|
||||
|
||||
public float getHealth()
|
||||
{
|
||||
return DataWatcher.getFloat(6);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -13,6 +17,7 @@ public class DisguisePlayer extends DisguiseHuman
|
||||
{
|
||||
private GameProfile _profile;
|
||||
private boolean _sneaking;
|
||||
private BlockFace _sleeping;
|
||||
|
||||
public DisguisePlayer(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
@ -22,36 +27,54 @@ public class DisguisePlayer extends DisguiseHuman
|
||||
public DisguisePlayer(org.bukkit.entity.Entity entity, GameProfile profile)
|
||||
{
|
||||
this(entity);
|
||||
|
||||
|
||||
setProfile(profile);
|
||||
}
|
||||
|
||||
public void setProfile(GameProfile profile)
|
||||
{
|
||||
_profile = profile;
|
||||
GameProfile newProfile = new GameProfile(UUID.randomUUID(), profile.getName());
|
||||
|
||||
newProfile.getProperties().putAll(profile.getProperties());
|
||||
|
||||
_profile = newProfile;
|
||||
}
|
||||
|
||||
public BlockFace getSleepingDirection()
|
||||
{
|
||||
return _sleeping;
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't use this if the disguise is already on as it will not work the way you want it to. Contact libraryaddict if you need
|
||||
* that added.
|
||||
*/
|
||||
public void setSleeping(BlockFace sleeping)
|
||||
{
|
||||
_sleeping = sleeping;
|
||||
}
|
||||
|
||||
public void setSneaking(boolean sneaking)
|
||||
{
|
||||
_sneaking = sneaking;
|
||||
}
|
||||
|
||||
|
||||
public Packet getOldInfoPacket(boolean add)
|
||||
{
|
||||
PacketPlayOutPlayerInfo playerInfo = new PacketPlayOutPlayerInfo();
|
||||
|
||||
|
||||
if (Entity instanceof Player)
|
||||
{
|
||||
playerInfo.username = Entity.getName();
|
||||
playerInfo.action = add ? 0 : 4;
|
||||
playerInfo.ping = 90;
|
||||
playerInfo.player = ((CraftPlayer)(Player)Entity).getProfile();
|
||||
playerInfo.player = ((CraftPlayer) (Player) Entity).getProfile();
|
||||
playerInfo.gamemode = 0;
|
||||
}
|
||||
|
||||
return playerInfo;
|
||||
}
|
||||
|
||||
|
||||
public Packet getNewInfoPacket(boolean add)
|
||||
{
|
||||
PacketPlayOutPlayerInfo newDisguiseInfo = new PacketPlayOutPlayerInfo();
|
||||
@ -61,37 +84,54 @@ public class DisguisePlayer extends DisguiseHuman
|
||||
newDisguiseInfo.player = _profile;
|
||||
newDisguiseInfo.gamemode = 0;
|
||||
|
||||
|
||||
return newDisguiseInfo;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void UpdateDataWatcher()
|
||||
{
|
||||
super.UpdateDataWatcher();
|
||||
|
||||
|
||||
byte b0 = DataWatcher.getByte(0);
|
||||
|
||||
if (_sneaking)
|
||||
DataWatcher.watch(0, Byte.valueOf((byte) (b0 | 1 << 1)));
|
||||
else
|
||||
DataWatcher.watch(0, Byte.valueOf((byte) (b0 & ~(1 << 1))));
|
||||
if (_sneaking)
|
||||
DataWatcher.watch(0, Byte.valueOf((byte) (b0 | 1 << 1)));
|
||||
else
|
||||
DataWatcher.watch(0, Byte.valueOf((byte) (b0 & ~(1 << 1))));
|
||||
}
|
||||
|
||||
|
||||
public PacketPlayOutNamedEntitySpawn spawnBeforePlayer(Location spawnLocation)
|
||||
{
|
||||
Location loc = spawnLocation.add(spawnLocation.getDirection().normalize().multiply(30));
|
||||
loc.setY(Math.max(loc.getY(), 0));
|
||||
|
||||
PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn();
|
||||
packet.a = Entity.getId();
|
||||
packet.b = _profile;
|
||||
packet.c = MathHelper.floor(loc.getX() * 32.0D);
|
||||
packet.d = MathHelper.floor(loc.getY() * 32.0D);
|
||||
packet.e = MathHelper.floor(loc.getZ() * 32.0D);
|
||||
packet.f = (byte) ((int) (loc.getYaw() * 256.0F / 360.0F));
|
||||
packet.g = (byte) ((int) (loc.getPitch() * 256.0F / 360.0F));
|
||||
packet.i = DataWatcher;
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet GetSpawnPacket()
|
||||
public PacketPlayOutNamedEntitySpawn GetSpawnPacket()
|
||||
{
|
||||
PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn();
|
||||
packet.a = Entity.getId();
|
||||
packet.b = _profile;
|
||||
packet.c = MathHelper.floor(Entity.locX * 32.0D);
|
||||
packet.d = MathHelper.floor(Entity.locY * 32.0D);
|
||||
packet.e = MathHelper.floor(Entity.locZ * 32.0D);
|
||||
packet.f = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
|
||||
packet.g = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
|
||||
packet.a = Entity.getId();
|
||||
packet.b = _profile;
|
||||
packet.c = MathHelper.floor(Entity.locX * 32.0D);
|
||||
packet.d = MathHelper.floor(Entity.locY * 32.0D);
|
||||
packet.e = MathHelper.floor(Entity.locZ * 32.0D);
|
||||
packet.f = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
|
||||
packet.g = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
|
||||
packet.i = DataWatcher;
|
||||
|
||||
return packet;
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
|
@ -0,0 +1,80 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.EnumEntitySize;
|
||||
import net.minecraft.server.v1_7_R4.MathHelper;
|
||||
import net.minecraft.server.v1_7_R4.Packet;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
|
||||
|
||||
public class DisguiseRabbit extends DisguiseInsentient
|
||||
{
|
||||
|
||||
public DisguiseRabbit(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(entity);
|
||||
|
||||
DataWatcher.a(4, Byte.valueOf((byte) 0));
|
||||
|
||||
DataWatcher.a(12, (byte) 0);
|
||||
DataWatcher.a(15, Byte.valueOf((byte) 0));
|
||||
DataWatcher.a(18, Byte.valueOf((byte) 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet GetSpawnPacket()
|
||||
{
|
||||
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
|
||||
packet.a = Entity.getId();
|
||||
packet.b = (byte) 101;
|
||||
packet.c = (int) EnumEntitySize.SIZE_2.a(Entity.locX);
|
||||
packet.d = (int) MathHelper.floor(Entity.locY * 32.0D);
|
||||
packet.e = (int) EnumEntitySize.SIZE_2.a(Entity.locZ);
|
||||
packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
|
||||
packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
|
||||
packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
|
||||
|
||||
double var2 = 3.9D;
|
||||
double var4 = 0;
|
||||
double var6 = 0;
|
||||
double var8 = 0;
|
||||
|
||||
if (var4 < -var2)
|
||||
{
|
||||
var4 = -var2;
|
||||
}
|
||||
|
||||
if (var6 < -var2)
|
||||
{
|
||||
var6 = -var2;
|
||||
}
|
||||
|
||||
if (var8 < -var2)
|
||||
{
|
||||
var8 = -var2;
|
||||
}
|
||||
|
||||
if (var4 > var2)
|
||||
{
|
||||
var4 = var2;
|
||||
}
|
||||
|
||||
if (var6 > var2)
|
||||
{
|
||||
var6 = var2;
|
||||
}
|
||||
|
||||
if (var8 > var2)
|
||||
{
|
||||
var8 = var2;
|
||||
}
|
||||
|
||||
packet.f = (int) (var4 * 8000.0D);
|
||||
packet.g = (int) (var6 * 8000.0D);
|
||||
packet.h = (int) (var8 * 8000.0D);
|
||||
|
||||
packet.l = DataWatcher;
|
||||
packet.m = DataWatcher.b();
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
}
|
@ -4,6 +4,7 @@ import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.Callback;
|
||||
@ -27,34 +28,39 @@ public class CoinCommand extends CommandBase<DonationManager>
|
||||
return;
|
||||
}
|
||||
|
||||
String targetName = args[0];
|
||||
String coinsString = args[1];
|
||||
final String targetName = args[0];
|
||||
final String coinsString = args[1];
|
||||
Player target = UtilPlayer.searchExact(targetName);
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
UUID uuid = UUIDFetcher.getUUIDOf(targetName);
|
||||
if (uuid != null)
|
||||
Plugin.getClientManager().loadClientByName(targetName, new Runnable()
|
||||
{
|
||||
rewardCoins(caller, null, targetName, uuid, coinsString);
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Coin", "Could not find player " + F.name(targetName)));
|
||||
}
|
||||
public void run()
|
||||
{
|
||||
CoreClient client = Plugin.getClientManager().Get(targetName);
|
||||
|
||||
if (client != null)
|
||||
rewardCoins(caller, null, targetName, client.getAccountId(), coinsString);
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Coin", "Could not find player " + F.name(targetName)));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
rewardCoins(caller, target, target.getName(), target.getUniqueId(), coinsString);
|
||||
rewardCoins(caller, target, target.getName(), Plugin.getClientManager().Get(target).getAccountId(), coinsString);
|
||||
}
|
||||
}
|
||||
|
||||
private void rewardCoins(final Player caller, final Player target, final String targetName, final UUID uuid, String coinsString)
|
||||
private void rewardCoins(final Player caller, final Player target, final String targetName, final int accountId, String coinsString)
|
||||
{
|
||||
try
|
||||
{
|
||||
int coins = Integer.parseInt(coinsString);
|
||||
rewardCoins(caller, target, targetName, uuid, coins);
|
||||
rewardCoins(caller, target, targetName, accountId, coins);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -62,7 +68,7 @@ public class CoinCommand extends CommandBase<DonationManager>
|
||||
}
|
||||
}
|
||||
|
||||
private void rewardCoins(final Player caller, final Player target, final String targetName, final UUID uuid, final int coins)
|
||||
private void rewardCoins(final Player caller, final Player target, final String targetName, final int accountId, final int coins)
|
||||
{
|
||||
Plugin.RewardCoins(new Callback<Boolean>()
|
||||
{
|
||||
@ -75,6 +81,6 @@ public class CoinCommand extends CommandBase<DonationManager>
|
||||
UtilPlayer.message(target, F.main("Coin", F.name(caller.getName()) + " gave you " + F.elem(coins + " Coins") + "."));
|
||||
}
|
||||
}
|
||||
}, caller.getName(), targetName, uuid, coins);
|
||||
}, caller.getName(), targetName, accountId, coins);
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
//_repository.updateGemsAndCoins(uuid, Get(token.Name).GetGems(), Get(token.Name).getCoins());
|
||||
}
|
||||
|
||||
public void PurchaseUnknownSalesPackage(final Callback<TransactionResponse> callback, final String name, final UUID uuid, final String packageName, final boolean coinPurchase, final int cost, boolean oneTimePurchase)
|
||||
public void PurchaseUnknownSalesPackage(final Callback<TransactionResponse> callback, final String name, final int accountId, final String packageName, final boolean coinPurchase, final int cost, boolean oneTimePurchase)
|
||||
{
|
||||
final Donor donor = Bukkit.getPlayerExact(name) != null ? Get(name) : null;
|
||||
|
||||
@ -89,7 +89,7 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
if (callback != null)
|
||||
callback.run(response);
|
||||
}
|
||||
}, name, uuid.toString(), packageName, coinPurchase, cost);
|
||||
}, name, accountId, packageName, coinPurchase, cost);
|
||||
}
|
||||
|
||||
public void PurchaseKnownSalesPackage(final Callback<TransactionResponse> callback, final String name, final UUID uuid, final int cost, final int salesPackageId)
|
||||
@ -196,12 +196,12 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
_gemQueue.clear();
|
||||
}
|
||||
|
||||
public void RewardCoins(Callback<Boolean> callback, String caller, String name, UUID uuid, int amount)
|
||||
public void RewardCoins(Callback<Boolean> callback, String caller, String name, int accountId, int amount)
|
||||
{
|
||||
RewardCoins(callback, caller, name, uuid, amount, true);
|
||||
RewardCoins(callback, caller, name, accountId, amount, true);
|
||||
}
|
||||
|
||||
public void RewardCoins(final Callback<Boolean> callback, final String caller, final String name, final UUID uuid, final int amount, final boolean updateTotal)
|
||||
public void RewardCoins(final Callback<Boolean> callback, final String caller, final String name, final int accountId, final int amount, final boolean updateTotal)
|
||||
{
|
||||
_repository.rewardCoins(new Callback<Boolean>()
|
||||
{
|
||||
@ -223,7 +223,7 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
callback.run(true);
|
||||
}
|
||||
}
|
||||
}, caller, name, uuid.toString(), amount);
|
||||
}, caller, name, accountId, amount);
|
||||
}
|
||||
|
||||
public void RewardCoinsLater(final String caller, final Player player, final int amount)
|
||||
@ -251,22 +251,35 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
if (event.getType() != UpdateType.SLOWER)
|
||||
return;
|
||||
|
||||
for (Player player : _coinQueue.keySet())
|
||||
for (final Player player : _coinQueue.keySet())
|
||||
{
|
||||
String caller = null;
|
||||
int total = 0;
|
||||
String tempCaller = null;
|
||||
int tempTotal = 0;
|
||||
|
||||
for (String curCaller : _coinQueue.get(player).keySet())
|
||||
{
|
||||
caller = curCaller;
|
||||
total += _coinQueue.get(player).get(curCaller);
|
||||
tempCaller = curCaller;
|
||||
tempTotal += _coinQueue.get(player).get(curCaller);
|
||||
}
|
||||
|
||||
final int total = tempTotal;
|
||||
final String caller = tempCaller;
|
||||
|
||||
if (caller == null)
|
||||
continue;
|
||||
|
||||
//Actually Add Gems
|
||||
RewardCoins(null, caller, player.getName(), player.getUniqueId(), total, false);
|
||||
if (player.isOnline() && player.isValid())
|
||||
RewardCoins(null, caller, player.getName(), ClientManager.Get(player).getAccountId(), total, false);
|
||||
else
|
||||
{
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
RewardCoins(null, caller, player.getName(), ClientManager.getCachedClientAccountId(player.getUniqueId()), total, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
System.out.println("Queue Added [" + player + "] with Coins [" + total + "] for [" + caller + "]");
|
||||
|
||||
@ -278,12 +291,12 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
_coinQueue.clear();
|
||||
}
|
||||
|
||||
public void RewardGold(Callback<Boolean> callback, String caller, String name, UUID uuid, int amount)
|
||||
public void RewardGold(Callback<Boolean> callback, String caller, String name, int accountId, int amount)
|
||||
{
|
||||
RewardGold(callback, caller, name, uuid, amount, true);
|
||||
RewardGold(callback, caller, name, accountId, amount, true);
|
||||
}
|
||||
|
||||
public void RewardGold(final Callback<Boolean> callback, final String caller, final String name, final UUID uuid, final int amount, final boolean updateTotal)
|
||||
public void RewardGold(final Callback<Boolean> callback, final String caller, final String name, final int accountId, final int amount, final boolean updateTotal)
|
||||
{
|
||||
_repository.rewardGold(new Callback<Boolean>()
|
||||
{
|
||||
@ -309,7 +322,7 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
if (callback != null)
|
||||
callback.run(true);
|
||||
}
|
||||
}, caller, name, uuid.toString(), amount);
|
||||
}, caller, name, accountId, amount);
|
||||
}
|
||||
|
||||
public void RewardGoldLater(final String caller, final Player player, final int amount)
|
||||
@ -352,7 +365,7 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
continue;
|
||||
|
||||
//Actually Add Gold
|
||||
RewardGold(null, caller, player.getName(), player.getUniqueId(), total, false);
|
||||
RewardGold(null, caller, player.getName(), ClientManager.Get(player).getAccountId(), total, false);
|
||||
|
||||
System.out.println("Queue Added [" + player + "] with Gold [" + total + "] for [" + caller + "]");
|
||||
|
||||
@ -375,15 +388,15 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
Get(playerName).addGold(_repository.retrieveDonorInfo(resultSet).getGold());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuery(String uuid, String name)
|
||||
{
|
||||
return "SELECT gold FROM accounts WHERE uuid = '" + uuid + "';";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Donor AddPlayer(String player)
|
||||
{
|
||||
return new Donor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuery(int accountId, String uuid, String name)
|
||||
{
|
||||
return "SELECT gold FROM accounts WHERE id = '" + accountId + "';";
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.Callback;
|
||||
@ -31,34 +32,39 @@ public class GoldCommand extends CommandBase<DonationManager>
|
||||
return;
|
||||
}
|
||||
|
||||
String targetName = args[0];
|
||||
String goldString = args[1];
|
||||
final String targetName = args[0];
|
||||
final String goldString = args[1];
|
||||
Player target = UtilPlayer.searchExact(targetName);
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
UUID uuid = UUIDFetcher.getUUIDOf(targetName);
|
||||
if (uuid != null)
|
||||
Plugin.getClientManager().loadClientByName(targetName, new Runnable()
|
||||
{
|
||||
rewardGold(caller, null, targetName, uuid, goldString);
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Gold", "Could not find player " + F.name(targetName)));
|
||||
}
|
||||
public void run()
|
||||
{
|
||||
CoreClient client = Plugin.getClientManager().Get(targetName);
|
||||
|
||||
if (client != null)
|
||||
rewardGold(caller, null, targetName, client.getAccountId(), goldString);
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Gold", "Could not find player " + F.name(targetName)));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
rewardGold(caller, target, target.getName(), target.getUniqueId(), goldString);
|
||||
rewardGold(caller, target, target.getName(), Plugin.getClientManager().Get(target).getAccountId(), goldString);
|
||||
}
|
||||
}
|
||||
|
||||
private void rewardGold(final Player caller, final Player target, final String targetName, final UUID uuid, String goldString)
|
||||
private void rewardGold(final Player caller, final Player target, final String targetName, final int accountId, String goldString)
|
||||
{
|
||||
try
|
||||
{
|
||||
int gold = Integer.parseInt(goldString);
|
||||
rewardGold(caller, target, targetName, uuid, gold);
|
||||
rewardGold(caller, target, targetName, accountId, gold);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -66,7 +72,7 @@ public class GoldCommand extends CommandBase<DonationManager>
|
||||
}
|
||||
}
|
||||
|
||||
private void rewardGold(final Player caller, final Player target, final String targetName, final UUID uuid, final int gold)
|
||||
private void rewardGold(final Player caller, final Player target, final String targetName, final int accountId, final int gold)
|
||||
{
|
||||
Plugin.RewardGold(new Callback<Boolean>()
|
||||
{
|
||||
@ -79,6 +85,6 @@ public class GoldCommand extends CommandBase<DonationManager>
|
||||
UtilPlayer.message(target, F.main("Gold", F.name(caller.getName()) + " gave you " + F.elem(gold + " Gold") + "."));
|
||||
}
|
||||
}
|
||||
}, caller.getName(), targetName, uuid, gold);
|
||||
}, caller.getName(), targetName, accountId, gold);
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package mineplex.core.donation.repository;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -23,12 +22,12 @@ import mineplex.core.server.util.TransactionResponse;
|
||||
|
||||
public class DonationRepository extends RepositoryBase
|
||||
{
|
||||
private static String CREATE_COIN_TRANSACTION_TABLE = "CREATE TABLE IF NOT EXISTS accountCoinTransactions (id INT NOT NULL AUTO_INCREMENT, accounts_uuid VARCHAR(100), reason VARCHAR(100), coins INT, PRIMARY KEY (id), FOREIGN KEY (accounts_uuid) REFERENCES accounts(uuid), INDEX coinUuidIndex (accounts_uuid));";
|
||||
private static String CREATE_GEM_TRANSACTION_TABLE = "CREATE TABLE IF NOT EXISTS accountGemTransactions (id INT NOT NULL AUTO_INCREMENT, accounts_uuid VARCHAR(100), reason VARCHAR(100), gems INT, PRIMARY KEY (id), FOREIGN KEY (accounts_uuid) REFERENCES accounts(uuid), INDEX gemUuidIndex (accounts_uuid));";
|
||||
private static String INSERT_COIN_TRANSACTION = "INSERT INTO accountCoinTransactions(accounts_uuid, reason, coins) VALUES(?, ?, ?);";
|
||||
private static String UPDATE_ACCOUNT_COINS = "UPDATE accounts SET coins = coins + ? WHERE uuid = ?;";
|
||||
private static String UPDATE_ACCOUNT_GOLD = "UPDATE accounts SET gold = gold + ? WHERE uuid = ?;";
|
||||
private static String UPDATE_NULL_ACCOUNT_GEMS_AND_COINS_ = "UPDATE accounts SET gems = ?, coins = ? WHERE uuid = ? AND gems IS NULL AND coins IS NULL;";
|
||||
private static String CREATE_COIN_TRANSACTION_TABLE = "CREATE TABLE IF NOT EXISTS accountCoinTransactions (id INT NOT NULL AUTO_INCREMENT, accountId INT, reason VARCHAR(100), coins INT, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id));";
|
||||
private static String CREATE_GEM_TRANSACTION_TABLE = "CREATE TABLE IF NOT EXISTS accountGemTransactions (id INT NOT NULL AUTO_INCREMENT, accountId INT, reason VARCHAR(100), gems INT, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id));";
|
||||
private static String INSERT_COIN_TRANSACTION = "INSERT INTO accountCoinTransactions(accountId, reason, coins) VALUES(?, ?, ?);";
|
||||
private static String UPDATE_ACCOUNT_COINS = "UPDATE accounts SET coins = coins + ? WHERE id = ?;";
|
||||
private static String UPDATE_ACCOUNT_GOLD = "UPDATE accounts SET gold = gold + ? WHERE id = ?;";
|
||||
private static String UPDATE_NULL_ACCOUNT_GEMS_AND_COINS_ = "UPDATE accounts SET gems = ?, coins = ? WHERE id = ? AND gems IS NULL AND coins IS NULL;";
|
||||
|
||||
private String _webAddress;
|
||||
|
||||
@ -70,7 +69,7 @@ public class DonationRepository extends RepositoryBase
|
||||
}), "Error purchasing known sales package in DonationRepository : ");
|
||||
}
|
||||
|
||||
public void PurchaseUnknownSalesPackage(final Callback<TransactionResponse> callback, final String name, final String uuid, final String packageName, final boolean coinPurchase, final int cost)
|
||||
public void PurchaseUnknownSalesPackage(final Callback<TransactionResponse> callback, final String name, final int accountId, final String packageName, final boolean coinPurchase, final int cost)
|
||||
{
|
||||
final UnknownPurchaseToken token = new UnknownPurchaseToken();
|
||||
token.AccountName = name;
|
||||
@ -87,8 +86,8 @@ public class DonationRepository extends RepositoryBase
|
||||
{
|
||||
if (coinPurchase)
|
||||
{
|
||||
executeUpdate(UPDATE_ACCOUNT_COINS, new ColumnInt("coins", -cost), new ColumnVarChar("uuid", 100, uuid));
|
||||
executeUpdate(INSERT_COIN_TRANSACTION, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("reason", 100, "Purchased " + packageName), new ColumnInt("coins", -cost));
|
||||
executeUpdate(UPDATE_ACCOUNT_COINS, new ColumnInt("coins", -cost), new ColumnInt("id", accountId));
|
||||
//executeUpdate(INSERT_COIN_TRANSACTION, new ColumnInt("id", accountId), new ColumnVarChar("reason", 100, "Purchased " + packageName), new ColumnInt("coins", -cost));
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,7 +142,7 @@ public class DonationRepository extends RepositoryBase
|
||||
}), "Error updating player gem amount in DonationRepository : ");
|
||||
}
|
||||
|
||||
public void rewardCoins(final Callback<Boolean> callback, final String giver, String name, final String uuid, final int coins)
|
||||
public void rewardCoins(final Callback<Boolean> callback, final String giver, String name, final int accountId, final int coins)
|
||||
{
|
||||
final GemRewardToken token = new GemRewardToken();
|
||||
token.Source = giver;
|
||||
@ -156,8 +155,8 @@ public class DonationRepository extends RepositoryBase
|
||||
{
|
||||
if (response)
|
||||
{
|
||||
executeUpdate(UPDATE_ACCOUNT_COINS, new ColumnInt("coins", coins), new ColumnVarChar("uuid", 100, uuid));
|
||||
executeUpdate(INSERT_COIN_TRANSACTION, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("reason", 100, "Rewarded by " + giver), new ColumnInt("coins", coins));
|
||||
executeUpdate(UPDATE_ACCOUNT_COINS, new ColumnInt("coins", coins), new ColumnInt("id", accountId));
|
||||
//executeUpdate(INSERT_COIN_TRANSACTION, new ColumnInt("id", accountId), new ColumnVarChar("reason", 100, "Rewarded by " + giver), new ColumnInt("coins", coins));
|
||||
}
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable()
|
||||
@ -180,13 +179,13 @@ public class DonationRepository extends RepositoryBase
|
||||
}), "Error updating player coin amount in DonationRepository : ");
|
||||
}
|
||||
|
||||
public void rewardGold(final Callback<Boolean> callback, final String giver, final String name, final String uuid, final int gold)
|
||||
public void rewardGold(final Callback<Boolean> callback, final String giver, final String name, final int accountId, final int gold)
|
||||
{
|
||||
handleDatabaseCall(new DatabaseRunnable(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
if (executeUpdate(UPDATE_ACCOUNT_GOLD, new ColumnInt("gold", gold), new ColumnVarChar("uuid", 100, uuid)) < 1)
|
||||
if (executeUpdate(UPDATE_ACCOUNT_GOLD, new ColumnInt("gold", gold), new ColumnInt("id", accountId)) < 1)
|
||||
{
|
||||
callback.run(false);
|
||||
}
|
||||
@ -208,13 +207,13 @@ public class DonationRepository extends RepositoryBase
|
||||
{
|
||||
}
|
||||
|
||||
public void updateGemsAndCoins(final UUID uuid, final int gems, final int coins)
|
||||
public void updateGemsAndCoins(final int accountId, final int gems, final int coins)
|
||||
{
|
||||
handleDatabaseCall(new DatabaseRunnable(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
executeUpdate(UPDATE_NULL_ACCOUNT_GEMS_AND_COINS_, new ColumnInt("gems", gems), new ColumnInt("coins", coins), new ColumnVarChar("uuid", 100, uuid.toString()));
|
||||
executeUpdate(UPDATE_NULL_ACCOUNT_GEMS_AND_COINS_, new ColumnInt("gems", gems), new ColumnInt("coins", coins), new ColumnInt("id", accountId));
|
||||
}
|
||||
}), "Error updating player's null gems and coins DonationRepository : ");
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user