Skip to content

Commit df8818e

Browse files
First Push
0 parents  commit df8818e

File tree

18 files changed

+888
-0
lines changed

18 files changed

+888
-0
lines changed

UUIDMethods/.classpath

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
5+
<classpathentry kind="lib" path="C:/spigot.jar"/>
6+
<classpathentry kind="output" path="bin"/>
7+
</classpath>

UUIDMethods/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/bin/

UUIDMethods/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>UUIDMethods</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.8
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=1.8

UUIDMethods/plugin.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: UUIDMethods
2+
version: 1.6
3+
author: YellowPhoenix18
4+
5+
main: de.yellowphoenix18.uuidmethods.main.UUIDMethods
6+
7+
commands:
8+
uuidmethods:
9+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package de.yellowphoenix18.uuidmethods;
2+
3+
import org.bukkit.plugin.java.JavaPlugin;
4+
5+
import de.yellowphoenix18.uuidmethods.database.MYSQL;
6+
import de.yellowphoenix18.uuidmethods.utils.Utils;
7+
8+
public class UUIDMethods extends JavaPlugin {
9+
10+
public static UUIDMethods m;
11+
12+
public static String ip = "localhost";
13+
public static int port = 3306;
14+
public static String username = "username";
15+
public static String password = "password";
16+
public static String database = "SkyWars";
17+
public static boolean enabled = false;
18+
19+
public void onEnable() {
20+
m = this;
21+
Utils.setUp();
22+
}
23+
24+
public void onDisable() {
25+
if(enabled == true) {
26+
MYSQL.disconnect();
27+
}
28+
}
29+
30+
31+
32+
33+
34+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package de.yellowphoenix18.uuidmethods.cache;
2+
3+
import java.util.HashMap;
4+
5+
public class Cache {
6+
7+
public static HashMap<String, CachePacket> uuid_list = new HashMap<String, CachePacket>();
8+
public static HashMap<String, CachePacket> username_list = new HashMap<String, CachePacket>();
9+
10+
public static void saveData(String uuid, String username) {
11+
CachePacket cp = new CachePacket(uuid, username);
12+
uuid_list.put(uuid, cp);
13+
username_list.put(username, cp);
14+
}
15+
16+
public static String getUsername(String uuid) {
17+
if(uuid_list.containsKey(uuid)) {
18+
CachePacket cp = uuid_list.get(uuid);
19+
if(cp.isPacketAlive()) {
20+
return cp.getName();
21+
} else {
22+
uuid_list.remove(uuid);
23+
}
24+
}
25+
return null;
26+
}
27+
28+
public static String getUUID(String username) {
29+
if(username_list.containsKey(username)) {
30+
CachePacket cp = username_list.get(username);
31+
if(cp.isPacketAlive()) {
32+
return cp.getName();
33+
} else {
34+
username_list.remove(username);
35+
}
36+
}
37+
return null;
38+
}
39+
40+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package de.yellowphoenix18.uuidmethods.cache;
2+
3+
public class CachePacket {
4+
5+
long time = 0;
6+
String uuid = "";
7+
String name = "";
8+
9+
public CachePacket(String uuid, String name) {
10+
long millis = System.currentTimeMillis();
11+
this.uuid = uuid;
12+
this.name = name;
13+
this.time = millis/1000;
14+
}
15+
16+
public boolean isPacketAlive() {
17+
long millis = System.currentTimeMillis();
18+
long nw_time = millis/1000;
19+
if(nw_time-time > 60*5) {
20+
return true;
21+
}
22+
return false;
23+
}
24+
25+
public String getName() {
26+
return this.name;
27+
}
28+
29+
public String getUUID() {
30+
return this.uuid;
31+
}
32+
33+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package de.yellowphoenix18.uuidmethods.commands;
2+
3+
import org.bukkit.Bukkit;
4+
import org.bukkit.command.Command;
5+
import org.bukkit.command.CommandExecutor;
6+
import org.bukkit.command.CommandSender;
7+
import org.bukkit.entity.Player;
8+
9+
import de.yellowphoenix18.uuidmethods.UUIDMethods;
10+
import de.yellowphoenix18.uuidmethods.methods.UUIDAPI;
11+
12+
public class UUIDMethodsCommand implements CommandExecutor {
13+
14+
@Override
15+
public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, String[] args) {
16+
17+
if(sender instanceof Player) {
18+
Player p = (Player) sender;
19+
if(p.hasPermission("uuidmethods.admin")) {
20+
if(args.length == 0) {
21+
22+
} else if(args.length == 2) {
23+
if(args[0].equalsIgnoreCase("getUUID")) {
24+
String username = args[1];
25+
Bukkit.getScheduler().runTaskAsynchronously(UUIDMethods.m, new Runnable() {
26+
@Override
27+
public void run() {
28+
if(UUIDAPI.getUUID(username) != null) {
29+
p.sendMessage(UUIDAPI.getUUID(username));
30+
}
31+
}
32+
});
33+
} else if(args[0].equalsIgnoreCase("getUsername")) {
34+
String uuid = args[1];
35+
Bukkit.getScheduler().runTaskAsynchronously(UUIDMethods.m, new Runnable() {
36+
@Override
37+
public void run() {
38+
if(UUIDAPI.getUUID(uuid) != null) {
39+
p.sendMessage(UUIDAPI.getUsername(uuid));
40+
}
41+
}
42+
});
43+
}
44+
}
45+
}
46+
}
47+
48+
49+
return true;
50+
}
51+
52+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package de.yellowphoenix18.uuidmethods.config;
2+
3+
import java.io.File;
4+
import java.io.IOException;
5+
6+
import org.bukkit.configuration.file.FileConfiguration;
7+
import org.bukkit.configuration.file.YamlConfiguration;
8+
9+
import de.yellowphoenix18.uuidmethods.UUIDMethods;
10+
11+
public class MainConfig {
12+
13+
public static File f = new File("plugins/UUIDDatabse", "config.yml");
14+
public static FileConfiguration cfg = YamlConfiguration.loadConfiguration(f);
15+
16+
public static boolean debug = false;
17+
18+
public static void loadConfig() {
19+
if(cfg.getString("MYSQL.IP") == null) {
20+
cfg.set("MYSQL.IP", "localhost");
21+
}
22+
if(cfg.getInt("MYSQL.Port") == 0) {
23+
cfg.set("MYSQL.Port", 3306);
24+
}
25+
if(cfg.getString("MYSQL.Username") == null) {
26+
cfg.set("MYSQL.Username", "Username");
27+
}
28+
if(cfg.getString("MYSQL.Password") == null) {
29+
cfg.set("MYSQL.Password", "Password");
30+
}
31+
if(cfg.getString("MYSQL.Database") == null) {
32+
cfg.set("MYSQL.Database", "Database");
33+
}
34+
if(cfg.getBoolean("MYSQL.Enabled") == false) {
35+
cfg.set("MYSQL.Enabled", false);
36+
}
37+
if(cfg.getBoolean("Settings.Debug") == false) {
38+
cfg.set("Settings.Debug", false);
39+
}
40+
41+
try {
42+
cfg.save(f);
43+
} catch (IOException e) {
44+
e.printStackTrace();
45+
}
46+
47+
UUIDMethods.username = cfg.getString("MYSQL.Username");
48+
UUIDMethods.ip = cfg.getString("MYSQL.IP");
49+
UUIDMethods.password = cfg.getString("MYSQL.Password");
50+
UUIDMethods.database = cfg.getString("MYSQL.Database");
51+
UUIDMethods.port = cfg.getInt("MYSQL.Port");
52+
UUIDMethods.enabled = cfg.getBoolean("MYSQL.Enabled");
53+
debug = cfg.getBoolean("Settings.Debug");
54+
}
55+
56+
}

0 commit comments

Comments
 (0)