Skip to content

Commit e95d007

Browse files
v 1.7
1 parent f29f450 commit e95d007

File tree

5 files changed

+55
-2
lines changed

5 files changed

+55
-2
lines changed

UUIDMethods/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: UUIDMethods
2-
version: 1.6.1
2+
version: 1.7
33
author: YellowPhoenix18
44

55
main: de.yellowphoenix18.uuidmethods.UUIDMethods

UUIDMethods/src/de/yellowphoenix18/uuidmethods/UUIDMethods.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class UUIDMethods extends JavaPlugin {
1515
public static String password = "password";
1616
public static String database = "database";
1717
public static boolean enabled = false;
18+
public static boolean storelocal = true;
1819

1920
public void onEnable() {
2021
m = this;

UUIDMethods/src/de/yellowphoenix18/uuidmethods/config/MainConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public static void loadConfig() {
3636
}
3737
if(cfg.getBoolean("Settings.Debug") == false) {
3838
cfg.set("Settings.Debug", false);
39+
}
40+
if(!cfg.contains("Config.StoreLocal")) {
41+
cfg.set("Config.StoreLocal", true);
3942
}
4043

4144
try {
@@ -50,6 +53,7 @@ public static void loadConfig() {
5053
UUIDMethods.database = cfg.getString("MYSQL.Database");
5154
UUIDMethods.port = cfg.getInt("MYSQL.Port");
5255
UUIDMethods.enabled = cfg.getBoolean("MYSQL.Enabled");
56+
UUIDMethods.storelocal = cfg.getBoolean("Config.StoreLocal");
5357
debug = cfg.getBoolean("Settings.Debug");
5458
}
5559

UUIDMethods/src/de/yellowphoenix18/uuidmethods/listener/UUIDListener.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import de.yellowphoenix18.uuidmethods.UUIDMethods;
1313
import de.yellowphoenix18.uuidmethods.database.UUIDDatabase;
1414
import de.yellowphoenix18.uuidmethods.fetcher.OldUsernameFetcher;
15+
import de.yellowphoenix18.uuidmethods.localstorage.LocalStorage;
1516

1617
public class UUIDListener implements Listener {
1718

@@ -36,7 +37,10 @@ public void run() {
3637
}
3738
}
3839
});
39-
}
40+
}
41+
if(UUIDMethods.storelocal == true) {
42+
LocalStorage.set(Username, UUID);
43+
}
4044
}
4145

4246
@EventHandler

UUIDMethods/src/de/yellowphoenix18/uuidmethods/methods/UUIDAPI.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
import java.util.Map;
66
import java.util.UUID;
77

8+
import de.yellowphoenix18.uuidmethods.UUIDMethods;
89
import de.yellowphoenix18.uuidmethods.cache.Cache;
910
import de.yellowphoenix18.uuidmethods.database.UUIDDatabase;
1011
import de.yellowphoenix18.uuidmethods.fetcher.OldUsernameFetcher;
1112
import de.yellowphoenix18.uuidmethods.fetcher.UUIDFetcher;
13+
import de.yellowphoenix18.uuidmethods.localstorage.LocalStorage;
1214
import de.yellowphoenix18.uuidmethods.status.MojangStatus;
1315

1416

@@ -24,12 +26,23 @@ public static String getUsernameDatabase(String UUID) {
2426
return Username;
2527
}
2628

29+
public static String getUsernameLocal(String UUID) {
30+
String username = null;
31+
if(UUIDMethods.storelocal == true) {
32+
username = LocalStorage.getUsername(UUID);
33+
}
34+
return username;
35+
}
36+
2737
public static String getUsernameMojang(String UUID) {
2838
String Username = null;
2939
UUIDFetcher fetcher = new UUIDFetcher(Arrays.asList("xxx"));
3040
try {
3141
Username = fetcher.getUsername(UUID);
3242
UUIDDatabase.setData(UUID, Username);
43+
if(UUIDMethods.storelocal == true) {
44+
LocalStorage.set(Username, UUID);
45+
}
3346
OldUsernameFetcher.storeData(UUID);
3447
return Username;
3548
} catch (Exception e) {
@@ -46,6 +59,11 @@ public static String getUsername(String UUID) {
4659
try {
4760
if(MojangOnline() == false) {
4861
Username = getUsernameDatabase(UUID);
62+
if(Username == null) {
63+
if(UUIDMethods.storelocal == true) {
64+
Username = LocalStorage.getUsername(UUID);
65+
}
66+
}
4967
} else {
5068
Username = getUsernameMojang(UUID);
5169
UUIDDatabase.setData(UUID, Username);
@@ -66,6 +84,11 @@ public static String getUsernameWithoutCache(String UUID) {
6684
try {
6785
if(MojangOnline() == false) {
6886
Username = getUsernameDatabase(UUID);
87+
if(Username == null) {
88+
if(UUIDMethods.storelocal == true) {
89+
Username = LocalStorage.getUsername(UUID);
90+
}
91+
}
6992
} else {
7093
Username = getUsernameMojang(UUID);
7194
UUIDDatabase.setData(UUID, Username);
@@ -80,6 +103,14 @@ public static String getUsernameWithoutCache(String UUID) {
80103
return Username;
81104
}
82105

106+
public static String getUUIDLocal(String Username) {
107+
String uuid = null;
108+
if(UUIDMethods.storelocal == true) {
109+
uuid = LocalStorage.getUUID(Username);
110+
}
111+
return uuid;
112+
}
113+
83114
public static String getUUIDMojang(String Username) {
84115
String UUID = null;
85116
UUIDFetcher fetcher = new UUIDFetcher(Arrays.asList(Username));
@@ -88,6 +119,9 @@ public static String getUUIDMojang(String Username) {
88119
response = fetcher.call();
89120
if(response.containsKey(Username)) {
90121
UUID = response.get(Username).toString();
122+
if(UUIDMethods.storelocal == true) {
123+
LocalStorage.set(Username, UUID);
124+
}
91125
UUIDDatabase.setData(UUID, Username);
92126
OldUsernameFetcher.storeData(UUID);
93127
}
@@ -146,6 +180,11 @@ public static String getUUID(String Username) {
146180
try {
147181
if(MojangOnline() == false) {
148182
UUID = getUUIDDatabase(Username);
183+
if(UUID == null) {
184+
if(UUIDMethods.storelocal == true) {
185+
UUID = LocalStorage.getUUID(Username);
186+
}
187+
}
149188
} else {
150189
UUID = getUUIDMojang(Username);
151190
UUIDDatabase.setData(UUID, Username);
@@ -177,6 +216,11 @@ public static String getUUIDWithoutCache(String Username) {
177216
try {
178217
if(MojangOnline() == false) {
179218
UUID = getUUIDDatabase(Username);
219+
if(UUID == null) {
220+
if(UUIDMethods.storelocal == true) {
221+
UUID = LocalStorage.getUUID(Username);
222+
}
223+
}
180224
} else {
181225
UUID = getUUIDMojang(Username);
182226
UUIDDatabase.setData(UUID, Username);

0 commit comments

Comments
 (0)