Fix WorldEdit integration stopping edits

It's been only more than a year, it's fine
This commit is contained in:
Norbi Peti 2021-02-21 00:04:56 +01:00
parent e4548069dc
commit dcd3ff31db
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
4 changed files with 41 additions and 43 deletions

View file

@ -1,13 +1,12 @@
package de.jaschastarke.minecraft.limitedcreative; package de.jaschastarke.minecraft.limitedcreative;
import org.bukkit.Bukkit;
import de.jaschastarke.hooking.BooleanHooker; import de.jaschastarke.hooking.BooleanHooker;
import de.jaschastarke.hooking.GetHooker; import de.jaschastarke.hooking.GetHooker;
import de.jaschastarke.minecraft.limitedcreative.hooks.MultiVerseHooks; import de.jaschastarke.minecraft.limitedcreative.hooks.MultiVerseHooks;
import de.jaschastarke.minecraft.limitedcreative.hooks.PlayerCheckHooker; import de.jaschastarke.minecraft.limitedcreative.hooks.PlayerCheckHooker;
import de.jaschastarke.minecraft.limitedcreative.hooks.WorldTypeHooker; import de.jaschastarke.minecraft.limitedcreative.hooks.WorldTypeHooker;
import de.jaschastarke.minecraft.limitedcreative.hooks.xAuthHooks; import de.jaschastarke.minecraft.limitedcreative.hooks.xAuthHooks;
import org.bukkit.Bukkit;
public final class Hooks { public final class Hooks {
public static PlayerCheckHooker IsLoggedIn = new PlayerCheckHooker(true); public static PlayerCheckHooker IsLoggedIn = new PlayerCheckHooker(true);
@ -53,7 +52,8 @@ public final class Hooks {
public static boolean isAuthMePresent() { public static boolean isAuthMePresent() {
if (isPluginEnabled("AuthMe")) { if (isPluginEnabled("AuthMe")) {
try { try {
return Class.forName("uk.org.whoami.authme.api.API") != null; Class.forName("uk.org.whoami.authme.api.API");
return true;
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
return false; return false;
} }
@ -64,7 +64,8 @@ public final class Hooks {
public static boolean isXAuth20Present() { public static boolean isXAuth20Present() {
if (isPluginEnabled("xAuth")) { if (isPluginEnabled("xAuth")) {
try { try {
return Class.forName("com.cypherx.xauth.xAuth") != null; Class.forName("com.cypherx.xauth.xAuth");
return true;
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
return false; return false;
} }

View file

@ -28,7 +28,6 @@ public class ModInventories extends CoreModule<LimitedCreative> {
return "Inventory"; return "Inventory";
} }
@SuppressWarnings("deprecation")
@Override @Override
public void initialize(ModuleEntry<IModule> entry) { public void initialize(ModuleEntry<IModule> entry) {
super.initialize(entry); super.initialize(entry);

View file

@ -166,44 +166,41 @@ public class BlockStateCommand extends BukkitCommand implements IHelpDescribed {
final BlockVector3 min = selection.getMinimumPoint(); final BlockVector3 min = selection.getMinimumPoint();
final BlockVector3 max = selection.getMaximumPoint(); final BlockVector3 max = selection.getMaximumPoint();
mod.getPlugin().getServer().getScheduler().runTaskAsynchronously(mod.getPlugin(), new Runnable() { mod.getPlugin().getServer().getScheduler().runTaskAsynchronously(mod.getPlugin(), () -> {
@Override if (mod.isDebug())
public void run() { mod.getLog().debug("Scheduler: Asynchronous Task run");
if (mod.isDebug()) DBTransaction update = mod.getModel().groupUpdate();
mod.getLog().debug("Scheduler: Asynchronous Task run"); int count = 0;
DBTransaction update = mod.getModel().groupUpdate(); World w = selection.getWorld();
int count = 0; assert w != null;
World w = selection.getWorld(); org.bukkit.World bw = BukkitAdapter.adapt(w);
assert w != null;
org.bukkit.World bw = BukkitAdapter.adapt(w); Cuboid c = new Cuboid();
c.add(new Location(bw, min.getBlockX(), min.getBlockY(), min.getBlockZ()));
Cuboid c = new Cuboid(); c.add(new Location(bw, max.getBlockX(), max.getBlockY(), max.getBlockZ()));
c.add(new Location(bw, min.getBlockX(), min.getBlockY(), min.getBlockZ())); mod.getModel().cacheStates(c);
c.add(new Location(bw, max.getBlockX(), max.getBlockY(), max.getBlockZ()));
mod.getModel().cacheStates(c); BlockState seed = new BlockState();
seed.setPlayer(context.getPlayer());
BlockState seed = new BlockState(); seed.setGameMode(tgm);
seed.setPlayer(context.getPlayer()); seed.setSource(Source.COMMAND);
seed.setGameMode(tgm); seed.setDate(new Date());
seed.setSource(Source.COMMAND); for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
seed.setDate(new Date()); for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) { for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) { BlockVector3 loc = BlockVector3.at(x, y, z);
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) { if (!w.getBlock(loc).getBlockType().getMaterial().isAir() && selection.contains(loc)) {
BlockVector3 loc = BlockVector3.at(x, y, z); seed.setLocation(new Location(bw, x, y, z));
if (!w.getBlock(loc).getBlockType().getMaterial().isAir() && selection.contains(loc)) { update.setState(new BlockState(seed));
seed.setLocation(new Location(bw, x, y, z)); count++;
update.setState(new BlockState(seed));
count++;
}
} }
} }
} }
update.finish();
context.response(L("command.blockstate.command_updated", count));
} }
update.finish();
context.response(L("command.blockstate.command_updated", count));
}); });
return true; return true;
} }

View file

@ -18,7 +18,7 @@ public class EditSessionExtent extends AbstractDelegateExtent {
private ModBlockStates mod; private ModBlockStates mod;
private Player player = null; private Player player = null;
private World world; private World world;
public EditSessionExtent(Extent extent, ModBlockStates mod, Player player, World world) { public EditSessionExtent(Extent extent, ModBlockStates mod, Player player, World world) {
super(extent); super(extent);
this.mod = mod; this.mod = mod;
@ -29,13 +29,13 @@ public class EditSessionExtent extends AbstractDelegateExtent {
/** /**
* Called when a block is being changed. * Called when a block is being changed.
* *
* @param pt the position * @param pt the position
* @param newBlock the new block to replace the old one * @param newBlock the new block to replace the old one
*/ */
@Override @Override
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 pt, T newBlock) throws WorldEditException { public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 pt, T newBlock) throws WorldEditException {
if (mod.isDebug()) if (mod.isDebug())
mod.getLog().debug("WorldEdit-Integration: BlockChange: "+pt.toString()+" BB: " + newBlock.toString()); mod.getLog().debug("WorldEdit-Integration: BlockChange: " + pt.toString() + " BB: " + newBlock.toString());
Location loc = new Location(world, pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); Location loc = new Location(world, pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
if (newBlock.getBlockType().getMaterial().isAir()) { if (newBlock.getBlockType().getMaterial().isAir()) {
mod.getModel().removeState(loc.getBlock()); mod.getModel().removeState(loc.getBlock());
@ -51,9 +51,10 @@ public class EditSessionExtent extends AbstractDelegateExtent {
s.setSource(Source.EDIT); s.setSource(Source.EDIT);
if (mod.isDebug()) if (mod.isDebug())
mod.getLog().debug("WorldEdit-Integration: Saving BlockState: " + s.toString()); mod.getLog().debug("WorldEdit-Integration: Saving BlockState: " + s.toString());
mod.getModel().setState(s); mod.getModel().setState(s);
} }
super.setBlock(pt, newBlock);
return true; return true;
} }
} }