mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-12-12 12:26:55 +01:00
Use name based UUID for the time being
This commit is contained in:
parent
e1c3404b16
commit
4c2754d6df
@ -16,6 +16,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
|
||||
import com.intellectualcrafters.plot.util.block.QueueProvider;
|
||||
import com.plotsquared.listener.WEManager;
|
||||
@ -48,6 +49,10 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getName(UUID uuid) {
|
||||
return UUIDHandler.getName(uuid);
|
||||
}
|
||||
|
||||
private void setupBlockQueue() {
|
||||
try {
|
||||
// If it's going to fail, throw an error now rather than later
|
||||
|
@ -24,12 +24,8 @@ import cn.nukkit.Player;
|
||||
import cn.nukkit.inventory.PlayerInventory;
|
||||
import cn.nukkit.item.Item;
|
||||
import cn.nukkit.level.Location;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
@ -50,7 +46,7 @@ public class NukkitPlayer extends LocalPlayer {
|
||||
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
return player.getUniqueId();
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName().toLowerCase()).getBytes(Charsets.UTF_8));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,6 +2,7 @@ package com.boydti.fawe.nukkit.optimization;
|
||||
|
||||
import cn.nukkit.Nukkit;
|
||||
import cn.nukkit.Player;
|
||||
import cn.nukkit.Server;
|
||||
import cn.nukkit.event.EventHandler;
|
||||
import cn.nukkit.event.Listener;
|
||||
import cn.nukkit.event.player.PlayerFormRespondedEvent;
|
||||
@ -27,16 +28,13 @@ import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.brush.visualization.VisualChunk;
|
||||
import com.boydti.fawe.regions.FaweMaskManager;
|
||||
import com.boydti.fawe.regions.general.plot.PlotSquaredFeature;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.boydti.fawe.util.gui.FormBuilder;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class FaweNukkit implements IFawe, Listener {
|
||||
@ -220,12 +218,42 @@ public class FaweNukkit implements IFawe, Listener {
|
||||
try {
|
||||
return UUID.fromString(name);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
|
||||
}
|
||||
}
|
||||
|
||||
private Map<UUID, String> names = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public String getName(UUID uuid) {
|
||||
try {
|
||||
Class.forName("com.boydti.fawe.regions.general.plot.PlotSquaredFeature");
|
||||
String name = PlotSquaredFeature.getName(uuid);
|
||||
if (name != null) return name;
|
||||
} catch (Throwable ignore){
|
||||
String mapped = names.get(uuid);
|
||||
if (mapped != null) return mapped;
|
||||
|
||||
boolean namesEmpty = names.isEmpty();
|
||||
for (Player player : Server.getInstance().getOnlinePlayers().values()) {
|
||||
String name = player.getName();
|
||||
UUID plrUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
|
||||
names.put(plrUUID, name);
|
||||
}
|
||||
|
||||
if (namesEmpty) {
|
||||
for (File file : new File("players").listFiles()) {
|
||||
String name = file.getName();
|
||||
name = name.substring(0, name.length() - 4);
|
||||
UUID plrUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
|
||||
names.put(plrUUID, name);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
mapped = names.get(uuid);
|
||||
if (mapped != null) return mapped;
|
||||
}
|
||||
return uuid.toString();
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import com.boydti.fawe.nukkit.core.NukkitPlatform;
|
||||
import com.boydti.fawe.nukkit.core.NukkitPlayer;
|
||||
import com.boydti.fawe.object.FaweLocation;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.google.common.base.Charsets;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FaweNukkitPlayer extends FawePlayer<Player> {
|
||||
@ -26,7 +27,7 @@ public class FaweNukkitPlayer extends FawePlayer<Player> {
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return this.parent.getUniqueId();
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + parent.getName().toLowerCase()).getBytes(Charsets.UTF_8));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user