3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-08 04:20:06 +01:00

Removed a stupid worldname method.

Dieser Commit ist enthalten in:
MattBDev 2019-06-18 23:43:06 -04:00
Ursprung 2f9ece3268
Commit 9d1117303c
14 geänderte Dateien mit 45 neuen und 91 gelöschten Zeilen

Datei anzeigen

@ -38,6 +38,8 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.AbstractWorld;
import com.sk89q.worldedit.world.World;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
@ -66,7 +68,7 @@ public class FaweAPI {
*
* @param world
* @return A new EditSessionBuilder
* @see com.boydti.fawe.util.EditSessionBuilder
* @see EditSessionBuilder
*/
public static EditSessionBuilder getEditSessionBuilder(World world) {
return new EditSessionBuilder(world);
@ -181,7 +183,7 @@ public class FaweAPI {
* @param world The name of the world
* @param autoqueue If it should start dispatching before you enqueue it.
* @return
* @see com.boydti.fawe.object.FaweQueue#enqueue()
* @see FaweQueue#enqueue()
*/
public static FaweQueue createQueue(World world, boolean autoqueue) {
return SetQueue.IMP.getNewQueue(world, true, autoqueue);
@ -190,11 +192,6 @@ public class FaweAPI {
public static World getWorld(String worldName) {
Platform platform = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING);
List<? extends World> worlds = platform.getWorlds();
for (World current : worlds) {
if (Fawe.imp().getWorldName(current).equals(worldName)) {
return WorldWrapper.wrap(current);
}
}
for (World current : worlds) {
if (current.getName().equals(worldName)) {
return WorldWrapper.wrap(current);
@ -219,8 +216,8 @@ public class FaweAPI {
*
* @param file
* @return
* @see com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat
* @see com.boydti.fawe.object.schematic.Schematic
* @see ClipboardFormat
* @see Schematic
*/
public static Schematic load(File file) throws IOException {
return ClipboardFormats.findByFile(file).load(file);
@ -261,7 +258,7 @@ public class FaweAPI {
*
* @param extent
* @param reason
* @see com.sk89q.worldedit.EditSession#getRegionExtent() To get the FaweExtent for an EditSession
* @see EditSession#getRegionExtent() To get the FaweExtent for an EditSession
*/
public static void cancelEdit(Extent extent, BBC reason) {
try {
@ -400,7 +397,7 @@ public class FaweAPI {
* @param uuid
* @param index
* @return
* @see com.boydti.fawe.object.changeset.DiskStorageHistory#toEditSession(com.boydti.fawe.object.FawePlayer)
* @see DiskStorageHistory#toEditSession(FawePlayer)
*/
public static DiskStorageHistory getChangeSetFromDisk(World world, UUID uuid, int index) {
return new DiskStorageHistory(world, uuid, index);
@ -517,25 +514,4 @@ public class FaweAPI {
return BBC.values();
}
/**
* @see #getEditSessionBuilder(com.sk89q.worldedit.world.World)
* @deprecated
*/
@Deprecated
public static EditSession getNewEditSession(@Nonnull FawePlayer player) {
if (player == null) {
throw new IllegalArgumentException("Player may not be null");
}
return player.getNewEditSession();
}
/**
* @see #getEditSessionBuilder(com.sk89q.worldedit.world.World)
* @deprecated
*/
@Deprecated
public static EditSession getNewEditSession(World world) {
return WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1);
}
}

Datei anzeigen

@ -111,7 +111,7 @@ public class AnvilCommands {
}
CuboidRegion cuboid = (CuboidRegion) selection;
RegionWrapper wrappedRegion = new RegionWrapper(cuboid.getMinimumPoint(), cuboid.getMaximumPoint());
String worldName = Fawe.imp().getWorldName(editSession.getWorld());
String worldName = editSession.getWorld().getName();
FaweQueue tmp = SetQueue.IMP.getNewQueue(worldName, true, false);
MCAQueue queue = new MCAQueue(tmp);
FawePlayer<Object> fp = FawePlayer.wrap(player);
@ -127,7 +127,7 @@ public class AnvilCommands {
if (session == null || session.hasFastMode()) {
run.accept(new NullAnvilHistory());
} else {
AnvilHistory history = new AnvilHistory(Fawe.imp().getWorldName(world), fp.getUUID());
AnvilHistory history = new AnvilHistory(world.getName(), fp.getUUID());
run.accept(history);
session.remember(fp.getPlayer(), world, history, fp.getLimit());
}
@ -173,13 +173,8 @@ public class AnvilCommands {
ClipboardRemapper mapper;
ClipboardRemapper.RemapPlatform from;
ClipboardRemapper.RemapPlatform to;
if (Fawe.imp().getPlatform().equalsIgnoreCase("nukkit")) {
from = ClipboardRemapper.RemapPlatform.PC;
to = ClipboardRemapper.RemapPlatform.PE;
} else {
from = ClipboardRemapper.RemapPlatform.PE;
to = ClipboardRemapper.RemapPlatform.PC;
}
RemapFilter filter = new RemapFilter(from, to);
RemapFilter result = runWithWorld(player, folder, filter, true);
if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
@ -199,8 +194,7 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.deleteallunvisited")
public void deleteAllUnvisited(Player player, String folder, int inhabitedTicks, @Optional("60000") int fileDurationMillis) throws WorldEditException {
long chunkInactivityMillis = fileDurationMillis; // Use same value for now
DeleteUninhabitedFilter filter = new DeleteUninhabitedFilter(fileDurationMillis, inhabitedTicks, chunkInactivityMillis);
DeleteUninhabitedFilter filter = new DeleteUninhabitedFilter(fileDurationMillis, inhabitedTicks, fileDurationMillis);
DeleteUninhabitedFilter result = runWithWorld(player, folder, filter, true);
if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
}
@ -218,9 +212,8 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.deleteallunclaimed")
public void deleteAllUnclaimed(Player player, int inhabitedTicks, @Optional("60000") int fileDurationMillis, @Switch('d') boolean debug) throws WorldEditException {
String folder = Fawe.imp().getWorldName(player.getWorld());
long chunkInactivityMillis = fileDurationMillis; // Use same value for now
DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, chunkInactivityMillis);
String folder = player.getWorld().getName();
DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis);
if (debug) filter.enableDebug();
DeleteUnclaimedFilter result = runWithWorld(player, folder, filter, true);
if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
@ -239,9 +232,7 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.deleteunclaimed")
public void deleteUnclaimed(Player player, EditSession editSession, @Selection Region selection, int inhabitedTicks, @Optional("60000") int fileDurationMillis, @Switch('d') boolean debug) throws WorldEditException {
String folder = Fawe.imp().getWorldName(player.getWorld());
long chunkInactivityMillis = fileDurationMillis; // Use same value for now
DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, chunkInactivityMillis);
DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis);
if (debug) filter.enableDebug();
DeleteUnclaimedFilter result = runWithSelection(player, editSession, selection, filter);
if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
@ -260,7 +251,7 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.deletealloldregions")
public void deleteAllOldRegions(Player player, String folder, String time) throws WorldEditException {
long duration = MainUtil.timeToSec(time) * 1000l;
long duration = MainUtil.timeToSec(time) * 1000L;
DeleteOldFilter filter = new DeleteOldFilter(duration);
DeleteOldFilter result = runWithWorld(player, folder, filter, true);
if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
@ -276,7 +267,7 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.trimallplots")
public void trimAllPlots(Player player, @Switch('v') boolean deleteUnvisited) throws WorldEditException {
String folder = Fawe.imp().getWorldName(player.getWorld());
String folder = player.getWorld().getName();
int visitTime = deleteUnvisited ? 1 : -1;
PlotTrimFilter filter = new PlotTrimFilter(player.getWorld(), 0, visitTime, 600000);
// PlotTrimFilter result = runWithWorld(player, folder, filter, true);
@ -627,7 +618,7 @@ public class AnvilCommands {
return;
}
CuboidRegion cuboid = (CuboidRegion) selection;
String worldName = Fawe.imp().getWorldName(editSession.getWorld());
String worldName = editSession.getWorld().getName();
FaweQueue tmp = SetQueue.IMP.getNewQueue(worldName, true, false);
MCAQueue queue = new MCAQueue(tmp);
BlockVector3 origin = session.getPlacementPosition(player);

Datei anzeigen

@ -11,7 +11,7 @@ public class DBHandler {
private Map<String, RollbackDatabase> databases = new ConcurrentHashMap<>(8, 0.9f, 1);
public RollbackDatabase getDatabase(World world) {
String worldName = Fawe.imp().getWorldName(world);
String worldName = world.getName();
RollbackDatabase database = databases.get(worldName);
if (database != null) {
return database;

Datei anzeigen

@ -52,9 +52,9 @@ public class RollbackDatabase extends AsyncNotifyQueue {
public RollbackDatabase(final World world) throws SQLException, ClassNotFoundException {
this.prefix = "";
this.worldName = Fawe.imp().getWorldName(world);
this.worldName = world.getName();
this.world = world;
this.dbLocation = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(world) + File.separator + "summary.db");
this.dbLocation = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + world.getName() + File.separator + "summary.db");
connection = openConnection();
CREATE_TABLE = "CREATE TABLE IF NOT EXISTS `" + prefix + "edits` (`player` BLOB(16) NOT NULL,`id` INT NOT NULL,`x1` INT NOT NULL,`y1` INT NOT NULL,`z1` INT NOT NULL,`x2` INT NOT NULL,`y2` INT NOT NULL,`z2` INT NOT NULL,`time` INT NOT NULL, PRIMARY KEY (player, id))";
INSERT_EDIT = "INSERT OR REPLACE INTO `" + prefix + "edits` (`player`,`id`,`x1`,`y1`,`z1`,`x2`,`y2`,`z2`,`time`) VALUES(?,?,?,?,?,?,?,?,?)";

Datei anzeigen

@ -84,7 +84,7 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, CHUNKSECTIONS, SECTION> impl
public MappedFaweQueue(final World world, IFaweQueueMap map) {
this.weWorld = world;
if (world != null) this.world = Fawe.imp().getWorldName(world);
if (world != null) this.world = world.getName();
if (map == null) {
map = getSettings().PREVENT_CRASHES ? new WeakFaweQueueMap(this) : new DefaultFaweQueueMap(this);
}

Datei anzeigen

@ -16,7 +16,7 @@ public class DeleteUnclaimedFilter extends DeleteUninhabitedFilter {
public DeleteUnclaimedFilter(World world, long fileDuration, long inhabitedTicks, long chunkInactivity) {
super(fileDuration, inhabitedTicks, chunkInactivity);
for (FaweMaskManager m : FaweAPI.getMaskManagers()) {
RegionFilter filter = m.getFilter(Fawe.imp().getWorldName(world));
RegionFilter filter = m.getFilter(world.getName());
if (filter != null) {
filters.add(filter);
}

Datei anzeigen

@ -46,7 +46,7 @@ public class PlotTrimFilter extends DeleteUninhabitedFilter {
super(fileDuration, inhabitedTicks, chunkInactivity);
Fawe.debug("Initializing Plot trim...");
String worldName = Fawe.imp().getWorldName(world);
String worldName = world.getName();
PlotArea area = PlotSquared.get().getPlotAreaByString(worldName);
IndependentPlotGenerator gen = area.getGenerator();
if (!(area instanceof HybridPlotWorld) || !(gen instanceof HybridGen)) {

Datei anzeigen

@ -88,15 +88,7 @@ public abstract class FawePlayer<T> extends Metadatable {
return existing;
}
}
if (obj.getClass().getName().contains("CraftPlayer") && !Fawe.imp().getPlatform().equals("bukkit")) {
try {
Method methodGetHandle = obj.getClass().getDeclaredMethod("getHandle");
obj = methodGetHandle.invoke(obj);
} catch (Throwable e) {
e.printStackTrace();
return null;
}
}
obj.getClass().getName();
return Fawe.imp().wrap(obj);
}

Datei anzeigen

@ -66,7 +66,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
public DiskStorageHistory(World world, UUID uuid) {
super(world);
init(uuid, Fawe.imp().getWorldName(world));
init(uuid, world.getName());
}
public DiskStorageHistory(String world, UUID uuid) {
@ -116,12 +116,12 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
private void init(UUID uuid, int i) {
this.uuid = uuid;
this.index = i;
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(getWorld()) + File.separator + uuid);
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + getWorld().getName() + File.separator + uuid);
initFiles(folder);
}
public void delete() {
Fawe.debug("Deleting history: " + Fawe.imp().getWorldName(getWorld()) + "/" + uuid + "/" + index);
Fawe.debug("Deleting history: " + getWorld().getName() + "/" + uuid + "/" + index);
deleteFiles();
if (Settings.IMP.HISTORY.USE_DATABASE) {
RollbackDatabase db = DBHandler.IMP.getDatabase(getWorld());

Datei anzeigen

@ -61,7 +61,7 @@ public abstract class FaweChangeSet implements ChangeSet {
public FaweChangeSet(World world) {
this.world = world;
this.worldName = Fawe.imp().getWorldName(world);
this.worldName = world.getName();
this.mainThread = Fawe.isMainThread();
this.layers = (this.world.getMaxY() + 1) >> 4;
}

Datei anzeigen

@ -97,7 +97,7 @@ public class EditSessionBuilder {
public EditSessionBuilder world(@Nonnull World world) {
checkNotNull(world);
this.world = world;
this.worldName = Fawe.imp().getWorldName(world);
this.worldName = world.getName();
return this;
}

Datei anzeigen

@ -244,7 +244,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
public EditSession(@Nullable String worldName, @Nullable World world, @Nullable FaweQueue queue, @Nullable FawePlayer player, @Nullable FaweLimit limit, @Nullable FaweChangeSet changeSet, @Nullable Region[] allowedRegions, @Nullable Boolean autoQueue, @Nullable Boolean fastmode, @Nullable Boolean checkMemory, @Nullable Boolean combineStages, @Nullable BlockBag blockBag, @Nullable EventBus bus, @Nullable EditSessionEvent event) {
super(world);
this.worldName = worldName == null ? world == null ? queue == null ? "" : queue.getWorldName() : Fawe.imp().getWorldName(world) : worldName;
this.worldName = worldName == null ? world == null ? queue == null ? "" : queue.getWorldName() : world.getName() : worldName;
if (world == null && this.worldName != null) world = FaweAPI.getWorld(this.worldName);
this.world = world;
if (bus == null) {

Datei anzeigen

@ -221,7 +221,7 @@ public class LocalSession implements TextureHolder {
private boolean loadHistoryChangeSets(UUID uuid, World world) {
SparseBitSet set = new SparseBitSet();
final File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(world) + File.separator + uuid);
final File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + world.getName() + File.separator + uuid);
if (folder.isDirectory()) {
folder.listFiles(pathname -> {
String name = pathname.getName();
@ -252,7 +252,7 @@ public class LocalSession implements TextureHolder {
if (!Settings.IMP.HISTORY.USE_DISK) {
return;
}
File file = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(world) + File.separator + uuid + File.separator + "index");
File file = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + world.getName() + File.separator + uuid + File.separator + "index");
if (file.exists()) {
try (FaweInputStream is = new FaweInputStream(new FileInputStream(file))) {
historyNegativeIndex = Math.min(Math.max(0, is.readInt()), history.size());
@ -268,7 +268,7 @@ public class LocalSession implements TextureHolder {
if (world == null || !Settings.IMP.HISTORY.USE_DISK) {
return;
}
File file = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(world) + File.separator + uuid + File.separator + "index");
File file = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + world.getName() + File.separator + uuid + File.separator + "index");
if (getHistoryNegativeIndex() != 0) {
try {
if (!file.exists()) {
@ -389,10 +389,10 @@ public class LocalSession implements TextureHolder {
return cs;
}
if (o instanceof Integer) {
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(currentWorld) + File.separator + uuid);
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + currentWorld.getName() + File.separator + uuid);
File specific = new File(folder, o.toString());
if (specific.isDirectory()) {
return new AnvilHistory(Fawe.imp().getWorldName(currentWorld), specific);
return new AnvilHistory(currentWorld.getName(), specific);
} else {
return new DiskStorageHistory(currentWorld, this.uuid, (Integer) o);
}

Datei anzeigen

@ -142,7 +142,7 @@ public class HistoryCommands extends MethodCommands {
if (file.getBDFile().exists()) {
if (restore) file.redo(FawePlayer.wrap(player));
else file.undo(FawePlayer.wrap(player));
BBC.ROLLBACK_ELEMENT.send(player, Fawe.imp().getWorldName(world) + "/" + user + "-" + index);
BBC.ROLLBACK_ELEMENT.send(player, world.getName() + "/" + user + "-" + index);
} else {
BBC.TOOL_INSPECT_INFO_FOOTER.send(player, 0);
}
@ -193,15 +193,10 @@ public class HistoryCommands extends MethodCommands {
@Override
public void run(DiskStorageHistory edit) {
edit.undo(fp, allowedRegions);
BBC.ROLLBACK_ELEMENT.send(player, Fawe.imp().getWorldName(edit.getWorld()) + "/" + user + "-" + edit.getIndex());
BBC.ROLLBACK_ELEMENT.send(player, edit.getWorld().getName() + "/" + user + "-" + edit.getIndex());
count.incrementAndGet();
}
}, new Runnable() {
@Override
public void run() {
BBC.TOOL_INSPECT_INFO_FOOTER.send(player, count);
}
}, true, restore);
}, () -> BBC.TOOL_INSPECT_INFO_FOOTER.send(player, count), true, restore);
}
@Command(