mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-06 20:56:41 +00:00
Remove FawePlayer and API modifications
This commit is contained in:
@ -19,13 +19,30 @@
|
||||
|
||||
package com.sk89q.worldedit.entity;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.FaweLimit;
|
||||
import com.boydti.fawe.object.brush.visualization.VirtualWorld;
|
||||
import com.boydti.fawe.object.clipboard.DiskOptimizedClipboard;
|
||||
import com.boydti.fawe.regions.FaweMaskManager;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.sk89q.worldedit.EmptyClipboardException;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionOperationException;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
@ -33,8 +50,11 @@ import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.NumberFormat;
|
||||
import javax.annotation.Nullable;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a player
|
||||
@ -290,6 +310,7 @@ public interface Player extends Entity, Actor {
|
||||
*
|
||||
* @param pos where to move them
|
||||
*/
|
||||
@Override
|
||||
void setPosition(Vector3 pos);
|
||||
|
||||
/**
|
||||
@ -303,4 +324,184 @@ public interface Player extends Entity, Actor {
|
||||
* @param block The block to send, null to reset
|
||||
*/
|
||||
<B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, @Nullable B block);
|
||||
|
||||
default FaweLimit getLimit() {
|
||||
return Settings.IMP.getLimit(this);
|
||||
}
|
||||
|
||||
void checkConfirmationStack(@NotNull Runnable task, @NotNull String command,
|
||||
Region region, int times, InjectedValueAccess context) throws RegionOperationException;
|
||||
|
||||
void checkConfirmationRegion(@NotNull Runnable task, @NotNull String command,
|
||||
Region region, InjectedValueAccess context) throws RegionOperationException;
|
||||
|
||||
void setConfirmTask(@NotNull Runnable task, InjectedValueAccess context,
|
||||
@NotNull String command);
|
||||
|
||||
public Region[] getCurrentRegions();
|
||||
|
||||
Region[] getCurrentRegions(FaweMaskManager.MaskType type);
|
||||
|
||||
Region getLargestRegion();
|
||||
|
||||
void setSelection(Region region);
|
||||
|
||||
/**
|
||||
* Get the player's current selection (or null)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
default Region getSelection() {
|
||||
try {
|
||||
return getSession().getSelection(getWorld());
|
||||
} catch (IncompleteRegionException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the player's WorldEdit selection
|
||||
*
|
||||
* @param selector
|
||||
*/
|
||||
default void setSelection(RegionSelector selector) {
|
||||
getSession().setRegionSelector(getWorld(), selector);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the World the player is editing in (may not match the world they are in)<br/> - e.g. If
|
||||
* they are editing a CFI world.<br/>
|
||||
*
|
||||
* @return Editing world
|
||||
*/
|
||||
default World getWorldForEditing() {
|
||||
VirtualWorld virtual = getSession().getVirtualWorld();
|
||||
if (virtual != null) {
|
||||
return virtual;
|
||||
}
|
||||
// CFICommands.CFISettings cfi = getMeta("CFISettings");
|
||||
// if (cfi != null && cfi.hasGenerator() && cfi.getGenerator().hasPacketViewer()) {
|
||||
// return cfi.getGenerator();
|
||||
// }
|
||||
return WorldEdit.getInstance().getPlatformManager().getWorldForEditing(getWorld());
|
||||
}
|
||||
|
||||
void checkConfirmation(@NotNull Runnable task, @NotNull String command, int times,
|
||||
int limit, InjectedValueAccess context) throws RegionOperationException;
|
||||
|
||||
default void checkConfirmationRadius(@NotNull Runnable task, String command, int radius,
|
||||
InjectedValueAccess context) throws RegionOperationException {
|
||||
if (command != null && !getMeta("cmdConfirmRunning", false)) {
|
||||
if (radius > 0) {
|
||||
if (radius > 448) {
|
||||
setConfirmTask(task, context, command);
|
||||
long volume = (long) (Math.PI * ((double) radius * radius));
|
||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM
|
||||
.format(0, radius, command,
|
||||
NumberFormat.getNumberInstance().format(volume)));
|
||||
}
|
||||
}
|
||||
}
|
||||
task.run();
|
||||
}
|
||||
|
||||
boolean confirm();
|
||||
|
||||
/**
|
||||
* Queue an action to run async
|
||||
*
|
||||
* @param run
|
||||
*/
|
||||
default void queueAction(Runnable run) {
|
||||
runAction(run, false, true);
|
||||
}
|
||||
|
||||
default boolean runAsyncIfFree(Runnable r) {
|
||||
return runAction(r, true, true);
|
||||
}
|
||||
|
||||
default boolean runIfFree(Runnable r) {
|
||||
return runAction(r, true, false);
|
||||
}
|
||||
|
||||
default boolean checkAction() {
|
||||
long time = getMeta("faweActionTick", Long.MIN_VALUE);
|
||||
long tick = Fawe.get().getTimer().getTick();
|
||||
setMeta("faweActionTick", tick);
|
||||
return tick > time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister this player (deletes all metadata etc) - Usually called on logout
|
||||
*/
|
||||
default void unregister() {
|
||||
cancel(true);
|
||||
if (Settings.IMP.HISTORY.DELETE_ON_LOGOUT) {
|
||||
getSession().setClipboard(null);
|
||||
getSession().clearHistory();
|
||||
getSession().unregisterTools(this);
|
||||
}
|
||||
Fawe.get().unregister(getName());
|
||||
}
|
||||
|
||||
default int cancel(boolean close) {
|
||||
// Collection<IQueueExtent> queues = SetQueue.IMP.getAllQueues(); TODO NOT IMPLEMENTED
|
||||
// int cancelled = 0;
|
||||
// clearActions();
|
||||
// for (IQueueExtent queue : queues) {
|
||||
// Collection<EditSession> sessions = queue.getEditSessions();
|
||||
// for (EditSession session : sessions) {
|
||||
// FawePlayer currentPlayer = session.getPlayer();
|
||||
// if (currentPlayer == this) {
|
||||
// if (session.cancel()) {
|
||||
// cancelled++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// VirtualWorld world = getSession().getVirtualWorld();
|
||||
// if (world != null) {
|
||||
// if (close) {
|
||||
// try {
|
||||
// world.close(false);
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// else world.clear();
|
||||
// }
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sendTitle(String title, String sub);
|
||||
|
||||
/**
|
||||
* Loads any history items from disk: - Should already be called if history on disk is enabled
|
||||
*/
|
||||
default void loadClipboardFromDisk() {
|
||||
File file = MainUtil.getFile(Fawe.imp().getDirectory(),
|
||||
Settings.IMP.PATHS.CLIPBOARD + File.separator + getUniqueId() + ".bd");
|
||||
try {
|
||||
if (file.exists() && file.length() > 5) {
|
||||
DiskOptimizedClipboard doc = new DiskOptimizedClipboard(file);
|
||||
LocalSession session = getSession();
|
||||
try {
|
||||
if (session.getClipboard() != null) {
|
||||
return;
|
||||
}
|
||||
} catch (EmptyClipboardException ignored) {
|
||||
}
|
||||
Clipboard clip = doc.toClipboard();
|
||||
ClipboardHolder holder = new ClipboardHolder(clip);
|
||||
getSession().setClipboard(holder);
|
||||
}
|
||||
} catch (Exception event) {
|
||||
Fawe.debug("====== INVALID CLIPBOARD ======");
|
||||
event.printStackTrace();
|
||||
Fawe.debug("===============---=============");
|
||||
Fawe.debug("This shouldn't result in any failure");
|
||||
Fawe.debug("File: " + file.getName() + " (len:" + file.length() + ")");
|
||||
Fawe.debug("===============---=============");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user