mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Fix some adapter issues
regen 1.13, tile get npe, null block type values
This commit is contained in:
@ -2,7 +2,6 @@ package com.boydti.fawe;
|
||||
|
||||
import com.boydti.fawe.beta.implementation.queue.QueueHandler;
|
||||
import com.boydti.fawe.beta.implementation.cache.preloader.Preloader;
|
||||
import com.boydti.fawe.object.FaweCommand;
|
||||
import com.boydti.fawe.regions.FaweMaskManager;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.boydti.fawe.util.image.ImageViewer;
|
||||
|
@ -1,45 +0,0 @@
|
||||
package com.boydti.fawe.object;
|
||||
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
|
||||
public abstract class FaweCommand<T> {
|
||||
public final String perm;
|
||||
public final boolean safe;
|
||||
|
||||
public FaweCommand(String perm) {
|
||||
this(perm, true);
|
||||
}
|
||||
|
||||
public FaweCommand(String perm, boolean safe) {
|
||||
this.perm = perm;
|
||||
this.safe = safe;
|
||||
}
|
||||
|
||||
public String getPerm() {
|
||||
return this.perm;
|
||||
}
|
||||
|
||||
public boolean executeSafe(Actor player, String... args) {
|
||||
try {
|
||||
if (!safe) {
|
||||
execute(player, args);
|
||||
return true;
|
||||
} else if (player == null) {
|
||||
TaskManager.IMP.async(() -> execute(player, args));
|
||||
} else {
|
||||
if (!player.runAction(() -> execute(player, args), true, true)) {
|
||||
player.printError(TranslatableComponent.of("fawe.info.worldedit.command.limit"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public abstract boolean execute(Actor actor, String... args);
|
||||
}
|
@ -28,6 +28,7 @@ import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.annotation.Confirm;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
@ -60,7 +61,7 @@ public class HistoryCommands {
|
||||
desc = "Undoes the last action (from history)"
|
||||
)
|
||||
@CommandPermissions({"worldedit.history.undo", "worldedit.history.undo.self"})
|
||||
public void undo(Player player, LocalSession session,
|
||||
public void undo(Actor actor, LocalSession session,
|
||||
@Confirm(Confirm.Processor.LIMIT) @Arg(desc = "Number of undoes to perform", def = "1")
|
||||
int times,
|
||||
@Arg(name = "player", desc = "Undo this player's operations", def = "")
|
||||
@ -68,31 +69,32 @@ public class HistoryCommands {
|
||||
times = Math.max(1, times);
|
||||
LocalSession undoSession = session;
|
||||
if (session.hasFastMode()) {
|
||||
player.print(TranslatableComponent.of("fawe.worldedit.history.command.undo.disabled"));
|
||||
actor.print(TranslatableComponent.of("fawe.worldedit.history.command.undo.disabled"));
|
||||
return;
|
||||
}
|
||||
if (playerName != null) {
|
||||
player.checkPermission("worldedit.history.undo.other");
|
||||
actor.checkPermission("worldedit.history.undo.other");
|
||||
undoSession = worldEdit.getSessionManager().findByName(playerName);
|
||||
if (undoSession == null) {
|
||||
player.printError(TranslatableComponent.of("worldedit.session.cant-find-session", TextComponent.of(playerName)));
|
||||
actor.printError(TranslatableComponent.of("worldedit.session.cant-find-session", TextComponent.of(playerName)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
int timesUndone = 0;
|
||||
for (int i = 0; i < times; ++i) {
|
||||
EditSession undone = undoSession.undo(undoSession.getBlockBag(player), player);
|
||||
BlockBag bag = actor instanceof Player ? undoSession.getBlockBag((Player) actor) : null;
|
||||
EditSession undone = undoSession.undo(bag, actor);
|
||||
if (undone != null) {
|
||||
timesUndone++;
|
||||
worldEdit.flushBlockBag(player, undone);
|
||||
worldEdit.flushBlockBag(actor, undone);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (timesUndone > 0) {
|
||||
player.printInfo(TranslatableComponent.of("worldedit.undo.undone", TextComponent.of(timesUndone)));
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.undo.undone", TextComponent.of(timesUndone)));
|
||||
} else {
|
||||
player.printError(TranslatableComponent.of("worldedit.undo.none"));
|
||||
actor.printError(TranslatableComponent.of("worldedit.undo.none"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,7 +104,7 @@ public class HistoryCommands {
|
||||
desc = "Redoes the last action (from history)"
|
||||
)
|
||||
@CommandPermissions({"worldedit.history.redo", "worldedit.history.redo.self"})
|
||||
public void redo(Player player, LocalSession session,
|
||||
public void redo(Actor actor, LocalSession session,
|
||||
@Confirm(Confirm.Processor.LIMIT) @Arg(desc = "Number of redoes to perform", def = "1")
|
||||
int times,
|
||||
@Arg(name = "player", desc = "Redo this player's operations", def = "")
|
||||
@ -110,27 +112,28 @@ public class HistoryCommands {
|
||||
times = Math.max(1, times);
|
||||
LocalSession redoSession = session;
|
||||
if (playerName != null) {
|
||||
player.checkPermission("worldedit.history.redo.other");
|
||||
actor.checkPermission("worldedit.history.redo.other");
|
||||
redoSession = worldEdit.getSessionManager().findByName(playerName);
|
||||
if (redoSession == null) {
|
||||
player.printError(TranslatableComponent.of("worldedit.session.cant-find-session", TextComponent.of(playerName)));
|
||||
actor.printError(TranslatableComponent.of("worldedit.session.cant-find-session", TextComponent.of(playerName)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
int timesRedone = 0;
|
||||
for (int i = 0; i < times; ++i) {
|
||||
EditSession redone = redoSession.redo(redoSession.getBlockBag(player), player);
|
||||
BlockBag bag = actor instanceof Player ? redoSession.getBlockBag((Player) actor) : null;
|
||||
EditSession redone = redoSession.redo(bag, actor);
|
||||
if (redone != null) {
|
||||
timesRedone++;
|
||||
worldEdit.flushBlockBag(player, redone);
|
||||
worldEdit.flushBlockBag(actor, redone);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (timesRedone > 0) {
|
||||
player.printInfo(TranslatableComponent.of("worldedit.redo.undone", TextComponent.of(timesRedone)));
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.redo.undone", TextComponent.of(timesRedone)));
|
||||
} else {
|
||||
player.printError(TranslatableComponent.of("worldedit.redo.none"));
|
||||
actor.printError(TranslatableComponent.of("worldedit.redo.none"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,6 +218,9 @@ public class BlockTypesCache {
|
||||
values[internalId] = type;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
if (values[i] == null) values[i] = values[0];
|
||||
}
|
||||
|
||||
states = stateList.toArray(new BlockState[stateList.size()]);
|
||||
|
||||
|
Reference in New Issue
Block a user