mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-29 04:04:43 +02:00
commit
This commit is contained in:
@ -31,7 +31,7 @@ import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.bukkit.listeners.PlotListener;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
@ -1421,15 +1421,6 @@ public class MainUtil {
|
||||
return sendMessage(plr, msg, true);
|
||||
}
|
||||
|
||||
public static boolean sendCallerMessage(final CommandCaller plr, final String msg) {
|
||||
if (plr.getSuperCaller() instanceof PlotPlayer) {
|
||||
sendMessage((PlotPlayer) plr.getSuperCaller(), msg);
|
||||
} else {
|
||||
sendConsoleMessage(msg);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void sendConsoleMessage(String msg) {
|
||||
sendMessage(null, msg);
|
||||
}
|
||||
@ -1516,15 +1507,6 @@ public class MainUtil {
|
||||
return lines.toArray(new String[lines.size()]);
|
||||
}
|
||||
|
||||
public static boolean sendCallerMessage(final CommandCaller caller, final C c, final String... args) {
|
||||
if (caller.getSuperCaller() instanceof PlotPlayer) {
|
||||
sendMessage((PlotPlayer) caller.getSuperCaller(), c, args);
|
||||
} else {
|
||||
sendConsoleMessage(c, args);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to the player
|
||||
*
|
||||
|
@ -152,22 +152,48 @@ public class StringMan {
|
||||
|
||||
public static String join(Object[] array, String delimiter) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
System.out.print(array.getClass().getName());
|
||||
for (int i = 0, j = array.length; i < j; i++) {
|
||||
if (i > 0) {
|
||||
result.append(delimiter);
|
||||
}
|
||||
System.out.print(array[i].getClass().getName());
|
||||
result.append(array[i]);
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public static String join(int[] array, String delimiter) {
|
||||
return join(Arrays.asList(array), delimiter);
|
||||
Integer[] wrapped = new Integer[array.length];
|
||||
for (int i = 0; i < array.length; i++) wrapped[i] = array[i];
|
||||
return join(wrapped, delimiter);
|
||||
}
|
||||
|
||||
public static boolean isEqual(String a, String b ) {
|
||||
public static boolean isEqualToAny(String a, String... args) {
|
||||
for (String arg : args) {
|
||||
if (StringMan.isEqual(a, arg)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isEqualIgnoreCaseToAny(String a, String... args) {
|
||||
for (String arg : args) {
|
||||
if (StringMan.isEqualIgnoreCase(a, arg)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isEqual(String a, String b) {
|
||||
return (a == b || (a.length() == b.length() && a.hashCode() == b.hashCode() && a.equals(b)));
|
||||
}
|
||||
|
||||
public static boolean isEqualIgnoreCase(String a, String b) {
|
||||
return (a == b || (a.length() == b.length() && a.equalsIgnoreCase(b)));
|
||||
}
|
||||
|
||||
public static String repeat(String s, int n) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
@ -79,8 +79,8 @@ public class UUIDHandler {
|
||||
implementation.setUUIDWrapper(wrapper);
|
||||
}
|
||||
|
||||
public static void startCaching() {
|
||||
implementation.startCaching();
|
||||
public static void startCaching(Runnable whenDone) {
|
||||
implementation.startCaching(whenDone);
|
||||
}
|
||||
|
||||
public static void cache(final BiMap<StringWrapper, UUID> toAdd) {
|
||||
|
@ -40,7 +40,7 @@ public abstract class UUIDHandlerImplementation {
|
||||
* Start UUID caching (this should be an async task)
|
||||
* Recommended to override this is you want to cache offline players
|
||||
*/
|
||||
public boolean startCaching() {
|
||||
public boolean startCaching(Runnable whenDone) {
|
||||
if (CACHED) {
|
||||
return false;
|
||||
}
|
||||
@ -55,6 +55,11 @@ public abstract class UUIDHandlerImplementation {
|
||||
this.uuidWrapper = wrapper;
|
||||
}
|
||||
|
||||
public void rename(UUID uuid, StringWrapper name) {
|
||||
uuidMap.inverse().remove(uuid);
|
||||
uuidMap.put(name, uuid);
|
||||
}
|
||||
|
||||
public void add(final BiMap<StringWrapper, UUID> toAdd) {
|
||||
if (uuidMap.size() == 0) {
|
||||
uuidMap = toAdd;
|
||||
@ -63,7 +68,20 @@ public abstract class UUIDHandlerImplementation {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Map.Entry<StringWrapper, UUID> entry : toAdd.entrySet()) {
|
||||
add(entry.getKey(), entry.getValue());
|
||||
UUID uuid = entry.getValue();
|
||||
StringWrapper name = entry.getKey();
|
||||
if ((uuid == null) || (name == null)) {
|
||||
continue;
|
||||
}
|
||||
BiMap<UUID, StringWrapper> inverse = uuidMap.inverse();
|
||||
if (inverse.containsKey(uuid)) {
|
||||
if (uuidMap.containsKey(name)) {
|
||||
continue;
|
||||
}
|
||||
rename(uuid, name);
|
||||
continue;
|
||||
}
|
||||
uuidMap.put(name, uuid);
|
||||
}
|
||||
PS.log(C.PREFIX.s() + "&6Cached a total of: " + uuidMap.size() + " UUIDs");
|
||||
}
|
||||
@ -79,7 +97,8 @@ public abstract class UUIDHandlerImplementation {
|
||||
if (uuidMap.containsKey(name)) {
|
||||
return false;
|
||||
}
|
||||
inverse.remove(uuid);
|
||||
rename(uuid, name);
|
||||
return false;
|
||||
}
|
||||
uuidMap.put(name, uuid);
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user