mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-27 09:35:26 +02:00
Various
sponge changes / documentation / cleanup / event tweak
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
package com.plotsquared.sponge.uuid;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.profile.GameProfile;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
import com.plotsquared.sponge.SpongeMain;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.profile.GameProfile;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SpongeLowerOfflineUUIDWrapper extends UUIDWrapper {
|
||||
|
||||
@@ -36,7 +35,7 @@ public class SpongeLowerOfflineUUIDWrapper extends UUIDWrapper {
|
||||
try {
|
||||
final GameProfile profile = SpongeMain.THIS.getResolver().get(uuid).get();
|
||||
if (profile != null) {
|
||||
name = profile.getName();
|
||||
name = profile.getName().orElse(null);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -44,9 +43,12 @@ public class SpongeLowerOfflineUUIDWrapper extends UUIDWrapper {
|
||||
}
|
||||
if (name == null) {
|
||||
for (final GameProfile profile : SpongeMain.THIS.getResolver().getCachedProfiles()) {
|
||||
if (getUUID(profile.getName()).equals(uuid)) {
|
||||
name = profile.getName();
|
||||
break;
|
||||
String tmp = profile.getName().orElse(null);
|
||||
if (tmp != null) {
|
||||
if (getUUID(name).equals(uuid)) {
|
||||
name = tmp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,5 @@
|
||||
package com.plotsquared.sponge.uuid;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
@@ -9,6 +7,8 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
import com.plotsquared.sponge.SpongeMain;
|
||||
import com.plotsquared.sponge.object.SpongePlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class SpongeOnlineUUIDWrapper extends UUIDWrapper {
|
||||
|
||||
@Override
|
||||
@@ -35,7 +35,7 @@ public class SpongeOnlineUUIDWrapper extends UUIDWrapper {
|
||||
public OfflinePlotPlayer getOfflinePlayer(final UUID uuid) {
|
||||
String name;
|
||||
try {
|
||||
name = SpongeMain.THIS.getResolver().get(uuid, true).get().getName();
|
||||
name = SpongeMain.THIS.getResolver().get(uuid, true).get().getName().orElse(null);
|
||||
} catch (final Exception e) {
|
||||
name = null;
|
||||
}
|
||||
|
@@ -1,9 +1,5 @@
|
||||
package com.plotsquared.sponge.uuid;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.spongepowered.api.profile.GameProfile;
|
||||
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
@@ -11,6 +7,9 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
import com.plotsquared.sponge.SpongeMain;
|
||||
import org.spongepowered.api.profile.GameProfile;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class SpongeUUIDHandler extends UUIDHandlerImplementation {
|
||||
|
||||
@@ -29,7 +28,10 @@ public class SpongeUUIDHandler extends UUIDHandlerImplementation {
|
||||
public boolean cache(final Runnable whenDone) {
|
||||
add(new StringWrapper("*"), DBFunc.everyone);
|
||||
for (final GameProfile profile : SpongeMain.THIS.getResolver().getCachedProfiles()) {
|
||||
add(new StringWrapper(profile.getName()), profile.getUniqueId());
|
||||
String name = profile.getName().orElse(null);
|
||||
if (name != null) {
|
||||
add(new StringWrapper(name), profile.getUniqueId());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user