added files.
This commit is contained in:
commit
f93cc6b887
1166 files changed
+142532
No files matched your search
@@ -0,0 +1,4 @@
|
||||
.gradle/
|
||||
build/
|
||||
.idea/
|
||||
*.iml
|
||||
@@ -0,0 +1,45 @@
|
||||
<p align="center">
|
||||
<img src="assets/ss.png" alt="Skid Solutions Banner" width="350" />
|
||||
<br>
|
||||
<font size="6"><b>OpenPhoenix</b></font>
|
||||
<br>
|
||||
<font size="3">by Skid Solutions</font>
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
<p align="center">
|
||||
<a href="https://discord.gg/AEwatvnvSf">https://discord.gg/AEwatvnvSf</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="assets/jak.jpg" alt="jak" height="150" />
|
||||
<img src="assets/hack.jpg" alt="hack" height="150" />
|
||||
<img src="assets/deobf2.png" alt="deobf2" height="150" />
|
||||
<img src="assets/deobf.jpg" alt="deobf" height="150" />
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
## How to build
|
||||
|
||||
### Prerequisites
|
||||
- **Java Development Kit**: JDK 17 (the Gradle wrapper 8.14.3 does not run on newer JDKs)
|
||||
|
||||
---
|
||||
|
||||
### Building Phoenix
|
||||
|
||||
Run from this folder:
|
||||
|
||||
```powershell
|
||||
$env:JAVA_HOME = "C:\Program Files\Java\jdk-17"
|
||||
|
||||
.\gradlew.bat clean build
|
||||
```
|
||||
|
||||
The build also compiles every NMS adapter listed in `platforms/versions.txt`.
|
||||
|
||||
Generated `build/libs/`:
|
||||
- `Phoenix-3.1-34677f1.jar`
|
||||
- `Phoenix-3.1-34677f1-sources.jar`
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 76 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 135 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.0 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 323 KiB |
@@ -0,0 +1,98 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'idea'
|
||||
id 'eclipse'
|
||||
}
|
||||
|
||||
group = 'xyz.refinedev.phoenix'
|
||||
version = '3.1-34677f1'
|
||||
|
||||
def javaVersion = 17
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/') }
|
||||
}
|
||||
|
||||
configurations {
|
||||
apiGenerator
|
||||
}
|
||||
|
||||
def generatorClasses = layout.buildDirectory.dir('api-generator/classes')
|
||||
tasks.register('compileApiGenerator', JavaCompile) {
|
||||
source = files('gradle/GenerateCompileApis.java')
|
||||
classpath = configurations.apiGenerator
|
||||
destinationDirectory = generatorClasses
|
||||
javaCompiler = javaToolchains.compilerFor { languageVersion = JavaLanguageVersion.of(javaVersion) }
|
||||
options.release = javaVersion
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
tasks.register('generateCompileApis', JavaExec) {
|
||||
group = 'build setup'
|
||||
description = 'Generates compile-only API headers from text declarations.'
|
||||
dependsOn tasks.named('compileApiGenerator')
|
||||
inputs.dir('gradle/api-signatures')
|
||||
outputs.dir(layout.buildDirectory.dir('compile-apis'))
|
||||
classpath = files(generatorClasses) + configurations.apiGenerator
|
||||
javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(javaVersion) }
|
||||
mainClass = 'GenerateCompileApis'
|
||||
maxHeapSize = '2g'
|
||||
args file('gradle/api-signatures').absolutePath, layout.buildDirectory.dir('compile-apis').get().asFile.absolutePath
|
||||
}
|
||||
def compileApi = { String name ->
|
||||
files(layout.buildDirectory.file("compile-apis/${name}.jar")).builtBy(tasks.named('generateCompileApis'))
|
||||
}
|
||||
tasks.register('prepareIde') {
|
||||
group = 'ide'
|
||||
description = 'Generates the compile-only API headers used by the IDE import.'
|
||||
dependsOn tasks.named('generateCompileApis')
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain.languageVersion = JavaLanguageVersion.of(javaVersion)
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
apiGenerator 'org.ow2.asm:asm:9.8'
|
||||
apiGenerator 'com.google.code.gson:gson:2.10.1'
|
||||
|
||||
compileOnly compileApi('phoenix')
|
||||
compileOnly compileApi('phoenix-adapters')
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
if (name != 'compileApiGenerator') {
|
||||
dependsOn tasks.named('generateCompileApis')
|
||||
}
|
||||
options.release = javaVersion
|
||||
options.encoding = 'UTF-8'
|
||||
options.compilerArgs += ['-parameters', '-Xmaxerrs', '1000']
|
||||
options.debug = true
|
||||
}
|
||||
|
||||
tasks.withType(AbstractArchiveTask).configureEach {
|
||||
preserveFileTimestamps = false
|
||||
reproducibleFileOrder = true
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest.attributes('Implementation-Title': 'Phoenix',
|
||||
'Implementation-Version': project.version)
|
||||
}
|
||||
|
||||
def nmsApis = ['v1_12_R1': 'phoenix-nms-1', 'v1_16_R3': 'phoenix-nms-1', 'v1_18_R2': 'phoenix-nms-1', 'v1_19_R3': 'phoenix-nms-1', 'v1_20_R3': 'phoenix-nms-2', 'v1_21_R1': 'phoenix-nms-1', 'v1_21_R10': 'phoenix-nms-1', 'v1_7_R4': 'phoenix-nms-1', 'v1_8_R3': 'phoenix-nms-1', 'v_1_20_R4': 'phoenix-nms-1']
|
||||
def serverVersions = file('platforms/versions.txt').readLines().findAll { !it.isBlank() }
|
||||
serverVersions.each { serverVersion ->
|
||||
def set = sourceSets.create('server_' + serverVersion)
|
||||
set.java.setSrcDirs(['platforms/' + serverVersion + '/src/main/java'])
|
||||
set.resources.setSrcDirs([])
|
||||
set.compileClasspath = compileApi(nmsApis[serverVersion]) + sourceSets.main.output + configurations.compileClasspath
|
||||
tasks.named(set.compileJavaTaskName) { dependsOn tasks.named('classes') }
|
||||
tasks.named('jar') { from set.output; dependsOn tasks.named(set.classesTaskName) }
|
||||
tasks.named('sourcesJar') { from set.allSource }
|
||||
}
|
||||
|
||||
tasks.named('sourcesJar') {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
org.gradle.jvmargs=-Xmx3g -Dfile.encoding=UTF-8
|
||||
org.gradle.workers.max=2
|
||||
org.gradle.parallel=false
|
||||
@@ -0,0 +1,66 @@
|
||||
import com.google.gson.*;
|
||||
import org.objectweb.asm.*;
|
||||
import java.io.*;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import java.util.jar.*;
|
||||
|
||||
public final class GenerateCompileApis implements Opcodes {
|
||||
static String text(JsonObject o,String k){return o.has(k)&&!o.get(k).isJsonNull()?o.get(k).getAsString():null;}
|
||||
static int number(JsonObject o,String k){return o.get(k).getAsInt();}
|
||||
static JsonArray array(JsonObject o,String k){return o.has(k)?o.getAsJsonArray(k):new JsonArray();}
|
||||
static String[] strings(JsonObject o,String k){List<String> r=new ArrayList<>();for(JsonElement e:array(o,k))r.add(e.getAsString());return r.toArray(new String[0]);}
|
||||
static Object scalar(JsonObject o){String v=text(o,"value");return switch(text(o,"type")){
|
||||
case "Long"->Long.valueOf(v);case "Integer"->Integer.valueOf(v);case "Float"->Float.valueOf(v);case "Double"->Double.valueOf(v);case "Byte"->Byte.valueOf(v);case "Short"->Short.valueOf(v);case "Character"->v.charAt(0);default->throw new IllegalArgumentException(o.toString());};}
|
||||
static Object constant(JsonElement e){if(e==null||e.isJsonNull())return null;if(e.isJsonObject())return scalar(e.getAsJsonObject());return e.getAsString();}
|
||||
static void annotationValue(AnnotationVisitor visitor,String name,JsonElement value){
|
||||
if(value.isJsonArray()){AnnotationVisitor nested=visitor.visitArray(name);for(JsonElement e:value.getAsJsonArray())annotationValue(nested,null,e);nested.visitEnd();}
|
||||
else if(value.isJsonObject()){JsonObject o=value.getAsJsonObject();switch(text(o,"kind")){
|
||||
case "scalar"->visitor.visit(name,scalar(o));case "type"->visitor.visit(name,Type.getType(text(o,"descriptor")));
|
||||
case "enum"->visitor.visitEnum(name,text(o,"descriptor"),text(o,"name"));
|
||||
case "annotation"->{JsonObject a=o.getAsJsonObject("annotation");writeAnnotation(visitor.visitAnnotation(name,text(a,"descriptor")),a);}
|
||||
default->throw new IllegalArgumentException(o.toString());}}
|
||||
else if(value.getAsJsonPrimitive().isBoolean())visitor.visit(name,value.getAsBoolean());
|
||||
else visitor.visit(name,value.getAsString());
|
||||
}
|
||||
static void writeAnnotation(AnnotationVisitor visitor,JsonObject annotation){if(visitor==null)return;for(var e:annotation.getAsJsonObject("values").entrySet())annotationValue(visitor,e.getKey(),e.getValue());visitor.visitEnd();}
|
||||
interface Factory {AnnotationVisitor create(JsonObject annotation);}
|
||||
static void annotations(JsonObject o,String key,Factory factory){for(JsonElement a:array(o,key)){JsonObject obj=a.getAsJsonObject();writeAnnotation(factory.create(obj),obj);}}
|
||||
static TypePath path(JsonObject o){return TypePath.fromString(text(o,"typePath"));}
|
||||
static byte[] compile(JsonObject c){
|
||||
ClassWriter cw=new ClassWriter(0);cw.visit(number(c,"version"),number(c,"access"),text(c,"name"),text(c,"signature"),text(c,"superName"),strings(c,"interfaces"));
|
||||
if(c.has("outerClass"))cw.visitOuterClass(text(c,"outerClass"),text(c,"outerMethod"),text(c,"outerMethodDescriptor"));
|
||||
if(c.has("nestHostClass"))cw.visitNestHost(text(c,"nestHostClass"));
|
||||
for(String n:strings(c,"nestMembers"))cw.visitNestMember(n);for(String n:strings(c,"permittedSubclasses"))cw.visitPermittedSubclass(n);
|
||||
annotations(c,"annotations",a->cw.visitAnnotation(text(a,"descriptor"),a.get("visible").getAsBoolean()));
|
||||
annotations(c,"typeAnnotations",a->cw.visitTypeAnnotation(number(a,"typeRef"),path(a),text(a,"descriptor"),a.get("visible").getAsBoolean()));
|
||||
for(JsonElement el:array(c,"innerClasses")){var n=el.getAsJsonObject();cw.visitInnerClass(text(n,"name"),text(n,"outerName"),text(n,"innerName"),number(n,"access"));}
|
||||
for(JsonElement el:array(c,"recordComponents")){var r=el.getAsJsonObject();var rv=cw.visitRecordComponent(text(r,"name"),text(r,"descriptor"),text(r,"signature"));annotations(r,"annotations",a->rv.visitAnnotation(text(a,"descriptor"),a.get("visible").getAsBoolean()));annotations(r,"typeAnnotations",a->rv.visitTypeAnnotation(number(a,"typeRef"),path(a),text(a,"descriptor"),a.get("visible").getAsBoolean()));rv.visitEnd();}
|
||||
for(JsonElement el:array(c,"fields")){var f=el.getAsJsonObject();var fv=cw.visitField(number(f,"access"),text(f,"name"),text(f,"descriptor"),text(f,"signature"),constant(f.get("constant")));annotations(f,"annotations",a->fv.visitAnnotation(text(a,"descriptor"),a.get("visible").getAsBoolean()));annotations(f,"typeAnnotations",a->fv.visitTypeAnnotation(number(a,"typeRef"),path(a),text(a,"descriptor"),a.get("visible").getAsBoolean()));fv.visitEnd();}
|
||||
for(JsonElement el:array(c,"methods")){var m=el.getAsJsonObject();int access=number(m,"access");String descriptor=text(m,"descriptor");var mv=cw.visitMethod(access,text(m,"name"),descriptor,text(m,"signature"),strings(m,"exceptions"));
|
||||
for(JsonElement pe:array(m,"parameters")){var p=pe.getAsJsonObject();mv.visitParameter(text(p,"name"),number(p,"access"));}
|
||||
annotations(m,"annotations",a->mv.visitAnnotation(text(a,"descriptor"),a.get("visible").getAsBoolean()));annotations(m,"typeAnnotations",a->mv.visitTypeAnnotation(number(a,"typeRef"),path(a),text(a,"descriptor"),a.get("visible").getAsBoolean()));
|
||||
annotations(m,"parameterAnnotations",a->mv.visitParameterAnnotation(number(a,"parameter"),text(a,"descriptor"),a.get("visible").getAsBoolean()));
|
||||
if(m.has("annotationDefault")){var av=mv.visitAnnotationDefault();annotationValue(av,null,m.get("annotationDefault"));av.visitEnd();}
|
||||
if((access&(ACC_ABSTRACT|ACC_NATIVE))==0){mv.visitCode();mv.visitTypeInsn(NEW,"java/lang/UnsupportedOperationException");mv.visitInsn(DUP);mv.visitLdcInsn("Compile-only API header; use the real server or library at runtime");mv.visitMethodInsn(INVOKESPECIAL,"java/lang/UnsupportedOperationException","<init>","(Ljava/lang/String;)V",false);mv.visitInsn(ATHROW);int locals=(access&ACC_STATIC)==0?1:0;for(Type t:Type.getArgumentTypes(descriptor))locals+=t.getSize();mv.visitMaxs(3,locals);}
|
||||
mv.visitEnd();}
|
||||
cw.visitEnd();return cw.toByteArray();
|
||||
}
|
||||
static SortedMap<String,JsonObject> declarations(Path input,Path schema,Set<Path> active)throws Exception {
|
||||
if(!active.add(schema))throw new IllegalArgumentException("Cyclic API declaration inheritance: "+schema);
|
||||
JsonObject data;try(Reader r=Files.newBufferedReader(schema)){data=JsonParser.parseReader(r).getAsJsonObject();}
|
||||
SortedMap<String,JsonObject> classes=new TreeMap<>();
|
||||
if(data.has("base"))classes.putAll(declarations(input,input.resolve(text(data,"base")+".json"),active));
|
||||
for(JsonElement entry:array(data,"classes")){JsonObject c=entry.getAsJsonObject();classes.put(text(c,"name"),c);}
|
||||
active.remove(schema);return classes;
|
||||
}
|
||||
public static void main(String[] args)throws Exception{
|
||||
Path input=Path.of(args[0]),output=Path.of(args[1]);Files.createDirectories(output);
|
||||
for(Path schema:Files.list(input).filter(p->p.toString().endsWith(".json")).sorted().toList()){
|
||||
SortedMap<String,JsonObject> classes=declarations(input,schema,new HashSet<>());
|
||||
String name=schema.getFileName().toString().replace(".json",".jar");Path jar=output.resolve(name);
|
||||
try(var out=new JarOutputStream(Files.newOutputStream(jar))){for(JsonObject c:classes.values()){var entry=new JarEntry(text(c,"name")+".class");entry.setTime(0);out.putNextEntry(entry);out.write(compile(c));out.closeEntry();}}
|
||||
System.out.println("Generated compile API "+name+" ("+classes.size()+" declarations)");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"formatVersion":1,"purpose":"Compile-only API declarations; not runtime implementations","classes":[{"name":"me/creaxx/api/nms/impl/v1_12_R1","version":52,"access":33,"superName":"java/lang/Object","interfaces":["me/creaxx/api/nms/INMSImpl"],"innerClasses":[{"name":"net/minecraft/server/v1_12_R1/PacketPlayOutPlayerInfo$EnumPlayerInfoAction","outerName":"net/minecraft/server/v1_12_R1/PacketPlayOutPlayerInfo","innerName":"EnumPlayerInfoAction","access":16409},{"name":"net/minecraft/server/v1_12_R1/IChatBaseComponent$ChatSerializer","outerName":"net/minecraft/server/v1_12_R1/IChatBaseComponent","innerName":"ChatSerializer","access":9}],"fields":[{"name":"creeperIds","access":2,"descriptor":"Ljava/util/Map;","signature":"Ljava/util/Map<Ljava/util/UUID;Ljava/lang/Integer;>;"}],"methods":[{"name":"<init>","access":1,"descriptor":"()V"},{"name":"disguise","access":1,"descriptor":"(Lxyz/refinedev/phoenix/profile/IProfile;Z)V"},{"name":"undisguise","access":1,"descriptor":"(Lxyz/refinedev/phoenix/profile/IProfile;)V"},{"name":"updateSkin","access":1,"descriptor":"(Lorg/bukkit/entity/Player;Lxyz/refinedev/phoenix/profile/disguise/ISkin;Z)V"},{"name":"updateHeaderFooter","access":1,"descriptor":"(Lorg/bukkit/entity/Player;Ljava/lang/String;Ljava/lang/String;)V"},{"name":"getPlayerSkin","access":1,"descriptor":"(Lorg/bukkit/entity/Player;)Lxyz/refinedev/phoenix/profile/disguise/ISkin;"},{"name":"itemWithBase64","access":1,"descriptor":"(Lorg/bukkit/inventory/ItemStack;Ljava/lang/String;)Lorg/bukkit/inventory/ItemStack;"},{"name":"sitPlayer","access":1,"descriptor":"(Lorg/bukkit/entity/Player;)V"},{"name":"unsitPlayer","access":1,"descriptor":"(Lorg/bukkit/entity/Player;)V"},{"name":"removePlayerFromTeam","access":1,"descriptor":"(Ljava/lang/String;Lorg/bukkit/scoreboard/Team;)V"},{"name":"sendPacket","access":2,"descriptor":"(Lorg/bukkit/entity/Player;Lnet/minecraft/server/v1_12_R1/Packet;)V"},{"name":"getEntity","access":1,"descriptor":"(Lorg/bukkit/entity/Player;)Lnet/minecraft/server/v1_12_R1/EntityPlayer;"}]},{"name":"me/creaxx/api/nms/impl/v1_16_R3","version":52,"access":33,"superName":"java/lang/Object","interfaces":["me/creaxx/api/nms/INMSImpl"],"innerClasses":[{"name":"net/minecraft/server/v1_16_R3/PacketPlayOutPlayerInfo$EnumPlayerInfoAction","outerName":"net/minecraft/server/v1_16_R3/PacketPlayOutPlayerInfo","innerName":"EnumPlayerInfoAction","access":16409},{"name":"org/bukkit/entity/Player$Spigot","outerName":"org/bukkit/entity/Player","innerName":"Spigot","access":9},{"name":"net/minecraft/server/v1_16_R3/IChatBaseComponent$ChatSerializer","outerName":"net/minecraft/server/v1_16_R3/IChatBaseComponent","innerName":"ChatSerializer","access":9},{"name":"java/lang/invoke/MethodHandles$Lookup","outerName":"java/lang/invoke/MethodHandles","innerName":"Lookup","access":25}],"fields":[{"name":"creeperIds","access":2,"descriptor":"Ljava/util/Map;","signature":"Ljava/util/Map<Ljava/util/UUID;Ljava/lang/Integer;>;"}],"methods":[{"name":"<init>","access":1,"descriptor":"()V"},{"name":"disguise","access":1,"descriptor":"(Lxyz/refinedev/phoenix/profile/IProfile;Z)V"},{"name":"undisguise","access":1,"descriptor":"(Lxyz/refinedev/phoenix/profile/IProfile;)V"},{"name":"updateSkin","access":1,"descriptor":"(Lorg/bukkit/entity/Player;Lxyz/refinedev/phoenix/profile/disguise/ISkin;Z)V"},{"name":"updateHeaderFooter","access":1,"descriptor":"(Lorg/bukkit/entity/Player;Ljava/lang/String;Ljava/lang/String;)V"},{"name":"itemWithBase64","access":1,"descriptor":"(Lorg/bukkit/inventory/ItemStack;Ljava/lang/String;)Lorg/bukkit/inventory/ItemStack;"},{"name":"getPlayerSkin","access":1,"descriptor":"(Lorg/bukkit/entity/Player;)Lxyz/refinedev/phoenix/profile/disguise/ISkin;"},{"name":"sitPlayer","access":1,"descriptor":"(Lorg/bukkit/entity/Player;)V"},{"name":"unsitPlayer","access":1,"descriptor":"(Lorg/bukkit/entity/Player;)V"},{"name":"removePlayerFromTeam","access":1,"descriptor":"(Ljava/lang/String;Lorg/bukkit/scoreboard/Team;)V"},{"name":"sendPacket","access":2,"descriptor":"(Lorg/bukkit/entity/Player;Lnet/minecraft/server/v1_16_R3/Packet;)V"},{"name":"getEntity","access":1,"descriptor":"(Lorg/bukkit/entity/Player;)Lnet/minecraft/server/v1_16_R3/EntityPlayer;"},{"name":"lambda$updateSkin$4","access":4106,"descriptor":"(Ljava/util/List;Lorg/bukkit/entity/Player;)V"}]},{"name":"me/creaxx/api/nms/impl/v1_18_R2","version":52,"access":33,"superName":"java/lang/Object","interfaces":["me/creaxx/api/nms/INMSImpl"],"innerClasses":[{"name":"net/minecraft/network/protocol/game/PacketPlayOutPlayerInfo$EnumPlayerInfoAction","outerName":"net/minecraft/network/protocol/game/PacketPlayOutPlayerInfo","innerName":"EnumPlayerInfoAction","access":17417},{"name":"org/bukkit/entity/Player$Spigot","outerName":"org/bukkit/entity/Player","innerName":"Spigot","access":9},{"name":"net/minecraft/network/chat/IChatBaseComponent$ChatSerializer","outerName":"net/minecraft/network/chat/IChatBaseComponent","innerName":"ChatSerializer","access":9}],"methods":[{"namLine truncated
|
||||
@@ -0,0 +1 @@
|
||||
{"formatVersion":1,"purpose":"Compile-only API declarations; not runtime implementations","classes":[{"name":"net/minecraft/network/chat/IChatBaseComponent","version":61,"access":1537,"superName":"java/lang/Object","innerClasses":[{"name":"net/minecraft/network/chat/IChatBaseComponent$ChatSerializer","outerName":"net/minecraft/network/chat/IChatBaseComponent","innerName":"ChatSerializer","access":9}]},{"name":"net/minecraft/network/chat/IChatBaseComponent$ChatSerializer","version":61,"access":33,"superName":"java/lang/Object","innerClasses":[{"name":"net/minecraft/network/chat/IChatBaseComponent$ChatSerializer","outerName":"net/minecraft/network/chat/IChatBaseComponent","innerName":"ChatSerializer","access":9}],"methods":[{"name":"a","access":9,"descriptor":"(Ljava/lang/String;)Lnet/minecraft/network/chat/IChatMutableComponent;"}]},{"name":"net/minecraft/network/chat/IChatMutableComponent","version":61,"access":1537,"superName":"java/lang/Object","interfaces":["net/minecraft/network/chat/IChatBaseComponent"]},{"name":"net/minecraft/network/protocol/Packet","version":61,"access":1537,"superName":"java/lang/Object"},{"name":"net/minecraft/network/protocol/game/ClientboundPlayerInfoRemovePacket","version":61,"access":33,"superName":"java/lang/Object","interfaces":["net/minecraft/network/protocol/Packet"],"methods":[{"name":"<init>","access":1,"descriptor":"(Ljava/util/List;)V"}]},{"name":"net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket","version":61,"access":33,"superName":"java/lang/Object","interfaces":["net/minecraft/network/protocol/Packet"],"innerClasses":[{"name":"net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket$a","outerName":"net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket","innerName":"a","access":9}],"methods":[{"name":"createPlayerInitializing","access":9,"descriptor":"(Ljava/util/Collection;)Lnet/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket;"},{"name":"<init>","access":1,"descriptor":"(Lnet/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket$a;Lnet/minecraft/server/level/EntityPlayer;)V"}]},{"name":"net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket$a","version":61,"access":33,"superName":"java/lang/Object","innerClasses":[{"name":"net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket$a","outerName":"net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket","innerName":"a","access":9}],"fields":[{"name":"b","access":9,"descriptor":"Lnet/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket$a;"},{"name":"d","access":9,"descriptor":"Lnet/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket$a;"}]},{"name":"net/minecraft/network/protocol/game/PacketPlayOutPlayerInfo","version":61,"access":33,"superName":"java/lang/Object","interfaces":["net/minecraft/network/protocol/Packet"],"innerClasses":[{"name":"net/minecraft/network/protocol/game/PacketPlayOutPlayerInfo$EnumPlayerInfoAction","outerName":"net/minecraft/network/protocol/game/PacketPlayOutPlayerInfo","innerName":"EnumPlayerInfoAction","access":9}],"methods":[{"name":"<init>","access":1,"descriptor":"(Lnet/minecraft/network/protocol/game/PacketPlayOutPlayerInfo$EnumPlayerInfoAction;[Lnet/minecraft/server/level/EntityPlayer;)V"}]},{"name":"net/minecraft/network/protocol/game/PacketPlayOutPlayerInfo$EnumPlayerInfoAction","version":61,"access":33,"superName":"java/lang/Object","interfaces":["net/minecraft/network/protocol/Packet"],"innerClasses":[{"name":"net/minecraft/network/protocol/game/PacketPlayOutPlayerInfo$EnumPlayerInfoAction","outerName":"net/minecraft/network/protocol/game/PacketPlayOutPlayerInfo","innerName":"EnumPlayerInfoAction","access":9}],"fields":[{"name":"b","access":9,"descriptor":"Lnet/minecraft/network/protocol/game/PacketPlayOutPlayerInfo$EnumPlayerInfoAction;"},{"name":"a","access":9,"descriptor":"Lnet/minecraft/network/protocol/game/PacketPlayOutPlayerInfo$EnumPlayerInfoAction;"}]},{"name":"net/minecraft/network/protocol/game/PacketPlayOutPlayerListHeaderFooter","version":61,"access":33,"superName":"java/lang/Object","interfaces":["net/minecraft/network/protocol/Packet"],"methods":[{"name":"<init>","access":1,"descriptor":"(Lnet/minecraft/network/chat/IChatBaseComponent;Lnet/minecraft/network/chat/IChatBaseComponent;)V"}]},{"name":"net/minecraft/server/dedicated/DedicatedPlayerList","version":61,"access":33,"superName":"java/lang/Object","methods":[{"name":"getServer","access":1,"descriptor":"()Lnet/minecraft/server/dedicated/DedicatedServer;"},{"name":"b","access":1,"descriptor":"()Lnet/minecraft/server/dedicated/DedicatedServer;"}]},{"name":"net/minecraft/server/dedicated/DedicatedServer","version":61,"access":33,"superName":"java/lang/Object","methods":[{"name":"getPlayerList","access":1,"descriptor":"()Lnet/minecraft/server/dedicated/DedicatedPlayerList;"},{"name":"ac","access":1,"descriptor":"()Lnet/minecraft/server/players/PlayerList;"},{"name":"ae","aLine truncated
|
||||
@@ -0,0 +1 @@
|
||||
{"formatVersion":1,"purpose":"Compile-only API declarations; not runtime implementations","classes":[{"name":"net/minecraft/server/network/PlayerConnection","version":61,"access":33,"superName":"java/lang/Object","methods":[{"name":"a","access":1,"descriptor":"(Lnet/minecraft/network/protocol/Packet;)Z"}]}],"base":"phoenix-nms-1"}
|
||||
@@ -0,0 +1 @@
|
||||
{"formatVersion":1,"purpose":"Compile-only API declarations; not runtime implementations","classes":[{"name":"com/destroystokyo/paper/profile/PlayerProfile","version":61,"access":1537,"superName":"java/lang/Object","methods":[{"name":"getProperties","access":1025,"descriptor":"()Ljava/util/Set;"},{"name":"setProperty","access":1025,"descriptor":"(Lcom/destroystokyo/paper/profile/ProfileProperty;)V"},{"name":"getId","access":1025,"descriptor":"()Ljava/util/UUID;"}]},{"name":"com/destroystokyo/paper/profile/ProfileProperty","version":61,"access":33,"superName":"java/lang/Object","methods":[{"name":"<init>","access":1,"descriptor":"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"},{"name":"<init>","access":1,"descriptor":"(Ljava/lang/String;Ljava/lang/String;)V"},{"name":"getName","access":1,"descriptor":"()Ljava/lang/String;"},{"name":"getValue","access":1,"descriptor":"()Ljava/lang/String;"},{"name":"getSignature","access":1,"descriptor":"()Ljava/lang/String;"}]},{"name":"com/google/common/annotations/Beta","version":52,"access":9729,"superName":"java/lang/Object","interfaces":["java/lang/annotation/Annotation"]},{"name":"com/google/common/annotations/GwtCompatible","version":52,"access":9729,"superName":"java/lang/Object","interfaces":["java/lang/annotation/Annotation"],"methods":[{"name":"serializable","access":1025,"descriptor":"()Z","annotationDefault":false},{"name":"emulated","access":1025,"descriptor":"()Z","annotationDefault":false}]},{"name":"com/google/common/annotations/GwtIncompatible","version":52,"access":9729,"superName":"java/lang/Object","interfaces":["java/lang/annotation/Annotation"],"methods":[{"name":"value","access":1025,"descriptor":"()Ljava/lang/String;","annotationDefault":""}]},{"name":"com/google/common/annotations/J2ktIncompatible","version":52,"access":9729,"superName":"java/lang/Object","interfaces":["java/lang/annotation/Annotation"]},{"name":"com/google/common/annotations/VisibleForTesting","version":52,"access":9729,"superName":"java/lang/Object","interfaces":["java/lang/annotation/Annotation"]},{"name":"com/google/common/annotations/package-info","version":52,"access":5632,"superName":"java/lang/Object"},{"name":"com/google/common/base/Absent","version":52,"access":48,"signature":"<T:Ljava/lang/Object;>Lcom/google/common/base/Optional<TT;>;","superName":"com/google/common/base/Optional","fields":[{"name":"INSTANCE","access":24,"descriptor":"Lcom/google/common/base/Absent;","signature":"Lcom/google/common/base/Absent<Ljava/lang/Object;>;"},{"name":"serialVersionUID","access":26,"descriptor":"J","constant":{"kind":"scalar","type":"Long","value":"0"}}],"methods":[{"name":"withType","access":8,"descriptor":"()Lcom/google/common/base/Optional;","signature":"<T:Ljava/lang/Object;>()Lcom/google/common/base/Optional<TT;>;"},{"name":"<init>","access":2,"descriptor":"()V"},{"name":"isPresent","access":1,"descriptor":"()Z"},{"name":"get","access":1,"descriptor":"()Ljava/lang/Object;","signature":"()TT;"},{"name":"or","access":1,"descriptor":"(Ljava/lang/Object;)Ljava/lang/Object;","signature":"(TT;)TT;"},{"name":"or","access":1,"descriptor":"(Lcom/google/common/base/Optional;)Lcom/google/common/base/Optional;","signature":"(Lcom/google/common/base/Optional<+TT;>;)Lcom/google/common/base/Optional<TT;>;"},{"name":"or","access":1,"descriptor":"(Lcom/google/common/base/Supplier;)Ljava/lang/Object;","signature":"(Lcom/google/common/base/Supplier<+TT;>;)TT;"},{"name":"orNull","access":1,"descriptor":"()Ljava/lang/Object;","signature":"()TT;"},{"name":"asSet","access":1,"descriptor":"()Ljava/util/Set;","signature":"()Ljava/util/Set<TT;>;"},{"name":"transform","access":1,"descriptor":"(Lcom/google/common/base/Function;)Lcom/google/common/base/Optional;","signature":"<V:Ljava/lang/Object;>(Lcom/google/common/base/Function<-TT;TV;>;)Lcom/google/common/base/Optional<TV;>;"},{"name":"equals","access":1,"descriptor":"(Ljava/lang/Object;)Z"},{"name":"hashCode","access":1,"descriptor":"()I"},{"name":"toString","access":1,"descriptor":"()Ljava/lang/String;"},{"name":"readResolve","access":2,"descriptor":"()Ljava/lang/Object;"}]},{"name":"com/google/common/base/AbstractIterator","version":52,"access":1056,"signature":"<T:Ljava/lang/Object;>Ljava/lang/Object;Ljava/util/Iterator<TT;>;","superName":"java/lang/Object","interfaces":["java/util/Iterator"],"innerClasses":[{"name":"com/google/common/base/AbstractIterator$State","outerName":"com/google/common/base/AbstractIterator","innerName":"State","access":16410}],"fields":[{"name":"state","access":2,"descriptor":"Lcom/google/common/base/AbstractIterator$State;"},{"name":"next","access":2,"descriptor":"Ljava/lang/Object;","signature":"TT;"}],"methods":[{"name":"<init>","access":4,"descriptor":"()V"},{"name":"computeNext","access":1028,"descriptor":"()Ljava/lang/Object;","signature":"()TT;"},{"name":"endOfData","access":20,"descriptor":"()Ljava/lang/Object;","signature":"()TT;"},{"name":"hasNext","access":17,"descriptor":"()Z"},{"name":"tryToCompuLine truncated
|
||||
Vendored
BIN
Binary file not shown.
+8
@@ -0,0 +1,8 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionSha256Sum=bd71102213493060956ec229d946beee57158dbd89d0e62b91bca0fa2c5f3531
|
||||
@@ -0,0 +1,251 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH="\\\"\\\""
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
Vendored
+94
@@ -0,0 +1,94 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -0,0 +1,267 @@
|
||||
package me.creaxx.api.nms.impl;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
import me.creaxx.api.nms.INMSImpl;
|
||||
|
||||
import net.minecraft.server.v1_12_R1.EntityCreeper;
|
||||
import net.minecraft.server.v1_12_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_12_R1.EnumGamemode;
|
||||
import net.minecraft.server.v1_12_R1.IChatBaseComponent.ChatSerializer;
|
||||
import net.minecraft.server.v1_12_R1.Packet;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayOutAttachEntity;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayOutEntityDestroy;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayOutPlayerInfo;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayOutPlayerInfo.EnumPlayerInfoAction;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayOutPlayerListHeaderFooter;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayOutRespawn;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayOutSpawnEntityLiving;
|
||||
import net.minecraft.server.v1_12_R1.PlayerList;
|
||||
import net.minecraft.server.v1_12_R1.Scoreboard;
|
||||
import net.minecraft.server.v1_12_R1.ScoreboardTeam;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.scoreboard.CraftScoreboard;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.disguise.IDisguiseData;
|
||||
import xyz.refinedev.phoenix.profile.disguise.ISkin;
|
||||
import xyz.refinedev.phoenix.profile.disguise.Skin;
|
||||
import xyz.refinedev.phoenix.utils.DisguiseUtil;
|
||||
import xyz.refinedev.phoenix.utils.ExceptionUtil;
|
||||
import xyz.refinedev.phoenix.utils.Utilities;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class v1_12_R1 implements INMSImpl {
|
||||
|
||||
private Map<UUID, Integer> creeperIds = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void disguise(IProfile profile, boolean matches) {
|
||||
Player player = Bukkit.getPlayer(profile.getUniqueId());
|
||||
IDisguiseData disguiseData = profile.getDisguiseData();
|
||||
EntityPlayer entityPlayer;
|
||||
DisguiseUtil.updateName(
|
||||
(entityPlayer = this.getEntity(player)).getProfile(),
|
||||
disguiseData.getDisguiseName());
|
||||
entityPlayer.displayName = disguiseData.getDisguiseName();
|
||||
try {
|
||||
PlayerList playerList =
|
||||
((CraftServer) Bukkit.getServer()).getHandle().getServer().getPlayerList();
|
||||
Field field;
|
||||
(field = PlayerList.class.getDeclaredField("playersByName")).setAccessible(true);
|
||||
Map entries;
|
||||
(entries = (Map) field.get(playerList)).remove(profile.getName());
|
||||
entries.put(disguiseData.getDisguiseName(), entityPlayer);
|
||||
} catch (Exception exception) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.log(Level.SEVERE, ExceptionUtil.getStackTrace(exception));
|
||||
}
|
||||
this.updateSkin(player, disguiseData.getDisguiseSkin(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undisguise(IProfile profile) {
|
||||
Player player = Bukkit.getPlayer(profile.getUniqueId());
|
||||
IDisguiseData disguiseData = profile.getDisguiseData();
|
||||
EntityPlayer entityPlayer;
|
||||
DisguiseUtil.updateName(
|
||||
(entityPlayer = this.getEntity(player)).getProfile(), disguiseData.getRealName());
|
||||
entityPlayer.displayName = disguiseData.getRealName();
|
||||
try {
|
||||
PlayerList playerList =
|
||||
((CraftServer) Bukkit.getServer()).getHandle().getServer().getPlayerList();
|
||||
Field field;
|
||||
(field = PlayerList.class.getDeclaredField("playersByName")).setAccessible(true);
|
||||
Map entries;
|
||||
(entries = (Map) field.get(playerList)).remove(disguiseData.getDisguiseName());
|
||||
entries.put(disguiseData.getRealName(), entityPlayer);
|
||||
} catch (Exception exception) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.log(Level.SEVERE, ExceptionUtil.getStackTrace(exception));
|
||||
}
|
||||
this.updateSkin(player, disguiseData.getRealSkin(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSkin(Player player, ISkin skin, boolean matches) {
|
||||
EntityPlayer handle = ((CraftPlayer) player).getHandle();
|
||||
Location location = player.getLocation().clone();
|
||||
GameProfile gameProfile;
|
||||
(gameProfile = handle.getProfile()).getProperties().clear();
|
||||
gameProfile
|
||||
.getProperties()
|
||||
.put("textures", new Property("textures", skin.getValue(), skin.getSignature()));
|
||||
handle.playerConnection.sendPacket(
|
||||
new PacketPlayOutPlayerInfo(
|
||||
EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[] {handle}));
|
||||
handle.playerConnection.sendPacket(
|
||||
new PacketPlayOutPlayerInfo(
|
||||
EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] {handle}));
|
||||
handle.playerConnection.sendPacket(
|
||||
new PacketPlayOutRespawn(
|
||||
handle.getWorld().worldProvider.getDimensionManager().getDimensionID(),
|
||||
handle.getWorld().worldData.getDifficulty(),
|
||||
handle.getWorld().worldData.getType(),
|
||||
EnumGamemode.valueOf(player.getGameMode().name())));
|
||||
player.getInventory().setItemInHand(player.getItemInHand());
|
||||
player.updateInventory();
|
||||
player.teleport(location);
|
||||
Iterator<org.bukkit.entity.Player> iterator2 = Utilities.getOnlinePlayers().iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Player player2;
|
||||
if ((player2 = (Player) iterator2.next()).canSee(player)) {
|
||||
player2.hidePlayer(player);
|
||||
player2.showPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateHeaderFooter(Player player, String text, String text2) {
|
||||
EntityPlayer handle = ((CraftPlayer) player).getHandle();
|
||||
PacketPlayOutPlayerListHeaderFooter packetPlayOutPlayerListHeaderFooter =
|
||||
new PacketPlayOutPlayerListHeaderFooter();
|
||||
try {
|
||||
Field declaredField =
|
||||
packetPlayOutPlayerListHeaderFooter.getClass().getDeclaredField("a");
|
||||
Field declaredField2 =
|
||||
packetPlayOutPlayerListHeaderFooter.getClass().getDeclaredField("b");
|
||||
declaredField.setAccessible(true);
|
||||
declaredField2.setAccessible(true);
|
||||
declaredField.set(
|
||||
packetPlayOutPlayerListHeaderFooter,
|
||||
ChatSerializer.a("{\"text\":\"" + text + "\"}"));
|
||||
declaredField2.set(
|
||||
packetPlayOutPlayerListHeaderFooter,
|
||||
ChatSerializer.a("{\"text\":\"" + text2 + "\"}"));
|
||||
} catch (IllegalAccessException | NoSuchFieldException exception) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.log(Level.SEVERE, ExceptionUtil.getStackTrace(exception));
|
||||
}
|
||||
handle.playerConnection.sendPacket(packetPlayOutPlayerListHeaderFooter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISkin getPlayerSkin(Player player) {
|
||||
String text = "";
|
||||
String text2 = "";
|
||||
Iterator<com.mojang.authlib.properties.Property> iterator2 =
|
||||
this.getEntity(player).getProfile().getProperties().get("textures").iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Property property;
|
||||
text = (property = (Property) iterator2.next()).getValue();
|
||||
text2 = property.getSignature();
|
||||
}
|
||||
return new Skin(player.getName(), text, text2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack itemWithBase64(ItemStack itemStack, String text) {
|
||||
if (itemStack == null || text == null || text.isEmpty()) {
|
||||
return itemStack;
|
||||
}
|
||||
if (!(itemStack.getItemMeta() instanceof SkullMeta)) {
|
||||
return itemStack;
|
||||
}
|
||||
SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta();
|
||||
UUID uUID =
|
||||
new UUID(
|
||||
text.substring(text.length() - 20).hashCode(),
|
||||
text.substring(text.length() - 10).hashCode());
|
||||
GameProfile gameProfile;
|
||||
(gameProfile = new GameProfile(uUID, "Player"))
|
||||
.getProperties()
|
||||
.put("textures", new Property("textures", text));
|
||||
try {
|
||||
Field field = skullMeta.getClass().getDeclaredField("profile");
|
||||
field.setAccessible(true);
|
||||
field.set(skullMeta, gameProfile);
|
||||
} catch (ReflectiveOperationException exception) {
|
||||
throw ExceptionUtil.propagate(exception);
|
||||
}
|
||||
itemStack.setItemMeta(skullMeta);
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sitPlayer(Player player) {
|
||||
if (!this.creeperIds.containsKey(player.getUniqueId())) {
|
||||
player.setAllowFlight(true);
|
||||
Location location = player.getLocation();
|
||||
EntityPlayer entity = this.getEntity(player);
|
||||
EntityCreeper entityCreeper;
|
||||
(entityCreeper = new EntityCreeper(entity.getWorld()))
|
||||
.setLocation(
|
||||
location.getX(),
|
||||
location.getY(),
|
||||
location.getX(),
|
||||
location.getYaw(),
|
||||
location.getPitch());
|
||||
entityCreeper.setInvisible(true);
|
||||
entityCreeper.setCustomNameVisible(false);
|
||||
this.creeperIds.put(player.getUniqueId(), entityCreeper.getId());
|
||||
PacketPlayOutSpawnEntityLiving packetPlayOutSpawnEntityLiving =
|
||||
new PacketPlayOutSpawnEntityLiving(entityCreeper);
|
||||
this.sendPacket(player, packetPlayOutSpawnEntityLiving);
|
||||
PacketPlayOutAttachEntity packetPlayOutAttachEntity =
|
||||
new PacketPlayOutAttachEntity(entity, entityCreeper);
|
||||
this.sendPacket(player, packetPlayOutAttachEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsitPlayer(Player player) {
|
||||
if (this.creeperIds.containsKey(player.getUniqueId())) {
|
||||
player.setAllowFlight(false);
|
||||
int value = this.creeperIds.get(player.getUniqueId());
|
||||
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy =
|
||||
new PacketPlayOutEntityDestroy(new int[] {value});
|
||||
this.sendPacket(player, packetPlayOutEntityDestroy);
|
||||
this.creeperIds.remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayerFromTeam(String text, Team team) {
|
||||
CraftScoreboard craftScoreboard = (CraftScoreboard) team.getScoreboard();
|
||||
try {
|
||||
Field field;
|
||||
(field = Scoreboard.class.getDeclaredField("teamsByPlayer")).setAccessible(true);
|
||||
((Map) field.get(craftScoreboard.getHandle())).remove(text);
|
||||
Field field2;
|
||||
(field2 =
|
||||
Class.forName("org.bukkit.craftbukkit.v1_12_R1.scoreboard.CraftTeam")
|
||||
.getDeclaredField("team"))
|
||||
.setAccessible(true);
|
||||
((ScoreboardTeam) field2.get(team)).getPlayerNameSet().remove(text);
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendPacket(Player player, Packet packet) {
|
||||
this.getEntity(player).playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
public EntityPlayer getEntity(Player player) {
|
||||
return ((CraftPlayer) player).getHandle();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
package me.creaxx.api.nms.impl;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
import me.creaxx.api.nms.INMSImpl;
|
||||
|
||||
import net.minecraft.server.v1_16_R3.DedicatedPlayerList;
|
||||
import net.minecraft.server.v1_16_R3.EntityCreeper;
|
||||
import net.minecraft.server.v1_16_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_16_R3.EntityTypes;
|
||||
import net.minecraft.server.v1_16_R3.IChatBaseComponent.ChatSerializer;
|
||||
import net.minecraft.server.v1_16_R3.Packet;
|
||||
import net.minecraft.server.v1_16_R3.PacketPlayOutAttachEntity;
|
||||
import net.minecraft.server.v1_16_R3.PacketPlayOutEntityDestroy;
|
||||
import net.minecraft.server.v1_16_R3.PacketPlayOutPlayerInfo;
|
||||
import net.minecraft.server.v1_16_R3.PacketPlayOutPlayerInfo.EnumPlayerInfoAction;
|
||||
import net.minecraft.server.v1_16_R3.PacketPlayOutPlayerListHeaderFooter;
|
||||
import net.minecraft.server.v1_16_R3.PacketPlayOutSpawnEntityLiving;
|
||||
import net.minecraft.server.v1_16_R3.PlayerList;
|
||||
import net.minecraft.server.v1_16_R3.Scoreboard;
|
||||
import net.minecraft.server.v1_16_R3.ScoreboardTeam;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.scoreboard.CraftScoreboard;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.disguise.IDisguiseData;
|
||||
import xyz.refinedev.phoenix.profile.disguise.ISkin;
|
||||
import xyz.refinedev.phoenix.profile.disguise.Skin;
|
||||
import xyz.refinedev.phoenix.utils.DisguiseUtil;
|
||||
import xyz.refinedev.phoenix.utils.ExceptionUtil;
|
||||
import xyz.refinedev.phoenix.utils.Utilities;
|
||||
import xyz.refinedev.phoenix.utils.general.Tasks;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class v1_16_R3 implements INMSImpl {
|
||||
|
||||
private Map<UUID, Integer> creeperIds = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void disguise(IProfile profile, boolean matches) {
|
||||
Player player = Bukkit.getPlayer(profile.getUniqueId());
|
||||
IDisguiseData disguiseData = profile.getDisguiseData();
|
||||
EntityPlayer entityPlayer;
|
||||
DisguiseUtil.updateName(
|
||||
(entityPlayer = this.getEntity(player)).getProfile(),
|
||||
disguiseData.getDisguiseName());
|
||||
entityPlayer.displayName = disguiseData.getDisguiseName();
|
||||
try {
|
||||
DedicatedPlayerList playerList =
|
||||
((CraftServer) Bukkit.getServer()).getHandle().getServer().getPlayerList();
|
||||
Field field;
|
||||
(field = PlayerList.class.getDeclaredField("playersByName")).setAccessible(true);
|
||||
Map entries;
|
||||
(entries = (Map) field.get(playerList)).remove(profile.getName());
|
||||
entries.put(disguiseData.getDisguiseName(), entityPlayer);
|
||||
} catch (Exception exception) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.log(Level.SEVERE, ExceptionUtil.getStackTrace(exception));
|
||||
}
|
||||
this.updateSkin(player, disguiseData.getDisguiseSkin(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undisguise(IProfile profile) {
|
||||
Player player = Bukkit.getPlayer(profile.getUniqueId());
|
||||
IDisguiseData disguiseData = profile.getDisguiseData();
|
||||
EntityPlayer entityPlayer;
|
||||
DisguiseUtil.updateName(
|
||||
(entityPlayer = this.getEntity(player)).getProfile(), disguiseData.getRealName());
|
||||
entityPlayer.displayName = disguiseData.getRealName();
|
||||
try {
|
||||
DedicatedPlayerList playerList =
|
||||
((CraftServer) Bukkit.getServer()).getHandle().getServer().getPlayerList();
|
||||
Field field;
|
||||
(field = PlayerList.class.getDeclaredField("playersByName")).setAccessible(true);
|
||||
Map entries;
|
||||
(entries = (Map) field.get(playerList)).remove(disguiseData.getDisguiseName());
|
||||
entries.put(disguiseData.getRealName(), entityPlayer);
|
||||
} catch (Exception exception) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.log(Level.SEVERE, ExceptionUtil.getStackTrace(exception));
|
||||
}
|
||||
this.updateSkin(player, disguiseData.getRealSkin(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSkin(Player player, ISkin skin, boolean matches) {
|
||||
EntityPlayer entity = this.getEntity(player);
|
||||
Location location = player.getLocation().clone();
|
||||
GameProfile profile = entity.getProfile();
|
||||
ArrayList<org.bukkit.entity.Player> values = new ArrayList<>();
|
||||
Iterator<org.bukkit.entity.Player> iterator2 = Utilities.getOnlinePlayers().iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Player player2;
|
||||
if ((player2 = (Player) iterator2.next()).canSee(player)) {
|
||||
values.add(player2);
|
||||
player2.hidePlayer(player);
|
||||
}
|
||||
}
|
||||
profile.getProperties().clear();
|
||||
profile.getProperties()
|
||||
.put("textures", new Property("textures", skin.getValue(), skin.getSignature()));
|
||||
Tasks.runLater(
|
||||
() -> {
|
||||
Iterator iterator3 = values.iterator();
|
||||
while (iterator3.hasNext()) {
|
||||
((Player) iterator3.next()).showPlayer(player);
|
||||
}
|
||||
},
|
||||
5L);
|
||||
entity.playerConnection.sendPacket(
|
||||
new PacketPlayOutPlayerInfo(
|
||||
EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[] {entity}));
|
||||
entity.playerConnection.sendPacket(
|
||||
new PacketPlayOutPlayerInfo(
|
||||
EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] {entity}));
|
||||
player.spigot().respawn();
|
||||
player.getInventory().setItemInHand(player.getItemInHand());
|
||||
player.updateInventory();
|
||||
player.teleport(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateHeaderFooter(Player player, String text, String text2) {
|
||||
EntityPlayer handle = ((CraftPlayer) player).getHandle();
|
||||
PacketPlayOutPlayerListHeaderFooter packetPlayOutPlayerListHeaderFooter;
|
||||
(packetPlayOutPlayerListHeaderFooter = new PacketPlayOutPlayerListHeaderFooter()).header =
|
||||
ChatSerializer.a("{\"text\":\"" + text + "\"}");
|
||||
packetPlayOutPlayerListHeaderFooter.footer =
|
||||
ChatSerializer.a("{\"text\":\"" + text2 + "\"}");
|
||||
handle.playerConnection.sendPacket(packetPlayOutPlayerListHeaderFooter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack itemWithBase64(ItemStack itemStack, String text) {
|
||||
if (itemStack == null || text == null || text.isEmpty()) {
|
||||
return itemStack;
|
||||
}
|
||||
if (!(itemStack.getItemMeta() instanceof SkullMeta)) {
|
||||
return itemStack;
|
||||
}
|
||||
SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta();
|
||||
UUID uUID =
|
||||
new UUID(
|
||||
text.substring(text.length() - 20).hashCode(),
|
||||
text.substring(text.length() - 10).hashCode());
|
||||
GameProfile gameProfile;
|
||||
(gameProfile = new GameProfile(uUID, "Player"))
|
||||
.getProperties()
|
||||
.put("textures", new Property("textures", text));
|
||||
try {
|
||||
Field field = skullMeta.getClass().getDeclaredField("profile");
|
||||
field.setAccessible(true);
|
||||
field.set(skullMeta, gameProfile);
|
||||
} catch (ReflectiveOperationException exception) {
|
||||
throw ExceptionUtil.propagate(exception);
|
||||
}
|
||||
itemStack.setItemMeta(skullMeta);
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISkin getPlayerSkin(Player player) {
|
||||
String text = "";
|
||||
String text2 = "";
|
||||
Iterator<com.mojang.authlib.properties.Property> iterator2 =
|
||||
this.getEntity(player).getProfile().getProperties().get("textures").iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Property property;
|
||||
text = (property = (Property) iterator2.next()).getValue();
|
||||
text2 = property.getSignature();
|
||||
}
|
||||
return new Skin(player.getName(), text, text2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sitPlayer(Player player) {
|
||||
if (!this.creeperIds.containsKey(player.getUniqueId())) {
|
||||
player.setAllowFlight(true);
|
||||
Location location = player.getLocation();
|
||||
EntityPlayer entity = this.getEntity(player);
|
||||
EntityCreeper entityCreeper;
|
||||
(entityCreeper = new EntityCreeper(EntityTypes.CREEPER, entity.getWorld()))
|
||||
.setLocation(
|
||||
location.getX(),
|
||||
location.getY(),
|
||||
location.getX(),
|
||||
location.getYaw(),
|
||||
location.getPitch());
|
||||
entityCreeper.setInvisible(true);
|
||||
entityCreeper.setCustomNameVisible(false);
|
||||
this.creeperIds.put(player.getUniqueId(), entityCreeper.getId());
|
||||
PacketPlayOutSpawnEntityLiving packetPlayOutSpawnEntityLiving =
|
||||
new PacketPlayOutSpawnEntityLiving(entityCreeper);
|
||||
this.sendPacket(player, packetPlayOutSpawnEntityLiving);
|
||||
PacketPlayOutAttachEntity packetPlayOutAttachEntity =
|
||||
new PacketPlayOutAttachEntity(entity, entityCreeper);
|
||||
this.sendPacket(player, packetPlayOutAttachEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsitPlayer(Player player) {
|
||||
if (this.creeperIds.containsKey(player.getUniqueId())) {
|
||||
player.setAllowFlight(false);
|
||||
int value = this.creeperIds.get(player.getUniqueId());
|
||||
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy =
|
||||
new PacketPlayOutEntityDestroy(new int[] {value});
|
||||
this.sendPacket(player, packetPlayOutEntityDestroy);
|
||||
this.creeperIds.remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayerFromTeam(String text, Team team) {
|
||||
CraftScoreboard craftScoreboard = (CraftScoreboard) team.getScoreboard();
|
||||
try {
|
||||
Field field;
|
||||
(field = Scoreboard.class.getDeclaredField("teamsByPlayer")).setAccessible(true);
|
||||
((Map) field.get(craftScoreboard.getHandle())).remove(text);
|
||||
Field field2;
|
||||
(field2 =
|
||||
Class.forName("org.bukkit.craftbukkit.v1_16_R3.scoreboard.CraftTeam")
|
||||
.getDeclaredField("team"))
|
||||
.setAccessible(true);
|
||||
((ScoreboardTeam) field2.get(team)).getPlayerNameSet().remove(text);
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendPacket(Player player, Packet packet) {
|
||||
this.getEntity(player).playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
public EntityPlayer getEntity(Player player) {
|
||||
return ((CraftPlayer) player).getHandle();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
package me.creaxx.api.nms.impl;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
import me.creaxx.api.nms.INMSImpl;
|
||||
|
||||
import net.minecraft.network.chat.IChatBaseComponent.ChatSerializer;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutPlayerInfo;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutPlayerInfo.EnumPlayerInfoAction;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutPlayerListHeaderFooter;
|
||||
import net.minecraft.server.level.EntityPlayer;
|
||||
import net.minecraft.server.players.PlayerList;
|
||||
import net.minecraft.world.scores.Scoreboard;
|
||||
import net.minecraft.world.scores.ScoreboardTeam;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.scoreboard.CraftScoreboard;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.disguise.IDisguiseData;
|
||||
import xyz.refinedev.phoenix.profile.disguise.ISkin;
|
||||
import xyz.refinedev.phoenix.profile.disguise.Skin;
|
||||
import xyz.refinedev.phoenix.utils.DisguiseUtil;
|
||||
import xyz.refinedev.phoenix.utils.ExceptionUtil;
|
||||
import xyz.refinedev.phoenix.utils.Utilities;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class v1_18_R2 implements INMSImpl {
|
||||
|
||||
@Override
|
||||
public void disguise(IProfile profile, boolean matches) {
|
||||
Player player = Bukkit.getPlayer(profile.getUniqueId());
|
||||
IDisguiseData disguiseData = profile.getDisguiseData();
|
||||
EntityPlayer entity = this.getEntity(player);
|
||||
DisguiseUtil.updateName(
|
||||
((CraftPlayer) player).getProfile(), disguiseData.getDisguiseName());
|
||||
entity.displayName = disguiseData.getDisguiseName();
|
||||
try {
|
||||
PlayerList playerList = ((CraftServer) Bukkit.getServer()).getHandle().b().ac();
|
||||
Field field;
|
||||
(field = PlayerList.class.getDeclaredField("playersByName")).setAccessible(true);
|
||||
Map entries;
|
||||
(entries = (Map) field.get(playerList)).remove(profile.getName());
|
||||
entries.put(disguiseData.getDisguiseName(), entity);
|
||||
} catch (Exception exception) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.log(Level.SEVERE, ExceptionUtil.getStackTrace(exception));
|
||||
}
|
||||
this.updateSkin(player, disguiseData.getDisguiseSkin(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undisguise(IProfile profile) {
|
||||
Player player = Bukkit.getPlayer(profile.getUniqueId());
|
||||
IDisguiseData disguiseData = profile.getDisguiseData();
|
||||
EntityPlayer entity = this.getEntity(player);
|
||||
DisguiseUtil.updateName(((CraftPlayer) player).getProfile(), disguiseData.getRealName());
|
||||
entity.displayName = disguiseData.getRealName();
|
||||
try {
|
||||
PlayerList playerList = ((CraftServer) Bukkit.getServer()).getHandle().b().ac();
|
||||
Field field;
|
||||
(field = PlayerList.class.getDeclaredField("playersByName")).setAccessible(true);
|
||||
Map entries;
|
||||
(entries = (Map) field.get(playerList)).remove(disguiseData.getDisguiseName());
|
||||
entries.put(disguiseData.getRealName(), entity);
|
||||
} catch (Exception exception) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.log(Level.SEVERE, ExceptionUtil.getStackTrace(exception));
|
||||
}
|
||||
this.updateSkin(player, disguiseData.getRealSkin(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSkin(Player player, ISkin skin, boolean matches) {
|
||||
EntityPlayer entity = this.getEntity(player);
|
||||
Location location = player.getLocation().clone();
|
||||
GameProfile gameProfile;
|
||||
(gameProfile = ((CraftPlayer) player).getProfile()).getProperties().clear();
|
||||
gameProfile
|
||||
.getProperties()
|
||||
.put("textures", new Property("textures", skin.getValue(), skin.getSignature()));
|
||||
entity.b.a(
|
||||
new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.b, new EntityPlayer[] {entity}));
|
||||
entity.b.a(
|
||||
new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.a, new EntityPlayer[] {entity}));
|
||||
player.spigot().respawn();
|
||||
player.getInventory().setItemInHand(player.getItemInHand());
|
||||
player.updateInventory();
|
||||
player.teleport(location);
|
||||
Iterator<org.bukkit.entity.Player> iterator2 = Utilities.getOnlinePlayers().iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Player player2;
|
||||
if ((player2 = (Player) iterator2.next()).canSee(player)) {
|
||||
player2.hidePlayer(player);
|
||||
player2.showPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateHeaderFooter(Player player, String text, String text2) {
|
||||
EntityPlayer handle = ((CraftPlayer) player).getHandle();
|
||||
PacketPlayOutPlayerListHeaderFooter packetPlayOutPlayerListHeaderFooter =
|
||||
new PacketPlayOutPlayerListHeaderFooter(
|
||||
ChatSerializer.a("{\"text\":\"" + text + "\"}"),
|
||||
ChatSerializer.a("{\"text\":\"" + text2 + "\"}"));
|
||||
handle.b.a(packetPlayOutPlayerListHeaderFooter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack itemWithBase64(ItemStack itemStack, String text) {
|
||||
if (itemStack == null || text == null || text.isEmpty()) {
|
||||
return itemStack;
|
||||
}
|
||||
if (!(itemStack.getItemMeta() instanceof SkullMeta)) {
|
||||
return itemStack;
|
||||
}
|
||||
SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta();
|
||||
UUID uUID =
|
||||
new UUID(
|
||||
text.substring(text.length() - 20).hashCode(),
|
||||
text.substring(text.length() - 10).hashCode());
|
||||
GameProfile gameProfile;
|
||||
(gameProfile = new GameProfile(uUID, "Player"))
|
||||
.getProperties()
|
||||
.put("textures", new Property("textures", text));
|
||||
try {
|
||||
Field field = skullMeta.getClass().getDeclaredField("profile");
|
||||
field.setAccessible(true);
|
||||
field.set(skullMeta, gameProfile);
|
||||
} catch (ReflectiveOperationException exception) {
|
||||
throw ExceptionUtil.propagate(exception);
|
||||
}
|
||||
itemStack.setItemMeta(skullMeta);
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISkin getPlayerSkin(Player player) {
|
||||
String text = "";
|
||||
String text2 = "";
|
||||
Iterator<com.mojang.authlib.properties.Property> iterator2 =
|
||||
((CraftPlayer) player).getProfile().getProperties().get("textures").iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Property property;
|
||||
text = (property = (Property) iterator2.next()).getValue();
|
||||
text2 = property.getSignature();
|
||||
}
|
||||
return new Skin(player.getName(), text, text2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sitPlayer(Player player) {}
|
||||
|
||||
@Override
|
||||
public void unsitPlayer(Player player) {}
|
||||
|
||||
@Override
|
||||
public void removePlayerFromTeam(String text, Team team) {
|
||||
CraftScoreboard craftScoreboard = (CraftScoreboard) team.getScoreboard();
|
||||
try {
|
||||
Field field;
|
||||
(field = Scoreboard.class.getDeclaredField("m")).setAccessible(true);
|
||||
((Map) field.get(craftScoreboard.getHandle())).remove(text);
|
||||
Field field2;
|
||||
(field2 =
|
||||
Class.forName("org.bukkit.craftbukkit.v1_18_R2.scoreboard.CraftTeam")
|
||||
.getDeclaredField("team"))
|
||||
.setAccessible(true);
|
||||
((ScoreboardTeam) field2.get(team)).g().remove(text);
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
}
|
||||
|
||||
public EntityPlayer getEntity(Player player) {
|
||||
return ((CraftPlayer) player).getHandle();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
package me.creaxx.api.nms.impl;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
import me.creaxx.api.nms.INMSImpl;
|
||||
|
||||
import net.minecraft.network.chat.IChatBaseComponent.ChatSerializer;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket.a;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutPlayerListHeaderFooter;
|
||||
import net.minecraft.server.level.EntityPlayer;
|
||||
import net.minecraft.server.players.PlayerList;
|
||||
import net.minecraft.world.scores.Scoreboard;
|
||||
import net.minecraft.world.scores.ScoreboardTeam;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.scoreboard.CraftScoreboard;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.disguise.IDisguiseData;
|
||||
import xyz.refinedev.phoenix.profile.disguise.ISkin;
|
||||
import xyz.refinedev.phoenix.profile.disguise.Skin;
|
||||
import xyz.refinedev.phoenix.utils.DisguiseUtil;
|
||||
import xyz.refinedev.phoenix.utils.ExceptionUtil;
|
||||
import xyz.refinedev.phoenix.utils.Utilities;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class v1_19_R3 implements INMSImpl {
|
||||
|
||||
@Override
|
||||
public void disguise(IProfile profile, boolean matches) {
|
||||
Player player = Bukkit.getPlayer(profile.getUniqueId());
|
||||
IDisguiseData disguiseData = profile.getDisguiseData();
|
||||
EntityPlayer entityPlayer;
|
||||
DisguiseUtil.updateName(
|
||||
(entityPlayer = this.getEntity(player)).fI(), disguiseData.getDisguiseName());
|
||||
entityPlayer.displayName = disguiseData.getRealName();
|
||||
try {
|
||||
PlayerList playerList = ((CraftServer) Bukkit.getServer()).getHandle().b().ac();
|
||||
Field field;
|
||||
(field = PlayerList.class.getDeclaredField("playersByName")).setAccessible(true);
|
||||
Map entries;
|
||||
(entries = (Map) field.get(playerList)).remove(profile.getName());
|
||||
entries.put(disguiseData.getDisguiseName(), entityPlayer);
|
||||
} catch (Exception exception) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.log(Level.SEVERE, ExceptionUtil.getStackTrace(exception));
|
||||
}
|
||||
this.updateSkin(player, disguiseData.getDisguiseSkin(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undisguise(IProfile profile) {
|
||||
Player player = Bukkit.getPlayer(profile.getUniqueId());
|
||||
IDisguiseData disguiseData = profile.getDisguiseData();
|
||||
EntityPlayer entityPlayer;
|
||||
DisguiseUtil.updateName(
|
||||
(entityPlayer = this.getEntity(player)).fI(), disguiseData.getRealName());
|
||||
entityPlayer.displayName = disguiseData.getRealName();
|
||||
try {
|
||||
PlayerList playerList = ((CraftServer) Bukkit.getServer()).getHandle().b().ac();
|
||||
Field field;
|
||||
(field = PlayerList.class.getDeclaredField("playersByName")).setAccessible(true);
|
||||
Map entries;
|
||||
(entries = (Map) field.get(playerList)).remove(disguiseData.getDisguiseName());
|
||||
entries.put(disguiseData.getRealName(), entityPlayer);
|
||||
} catch (Exception exception) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.log(Level.SEVERE, ExceptionUtil.getStackTrace(exception));
|
||||
}
|
||||
this.updateSkin(player, disguiseData.getRealSkin(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSkin(Player player, ISkin skin, boolean matches) {
|
||||
EntityPlayer entity = this.getEntity(player);
|
||||
Location location = player.getLocation().clone();
|
||||
GameProfile gameProfile;
|
||||
(gameProfile = entity.fI()).getProperties().clear();
|
||||
gameProfile
|
||||
.getProperties()
|
||||
.put("textures", new Property("textures", skin.getValue(), skin.getSignature()));
|
||||
entity.b.a(
|
||||
new ClientboundPlayerInfoRemovePacket(
|
||||
Collections.singletonList(player.getUniqueId())));
|
||||
entity.b.a(new ClientboundPlayerInfoUpdatePacket(a.b, entity));
|
||||
entity.b.a(new ClientboundPlayerInfoUpdatePacket(a.d, entity));
|
||||
player.spigot().respawn();
|
||||
player.getInventory().setItemInHand(player.getItemInHand());
|
||||
player.updateInventory();
|
||||
player.teleport(location);
|
||||
Iterator<org.bukkit.entity.Player> iterator2 = Utilities.getOnlinePlayers().iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Player player2;
|
||||
if ((player2 = (Player) iterator2.next()).canSee(player)) {
|
||||
player2.hidePlayer(player);
|
||||
player2.showPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateHeaderFooter(Player player, String text, String text2) {
|
||||
EntityPlayer handle = ((CraftPlayer) player).getHandle();
|
||||
PacketPlayOutPlayerListHeaderFooter packetPlayOutPlayerListHeaderFooter =
|
||||
new PacketPlayOutPlayerListHeaderFooter(
|
||||
ChatSerializer.a("{\"text\":\"" + text + "\"}"),
|
||||
ChatSerializer.a("{\"text\":\"" + text2 + "\"}"));
|
||||
handle.b.a(packetPlayOutPlayerListHeaderFooter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack itemWithBase64(ItemStack itemStack, String text) {
|
||||
if (itemStack == null || text == null || text.isEmpty()) {
|
||||
return itemStack;
|
||||
}
|
||||
if (!(itemStack.getItemMeta() instanceof SkullMeta)) {
|
||||
return itemStack;
|
||||
}
|
||||
SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta();
|
||||
UUID uUID =
|
||||
new UUID(
|
||||
text.substring(text.length() - 20).hashCode(),
|
||||
text.substring(text.length() - 10).hashCode());
|
||||
GameProfile gameProfile;
|
||||
(gameProfile = new GameProfile(uUID, "Player"))
|
||||
.getProperties()
|
||||
.put("textures", new Property("textures", text));
|
||||
try {
|
||||
Field field = skullMeta.getClass().getDeclaredField("profile");
|
||||
field.setAccessible(true);
|
||||
field.set(skullMeta, gameProfile);
|
||||
} catch (ReflectiveOperationException exception) {
|
||||
throw ExceptionUtil.propagate(exception);
|
||||
}
|
||||
itemStack.setItemMeta(skullMeta);
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISkin getPlayerSkin(Player player) {
|
||||
String text = "";
|
||||
String text2 = "";
|
||||
Iterator<com.mojang.authlib.properties.Property> iterator2 =
|
||||
((CraftPlayer) player).getProfile().getProperties().get("textures").iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Property property;
|
||||
text = (property = (Property) iterator2.next()).getValue();
|
||||
text2 = property.getSignature();
|
||||
}
|
||||
return new Skin(player.getName(), text, text2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sitPlayer(Player player) {}
|
||||
|
||||
@Override
|
||||
public void unsitPlayer(Player player) {}
|
||||
|
||||
@Override
|
||||
public void removePlayerFromTeam(String text, Team team) {
|
||||
CraftScoreboard craftScoreboard = (CraftScoreboard) team.getScoreboard();
|
||||
try {
|
||||
Field field;
|
||||
(field = Scoreboard.class.getDeclaredField("m")).setAccessible(true);
|
||||
((Map) field.get(craftScoreboard.getHandle())).remove(text);
|
||||
Field field2;
|
||||
(field2 =
|
||||
Class.forName("org.bukkit.craftbukkit.v1_19_R3.scoreboard.CraftTeam")
|
||||
.getDeclaredField("team"))
|
||||
.setAccessible(true);
|
||||
((ScoreboardTeam) field2.get(team)).g().remove(text);
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
}
|
||||
|
||||
public EntityPlayer getEntity(Player player) {
|
||||
return ((CraftPlayer) player).getHandle();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
package me.creaxx.api.nms.impl;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
|
||||
import me.creaxx.api.nms.INMSImpl;
|
||||
|
||||
import net.minecraft.network.chat.IChatBaseComponent.ChatSerializer;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket.a;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutPlayerListHeaderFooter;
|
||||
import net.minecraft.server.level.EntityPlayer;
|
||||
import net.minecraft.server.players.PlayerList;
|
||||
import net.minecraft.world.scores.Scoreboard;
|
||||
import net.minecraft.world.scores.ScoreboardTeam;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_20_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_20_R3.profile.CraftPlayerProfile;
|
||||
import org.bukkit.craftbukkit.v1_20_R3.scoreboard.CraftScoreboard;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.disguise.IDisguiseData;
|
||||
import xyz.refinedev.phoenix.profile.disguise.ISkin;
|
||||
import xyz.refinedev.phoenix.profile.disguise.Skin;
|
||||
import xyz.refinedev.phoenix.utils.DisguiseUtil;
|
||||
import xyz.refinedev.phoenix.utils.ExceptionUtil;
|
||||
import xyz.refinedev.phoenix.utils.Utilities;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class v1_20_R3 implements INMSImpl {
|
||||
|
||||
@Override
|
||||
public void disguise(IProfile profile, boolean matches) {
|
||||
Player player = Bukkit.getPlayer(profile.getUniqueId());
|
||||
IDisguiseData disguiseData = profile.getDisguiseData();
|
||||
EntityPlayer entityPlayer;
|
||||
DisguiseUtil.updateName(
|
||||
(entityPlayer = this.getEntity(player)).fR(), disguiseData.getDisguiseName());
|
||||
entityPlayer.displayName = disguiseData.getRealName();
|
||||
try {
|
||||
PlayerList playerList = ((CraftServer) Bukkit.getServer()).getHandle().b().ae();
|
||||
Field field;
|
||||
(field = PlayerList.class.getDeclaredField("playersByName")).setAccessible(true);
|
||||
Map entries;
|
||||
(entries = (Map) field.get(playerList)).remove(profile.getName());
|
||||
entries.put(disguiseData.getDisguiseName(), entityPlayer);
|
||||
} catch (Exception exception) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.log(Level.SEVERE, ExceptionUtil.getStackTrace(exception));
|
||||
}
|
||||
this.updateSkin(player, disguiseData.getDisguiseSkin(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undisguise(IProfile profile) {
|
||||
Player player = Bukkit.getPlayer(profile.getUniqueId());
|
||||
IDisguiseData disguiseData = profile.getDisguiseData();
|
||||
EntityPlayer entityPlayer;
|
||||
DisguiseUtil.updateName(
|
||||
(entityPlayer = this.getEntity(player)).fR(), disguiseData.getRealName());
|
||||
entityPlayer.displayName = disguiseData.getRealName();
|
||||
try {
|
||||
PlayerList playerList = ((CraftServer) Bukkit.getServer()).getHandle().b().ae();
|
||||
Field field;
|
||||
(field = PlayerList.class.getDeclaredField("playersByName")).setAccessible(true);
|
||||
Map entries;
|
||||
(entries = (Map) field.get(playerList)).remove(disguiseData.getDisguiseName());
|
||||
entries.put(disguiseData.getRealName(), entityPlayer);
|
||||
} catch (Exception exception) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.log(Level.SEVERE, ExceptionUtil.getStackTrace(exception));
|
||||
}
|
||||
this.updateSkin(player, disguiseData.getRealSkin(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSkin(Player player, ISkin skin, boolean matches) {
|
||||
EntityPlayer entity = this.getEntity(player);
|
||||
Location location = player.getLocation().clone();
|
||||
GameProfile gameProfile;
|
||||
(gameProfile = entity.fR()).getProperties().clear();
|
||||
gameProfile
|
||||
.getProperties()
|
||||
.put("textures", new Property("textures", skin.getValue(), skin.getSignature()));
|
||||
entity.c.a(
|
||||
new ClientboundPlayerInfoRemovePacket(
|
||||
Collections.singletonList(player.getUniqueId())));
|
||||
entity.c.a(new ClientboundPlayerInfoUpdatePacket(a.b, entity));
|
||||
entity.c.a(new ClientboundPlayerInfoUpdatePacket(a.d, entity));
|
||||
player.spigot().respawn();
|
||||
player.getInventory().setItemInHand(player.getItemInHand());
|
||||
player.updateInventory();
|
||||
player.teleport(location);
|
||||
Iterator<org.bukkit.entity.Player> iterator2 = Utilities.getOnlinePlayers().iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Player player2;
|
||||
if ((player2 = (Player) iterator2.next()).canSee(player)) {
|
||||
player2.hidePlayer(player);
|
||||
player2.showPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateHeaderFooter(Player player, String text, String text2) {
|
||||
EntityPlayer handle = ((CraftPlayer) player).getHandle();
|
||||
PacketPlayOutPlayerListHeaderFooter packetPlayOutPlayerListHeaderFooter =
|
||||
new PacketPlayOutPlayerListHeaderFooter(
|
||||
ChatSerializer.a("{\"text\":\"" + text + "\"}"),
|
||||
ChatSerializer.a("{\"text\":\"" + text2 + "\"}"));
|
||||
handle.c.a(packetPlayOutPlayerListHeaderFooter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack itemWithBase64(ItemStack itemStack, String text) {
|
||||
if (itemStack == null || text == null || text.isEmpty()) {
|
||||
return itemStack;
|
||||
}
|
||||
if (!(itemStack.getItemMeta() instanceof SkullMeta)) {
|
||||
return itemStack;
|
||||
}
|
||||
SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta();
|
||||
UUID uUID =
|
||||
new UUID(
|
||||
text.substring(text.length() - 20).hashCode(),
|
||||
text.substring(text.length() - 10).hashCode());
|
||||
GameProfile gameProfile;
|
||||
(gameProfile = new GameProfile(uUID, "Player"))
|
||||
.getProperties()
|
||||
.put("textures", new Property("textures", text));
|
||||
skullMeta.setOwnerProfile(new CraftPlayerProfile(gameProfile));
|
||||
itemStack.setItemMeta(skullMeta);
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISkin getPlayerSkin(Player player) {
|
||||
String text = "";
|
||||
String text2 = "";
|
||||
Iterator<com.mojang.authlib.properties.Property> iterator2 =
|
||||
((CraftPlayer) player).getProfile().getProperties().get("textures").iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Property property;
|
||||
text = (property = (Property) iterator2.next()).value();
|
||||
text2 = property.signature();
|
||||
}
|
||||
return new Skin(player.getName(), text, text2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sitPlayer(Player player) {}
|
||||
|
||||
@Override
|
||||
public void unsitPlayer(Player player) {}
|
||||
|
||||
@Override
|
||||
public void removePlayerFromTeam(String text, Team team) {
|
||||
CraftScoreboard craftScoreboard = (CraftScoreboard) team.getScoreboard();
|
||||
try {
|
||||
Field field;
|
||||
(field = Scoreboard.class.getDeclaredField("h")).setAccessible(true);
|
||||
((Object2ObjectMap) field.get(craftScoreboard.getHandle())).remove(text);
|
||||
Field field2;
|
||||
(field2 =
|
||||
Class.forName("org.bukkit.craftbukkit.v1_20_R3.scoreboard.CraftTeam")
|
||||
.getDeclaredField("team"))
|
||||
.setAccessible(true);
|
||||
((ScoreboardTeam) field2.get(team)).g().remove(text);
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
}
|
||||
|
||||
public EntityPlayer getEntity(Player player) {
|
||||
return ((CraftPlayer) player).getHandle();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
package me.creaxx.api.nms.impl;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
|
||||
import me.creaxx.api.NMSHandler;
|
||||
import me.creaxx.api.nms.INMSImpl;
|
||||
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
|
||||
import net.minecraft.server.dedicated.DedicatedPlayerList;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.players.PlayerList;
|
||||
import net.minecraft.world.scores.PlayerTeam;
|
||||
import net.minecraft.world.scores.Scoreboard;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.profile.CraftPlayerProfile;
|
||||
import org.bukkit.craftbukkit.scoreboard.CraftScoreboard;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.disguise.IDisguiseData;
|
||||
import xyz.refinedev.phoenix.profile.disguise.ISkin;
|
||||
import xyz.refinedev.phoenix.profile.disguise.Skin;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.DisguiseUtil;
|
||||
import xyz.refinedev.phoenix.utils.ExceptionUtil;
|
||||
import xyz.refinedev.phoenix.utils.Utilities;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class v1_21_R1 implements INMSImpl {
|
||||
|
||||
@Override
|
||||
public void disguise(IProfile profile, boolean matches) {
|
||||
Player player = Bukkit.getPlayer(profile.getUniqueId());
|
||||
IDisguiseData disguiseData = profile.getDisguiseData();
|
||||
ServerPlayer serverPlayer;
|
||||
DisguiseUtil.updateName(
|
||||
(serverPlayer = this.getEntity(player)).getGameProfile(),
|
||||
disguiseData.getDisguiseName());
|
||||
serverPlayer.displayName = disguiseData.getRealName();
|
||||
try {
|
||||
DedicatedPlayerList playerList =
|
||||
((CraftServer) Bukkit.getServer()).getHandle().getServer().getPlayerList();
|
||||
Field field;
|
||||
(field = PlayerList.class.getDeclaredField("playersByName")).setAccessible(true);
|
||||
Map entries;
|
||||
(entries = (Map) field.get(playerList)).remove(profile.getName());
|
||||
entries.put(disguiseData.getDisguiseName(), serverPlayer);
|
||||
} catch (Exception exception) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.log(Level.SEVERE, ExceptionUtil.getStackTrace(exception));
|
||||
}
|
||||
this.updateSkin(player, disguiseData.getDisguiseSkin(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undisguise(IProfile profile) {
|
||||
Player player = Bukkit.getPlayer(profile.getUniqueId());
|
||||
IDisguiseData disguiseData = profile.getDisguiseData();
|
||||
ServerPlayer serverPlayer;
|
||||
DisguiseUtil.updateName(
|
||||
(serverPlayer = this.getEntity(player)).getGameProfile(),
|
||||
disguiseData.getRealName());
|
||||
serverPlayer.displayName = disguiseData.getRealName();
|
||||
try {
|
||||
DedicatedPlayerList playerList =
|
||||
((CraftServer) Bukkit.getServer()).getHandle().getServer().getPlayerList();
|
||||
Field field;
|
||||
(field = PlayerList.class.getDeclaredField("playersByName")).setAccessible(true);
|
||||
Map entries;
|
||||
(entries = (Map) field.get(playerList)).remove(disguiseData.getDisguiseName());
|
||||
entries.put(disguiseData.getRealName(), serverPlayer);
|
||||
} catch (Exception exception) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.log(Level.SEVERE, ExceptionUtil.getStackTrace(exception));
|
||||
}
|
||||
this.updateSkin(player, disguiseData.getRealSkin(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSkin(Player player, ISkin skin, boolean matches) {
|
||||
ServerPlayer entity = this.getEntity(player);
|
||||
Location location = player.getLocation().clone();
|
||||
GameProfile gameProfile;
|
||||
(gameProfile = entity.getGameProfile()).getProperties().clear();
|
||||
gameProfile
|
||||
.getProperties()
|
||||
.put("textures", new Property("textures", skin.getValue(), skin.getSignature()));
|
||||
entity.connection.send(
|
||||
new ClientboundPlayerInfoRemovePacket(
|
||||
Collections.singletonList(entity.getGameProfile().getId())));
|
||||
entity.connection.send(
|
||||
ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(
|
||||
Collections.singletonList(entity)));
|
||||
player.spigot().respawn();
|
||||
player.getInventory().setItemInHand(player.getItemInHand());
|
||||
player.updateInventory();
|
||||
NMSHandler.getInstance().getTeleportAPI().teleport(player, location);
|
||||
Iterator<org.bukkit.entity.Player> iterator2 = Utilities.getOnlinePlayers().iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Player player2;
|
||||
if ((player2 = (Player) iterator2.next()).canSee(player)) {
|
||||
player2.hidePlayer(player);
|
||||
player2.showPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateHeaderFooter(Player player, String text, String text2) {
|
||||
player.setPlayerListHeaderFooter(Color.translate(text), Color.translate(text2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack itemWithBase64(ItemStack itemStack, String text) {
|
||||
if (itemStack == null || text == null || text.isEmpty()) {
|
||||
return itemStack;
|
||||
}
|
||||
if (!(itemStack.getItemMeta() instanceof SkullMeta)) {
|
||||
return itemStack;
|
||||
}
|
||||
SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta();
|
||||
UUID uUID =
|
||||
new UUID(
|
||||
text.substring(text.length() - 20).hashCode(),
|
||||
text.substring(text.length() - 10).hashCode());
|
||||
GameProfile gameProfile;
|
||||
(gameProfile = new GameProfile(uUID, "Player"))
|
||||
.getProperties()
|
||||
.put("textures", new Property("textures", text));
|
||||
skullMeta.setOwnerProfile(new CraftPlayerProfile(gameProfile));
|
||||
itemStack.setItemMeta(skullMeta);
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISkin getPlayerSkin(Player player) {
|
||||
String text = "";
|
||||
String text2 = "";
|
||||
Iterator<com.mojang.authlib.properties.Property> iterator2 =
|
||||
((CraftPlayer) player).getProfile().getProperties().get("textures").iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Property property;
|
||||
text = (property = (Property) iterator2.next()).value();
|
||||
text2 = property.signature();
|
||||
}
|
||||
return new Skin(player.getName(), text, text2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sitPlayer(Player player) {}
|
||||
|
||||
@Override
|
||||
public void unsitPlayer(Player player) {}
|
||||
|
||||
@Override
|
||||
public void removePlayerFromTeam(String text, Team team) {
|
||||
CraftScoreboard craftScoreboard = (CraftScoreboard) team.getScoreboard();
|
||||
try {
|
||||
Field field;
|
||||
(field = Scoreboard.class.getDeclaredField("teamsByPlayer")).setAccessible(true);
|
||||
((Object2ObjectMap) field.get(craftScoreboard.getHandle())).remove(text);
|
||||
Field field2;
|
||||
(field2 =
|
||||
Class.forName("org.bukkit.craftbukkit.scoreboard.CraftTeam")
|
||||
.getDeclaredField("team"))
|
||||
.setAccessible(true);
|
||||
((PlayerTeam) field2.get(team)).getPlayers().remove(text);
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
}
|
||||
|
||||
public ServerPlayer getEntity(Player player) {
|
||||
return ((CraftPlayer) player).getHandle();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
package me.creaxx.api.nms.impl;
|
||||
|
||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
import com.destroystokyo.paper.profile.ProfileProperty;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
|
||||
import me.creaxx.api.NMSHandler;
|
||||
import me.creaxx.api.nms.INMSImpl;
|
||||
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
|
||||
import net.minecraft.server.dedicated.DedicatedPlayerList;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.players.PlayerList;
|
||||
import net.minecraft.world.scores.PlayerTeam;
|
||||
import net.minecraft.world.scores.Scoreboard;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.scoreboard.CraftScoreboard;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.disguise.IDisguiseData;
|
||||
import xyz.refinedev.phoenix.profile.disguise.ISkin;
|
||||
import xyz.refinedev.phoenix.profile.disguise.Skin;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.DisguiseUtil;
|
||||
import xyz.refinedev.phoenix.utils.ExceptionUtil;
|
||||
import xyz.refinedev.phoenix.utils.Utilities;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class v1_21_R10 implements INMSImpl {
|
||||
|
||||
@Override
|
||||
public void disguise(IProfile profile, boolean matches) {
|
||||
Player player = Bukkit.getPlayer(profile.getUniqueId());
|
||||
IDisguiseData disguiseData = profile.getDisguiseData();
|
||||
ServerPlayer entity = this.getEntity(player);
|
||||
DisguiseUtil.updateName(player.getPlayerProfile(), disguiseData.getDisguiseName());
|
||||
entity.displayName = disguiseData.getRealName();
|
||||
try {
|
||||
DedicatedPlayerList playerList =
|
||||
((CraftServer) Bukkit.getServer()).getHandle().getServer().getPlayerList();
|
||||
Field field;
|
||||
(field = PlayerList.class.getDeclaredField("playersByName")).setAccessible(true);
|
||||
Map entries;
|
||||
(entries = (Map) field.get(playerList)).remove(profile.getName());
|
||||
entries.put(disguiseData.getDisguiseName(), entity);
|
||||
} catch (Exception exception) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.log(Level.SEVERE, ExceptionUtil.getStackTrace(exception));
|
||||
}
|
||||
this.updateSkin(player, disguiseData.getDisguiseSkin(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undisguise(IProfile profile) {
|
||||
Player player = Bukkit.getPlayer(profile.getUniqueId());
|
||||
IDisguiseData disguiseData = profile.getDisguiseData();
|
||||
ServerPlayer entity = this.getEntity(player);
|
||||
DisguiseUtil.updateName(player.getPlayerProfile(), disguiseData.getRealName());
|
||||
entity.displayName = disguiseData.getRealName();
|
||||
try {
|
||||
DedicatedPlayerList playerList =
|
||||
((CraftServer) Bukkit.getServer()).getHandle().getServer().getPlayerList();
|
||||
Field field;
|
||||
(field = PlayerList.class.getDeclaredField("playersByName")).setAccessible(true);
|
||||
Map entries;
|
||||
(entries = (Map) field.get(playerList)).remove(disguiseData.getDisguiseName());
|
||||
entries.put(disguiseData.getRealName(), entity);
|
||||
} catch (Exception exception) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.log(Level.SEVERE, ExceptionUtil.getStackTrace(exception));
|
||||
}
|
||||
this.updateSkin(player, disguiseData.getRealSkin(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSkin(Player player, ISkin skin, boolean matches) {
|
||||
ServerPlayer entity = this.getEntity(player);
|
||||
Location location = player.getLocation().clone();
|
||||
PlayerProfile playerProfile;
|
||||
(playerProfile = player.getPlayerProfile()).getProperties().clear();
|
||||
playerProfile.setProperty(
|
||||
new ProfileProperty("textures", skin.getValue(), skin.getSignature()));
|
||||
entity.connection.send(
|
||||
new ClientboundPlayerInfoRemovePacket(
|
||||
Collections.singletonList(player.getPlayerProfile().getId())));
|
||||
entity.connection.send(
|
||||
ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(
|
||||
Collections.singletonList(entity)));
|
||||
player.spigot().respawn();
|
||||
player.getInventory().setItemInHand(player.getItemInHand());
|
||||
player.updateInventory();
|
||||
NMSHandler.getInstance().getTeleportAPI().teleport(player, location);
|
||||
Iterator<org.bukkit.entity.Player> iterator2 = Utilities.getOnlinePlayers().iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Player player2;
|
||||
if ((player2 = (Player) iterator2.next()).canSee(player)) {
|
||||
player2.hidePlayer(player);
|
||||
player2.showPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateHeaderFooter(Player player, String text, String text2) {
|
||||
player.setPlayerListHeaderFooter(Color.translate(text), Color.translate(text2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack itemWithBase64(ItemStack itemStack, String text) {
|
||||
if (itemStack == null || text == null || text.isEmpty()) {
|
||||
return itemStack;
|
||||
}
|
||||
if (!(itemStack.getItemMeta() instanceof SkullMeta)) {
|
||||
return itemStack;
|
||||
}
|
||||
SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta();
|
||||
PlayerProfile playerProfile;
|
||||
(playerProfile =
|
||||
Bukkit.createProfile(
|
||||
new UUID(
|
||||
text.substring(text.length() - 20).hashCode(),
|
||||
text.substring(text.length() - 10).hashCode()),
|
||||
"Player"))
|
||||
.setProperty(new ProfileProperty("textures", text));
|
||||
skullMeta.setPlayerProfile(playerProfile);
|
||||
itemStack.setItemMeta(skullMeta);
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISkin getPlayerSkin(Player player) {
|
||||
String text = "";
|
||||
String text2 = "";
|
||||
Iterator iterator2 = player.getPlayerProfile().getProperties().iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
ProfileProperty profileProperty;
|
||||
if ((profileProperty = (ProfileProperty) iterator2.next())
|
||||
.getName()
|
||||
.equals("textures")) {
|
||||
text = profileProperty.getValue();
|
||||
text2 = profileProperty.getSignature();
|
||||
}
|
||||
}
|
||||
return new Skin(player.getName(), text, text2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sitPlayer(Player player) {}
|
||||
|
||||
@Override
|
||||
public void unsitPlayer(Player player) {}
|
||||
|
||||
@Override
|
||||
public void removePlayerFromTeam(String text, Team team) {
|
||||
CraftScoreboard craftScoreboard = (CraftScoreboard) team.getScoreboard();
|
||||
try {
|
||||
Field field;
|
||||
(field = Scoreboard.class.getDeclaredField("teamsByPlayer")).setAccessible(true);
|
||||
((Object2ObjectMap) field.get(craftScoreboard.getHandle())).remove(text);
|
||||
Field field2;
|
||||
(field2 =
|
||||
Class.forName("org.bukkit.craftbukkit.scoreboard.CraftTeam")
|
||||
.getDeclaredField("team"))
|
||||
.setAccessible(true);
|
||||
((PlayerTeam) field2.get(team)).getPlayers().remove(text);
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
}
|
||||
|
||||
public ServerPlayer getEntity(Player player) {
|
||||
return ((CraftPlayer) player).getHandle();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
package me.creaxx.api.nms.impl;
|
||||
|
||||
import me.creaxx.api.nms.INMSImpl;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.ChatSerializer;
|
||||
import net.minecraft.server.v1_7_R4.EntityCreeper;
|
||||
import net.minecraft.server.v1_7_R4.EntityPlayer;
|
||||
import net.minecraft.server.v1_7_R4.EnumGamemode;
|
||||
import net.minecraft.server.v1_7_R4.Packet;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutPlayerInfo;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutRespawn;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
|
||||
import net.minecraft.server.v1_7_R4.PlayerList;
|
||||
import net.minecraft.server.v1_7_R4.Scoreboard;
|
||||
import net.minecraft.server.v1_7_R4.ScoreboardTeam;
|
||||
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.util.com.mojang.authlib.properties.Property;
|
||||
import net.minecraft.util.org.apache.commons.lang3.StringEscapeUtils;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.scoreboard.CraftScoreboard;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.spigotmc.ProtocolInjector.PacketTabHeader;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.disguise.IDisguiseData;
|
||||
import xyz.refinedev.phoenix.profile.disguise.ISkin;
|
||||
import xyz.refinedev.phoenix.profile.disguise.Skin;
|
||||
import xyz.refinedev.phoenix.utils.DisguiseUtil;
|
||||
import xyz.refinedev.phoenix.utils.ExceptionUtil;
|
||||
import xyz.refinedev.phoenix.utils.Utilities;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class v1_7_R4 implements INMSImpl {
|
||||
|
||||
private Map<UUID, Integer> creeperIds = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void disguise(IProfile profile, boolean matches) {
|
||||
Player player = Bukkit.getPlayer(profile.getUniqueId());
|
||||
IDisguiseData disguiseData = profile.getDisguiseData();
|
||||
EntityPlayer entityPlayer;
|
||||
DisguiseUtil.updateName(
|
||||
(entityPlayer = this.getEntity(player)).getProfile(),
|
||||
disguiseData.getDisguiseName());
|
||||
entityPlayer.displayName = disguiseData.getDisguiseName();
|
||||
try {
|
||||
PlayerList playerList =
|
||||
((CraftServer) Bukkit.getServer()).getHandle().getServer().getPlayerList();
|
||||
Field field;
|
||||
(field = PlayerList.class.getDeclaredField("playerMap")).setAccessible(true);
|
||||
Map entries;
|
||||
(entries = (Map) field.get(playerList)).remove(profile.getName());
|
||||
entries.put(disguiseData.getDisguiseName(), entityPlayer);
|
||||
} catch (Exception exception) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.log(Level.SEVERE, ExceptionUtil.getStackTrace(exception));
|
||||
}
|
||||
this.updateSkin(player, disguiseData.getDisguiseSkin(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undisguise(IProfile profile) {
|
||||
Player player = Bukkit.getPlayer(profile.getUniqueId());
|
||||
IDisguiseData disguiseData = profile.getDisguiseData();
|
||||
EntityPlayer handle = ((CraftPlayer) player).getHandle();
|
||||
DisguiseUtil.updateName(((CraftPlayer) player).getProfile(), disguiseData.getRealName());
|
||||
handle.displayName = disguiseData.getRealName();
|
||||
try {
|
||||
PlayerList playerList =
|
||||
((CraftServer) Bukkit.getServer()).getHandle().getServer().getPlayerList();
|
||||
Field field;
|
||||
(field = PlayerList.class.getDeclaredField("playerMap")).setAccessible(true);
|
||||
Map entries;
|
||||
(entries = (Map) field.get(playerList)).remove(disguiseData.getDisguiseName());
|
||||
entries.put(disguiseData.getRealName(), handle);
|
||||
} catch (Exception exception) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.log(Level.SEVERE, ExceptionUtil.getStackTrace(exception));
|
||||
}
|
||||
this.updateSkin(player, disguiseData.getRealSkin(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSkin(Player player, ISkin skin, boolean matches) {
|
||||
EntityPlayer entityPlayer;
|
||||
GameProfile profile = (entityPlayer = ((CraftPlayer) player).getHandle()).getProfile();
|
||||
Location location = player.getLocation().clone();
|
||||
profile.getProperties().removeAll("textures");
|
||||
profile.getProperties()
|
||||
.put("textures", new Property("textures", skin.getValue(), skin.getSignature()));
|
||||
PacketPlayOutPlayerInfo.removePlayer(entityPlayer);
|
||||
PacketPlayOutPlayerInfo.addPlayer(entityPlayer);
|
||||
entityPlayer.playerConnection.sendPacket(
|
||||
new PacketPlayOutRespawn(
|
||||
0,
|
||||
entityPlayer.getWorld().difficulty,
|
||||
entityPlayer.getWorld().worldData.getType(),
|
||||
EnumGamemode.valueOf(player.getGameMode().name())));
|
||||
player.getInventory().setItemInHand(player.getItemInHand());
|
||||
player.updateInventory();
|
||||
player.teleport(location);
|
||||
Iterator<org.bukkit.entity.Player> iterator2 = Utilities.getOnlinePlayers().iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Player player2;
|
||||
if ((player2 = (Player) iterator2.next()).canSee(player)) {
|
||||
player2.hidePlayer(player);
|
||||
player2.showPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateHeaderFooter(Player player, String text, String text2) {
|
||||
((CraftPlayer) player)
|
||||
.getHandle()
|
||||
.playerConnection
|
||||
.sendPacket(
|
||||
new PacketTabHeader(
|
||||
ChatSerializer.a(
|
||||
"{text:\"" + StringEscapeUtils.escapeJava(text) + "\"}"),
|
||||
ChatSerializer.a(
|
||||
"{text:\"" + StringEscapeUtils.escapeJava(text2) + "\"}")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISkin getPlayerSkin(Player player) {
|
||||
String text = "";
|
||||
String text2 = "";
|
||||
Iterator iterator2 =
|
||||
this.getEntity(player).getProfile().getProperties().get("textures").iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Property property;
|
||||
text = (property = (Property) iterator2.next()).getValue();
|
||||
text2 = property.getSignature();
|
||||
}
|
||||
return new Skin(player.getName(), text, text2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack itemWithBase64(ItemStack itemStack, String text) {
|
||||
if (itemStack == null || text == null || text.isEmpty()) {
|
||||
return itemStack;
|
||||
}
|
||||
if (!(itemStack.getItemMeta() instanceof SkullMeta)) {
|
||||
return itemStack;
|
||||
}
|
||||
SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta();
|
||||
UUID uUID =
|
||||
new UUID(
|
||||
text.substring(text.length() - 20).hashCode(),
|
||||
text.substring(text.length() - 10).hashCode());
|
||||
GameProfile gameProfile;
|
||||
(gameProfile = new GameProfile(uUID, "Player"))
|
||||
.getProperties()
|
||||
.put("textures", new Property("textures", text));
|
||||
try {
|
||||
Field field = skullMeta.getClass().getDeclaredField("profile");
|
||||
field.setAccessible(true);
|
||||
field.set(skullMeta, gameProfile);
|
||||
} catch (ReflectiveOperationException exception) {
|
||||
throw ExceptionUtil.propagate(exception);
|
||||
}
|
||||
itemStack.setItemMeta(skullMeta);
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sitPlayer(Player player) {
|
||||
if (!this.creeperIds.containsKey(player.getUniqueId())) {
|
||||
player.setAllowFlight(true);
|
||||
Location location = player.getLocation();
|
||||
EntityPlayer entity = this.getEntity(player);
|
||||
EntityCreeper entityCreeper;
|
||||
(entityCreeper = new EntityCreeper(entity.getWorld()))
|
||||
.setLocation(
|
||||
location.getX(),
|
||||
location.getY(),
|
||||
location.getX(),
|
||||
location.getYaw(),
|
||||
location.getPitch());
|
||||
entityCreeper.setInvisible(true);
|
||||
entityCreeper.setCustomNameVisible(false);
|
||||
this.creeperIds.put(player.getUniqueId(), entityCreeper.getId());
|
||||
PacketPlayOutSpawnEntityLiving packetPlayOutSpawnEntityLiving =
|
||||
new PacketPlayOutSpawnEntityLiving(entityCreeper);
|
||||
this.sendPacket(player, packetPlayOutSpawnEntityLiving);
|
||||
PacketPlayOutAttachEntity packetPlayOutAttachEntity =
|
||||
new PacketPlayOutAttachEntity(0, entity, entityCreeper);
|
||||
this.sendPacket(player, packetPlayOutAttachEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsitPlayer(Player player) {
|
||||
if (this.creeperIds.containsKey(player.getUniqueId())) {
|
||||
player.setAllowFlight(false);
|
||||
int value = this.creeperIds.get(player.getUniqueId());
|
||||
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy =
|
||||
new PacketPlayOutEntityDestroy(new int[] {value});
|
||||
this.sendPacket(player, packetPlayOutEntityDestroy);
|
||||
this.creeperIds.remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayerFromTeam(String text, Team team) {
|
||||
CraftScoreboard craftScoreboard = (CraftScoreboard) team.getScoreboard();
|
||||
try {
|
||||
Field field;
|
||||
(field = Scoreboard.class.getDeclaredField("teamsByPlayer")).setAccessible(true);
|
||||
((Map) field.get(craftScoreboard.getHandle())).remove(text);
|
||||
Field field2;
|
||||
(field2 =
|
||||
Class.forName("org.bukkit.craftbukkit.v1_7_R4.scoreboard.CraftTeam")
|
||||
.getDeclaredField("team"))
|
||||
.setAccessible(true);
|
||||
((ScoreboardTeam) field2.get(team)).getPlayerNameSet().remove(text);
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendPacket(Player player, Packet packet) {
|
||||
this.getEntity(player).playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
public EntityPlayer getEntity(Player player) {
|
||||
return ((CraftPlayer) player).getHandle();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,287 @@
|
||||
package me.creaxx.api.nms.impl;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
import me.creaxx.api.nms.INMSImpl;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityCreeper;
|
||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_8_R3.IChatBaseComponent.ChatSerializer;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.EnumPlayerInfoAction;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerListHeaderFooter;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutRespawn;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
|
||||
import net.minecraft.server.v1_8_R3.PlayerList;
|
||||
import net.minecraft.server.v1_8_R3.Scoreboard;
|
||||
import net.minecraft.server.v1_8_R3.ScoreboardTeam;
|
||||
import net.minecraft.server.v1_8_R3.WorldSettings.EnumGamemode;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.scoreboard.CraftScoreboard;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.disguise.IDisguiseData;
|
||||
import xyz.refinedev.phoenix.profile.disguise.ISkin;
|
||||
import xyz.refinedev.phoenix.profile.disguise.Skin;
|
||||
import xyz.refinedev.phoenix.utils.DisguiseUtil;
|
||||
import xyz.refinedev.phoenix.utils.ExceptionUtil;
|
||||
import xyz.refinedev.phoenix.utils.Utilities;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class v1_8_R3 implements INMSImpl {
|
||||
|
||||
private final Map<UUID, Integer> creeperIds = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void disguise(IProfile profile, boolean matches) {
|
||||
Player player = Bukkit.getPlayer(profile.getUniqueId());
|
||||
IDisguiseData disguiseData = profile.getDisguiseData();
|
||||
EntityPlayer entityPlayer;
|
||||
DisguiseUtil.updateName(
|
||||
(entityPlayer = this.getEntity(player)).getProfile(),
|
||||
disguiseData.getDisguiseName());
|
||||
entityPlayer.displayName = disguiseData.getDisguiseName();
|
||||
try {
|
||||
PlayerList playerList =
|
||||
((CraftServer) Bukkit.getServer()).getHandle().getServer().getPlayerList();
|
||||
Field field;
|
||||
(field = PlayerList.class.getDeclaredField("playersByName")).setAccessible(true);
|
||||
Map entries;
|
||||
(entries = (Map) field.get(playerList)).remove(profile.getName());
|
||||
entries.put(disguiseData.getDisguiseName(), entityPlayer);
|
||||
} catch (Exception exception) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.log(Level.SEVERE, ExceptionUtil.getStackTrace(exception));
|
||||
}
|
||||
this.updateSkin(player, disguiseData.getDisguiseSkin(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undisguise(IProfile profile) {
|
||||
Player player = Bukkit.getPlayer(profile.getUniqueId());
|
||||
IDisguiseData disguiseData = profile.getDisguiseData();
|
||||
EntityPlayer entityPlayer;
|
||||
DisguiseUtil.updateName(
|
||||
(entityPlayer = this.getEntity(player)).getProfile(), disguiseData.getRealName());
|
||||
entityPlayer.displayName = disguiseData.getRealName();
|
||||
try {
|
||||
PlayerList playerList =
|
||||
((CraftServer) Bukkit.getServer()).getHandle().getServer().getPlayerList();
|
||||
Field field;
|
||||
(field = PlayerList.class.getDeclaredField("playersByName")).setAccessible(true);
|
||||
Map entries;
|
||||
(entries = (Map) field.get(playerList)).remove(disguiseData.getDisguiseName());
|
||||
entries.put(disguiseData.getRealName(), entityPlayer);
|
||||
} catch (Exception exception) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.log(Level.SEVERE, ExceptionUtil.getStackTrace(exception));
|
||||
}
|
||||
this.updateSkin(player, disguiseData.getRealSkin(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSkin(Player player, ISkin skin, boolean matches) {
|
||||
EntityPlayer entityPlayer;
|
||||
GameProfile gameProfile;
|
||||
(gameProfile = (entityPlayer = this.getEntity(player)).getProfile())
|
||||
.getProperties()
|
||||
.clear();
|
||||
gameProfile
|
||||
.getProperties()
|
||||
.put("textures", new Property("textures", skin.getValue(), skin.getSignature()));
|
||||
Location location = player.getLocation().clone();
|
||||
double health = player.getHealth();
|
||||
int foodLevel = player.getFoodLevel();
|
||||
float saturation = player.getSaturation();
|
||||
entityPlayer.playerConnection.sendPacket(
|
||||
new PacketPlayOutPlayerInfo(
|
||||
EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[] {entityPlayer}));
|
||||
entityPlayer.playerConnection.sendPacket(
|
||||
new PacketPlayOutPlayerInfo(
|
||||
EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] {entityPlayer}));
|
||||
entityPlayer.playerConnection.sendPacket(
|
||||
new PacketPlayOutRespawn(
|
||||
entityPlayer.getWorld().worldProvider.getDimension(),
|
||||
entityPlayer.getWorld().worldData.getDifficulty(),
|
||||
entityPlayer.getWorld().worldData.getType(),
|
||||
EnumGamemode.valueOf(player.getGameMode().name())));
|
||||
player.updateInventory();
|
||||
player.setGameMode(player.getGameMode());
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
inventory.setHeldItemSlot(inventory.getHeldItemSlot());
|
||||
player.setFoodLevel(20);
|
||||
player.setFoodLevel(foodLevel);
|
||||
player.setSaturation(5.0F);
|
||||
player.setSaturation(saturation);
|
||||
player.setMaxHealth(player.getMaxHealth());
|
||||
player.setHealth(20.0);
|
||||
player.setHealth(health);
|
||||
float exp = player.getExp();
|
||||
int totalExperience = player.getTotalExperience();
|
||||
player.setExp(exp);
|
||||
player.setTotalExperience(totalExperience);
|
||||
player.setWalkSpeed(player.getWalkSpeed());
|
||||
player.teleport(location);
|
||||
Iterator<org.bukkit.entity.Player> iterator2 = Utilities.getOnlinePlayers().iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Player player2;
|
||||
if ((player2 = (Player) iterator2.next()).canSee(player)) {
|
||||
player2.hidePlayer(player);
|
||||
player2.showPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISkin getPlayerSkin(Player player) {
|
||||
String text = "";
|
||||
String text2 = "";
|
||||
Iterator<com.mojang.authlib.properties.Property> iterator2 =
|
||||
this.getEntity(player).getProfile().getProperties().get("textures").iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Property property;
|
||||
text = (property = (Property) iterator2.next()).getValue();
|
||||
text2 = property.getSignature();
|
||||
}
|
||||
return new Skin(player.getName(), text, text2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack itemWithBase64(ItemStack itemStack, String text) {
|
||||
if (itemStack == null || text == null || text.isEmpty()) {
|
||||
return itemStack;
|
||||
}
|
||||
if (!(itemStack.getItemMeta() instanceof SkullMeta)) {
|
||||
return itemStack;
|
||||
}
|
||||
SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta();
|
||||
UUID uUID =
|
||||
new UUID(
|
||||
text.substring(text.length() - 20).hashCode(),
|
||||
text.substring(text.length() - 10).hashCode());
|
||||
GameProfile gameProfile;
|
||||
(gameProfile = new GameProfile(uUID, "Player"))
|
||||
.getProperties()
|
||||
.put("textures", new Property("textures", text));
|
||||
try {
|
||||
Field field = skullMeta.getClass().getDeclaredField("profile");
|
||||
field.setAccessible(true);
|
||||
field.set(skullMeta, gameProfile);
|
||||
} catch (ReflectiveOperationException exception) {
|
||||
throw ExceptionUtil.propagate(exception);
|
||||
}
|
||||
itemStack.setItemMeta(skullMeta);
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateHeaderFooter(Player player, String text, String text2) {
|
||||
PacketPlayOutPlayerListHeaderFooter packetPlayOutPlayerListHeaderFooter =
|
||||
new PacketPlayOutPlayerListHeaderFooter();
|
||||
try {
|
||||
Field field;
|
||||
(field = packetPlayOutPlayerListHeaderFooter.getClass().getDeclaredField("a"))
|
||||
.setAccessible(true);
|
||||
field.set(
|
||||
packetPlayOutPlayerListHeaderFooter,
|
||||
ChatSerializer.a("{\"text\":\"" + text + "\"}"));
|
||||
Field field2;
|
||||
(field2 = packetPlayOutPlayerListHeaderFooter.getClass().getDeclaredField("b"))
|
||||
.setAccessible(true);
|
||||
field2.set(
|
||||
packetPlayOutPlayerListHeaderFooter,
|
||||
ChatSerializer.a("{\"text\":\"" + text2 + "\"}"));
|
||||
} catch (IllegalAccessException | NoSuchFieldException exception) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.log(Level.SEVERE, ExceptionUtil.getStackTrace(exception));
|
||||
}
|
||||
this.sendPacket(player, packetPlayOutPlayerListHeaderFooter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sitPlayer(Player player) {
|
||||
if (!this.creeperIds.containsKey(player.getUniqueId())) {
|
||||
player.setAllowFlight(true);
|
||||
Location location = player.getLocation();
|
||||
EntityPlayer entity = this.getEntity(player);
|
||||
EntityCreeper entityCreeper;
|
||||
(entityCreeper = new EntityCreeper(entity.getWorld()))
|
||||
.setLocation(
|
||||
location.getX(),
|
||||
location.getY(),
|
||||
location.getX(),
|
||||
location.getYaw(),
|
||||
location.getPitch());
|
||||
entityCreeper.setInvisible(true);
|
||||
entityCreeper.setCustomNameVisible(false);
|
||||
this.creeperIds.put(player.getUniqueId(), entityCreeper.getId());
|
||||
PacketPlayOutSpawnEntityLiving packetPlayOutSpawnEntityLiving =
|
||||
new PacketPlayOutSpawnEntityLiving(entityCreeper);
|
||||
this.sendPacket(player, packetPlayOutSpawnEntityLiving);
|
||||
PacketPlayOutAttachEntity packetPlayOutAttachEntity =
|
||||
new PacketPlayOutAttachEntity(0, entity, entityCreeper);
|
||||
this.sendPacket(player, packetPlayOutAttachEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsitPlayer(Player player) {
|
||||
if (this.creeperIds.containsKey(player.getUniqueId())) {
|
||||
player.setAllowFlight(false);
|
||||
int value = this.creeperIds.get(player.getUniqueId());
|
||||
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy =
|
||||
new PacketPlayOutEntityDestroy(new int[] {value});
|
||||
this.sendPacket(player, packetPlayOutEntityDestroy);
|
||||
this.creeperIds.remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayerFromTeam(String text, Team team) {
|
||||
CraftScoreboard craftScoreboard = (CraftScoreboard) team.getScoreboard();
|
||||
try {
|
||||
Field field;
|
||||
(field = Scoreboard.class.getDeclaredField("teamsByPlayer")).setAccessible(true);
|
||||
((Map) field.get(craftScoreboard.getHandle())).remove(text);
|
||||
Field field2;
|
||||
(field2 =
|
||||
Class.forName("org.bukkit.craftbukkit.v1_8_R3.scoreboard.CraftTeam")
|
||||
.getDeclaredField("team"))
|
||||
.setAccessible(true);
|
||||
((ScoreboardTeam) field2.get(team)).getPlayerNameSet().remove(text);
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void sendPacket(Player player, Packet packet) {
|
||||
this.getEntity(player).playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
public EntityPlayer getEntity(Player player) {
|
||||
return ((CraftPlayer) player).getHandle();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
package me.creaxx.api.nms.impl;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
|
||||
import me.creaxx.api.nms.INMSImpl;
|
||||
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
|
||||
import net.minecraft.server.dedicated.DedicatedPlayerList;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.players.PlayerList;
|
||||
import net.minecraft.world.scores.PlayerTeam;
|
||||
import net.minecraft.world.scores.Scoreboard;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.profile.CraftPlayerProfile;
|
||||
import org.bukkit.craftbukkit.scoreboard.CraftScoreboard;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.disguise.IDisguiseData;
|
||||
import xyz.refinedev.phoenix.profile.disguise.ISkin;
|
||||
import xyz.refinedev.phoenix.profile.disguise.Skin;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.DisguiseUtil;
|
||||
import xyz.refinedev.phoenix.utils.ExceptionUtil;
|
||||
import xyz.refinedev.phoenix.utils.Utilities;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class v_1_20_R4 implements INMSImpl {
|
||||
|
||||
@Override
|
||||
public void disguise(IProfile profile, boolean matches) {
|
||||
Player player = Bukkit.getPlayer(profile.getUniqueId());
|
||||
IDisguiseData disguiseData = profile.getDisguiseData();
|
||||
ServerPlayer serverPlayer;
|
||||
DisguiseUtil.updateName(
|
||||
(serverPlayer = this.getEntity(player)).getGameProfile(),
|
||||
disguiseData.getDisguiseName());
|
||||
serverPlayer.displayName = disguiseData.getRealName();
|
||||
try {
|
||||
DedicatedPlayerList playerList =
|
||||
((CraftServer) Bukkit.getServer()).getHandle().getServer().getPlayerList();
|
||||
Field field;
|
||||
(field = PlayerList.class.getDeclaredField("playersByName")).setAccessible(true);
|
||||
Map entries;
|
||||
(entries = (Map) field.get(playerList)).remove(profile.getName());
|
||||
entries.put(disguiseData.getDisguiseName(), serverPlayer);
|
||||
} catch (Exception exception) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.log(Level.SEVERE, ExceptionUtil.getStackTrace(exception));
|
||||
}
|
||||
this.updateSkin(player, disguiseData.getDisguiseSkin(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undisguise(IProfile profile) {
|
||||
Player player = Bukkit.getPlayer(profile.getUniqueId());
|
||||
IDisguiseData disguiseData = profile.getDisguiseData();
|
||||
ServerPlayer serverPlayer;
|
||||
DisguiseUtil.updateName(
|
||||
(serverPlayer = this.getEntity(player)).getGameProfile(),
|
||||
disguiseData.getRealName());
|
||||
serverPlayer.displayName = disguiseData.getRealName();
|
||||
try {
|
||||
DedicatedPlayerList playerList =
|
||||
((CraftServer) Bukkit.getServer()).getHandle().getServer().getPlayerList();
|
||||
Field field;
|
||||
(field = PlayerList.class.getDeclaredField("playersByName")).setAccessible(true);
|
||||
Map entries;
|
||||
(entries = (Map) field.get(playerList)).remove(disguiseData.getDisguiseName());
|
||||
entries.put(disguiseData.getRealName(), serverPlayer);
|
||||
} catch (Exception exception) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.log(Level.SEVERE, ExceptionUtil.getStackTrace(exception));
|
||||
}
|
||||
this.updateSkin(player, disguiseData.getRealSkin(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSkin(Player player, ISkin skin, boolean matches) {
|
||||
ServerPlayer entity = this.getEntity(player);
|
||||
Location location = player.getLocation().clone();
|
||||
GameProfile gameProfile;
|
||||
(gameProfile = entity.getGameProfile()).getProperties().clear();
|
||||
gameProfile
|
||||
.getProperties()
|
||||
.put("textures", new Property("textures", skin.getValue(), skin.getSignature()));
|
||||
entity.connection.send(
|
||||
new ClientboundPlayerInfoRemovePacket(
|
||||
Collections.singletonList(entity.getGameProfile().getId())));
|
||||
entity.connection.send(
|
||||
ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(
|
||||
Collections.singletonList(entity)));
|
||||
player.spigot().respawn();
|
||||
player.getInventory().setItemInHand(player.getItemInHand());
|
||||
player.updateInventory();
|
||||
player.teleport(location);
|
||||
Iterator<org.bukkit.entity.Player> iterator2 = Utilities.getOnlinePlayers().iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Player player2;
|
||||
if ((player2 = (Player) iterator2.next()).canSee(player)) {
|
||||
player2.hidePlayer(player);
|
||||
player2.showPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateHeaderFooter(Player player, String text, String text2) {
|
||||
player.setPlayerListHeaderFooter(Color.translate(text), Color.translate(text2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack itemWithBase64(ItemStack itemStack, String text) {
|
||||
if (itemStack == null || text == null || text.isEmpty()) {
|
||||
return itemStack;
|
||||
}
|
||||
if (!(itemStack.getItemMeta() instanceof SkullMeta)) {
|
||||
return itemStack;
|
||||
}
|
||||
SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta();
|
||||
UUID uUID =
|
||||
new UUID(
|
||||
text.substring(text.length() - 20).hashCode(),
|
||||
text.substring(text.length() - 10).hashCode());
|
||||
GameProfile gameProfile;
|
||||
(gameProfile = new GameProfile(uUID, "Player"))
|
||||
.getProperties()
|
||||
.put("textures", new Property("textures", text));
|
||||
skullMeta.setOwnerProfile(new CraftPlayerProfile(gameProfile));
|
||||
itemStack.setItemMeta(skullMeta);
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISkin getPlayerSkin(Player player) {
|
||||
String text = "";
|
||||
String text2 = "";
|
||||
Iterator<com.mojang.authlib.properties.Property> iterator2 =
|
||||
((CraftPlayer) player).getProfile().getProperties().get("textures").iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Property property;
|
||||
text = (property = (Property) iterator2.next()).value();
|
||||
text2 = property.signature();
|
||||
}
|
||||
return new Skin(player.getName(), text, text2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sitPlayer(Player player) {}
|
||||
|
||||
@Override
|
||||
public void unsitPlayer(Player player) {}
|
||||
|
||||
@Override
|
||||
public void removePlayerFromTeam(String text, Team team) {
|
||||
CraftScoreboard craftScoreboard = (CraftScoreboard) team.getScoreboard();
|
||||
try {
|
||||
Field field;
|
||||
(field = Scoreboard.class.getDeclaredField("teamsByPlayer")).setAccessible(true);
|
||||
((Object2ObjectMap) field.get(craftScoreboard.getHandle())).remove(text);
|
||||
Field field2;
|
||||
(field2 =
|
||||
Class.forName("org.bukkit.craftbukkit.scoreboard.CraftTeam")
|
||||
.getDeclaredField("team"))
|
||||
.setAccessible(true);
|
||||
((PlayerTeam) field2.get(team)).getPlayers().remove(text);
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
}
|
||||
|
||||
public ServerPlayer getEntity(Player player) {
|
||||
return ((CraftPlayer) player).getHandle();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
v1_12_R1
|
||||
v1_16_R3
|
||||
v1_18_R2
|
||||
v1_19_R3
|
||||
v1_20_R3
|
||||
v1_21_R1
|
||||
v1_21_R10
|
||||
v1_7_R4
|
||||
v1_8_R3
|
||||
v_1_20_R4
|
||||
@@ -0,0 +1,7 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
rootProject.name = 'Phoenix'
|
||||
@@ -0,0 +1,178 @@
|
||||
package me.creaxx.api;
|
||||
|
||||
import me.creaxx.api.nms.INMSImpl;
|
||||
import me.creaxx.api.nms.ITeleportImpl;
|
||||
import me.creaxx.api.nms.impl.LegacyTeleportImpl;
|
||||
import me.creaxx.api.nms.impl.ModernTeleportImpl;
|
||||
import me.creaxx.api.nms.impl.v1_12_R1;
|
||||
import me.creaxx.api.nms.impl.v1_16_R3;
|
||||
import me.creaxx.api.nms.impl.v1_18_R2;
|
||||
import me.creaxx.api.nms.impl.v1_19_R3;
|
||||
import me.creaxx.api.nms.impl.v1_20_R3;
|
||||
import me.creaxx.api.nms.impl.v1_21_R1;
|
||||
import me.creaxx.api.nms.impl.v1_21_R10;
|
||||
import me.creaxx.api.nms.impl.v1_7_R4;
|
||||
import me.creaxx.api.nms.impl.v1_8_R3;
|
||||
import me.creaxx.api.nms.impl.v_1_20_R4;
|
||||
import me.creaxx.api.particle.ParticleAPI;
|
||||
import me.creaxx.api.title.ITitleAPI;
|
||||
import me.creaxx.api.utils.VersionUtil;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import xyz.refinedev.lib.folialib.FoliaLib;
|
||||
import xyz.refinedev.lib.particlenativeapi.api.ParticleNativeAPI;
|
||||
import xyz.refinedev.lib.particlenativeapi.core.ParticleNativeCore;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class NMSHandler {
|
||||
|
||||
public static NMSHandler instance;
|
||||
|
||||
private final JavaPlugin plugin;
|
||||
|
||||
private INMSImpl API;
|
||||
|
||||
private ITeleportImpl teleportAPI;
|
||||
|
||||
private ITitleAPI titleAPI;
|
||||
|
||||
private ParticleAPI particleAPI;
|
||||
|
||||
private boolean registered = false;
|
||||
|
||||
public NMSHandler(JavaPlugin javaPlugin) {
|
||||
instance = this;
|
||||
this.plugin = javaPlugin;
|
||||
}
|
||||
|
||||
public boolean init() {
|
||||
FoliaLib foliaLib = new FoliaLib(this.plugin);
|
||||
String text;
|
||||
try {
|
||||
String text2;
|
||||
Integer.parseInt(
|
||||
(text =
|
||||
(text2 = Bukkit.getServer().getClass().getPackage().getName())
|
||||
.length()
|
||||
< 4
|
||||
? text2.split("\\.")[2]
|
||||
: text2.split("\\.")[3])
|
||||
.split("_")[1]);
|
||||
} catch (Exception exception) {
|
||||
text =
|
||||
"v"
|
||||
+ Bukkit.getServer()
|
||||
.getBukkitVersion()
|
||||
.replace("-SNAPSHOT", "")
|
||||
.replace("-R0.", "_R")
|
||||
.replace(".", "_");
|
||||
}
|
||||
if (!VersionUtil.canHex() || !foliaLib.isFolia() && !foliaLib.isPaper()) {
|
||||
this.teleportAPI = new LegacyTeleportImpl();
|
||||
} else {
|
||||
this.teleportAPI = new ModernTeleportImpl();
|
||||
}
|
||||
this.plugin.getLogger().log(Level.INFO, "Loading NMS Implementation...");
|
||||
try {
|
||||
this.setupNMS(text);
|
||||
this.plugin.getLogger().log(Level.INFO, "Detected version " + text + "!");
|
||||
try {
|
||||
this.setupParticleAPI();
|
||||
} catch (Exception exception2) {
|
||||
this.plugin
|
||||
.getLogger()
|
||||
.log(Level.SEVERE, "ParticleAPI is not supported on this version.");
|
||||
}
|
||||
this.registered = true;
|
||||
return true;
|
||||
} catch (IllegalArgumentException illegalArgumentException) {
|
||||
this.plugin
|
||||
.getLogger()
|
||||
.log(Level.INFO, "This version is not fully supported (" + text + ")!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setupNMS(String text) throws IllegalArgumentException {
|
||||
switch (text) {
|
||||
case "v1_7_R4":
|
||||
this.API = new v1_7_R4();
|
||||
break;
|
||||
case "v1_8_R3":
|
||||
this.API = new v1_8_R3();
|
||||
break;
|
||||
case "v1_12_R1":
|
||||
this.API = new v1_12_R1();
|
||||
break;
|
||||
case "v1_16_R3":
|
||||
this.API = new v1_16_R3();
|
||||
break;
|
||||
case "v1_18_R2":
|
||||
this.API = new v1_18_R2();
|
||||
break;
|
||||
case "v1_19_R3":
|
||||
this.API = new v1_19_R3();
|
||||
break;
|
||||
case "v1_20_R3":
|
||||
this.API = new v1_20_R3();
|
||||
break;
|
||||
case "v1_20_6_R1":
|
||||
this.API = new v_1_20_R4();
|
||||
break;
|
||||
case "v1_21_11_R1":
|
||||
case "v1_21_10_R1":
|
||||
this.API = new v1_21_R10();
|
||||
break;
|
||||
case "v1_21_9_R1":
|
||||
case "v1_21_8_R1":
|
||||
case "v1_21_7_R1":
|
||||
case "v1_21_6_R1":
|
||||
case "v1_21_5_R1":
|
||||
case "v1_21_4_R1":
|
||||
case "v1_21_3_R1":
|
||||
case "v1_21_2_R1":
|
||||
case "v1_21_1_R1":
|
||||
case "v1_21_R1":
|
||||
this.API = new v1_21_R1();
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported Version!");
|
||||
}
|
||||
}
|
||||
|
||||
public void setupParticleAPI() {
|
||||
ParticleNativeAPI particleNativeAPI = ParticleNativeCore.loadAPI(this.plugin);
|
||||
this.particleAPI = new ParticleAPI(particleNativeAPI);
|
||||
}
|
||||
|
||||
public JavaPlugin getPlugin() {
|
||||
return this.plugin;
|
||||
}
|
||||
|
||||
public INMSImpl getAPI() {
|
||||
return this.API;
|
||||
}
|
||||
|
||||
public ITeleportImpl getTeleportAPI() {
|
||||
return this.teleportAPI;
|
||||
}
|
||||
|
||||
public ITitleAPI getTitleAPI() {
|
||||
return this.titleAPI;
|
||||
}
|
||||
|
||||
public ParticleAPI getParticleAPI() {
|
||||
return this.particleAPI;
|
||||
}
|
||||
|
||||
public boolean isRegistered() {
|
||||
return this.registered;
|
||||
}
|
||||
|
||||
public static NMSHandler getInstance() {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package me.creaxx.api.nms;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.disguise.ISkin;
|
||||
|
||||
public interface INMSImpl {
|
||||
|
||||
void disguise(IProfile profile, boolean matches);
|
||||
|
||||
void undisguise(IProfile profile);
|
||||
|
||||
void updateSkin(Player player, ISkin skin, boolean matches);
|
||||
|
||||
void updateHeaderFooter(Player player, String text, String text2);
|
||||
|
||||
ISkin getPlayerSkin(Player player);
|
||||
|
||||
ItemStack itemWithBase64(ItemStack itemStack, String text);
|
||||
|
||||
void sitPlayer(Player player);
|
||||
|
||||
void unsitPlayer(Player player);
|
||||
|
||||
void removePlayerFromTeam(String text, Team team);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package me.creaxx.api.nms;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface ITeleportImpl {
|
||||
|
||||
void teleport(Player player, Location location);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package me.creaxx.api.nms.impl;
|
||||
|
||||
import me.creaxx.api.nms.ITeleportImpl;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LegacyTeleportImpl implements ITeleportImpl {
|
||||
|
||||
@Override
|
||||
public void teleport(Player player, Location location) {
|
||||
player.teleport(location);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package me.creaxx.api.nms.impl;
|
||||
|
||||
import me.creaxx.api.nms.ITeleportImpl;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ModernTeleportImpl implements ITeleportImpl {
|
||||
|
||||
@Override
|
||||
public void teleport(Player player, Location location) {
|
||||
player.teleportAsync(location);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package me.creaxx.api.particle;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.particlenativeapi.api.ParticleNativeAPI;
|
||||
import xyz.refinedev.lib.particlenativeapi.api.packet.ParticlePacket;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.handler.IProfileHandler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ParticleAPI {
|
||||
|
||||
private final ParticleNativeAPI particleAPI;
|
||||
|
||||
public void sendParticlePacket(
|
||||
ParticleEffect.ParticlePacket particlePacket, Location location, Player player) {
|
||||
particlePacket.toNativePacket(this.particleAPI, location).sendTo(player);
|
||||
}
|
||||
|
||||
public void sendParticlePacket(
|
||||
Player player,
|
||||
ParticleEffect.ParticlePacket particlePacket,
|
||||
Location location,
|
||||
List<Player> values) {
|
||||
ParticlePacket particlePacket2 = particlePacket.toNativePacket(this.particleAPI, location);
|
||||
for (Player player2 : values) {
|
||||
if (player == null || player2.canSee(player)) {
|
||||
particlePacket2.sendTo(player2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendParticlePacket(
|
||||
Player player,
|
||||
ParticleEffect.ParticlePacket particlePacket,
|
||||
Location location,
|
||||
double value) {
|
||||
ParticlePacket particlePacket2 = particlePacket.toNativePacket(this.particleAPI, location);
|
||||
String name = location.getWorld().getName();
|
||||
double value2 = value * value;
|
||||
IProfileHandler profileHandler = Phoenix.getInstance().getProfileHandler();
|
||||
for (Player player2 : Bukkit.getOnlinePlayers()) {
|
||||
if ((player == null || player2.canSee(player))
|
||||
&& player2.getWorld().getName().equals(name)
|
||||
&& !(player2.getLocation().distanceSquared(location) > value2)
|
||||
&& profileHandler.getProfile(player2.getUniqueId()).isSetting("particles")) {
|
||||
particlePacket2.sendTo(player2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ParticleAPI(ParticleNativeAPI particleNativeAPI) {
|
||||
this.particleAPI = particleNativeAPI;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,10 @@
|
||||
package me.creaxx.api.title;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface ITitleAPI {
|
||||
|
||||
void sendTitle(Player player, String text, String text2, int value, int value2, int value3);
|
||||
|
||||
void clearTitle(Player player);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package me.creaxx.api.utils;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class VersionUtil {
|
||||
|
||||
public static String VERSION;
|
||||
|
||||
public static int MINOR_VERSION;
|
||||
|
||||
public static boolean canHex() {
|
||||
return MINOR_VERSION >= 16;
|
||||
}
|
||||
|
||||
static {
|
||||
try {
|
||||
String text;
|
||||
VERSION =
|
||||
(text = Bukkit.getServer().getClass().getPackage().getName()).length() < 4
|
||||
? text.split("\\.")[2]
|
||||
: text.split("\\.")[3];
|
||||
MINOR_VERSION = Integer.parseInt(VERSION.split("_")[1]);
|
||||
} catch (Exception exception) {
|
||||
VERSION =
|
||||
"v"
|
||||
+ Bukkit.getServer()
|
||||
.getBukkitVersion()
|
||||
.replace("-SNAPSHOT", "")
|
||||
.replace("-R0.", "_R")
|
||||
.replace(".", "_");
|
||||
MINOR_VERSION = Integer.parseInt(VERSION.split("_")[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,374 @@
|
||||
package xyz.refinedev.phoenix;
|
||||
|
||||
import me.creaxx.api.NMSHandler;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
import xyz.refinedev.lib.jetbrains.NotNull;
|
||||
import xyz.refinedev.lib.jetbrains.Nullable;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatChannelType;
|
||||
import xyz.refinedev.phoenix.config.GlobalConfig;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.packet.impl.profile.ChatChannelMessagePacket;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.tag.ITag;
|
||||
import xyz.refinedev.phoenix.rank.IRank;
|
||||
import xyz.refinedev.phoenix.server.IServerData;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.DateUtils;
|
||||
import xyz.refinedev.phoenix.utils.Duration;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.events.player.PlayerChatInChannelEvent;
|
||||
import xyz.refinedev.phoenix.utils.general.Tasks;
|
||||
import xyz.refinedev.phoenix.whitelist.WhitelistAccess;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public final class BukkitAPI {
|
||||
|
||||
public static CommonPlatform api = Phoenix.getInstance();
|
||||
|
||||
public static Pattern UUID_PATTERN =
|
||||
Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}");
|
||||
|
||||
public static final Pattern VALID_NAME_PATTERN = Pattern.compile("^[a-zA-Z0-9_$]{1,16}$");
|
||||
|
||||
public static final Pattern DISGUISE_VALID_NAME_PATTERN =
|
||||
Pattern.compile("^[a-zA-Z0-9_$]{3,16}$");
|
||||
|
||||
public static boolean isUuid(String text) {
|
||||
return UUID_PATTERN.matcher(text).find();
|
||||
}
|
||||
|
||||
public static boolean isDisguiseValidName(String text) {
|
||||
return text != null
|
||||
&& !text.isEmpty()
|
||||
&& DISGUISE_VALID_NAME_PATTERN.matcher(text).matches();
|
||||
}
|
||||
|
||||
public static boolean isValidName(String text) {
|
||||
return text != null
|
||||
&& !text.isEmpty()
|
||||
&& VALID_NAME_PATTERN.matcher(text.replace("*", "").replace(".", "")).matches();
|
||||
}
|
||||
|
||||
public static void sendAdminAlert(Player player, String text) {
|
||||
IProfile cachedProfile = api.getProfileHandler().getCachedProfile(player.getUniqueId());
|
||||
Iterator iterator2 = Bukkit.getOnlinePlayers().iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Player player2;
|
||||
IProfile profile;
|
||||
if (!(player2 = (Player) iterator2.next()).getName().equals(player.getName())
|
||||
&& player2.hasPermission("core.admin")
|
||||
&& (profile =
|
||||
Phoenix.getInstance()
|
||||
.getProfileHandler()
|
||||
.getCachedProfile(player2.getUniqueId()))
|
||||
!= null
|
||||
&& profile.isSetting("admin-alerts")) {
|
||||
player2.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player2, MessageConfig.STAFF.ADMIN_ALERT)
|
||||
.replace(
|
||||
"<player>",
|
||||
cachedProfile.getNameWithColorNoDisguise())
|
||||
.replace("<action>", text)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void broadcastToStaff(String text) {
|
||||
Iterator iterator2 = Bukkit.getOnlinePlayers().iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Player player;
|
||||
if ((player = (Player) iterator2.next()).hasPermission("core.admin")
|
||||
&& api.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId())
|
||||
.isSetting("admin-alerts")) {
|
||||
player.sendMessage(Color.translate(text));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void broadcastToStaff(Function<Player, String> function) {
|
||||
Iterator iterator2 = Bukkit.getOnlinePlayers().iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Player player;
|
||||
if ((player = (Player) iterator2.next()).hasPermission("core.admin")
|
||||
&& api.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId())
|
||||
.isSetting("admin-alerts")) {
|
||||
player.sendMessage((String) function.apply(player));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isInModMode(Player player) {
|
||||
return player.hasMetadata("ModMode");
|
||||
}
|
||||
|
||||
public static long parseDuration(String text) {
|
||||
if (!text.equalsIgnoreCase("perm") && !text.equalsIgnoreCase("permanent")) {
|
||||
try {
|
||||
return getDuration(text);
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
}
|
||||
return -5L;
|
||||
}
|
||||
|
||||
public static long parseDurationPunishment(String text) {
|
||||
Duration duration;
|
||||
return (duration = Duration.of(text)) == null ? -3L : duration.getTimeTime();
|
||||
}
|
||||
|
||||
public static long getDuration(String text) {
|
||||
return DateUtils.getDuration(text);
|
||||
}
|
||||
|
||||
public static void callEvent(Event event) {
|
||||
if (event.isAsynchronous()) {
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
Tasks.runAsync(() -> Bukkit.getPluginManager().callEvent(event));
|
||||
} else {
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
}
|
||||
} else if (Bukkit.isPrimaryThread()) {
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
} else {
|
||||
Tasks.run(() -> Bukkit.getPluginManager().callEvent(event));
|
||||
}
|
||||
}
|
||||
|
||||
public static String getKickMessage(List<String> values) {
|
||||
if (values.isEmpty()) {
|
||||
return "Empty";
|
||||
}
|
||||
int value = 0;
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (String text : values) {
|
||||
value++;
|
||||
stringBuilder.append(text);
|
||||
if (value < values.size()) {
|
||||
stringBuilder.append("\n");
|
||||
}
|
||||
}
|
||||
return Color.translate(stringBuilder.toString());
|
||||
}
|
||||
|
||||
public static String getUntranslatedStringFromList(List<String> values) {
|
||||
if (values.isEmpty()) {
|
||||
return "Empty";
|
||||
}
|
||||
int value = 0;
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (String text : values) {
|
||||
value++;
|
||||
stringBuilder.append(text);
|
||||
if (value < values.size()) {
|
||||
stringBuilder.append("\n");
|
||||
}
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getTagPrefix(IProfile profile) {
|
||||
ITag tag;
|
||||
if ((tag = profile.getTag()) != null
|
||||
&& (hasTag(profile, tag) || profile.getCustomTag() != null)) {
|
||||
return !tag.isScheduleActive()
|
||||
? ""
|
||||
: Color.translate(
|
||||
SettingsConfig.FORMATS
|
||||
.TAGS_FORMAT
|
||||
.replace("<color>", tag.getColor())
|
||||
.replace("<tag>", tag.getPrefix()));
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getTagPrefix(Player player) {
|
||||
IProfile profile;
|
||||
ITag tag;
|
||||
if ((tag =
|
||||
(profile =
|
||||
api.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId()))
|
||||
.getTag())
|
||||
!= null
|
||||
&& (hasTag(player, tag) || profile.getCustomTag() != null)) {
|
||||
return !tag.isScheduleActive()
|
||||
? ""
|
||||
: Color.translate(
|
||||
SettingsConfig.FORMATS
|
||||
.TAGS_FORMAT
|
||||
.replace("<color>", tag.getColor())
|
||||
.replace("<tag>", tag.getPrefix()));
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasTag(IProfile profile, ITag tag) {
|
||||
return profile.checkPermission("core.tags." + tag.getName(), false)
|
||||
|| profile.checkPermission("core.tags.*", false);
|
||||
}
|
||||
|
||||
public static boolean hasTag(Player player, ITag tag) {
|
||||
return player.hasPermission("core.tags." + tag.getName())
|
||||
|| player.hasPermission("core.tags.*");
|
||||
}
|
||||
|
||||
public static void sendSomeStaffMessage(
|
||||
IProfile profile, ChatChannelType chatChannelType, String text) {
|
||||
if (!chatChannelType.canSendMessage(Bukkit.getPlayer(profile.getUniqueId()))) {
|
||||
profile.updateMetadata("channel", "Default", true);
|
||||
} else {
|
||||
callEvent(new PlayerChatInChannelEvent(chatChannelType, profile, text));
|
||||
api.getPacketHandler()
|
||||
.send(
|
||||
new ChatChannelMessagePacket(
|
||||
profile.getUuid(),
|
||||
chatChannelType.getName(),
|
||||
profile.getNameWithColorNoDisguise(),
|
||||
GlobalConfig.SERVER.DISPLAYNAME,
|
||||
text));
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendGlobalChatChannel(
|
||||
IProfile profile, ChatChannelType chatChannelType, String text) {
|
||||
if (!chatChannelType.canSendMessage(Bukkit.getPlayer(profile.getUniqueId()))) {
|
||||
profile.updateMetadata("channel", "Default", true);
|
||||
} else {
|
||||
callEvent(new PlayerChatInChannelEvent(chatChannelType, profile, text));
|
||||
api.getPacketHandler()
|
||||
.send(
|
||||
new ChatChannelMessagePacket(
|
||||
profile.getUuid(),
|
||||
chatChannelType.getName(),
|
||||
profile.getNameWithColorNoDisguise(),
|
||||
GlobalConfig.SERVER.DISPLAYNAME,
|
||||
text));
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendSomeStaffMessageConsole(ChatChannelType chatChannelType, String text) {
|
||||
api.getPacketHandler()
|
||||
.send(
|
||||
new ChatChannelMessagePacket(
|
||||
IProfile.getConsoleUuid(),
|
||||
chatChannelType.getName(),
|
||||
GlobalConfig.SERVER.CONSOLE_NAME,
|
||||
GlobalConfig.SERVER.DISPLAYNAME,
|
||||
text));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IProfile getProfileByName(String text) {
|
||||
IProfile profile;
|
||||
String text2;
|
||||
if ((profile = api.getProfileHandler().getLocalProfileByName(text)) == null
|
||||
&& (text2 = Phoenix.getInstance().getDisguiseHandler().getUuidByFakeName(text))
|
||||
!= null) {
|
||||
UUID uUID = UUID.fromString(text2);
|
||||
profile = api.getProfileHandler().getProfile(uUID);
|
||||
}
|
||||
if (profile == null) {
|
||||
UUID uUID2;
|
||||
if ((uUID2 = api.getUuidCache().getUuidNoMojang(text)) != null) {
|
||||
profile = api.getProfileHandler().getProfile(uUID2);
|
||||
} else {
|
||||
UUID uUID3;
|
||||
if ((uUID3 = api.getProfileHandler().getUuidFromName(text)) != null) {
|
||||
profile = api.getProfileHandler().getProfile(uUID3);
|
||||
}
|
||||
}
|
||||
}
|
||||
return profile;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IProfile getProfileByNameNoDisguise(String text) {
|
||||
IProfile profile;
|
||||
if ((profile = api.getProfileHandler().getLocalProfileByName(text)) == null) {
|
||||
UUID uUID;
|
||||
if ((uUID = api.getUuidCache().getUuidNoMojang(text)) != null) {
|
||||
profile = api.getProfileHandler().getProfile(uUID);
|
||||
} else if ((uUID = api.getProfileHandler().getUuidFromName(text)) != null) {
|
||||
profile = api.getProfileHandler().getProfile(uUID);
|
||||
}
|
||||
}
|
||||
return profile;
|
||||
}
|
||||
|
||||
public static void kickUnwhitelistedUsers() {
|
||||
if (api.getWhitelistHandler().isWhitelisted()) {
|
||||
IRank rank = api.getRankHandler().getRank("WhitelistBypass");
|
||||
Set<WhitelistAccess> accessTypes = api.getWhitelistHandler().getAccessTypes();
|
||||
IServerData serverByName =
|
||||
api.getNetworkHandler().getServerByName(GlobalConfig.SERVER.NAME);
|
||||
IRank whitelistRank = api.getWhitelistHandler().getWhitelistRank();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
IProfile profile;
|
||||
if ((profile = api.getProfileHandler().getCachedProfile(player.getUniqueId()))
|
||||
!= null
|
||||
&& (rank == null || !profile.hasRank(rank))) {
|
||||
boolean matches = false;
|
||||
WhitelistAccess whitelistAccess = null;
|
||||
WhitelistAccess[] whitelistAccesss;
|
||||
int value = (whitelistAccesss = WhitelistAccess.values()).length;
|
||||
for (int index = 0; index < value; index++) {
|
||||
WhitelistAccess whitelistAccess2 = whitelistAccesss[index];
|
||||
if (accessTypes.contains(whitelistAccess2)) {
|
||||
if (whitelistAccess2.getFunction().apply(profile, serverByName)) {
|
||||
matches = true;
|
||||
break;
|
||||
}
|
||||
whitelistAccess = whitelistAccess2;
|
||||
}
|
||||
}
|
||||
if (!matches) {
|
||||
List<String> values2 =
|
||||
whitelistAccess == WhitelistAccess.RANK
|
||||
? MessageConfig.WHITELIST.RANK_KICK_MESSAGE
|
||||
: MessageConfig.WHITELIST.UUID_KICK_MESSAGE;
|
||||
player.kickPlayer(
|
||||
Color.translate(
|
||||
getKickMessage(values2)
|
||||
.replace(
|
||||
"<rank>",
|
||||
whitelistRank != null
|
||||
? whitelistRank.getDisplayName()
|
||||
: "")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void teleport(Player player, Location location) {
|
||||
NMSHandler.getInstance().getTeleportAPI().teleport(player, location);
|
||||
}
|
||||
|
||||
public static void teleport(Player player, Player player2) {
|
||||
teleport(player, player2.getLocation());
|
||||
}
|
||||
|
||||
private BukkitAPI() {
|
||||
throw new UnsupportedOperationException(
|
||||
"This is a utility class and cannot be instantiated");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
package xyz.refinedev.phoenix;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import xyz.refinedev.lib.config.ConfigHandler;
|
||||
import xyz.refinedev.phoenix.cache.api.IUUIDCache;
|
||||
import xyz.refinedev.phoenix.handler.IAddressStatsHandler;
|
||||
import xyz.refinedev.phoenix.handler.IAltHandler;
|
||||
import xyz.refinedev.phoenix.handler.IAnalyticsHandler;
|
||||
import xyz.refinedev.phoenix.handler.IAntiVPNHandler;
|
||||
import xyz.refinedev.phoenix.handler.IChatLogHandler;
|
||||
import xyz.refinedev.phoenix.handler.IChatSnapshotHandler;
|
||||
import xyz.refinedev.phoenix.handler.ICommandLogHandler;
|
||||
import xyz.refinedev.phoenix.handler.ICooldownHandler;
|
||||
import xyz.refinedev.phoenix.handler.ICustomTagHandler;
|
||||
import xyz.refinedev.phoenix.handler.IDatabaseHandler;
|
||||
import xyz.refinedev.phoenix.handler.IFilterHandler;
|
||||
import xyz.refinedev.phoenix.handler.IGrantHandler;
|
||||
import xyz.refinedev.phoenix.handler.IHashHandler;
|
||||
import xyz.refinedev.phoenix.handler.ILoginHandler;
|
||||
import xyz.refinedev.phoenix.handler.IMetricsHandler;
|
||||
import xyz.refinedev.phoenix.handler.INetworkHandler;
|
||||
import xyz.refinedev.phoenix.handler.INotificationHandler;
|
||||
import xyz.refinedev.phoenix.handler.IPlaceholderHandler;
|
||||
import xyz.refinedev.phoenix.handler.IProfileHandler;
|
||||
import xyz.refinedev.phoenix.handler.IPunishmentHandler;
|
||||
import xyz.refinedev.phoenix.handler.IPunishmentLadderHandler;
|
||||
import xyz.refinedev.phoenix.handler.IRankHandler;
|
||||
import xyz.refinedev.phoenix.handler.IReportCategoryHandler;
|
||||
import xyz.refinedev.phoenix.handler.IReportHandler;
|
||||
import xyz.refinedev.phoenix.handler.ISecurityHandler;
|
||||
import xyz.refinedev.phoenix.handler.IServerHopHandler;
|
||||
import xyz.refinedev.phoenix.handler.ITagHandler;
|
||||
import xyz.refinedev.phoenix.handler.IWhitelistHandler;
|
||||
import xyz.refinedev.phoenix.hook.ICosmeticsHook;
|
||||
import xyz.refinedev.phoenix.hook.ILevelHook;
|
||||
import xyz.refinedev.phoenix.hook.IModUtilsHook;
|
||||
import xyz.refinedev.phoenix.packet.api.IPacketHandler;
|
||||
import xyz.refinedev.phoenix.utils.ExecuteOnMainThread;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public interface CommonPlatform {
|
||||
|
||||
boolean start(Logger logger);
|
||||
|
||||
boolean isMainThread(Thread thread);
|
||||
|
||||
void shutdown();
|
||||
|
||||
boolean isMongoDB();
|
||||
|
||||
Gson getGson();
|
||||
|
||||
Logger getLogger();
|
||||
|
||||
IDatabaseHandler getDatabaseHandler();
|
||||
|
||||
IProfileHandler getProfileHandler();
|
||||
|
||||
IRankHandler getRankHandler();
|
||||
|
||||
IHashHandler getHashHandler();
|
||||
|
||||
INetworkHandler getNetworkHandler();
|
||||
|
||||
IWhitelistHandler getWhitelistHandler();
|
||||
|
||||
IFilterHandler getFilterHandler();
|
||||
|
||||
ITagHandler getTagHandler();
|
||||
|
||||
IGrantHandler getGrantHandler();
|
||||
|
||||
IPunishmentHandler getPunishmentHandler();
|
||||
|
||||
ICooldownHandler getCooldownHandler();
|
||||
|
||||
ICommandLogHandler getCommandLogHandler();
|
||||
|
||||
INotificationHandler getNotificationHandler();
|
||||
|
||||
IChatSnapshotHandler getChatSnapshotHandler();
|
||||
|
||||
IPunishmentLadderHandler getPunishmentLadderHandler();
|
||||
|
||||
ISecurityHandler getSecurityHandler();
|
||||
|
||||
IReportHandler getReportHandler();
|
||||
|
||||
IReportCategoryHandler getReportCategoryHandler();
|
||||
|
||||
IPlaceholderHandler getPlaceholderHandler();
|
||||
|
||||
ILoginHandler getLoginHandler();
|
||||
|
||||
IAddressStatsHandler getAddressStatsHandler();
|
||||
|
||||
IAltHandler getAltHandler();
|
||||
|
||||
IServerHopHandler getServerHopHandler();
|
||||
|
||||
IChatLogHandler getChatLogHandler();
|
||||
|
||||
ICustomTagHandler getCustomTagHandler();
|
||||
|
||||
IAnalyticsHandler getAnalyticsHandler();
|
||||
|
||||
IAntiVPNHandler getAntiVPNHandler();
|
||||
|
||||
IMetricsHandler getMetricsHandler();
|
||||
|
||||
IPacketHandler getPacketHandler();
|
||||
|
||||
ConfigHandler getConfigHandler();
|
||||
|
||||
IUUIDCache getUuidCache();
|
||||
|
||||
long getStartedAt();
|
||||
|
||||
long getStoppedAt();
|
||||
|
||||
Map<String, String> getMetaData();
|
||||
|
||||
IModUtilsHook getModUtilsHook();
|
||||
|
||||
ILevelHook getLevelHook();
|
||||
|
||||
ICosmeticsHook getCosmeticsHook();
|
||||
|
||||
ExecuteOnMainThread getExecuteOnMainThread();
|
||||
|
||||
boolean isApiEnabled();
|
||||
|
||||
boolean isDebugMode();
|
||||
|
||||
boolean isUseModernPrefixes();
|
||||
|
||||
boolean isUsingMongoDB();
|
||||
|
||||
Thread getMainThread();
|
||||
|
||||
void setGson(Gson gson);
|
||||
|
||||
void setLogger(Logger logger);
|
||||
|
||||
void setPacketHandler(IPacketHandler packetHandler);
|
||||
|
||||
void setDatabaseHandler(IDatabaseHandler databaseHandler);
|
||||
|
||||
void setProfileHandler(IProfileHandler profileHandler);
|
||||
|
||||
void setRankHandler(IRankHandler rankHandler);
|
||||
|
||||
void setHashHandler(IHashHandler hashHandler);
|
||||
|
||||
void setNetworkHandler(INetworkHandler networkHandler);
|
||||
|
||||
void setWhitelistHandler(IWhitelistHandler whitelistHandler);
|
||||
|
||||
void setFilterHandler(IFilterHandler filterHandler);
|
||||
|
||||
void setTagHandler(ITagHandler tagHandler);
|
||||
|
||||
void setGrantHandler(IGrantHandler grantHandler);
|
||||
|
||||
void setPunishmentHandler(IPunishmentHandler punishmentHandler);
|
||||
|
||||
void setCooldownHandler(ICooldownHandler cooldownHandler);
|
||||
|
||||
void setCommandLogHandler(ICommandLogHandler commandLogHandler);
|
||||
|
||||
void setNotificationHandler(INotificationHandler notificationHandler);
|
||||
|
||||
void setChatSnapshotHandler(IChatSnapshotHandler chatSnapshotHandler);
|
||||
|
||||
void setPunishmentLadderHandler(IPunishmentLadderHandler punishmentLadderHandler);
|
||||
|
||||
void setSecurityHandler(ISecurityHandler securityHandler);
|
||||
|
||||
void setPlaceholderHandler(IPlaceholderHandler placeholderHandler);
|
||||
|
||||
void setLoginHandler(ILoginHandler loginHandler);
|
||||
|
||||
void setAddressStatsHandler(IAddressStatsHandler addressStatsHandler);
|
||||
|
||||
void setAltHandler(IAltHandler altHandler);
|
||||
|
||||
void setServerHopHandler(IServerHopHandler serverHopHandler);
|
||||
|
||||
void setChatLogHandler(IChatLogHandler chatLogHandler);
|
||||
|
||||
void setCustomTagHandler(ICustomTagHandler customTagHandler);
|
||||
|
||||
void setAnalyticsHandler(IAnalyticsHandler analyticsHandler);
|
||||
|
||||
void setAntiVPNHandler(IAntiVPNHandler antiVPNHandler);
|
||||
|
||||
void setMetricsHandler(IMetricsHandler metricsHandler);
|
||||
|
||||
void setConfigHandler(ConfigHandler configHandler);
|
||||
|
||||
void setUuidCache(IUUIDCache uUIDCache);
|
||||
|
||||
void setStartedAt(long value);
|
||||
|
||||
void setStoppedAt(long value);
|
||||
|
||||
void setMetaData(Map<String, String> entries);
|
||||
|
||||
void setModUtilsHook(IModUtilsHook modUtilsHook);
|
||||
|
||||
void setLevelHook(ILevelHook levelHook);
|
||||
|
||||
void setCosmeticsHook(ICosmeticsHook cosmeticsHook);
|
||||
|
||||
void setExecuteOnMainThread(ExecuteOnMainThread executeOnMainThread);
|
||||
|
||||
void setApiEnabled(boolean matches);
|
||||
|
||||
void setDebugMode(boolean matches);
|
||||
|
||||
void setUseModernPrefixes(boolean matches);
|
||||
|
||||
void setMainThread(Thread thread);
|
||||
|
||||
default boolean isFeatureFlag(String text) {
|
||||
return true;
|
||||
}
|
||||
|
||||
default void trackMetric(String text, double value) {}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,899 @@
|
||||
package xyz.refinedev.phoenix;
|
||||
|
||||
import com.google.gson.ExclusionStrategy;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.LongSerializationPolicy;
|
||||
|
||||
import xyz.refinedev.lib.config.ConfigHandler;
|
||||
import xyz.refinedev.phoenix.alt.AddressDensityBackfill;
|
||||
import xyz.refinedev.phoenix.alt.AltSignal;
|
||||
import xyz.refinedev.phoenix.alt.ClientFingerprint;
|
||||
import xyz.refinedev.phoenix.alt.IAltSignal;
|
||||
import xyz.refinedev.phoenix.alt.IClientFingerprint;
|
||||
import xyz.refinedev.phoenix.cache.api.IUUIDCache;
|
||||
import xyz.refinedev.phoenix.config.GlobalConfig;
|
||||
import xyz.refinedev.phoenix.handler.AnalyticsHandler;
|
||||
import xyz.refinedev.phoenix.handler.ChatLogHandler;
|
||||
import xyz.refinedev.phoenix.handler.ChatSnapshotHandler;
|
||||
import xyz.refinedev.phoenix.handler.CommandLogHandler;
|
||||
import xyz.refinedev.phoenix.handler.CooldownHandler;
|
||||
import xyz.refinedev.phoenix.handler.CustomTagHandler;
|
||||
import xyz.refinedev.phoenix.handler.FilterHandler;
|
||||
import xyz.refinedev.phoenix.handler.GrantHandler;
|
||||
import xyz.refinedev.phoenix.handler.HashHandler;
|
||||
import xyz.refinedev.phoenix.handler.IAddressStatsHandler;
|
||||
import xyz.refinedev.phoenix.handler.IAltHandler;
|
||||
import xyz.refinedev.phoenix.handler.IAnalyticsHandler;
|
||||
import xyz.refinedev.phoenix.handler.IAntiVPNHandler;
|
||||
import xyz.refinedev.phoenix.handler.IChatLogHandler;
|
||||
import xyz.refinedev.phoenix.handler.IChatSnapshotHandler;
|
||||
import xyz.refinedev.phoenix.handler.ICommandLogHandler;
|
||||
import xyz.refinedev.phoenix.handler.ICooldownHandler;
|
||||
import xyz.refinedev.phoenix.handler.ICustomTagHandler;
|
||||
import xyz.refinedev.phoenix.handler.IDatabaseHandler;
|
||||
import xyz.refinedev.phoenix.handler.IFilterHandler;
|
||||
import xyz.refinedev.phoenix.handler.IGrantHandler;
|
||||
import xyz.refinedev.phoenix.handler.IHashHandler;
|
||||
import xyz.refinedev.phoenix.handler.ILoginHandler;
|
||||
import xyz.refinedev.phoenix.handler.IMetricsHandler;
|
||||
import xyz.refinedev.phoenix.handler.INetworkHandler;
|
||||
import xyz.refinedev.phoenix.handler.INotificationHandler;
|
||||
import xyz.refinedev.phoenix.handler.IPlaceholderHandler;
|
||||
import xyz.refinedev.phoenix.handler.IProfileHandler;
|
||||
import xyz.refinedev.phoenix.handler.IPunishmentHandler;
|
||||
import xyz.refinedev.phoenix.handler.IPunishmentLadderHandler;
|
||||
import xyz.refinedev.phoenix.handler.IRankHandler;
|
||||
import xyz.refinedev.phoenix.handler.IReportCategoryHandler;
|
||||
import xyz.refinedev.phoenix.handler.IReportHandler;
|
||||
import xyz.refinedev.phoenix.handler.ISecurityHandler;
|
||||
import xyz.refinedev.phoenix.handler.IServerHopHandler;
|
||||
import xyz.refinedev.phoenix.handler.ITagHandler;
|
||||
import xyz.refinedev.phoenix.handler.IWhitelistHandler;
|
||||
import xyz.refinedev.phoenix.handler.LoginHandler;
|
||||
import xyz.refinedev.phoenix.handler.MetricsHandler;
|
||||
import xyz.refinedev.phoenix.handler.MongoAddressStatsHandler;
|
||||
import xyz.refinedev.phoenix.handler.MongoAltHandler;
|
||||
import xyz.refinedev.phoenix.handler.PlaceholderHandler;
|
||||
import xyz.refinedev.phoenix.handler.ProfileHandler;
|
||||
import xyz.refinedev.phoenix.handler.PunishmentHandler;
|
||||
import xyz.refinedev.phoenix.handler.PunishmentLadderHandler;
|
||||
import xyz.refinedev.phoenix.handler.RankHandler;
|
||||
import xyz.refinedev.phoenix.handler.RedisAntiVPNHandler;
|
||||
import xyz.refinedev.phoenix.handler.RedisNetworkHandler;
|
||||
import xyz.refinedev.phoenix.handler.RedisNotificationHandler;
|
||||
import xyz.refinedev.phoenix.handler.ReportCategoryHandler;
|
||||
import xyz.refinedev.phoenix.handler.ReportHandler;
|
||||
import xyz.refinedev.phoenix.handler.SecurityHandler;
|
||||
import xyz.refinedev.phoenix.handler.ServerHopHandler;
|
||||
import xyz.refinedev.phoenix.handler.TagHandler;
|
||||
import xyz.refinedev.phoenix.handler.WhitelistHandler;
|
||||
import xyz.refinedev.phoenix.handler.database.MongoDatabaseHandler;
|
||||
import xyz.refinedev.phoenix.handler.database.MySQLDatabaseHandler;
|
||||
import xyz.refinedev.phoenix.handler.database.local.LocalRedis;
|
||||
import xyz.refinedev.phoenix.hook.ICosmeticsHook;
|
||||
import xyz.refinedev.phoenix.hook.ILevelHook;
|
||||
import xyz.refinedev.phoenix.hook.IModUtilsHook;
|
||||
import xyz.refinedev.phoenix.hook.impl.CosmeticsHook;
|
||||
import xyz.refinedev.phoenix.hook.impl.LevelHook;
|
||||
import xyz.refinedev.phoenix.hook.impl.ModUtilsHook;
|
||||
import xyz.refinedev.phoenix.notification.INotification;
|
||||
import xyz.refinedev.phoenix.notification.Notification;
|
||||
import xyz.refinedev.phoenix.packet.api.IPacketHandler;
|
||||
import xyz.refinedev.phoenix.packet.api.PacketHandler;
|
||||
import xyz.refinedev.phoenix.profile.INameChange;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.NameChange;
|
||||
import xyz.refinedev.phoenix.profile.RedisProfile;
|
||||
import xyz.refinedev.phoenix.profile.antivpn.AntiVPNData;
|
||||
import xyz.refinedev.phoenix.profile.antivpn.IAntiVPNData;
|
||||
import xyz.refinedev.phoenix.profile.chatsnapshot.ChatEntry;
|
||||
import xyz.refinedev.phoenix.profile.chatsnapshot.ChatLog;
|
||||
import xyz.refinedev.phoenix.profile.chatsnapshot.ChatSnapshot;
|
||||
import xyz.refinedev.phoenix.profile.chatsnapshot.IChatEntry;
|
||||
import xyz.refinedev.phoenix.profile.chatsnapshot.IChatLog;
|
||||
import xyz.refinedev.phoenix.profile.chatsnapshot.IChatSnapshot;
|
||||
import xyz.refinedev.phoenix.profile.commandlog.CommandLog;
|
||||
import xyz.refinedev.phoenix.profile.commandlog.ICommandLog;
|
||||
import xyz.refinedev.phoenix.profile.cooldown.Cooldown;
|
||||
import xyz.refinedev.phoenix.profile.cooldown.ICooldown;
|
||||
import xyz.refinedev.phoenix.profile.disguise.DisguiseData;
|
||||
import xyz.refinedev.phoenix.profile.disguise.DisguiseHistory;
|
||||
import xyz.refinedev.phoenix.profile.disguise.IDisguiseData;
|
||||
import xyz.refinedev.phoenix.profile.disguise.IDisguiseHistory;
|
||||
import xyz.refinedev.phoenix.profile.disguise.ISkin;
|
||||
import xyz.refinedev.phoenix.profile.disguise.Skin;
|
||||
import xyz.refinedev.phoenix.profile.filter.Filter;
|
||||
import xyz.refinedev.phoenix.profile.filter.IFilter;
|
||||
import xyz.refinedev.phoenix.profile.grant.Grant;
|
||||
import xyz.refinedev.phoenix.profile.grant.IGrant;
|
||||
import xyz.refinedev.phoenix.profile.hop.IServerHop;
|
||||
import xyz.refinedev.phoenix.profile.hop.ServerHop;
|
||||
import xyz.refinedev.phoenix.profile.login.ILogin;
|
||||
import xyz.refinedev.phoenix.profile.login.Login;
|
||||
import xyz.refinedev.phoenix.profile.notes.INote;
|
||||
import xyz.refinedev.phoenix.profile.notes.Note;
|
||||
import xyz.refinedev.phoenix.profile.permission.IProfilePermission;
|
||||
import xyz.refinedev.phoenix.profile.permission.ProfilePermission;
|
||||
import xyz.refinedev.phoenix.profile.punishment.IProof;
|
||||
import xyz.refinedev.phoenix.profile.punishment.IPunishment;
|
||||
import xyz.refinedev.phoenix.profile.punishment.Proof;
|
||||
import xyz.refinedev.phoenix.profile.punishment.Punishment;
|
||||
import xyz.refinedev.phoenix.profile.punishment.banwave.BanWave;
|
||||
import xyz.refinedev.phoenix.profile.punishment.banwave.BanWaveEntry;
|
||||
import xyz.refinedev.phoenix.profile.punishment.banwave.IBanWave;
|
||||
import xyz.refinedev.phoenix.profile.punishment.banwave.IBanWaveEntry;
|
||||
import xyz.refinedev.phoenix.profile.punishment.ladder.IPunishmentLadder;
|
||||
import xyz.refinedev.phoenix.profile.punishment.ladder.IPunishmentLadderType;
|
||||
import xyz.refinedev.phoenix.profile.punishment.ladder.PunishmentLadder;
|
||||
import xyz.refinedev.phoenix.profile.punishment.ladder.PunishmentLadderType;
|
||||
import xyz.refinedev.phoenix.profile.security.ISecurityUser;
|
||||
import xyz.refinedev.phoenix.profile.security.SecurityUser;
|
||||
import xyz.refinedev.phoenix.profile.tag.CustomTag;
|
||||
import xyz.refinedev.phoenix.profile.tag.ICustomTag;
|
||||
import xyz.refinedev.phoenix.profile.tag.ITag;
|
||||
import xyz.refinedev.phoenix.profile.tag.ITagCategory;
|
||||
import xyz.refinedev.phoenix.profile.tag.Tag;
|
||||
import xyz.refinedev.phoenix.profile.tag.TagCategory;
|
||||
import xyz.refinedev.phoenix.rank.IRank;
|
||||
import xyz.refinedev.phoenix.rank.Rank;
|
||||
import xyz.refinedev.phoenix.rank.permission.IPermission;
|
||||
import xyz.refinedev.phoenix.rank.permission.Permission;
|
||||
import xyz.refinedev.phoenix.report.IReport;
|
||||
import xyz.refinedev.phoenix.report.IReportCategory;
|
||||
import xyz.refinedev.phoenix.report.Report;
|
||||
import xyz.refinedev.phoenix.report.ReportCategory;
|
||||
import xyz.refinedev.phoenix.repository.impl.RedisUUIDCache;
|
||||
import xyz.refinedev.phoenix.scope.IScope;
|
||||
import xyz.refinedev.phoenix.scope.Scope;
|
||||
import xyz.refinedev.phoenix.server.IServerData;
|
||||
import xyz.refinedev.phoenix.server.IWhitelistInfo;
|
||||
import xyz.refinedev.phoenix.server.ServerData;
|
||||
import xyz.refinedev.phoenix.server.WhitelistInfo;
|
||||
import xyz.refinedev.phoenix.utils.DateUtils;
|
||||
import xyz.refinedev.phoenix.utils.ExecuteOnMainThread;
|
||||
import xyz.refinedev.phoenix.utils.GsonExclusionStrategy;
|
||||
import xyz.refinedev.phoenix.utils.gson.EnumTypeAdapterFactory;
|
||||
import xyz.refinedev.phoenix.utils.gson.OptionalTypeAdapterFactory;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class PhoenixPlatform implements CommonPlatform {
|
||||
|
||||
public static CommonPlatform platform;
|
||||
|
||||
private Gson gson;
|
||||
|
||||
private Logger logger;
|
||||
|
||||
private IDatabaseHandler databaseHandler;
|
||||
|
||||
private ConfigHandler configHandler;
|
||||
|
||||
private IProfileHandler profileHandler;
|
||||
|
||||
private IRankHandler rankHandler;
|
||||
|
||||
private IHashHandler hashHandler;
|
||||
|
||||
private INetworkHandler networkHandler;
|
||||
|
||||
private IWhitelistHandler whitelistHandler;
|
||||
|
||||
private IFilterHandler filterHandler;
|
||||
|
||||
private ITagHandler tagHandler;
|
||||
|
||||
private IGrantHandler grantHandler;
|
||||
|
||||
private IPunishmentHandler punishmentHandler;
|
||||
|
||||
private ICooldownHandler cooldownHandler;
|
||||
|
||||
private ICommandLogHandler commandLogHandler;
|
||||
|
||||
private INotificationHandler notificationHandler;
|
||||
|
||||
private IChatSnapshotHandler chatSnapshotHandler;
|
||||
|
||||
private IPunishmentLadderHandler punishmentLadderHandler;
|
||||
|
||||
private IReportHandler reportHandler;
|
||||
|
||||
private IReportCategoryHandler reportCategoryHandler;
|
||||
|
||||
private ISecurityHandler securityHandler;
|
||||
|
||||
private IPlaceholderHandler placeholderHandler;
|
||||
|
||||
private ILoginHandler loginHandler;
|
||||
|
||||
private IAddressStatsHandler addressStatsHandler;
|
||||
|
||||
private IAltHandler altHandler;
|
||||
|
||||
private IServerHopHandler serverHopHandler;
|
||||
|
||||
private IChatLogHandler chatLogHandler;
|
||||
|
||||
private ICustomTagHandler customTagHandler;
|
||||
|
||||
private IAnalyticsHandler analyticsHandler;
|
||||
|
||||
private IAntiVPNHandler antiVPNHandler;
|
||||
|
||||
private IMetricsHandler metricsHandler;
|
||||
|
||||
private IPacketHandler packetHandler;
|
||||
|
||||
private IUUIDCache uuidCache;
|
||||
|
||||
private long startedAt = 0L;
|
||||
|
||||
private long stoppedAt = 0L;
|
||||
|
||||
private Map<String, String> metaData = new ConcurrentHashMap<>();
|
||||
|
||||
private IModUtilsHook modUtilsHook = new ModUtilsHook();
|
||||
|
||||
private ILevelHook levelHook = new LevelHook();
|
||||
|
||||
private ICosmeticsHook cosmeticsHook = new CosmeticsHook();
|
||||
|
||||
private ExecuteOnMainThread executeOnMainThread;
|
||||
|
||||
public boolean apiEnabled = false;
|
||||
|
||||
public boolean debugMode = false;
|
||||
|
||||
public boolean useModernPrefixes = false;
|
||||
|
||||
public boolean mongoDB = true;
|
||||
|
||||
private Thread mainThread;
|
||||
|
||||
@Override
|
||||
public boolean start(Logger logger2) {
|
||||
if (this.executeOnMainThread == null) {
|
||||
logger2.severe("Execute on main thread is null.");
|
||||
System.exit(0);
|
||||
return false;
|
||||
}
|
||||
this.logger = logger2;
|
||||
platform = this;
|
||||
PlatformGetter.instance = this;
|
||||
this.configHandler = new ConfigHandler(logger2);
|
||||
new GlobalConfig(this.configHandler).load();
|
||||
this.gson =
|
||||
new GsonBuilder()
|
||||
.setPrettyPrinting()
|
||||
.serializeNulls()
|
||||
.setExclusionStrategies(
|
||||
new ExclusionStrategy[] {new GsonExclusionStrategy()})
|
||||
.setLongSerializationPolicy(LongSerializationPolicy.STRING)
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(INotification.class, Notification.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IAntiVPNData.class, AntiVPNData.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IChatEntry.class, ChatEntry.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IChatLog.class, ChatLog.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IChatSnapshot.class, ChatSnapshot.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(ICommandLog.class, CommandLog.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(ICooldown.class, Cooldown.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IDisguiseData.class, DisguiseData.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(
|
||||
IDisguiseHistory.class, DisguiseHistory.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(ISkin.class, Skin.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IFilter.class, Filter.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IGrant.class, Grant.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(ILogin.class, Login.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IServerHop.class, ServerHop.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(INote.class, Note.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(INameChange.class, NameChange.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(
|
||||
IProfilePermission.class, ProfilePermission.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(
|
||||
IPunishmentLadder.class, PunishmentLadder.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(
|
||||
IPunishmentLadderType.class, PunishmentLadderType.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IProof.class, Proof.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IBanWave.class, BanWave.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IBanWaveEntry.class, BanWaveEntry.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IPunishment.class, Punishment.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IReport.class, Report.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(
|
||||
IReportCategory.class, ReportCategory.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(ISecurityUser.class, SecurityUser.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(ICustomTag.class, CustomTag.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(ITag.class, Tag.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(ITagCategory.class, TagCategory.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IProfile.class, RedisProfile.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IScope.class, Scope.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IRank.class, Rank.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IPermission.class, Permission.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(
|
||||
IWhitelistInfo.class, WhitelistInfo.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IServerData.class, ServerData.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(IAltSignal.class, AltSignal.class))
|
||||
.registerTypeAdapterFactory(
|
||||
EnumTypeAdapterFactory.of(
|
||||
IClientFingerprint.class, ClientFingerprint.class))
|
||||
.registerTypeAdapterFactory(new OptionalTypeAdapterFactory())
|
||||
.create();
|
||||
if (GlobalConfig.DATABASE.DATABASE_TYPE.equalsIgnoreCase("MySQL")) {
|
||||
this.databaseHandler = new MySQLDatabaseHandler(this);
|
||||
this.mongoDB = false;
|
||||
} else {
|
||||
this.databaseHandler = new MongoDatabaseHandler(this);
|
||||
this.mongoDB = true;
|
||||
}
|
||||
if (LocalRedis.matchesEnabled(logger2, "the REST API")) {
|
||||
return false;
|
||||
}
|
||||
if (!this.databaseHandler.enable()) {
|
||||
logger2.severe("There was an issue with the database! Disabling...");
|
||||
return false;
|
||||
}
|
||||
this.packetHandler = new PacketHandler(this);
|
||||
this.packetHandler.enable();
|
||||
this.useModernPrefixes = GlobalConfig.SERVER.USE_MODERN_RANK_PREFIX;
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(GlobalConfig.SERVER.DATE_FORMAT);
|
||||
try {
|
||||
simpleDateFormat.setTimeZone(TimeZone.getTimeZone(GlobalConfig.SERVER.TIMEZONE));
|
||||
logger2.info("TimeZone in use: " + GlobalConfig.SERVER.TIMEZONE);
|
||||
} catch (Exception exception) {
|
||||
logger2.severe("Failed to set TimeZone to: " + GlobalConfig.SERVER.TIMEZONE);
|
||||
}
|
||||
DateUtils.setDateFormat(simpleDateFormat);
|
||||
this.analyticsHandler = new AnalyticsHandler(this);
|
||||
this.whitelistHandler = new WhitelistHandler(this);
|
||||
this.rankHandler = new RankHandler(this);
|
||||
this.profileHandler = new ProfileHandler(this);
|
||||
this.networkHandler = new RedisNetworkHandler(this);
|
||||
this.analyticsHandler.cleanUp();
|
||||
this.hashHandler = new HashHandler();
|
||||
this.filterHandler = new FilterHandler(this);
|
||||
this.tagHandler = new TagHandler(this);
|
||||
this.grantHandler = new GrantHandler(this);
|
||||
this.punishmentHandler = new PunishmentHandler(this);
|
||||
this.loginHandler = new LoginHandler(this);
|
||||
this.addressStatsHandler = new MongoAddressStatsHandler(this);
|
||||
this.altHandler = new MongoAltHandler(this);
|
||||
new AddressDensityBackfill(this).initialize();
|
||||
this.serverHopHandler = new ServerHopHandler(this);
|
||||
this.cooldownHandler = new CooldownHandler();
|
||||
this.commandLogHandler = new CommandLogHandler(this);
|
||||
this.notificationHandler = new RedisNotificationHandler(this);
|
||||
this.chatSnapshotHandler = new ChatSnapshotHandler(this);
|
||||
this.punishmentLadderHandler = new PunishmentLadderHandler(this);
|
||||
this.reportCategoryHandler = new ReportCategoryHandler(this);
|
||||
this.reportHandler = new ReportHandler(this);
|
||||
this.securityHandler = new SecurityHandler(this);
|
||||
this.chatLogHandler = new ChatLogHandler(this);
|
||||
this.placeholderHandler = new PlaceholderHandler();
|
||||
this.customTagHandler = new CustomTagHandler(this);
|
||||
this.antiVPNHandler = new RedisAntiVPNHandler(this);
|
||||
this.antiVPNHandler.fetchAntiVpnBypass();
|
||||
this.metricsHandler = new MetricsHandler(this);
|
||||
this.metricsHandler.start();
|
||||
this.uuidCache = new RedisUUIDCache(this);
|
||||
this.uuidCache.loadFromCache();
|
||||
Calendar calendar;
|
||||
if ((calendar = Calendar.getInstance()).get(5) == 25 && calendar.get(2) == 11) {
|
||||
logger2.info("We at the Refine Development team wish you a merry christmas!");
|
||||
}
|
||||
this.apiEnabled = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMainThread(Thread thread) {
|
||||
return this.mainThread == null ? false : thread == this.mainThread;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
this.networkHandler.saveMetadata();
|
||||
if (this.metricsHandler != null) {
|
||||
this.metricsHandler.stop();
|
||||
}
|
||||
this.packetHandler.disable();
|
||||
this.databaseHandler.disable();
|
||||
this.apiEnabled = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMongoDB() {
|
||||
return this.mongoDB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Gson getGson() {
|
||||
return this.gson;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getLogger() {
|
||||
return this.logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDatabaseHandler getDatabaseHandler() {
|
||||
return this.databaseHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigHandler getConfigHandler() {
|
||||
return this.configHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IProfileHandler getProfileHandler() {
|
||||
return this.profileHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRankHandler getRankHandler() {
|
||||
return this.rankHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IHashHandler getHashHandler() {
|
||||
return this.hashHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public INetworkHandler getNetworkHandler() {
|
||||
return this.networkHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWhitelistHandler getWhitelistHandler() {
|
||||
return this.whitelistHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFilterHandler getFilterHandler() {
|
||||
return this.filterHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITagHandler getTagHandler() {
|
||||
return this.tagHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGrantHandler getGrantHandler() {
|
||||
return this.grantHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPunishmentHandler getPunishmentHandler() {
|
||||
return this.punishmentHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICooldownHandler getCooldownHandler() {
|
||||
return this.cooldownHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICommandLogHandler getCommandLogHandler() {
|
||||
return this.commandLogHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public INotificationHandler getNotificationHandler() {
|
||||
return this.notificationHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChatSnapshotHandler getChatSnapshotHandler() {
|
||||
return this.chatSnapshotHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPunishmentLadderHandler getPunishmentLadderHandler() {
|
||||
return this.punishmentLadderHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IReportHandler getReportHandler() {
|
||||
return this.reportHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IReportCategoryHandler getReportCategoryHandler() {
|
||||
return this.reportCategoryHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISecurityHandler getSecurityHandler() {
|
||||
return this.securityHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPlaceholderHandler getPlaceholderHandler() {
|
||||
return this.placeholderHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILoginHandler getLoginHandler() {
|
||||
return this.loginHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAddressStatsHandler getAddressStatsHandler() {
|
||||
return this.addressStatsHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAltHandler getAltHandler() {
|
||||
return this.altHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IServerHopHandler getServerHopHandler() {
|
||||
return this.serverHopHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChatLogHandler getChatLogHandler() {
|
||||
return this.chatLogHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICustomTagHandler getCustomTagHandler() {
|
||||
return this.customTagHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAnalyticsHandler getAnalyticsHandler() {
|
||||
return this.analyticsHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAntiVPNHandler getAntiVPNHandler() {
|
||||
return this.antiVPNHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMetricsHandler getMetricsHandler() {
|
||||
return this.metricsHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacketHandler getPacketHandler() {
|
||||
return this.packetHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IUUIDCache getUuidCache() {
|
||||
return this.uuidCache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStartedAt() {
|
||||
return this.startedAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStoppedAt() {
|
||||
return this.stoppedAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMetaData() {
|
||||
return this.metaData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModUtilsHook getModUtilsHook() {
|
||||
return this.modUtilsHook;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILevelHook getLevelHook() {
|
||||
return this.levelHook;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICosmeticsHook getCosmeticsHook() {
|
||||
return this.cosmeticsHook;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExecuteOnMainThread getExecuteOnMainThread() {
|
||||
return this.executeOnMainThread;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApiEnabled() {
|
||||
return this.apiEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebugMode() {
|
||||
return this.debugMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseModernPrefixes() {
|
||||
return this.useModernPrefixes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsingMongoDB() {
|
||||
return this.mongoDB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Thread getMainThread() {
|
||||
return this.mainThread;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGson(Gson gson2) {
|
||||
this.gson = gson2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogger(Logger logger2) {
|
||||
this.logger = logger2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDatabaseHandler(IDatabaseHandler databaseHandler2) {
|
||||
this.databaseHandler = databaseHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfigHandler(ConfigHandler configHandler2) {
|
||||
this.configHandler = configHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProfileHandler(IProfileHandler profileHandler2) {
|
||||
this.profileHandler = profileHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRankHandler(IRankHandler rankHandler2) {
|
||||
this.rankHandler = rankHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHashHandler(IHashHandler hashHandler2) {
|
||||
this.hashHandler = hashHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetworkHandler(INetworkHandler networkHandler2) {
|
||||
this.networkHandler = networkHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWhitelistHandler(IWhitelistHandler whitelistHandler2) {
|
||||
this.whitelistHandler = whitelistHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFilterHandler(IFilterHandler filterHandler2) {
|
||||
this.filterHandler = filterHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTagHandler(ITagHandler tagHandler2) {
|
||||
this.tagHandler = tagHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGrantHandler(IGrantHandler grantHandler2) {
|
||||
this.grantHandler = grantHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPunishmentHandler(IPunishmentHandler punishmentHandler2) {
|
||||
this.punishmentHandler = punishmentHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCooldownHandler(ICooldownHandler cooldownHandler2) {
|
||||
this.cooldownHandler = cooldownHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCommandLogHandler(ICommandLogHandler commandLogHandler2) {
|
||||
this.commandLogHandler = commandLogHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNotificationHandler(INotificationHandler notificationHandler2) {
|
||||
this.notificationHandler = notificationHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChatSnapshotHandler(IChatSnapshotHandler chatSnapshotHandler2) {
|
||||
this.chatSnapshotHandler = chatSnapshotHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPunishmentLadderHandler(IPunishmentLadderHandler punishmentLadderHandler2) {
|
||||
this.punishmentLadderHandler = punishmentLadderHandler2;
|
||||
}
|
||||
|
||||
public void setReportHandler(IReportHandler reportHandler2) {
|
||||
this.reportHandler = reportHandler2;
|
||||
}
|
||||
|
||||
public void setReportCategoryHandler(IReportCategoryHandler reportCategoryHandler2) {
|
||||
this.reportCategoryHandler = reportCategoryHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecurityHandler(ISecurityHandler securityHandler2) {
|
||||
this.securityHandler = securityHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlaceholderHandler(IPlaceholderHandler placeholderHandler2) {
|
||||
this.placeholderHandler = placeholderHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoginHandler(ILoginHandler loginHandler2) {
|
||||
this.loginHandler = loginHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAddressStatsHandler(IAddressStatsHandler addressStatsHandler2) {
|
||||
this.addressStatsHandler = addressStatsHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAltHandler(IAltHandler altHandler2) {
|
||||
this.altHandler = altHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setServerHopHandler(IServerHopHandler serverHopHandler2) {
|
||||
this.serverHopHandler = serverHopHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChatLogHandler(IChatLogHandler chatLogHandler2) {
|
||||
this.chatLogHandler = chatLogHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomTagHandler(ICustomTagHandler customTagHandler2) {
|
||||
this.customTagHandler = customTagHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAnalyticsHandler(IAnalyticsHandler analyticsHandler2) {
|
||||
this.analyticsHandler = analyticsHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAntiVPNHandler(IAntiVPNHandler antiVPNHandler2) {
|
||||
this.antiVPNHandler = antiVPNHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetricsHandler(IMetricsHandler metricsHandler2) {
|
||||
this.metricsHandler = metricsHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPacketHandler(IPacketHandler packetHandler2) {
|
||||
this.packetHandler = packetHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUuidCache(IUUIDCache uUIDCache) {
|
||||
this.uuidCache = uUIDCache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStartedAt(long startedAt) {
|
||||
this.startedAt = startedAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStoppedAt(long stoppedAt) {
|
||||
this.stoppedAt = stoppedAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetaData(Map<String, String> entries) {
|
||||
this.metaData = entries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setModUtilsHook(IModUtilsHook modUtilsHook2) {
|
||||
this.modUtilsHook = modUtilsHook2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLevelHook(ILevelHook levelHook2) {
|
||||
this.levelHook = levelHook2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCosmeticsHook(ICosmeticsHook cosmeticsHook2) {
|
||||
this.cosmeticsHook = cosmeticsHook2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExecuteOnMainThread(ExecuteOnMainThread executeOnMainThread2) {
|
||||
this.executeOnMainThread = executeOnMainThread2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApiEnabled(boolean apiEnabled) {
|
||||
this.apiEnabled = apiEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDebugMode(boolean debugMode) {
|
||||
this.debugMode = debugMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUseModernPrefixes(boolean useModernPrefixes) {
|
||||
this.useModernPrefixes = useModernPrefixes;
|
||||
}
|
||||
|
||||
public void setMongoDB(boolean mongoDB) {
|
||||
this.mongoDB = mongoDB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMainThread(Thread thread) {
|
||||
this.mainThread = thread;
|
||||
}
|
||||
|
||||
public static CommonPlatform getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package xyz.refinedev.phoenix;
|
||||
|
||||
public class PlatformGetter {
|
||||
|
||||
public static CommonPlatform instance;
|
||||
|
||||
public static CommonPlatform getInstance() {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
public enum AddressClassification {
|
||||
UNKNOWN,
|
||||
HOUSEHOLD,
|
||||
SHARED,
|
||||
FORCED_SHARED,
|
||||
FORCED_TRUSTED
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
public class AddressDensity {
|
||||
|
||||
private final String text;
|
||||
|
||||
private final String textString;
|
||||
|
||||
private final int count;
|
||||
|
||||
private final int countCount;
|
||||
|
||||
private final int count2;
|
||||
|
||||
private final long time;
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
private boolean enabledEnabled;
|
||||
|
||||
private AddressClassification addressClassification = AddressClassification.UNKNOWN;
|
||||
|
||||
public String getText() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public String getTextString() {
|
||||
return this.textString;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return this.count;
|
||||
}
|
||||
|
||||
public int getCountCount() {
|
||||
return this.countCount;
|
||||
}
|
||||
|
||||
public int getCount2() {
|
||||
return this.count2;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return this.time;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public boolean isEnabledEnabled() {
|
||||
return this.enabledEnabled;
|
||||
}
|
||||
|
||||
public AddressClassification getAddressClassification() {
|
||||
return this.addressClassification;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public void setEnabledEnabled(boolean enabledEnabled) {
|
||||
this.enabledEnabled = enabledEnabled;
|
||||
}
|
||||
|
||||
public void setAddressClassification(AddressClassification addressClassification2) {
|
||||
this.addressClassification = addressClassification2;
|
||||
}
|
||||
|
||||
public AddressDensity(
|
||||
String text, String textString, int count, int countCount, int count2, long time) {
|
||||
this.text = text;
|
||||
this.textString = textString;
|
||||
this.count = count;
|
||||
this.countCount = countCount;
|
||||
this.count2 = count2;
|
||||
this.time = time;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import xyz.refinedev.lib.bson.Document;
|
||||
import xyz.refinedev.lib.mongodb.client.MongoCollection;
|
||||
import xyz.refinedev.lib.mongodb.client.MongoCursor;
|
||||
import xyz.refinedev.phoenix.CommonPlatform;
|
||||
import xyz.refinedev.phoenix.config.GlobalConfig;
|
||||
import xyz.refinedev.phoenix.handler.MongoAddressStatsHandler;
|
||||
import xyz.refinedev.phoenix.handler.database.AbstractDatabaseHandler;
|
||||
import xyz.refinedev.phoenix.handler.database.MongoDatabaseHandler;
|
||||
import xyz.refinedev.phoenix.handler.database.MySQLDatabaseHandler;
|
||||
import xyz.refinedev.phoenix.repository.IAddressStatsRepository;
|
||||
import xyz.refinedev.phoenix.utils.mysql.SQLBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class AddressDensityBackfill {
|
||||
|
||||
public static final String text = "__backfill_marker__";
|
||||
|
||||
private final CommonPlatform platform;
|
||||
|
||||
public AddressDensityBackfill(CommonPlatform commonPlatform) {
|
||||
this.platform = commonPlatform;
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
if (GlobalConfig.SERVER.ALTS.ENABLED) {
|
||||
if (GlobalConfig.SERVER.ALTS.SHARED_ADDRESS.BACKFILL_ON_STARTUP) {
|
||||
if (!this.platform
|
||||
.getAddressStatsHandler()
|
||||
.getRepository()
|
||||
.fetchSync("__backfill_marker__")
|
||||
.isPresent()) {
|
||||
AddressDensityBackfill addressDensityBackfill = this;
|
||||
CompletableFuture.runAsync(
|
||||
addressDensityBackfill::initializeByPlatform,
|
||||
AbstractDatabaseHandler.DB_EXECUTOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void initializeByPlatform() {
|
||||
long now = System.currentTimeMillis();
|
||||
this.platform
|
||||
.getLogger()
|
||||
.info(
|
||||
"(Alts) Backfilling address density from login history. On a large database this runs once and may take a while.");
|
||||
try {
|
||||
int value = this.platform.isMongoDB() ? this.getLogins() : this.getCount();
|
||||
AddressStats addressStats;
|
||||
(addressStats = new AddressStats("__backfill_marker__")).setAccounts(value);
|
||||
this.platform
|
||||
.getAddressStatsHandler()
|
||||
.getRepository()
|
||||
.saveSync("__backfill_marker__", addressStats);
|
||||
this.platform
|
||||
.getLogger()
|
||||
.info(
|
||||
"(Alts) Address density backfill complete: "
|
||||
+ value
|
||||
+ " addresses and subnets in "
|
||||
+ (System.currentTimeMillis() - now)
|
||||
+ "ms.");
|
||||
} catch (Exception exception) {
|
||||
this.platform
|
||||
.getLogger()
|
||||
.log(
|
||||
Level.SEVERE,
|
||||
"(Alts) Address density backfill failed - it will retry on next startup.",
|
||||
exception);
|
||||
}
|
||||
}
|
||||
|
||||
private int getLogins() {
|
||||
MongoCollection logins = this.getDatabaseHandler().getLogins();
|
||||
return this.calculateCount(this.findMap(logins, "ip"))
|
||||
+ this.calculateCount(this.findMap(logins, "subnet"));
|
||||
}
|
||||
|
||||
private Map<String, Integer> findMap(MongoCollection<Document> mongoCollection, String text) {
|
||||
List<Document> values =
|
||||
Arrays.asList(
|
||||
new Document("$match", new Document(text, new Document("$ne", null))),
|
||||
new Document(
|
||||
"$group",
|
||||
new Document(
|
||||
"_id",
|
||||
new Document("a", "$" + text).append("t", "$target"))),
|
||||
new Document(
|
||||
"$group",
|
||||
new Document("_id", "$_id.a")
|
||||
.append("count", new Document("$sum", 1))));
|
||||
HashMap<String, Integer> entries = new HashMap<>();
|
||||
MongoCursor mongoCursor = mongoCollection.aggregate(values).allowDiskUse(true).iterator();
|
||||
while (mongoCursor.hasNext()) {
|
||||
Document document;
|
||||
Object result;
|
||||
if ((result = (document = (Document) mongoCursor.next()).get("_id"))
|
||||
instanceof String) {
|
||||
entries.put((String) result, document.getInteger("count", 0));
|
||||
}
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
private int getCount() throws Exception {
|
||||
String name = this.getDatabaseHandlerByPlatform().getLogins().getName();
|
||||
return this.calculateCount(this.findMap(name, "ip"))
|
||||
+ this.calculateCount(this.findMap(name, "subnet"));
|
||||
}
|
||||
|
||||
private Map<String, Integer> findMap(String text, String text2) throws Exception {
|
||||
HashMap<String, Integer> entries = new HashMap<>();
|
||||
SQLBuilder sQLBuilder = new SQLBuilder();
|
||||
try {
|
||||
sQLBuilder.setStatement(
|
||||
"SELECT JSON_UNQUOTE(JSON_EXTRACT(data, '$."
|
||||
+ text2
|
||||
+ "')) AS addr, COUNT(DISTINCT JSON_UNQUOTE(JSON_EXTRACT(data, '$.target'))) AS accounts FROM "
|
||||
+ text
|
||||
+ " GROUP BY addr HAVING addr IS NOT NULL");
|
||||
sQLBuilder.executeQuery();
|
||||
while (sQLBuilder.next()) {
|
||||
Object object = sQLBuilder.getObject(1);
|
||||
Object object2 = sQLBuilder.getObject(2);
|
||||
if (object instanceof String && object2 instanceof Number) {
|
||||
entries.put((String) object, ((Number) object2).intValue());
|
||||
}
|
||||
}
|
||||
} catch (Throwable throwable) {
|
||||
try {
|
||||
sQLBuilder.close();
|
||||
} catch (Throwable throwable2) {
|
||||
throwable.addSuppressed(throwable2);
|
||||
}
|
||||
throw throwable;
|
||||
}
|
||||
sQLBuilder.close();
|
||||
return entries;
|
||||
}
|
||||
|
||||
private int calculateCount(Map<String, Integer> entries) {
|
||||
IAddressStatsRepository repository = this.platform.getAddressStatsHandler().getRepository();
|
||||
int value = Math.max(100, GlobalConfig.SERVER.ALTS.SHARED_ADDRESS.BACKFILL_CHUNK_SIZE);
|
||||
int value2 = GlobalConfig.SERVER.ALTS.SHARED_ADDRESS.AUTO_CLASSIFY_AT;
|
||||
int value3 = GlobalConfig.SERVER.ALTS.SCORE.HOUSEHOLD_SIZE;
|
||||
ArrayList values = new ArrayList(entries.keySet());
|
||||
int value4 = 0;
|
||||
for (int index = 0; index < values.size(); index += value) {
|
||||
List<String> values2 = values.subList(index, Math.min(values.size(), index + value));
|
||||
Map entries2 = this.platform.getAddressStatsHandler().fetch(new HashSet<>(values2));
|
||||
for (String text : values2) {
|
||||
IAddressStats addressStats;
|
||||
if ((addressStats = (IAddressStats) entries2.get(text)) == null) {
|
||||
addressStats = new AddressStats(text);
|
||||
}
|
||||
addressStats.setAccounts((Integer) entries.get(text));
|
||||
addressStats.setClassification(
|
||||
MongoAddressStatsHandler.findAddressClassification(
|
||||
addressStats, value2, value3));
|
||||
repository.saveSync(text, addressStats);
|
||||
}
|
||||
value4 += values2.size();
|
||||
this.platform
|
||||
.getLogger()
|
||||
.info("(Alts) Backfill progress: " + value4 + "/" + values.size());
|
||||
}
|
||||
return value4;
|
||||
}
|
||||
|
||||
private MongoDatabaseHandler getDatabaseHandler() {
|
||||
return (MongoDatabaseHandler) this.platform.getDatabaseHandler();
|
||||
}
|
||||
|
||||
private MySQLDatabaseHandler getDatabaseHandlerByPlatform() {
|
||||
return (MySQLDatabaseHandler) this.platform.getDatabaseHandler();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
public final class AddressNormalizer {
|
||||
|
||||
public static final String UNKNOWN_TEXT = "unknown";
|
||||
|
||||
private AddressNormalizer() {}
|
||||
|
||||
public static String formatString(String text) {
|
||||
if (text == null || text.isEmpty()) {
|
||||
return "unknown";
|
||||
}
|
||||
if (text.indexOf(58) >= 0) {
|
||||
return formatStringByString(text);
|
||||
}
|
||||
int value;
|
||||
return (value = text.lastIndexOf(46)) <= 0 ? text : text.substring(0, value);
|
||||
}
|
||||
|
||||
private static String formatStringByString(String text) {
|
||||
int value;
|
||||
if ((value = text.indexOf("::")) >= 0) {
|
||||
String[] texts;
|
||||
String text2;
|
||||
return (texts =
|
||||
(text2 = text.substring(0, value)).isEmpty()
|
||||
? new String[0]
|
||||
: text2.split(":"))
|
||||
.length
|
||||
>= 4
|
||||
? formatString(texts, 4)
|
||||
: text2 + "::";
|
||||
} else {
|
||||
String[] texts2;
|
||||
return (texts2 = text.split(":")).length < 4 ? text : formatString(texts2, 4);
|
||||
}
|
||||
}
|
||||
|
||||
private static String formatString(String[] texts, int value) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (int index = 0; index < value && index < texts.length; index++) {
|
||||
if (index > 0) {
|
||||
stringBuilder.append(':');
|
||||
}
|
||||
stringBuilder.append(texts[index]);
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import xyz.refinedev.phoenix.profile.TrackedEntity;
|
||||
|
||||
public class AddressStats extends TrackedEntity implements IAddressStats {
|
||||
|
||||
@SerializedName("_id")
|
||||
private final String id;
|
||||
|
||||
@SerializedName("accounts")
|
||||
private int accounts;
|
||||
|
||||
@SerializedName("firstSeen")
|
||||
private long firstSeen = System.currentTimeMillis();
|
||||
|
||||
@SerializedName("lastSeen")
|
||||
private long lastSeen = System.currentTimeMillis();
|
||||
|
||||
@SerializedName("classification")
|
||||
private AddressClassification classification = AddressClassification.UNKNOWN;
|
||||
|
||||
@SerializedName("asn")
|
||||
private String asn;
|
||||
|
||||
@SerializedName("isp")
|
||||
private String isp;
|
||||
|
||||
@SerializedName("country")
|
||||
private String country;
|
||||
|
||||
@SerializedName("vpn")
|
||||
private boolean vpn;
|
||||
|
||||
@SerializedName("mobile")
|
||||
private boolean mobile;
|
||||
|
||||
public AddressStats(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAccounts() {
|
||||
return this.accounts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getFirstSeen() {
|
||||
return this.firstSeen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastSeen() {
|
||||
return this.lastSeen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddressClassification getClassification() {
|
||||
return this.classification;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsn() {
|
||||
return this.asn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIsp() {
|
||||
return this.isp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCountry() {
|
||||
return this.country;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVpn() {
|
||||
return this.vpn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMobile() {
|
||||
return this.mobile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAccounts(int accounts) {
|
||||
this.accounts = accounts;
|
||||
}
|
||||
|
||||
public void setFirstSeen(long firstSeen) {
|
||||
this.firstSeen = firstSeen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastSeen(long lastSeen) {
|
||||
this.lastSeen = lastSeen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClassification(AddressClassification addressClassification) {
|
||||
this.classification = addressClassification;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAsn(String asn) {
|
||||
this.asn = asn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsp(String isp) {
|
||||
this.isp = isp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVpn(boolean vpn) {
|
||||
this.vpn = vpn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMobile(boolean mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AltEvidenceAccumulator {
|
||||
|
||||
private List<AddressDensity> addressDensities = new ArrayList<>();
|
||||
|
||||
private AddressDensity addressDensity;
|
||||
|
||||
private int count;
|
||||
|
||||
private int countCount;
|
||||
|
||||
private int count2;
|
||||
|
||||
private long time;
|
||||
|
||||
private int count3;
|
||||
|
||||
private int count4;
|
||||
|
||||
private int count5;
|
||||
|
||||
private int count6;
|
||||
|
||||
private double value;
|
||||
|
||||
private double valueValue;
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
private int count7;
|
||||
|
||||
private boolean enabledEnabled;
|
||||
|
||||
private long timeTime;
|
||||
|
||||
private int count8;
|
||||
|
||||
private int count9;
|
||||
|
||||
private static final long time2 = -1L;
|
||||
|
||||
public AltEvidenceAccumulator() {
|
||||
this.time = time2;
|
||||
this.count6 = Integer.MAX_VALUE;
|
||||
this.count7 = Integer.MAX_VALUE;
|
||||
this.count9 = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public List<AddressDensity> getAddressDensities() {
|
||||
return this.addressDensities;
|
||||
}
|
||||
|
||||
public AddressDensity getAddressDensity() {
|
||||
return this.addressDensity;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return this.count;
|
||||
}
|
||||
|
||||
public int getCountCount() {
|
||||
return this.countCount;
|
||||
}
|
||||
|
||||
public int getCount2() {
|
||||
return this.count2;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return this.time;
|
||||
}
|
||||
|
||||
public int getCount3() {
|
||||
return this.count3;
|
||||
}
|
||||
|
||||
public int getCount4() {
|
||||
return this.count4;
|
||||
}
|
||||
|
||||
public int getCount5() {
|
||||
return this.count5;
|
||||
}
|
||||
|
||||
public int getCount6() {
|
||||
return this.count6;
|
||||
}
|
||||
|
||||
public double getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public double getValueValue() {
|
||||
return this.valueValue;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public int getCount7() {
|
||||
return this.count7;
|
||||
}
|
||||
|
||||
public boolean isEnabledEnabled() {
|
||||
return this.enabledEnabled;
|
||||
}
|
||||
|
||||
public long getTimeTime() {
|
||||
return this.timeTime;
|
||||
}
|
||||
|
||||
public int getCount8() {
|
||||
return this.count8;
|
||||
}
|
||||
|
||||
public int getCount9() {
|
||||
return this.count9;
|
||||
}
|
||||
|
||||
public void setAddressDensities(List<AddressDensity> addressDensities) {
|
||||
this.addressDensities = addressDensities;
|
||||
}
|
||||
|
||||
public void setAddressDensity(AddressDensity addressDensity2) {
|
||||
this.addressDensity = addressDensity2;
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public void setCountCount(int countCount) {
|
||||
this.countCount = countCount;
|
||||
}
|
||||
|
||||
public void setCount2(int count2) {
|
||||
this.count2 = count2;
|
||||
}
|
||||
|
||||
public void setTime(long time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public void setCount3(int count3) {
|
||||
this.count3 = count3;
|
||||
}
|
||||
|
||||
public void setCount4(int count4) {
|
||||
this.count4 = count4;
|
||||
}
|
||||
|
||||
public void setCount5(int count5) {
|
||||
this.count5 = count5;
|
||||
}
|
||||
|
||||
public void setCount6(int count6) {
|
||||
this.count6 = count6;
|
||||
}
|
||||
|
||||
public void setValue(double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void setValueValue(double valueValue) {
|
||||
this.valueValue = valueValue;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public void setCount7(int count7) {
|
||||
this.count7 = count7;
|
||||
}
|
||||
|
||||
public void setEnabledEnabled(boolean enabledEnabled) {
|
||||
this.enabledEnabled = enabledEnabled;
|
||||
}
|
||||
|
||||
public void setTimeTime(long timeTime) {
|
||||
this.timeTime = timeTime;
|
||||
}
|
||||
|
||||
public void setCount8(int count8) {
|
||||
this.count8 = count8;
|
||||
}
|
||||
|
||||
public void setCount9(int count9) {
|
||||
this.count9 = count9;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import xyz.refinedev.phoenix.profile.login.ILogin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class AltEvidenceEvaluator {
|
||||
|
||||
private static final long time = 24L;
|
||||
|
||||
private AltEvidenceEvaluator() {}
|
||||
|
||||
public static int calculateCount(List<ILogin> values, List<ILogin> values2, long value) {
|
||||
return calculateCountByCount(values, values2, value)
|
||||
+ calculateCountByCount(values2, values, value);
|
||||
}
|
||||
|
||||
private static int calculateCountByCount(
|
||||
List<ILogin> values, List<ILogin> values2, long value) {
|
||||
long[] values3 = new long[values.size()];
|
||||
int value2 = 0;
|
||||
Iterator<ILogin> iterator2 = values.iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
ILogin login;
|
||||
if ((login = (ILogin) iterator2.next()).hasLoggedOut()) {
|
||||
values3[value2++] = login.getLogout();
|
||||
}
|
||||
}
|
||||
long[] values4 = new long[values2.size()];
|
||||
for (int index = 0; index < values2.size(); index++) {
|
||||
values4[index] = ((ILogin) values2.get(index)).getLogin();
|
||||
}
|
||||
Arrays.sort(values3, 0, value2);
|
||||
Arrays.sort(values4);
|
||||
int value3 = 0;
|
||||
int value4 = 0;
|
||||
for (int index2 = 0; index2 < value2; index2++) {
|
||||
while (value4 < values4.length && values4[value4] < values3[index2]) {
|
||||
value4++;
|
||||
}
|
||||
if (value4 < values4.length && values4[value4] - values3[index2] <= value) {
|
||||
value3++;
|
||||
}
|
||||
}
|
||||
return value3;
|
||||
}
|
||||
|
||||
public static int calculateCountByList(List<ILogin> values, List<ILogin> values2, long value) {
|
||||
long[] values3 = new long[values2.size()];
|
||||
long[] values4 = new long[values2.size()];
|
||||
for (int index = 0; index < values2.size(); index++) {
|
||||
ILogin login = (ILogin) values2.get(index);
|
||||
values3[index] = login.getLogin();
|
||||
values4[index] = login.hasLoggedOut() ? login.getLogout() : value;
|
||||
}
|
||||
Arrays.sort(values3);
|
||||
Arrays.sort(values4);
|
||||
int value2 = 0;
|
||||
Iterator<ILogin> iterator2 = values.iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
ILogin login2;
|
||||
long login3 = (login2 = (ILogin) iterator2.next()).getLogin();
|
||||
long value3 = login2.hasLoggedOut() ? login2.getLogout() : value;
|
||||
value2 += calculateCount(values3, value3) - calculateCountByCount(values4, login3);
|
||||
}
|
||||
return value2;
|
||||
}
|
||||
|
||||
private static int calculateCount(long[] values, long value) {
|
||||
int value2 = 0;
|
||||
int value3 = values.length;
|
||||
while (value2 < value3) {
|
||||
int value4 = value2 + value3 >>> 1;
|
||||
if (values[value4] < value) {
|
||||
value2 = value4 + 1;
|
||||
} else {
|
||||
value3 = value4;
|
||||
}
|
||||
}
|
||||
return value2;
|
||||
}
|
||||
|
||||
private static int calculateCountByCount(long[] values, long value) {
|
||||
int value2 = 0;
|
||||
int value3 = values.length;
|
||||
while (value2 < value3) {
|
||||
int value4 = value2 + value3 >>> 1;
|
||||
if (values[value4] <= value) {
|
||||
value2 = value4 + 1;
|
||||
} else {
|
||||
value3 = value4;
|
||||
}
|
||||
}
|
||||
return value2;
|
||||
}
|
||||
|
||||
public static double calculateValue(List<ILogin> values, List<ILogin> values2) {
|
||||
double[] values3 = findValueArray(values);
|
||||
double[] values4 = findValueArray(values2);
|
||||
return calculateValue(values3, values4);
|
||||
}
|
||||
|
||||
private static double[] findValueArray(List<ILogin> values) {
|
||||
double[] values2 = new double[24];
|
||||
Iterator<ILogin> iterator2 = values.iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
int value;
|
||||
if ((value =
|
||||
(int)
|
||||
(((ILogin) iterator2.next()).getLogin()
|
||||
/ TimeUnit.HOURS.toMillis(1L)
|
||||
% time))
|
||||
< 0) {
|
||||
value += 24;
|
||||
}
|
||||
values2[value]++;
|
||||
}
|
||||
return values2;
|
||||
}
|
||||
|
||||
private static double calculateValue(double[] values, double[] values2) {
|
||||
int value;
|
||||
if ((value = Math.min(values.length, values2.length)) == 0) {
|
||||
return 0.0;
|
||||
}
|
||||
double value2 = calculateValue(values);
|
||||
double value3 = calculateValue(values2);
|
||||
double value4 = 0.0;
|
||||
double value5 = 0.0;
|
||||
double value6 = 0.0;
|
||||
for (int index = 0; index < value; index++) {
|
||||
double value7 = values[index] - value2;
|
||||
double value8 = values2[index] - value3;
|
||||
value4 += value7 * value8;
|
||||
value5 += value7 * value7;
|
||||
value6 += value8 * value8;
|
||||
}
|
||||
return !(value5 <= 0.0) && !(value6 <= 0.0) ? value4 / Math.sqrt(value5 * value6) : 0.0;
|
||||
}
|
||||
|
||||
private static double calculateValue(double[] values) {
|
||||
double value = 0.0;
|
||||
double[] values2 = values;
|
||||
int value2 = values.length;
|
||||
for (int index = 0; index < value2; index++) {
|
||||
double value3 = values2[index];
|
||||
value += value3;
|
||||
}
|
||||
return values.length == 0 ? 0.0 : value / values.length;
|
||||
}
|
||||
|
||||
public static int calculateCount(List<Integer> values) {
|
||||
if (values != null && !values.isEmpty()) {
|
||||
ArrayList values2;
|
||||
Collections.sort(values2 = new ArrayList(values));
|
||||
return (Integer) values2.get(values2.size() / 2);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static double calculateValue(String text, String text2) {
|
||||
if (text != null && text2 != null) {
|
||||
String text3 = formatString(text.toLowerCase());
|
||||
String text4 = formatString(text2.toLowerCase());
|
||||
if (text3.isEmpty() || text4.isEmpty()) {
|
||||
return 0.0;
|
||||
} else if (text3.equals(text4)) {
|
||||
return 1.0;
|
||||
} else {
|
||||
double value = max(text3, text4);
|
||||
int value2;
|
||||
if ((value2 = calculateCountByCount(text3, text4)) >= 4) {
|
||||
double value3 = (double) value2 / Math.min(text3.length(), text4.length());
|
||||
return Math.max(value, value3);
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
private static String formatString(String text) {
|
||||
int value = 0;
|
||||
while (value < text.length()
|
||||
&& !Character.isLetterOrDigit(text.charAt(value))
|
||||
&& text.charAt(value) != '_') {
|
||||
value++;
|
||||
}
|
||||
return value == 0 ? text : text.substring(value);
|
||||
}
|
||||
|
||||
private static double max(String text, String text2) {
|
||||
int value;
|
||||
return (value = Math.max(text.length(), text2.length())) == 0
|
||||
? 1.0
|
||||
: 1.0 - (double) calculateCount(text, text2) / value;
|
||||
}
|
||||
|
||||
private static int calculateCount(String text, String text2) {
|
||||
int[] values = new int[text2.length() + 1];
|
||||
int[] values2 = new int[text2.length() + 1];
|
||||
int value = 0;
|
||||
while (value <= text2.length()) {
|
||||
values[value] = value++;
|
||||
}
|
||||
for (int index = 1; index <= text.length(); index++) {
|
||||
values2[0] = index;
|
||||
for (int index2 = 1; index2 <= text2.length(); index2++) {
|
||||
int value2 =
|
||||
values[index2 - 1]
|
||||
+ (text.charAt(index - 1) == text2.charAt(index2 - 1) ? 0 : 1);
|
||||
values2[index2] =
|
||||
Math.min(Math.min(values2[index2 - 1] + 1, values[index2] + 1), value2);
|
||||
}
|
||||
int[] values3 = values;
|
||||
values = values2;
|
||||
values2 = values3;
|
||||
}
|
||||
return values[text2.length()];
|
||||
}
|
||||
|
||||
private static int calculateCountByCount(String text, String text2) {
|
||||
int[] values = new int[text2.length() + 1];
|
||||
int[] values2 = new int[text2.length() + 1];
|
||||
int value = 0;
|
||||
for (int index = 1; index <= text.length(); index++) {
|
||||
for (int index2 = 1; index2 <= text2.length(); index2++) {
|
||||
if (text.charAt(index - 1) == text2.charAt(index2 - 1)) {
|
||||
values2[index2] = values[index2 - 1] + 1;
|
||||
value = Math.max(value, values2[index2]);
|
||||
} else {
|
||||
values2[index2] = 0;
|
||||
}
|
||||
}
|
||||
int[] values3 = values;
|
||||
values = values2;
|
||||
values2 = values3;
|
||||
Arrays.fill(values3, 0);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
public final class AltEvidenceTypes {
|
||||
|
||||
private AltEvidenceTypes() {}
|
||||
|
||||
public static boolean matchesEnabled(int value, AltLinkStatus altLinkStatus, int value2) {
|
||||
return altLinkStatus != AltLinkStatus.ACTIVE ? false : value >= value2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import xyz.refinedev.phoenix.profile.TrackedEntity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AltLink extends TrackedEntity implements IAltLink {
|
||||
|
||||
@SerializedName("_id")
|
||||
private final String id;
|
||||
|
||||
@SerializedName("a")
|
||||
private final UUID a;
|
||||
|
||||
@SerializedName("b")
|
||||
private final UUID b;
|
||||
|
||||
@SerializedName("score")
|
||||
private int score;
|
||||
|
||||
@SerializedName("signals")
|
||||
private List<IAltSignal> signals = new ArrayList<>();
|
||||
|
||||
@SerializedName("sharedAddresses")
|
||||
private int sharedAddresses;
|
||||
|
||||
@SerializedName("independentSubnets")
|
||||
private int independentSubnets;
|
||||
|
||||
@SerializedName("lastSharedLogin")
|
||||
private long lastSharedLogin;
|
||||
|
||||
@SerializedName("firstLinked")
|
||||
private long firstLinked = System.currentTimeMillis();
|
||||
|
||||
@SerializedName("lastEvaluated")
|
||||
private long lastEvaluated = System.currentTimeMillis();
|
||||
|
||||
@SerializedName("status")
|
||||
private AltLinkStatus status = AltLinkStatus.ACTIVE;
|
||||
|
||||
public AltLink(UUID uUID, UUID uUID2) {
|
||||
boolean matches = uUID.toString().compareTo(uUID2.toString()) <= 0;
|
||||
this.a = matches ? uUID : uUID2;
|
||||
this.b = matches ? uUID2 : uUID;
|
||||
this.id = formatString(uUID, uUID2);
|
||||
}
|
||||
|
||||
public static String formatString(UUID uUID, UUID uUID2) {
|
||||
String text = uUID.toString();
|
||||
String text2 = uUID2.toString();
|
||||
return text.compareTo(text2) <= 0 ? text + ":" + text2 : text2 + ":" + text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID other(UUID uUID) {
|
||||
return this.a.equals(uUID) ? this.b : this.a;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean involves(UUID uUID) {
|
||||
return this.a.equals(uUID) || this.b.equals(uUID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getA() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getB() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getScore() {
|
||||
return this.score;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IAltSignal> getSignals() {
|
||||
return this.signals;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSharedAddresses() {
|
||||
return this.sharedAddresses;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIndependentSubnets() {
|
||||
return this.independentSubnets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastSharedLogin() {
|
||||
return this.lastSharedLogin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getFirstLinked() {
|
||||
return this.firstLinked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastEvaluated() {
|
||||
return this.lastEvaluated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AltLinkStatus getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScore(int score) {
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSignals(List<IAltSignal> signals) {
|
||||
this.signals = signals;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSharedAddresses(int sharedAddresses) {
|
||||
this.sharedAddresses = sharedAddresses;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIndependentSubnets(int independentSubnets) {
|
||||
this.independentSubnets = independentSubnets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastSharedLogin(long lastSharedLogin) {
|
||||
this.lastSharedLogin = lastSharedLogin;
|
||||
}
|
||||
|
||||
public void setFirstLinked(long firstLinked) {
|
||||
this.firstLinked = firstLinked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastEvaluated(long lastEvaluated) {
|
||||
this.lastEvaluated = lastEvaluated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStatus(AltLinkStatus altLinkStatus) {
|
||||
this.status = altLinkStatus;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
public enum AltLinkStatus {
|
||||
ACTIVE,
|
||||
SUPPRESSED,
|
||||
TRUSTED
|
||||
}
|
||||
@@ -0,0 +1,383 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class AltScoreCalculator {
|
||||
|
||||
private static final long timeTime = 3600000L;
|
||||
|
||||
public ScoreResult create(
|
||||
AltEvidenceAccumulator altEvidenceAccumulator, AltScoringWeights altScoringWeights) {
|
||||
ArrayList<xyz.refinedev.phoenix.alt.IAltSignal> values = new ArrayList<>();
|
||||
double value = this.calculateValue(altEvidenceAccumulator, altScoringWeights, values);
|
||||
double value2 =
|
||||
this.calculateValueByTimeTime(altEvidenceAccumulator, altScoringWeights, values);
|
||||
double value3;
|
||||
if ((value3 = Math.min(altScoringWeights.getValue9(), value2)) < value2) {
|
||||
values.add(
|
||||
new AltSignal(
|
||||
"non-ip-cap",
|
||||
value3 - value2,
|
||||
"capped at "
|
||||
+ (int) altScoringWeights.getValue9()
|
||||
+ " - non-IP evidence alone cannot reach the enforce threshold"));
|
||||
}
|
||||
value =
|
||||
value
|
||||
+ value3
|
||||
- this.calculateValueByValue(
|
||||
altEvidenceAccumulator, altScoringWeights, values);
|
||||
int value4 = (int) Math.round(Math.max(0.0, Math.min(100.0, value)));
|
||||
return new ScoreResult(value4, values);
|
||||
}
|
||||
|
||||
public ScoreResult findScoreResult(
|
||||
List<AddressDensity> values,
|
||||
AddressDensity addressDensity,
|
||||
AltScoringWeights altScoringWeights) {
|
||||
AltEvidenceAccumulator altEvidenceAccumulator;
|
||||
(altEvidenceAccumulator = new AltEvidenceAccumulator()).setAddressDensities(values);
|
||||
altEvidenceAccumulator.setAddressDensity(addressDensity);
|
||||
return this.create(altEvidenceAccumulator, altScoringWeights);
|
||||
}
|
||||
|
||||
private double calculateValue(
|
||||
AltEvidenceAccumulator altEvidenceAccumulator,
|
||||
AltScoringWeights altScoringWeights,
|
||||
List<IAltSignal> values2) {
|
||||
List<xyz.refinedev.phoenix.alt.AddressDensity> addressDensities =
|
||||
altEvidenceAccumulator.getAddressDensities();
|
||||
AddressDensity addressDensity = altEvidenceAccumulator.getAddressDensity();
|
||||
double value = 0.0;
|
||||
Map<String, List<xyz.refinedev.phoenix.alt.AddressDensity>> entries = new LinkedHashMap();
|
||||
for (AddressDensity addressDensity2 : addressDensities) {
|
||||
entries.computeIfAbsent(addressDensity2.getTextString(), result -> new ArrayList<>())
|
||||
.add(addressDensity2);
|
||||
}
|
||||
double value2 = Math.max(0.0, Math.min(1.0, altScoringWeights.getValue2()));
|
||||
Iterator iterator2 = entries.values().iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
List<AddressDensity> values3;
|
||||
List values4 = values3 = (List) iterator2.next();
|
||||
values4.sort(
|
||||
Comparator.<AddressDensity>comparingDouble(
|
||||
result2 -> this.calculateValue(result2, altScoringWeights))
|
||||
.reversed());
|
||||
double value3 = 1.0;
|
||||
double value4 = 0.0;
|
||||
for (AddressDensity addressDensity3 : values3) {
|
||||
double value5 = this.calculateValue(addressDensity3, altScoringWeights) * value3;
|
||||
value4 += value5;
|
||||
values2.add(
|
||||
new AltSignal(
|
||||
"shared-address",
|
||||
value5,
|
||||
addressDensity3.getCount()
|
||||
+ " accounts seen there (x"
|
||||
+ String.format(
|
||||
"%.2f",
|
||||
this.max(addressDensity3, altScoringWeights))
|
||||
+ ")"
|
||||
+ (value3 < 1.0 ? " (pooled)" : "")));
|
||||
value3 *= value2;
|
||||
}
|
||||
if (value4 > altScoringWeights.getValue()) {
|
||||
values2.add(
|
||||
new AltSignal(
|
||||
"subnet-cap",
|
||||
altScoringWeights.getValue() - value4,
|
||||
"one subnet cannot outweigh a single clean address match"));
|
||||
value4 = altScoringWeights.getValue();
|
||||
}
|
||||
value += value4;
|
||||
}
|
||||
if (!addressDensities.isEmpty()) {
|
||||
int value6;
|
||||
if ((value6 = entries.size() - 1) > 0) {
|
||||
double value7 = altScoringWeights.getValueValue() * value6;
|
||||
value += value7;
|
||||
values2.add(
|
||||
new AltSignal(
|
||||
"multi-subnet",
|
||||
value7,
|
||||
entries.size() + " independent subnets shared"));
|
||||
}
|
||||
} else if (addressDensity != null) {
|
||||
double value8 =
|
||||
altScoringWeights.getValue3()
|
||||
* this.max(addressDensity, altScoringWeights)
|
||||
* this.maxByValue(addressDensity, altScoringWeights);
|
||||
value += value8;
|
||||
values2.add(new AltSignal("subnet-only", value8, "same subnet, no shared address"));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private double calculateValue(
|
||||
AddressDensity addressDensity, AltScoringWeights altScoringWeights) {
|
||||
return altScoringWeights.getValue()
|
||||
* this.max(addressDensity, altScoringWeights)
|
||||
* this.maxByValue(addressDensity, altScoringWeights)
|
||||
* this.calculateValueByValue(addressDensity, altScoringWeights);
|
||||
}
|
||||
|
||||
double max(int value, int value2) {
|
||||
int value3;
|
||||
return (double) (value3 = Math.max(1, value2)) / Math.max(value3, value);
|
||||
}
|
||||
|
||||
private double calculateValueByTimeTime(
|
||||
AltEvidenceAccumulator altEvidenceAccumulator,
|
||||
AltScoringWeights altScoringWeights,
|
||||
List<IAltSignal> values) {
|
||||
return 0.0
|
||||
+ this.calculateValue(
|
||||
values,
|
||||
"alternation",
|
||||
this.calculateValue(altEvidenceAccumulator, altScoringWeights),
|
||||
altEvidenceAccumulator.getCount() + " login handoffs")
|
||||
+ this.calculateValue(
|
||||
values,
|
||||
"ban-appearance",
|
||||
this.max(altEvidenceAccumulator, altScoringWeights),
|
||||
"first login "
|
||||
+ altEvidenceAccumulator.getTime() / timeTime
|
||||
+ "h after the other account was banned")
|
||||
+ this.calculateValue(
|
||||
values,
|
||||
"client-fingerprint",
|
||||
this.calculateValueByValue(altEvidenceAccumulator, altScoringWeights),
|
||||
altEvidenceAccumulator.getCount4()
|
||||
+ "/"
|
||||
+ altEvidenceAccumulator.getCount5()
|
||||
+ " client attributes"
|
||||
+ (altEvidenceAccumulator.getCount6() == 2147483647
|
||||
? ""
|
||||
: ", shared by "
|
||||
+ altEvidenceAccumulator.getCount6()
|
||||
+ " accounts"))
|
||||
+ this.calculateValue(
|
||||
values,
|
||||
"name-similarity",
|
||||
this.calculateValueByAltEvidenceAccumulator(
|
||||
altEvidenceAccumulator, altScoringWeights),
|
||||
String.format(
|
||||
"%.0f%% name similarity",
|
||||
altEvidenceAccumulator.getValue() * 100.0))
|
||||
+ this.calculateValue(
|
||||
values,
|
||||
"playtime-rhythm",
|
||||
this.calculateValueByAltScoringWeights(
|
||||
altEvidenceAccumulator, altScoringWeights),
|
||||
String.format(
|
||||
"%.2f play-hour correlation",
|
||||
altEvidenceAccumulator.getValueValue()))
|
||||
+ this.calculateValue(
|
||||
values,
|
||||
"skin",
|
||||
this.calculateValue2(altEvidenceAccumulator, altScoringWeights),
|
||||
"same skin, used by " + altEvidenceAccumulator.getCount7() + " accounts")
|
||||
+ this.calculateValue(
|
||||
values,
|
||||
"latency",
|
||||
this.calculateValue3(altEvidenceAccumulator, altScoringWeights),
|
||||
altEvidenceAccumulator.getTimeTime() + "ms median ping difference")
|
||||
+ this.calculateValue(
|
||||
values,
|
||||
"logout-location",
|
||||
this.calculateValue4(altEvidenceAccumulator, altScoringWeights),
|
||||
altEvidenceAccumulator.getCount8()
|
||||
+ " shared logout areas, used by "
|
||||
+ altEvidenceAccumulator.getCount9()
|
||||
+ " accounts");
|
||||
}
|
||||
|
||||
private double calculateValue(
|
||||
List<IAltSignal> values, String text, double value, String text2) {
|
||||
if (value <= 0.0) {
|
||||
return 0.0;
|
||||
}
|
||||
if (value >= 0.05) {
|
||||
values.add(new AltSignal(text, value, text2));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
double calculateValue(
|
||||
AltEvidenceAccumulator altEvidenceAccumulator, AltScoringWeights altScoringWeights) {
|
||||
if (altEvidenceAccumulator.getCount() <= 0) {
|
||||
return 0.0;
|
||||
}
|
||||
int value = Math.max(1, altScoringWeights.getCount2());
|
||||
double value2 =
|
||||
altScoringWeights.getValue10()
|
||||
* Math.min(1.0, (double) altEvidenceAccumulator.getCount() / value);
|
||||
int value3;
|
||||
if ((value3 =
|
||||
Math.min(
|
||||
altEvidenceAccumulator.getCountCount(),
|
||||
altEvidenceAccumulator.getCount2()))
|
||||
> 0) {
|
||||
double value4 = (double) altEvidenceAccumulator.getCount() / value3;
|
||||
value2 *= Math.min(1.0, value4 / Math.max(0.01, altScoringWeights.getValue11()));
|
||||
}
|
||||
return value2;
|
||||
}
|
||||
|
||||
double max(AltEvidenceAccumulator altEvidenceAccumulator, AltScoringWeights altScoringWeights) {
|
||||
long value;
|
||||
if ((value = altEvidenceAccumulator.getTime()) < 0L) {
|
||||
return 0.0;
|
||||
}
|
||||
long value2 = Math.max(1L, altScoringWeights.getTime4());
|
||||
return value >= value2
|
||||
? 0.0
|
||||
: altScoringWeights.getValue12() * (1.0 - (double) value / value2);
|
||||
}
|
||||
|
||||
double calculateValueByValue(
|
||||
AltEvidenceAccumulator altEvidenceAccumulator,
|
||||
AltScoringWeights altScoringWeights,
|
||||
List<IAltSignal> values) {
|
||||
if (altEvidenceAccumulator.getCount3() <= 0) {
|
||||
return 0.0;
|
||||
} else if (altScoringWeights.isEnabled()
|
||||
&& altEvidenceAccumulator.getAddressDensities() != null
|
||||
&& !altEvidenceAccumulator.getAddressDensities().isEmpty()) {
|
||||
values.add(
|
||||
new AltSignal(
|
||||
"concurrent-sessions",
|
||||
0.0,
|
||||
altEvidenceAccumulator.getCount3()
|
||||
+ " overlapping sessions - not penalised, both are on a shared address"));
|
||||
return 0.0;
|
||||
} else {
|
||||
int value = Math.max(1, altScoringWeights.getCount3());
|
||||
double value2 =
|
||||
altScoringWeights.getValue13()
|
||||
* Math.min(1.0, (double) altEvidenceAccumulator.getCount3() / value);
|
||||
values.add(
|
||||
new AltSignal(
|
||||
"concurrent-sessions",
|
||||
-value2,
|
||||
altEvidenceAccumulator.getCount3()
|
||||
+ " overlapping sessions - suggests two people"));
|
||||
return value2;
|
||||
}
|
||||
}
|
||||
|
||||
double calculateValueByValue(
|
||||
AltEvidenceAccumulator altEvidenceAccumulator, AltScoringWeights altScoringWeights) {
|
||||
if (altEvidenceAccumulator.getCount5() <= 0) {
|
||||
return 0.0;
|
||||
}
|
||||
if (altEvidenceAccumulator.getCount4() <= 0) {
|
||||
return 0.0;
|
||||
}
|
||||
double value =
|
||||
(double) altEvidenceAccumulator.getCount4() / altEvidenceAccumulator.getCount5();
|
||||
return altScoringWeights.getValue14()
|
||||
* value
|
||||
* this.max(altEvidenceAccumulator.getCount6(), altScoringWeights.getCount4());
|
||||
}
|
||||
|
||||
double calculateValueByAltEvidenceAccumulator(
|
||||
AltEvidenceAccumulator altEvidenceAccumulator, AltScoringWeights altScoringWeights) {
|
||||
return this.calculateValue(
|
||||
altEvidenceAccumulator.getValue(), altScoringWeights.getValue16())
|
||||
* altScoringWeights.getValue15();
|
||||
}
|
||||
|
||||
double calculateValueByAltScoringWeights(
|
||||
AltEvidenceAccumulator altEvidenceAccumulator, AltScoringWeights altScoringWeights) {
|
||||
return this.calculateValue(
|
||||
altEvidenceAccumulator.getValueValue(), altScoringWeights.getValue18())
|
||||
* altScoringWeights.getValue17();
|
||||
}
|
||||
|
||||
double calculateValue2(
|
||||
AltEvidenceAccumulator altEvidenceAccumulator, AltScoringWeights altScoringWeights) {
|
||||
return !altEvidenceAccumulator.isEnabled()
|
||||
? 0.0
|
||||
: altScoringWeights.getValue19()
|
||||
* this.max(
|
||||
altEvidenceAccumulator.getCount7(), altScoringWeights.getCount5());
|
||||
}
|
||||
|
||||
double calculateValue3(
|
||||
AltEvidenceAccumulator altEvidenceAccumulator, AltScoringWeights altScoringWeights) {
|
||||
if (!altEvidenceAccumulator.isEnabledEnabled()) {
|
||||
return 0.0;
|
||||
}
|
||||
long value = Math.max(1L, altScoringWeights.getTime5());
|
||||
double value2 = 1.0 - (double) Math.abs(altEvidenceAccumulator.getTimeTime()) / value;
|
||||
return altScoringWeights.getValue20() * Math.max(0.0, value2);
|
||||
}
|
||||
|
||||
double calculateValue4(
|
||||
AltEvidenceAccumulator altEvidenceAccumulator, AltScoringWeights altScoringWeights) {
|
||||
if (altEvidenceAccumulator.getCount8() <= 0) {
|
||||
return 0.0;
|
||||
}
|
||||
int value = Math.max(1, altScoringWeights.getCount7());
|
||||
double value2 = Math.min(1.0, (double) altEvidenceAccumulator.getCount8() / value);
|
||||
return altScoringWeights.getValue21()
|
||||
* value2
|
||||
* this.max(altEvidenceAccumulator.getCount9(), altScoringWeights.getCount6());
|
||||
}
|
||||
|
||||
private double calculateValue(double value, double value2) {
|
||||
if (value <= value2) {
|
||||
return 0.0;
|
||||
} else {
|
||||
return value2 >= 1.0 ? 0.0 : (value - value2) / (1.0 - value2);
|
||||
}
|
||||
}
|
||||
|
||||
double max(AddressDensity addressDensity, AltScoringWeights altScoringWeights) {
|
||||
if (addressDensity.getAddressClassification() == AddressClassification.FORCED_TRUSTED) {
|
||||
return 1.0;
|
||||
}
|
||||
if (addressDensity.getAddressClassification() == AddressClassification.FORCED_SHARED) {
|
||||
return altScoringWeights.getValue6();
|
||||
}
|
||||
int value;
|
||||
double value2 =
|
||||
(double) (value = Math.max(1, altScoringWeights.getCount()))
|
||||
/ Math.max(value, addressDensity.getCount());
|
||||
if (addressDensity.isEnabled()) {
|
||||
value2 *= altScoringWeights.getValue4();
|
||||
}
|
||||
if (addressDensity.isEnabledEnabled()) {
|
||||
value2 *= altScoringWeights.getValue5();
|
||||
}
|
||||
return value2;
|
||||
}
|
||||
|
||||
double maxByValue(AddressDensity addressDensity, AltScoringWeights altScoringWeights) {
|
||||
long value = Math.max(0L, addressDensity.getTime());
|
||||
long time = altScoringWeights.getTime();
|
||||
long timeTime = altScoringWeights.getTimeTime();
|
||||
if (value <= time) {
|
||||
return 1.0;
|
||||
} else if (value < timeTime && timeTime > time) {
|
||||
double value2 = (double) (value - time) / (timeTime - time);
|
||||
return 1.0 - value2 * (1.0 - altScoringWeights.getValue7());
|
||||
} else {
|
||||
return altScoringWeights.getValue7();
|
||||
}
|
||||
}
|
||||
|
||||
double calculateValueByValue(
|
||||
AddressDensity addressDensity, AltScoringWeights altScoringWeights) {
|
||||
int value = Math.min(addressDensity.getCountCount(), addressDensity.getCount2());
|
||||
int value2 = Math.max(1, altScoringWeights.getCountCount());
|
||||
double value3 = Math.min(1.0, (double) value / value2);
|
||||
return 1.0 - (1.0 - value3) * (1.0 - this.max(addressDensity, altScoringWeights));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,386 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class AltScoringWeights {
|
||||
|
||||
private int count = 4;
|
||||
|
||||
private double value = 85.0;
|
||||
|
||||
private double valueValue = 25.0;
|
||||
|
||||
private double value2 = 0.5;
|
||||
|
||||
private double value3 = 15.0;
|
||||
|
||||
private double value4 = 0.05;
|
||||
|
||||
private double value5 = 0.5;
|
||||
|
||||
private double value6 = 0.02;
|
||||
|
||||
private long time = TimeUnit.DAYS.toMillis(7L);
|
||||
|
||||
private long timeTime = TimeUnit.DAYS.toMillis(90L);
|
||||
|
||||
private double value7 = 0.15;
|
||||
|
||||
private int countCount = 5;
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
private long time2 = TimeUnit.HOURS.toMillis(12L);
|
||||
|
||||
private boolean enabledEnabled;
|
||||
|
||||
private double value8 = 0.6;
|
||||
|
||||
private double value9 = 60.0;
|
||||
|
||||
private double value10 = 35.0;
|
||||
|
||||
private int count2 = 5;
|
||||
|
||||
private double value11 = 0.25;
|
||||
|
||||
private long time3 = TimeUnit.MINUTES.toMillis(5L);
|
||||
|
||||
private double value12 = 20.0;
|
||||
|
||||
private long time4 = TimeUnit.DAYS.toMillis(7L);
|
||||
|
||||
private double value13 = 20.0;
|
||||
|
||||
private int count3 = 5;
|
||||
|
||||
private double value14 = 25.0;
|
||||
|
||||
private int count4 = 4;
|
||||
|
||||
private double value15 = 20.0;
|
||||
|
||||
private double value16 = 0.6;
|
||||
|
||||
private double value17 = 10.0;
|
||||
|
||||
private double value18 = 0.85;
|
||||
|
||||
private double value19 = 20.0;
|
||||
|
||||
private int count5 = 3;
|
||||
|
||||
private double value20 = 8.0;
|
||||
|
||||
private long time5 = 15L;
|
||||
|
||||
private double value21 = 25.0;
|
||||
|
||||
private int count6 = 3;
|
||||
|
||||
private int count7 = 2;
|
||||
|
||||
public int getCount() {
|
||||
return this.count;
|
||||
}
|
||||
|
||||
public double getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public double getValueValue() {
|
||||
return this.valueValue;
|
||||
}
|
||||
|
||||
public double getValue2() {
|
||||
return this.value2;
|
||||
}
|
||||
|
||||
public double getValue3() {
|
||||
return this.value3;
|
||||
}
|
||||
|
||||
public double getValue4() {
|
||||
return this.value4;
|
||||
}
|
||||
|
||||
public double getValue5() {
|
||||
return this.value5;
|
||||
}
|
||||
|
||||
public double getValue6() {
|
||||
return this.value6;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return this.time;
|
||||
}
|
||||
|
||||
public long getTimeTime() {
|
||||
return this.timeTime;
|
||||
}
|
||||
|
||||
public double getValue7() {
|
||||
return this.value7;
|
||||
}
|
||||
|
||||
public int getCountCount() {
|
||||
return this.countCount;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public long getTime2() {
|
||||
return this.time2;
|
||||
}
|
||||
|
||||
public boolean isEnabledEnabled() {
|
||||
return this.enabledEnabled;
|
||||
}
|
||||
|
||||
public double getValue8() {
|
||||
return this.value8;
|
||||
}
|
||||
|
||||
public double getValue9() {
|
||||
return this.value9;
|
||||
}
|
||||
|
||||
public double getValue10() {
|
||||
return this.value10;
|
||||
}
|
||||
|
||||
public int getCount2() {
|
||||
return this.count2;
|
||||
}
|
||||
|
||||
public double getValue11() {
|
||||
return this.value11;
|
||||
}
|
||||
|
||||
public long getTime3() {
|
||||
return this.time3;
|
||||
}
|
||||
|
||||
public double getValue12() {
|
||||
return this.value12;
|
||||
}
|
||||
|
||||
public long getTime4() {
|
||||
return this.time4;
|
||||
}
|
||||
|
||||
public double getValue13() {
|
||||
return this.value13;
|
||||
}
|
||||
|
||||
public int getCount3() {
|
||||
return this.count3;
|
||||
}
|
||||
|
||||
public double getValue14() {
|
||||
return this.value14;
|
||||
}
|
||||
|
||||
public int getCount4() {
|
||||
return this.count4;
|
||||
}
|
||||
|
||||
public double getValue15() {
|
||||
return this.value15;
|
||||
}
|
||||
|
||||
public double getValue16() {
|
||||
return this.value16;
|
||||
}
|
||||
|
||||
public double getValue17() {
|
||||
return this.value17;
|
||||
}
|
||||
|
||||
public double getValue18() {
|
||||
return this.value18;
|
||||
}
|
||||
|
||||
public double getValue19() {
|
||||
return this.value19;
|
||||
}
|
||||
|
||||
public int getCount5() {
|
||||
return this.count5;
|
||||
}
|
||||
|
||||
public double getValue20() {
|
||||
return this.value20;
|
||||
}
|
||||
|
||||
public long getTime5() {
|
||||
return this.time5;
|
||||
}
|
||||
|
||||
public double getValue21() {
|
||||
return this.value21;
|
||||
}
|
||||
|
||||
public int getCount6() {
|
||||
return this.count6;
|
||||
}
|
||||
|
||||
public int getCount7() {
|
||||
return this.count7;
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public void setValue(double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void setValueValue(double valueValue) {
|
||||
this.valueValue = valueValue;
|
||||
}
|
||||
|
||||
public void setValue2(double value2) {
|
||||
this.value2 = value2;
|
||||
}
|
||||
|
||||
public void setValue3(double value3) {
|
||||
this.value3 = value3;
|
||||
}
|
||||
|
||||
public void setValue4(double value4) {
|
||||
this.value4 = value4;
|
||||
}
|
||||
|
||||
public void setValue5(double value5) {
|
||||
this.value5 = value5;
|
||||
}
|
||||
|
||||
public void setValue6(double value6) {
|
||||
this.value6 = value6;
|
||||
}
|
||||
|
||||
public void setTime(long time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public void setTimeTime(long timeTime) {
|
||||
this.timeTime = timeTime;
|
||||
}
|
||||
|
||||
public void setValue7(double value7) {
|
||||
this.value7 = value7;
|
||||
}
|
||||
|
||||
public void setCountCount(int countCount) {
|
||||
this.countCount = countCount;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public void setTime2(long time2) {
|
||||
this.time2 = time2;
|
||||
}
|
||||
|
||||
public void setEnabledEnabled(boolean enabledEnabled) {
|
||||
this.enabledEnabled = enabledEnabled;
|
||||
}
|
||||
|
||||
public void setValue8(double value8) {
|
||||
this.value8 = value8;
|
||||
}
|
||||
|
||||
public void setValue9(double value9) {
|
||||
this.value9 = value9;
|
||||
}
|
||||
|
||||
public void setValue10(double value10) {
|
||||
this.value10 = value10;
|
||||
}
|
||||
|
||||
public void setCount2(int count2) {
|
||||
this.count2 = count2;
|
||||
}
|
||||
|
||||
public void setValue11(double value11) {
|
||||
this.value11 = value11;
|
||||
}
|
||||
|
||||
public void setTime3(long time3) {
|
||||
this.time3 = time3;
|
||||
}
|
||||
|
||||
public void setValue12(double value12) {
|
||||
this.value12 = value12;
|
||||
}
|
||||
|
||||
public void setTime4(long time4) {
|
||||
this.time4 = time4;
|
||||
}
|
||||
|
||||
public void setValue13(double value13) {
|
||||
this.value13 = value13;
|
||||
}
|
||||
|
||||
public void setCount3(int count3) {
|
||||
this.count3 = count3;
|
||||
}
|
||||
|
||||
public void setValue14(double value14) {
|
||||
this.value14 = value14;
|
||||
}
|
||||
|
||||
public void setCount4(int count4) {
|
||||
this.count4 = count4;
|
||||
}
|
||||
|
||||
public void setValue15(double value15) {
|
||||
this.value15 = value15;
|
||||
}
|
||||
|
||||
public void setValue16(double value16) {
|
||||
this.value16 = value16;
|
||||
}
|
||||
|
||||
public void setValue17(double value17) {
|
||||
this.value17 = value17;
|
||||
}
|
||||
|
||||
public void setValue18(double value18) {
|
||||
this.value18 = value18;
|
||||
}
|
||||
|
||||
public void setValue19(double value19) {
|
||||
this.value19 = value19;
|
||||
}
|
||||
|
||||
public void setCount5(int count5) {
|
||||
this.count5 = count5;
|
||||
}
|
||||
|
||||
public void setValue20(double value20) {
|
||||
this.value20 = value20;
|
||||
}
|
||||
|
||||
public void setTime5(long time5) {
|
||||
this.time5 = time5;
|
||||
}
|
||||
|
||||
public void setValue21(double value21) {
|
||||
this.value21 = value21;
|
||||
}
|
||||
|
||||
public void setCount6(int count6) {
|
||||
this.count6 = count6;
|
||||
}
|
||||
|
||||
public void setCount7(int count7) {
|
||||
this.count7 = count7;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class AltSignal implements IAltSignal {
|
||||
|
||||
@SerializedName("name")
|
||||
private final String name;
|
||||
|
||||
@SerializedName("points")
|
||||
private final double points;
|
||||
|
||||
@SerializedName("detail")
|
||||
private final String detail;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPoints() {
|
||||
return this.points;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDetail() {
|
||||
return this.detail;
|
||||
}
|
||||
|
||||
public AltSignal(String name, double points, String detail) {
|
||||
this.name = name;
|
||||
this.points = points;
|
||||
this.detail = detail;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public final class AltSignals {
|
||||
|
||||
private AltSignals() {}
|
||||
|
||||
public static List<AddressDensity> findList(
|
||||
List<AddressDensity> values, long value, boolean matches, String text, String text2) {
|
||||
ArrayList<AddressDensity> values2 = new ArrayList<>();
|
||||
if (values != null && !values.isEmpty()) {
|
||||
if (!matches || !isEmpty(text) && !isEmpty(text2)) {
|
||||
long value2 = Math.max(0L, value);
|
||||
Iterator<xyz.refinedev.phoenix.alt.AddressDensity> iterator2 = values.iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
AddressDensity addressDensity;
|
||||
if ((addressDensity = (AddressDensity) iterator2.next()).getTime() <= value2
|
||||
&& (!matches
|
||||
|| addressDensity.getText().equals(text)
|
||||
&& addressDensity.getText().equals(text2))) {
|
||||
values2.add(addressDensity);
|
||||
}
|
||||
}
|
||||
return values2;
|
||||
} else {
|
||||
return values2;
|
||||
}
|
||||
} else {
|
||||
return values2;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isEmpty(String text) {
|
||||
return text == null || text.isEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ClientFingerprint implements IClientFingerprint {
|
||||
|
||||
@SerializedName("locale")
|
||||
private String locale;
|
||||
|
||||
@SerializedName("viewDistance")
|
||||
private int viewDistance = -1;
|
||||
|
||||
@SerializedName("chatVisibility")
|
||||
private int chatVisibility = -1;
|
||||
|
||||
@SerializedName("skinParts")
|
||||
private int skinParts = -1;
|
||||
|
||||
@SerializedName("mainHand")
|
||||
private int mainHand = -1;
|
||||
|
||||
@SerializedName("brand")
|
||||
private String brand;
|
||||
|
||||
@SerializedName("protocolVersion")
|
||||
private int protocolVersion = -1;
|
||||
|
||||
@SerializedName("channels")
|
||||
private List<String> channels;
|
||||
|
||||
@SerializedName("capturedAt")
|
||||
private long capturedAt = System.currentTimeMillis();
|
||||
|
||||
@Override
|
||||
public String signature() {
|
||||
return this.formatString(this.locale)
|
||||
+ "|"
|
||||
+ this.viewDistance
|
||||
+ "|"
|
||||
+ this.chatVisibility
|
||||
+ "|"
|
||||
+ this.skinParts
|
||||
+ "|"
|
||||
+ this.mainHand
|
||||
+ "|"
|
||||
+ this.formatString(this.brand)
|
||||
+ "|"
|
||||
+ this.protocolVersion
|
||||
+ "|"
|
||||
+ (this.channels == null ? "" : String.join(",", this.channels));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int comparedCount(IClientFingerprint clientFingerprint) {
|
||||
if (clientFingerprint == null) {
|
||||
return 0;
|
||||
}
|
||||
int value = 0;
|
||||
if (this.isEmpty(this.locale, clientFingerprint.getLocale())) {
|
||||
value++;
|
||||
}
|
||||
if (this.matchesEnabled(this.viewDistance, clientFingerprint.getViewDistance())) {
|
||||
value++;
|
||||
}
|
||||
if (this.matchesEnabled(this.chatVisibility, clientFingerprint.getChatVisibility())) {
|
||||
value++;
|
||||
}
|
||||
if (this.matchesEnabled(this.skinParts, clientFingerprint.getSkinParts())) {
|
||||
value++;
|
||||
}
|
||||
if (this.matchesEnabled(this.mainHand, clientFingerprint.getMainHand())) {
|
||||
value++;
|
||||
}
|
||||
if (this.isEmpty(this.brand, clientFingerprint.getBrand())) {
|
||||
value++;
|
||||
}
|
||||
if (this.matchesEnabled(this.protocolVersion, clientFingerprint.getProtocolVersion())) {
|
||||
value++;
|
||||
}
|
||||
if (this.isEmpty(this.channels, clientFingerprint.getChannels())) {
|
||||
value++;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matchCount(IClientFingerprint clientFingerprint) {
|
||||
if (clientFingerprint == null) {
|
||||
return 0;
|
||||
}
|
||||
int value = 0;
|
||||
if (this.isEmpty(this.locale, clientFingerprint.getLocale())
|
||||
&& this.formatString(this.locale)
|
||||
.equals(this.formatString(clientFingerprint.getLocale()))) {
|
||||
value++;
|
||||
}
|
||||
if (this.matchesEnabled(this.viewDistance, clientFingerprint.getViewDistance())
|
||||
&& this.viewDistance == clientFingerprint.getViewDistance()) {
|
||||
value++;
|
||||
}
|
||||
if (this.matchesEnabled(this.chatVisibility, clientFingerprint.getChatVisibility())
|
||||
&& this.chatVisibility == clientFingerprint.getChatVisibility()) {
|
||||
value++;
|
||||
}
|
||||
if (this.matchesEnabled(this.skinParts, clientFingerprint.getSkinParts())
|
||||
&& this.skinParts == clientFingerprint.getSkinParts()) {
|
||||
value++;
|
||||
}
|
||||
if (this.matchesEnabled(this.mainHand, clientFingerprint.getMainHand())
|
||||
&& this.mainHand == clientFingerprint.getMainHand()) {
|
||||
value++;
|
||||
}
|
||||
if (this.isEmpty(this.brand, clientFingerprint.getBrand())
|
||||
&& this.formatString(this.brand)
|
||||
.equals(this.formatString(clientFingerprint.getBrand()))) {
|
||||
value++;
|
||||
}
|
||||
if (this.matchesEnabled(this.protocolVersion, clientFingerprint.getProtocolVersion())
|
||||
&& this.protocolVersion == clientFingerprint.getProtocolVersion()) {
|
||||
value++;
|
||||
}
|
||||
if (this.isEmpty(this.channels, clientFingerprint.getChannels())
|
||||
&& this.channels.equals(clientFingerprint.getChannels())) {
|
||||
value++;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return this.locale == null
|
||||
&& this.brand == null
|
||||
&& this.viewDistance == -1
|
||||
&& this.chatVisibility == -1
|
||||
&& this.skinParts == -1
|
||||
&& this.mainHand == -1
|
||||
&& this.protocolVersion == -1
|
||||
&& (this.channels == null || this.channels.isEmpty());
|
||||
}
|
||||
|
||||
private boolean isEmpty(String text, String text2) {
|
||||
return text != null && !text.isEmpty() && text2 != null && !text2.isEmpty();
|
||||
}
|
||||
|
||||
private boolean isEmpty(List<String> values, List<String> values2) {
|
||||
return values != null && !values.isEmpty() && values2 != null && !values2.isEmpty();
|
||||
}
|
||||
|
||||
private boolean matchesEnabled(int value, int value2) {
|
||||
return value != -1 && value2 != -1;
|
||||
}
|
||||
|
||||
private String formatString(String text) {
|
||||
return text == null ? "" : text.toLowerCase().trim();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocale() {
|
||||
return this.locale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewDistance() {
|
||||
return this.viewDistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChatVisibility() {
|
||||
return this.chatVisibility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSkinParts() {
|
||||
return this.skinParts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMainHand() {
|
||||
return this.mainHand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBrand() {
|
||||
return this.brand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProtocolVersion() {
|
||||
return this.protocolVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getChannels() {
|
||||
return this.channels;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCapturedAt() {
|
||||
return this.capturedAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocale(String locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setViewDistance(int viewDistance) {
|
||||
this.viewDistance = viewDistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChatVisibility(int chatVisibility) {
|
||||
this.chatVisibility = chatVisibility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkinParts(int skinParts) {
|
||||
this.skinParts = skinParts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMainHand(int mainHand) {
|
||||
this.mainHand = mainHand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBrand(String brand) {
|
||||
this.brand = brand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProtocolVersion(int protocolVersion) {
|
||||
this.protocolVersion = protocolVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChannels(List<String> channels) {
|
||||
this.channels = channels;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCapturedAt(long capturedAt) {
|
||||
this.capturedAt = capturedAt;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
public interface IAddressStats {
|
||||
|
||||
String getId();
|
||||
|
||||
int getAccounts();
|
||||
|
||||
void setAccounts(int value);
|
||||
|
||||
long getFirstSeen();
|
||||
|
||||
long getLastSeen();
|
||||
|
||||
void setLastSeen(long value);
|
||||
|
||||
AddressClassification getClassification();
|
||||
|
||||
void setClassification(AddressClassification addressClassification);
|
||||
|
||||
String getAsn();
|
||||
|
||||
void setAsn(String text);
|
||||
|
||||
String getIsp();
|
||||
|
||||
void setIsp(String text);
|
||||
|
||||
String getCountry();
|
||||
|
||||
void setCountry(String text);
|
||||
|
||||
boolean isVpn();
|
||||
|
||||
void setVpn(boolean matches);
|
||||
|
||||
boolean isMobile();
|
||||
|
||||
void setMobile(boolean matches);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface IAltLink {
|
||||
|
||||
String getId();
|
||||
|
||||
UUID getA();
|
||||
|
||||
UUID getB();
|
||||
|
||||
int getScore();
|
||||
|
||||
void setScore(int value);
|
||||
|
||||
List<IAltSignal> getSignals();
|
||||
|
||||
void setSignals(List<IAltSignal> values);
|
||||
|
||||
int getSharedAddresses();
|
||||
|
||||
void setSharedAddresses(int value);
|
||||
|
||||
int getIndependentSubnets();
|
||||
|
||||
void setIndependentSubnets(int value);
|
||||
|
||||
long getLastSharedLogin();
|
||||
|
||||
void setLastSharedLogin(long value);
|
||||
|
||||
long getFirstLinked();
|
||||
|
||||
long getLastEvaluated();
|
||||
|
||||
void setLastEvaluated(long value);
|
||||
|
||||
AltLinkStatus getStatus();
|
||||
|
||||
void setStatus(AltLinkStatus altLinkStatus);
|
||||
|
||||
UUID other(UUID uUID);
|
||||
|
||||
boolean involves(UUID uUID);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
public interface IAltSignal {
|
||||
|
||||
String getName();
|
||||
|
||||
double getPoints();
|
||||
|
||||
String getDetail();
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IClientFingerprint {
|
||||
|
||||
int UNSET = -1;
|
||||
|
||||
String getLocale();
|
||||
|
||||
void setLocale(String text);
|
||||
|
||||
int getViewDistance();
|
||||
|
||||
void setViewDistance(int value);
|
||||
|
||||
int getChatVisibility();
|
||||
|
||||
void setChatVisibility(int value);
|
||||
|
||||
int getSkinParts();
|
||||
|
||||
void setSkinParts(int value);
|
||||
|
||||
int getMainHand();
|
||||
|
||||
void setMainHand(int value);
|
||||
|
||||
String getBrand();
|
||||
|
||||
void setBrand(String text);
|
||||
|
||||
int getProtocolVersion();
|
||||
|
||||
void setProtocolVersion(int value);
|
||||
|
||||
long getCapturedAt();
|
||||
|
||||
void setCapturedAt(long value);
|
||||
|
||||
List<String> getChannels();
|
||||
|
||||
void setChannels(List<String> values);
|
||||
|
||||
String signature();
|
||||
|
||||
int comparedCount(IClientFingerprint clientFingerprint);
|
||||
|
||||
int matchCount(IClientFingerprint clientFingerprint);
|
||||
|
||||
boolean isEmpty();
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IScoreResult {
|
||||
|
||||
int getScore();
|
||||
|
||||
List<IAltSignal> getSignals();
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import xyz.refinedev.phoenix.CommonPlatform;
|
||||
import xyz.refinedev.phoenix.PlatformGetter;
|
||||
import xyz.refinedev.phoenix.handler.database.MySQLDatabaseHandler;
|
||||
import xyz.refinedev.phoenix.profile.login.ILogin;
|
||||
import xyz.refinedev.phoenix.profile.login.Login;
|
||||
import xyz.refinedev.phoenix.utils.mysql.SQLBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class LoginIndexMigration {
|
||||
|
||||
private final CommonPlatform platform;
|
||||
|
||||
private volatile boolean enabled;
|
||||
|
||||
public LoginIndexMigration(CommonPlatform commonPlatform) {
|
||||
this.platform = commonPlatform;
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
String name = this.getDatabaseHandler().getLogins().getName();
|
||||
String name2 = this.getDatabaseHandler().getAltLinks().getName();
|
||||
try {
|
||||
if (!this.matchesEnabled(name, "ip")) {
|
||||
this.platform
|
||||
.getLogger()
|
||||
.info(
|
||||
"(Alts) Adding indexed login columns to "
|
||||
+ name
|
||||
+ ". On a large table this runs once and may take a while.");
|
||||
SQLBuilder sQLBuilder = new SQLBuilder();
|
||||
try {
|
||||
sQLBuilder.setStatement(
|
||||
"ALTER TABLE "
|
||||
+ name
|
||||
+ " ADD COLUMN ip VARCHAR(96) GENERATED ALWAYS AS (JSON_UNQUOTE(JSON_EXTRACT(data, '$.ip'))) VIRTUAL, ADD COLUMN target VARCHAR(64) GENERATED ALWAYS AS (JSON_UNQUOTE(JSON_EXTRACT(data, '$.target'))) VIRTUAL, ADD INDEX pxlogins_ip (ip), ADD INDEX pxlogins_target (target)");
|
||||
sQLBuilder.executeUpdate();
|
||||
} catch (Throwable throwable) {
|
||||
try {
|
||||
sQLBuilder.close();
|
||||
} catch (Throwable throwable2) {
|
||||
throwable.addSuppressed(throwable2);
|
||||
}
|
||||
throw throwable;
|
||||
}
|
||||
sQLBuilder.close();
|
||||
this.platform.getLogger().info("(Alts) Indexed login columns ready.");
|
||||
}
|
||||
if (!this.matchesEnabled(name2, "a")) {
|
||||
SQLBuilder sQLBuilder2 = new SQLBuilder();
|
||||
try {
|
||||
sQLBuilder2.setStatement(
|
||||
"ALTER TABLE "
|
||||
+ name2
|
||||
+ " ADD COLUMN a VARCHAR(36) GENERATED ALWAYS AS (JSON_UNQUOTE(JSON_EXTRACT(data, '$.a'))) VIRTUAL, ADD COLUMN b VARCHAR(36) GENERATED ALWAYS AS (JSON_UNQUOTE(JSON_EXTRACT(data, '$.b'))) VIRTUAL, ADD INDEX pxaltLinks_a (a), ADD INDEX pxaltLinks_b (b)");
|
||||
sQLBuilder2.executeUpdate();
|
||||
} catch (Throwable throwable3) {
|
||||
try {
|
||||
sQLBuilder2.close();
|
||||
} catch (Throwable throwable4) {
|
||||
throwable3.addSuppressed(throwable4);
|
||||
}
|
||||
throw throwable3;
|
||||
}
|
||||
sQLBuilder2.close();
|
||||
}
|
||||
this.enabled = true;
|
||||
} catch (Exception exception) {
|
||||
this.platform
|
||||
.getLogger()
|
||||
.log(
|
||||
Level.WARNING,
|
||||
"(Alts) Could not add indexed columns - alt queries will run unindexed.",
|
||||
exception);
|
||||
}
|
||||
}
|
||||
|
||||
public List<ILogin> findList(String text, Collection<String> values) {
|
||||
if (this.enabled && !values.isEmpty()) {
|
||||
String name = this.getDatabaseHandler().getLogins().getName();
|
||||
try {
|
||||
SQLBuilder sQLBuilder = new SQLBuilder();
|
||||
ArrayList<ILogin> values2;
|
||||
try {
|
||||
sQLBuilder.setStatement(
|
||||
"SELECT data FROM "
|
||||
+ name
|
||||
+ " WHERE "
|
||||
+ text
|
||||
+ " IN ("
|
||||
+ this.append(values.size())
|
||||
+ ")");
|
||||
sQLBuilder.executeQuery(values.toArray());
|
||||
ArrayList<ILogin> values3 = new ArrayList<>();
|
||||
while (sQLBuilder.next()) {
|
||||
ILogin login;
|
||||
if ((login = this.findObject(sQLBuilder, Login.class)) != null) {
|
||||
values3.add(login);
|
||||
}
|
||||
}
|
||||
values2 = values3;
|
||||
} catch (Throwable throwable) {
|
||||
try {
|
||||
sQLBuilder.close();
|
||||
} catch (Throwable throwable2) {
|
||||
throwable.addSuppressed(throwable2);
|
||||
}
|
||||
throw throwable;
|
||||
}
|
||||
sQLBuilder.close();
|
||||
return values2;
|
||||
} catch (Exception exception) {
|
||||
this.platform
|
||||
.getLogger()
|
||||
.log(
|
||||
Level.WARNING,
|
||||
"(Alts) Indexed login query failed, falling back to filters.",
|
||||
exception);
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<IAltLink> findList(UUID uUID) {
|
||||
if (!this.enabled) {
|
||||
return null;
|
||||
}
|
||||
String name = this.getDatabaseHandler().getAltLinks().getName();
|
||||
try {
|
||||
SQLBuilder sQLBuilder = new SQLBuilder();
|
||||
ArrayList<IAltLink> values;
|
||||
try {
|
||||
sQLBuilder.setStatement("SELECT data FROM " + name + " WHERE a = ? OR b = ?");
|
||||
sQLBuilder.executeQuery(uUID.toString(), uUID.toString());
|
||||
ArrayList<xyz.refinedev.phoenix.alt.IAltLink> values2 = new ArrayList<>();
|
||||
while (sQLBuilder.next()) {
|
||||
IAltLink altLink;
|
||||
if ((altLink = this.findObject(sQLBuilder, AltLink.class)) != null) {
|
||||
values2.add(altLink);
|
||||
}
|
||||
}
|
||||
values = values2;
|
||||
} catch (Throwable throwable) {
|
||||
try {
|
||||
sQLBuilder.close();
|
||||
} catch (Throwable throwable2) {
|
||||
throwable.addSuppressed(throwable2);
|
||||
}
|
||||
throw throwable;
|
||||
}
|
||||
sQLBuilder.close();
|
||||
return values;
|
||||
} catch (Exception exception) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private <T> T findObject(SQLBuilder sQLBuilder, Class<T> classValue) throws Exception {
|
||||
return (T)
|
||||
PlatformGetter.getInstance()
|
||||
.getGson()
|
||||
.fromJson(String.valueOf(sQLBuilder.getObject(1)), classValue);
|
||||
}
|
||||
|
||||
private String append(int value) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (int index = 0; index < value; index++) {
|
||||
if (index > 0) {
|
||||
stringBuilder.append(',');
|
||||
}
|
||||
stringBuilder.append('?');
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
private boolean matchesEnabled(String text, String text2) throws Exception {
|
||||
SQLBuilder sQLBuilder = new SQLBuilder();
|
||||
boolean matches;
|
||||
try {
|
||||
sQLBuilder.setStatement(
|
||||
"SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ? AND COLUMN_NAME = ?");
|
||||
sQLBuilder.executeQuery(text, text2);
|
||||
matches = sQLBuilder.next() && ((Number) sQLBuilder.getObject(1)).intValue() > 0;
|
||||
} catch (Throwable throwable) {
|
||||
try {
|
||||
sQLBuilder.close();
|
||||
} catch (Throwable throwable2) {
|
||||
throwable.addSuppressed(throwable2);
|
||||
}
|
||||
throw throwable;
|
||||
}
|
||||
sQLBuilder.close();
|
||||
return matches;
|
||||
}
|
||||
|
||||
private MySQLDatabaseHandler getDatabaseHandler() {
|
||||
return (MySQLDatabaseHandler) this.platform.getDatabaseHandler();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package xyz.refinedev.phoenix.alt;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ScoreResult implements IScoreResult {
|
||||
|
||||
private final int score;
|
||||
|
||||
private final List<IAltSignal> signals;
|
||||
|
||||
@Override
|
||||
public int getScore() {
|
||||
return this.score;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IAltSignal> getSignals() {
|
||||
return this.signals;
|
||||
}
|
||||
|
||||
public ScoreResult(int score, List<IAltSignal> signals) {
|
||||
this.score = score;
|
||||
this.signals = signals;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package xyz.refinedev.phoenix.antivpn.api;
|
||||
|
||||
import xyz.refinedev.lib.jetbrains.Nullable;
|
||||
import xyz.refinedev.phoenix.profile.antivpn.IAntiVPNData;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface IAntiVPNProvider {
|
||||
|
||||
@Nullable
|
||||
IAntiVPNData check(UUID uUID, String text);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package xyz.refinedev.phoenix.antivpn.api.impl;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import xyz.refinedev.phoenix.CommonPlatform;
|
||||
import xyz.refinedev.phoenix.antivpn.api.IAntiVPNProvider;
|
||||
import xyz.refinedev.phoenix.profile.antivpn.AntiVPNData;
|
||||
import xyz.refinedev.phoenix.profile.antivpn.IAntiVPNData;
|
||||
import xyz.refinedev.phoenix.utils.HttpUtils;
|
||||
import xyz.refinedev.phoenix.utils.JsonParser;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class AntiVPNProvider implements IAntiVPNProvider {
|
||||
|
||||
private final CommonPlatform platform;
|
||||
|
||||
private final String text;
|
||||
|
||||
@Override
|
||||
public IAntiVPNData check(UUID uUID, String text2) {
|
||||
String text3 = this.platform.getHashHandler().hash(text2);
|
||||
String text4;
|
||||
if ((text4 =
|
||||
HttpUtils.get(
|
||||
"https://proxycheck.io/v2/"
|
||||
+ text2
|
||||
+ "?key="
|
||||
+ this.text
|
||||
+ "&vpn=1&asn=1"))
|
||||
== null) {
|
||||
return null;
|
||||
}
|
||||
JsonObject jsonObject;
|
||||
boolean matches =
|
||||
(jsonObject =
|
||||
JsonParser.findJsonElement(text4)
|
||||
.getAsJsonObject()
|
||||
.getAsJsonObject(text2))
|
||||
.get("proxy")
|
||||
.getAsString()
|
||||
.equalsIgnoreCase("yes")
|
||||
|| jsonObject.get("type").getAsString().equalsIgnoreCase("VPN");
|
||||
AntiVPNData antiVPNData;
|
||||
(antiVPNData = new AntiVPNData(uUID, text3)).setCity(jsonObject.get("city").getAsString());
|
||||
antiVPNData.setIsp(jsonObject.get("provider").getAsString());
|
||||
antiVPNData.setCountry(jsonObject.get("country").getAsString());
|
||||
antiVPNData.setRegion(jsonObject.get("continent").getAsString());
|
||||
antiVPNData.setVpn(matches);
|
||||
antiVPNData.setMobile(
|
||||
jsonObject.has("type")
|
||||
&& jsonObject.get("type").getAsString().equalsIgnoreCase("Mobile"));
|
||||
return antiVPNData;
|
||||
}
|
||||
|
||||
public AntiVPNProvider(CommonPlatform commonPlatform, String text) {
|
||||
this.platform = commonPlatform;
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package xyz.refinedev.phoenix.antivpn.provider;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import xyz.refinedev.phoenix.CommonPlatform;
|
||||
import xyz.refinedev.phoenix.antivpn.api.IAntiVPNProvider;
|
||||
import xyz.refinedev.phoenix.profile.antivpn.AntiVPNData;
|
||||
import xyz.refinedev.phoenix.profile.antivpn.IAntiVPNData;
|
||||
import xyz.refinedev.phoenix.utils.HttpUtils;
|
||||
import xyz.refinedev.phoenix.utils.JsonParser;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class IpRiskProvider implements IAntiVPNProvider {
|
||||
|
||||
private final CommonPlatform platform;
|
||||
|
||||
@Override
|
||||
public IAntiVPNData check(UUID uUID, String text) {
|
||||
String text2 = this.platform.getHashHandler().hash(text);
|
||||
String text3;
|
||||
if ((text3 = HttpUtils.get("https://beta.iprisk.info/v1/" + text)) == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
JsonObject jsonObject;
|
||||
boolean matches =
|
||||
(jsonObject = JsonParser.findJsonElement(text3).getAsJsonObject())
|
||||
.get("data_center")
|
||||
.getAsBoolean()
|
||||
|| jsonObject.get("public_proxy").getAsBoolean()
|
||||
|| jsonObject.get("tor_exit_relay").getAsBoolean();
|
||||
AntiVPNData antiVPNData;
|
||||
(antiVPNData = new AntiVPNData(uUID, text2))
|
||||
.setCity(
|
||||
jsonObject.get("city_name") != null
|
||||
? jsonObject.get("city_name").getAsString()
|
||||
: "N/A");
|
||||
antiVPNData.setIsp(
|
||||
jsonObject.get("autonomous_system_organization") != null
|
||||
? jsonObject.get("autonomous_system_organization").getAsString()
|
||||
: "N/A");
|
||||
antiVPNData.setCountry(
|
||||
jsonObject.get("country_name") != null
|
||||
? jsonObject.get("country_name").getAsString()
|
||||
: "N/A");
|
||||
antiVPNData.setRegion(
|
||||
jsonObject.get("region_name") != null
|
||||
? jsonObject.get("region_name").getAsString()
|
||||
: "N/A");
|
||||
antiVPNData.setVpn(matches);
|
||||
return antiVPNData;
|
||||
} catch (Exception exception) {
|
||||
this.platform
|
||||
.getLogger()
|
||||
.log(
|
||||
Level.SEVERE,
|
||||
"There was an error while performing the AntiVPN Check: ",
|
||||
exception);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public IpRiskProvider(CommonPlatform commonPlatform) {
|
||||
this.platform = commonPlatform;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package xyz.refinedev.phoenix.cache.api;
|
||||
|
||||
import xyz.refinedev.lib.jetbrains.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface IUUIDCache {
|
||||
|
||||
Map<String, UUID> nameToUuid = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
Map<UUID, String> uuidToName = new HashMap<>();
|
||||
|
||||
void loadFromCache();
|
||||
|
||||
@Nullable
|
||||
default UUID getUuidNoMojang(String text) {
|
||||
return nameToUuid.get(text);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default String getName(UUID uUID) {
|
||||
return uuidToName.get(uUID);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default String getNameFromString(String text) {
|
||||
try {
|
||||
return this.getName(UUID.fromString(text));
|
||||
} catch (Exception exception) {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default UUID getUuid(String text) {
|
||||
return text.toLowerCase().contains("uuid") ? nameToUuid.get(text) : null;
|
||||
}
|
||||
|
||||
void addToCache(UUID uUID, String text, boolean matches);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package xyz.refinedev.phoenix.chat;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Optional;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Text;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.phoenix.BukkitAPI;
|
||||
import xyz.refinedev.phoenix.CommonPlatform;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatChannelType;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
public class ChatChannelUtils {
|
||||
|
||||
private final CommonPlatform platform;
|
||||
|
||||
private final ChatChannelType chatChannelType;
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(@Sender Player player, @Optional @Named("message") @Text String text) {
|
||||
IProfile cachedProfile =
|
||||
this.platform.getProfileHandler().getCachedProfile(player.getUniqueId());
|
||||
if (text == null) {
|
||||
if (cachedProfile
|
||||
.getSetting("channel", "Default")
|
||||
.equalsIgnoreCase(this.chatChannelType.getName())) {
|
||||
cachedProfile.updateMetadata("channel", "Default", true);
|
||||
} else {
|
||||
cachedProfile.updateMetadata("channel", this.chatChannelType.getName(), true);
|
||||
}
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.GENERAL.CHANNEL_SWITCHED)
|
||||
.replace(
|
||||
"<channel>",
|
||||
cachedProfile.getSetting("channel", "Default"))));
|
||||
} else {
|
||||
BukkitAPI.sendGlobalChatChannel(cachedProfile, this.chatChannelType, text);
|
||||
}
|
||||
}
|
||||
|
||||
public ChatChannelUtils(CommonPlatform commonPlatform, ChatChannelType chatChannelType2) {
|
||||
this.platform = commonPlatform;
|
||||
this.chatChannelType = chatChannelType2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package xyz.refinedev.phoenix.chat.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class ChatChannelType {
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
public abstract boolean canSendMessage(Player player);
|
||||
|
||||
public abstract int getPriority();
|
||||
|
||||
public abstract String getFormat();
|
||||
|
||||
public abstract boolean canReceiveMessage(UUID uUID, Player player);
|
||||
|
||||
public boolean isGlobal() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isStaff() {
|
||||
return this.isGlobal();
|
||||
}
|
||||
|
||||
public String getPermission() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getQuickAccessPrefix() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package xyz.refinedev.phoenix.chat.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
public class ChatLimitation {
|
||||
|
||||
private final String name;
|
||||
|
||||
private final int priority;
|
||||
|
||||
private final BiFunction<Player, String, Boolean> function;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public int getPriority() {
|
||||
return this.priority;
|
||||
}
|
||||
|
||||
public BiFunction<Player, String, Boolean> getFunction() {
|
||||
return this.function;
|
||||
}
|
||||
|
||||
public ChatLimitation(
|
||||
String name, int priority, BiFunction<Player, String, Boolean> biFunction) {
|
||||
this.name = name;
|
||||
this.priority = priority;
|
||||
this.function = biFunction;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package xyz.refinedev.phoenix.chat.channel;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatChannelType;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class AdminChatChannel extends ChatChannelType {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSendMessage(Player player) {
|
||||
return !Phoenix.getInstance()
|
||||
.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId())
|
||||
.isSetting("staff-messages")
|
||||
? false
|
||||
: player.hasPermission("core.adminchat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 30;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormat() {
|
||||
return Color.translate(SettingsConfig.FORMATS.ADMIN_CHAT_FORMAT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveMessage(UUID uUID, Player player) {
|
||||
return !Phoenix.getInstance()
|
||||
.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId())
|
||||
.isSetting("staff-messages")
|
||||
? false
|
||||
: player.hasPermission("core.adminchat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlobal() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "core.adminchat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuickAccessPrefix() {
|
||||
return SettingsConfig.QUICK_ACCESS_PREFIXES.ADMIN_CHAT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package xyz.refinedev.phoenix.chat.channel;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatChannelType;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class BuilderChatChannel extends ChatChannelType {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Builder";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSendMessage(Player player) {
|
||||
return !Phoenix.getInstance()
|
||||
.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId())
|
||||
.isSetting("staff-messages")
|
||||
? false
|
||||
: player.hasPermission("core.builderchat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormat() {
|
||||
return Color.translate(SettingsConfig.FORMATS.BUILDER_CHAT_FORMAT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveMessage(UUID uUID, Player player) {
|
||||
return !Phoenix.getInstance()
|
||||
.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId())
|
||||
.isSetting("staff-messages")
|
||||
? false
|
||||
: player.hasPermission("core.builderchat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlobal() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "core.builderchat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuickAccessPrefix() {
|
||||
return SettingsConfig.QUICK_ACCESS_PREFIXES.BUILD_CHAT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package xyz.refinedev.phoenix.chat.channel;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatChannelType;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class DefaultChatChannel extends ChatChannelType {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Default";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSendMessage(Player player) {
|
||||
IProfile profile;
|
||||
if ((profile =
|
||||
Phoenix.getInstance()
|
||||
.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId()))
|
||||
== null) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.warning(player.getName() + " tried to chat, but there is no profile cached.");
|
||||
return false;
|
||||
} else if (!profile.isSetting("global-chat")) {
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.ERROR.GLOBAL_CHAT_DISABLED)));
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormat() {
|
||||
return Color.translate(SettingsConfig.FORMATS.CHAT_FORMAT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveMessage(UUID uUID, Player player) {
|
||||
IProfile profile;
|
||||
if ((profile = Phoenix.getInstance().getProfileHandler().getCachedProfile(uUID)) == null) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.warning(uUID + " tried to chat, but there is no profile cached.");
|
||||
return false;
|
||||
} else {
|
||||
IProfile profile2;
|
||||
if ((profile2 =
|
||||
Phoenix.getInstance()
|
||||
.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId()))
|
||||
== null) {
|
||||
Phoenix.getInstance()
|
||||
.getLogger()
|
||||
.warning(
|
||||
"The recipient '"
|
||||
+ player.getName()
|
||||
+ "' of a chat message has a null profile.");
|
||||
return false;
|
||||
} else if (profile.checkPermission("core.globalchat.bypass", false)) {
|
||||
return true;
|
||||
} else {
|
||||
return profile2.getIgnoring().contains(uUID)
|
||||
? false
|
||||
: profile2.isSetting("global-chat");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package xyz.refinedev.phoenix.chat.channel;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatChannelType;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ManagementChatChannel extends ChatChannelType {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Management";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSendMessage(Player player) {
|
||||
return !Phoenix.getInstance()
|
||||
.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId())
|
||||
.isSetting("staff-messages")
|
||||
? false
|
||||
: player.hasPermission("core.managementchat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 40;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormat() {
|
||||
return Color.translate(SettingsConfig.FORMATS.MANAGEMENT_CHAT_FORMAT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveMessage(UUID uUID, Player player) {
|
||||
return !Phoenix.getInstance()
|
||||
.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId())
|
||||
.isSetting("staff-messages")
|
||||
? false
|
||||
: player.hasPermission("core.managementchat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlobal() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "core.managementchat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuickAccessPrefix() {
|
||||
return SettingsConfig.QUICK_ACCESS_PREFIXES.MANAGEMENT_CHAT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package xyz.refinedev.phoenix.chat.channel;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatChannelType;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class StaffChatChannel extends ChatChannelType {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Staff";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSendMessage(Player player) {
|
||||
return !Phoenix.getInstance()
|
||||
.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId())
|
||||
.isSetting("staff-messages")
|
||||
? false
|
||||
: player.hasPermission("core.staff");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormat() {
|
||||
return Color.translate(SettingsConfig.FORMATS.STAFF_CHAT_FORMAT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveMessage(UUID uUID, Player player) {
|
||||
return !Phoenix.getInstance()
|
||||
.getProfileHandler()
|
||||
.getCachedProfile(player.getUniqueId())
|
||||
.isSetting("staff-messages")
|
||||
? false
|
||||
: player.hasPermission("core.staff");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlobal() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "core.staff";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuickAccessPrefix() {
|
||||
return SettingsConfig.QUICK_ACCESS_PREFIXES.STAFF_CHAT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package xyz.refinedev.phoenix.chat.limitation;
|
||||
|
||||
import xyz.refinedev.phoenix.CommonPlatform;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatLimitation;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class AntiSpamChatLimitation extends ChatLimitation {
|
||||
|
||||
private static final Map<UUID, String> stringsById = new ConcurrentHashMap<>();
|
||||
|
||||
public AntiSpamChatLimitation(CommonPlatform commonPlatform) {
|
||||
super(
|
||||
"AntiSpam",
|
||||
4,
|
||||
(result, result2) -> {
|
||||
if (!SettingsConfig.SERVER.ANTISPAM.ENABLED) {
|
||||
return true;
|
||||
} else if (result.hasPermission("core.antispam.bypass")) {
|
||||
return true;
|
||||
} else {
|
||||
String text =
|
||||
commonPlatform
|
||||
.getFilterHandler()
|
||||
.sanitize(result2)
|
||||
.replace(" ", "");
|
||||
String text2;
|
||||
if ((text2 = stringsById.put(result.getUniqueId(), text)) == null) {
|
||||
return true;
|
||||
} else if (calculateValue(text2, text)
|
||||
>= SettingsConfig.SERVER.ANTISPAM.SIMILARITY) {
|
||||
result.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(
|
||||
result,
|
||||
MessageConfig.ANTISPAM.YOU_CANT_SEND_TWICE)));
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void applyUUID(UUID uUID) {
|
||||
stringsById.remove(uUID);
|
||||
}
|
||||
|
||||
private static double calculateValue(String text, String text2) {
|
||||
if (text.equalsIgnoreCase(text2)) {
|
||||
return 1.0;
|
||||
} else {
|
||||
int value;
|
||||
if ((value = Math.max(text.length(), text2.length())) == 0) {
|
||||
return 1.0;
|
||||
} else if (!text.contains(text2) && !text2.contains(text)) {
|
||||
return (double) calculateCount(text, text2) / value;
|
||||
} else {
|
||||
return text.length() > text2.length()
|
||||
? (double) text2.length() / text.length()
|
||||
: (double) text.length() / text2.length();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static int calculateCount(String text, String text2) {
|
||||
int value = Math.min(text.length(), text2.length());
|
||||
int value2 = 0;
|
||||
for (int index = 0; index < value; index++) {
|
||||
if (text.charAt(index) == text2.charAt(index)) {
|
||||
value2++;
|
||||
}
|
||||
}
|
||||
return value2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package xyz.refinedev.phoenix.chat.limitation;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatLimitation;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.utils.chat.Clickable;
|
||||
|
||||
public class AuthenticationChatLimitation extends ChatLimitation {
|
||||
|
||||
private static final String SHADOWMUTE_TEXT = "shadowmute";
|
||||
|
||||
public AuthenticationChatLimitation(Phoenix phoenix) {
|
||||
super(
|
||||
SHADOWMUTE_TEXT,
|
||||
5,
|
||||
(result, result2) -> {
|
||||
IProfile profile;
|
||||
if ((profile =
|
||||
phoenix.getProfileHandler()
|
||||
.getCachedProfile(result.getUniqueId()))
|
||||
== null) {
|
||||
return false;
|
||||
} else if (profile.isShadowMuted()) {
|
||||
Clickable clickable;
|
||||
(clickable = new Clickable())
|
||||
.addComponent(
|
||||
phoenix.getChatHandler()
|
||||
.buildDefaultChatComponent(
|
||||
result, result, result2));
|
||||
clickable.sendToPlayer(result);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package xyz.refinedev.phoenix.chat.limitation;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatLimitation;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
public class ChatCooldownLimitation extends ChatLimitation {
|
||||
|
||||
private static final String AUTH_TEXT = "auth";
|
||||
|
||||
public ChatCooldownLimitation(Phoenix phoenix) {
|
||||
super(
|
||||
AUTH_TEXT,
|
||||
6,
|
||||
(result, result2) -> {
|
||||
IProfile profile;
|
||||
if ((profile =
|
||||
phoenix.getProfileHandler()
|
||||
.getCachedProfile(result.getUniqueId()))
|
||||
== null) {
|
||||
return false;
|
||||
} else if (profile.isTwoFactor()) {
|
||||
result.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(result, MessageConfig.AUTH.CANNOT_CHAT)));
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package xyz.refinedev.phoenix.chat.limitation;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatLimitation;
|
||||
import xyz.refinedev.phoenix.config.GlobalConfig;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.packet.impl.server.SendToStaffPacket;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.chatsnapshot.ChatEntry;
|
||||
import xyz.refinedev.phoenix.profile.chatsnapshot.ChatLog;
|
||||
import xyz.refinedev.phoenix.profile.filter.IFilter;
|
||||
import xyz.refinedev.phoenix.profile.punishment.IPunishment;
|
||||
import xyz.refinedev.phoenix.profile.punishment.ladder.IPunishmentLadder;
|
||||
import xyz.refinedev.phoenix.profile.punishment.ladder.IPunishmentLadderType;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.PunishmentUtil;
|
||||
import xyz.refinedev.phoenix.utils.chat.Clickable;
|
||||
import xyz.refinedev.phoenix.utils.general.Tasks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FilterChatLimitation extends ChatLimitation {
|
||||
|
||||
public FilterChatLimitation(Phoenix phoenix) {
|
||||
super(
|
||||
"filter",
|
||||
4,
|
||||
(result, result2) -> {
|
||||
if (phoenix.getFilterHandler().isFiltered(result2)) {
|
||||
if (result.hasPermission("core.filter.bypass")) {
|
||||
result.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(
|
||||
result,
|
||||
MessageConfig.FILTER.WOULDVE_BEEN_FILTERED)));
|
||||
return true;
|
||||
}
|
||||
IProfile profile;
|
||||
if ((profile =
|
||||
phoenix.getProfileHandler()
|
||||
.getCachedProfile(result.getUniqueId()))
|
||||
== null) {
|
||||
phoenix.getLogger()
|
||||
.warning(
|
||||
"Unable to check "
|
||||
+ result.getName()
|
||||
+ "'s chat messages with the filter, because their profile isn't loaded.");
|
||||
return false;
|
||||
}
|
||||
phoenix.getChatSnapshotHandler()
|
||||
.getChatEntries()
|
||||
.add(
|
||||
new ChatEntry(
|
||||
result.getUniqueId(),
|
||||
phoenix.getChatHandler()
|
||||
.getReplacedChatFormat(result, result2)));
|
||||
phoenix.getChatLogHandler()
|
||||
.addChatLog(new ChatLog(result.getUniqueId(), result2));
|
||||
IFilter filter;
|
||||
if ((filter = phoenix.getFilterHandler().getFilterFromMessage(result2))
|
||||
!= null
|
||||
&& filter.isAutoPunish()
|
||||
&& filter.hasPunishmentLadder()) {
|
||||
IPunishmentLadder punishmentLadder = filter.getPunishmentLadder();
|
||||
IProfile profile2 = profile;
|
||||
Tasks.runAsync(
|
||||
() -> {
|
||||
List<IPunishment> punishments =
|
||||
phoenix.getPunishmentHandler()
|
||||
.getPunishments(profile2.getUniqueId());
|
||||
IPunishmentLadderType nextLadder =
|
||||
punishmentLadder.getNextLadder(punishments);
|
||||
if (!profile2.hasActivePunishment(nextLadder.getType())) {
|
||||
IPunishment punishment =
|
||||
phoenix.getPunishmentLadderHandler()
|
||||
.createPunishment(
|
||||
IProfile.getConsoleUuid(),
|
||||
profile2,
|
||||
punishmentLadder,
|
||||
true);
|
||||
phoenix.getPunishmentHandler()
|
||||
.getRepository()
|
||||
.saveSync(punishment.getUuid(), punishment);
|
||||
PunishmentUtil.executePunishment(
|
||||
Bukkit.getConsoleSender(), punishment);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (filter == null
|
||||
&& GlobalConfig.FILTER.LINKS_HARD
|
||||
&& GlobalConfig.FILTER.LINKS_FILTER
|
||||
|| filter != null && filter.isHard()) {
|
||||
phoenix.getPacketHandler()
|
||||
.send(
|
||||
new SendToStaffPacket(
|
||||
MessageConfig.FILTER.STAFF_ALERT_SEVERE,
|
||||
LocaleUtil.replacements(
|
||||
"<player>",
|
||||
profile.getNameWithColorNoDisguise(),
|
||||
"<server>",
|
||||
phoenix.getNetworkHandler()
|
||||
.getDisplayName(),
|
||||
"<message>",
|
||||
result2),
|
||||
false,
|
||||
true));
|
||||
if (GlobalConfig.FILTER.ALERT_FILTER) {
|
||||
result.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(
|
||||
result,
|
||||
MessageConfig.FILTER
|
||||
.CONTAINS_BLOCKED_WORDS)));
|
||||
}
|
||||
if (GlobalConfig.FILTER.GHOST_MODE) {
|
||||
Clickable clickable;
|
||||
(clickable = new Clickable())
|
||||
.addComponent(
|
||||
phoenix.getChatHandler()
|
||||
.buildDefaultChatComponent(
|
||||
result, result, result2));
|
||||
clickable.sendToPlayer(result);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (filter != null || GlobalConfig.FILTER.LINKS_FILTER) {
|
||||
phoenix.getPacketHandler()
|
||||
.send(
|
||||
new SendToStaffPacket(
|
||||
MessageConfig.FILTER.STAFF_ALERT,
|
||||
LocaleUtil.replacements(
|
||||
"<player>",
|
||||
profile.getNameWithColorNoDisguise(),
|
||||
"<server>",
|
||||
phoenix.getNetworkHandler()
|
||||
.getDisplayName(),
|
||||
"<message>",
|
||||
result2),
|
||||
false,
|
||||
true));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package xyz.refinedev.phoenix.chat.limitation;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatLimitation;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class FrozenChatLimitation extends ChatLimitation {
|
||||
|
||||
public FrozenChatLimitation(Phoenix phoenix, Phoenix phoenix2) {
|
||||
super(
|
||||
"frozen",
|
||||
2,
|
||||
(result, result2) -> {
|
||||
if (!phoenix.getFreezeHandler().isFrozen(result.getUniqueId())) {
|
||||
return true;
|
||||
}
|
||||
String replacedChatFormat =
|
||||
phoenix2.getChatHandler().getReplacedChatFormat(result, result2);
|
||||
Iterator iterator2 = Bukkit.getOnlinePlayers().iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
Player player;
|
||||
if ((player = (Player) iterator2.next()).hasPermission("core.staff")) {
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(
|
||||
player, MessageConfig.FREEZE.PREFIX))
|
||||
+ replacedChatFormat);
|
||||
}
|
||||
}
|
||||
Bukkit.getConsoleSender()
|
||||
.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(
|
||||
Bukkit.getConsoleSender(),
|
||||
MessageConfig.FREEZE.PREFIX))
|
||||
+ replacedChatFormat);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package xyz.refinedev.phoenix.chat.limitation;
|
||||
|
||||
import xyz.refinedev.phoenix.chat.api.ChatLimitation;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
public class MutedChatLimitation extends ChatLimitation {
|
||||
|
||||
public MutedChatLimitation() {
|
||||
super(
|
||||
"mutechat",
|
||||
7,
|
||||
(result, result2) -> {
|
||||
if (SettingsConfig.CHAT_CONTROL.MUTED
|
||||
&& !result.hasPermission("core.mutechat.bypass")) {
|
||||
result.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(result, MessageConfig.CHAT.CURRENTLY_MUTED)));
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package xyz.refinedev.phoenix.chat.limitation;
|
||||
|
||||
import xyz.refinedev.phoenix.CommonPlatform;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatLimitation;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.handler.BukkitLocaleHandler;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.punishment.IPunishment;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.TimeConstants;
|
||||
|
||||
public class PunishmentChatLimitation extends ChatLimitation {
|
||||
|
||||
public PunishmentChatLimitation(CommonPlatform commonPlatform) {
|
||||
super(
|
||||
"punishments",
|
||||
3,
|
||||
(result, result2) -> {
|
||||
IProfile cachedProfile =
|
||||
commonPlatform
|
||||
.getProfileHandler()
|
||||
.getCachedProfile(result.getUniqueId());
|
||||
BukkitLocaleHandler localeHandler = Phoenix.getInstance().getLocaleHandler();
|
||||
if (cachedProfile.isBanned() || cachedProfile.isBlacklisted()) {
|
||||
result.sendMessage(
|
||||
Color.translate(
|
||||
localeHandler.get(
|
||||
result,
|
||||
"punishment.cant-talk-while-banned-or-blacklisted",
|
||||
MessageConfig.PUNISHMENT
|
||||
.CANT_TALK_WHILE_BANNED_OR_BLACKLISTED)));
|
||||
return false;
|
||||
}
|
||||
if (cachedProfile.isIPMuted()) {
|
||||
IPunishment punishment;
|
||||
if ((punishment = cachedProfile.getActiveIPMute()).isPermanent()) {
|
||||
for (String text :
|
||||
(Iterable<String>)
|
||||
((Iterable)
|
||||
localeHandler.getList(
|
||||
result,
|
||||
"punishment.ipmute.cant-talk-message",
|
||||
MessageConfig.PUNISHMENT
|
||||
.IPMUTE
|
||||
.CANT_TALK_MESSAGE))) {
|
||||
result.sendMessage(
|
||||
Color.translate(
|
||||
text.replace("<alt>", punishment.getNiceTarget())
|
||||
.replace(
|
||||
"<duration>",
|
||||
TimeConstants.PERMANENT)
|
||||
.replace("<reason>", punishment.getReason())
|
||||
.replace(
|
||||
"<punishmentID>",
|
||||
punishment.getPunishmentID())));
|
||||
}
|
||||
} else {
|
||||
for (String text2 :
|
||||
(Iterable<String>)
|
||||
((Iterable)
|
||||
localeHandler.getList(
|
||||
result,
|
||||
"punishment.tempipmute.cant-talk-message",
|
||||
MessageConfig.PUNISHMENT
|
||||
.TEMPIPMUTE
|
||||
.CANT_TALK_MESSAGE))) {
|
||||
result.sendMessage(
|
||||
Color.translate(
|
||||
text2.replace("<alt>", punishment.getNiceTarget())
|
||||
.replace(
|
||||
"<duration>",
|
||||
punishment.getNiceExpire())
|
||||
.replace("<reason>", punishment.getReason())
|
||||
.replace(
|
||||
"<punishmentID>",
|
||||
punishment.getPunishmentID())));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
if (!cachedProfile.isNormalMuted()) {
|
||||
return true;
|
||||
}
|
||||
IPunishment punishment2;
|
||||
if ((punishment2 = cachedProfile.getActiveMute()).isPermanent()) {
|
||||
for (String text3 :
|
||||
(Iterable<String>)
|
||||
((Iterable)
|
||||
localeHandler.getList(
|
||||
result,
|
||||
"punishment.mute.cant-talk-message",
|
||||
MessageConfig.PUNISHMENT
|
||||
.MUTE
|
||||
.CANT_TALK_MESSAGE))) {
|
||||
result.sendMessage(
|
||||
Color.translate(
|
||||
text3.replace("<duration>", TimeConstants.PERMANENT)
|
||||
.replace(
|
||||
"<reason>", punishment2.getReason())
|
||||
.replace(
|
||||
"<punishmentID>",
|
||||
punishment2.getPunishmentID())));
|
||||
}
|
||||
} else {
|
||||
for (String text4 :
|
||||
(Iterable<String>)
|
||||
((Iterable)
|
||||
localeHandler.getList(
|
||||
result,
|
||||
"punishment.tempmute.cant-talk-message",
|
||||
MessageConfig.PUNISHMENT
|
||||
.TEMPMUTE
|
||||
.CANT_TALK_MESSAGE))) {
|
||||
result.sendMessage(
|
||||
Color.translate(
|
||||
text4.replace(
|
||||
"<duration>",
|
||||
punishment2.getNiceExpire())
|
||||
.replace(
|
||||
"<reason>", punishment2.getReason())
|
||||
.replace(
|
||||
"<punishmentID>",
|
||||
punishment2.getPunishmentID())));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package xyz.refinedev.phoenix.chat.limitation;
|
||||
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.chat.api.ChatLimitation;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.handler.ICooldownHandler;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.DateUtils;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
public class SlowChatLimitation extends ChatLimitation {
|
||||
|
||||
private static final long timeTime = 1000L;
|
||||
|
||||
public SlowChatLimitation(Phoenix phoenix) {
|
||||
super(
|
||||
"slowchat",
|
||||
8,
|
||||
(result, result2) -> {
|
||||
ICooldownHandler cooldownHandler = phoenix.getCooldownHandler();
|
||||
if (!result.hasPermission("core.slowchat.bypass")) {
|
||||
if (cooldownHandler.isOnCooldown("slowchat", result.getUniqueId())) {
|
||||
result.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(
|
||||
result,
|
||||
MessageConfig.CHAT.CURRENTLY_SLOWED)
|
||||
.replace(
|
||||
"<seconds>",
|
||||
DateUtils.formatTimeMillis(
|
||||
cooldownHandler.getRemaining(
|
||||
"slowchat",
|
||||
result
|
||||
.getUniqueId())))));
|
||||
return false;
|
||||
} else {
|
||||
phoenix.getCooldownHandler()
|
||||
.placeOnCooldown(
|
||||
"slowchat",
|
||||
result.getUniqueId(),
|
||||
SettingsConfig.CHAT_CONTROL.SLOW_DELAY * timeTime);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Text;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.lib.commands.exception.execution.ExitMessage;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.XMaterial;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Register(name = "addlore")
|
||||
@Requires("core.command.addlore")
|
||||
public class AddloreCommand {
|
||||
|
||||
private static final String text = "<lore>";
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(@Sender Player player, @Named("lore") @Text String text2) {
|
||||
ItemStack itemStack;
|
||||
if ((itemStack = player.getItemInHand()) != null
|
||||
&& itemStack.getType() != XMaterial.AIR.parseMaterial()) {
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
List<String> values = new ArrayList<>();
|
||||
if (itemMeta.getLore() != null) {
|
||||
values = itemMeta.getLore();
|
||||
}
|
||||
values.add(text2);
|
||||
itemMeta.setLore(Color.translate(values));
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
player.updateInventory();
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.BASIC.ADMIN.ITEM.LORE_ADDED)
|
||||
.replace(text, Color.translate(text2))));
|
||||
} else {
|
||||
throw new ExitMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.BASIC.GENERAL.INVALID_ITEM)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Option;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.GlobalConfig;
|
||||
import xyz.refinedev.phoenix.menu.impl.AdminProfileSectionsMenu;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.utils.GsonExclude;
|
||||
|
||||
@Register(name = "adminprofile", aliases = "aprofile")
|
||||
@Requires("core.command.adminprofile")
|
||||
public class AdminprofileCommand {
|
||||
|
||||
@GsonExclude
|
||||
public static String text = "Uo9vZ5VqF8aPQ2mwXHWdON20E4V7M2Ce_rliCz6I93YcMmbys1UlPNSNer6YMKR8";
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "", async = true)
|
||||
public void execute(
|
||||
@Sender Player player,
|
||||
@Option({"disguise", "multiple"}) @Named("player") IProfile profile) {
|
||||
if (GlobalConfig.SERVER.ALTS.ENABLED) {
|
||||
profile.loadAlts();
|
||||
}
|
||||
this.plugin.getMenuHandler().openMenuAsync(new AdminProfileSectionsMenu(profile), player);
|
||||
}
|
||||
|
||||
public AdminprofileCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Text;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.packet.impl.profile.AlertPacket;
|
||||
|
||||
@Register(name = "alert")
|
||||
@Requires("core.command.alert")
|
||||
public class AlertCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
private static final String text = "<message>";
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(@Sender CommandSender sender, @Named("message") @Text String text2) {
|
||||
this.plugin
|
||||
.getPacketHandler()
|
||||
.send(new AlertPacket(MessageConfig.STAFF.ALERT.replace(text, text2)));
|
||||
}
|
||||
|
||||
public AlertCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,35 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.CommonPlatform;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
@Register(name = "amivanished", aliases = "amivis")
|
||||
@Requires("core.command.vanish")
|
||||
public class AmivanishedCommand {
|
||||
|
||||
private final CommonPlatform platform;
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(@Sender Player player) {
|
||||
if (this.platform.getProfileHandler().getCachedProfile(player.getUniqueId()).isVanished()) {
|
||||
player.sendMessage(
|
||||
Color.translate(LocaleUtil.tr(player, MessageConfig.STAFF.AM_I_VANISHED_TRUE)));
|
||||
} else {
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.STAFF.AM_I_VANISHED_FALSE)));
|
||||
}
|
||||
}
|
||||
|
||||
public AmivanishedCommand(CommonPlatform commonPlatform) {
|
||||
this.platform = commonPlatform;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Help;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.menu.impl.AnalyticsMenu;
|
||||
import xyz.refinedev.phoenix.server.IServerData;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.MetricsReporter;
|
||||
import xyz.refinedev.phoenix.utils.Utilities;
|
||||
import xyz.refinedev.phoenix.utils.general.Tasks;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@Help
|
||||
@Register(name = "analytics", aliases = "serveranalytics")
|
||||
@Requires("core.command.analytics")
|
||||
public class AnalyticsCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "total", async = true)
|
||||
public void total(@Sender CommandSender sender) {
|
||||
MetricsReporter.applyString("analytics_command");
|
||||
sender.sendMessage(Color.translate(LocaleUtil.tr(sender, MessageConfig.ANALYTICS.LOADING)));
|
||||
Tasks.runAsync(
|
||||
() -> {
|
||||
int totalPeakPlayers = this.plugin.getAnalyticsHandler().getTotalPeakPlayers();
|
||||
int totalPeakPlayers2 =
|
||||
this.plugin.getAnalyticsHandler().getTotalPeakPlayers(1);
|
||||
int peakPlayers = this.plugin.getAnalyticsHandler().getPeakPlayers(7);
|
||||
long logins = this.plugin.getAnalyticsHandler().getLogins(1);
|
||||
long logins2 = this.plugin.getAnalyticsHandler().getLogins(2);
|
||||
long logins3 = this.plugin.getAnalyticsHandler().getLogins(8);
|
||||
long logins4 = this.plugin.getAnalyticsHandler().getLogins(31);
|
||||
long totalServerSwitches =
|
||||
this.plugin.getAnalyticsHandler().getTotalServerSwitches(0);
|
||||
long totalServerSwitches2 =
|
||||
this.plugin.getAnalyticsHandler().getTotalServerSwitches(1);
|
||||
Map<String, String> retentionPlaceholders =
|
||||
this.plugin.getAnalyticsHandler().getRetentionPlaceholders();
|
||||
for (String text : LocaleUtil.tr(sender, MessageConfig.ANALYTICS.MESSAGE)) {
|
||||
for (Entry<String, String> entry : retentionPlaceholders.entrySet()) {
|
||||
text =
|
||||
text.replace(
|
||||
(CharSequence) entry.getKey(),
|
||||
(CharSequence) entry.getValue());
|
||||
}
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
text.replace(
|
||||
"<online>",
|
||||
String.valueOf(
|
||||
this.plugin
|
||||
.getNetworkHandler()
|
||||
.getAllOnline()))
|
||||
.replace("<peak>", String.valueOf(totalPeakPlayers))
|
||||
.replace(
|
||||
"<peakYesterday>",
|
||||
String.valueOf(totalPeakPlayers2))
|
||||
.replace("<peakWeek>", String.valueOf(peakPlayers))
|
||||
.replace(
|
||||
"<peakYesterdayDiff>",
|
||||
totalPeakPlayers >= totalPeakPlayers2
|
||||
? "&a+"
|
||||
+ (totalPeakPlayers
|
||||
- totalPeakPlayers2)
|
||||
: "&c"
|
||||
+ (totalPeakPlayers
|
||||
- totalPeakPlayers2))
|
||||
.replace(
|
||||
"<peakWeekDiff>",
|
||||
totalPeakPlayers >= peakPlayers
|
||||
? "&a+"
|
||||
+ (totalPeakPlayers
|
||||
- peakPlayers)
|
||||
: "&c"
|
||||
+ (totalPeakPlayers
|
||||
- peakPlayers))
|
||||
.replace(
|
||||
"<playtime>",
|
||||
this.plugin
|
||||
.getAnalyticsHandler()
|
||||
.getTotalAveragePlayTime(0))
|
||||
.replace(
|
||||
"<playtimeYesterday>",
|
||||
this.plugin
|
||||
.getAnalyticsHandler()
|
||||
.getTotalAveragePlayTime(1))
|
||||
.replace(
|
||||
"<playtimeWeek>",
|
||||
this.plugin
|
||||
.getAnalyticsHandler()
|
||||
.getAveragePlayTime(7))
|
||||
.replace(
|
||||
"<playtimeYesterdayDiff>",
|
||||
this.plugin
|
||||
.getAnalyticsHandler()
|
||||
.getTotalAveragePlayTimeDifference(
|
||||
1))
|
||||
.replace(
|
||||
"<playtimeWeekDiff>",
|
||||
this.plugin
|
||||
.getAnalyticsHandler()
|
||||
.getTotalAveragePlayTimeDifference(
|
||||
7))
|
||||
.replace("<logins>", Utilities.formatNumber(logins))
|
||||
.replace(
|
||||
"<loginsYesterday>",
|
||||
Utilities.formatNumber(logins2))
|
||||
.replace(
|
||||
"<loginsWeek>",
|
||||
Utilities.formatNumber(logins3))
|
||||
.replace(
|
||||
"<loginsMonth>",
|
||||
Utilities.formatNumber(logins4))
|
||||
.replace(
|
||||
"<loginsYesterdayDiff>",
|
||||
logins >= logins2
|
||||
? "&a+"
|
||||
+ Utilities.formatNumber(
|
||||
logins - logins2)
|
||||
: "&c"
|
||||
+ Utilities
|
||||
.formatNumberNegative(
|
||||
logins
|
||||
- logins2))
|
||||
.replace(
|
||||
"<switches>",
|
||||
Utilities.formatNumber(totalServerSwitches))
|
||||
.replace(
|
||||
"<switchesYesterday>",
|
||||
Utilities.formatNumber(
|
||||
totalServerSwitches2))));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Command(name = "view")
|
||||
public void view(@Sender Player player, @Named("server") IServerData serverData) {
|
||||
this.plugin.getMenuHandler().openMenu(new AnalyticsMenu(serverData), player);
|
||||
}
|
||||
|
||||
public AnalyticsCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Optional;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.lib.commands.exception.execution.ExitMessage;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.auth.api.Authenticator;
|
||||
import xyz.refinedev.phoenix.utils.general.Tasks;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@Register(name = "auth", aliases = "2fa")
|
||||
@Requires("core.2fa")
|
||||
public class AuthCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(@Sender Player player, @Named("code") @Optional String text) {
|
||||
IProfile cachedProfile =
|
||||
this.plugin.getProfileHandler().getCachedProfile(player.getUniqueId());
|
||||
Authenticator authenticator;
|
||||
if ((authenticator =
|
||||
this.plugin
|
||||
.getAuthHandler()
|
||||
.getAuthenticatorByType(cachedProfile.getAuthType()))
|
||||
== null) {
|
||||
throw new ExitMessage(LocaleUtil.tr(player, MessageConfig.AUTH.NOT_ENABLED));
|
||||
}
|
||||
if (authenticator.isRequireCode() && text == null) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(player, MessageConfig.AUTH.CODE_REQUIRED)
|
||||
.replace("<type>", authenticator.getName()));
|
||||
}
|
||||
if (!cachedProfile.isTwoFactor()) {
|
||||
throw new ExitMessage(LocaleUtil.tr(player, MessageConfig.AUTH.NO_NEED_TO));
|
||||
}
|
||||
if (authenticator.canAuthenticate(player)) {
|
||||
Map<java.util.UUID, Integer> entries;
|
||||
int value =
|
||||
(entries = this.plugin.getAuthHandler().getAuthAttempts())
|
||||
.getOrDefault(player.getUniqueId(), 0)
|
||||
+ 1;
|
||||
entries.put(player.getUniqueId(), value);
|
||||
if (authenticator.isAsync()) {
|
||||
Authenticator authenticator2 = authenticator;
|
||||
CompletableFuture<Boolean> completableFuture =
|
||||
CompletableFuture.supplyAsync(
|
||||
() -> authenticator2.authenticate(player, text));
|
||||
completableFuture.whenComplete(
|
||||
(result, result2) -> {
|
||||
if (result2 != null) {
|
||||
this.plugin
|
||||
.getLogger()
|
||||
.log(
|
||||
Level.SEVERE,
|
||||
"There was an error while authenticating "
|
||||
+ player.getName()
|
||||
+ ": ",
|
||||
result2);
|
||||
} else {
|
||||
Tasks.run(
|
||||
() ->
|
||||
this.sendMessage(
|
||||
player, cachedProfile, value, result));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.sendMessage(
|
||||
player, cachedProfile, value, authenticator.authenticate(player, text));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendMessage(Player player, IProfile profile, int value, boolean matches) {
|
||||
if (matches) {
|
||||
profile.setTwoFactor(false);
|
||||
profile.saveAndUpdate();
|
||||
if (this.plugin.getNmsHandler().isRegistered()) {
|
||||
this.plugin.getNmsHandler().getAPI().unsitPlayer(player);
|
||||
}
|
||||
this.plugin.getAuthHandler().getAuthAttempts().put(player.getUniqueId(), 0);
|
||||
player.sendMessage(
|
||||
Color.translate(LocaleUtil.tr(player, MessageConfig.AUTH.SUCCESSFUL)));
|
||||
} else {
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.AUTH.INVALID_CODE)
|
||||
.replace(
|
||||
"<attempts>",
|
||||
String.valueOf(SettingsConfig.AUTH.ATTEMPTS - value))));
|
||||
if (value >= SettingsConfig.AUTH.ATTEMPTS) {
|
||||
Bukkit.dispatchCommand(
|
||||
Bukkit.getConsoleSender(),
|
||||
SettingsConfig.AUTH.FAILED_COMMAND.replace("<user>", player.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public AuthCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Optional;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.lib.commands.exception.execution.ExitMessage;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.auth.api.Authenticator;
|
||||
|
||||
@Register(
|
||||
name = "authsetup",
|
||||
aliases = {"setup2fa", "2fasetup"})
|
||||
@Requires("core.2fa")
|
||||
public class AuthsetupCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(@Sender Player player, @Optional Authenticator authenticator) {
|
||||
this.plugin.getProfileHandler().getCachedProfile(player.getUniqueId());
|
||||
if (authenticator == null) {
|
||||
authenticator =
|
||||
this.plugin
|
||||
.getAuthHandler()
|
||||
.getAuthenticatorByType(SettingsConfig.AUTH.DEFAULT_METHOD);
|
||||
}
|
||||
if (authenticator == null) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(player, MessageConfig.AUTH.AUTH_METHOD_NOT_ENABLED));
|
||||
}
|
||||
if (authenticator.canSetup(player)) {
|
||||
authenticator.setup(player);
|
||||
}
|
||||
}
|
||||
|
||||
public AuthsetupCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,466 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Help;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Flag;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Option;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Text;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.lib.commands.exception.execution.ExitMessage;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.punishment.ProofType;
|
||||
import xyz.refinedev.phoenix.profile.punishment.PunishmentType;
|
||||
import xyz.refinedev.phoenix.profile.punishment.VoidReason;
|
||||
import xyz.refinedev.phoenix.profile.punishment.banwave.BanWave;
|
||||
import xyz.refinedev.phoenix.profile.punishment.banwave.BanWaveEntry;
|
||||
import xyz.refinedev.phoenix.profile.punishment.banwave.IBanWave;
|
||||
import xyz.refinedev.phoenix.profile.punishment.banwave.IBanWaveEntry;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.ConfirmationMenus;
|
||||
import xyz.refinedev.phoenix.utils.DateUtils;
|
||||
import xyz.refinedev.phoenix.utils.Duration;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.PunishmentUtil;
|
||||
import xyz.refinedev.phoenix.utils.chat.ConversationUtil;
|
||||
import xyz.refinedev.phoenix.utils.general.Tasks;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@Register(
|
||||
name = "banwave",
|
||||
aliases = {"wave", "punishwave"})
|
||||
@Requires("core.command.banwave")
|
||||
@Help
|
||||
public class BanwaveCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "create", description = "Start a new wave", async = true)
|
||||
@Requires("core.command.banwave.create")
|
||||
public void create(@Sender CommandSender sender, @Named("name") String text) {
|
||||
this.applyCommandSender(sender);
|
||||
if (this.plugin.getBanWaveHandler().byName(text) != null) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.ALREADY_EXISTS)
|
||||
.replace("<wave>", text));
|
||||
}
|
||||
BanWave banWave =
|
||||
new BanWave(
|
||||
text,
|
||||
sender instanceof Player
|
||||
? ((Player) sender).getUniqueId()
|
||||
: IProfile.getConsoleUuid(),
|
||||
System.currentTimeMillis());
|
||||
this.plugin.getBanWaveHandler().save(banWave);
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.CREATED)
|
||||
.replace("<wave>", text)));
|
||||
}
|
||||
|
||||
@Command(name = "add", description = "Stage an account in a wave", async = true)
|
||||
@Requires("core.command.banwave.add")
|
||||
public void add(
|
||||
@Sender CommandSender sender,
|
||||
@Named("wave") String text,
|
||||
@Option({"disguise", "multiple"}) IProfile profile,
|
||||
@Named("type") PunishmentType punishmentType,
|
||||
@Named("duration") Duration duration,
|
||||
@Named("reason") @Text String text2,
|
||||
@Flag("ip") boolean matches,
|
||||
@Flag("shadow") boolean matches2) {
|
||||
this.applyCommandSender(sender);
|
||||
IBanWave banWave;
|
||||
if ((banWave = this.findBanWave(sender, text)).holds(profile.getUniqueId())) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.ALREADY_STAGED)
|
||||
.replace("<player>", profile.getNameWithColorNoDisguise()));
|
||||
}
|
||||
if (PunishmentUtil.canPunish(sender, profile, new AtomicBoolean(false))) {
|
||||
if (sender instanceof Player
|
||||
&& !sender.hasPermission(
|
||||
"core.punish." + punishmentType.name().toLowerCase())) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.NO_PERMISSION)
|
||||
.replace("<type>", punishmentType.getNiceName()));
|
||||
}
|
||||
long timeTime = duration.getTimeTime();
|
||||
BanWaveEntry banWaveEntry;
|
||||
(banWaveEntry =
|
||||
new BanWaveEntry(
|
||||
profile.getUniqueId(),
|
||||
profile.getName(),
|
||||
punishmentType,
|
||||
timeTime,
|
||||
text2,
|
||||
sender instanceof Player
|
||||
? ((Player) sender).getUniqueId()
|
||||
: IProfile.getConsoleUuid(),
|
||||
System.currentTimeMillis()))
|
||||
.setIp(matches);
|
||||
banWaveEntry.setShadow(matches2);
|
||||
if (!matches
|
||||
|| profile.getCurrentAddress() != null
|
||||
&& !profile.getCurrentAddress().isEmpty()) {
|
||||
if (this.matchesEnabled(sender, punishmentType)) {
|
||||
Player player = (Player) sender;
|
||||
IBanWave banWave2 = banWave;
|
||||
BanWaveEntry banWaveEntry2 = banWaveEntry;
|
||||
Tasks.run(
|
||||
() -> {
|
||||
Phoenix phoenix = this.plugin;
|
||||
String text3 =
|
||||
LocaleUtil.tr(player, MessageConfig.PUNISHMENT.PROOF_PROMPT)
|
||||
.replace("<type>", punishmentType.getNiceName())
|
||||
.replace(
|
||||
"<player>",
|
||||
profile.getNameWithColorNoDisguise());
|
||||
ConversationUtil.ask(
|
||||
phoenix,
|
||||
player,
|
||||
text3,
|
||||
result -> {
|
||||
if (result != null && !result.trim().isEmpty()) {
|
||||
banWaveEntry2
|
||||
.getProof()
|
||||
.add(
|
||||
this.plugin
|
||||
.getPunishmentHandler()
|
||||
.createProof(
|
||||
ProofType.LINK,
|
||||
result.trim(),
|
||||
player
|
||||
.getUniqueId()));
|
||||
Tasks.runAsync(
|
||||
this.plugin,
|
||||
() ->
|
||||
this.sendMessage(
|
||||
player,
|
||||
banWave2,
|
||||
banWaveEntry2,
|
||||
profile));
|
||||
} else {
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(
|
||||
player,
|
||||
MessageConfig.PUNISHMENT
|
||||
.PROOF_CANCELLED)));
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.sendMessage(sender, banWave, banWaveEntry, profile);
|
||||
}
|
||||
} else {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.NO_ADDRESS)
|
||||
.replace("<player>", profile.getNameWithColorNoDisguise()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sendMessage(
|
||||
CommandSender sender, IBanWave banWave, IBanWaveEntry banWaveEntry, IProfile profile) {
|
||||
banWave.getEntries().add(banWaveEntry);
|
||||
this.plugin.getBanWaveHandler().save(banWave);
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.STAGED)
|
||||
.replace("<player>", profile.getNameWithColorNoDisguise())
|
||||
.replace("<wave>", banWave.getName())
|
||||
.replace("<amount>", String.valueOf(banWave.getEntries().size()))));
|
||||
}
|
||||
|
||||
private boolean matchesEnabled(CommandSender sender, PunishmentType punishmentType) {
|
||||
if (!SettingsConfig.SERVER.PUNISHMENTS.REQUIRE_PROOF.ENABLED) {
|
||||
return false;
|
||||
}
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
for (String text : SettingsConfig.SERVER.PUNISHMENTS.REQUIRE_PROOF.TYPES) {
|
||||
if (punishmentType.name().equalsIgnoreCase(text.trim())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Command(name = "remove", description = "Take an account back out of a wave", async = true)
|
||||
@Requires("core.command.banwave.remove")
|
||||
public void remove(
|
||||
@Sender CommandSender sender,
|
||||
@Named("wave") String text,
|
||||
@Option({"disguise", "multiple"}) IProfile profile) {
|
||||
this.applyCommandSender(sender);
|
||||
IBanWave banWave;
|
||||
List<IBanWaveEntry> entries = (banWave = this.findBanWave(sender, text)).getEntries();
|
||||
if (!entries.removeIf(result -> result.getTarget().equals(profile.getUniqueId()))) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.NOT_STAGED)
|
||||
.replace("<player>", profile.getNameWithColorNoDisguise()));
|
||||
}
|
||||
this.plugin.getBanWaveHandler().save(banWave);
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.UNSTAGED)
|
||||
.replace("<player>", profile.getNameWithColorNoDisguise())
|
||||
.replace("<wave>", banWave.getName())));
|
||||
}
|
||||
|
||||
@Command(name = "list", description = "The waves still waiting", async = true)
|
||||
@Requires("core.command.banwave.list")
|
||||
public void list(@Sender CommandSender sender) {
|
||||
this.applyCommandSender(sender);
|
||||
if (this.plugin.getBanWaveHandler().pending().isEmpty()) {
|
||||
throw new ExitMessage(LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.NONE));
|
||||
}
|
||||
for (String text : LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.LIST_HEADER)) {
|
||||
sender.sendMessage(Color.translate(text));
|
||||
}
|
||||
for (IBanWave banWave : this.plugin.getBanWaveHandler().pending()) {
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.LIST_ENTRY)
|
||||
.replace("<wave>", banWave.getName())
|
||||
.replace(
|
||||
"<amount>", String.valueOf(banWave.getEntries().size()))
|
||||
.replace("<when>", this.formatString(sender, banWave))));
|
||||
}
|
||||
}
|
||||
|
||||
@Command(name = "view", description = "What is staged in a wave", async = true)
|
||||
@Requires("core.command.banwave.view")
|
||||
public void view(@Sender CommandSender sender, @Named("wave") String text) {
|
||||
this.applyCommandSender(sender);
|
||||
IBanWave banWave = this.findBanWave(sender, text);
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.VIEW_HEADER)
|
||||
.replace("<wave>", banWave.getName())
|
||||
.replace("<amount>", String.valueOf(banWave.getEntries().size()))
|
||||
.replace("<when>", this.formatString(sender, banWave))));
|
||||
for (IBanWaveEntry banWaveEntry : banWave.getEntries()) {
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.VIEW_ENTRY)
|
||||
.replace("<player>", banWaveEntry.getTargetName())
|
||||
.replace(
|
||||
"<type>",
|
||||
(banWaveEntry.isIp()
|
||||
? LocaleUtil.tr(
|
||||
sender,
|
||||
MessageConfig.BAN_WAVE
|
||||
.IP_PREFIX)
|
||||
: "")
|
||||
+ banWaveEntry.getType().getNiceName())
|
||||
.replace(
|
||||
"<time>",
|
||||
banWaveEntry.isPermanent()
|
||||
? LocaleUtil.tr(
|
||||
sender,
|
||||
MessageConfig.BAN_WAVE.PERMANENT)
|
||||
: DateUtils.formatTimeMillis(
|
||||
banWaveEntry.getDuration()))
|
||||
.replace("<reason>", banWaveEntry.getReason())));
|
||||
}
|
||||
}
|
||||
|
||||
@Command(name = "schedule", description = "Set the day and time a wave goes out", async = true)
|
||||
@Requires("core.command.banwave.schedule")
|
||||
public void schedule(
|
||||
@Sender CommandSender sender,
|
||||
@Named("wave") String text,
|
||||
@Named("when (yyyy-MM-dd HH:mm, or a duration)") @Text String text2) {
|
||||
this.applyCommandSender(sender);
|
||||
IBanWave banWave = this.findBanWave(sender, text);
|
||||
long value;
|
||||
if ((value = this.calculateTime(text2)) <= 0L) {
|
||||
throw new ExitMessage(LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.BAD_TIME));
|
||||
}
|
||||
if (value <= System.currentTimeMillis()) {
|
||||
throw new ExitMessage(LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.TIME_PASSED));
|
||||
}
|
||||
banWave.setReleaseAt(value);
|
||||
this.plugin.getBanWaveHandler().save(banWave);
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.SCHEDULED)
|
||||
.replace("<wave>", banWave.getName())
|
||||
.replace("<when>", DateUtils.getDate(value))
|
||||
.replace(
|
||||
"<remaining>",
|
||||
DateUtils.formatTimeMillis(
|
||||
value - System.currentTimeMillis()))));
|
||||
}
|
||||
|
||||
@Command(name = "unschedule", description = "Stop a wave going out on its own", async = true)
|
||||
@Requires("core.command.banwave.unschedule")
|
||||
public void unschedule(@Sender CommandSender sender, @Named("wave") String text) {
|
||||
this.applyCommandSender(sender);
|
||||
IBanWave banWave;
|
||||
(banWave = this.findBanWave(sender, text)).setReleaseAt(0L);
|
||||
this.plugin.getBanWaveHandler().save(banWave);
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.UNSCHEDULED)
|
||||
.replace("<wave>", banWave.getName())));
|
||||
}
|
||||
|
||||
@Command(name = "release", description = "Send a wave out now")
|
||||
@Requires("core.command.banwave.release")
|
||||
public void release(@Sender Player player, @Named("wave") String text) {
|
||||
this.applyCommandSender(player);
|
||||
IBanWave banWave;
|
||||
if ((banWave = this.findBanWave(player, text)).getEntries().isEmpty()) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(player, MessageConfig.BAN_WAVE.EMPTY)
|
||||
.replace("<wave>", banWave.getName()));
|
||||
}
|
||||
Phoenix phoenix = this.plugin;
|
||||
String text2 =
|
||||
LocaleUtil.tr(player, MessageConfig.BAN_WAVE.CONFIRM)
|
||||
.replace("<wave>", banWave.getName())
|
||||
.replace("<amount>", String.valueOf(banWave.getEntries().size()));
|
||||
IBanWave banWave2 = banWave;
|
||||
ConfirmationMenus.applyPhoenix(
|
||||
phoenix,
|
||||
player,
|
||||
text2,
|
||||
true,
|
||||
result -> {
|
||||
if (result) {
|
||||
this.plugin.getBanWaveHandler().release(banWave2, player);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "void",
|
||||
description = "Take back a wave that has already gone out",
|
||||
async = true)
|
||||
@Requires("core.command.banwave.void")
|
||||
public void voidWave(
|
||||
@Sender Player player,
|
||||
@Named("wave") String text,
|
||||
@Named("void reason") VoidReason voidReason) {
|
||||
this.applyCommandSender(player);
|
||||
IBanWave banWave;
|
||||
if (!(banWave = this.findBanWave(player, text)).isReleased()) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(player, MessageConfig.BAN_WAVE.NOT_RELEASED)
|
||||
.replace("<wave>", banWave.getName()));
|
||||
}
|
||||
if (banWave.getIssued().isEmpty()) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(player, MessageConfig.BAN_WAVE.NOTHING_TO_VOID)
|
||||
.replace("<wave>", banWave.getName()));
|
||||
}
|
||||
Phoenix phoenix = this.plugin;
|
||||
String text2 =
|
||||
LocaleUtil.tr(player, MessageConfig.BAN_WAVE.CONFIRM_VOID)
|
||||
.replace("<wave>", banWave.getName())
|
||||
.replace("<amount>", String.valueOf(banWave.getIssued().size()));
|
||||
IBanWave banWave2 = banWave;
|
||||
ConfirmationMenus.applyPhoenix(
|
||||
phoenix,
|
||||
player,
|
||||
text2,
|
||||
true,
|
||||
result -> {
|
||||
if (result) {
|
||||
Tasks.runAsync(
|
||||
this.plugin,
|
||||
() -> {
|
||||
int value =
|
||||
this.plugin
|
||||
.getBanWaveHandler()
|
||||
.voidWave(banWave2, player, voidReason);
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(
|
||||
player,
|
||||
MessageConfig.BAN_WAVE.VOIDED)
|
||||
.replace("<wave>", banWave2.getName())
|
||||
.replace(
|
||||
"<amount>",
|
||||
String.valueOf(value))
|
||||
.replace(
|
||||
"<void_reason>",
|
||||
voidReason.getNiceName())));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Command(name = "cancel", description = "Throw a wave away without releasing it", async = true)
|
||||
@Requires("core.command.banwave.cancel")
|
||||
public void cancel(@Sender CommandSender sender, @Named("wave") String text) {
|
||||
this.applyCommandSender(sender);
|
||||
IBanWave banWave = this.findBanWave(sender, text);
|
||||
this.plugin.getBanWaveHandler().delete(banWave);
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.CANCELLED)
|
||||
.replace("<wave>", banWave.getName())));
|
||||
}
|
||||
|
||||
private long calculateTime(String text) {
|
||||
String text2 = text.trim();
|
||||
try {
|
||||
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
||||
return LocalDateTime.parse(text2, dateTimeFormatter)
|
||||
.atZone(ZoneId.systemDefault())
|
||||
.toInstant()
|
||||
.toEpochMilli();
|
||||
} catch (DateTimeParseException dateTimeParseException) {
|
||||
Duration duration;
|
||||
return (duration = Duration.of(text2)) != null && !duration.isEnabled()
|
||||
? System.currentTimeMillis() + duration.getTimeTime()
|
||||
: 0L;
|
||||
}
|
||||
}
|
||||
|
||||
private String formatString(CommandSender sender, IBanWave banWave) {
|
||||
return banWave.getReleaseAt() <= 0L
|
||||
? LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.MANUAL)
|
||||
: DateUtils.getDate(banWave.getReleaseAt());
|
||||
}
|
||||
|
||||
private IBanWave findBanWave(CommandSender sender, String text) {
|
||||
IBanWave banWave;
|
||||
if ((banWave = this.plugin.getBanWaveHandler().byName(text)) != null
|
||||
&& !banWave.isReleased()) {
|
||||
return banWave;
|
||||
} else {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.DOESNT_EXIST)
|
||||
.replace("<wave>", text));
|
||||
}
|
||||
}
|
||||
|
||||
private void applyCommandSender(CommandSender sender) {
|
||||
if (!SettingsConfig.BAN_WAVES.ENABLED) {
|
||||
throw new ExitMessage(LocaleUtil.tr(sender, MessageConfig.BAN_WAVE.DISABLED));
|
||||
}
|
||||
}
|
||||
|
||||
public BanwaveCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Text;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
|
||||
@Register(name = "broadcast", aliases = "bc")
|
||||
@Requires("core.command.broadcast")
|
||||
public class BroadcastCommand {
|
||||
|
||||
private static final String text = "<message>";
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(@Sender CommandSender sender, @Named("message") @Text String text2) {
|
||||
Bukkit.broadcastMessage(
|
||||
Color.translate(
|
||||
MessageConfig.BASIC.ADMIN.BROADCAST.replace(text, Color.translate(text2))));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Optional;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.lib.commands.exception.execution.ExitMessage;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
@Register(name = "build", aliases = "buildmode")
|
||||
@Requires("core.command.build")
|
||||
public class BuildCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(
|
||||
@Sender Player player,
|
||||
@Optional @Requires("core.command.build.others") Player player2) {
|
||||
if (!SettingsConfig.BASICS.BUILDMODE) {
|
||||
throw new ExitMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(
|
||||
player, MessageConfig.BASIC.ADMIN.BUILD.DISABLED_IN_CONFIG)));
|
||||
}
|
||||
if (player2 == null) {
|
||||
if (player.hasMetadata("BuildMode")) {
|
||||
player.removeMetadata("BuildMode", this.plugin);
|
||||
} else {
|
||||
player.setMetadata("BuildMode", new FixedMetadataValue(this.plugin, true));
|
||||
}
|
||||
player.sendMessage(
|
||||
player.hasMetadata("BuildMode")
|
||||
? Color.translate(MessageConfig.BASIC.ADMIN.BUILD.ENABLED)
|
||||
: Color.translate(MessageConfig.BASIC.ADMIN.BUILD.DISABLED));
|
||||
} else {
|
||||
IProfile profile = this.plugin.getProfileHandler().getProfile(player2.getUniqueId());
|
||||
if (player2.hasMetadata("BuildMode")) {
|
||||
player2.removeMetadata("BuildMode", this.plugin);
|
||||
} else {
|
||||
player2.setMetadata("BuildMode", new FixedMetadataValue(this.plugin, true));
|
||||
}
|
||||
player2.sendMessage(
|
||||
player2.hasMetadata("BuildMode")
|
||||
? Color.translate(MessageConfig.BASIC.ADMIN.BUILD.ENABLED)
|
||||
: Color.translate(MessageConfig.BASIC.ADMIN.BUILD.DISABLED));
|
||||
player.sendMessage(
|
||||
player2.hasMetadata("BuildMode")
|
||||
? Color.translate(
|
||||
MessageConfig.BASIC.ADMIN.BUILD.ENABLED_OTHER.replace(
|
||||
"<player>", profile.getNameWithColorNoDisguise()))
|
||||
: Color.translate(
|
||||
MessageConfig.BASIC.ADMIN.BUILD.DISABLED_OTHER.replace(
|
||||
"<player>", profile.getNameWithColorNoDisguise())));
|
||||
}
|
||||
}
|
||||
|
||||
public BuildCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Help;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Default;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Option;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Optional;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.CommonPlatform;
|
||||
import xyz.refinedev.phoenix.commands.api.annotations.DurationInput;
|
||||
import xyz.refinedev.phoenix.commands.provider.DurationProvider;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.chatsnapshot.IChatLog;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.PaginatedListClickable;
|
||||
import xyz.refinedev.phoenix.utils.chat.Clickable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Help
|
||||
@Register(name = "chatlogs")
|
||||
@Requires("core.command.chatlogs")
|
||||
public class ChatlogsCommand {
|
||||
|
||||
private final CommonPlatform platform;
|
||||
|
||||
@Command(name = "search", async = true)
|
||||
public void search(
|
||||
@Sender CommandSender sender,
|
||||
@Option({"disguise", "multiple"}) IProfile profile,
|
||||
@Named("message") String text,
|
||||
@Default("1") @Named("page") int value) {
|
||||
List<IChatLog> values =
|
||||
this.platform.getChatLogHandler().getByPlayer(profile.getUuid(), text).join();
|
||||
ArrayList<Clickable> values2 = new ArrayList<>();
|
||||
String nameWithColorNoDisguise = profile.getNameWithColorNoDisguise();
|
||||
String prefix = profile.getGeneralRank().getPrefix();
|
||||
for (IChatLog chatLog : values) {
|
||||
Clickable clickable =
|
||||
new Clickable(
|
||||
LocaleUtil.tr(sender, MessageConfig.CHAT_LOGS.FORMAT)
|
||||
.replace("<id>", chatLog.getId())
|
||||
.replace("<prefix>", prefix)
|
||||
.replace("<sender>", nameWithColorNoDisguise)
|
||||
.replace("<message>", chatLog.getMessage())
|
||||
.replace("<date>", chatLog.getNiceCreatedOn()));
|
||||
values2.add(clickable);
|
||||
}
|
||||
new PaginatedListClickable(
|
||||
"Chat Logs",
|
||||
profile.getNameWithColorNoDisguise(),
|
||||
"/chatlogs search " + profile.getName() + " " + text)
|
||||
.display(sender, value, values2);
|
||||
}
|
||||
|
||||
@Command(name = "view", async = true)
|
||||
public void view(
|
||||
@Sender CommandSender sender,
|
||||
@Option({"disguise", "multiple"}) IProfile profile,
|
||||
@Optional @Named("time") @DurationInput String text,
|
||||
@Default("1") @Named("page") int value) {
|
||||
long value2 = text != null ? DurationProvider.tr(sender, text, true).getTimeTime() : -5L;
|
||||
List<IChatLog> values =
|
||||
text != null
|
||||
? this.platform
|
||||
.getChatLogHandler()
|
||||
.getByPlayer(
|
||||
profile.getUuid(),
|
||||
value2 == -5L ? -5L : System.currentTimeMillis() - value2)
|
||||
.join()
|
||||
: this.platform.getChatLogHandler().getByPlayer(profile.getUuid()).join();
|
||||
ArrayList<Clickable> values2 = new ArrayList<>();
|
||||
String nameWithColorNoDisguise = profile.getNameWithColorNoDisguise();
|
||||
String prefix = profile.getGeneralRank().getPrefix();
|
||||
for (IChatLog chatLog : values) {
|
||||
Clickable clickable =
|
||||
new Clickable(
|
||||
LocaleUtil.tr(sender, MessageConfig.CHAT_LOGS.FORMAT)
|
||||
.replace("<id>", chatLog.getId())
|
||||
.replace("<prefix>", prefix)
|
||||
.replace("<sender>", nameWithColorNoDisguise)
|
||||
.replace("<message>", chatLog.getMessage())
|
||||
.replace("<date>", chatLog.getNiceCreatedOn()));
|
||||
values2.add(clickable);
|
||||
}
|
||||
new PaginatedListClickable(
|
||||
"Chat Logs",
|
||||
profile.getNameWithColorNoDisguise(),
|
||||
"/chatlogs view "
|
||||
+ profile.getName()
|
||||
+ (text != null ? " " + text : " perm"))
|
||||
.display(sender, value, values2);
|
||||
}
|
||||
|
||||
@Command(name = "clear")
|
||||
@Requires("core.command.chatlogs.clear")
|
||||
public void clear(
|
||||
@Sender CommandSender sender, @Option({"disguise", "multiple"}) IProfile profile) {
|
||||
this.platform.getChatLogHandler().clearLogs(profile.getUuid());
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.CHAT_LOGS.CLEAR)
|
||||
.replace("<target>", profile.getNameWithColorNoDisguise())));
|
||||
}
|
||||
|
||||
public ChatlogsCommand(CommonPlatform commonPlatform) {
|
||||
this.platform = commonPlatform;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Help;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Default;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Named;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Option;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Optional;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.lib.commands.exception.execution.ExitMessage;
|
||||
import xyz.refinedev.phoenix.BukkitAPI;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.config.SettingsConfig;
|
||||
import xyz.refinedev.phoenix.menu.impl.ChatsnapshotMenu;
|
||||
import xyz.refinedev.phoenix.profile.IProfile;
|
||||
import xyz.refinedev.phoenix.profile.chatsnapshot.IChatEntry;
|
||||
import xyz.refinedev.phoenix.profile.chatsnapshot.IChatSnapshot;
|
||||
import xyz.refinedev.phoenix.profile.cooldown.Cooldown;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.DateUtils;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
import xyz.refinedev.phoenix.utils.MetricsReporter;
|
||||
import xyz.refinedev.phoenix.utils.PaginatedListClickable;
|
||||
import xyz.refinedev.phoenix.utils.chat.Clickable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Help
|
||||
@Register(name = "chatsnapshot", aliases = "chatsnapshots")
|
||||
@Requires("core.command.chatsnapshot")
|
||||
public class ChatsnapshotCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "create")
|
||||
@Requires("core.command.chatsnapshot.create")
|
||||
public void create(@Sender CommandSender sender, @Optional Player player) {
|
||||
MetricsReporter.applyString("chatsnapshots");
|
||||
if (sender instanceof Player) {
|
||||
Player player2 = (Player) sender;
|
||||
IProfile cachedProfile =
|
||||
this.plugin.getProfileHandler().getCachedProfile(player2.getUniqueId());
|
||||
if (!player2.hasPermission("core.cooldowns.bypass")
|
||||
&& cachedProfile.hasGlobalCooldown("chatSnapshot")) {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(sender, MessageConfig.COOLDOWNS.SNAPSHOT_COOLDOWN)
|
||||
.replace(
|
||||
"<remaining>",
|
||||
DateUtils.formatTimeMillis(
|
||||
cachedProfile.getGlobalRemaining("chatSnapshot"))));
|
||||
}
|
||||
cachedProfile
|
||||
.getGlobalCooldowns()
|
||||
.add(
|
||||
new Cooldown(
|
||||
BukkitAPI.parseDuration(SettingsConfig.COOLDOWNS.CHAT_SNAPSHOT),
|
||||
"chatSnapshot"));
|
||||
cachedProfile.saveProfile();
|
||||
}
|
||||
UUID uUID =
|
||||
sender instanceof Player
|
||||
? ((Player) sender).getUniqueId()
|
||||
: IProfile.getConsoleUuid();
|
||||
IChatSnapshot chatSnapshot;
|
||||
if (player != null) {
|
||||
chatSnapshot =
|
||||
this.plugin.getChatSnapshotHandler().createSnapshot(uUID, player.getUniqueId());
|
||||
} else {
|
||||
chatSnapshot = this.plugin.getChatSnapshotHandler().createSnapshot(uUID);
|
||||
}
|
||||
if (chatSnapshot != null) {
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.CHAT_SNAPSHOT.CREATED)
|
||||
.replace("<id>", chatSnapshot.getNiceId())));
|
||||
} else {
|
||||
throw new ExitMessage(
|
||||
LocaleUtil.tr(sender, MessageConfig.CHAT_SNAPSHOT.NO_CHAT_MESSAGES));
|
||||
}
|
||||
}
|
||||
|
||||
@Command(name = "delete")
|
||||
@Requires("core.command.chatsnapshot.delete")
|
||||
public void delete(@Sender CommandSender sender, IChatSnapshot chatSnapshot) {
|
||||
this.plugin.getChatSnapshotHandler().deleteSnapshot(chatSnapshot);
|
||||
sender.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(sender, MessageConfig.CHAT_SNAPSHOT.DELETED)
|
||||
.replace("<id>", chatSnapshot.getNiceId())));
|
||||
}
|
||||
|
||||
@Command(name = "own")
|
||||
@Requires("core.command.chatsnapshot.own")
|
||||
public void own(@Sender Player player) {
|
||||
CompletableFuture<List<IChatSnapshot>> byPlayer =
|
||||
this.plugin.getChatSnapshotHandler().getByPlayer(player.getUniqueId());
|
||||
byPlayer.whenCompleteAsync(
|
||||
(result, result2) ->
|
||||
this.plugin
|
||||
.getMenuHandler()
|
||||
.openMenuAsync(
|
||||
new ChatsnapshotMenu((List<IChatSnapshot>) result, true),
|
||||
player));
|
||||
}
|
||||
|
||||
@Command(name = "player")
|
||||
@Requires("core.command.chatsnapshot.player")
|
||||
public void player(
|
||||
@Sender Player player2,
|
||||
@Named("player") @Option({"disguise", "multiple"}) IProfile profile) {
|
||||
CompletableFuture<List<IChatSnapshot>> byPlayer =
|
||||
this.plugin.getChatSnapshotHandler().getByPlayer(profile.getUniqueId());
|
||||
byPlayer.whenCompleteAsync(
|
||||
(result, result2) ->
|
||||
this.plugin
|
||||
.getMenuHandler()
|
||||
.openMenuAsync(
|
||||
new ChatsnapshotMenu((List<IChatSnapshot>) result, false),
|
||||
player2));
|
||||
}
|
||||
|
||||
@Command(name = "view", async = true)
|
||||
@Requires("core.command.chatsnapshot.view")
|
||||
public void view(
|
||||
@Sender Player player,
|
||||
IChatSnapshot chatSnapshot,
|
||||
@Default("1") @Named("page") int value) {
|
||||
PaginatedListClickable paginatedListClickable =
|
||||
new PaginatedListClickable(
|
||||
"Entries",
|
||||
DateUtils.getDate(chatSnapshot.getCreatedOn()),
|
||||
"/chatsnapshot view " + chatSnapshot.getNiceId());
|
||||
ArrayList<Clickable> values = new ArrayList<>();
|
||||
for (IChatEntry chatEntry : chatSnapshot.getChat()) {
|
||||
values.add(
|
||||
new Clickable("&7[" + chatEntry.getNiceTime() + "] " + chatEntry.getMessage()));
|
||||
}
|
||||
paginatedListClickable.display(player, value, values);
|
||||
}
|
||||
|
||||
public ChatsnapshotCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package xyz.refinedev.phoenix.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import xyz.refinedev.lib.commands.annotation.command.Command;
|
||||
import xyz.refinedev.lib.commands.annotation.command.Requires;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.Optional;
|
||||
import xyz.refinedev.lib.commands.annotation.parameter.classifier.Sender;
|
||||
import xyz.refinedev.lib.commands.annotation.registration.Register;
|
||||
import xyz.refinedev.phoenix.Phoenix;
|
||||
import xyz.refinedev.phoenix.config.MessageConfig;
|
||||
import xyz.refinedev.phoenix.utils.Color;
|
||||
import xyz.refinedev.phoenix.utils.LocaleUtil;
|
||||
|
||||
@Register(
|
||||
name = "clear",
|
||||
aliases = {"clearinv", "ci"})
|
||||
@Requires("core.command.clear")
|
||||
public class ClearCommand {
|
||||
|
||||
private final Phoenix plugin;
|
||||
|
||||
@Command(name = "")
|
||||
public void execute(
|
||||
@Sender Player player,
|
||||
@Optional @Requires("core.command.clear.others") Player player2) {
|
||||
if (player2 != null) {
|
||||
int value = this.calculateCount(player2);
|
||||
player2.getInventory().clear();
|
||||
player2.getInventory().setArmorContents(null);
|
||||
player2.updateInventory();
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.BASIC.ADMIN.CLEAR.OTHER)
|
||||
.replace(
|
||||
"<player>",
|
||||
this.plugin
|
||||
.getProfileHandler()
|
||||
.getProfile(player2.getUniqueId())
|
||||
.getNameWithColor())
|
||||
.replace("<total>", String.valueOf(value))));
|
||||
player2.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player2, MessageConfig.BASIC.ADMIN.CLEAR.R_OTHER)
|
||||
.replace(
|
||||
"<player>",
|
||||
this.plugin
|
||||
.getProfileHandler()
|
||||
.getProfile(player.getUniqueId())
|
||||
.getNameWithColor())
|
||||
.replace("<total>", String.valueOf(value))));
|
||||
} else {
|
||||
int value2 = this.calculateCount(player);
|
||||
player.getInventory().clear();
|
||||
player.getInventory().setArmorContents(null);
|
||||
player.updateInventory();
|
||||
player.sendMessage(
|
||||
Color.translate(
|
||||
LocaleUtil.tr(player, MessageConfig.BASIC.ADMIN.CLEAR.SELF)
|
||||
.replace("<total>", String.valueOf(value2))));
|
||||
}
|
||||
}
|
||||
|
||||
private int calculateCount(Player player) {
|
||||
int value = 0;
|
||||
ItemStack[] itemStacks;
|
||||
int value2 = (itemStacks = player.getInventory().getContents()).length;
|
||||
for (int index = 0; index < value2; index++) {
|
||||
ItemStack itemStack;
|
||||
if ((itemStack = itemStacks[index]) != null) {
|
||||
value += itemStack.getAmount();
|
||||
}
|
||||
}
|
||||
value2 = (itemStacks = player.getInventory().getArmorContents()).length;
|
||||
for (int index2 = 0; index2 < value2; index2++) {
|
||||
ItemStack itemStack2;
|
||||
if ((itemStack2 = itemStacks[index2]) != null) {
|
||||
value += itemStack2.getAmount();
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public ClearCommand(Phoenix phoenix) {
|
||||
this.plugin = phoenix;
|
||||
}
|
||||
}
|
||||
Loaded 100 of 1166 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user