mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
reduce diff
This commit is contained in:
@ -182,7 +182,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
@Override
|
||||
public void printError(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
player.sendMessage("§c" + part);
|
||||
player.sendMessage("\u00A7c" + part);
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,18 +226,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String perm) {
|
||||
return (!plugin.getLocalConfiguration().noOpPermissions && player.isOp())
|
||||
|| plugin.getPermissionsResolver().hasPermission(player.getWorld().getName(), player, perm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowedToFly() {
|
||||
return player.getAllowFlight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlying(boolean flying) {
|
||||
player.setFlying(flying);
|
||||
return (!plugin.getLocalConfiguration().noOpPermissions && player.isOp());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -272,14 +261,14 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
player.sendPluginMessage(plugin, WorldEditPlugin.CUI_PLUGIN_CHANNEL, send.getBytes(CUIChannelListener.UTF_8_CHARSET));
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
if (!player.isValid()) {
|
||||
Player tmp = Bukkit.getPlayer(getUniqueId());
|
||||
if (tmp != null) {
|
||||
player = tmp;
|
||||
}
|
||||
}
|
||||
return player;
|
||||
@Override
|
||||
public boolean isAllowedToFly() {
|
||||
return player.getAllowFlight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlying(boolean flying) {
|
||||
player.setFlying(flying);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -311,7 +300,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
|
||||
@Override
|
||||
public SessionKey getSessionKey() {
|
||||
return new SessionKeyImpl(getUniqueId(), getName());
|
||||
return new SessionKeyImpl(this.player.getUniqueId(), player.getName());
|
||||
}
|
||||
|
||||
private static class SessionKeyImpl implements SessionKey {
|
||||
@ -382,4 +371,14 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
public void unregister() {
|
||||
player.removeMetadata("WE", WorldEditPlugin.getInstance());
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
if (!player.isValid()) {
|
||||
Player tmp = Bukkit.getPlayer(getUniqueId());
|
||||
if (tmp != null) {
|
||||
player = tmp;
|
||||
}
|
||||
}
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ public class BukkitServerInterface implements MultiUserPlatform {
|
||||
|
||||
@Override
|
||||
public String getPlatformName() {
|
||||
return "Bukkit";
|
||||
return "Bukkit-Official";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -190,48 +190,50 @@ public class BukkitWorld extends AbstractWorld {
|
||||
|
||||
@Override
|
||||
public boolean regenerate(Region region, EditSession editSession) {
|
||||
/*
|
||||
BaseBlock[] history = new BaseBlock[16 * 16 * (getMaxY() + 1)];
|
||||
|
||||
for (BlockVector2 chunk : region.getChunks()) {
|
||||
BlockVector3 min = BlockVector3.at(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
|
||||
|
||||
// First save all the blocks inside
|
||||
for (int x = 0; x < 16; ++x) {
|
||||
for (int y = 0; y < (getMaxY() + 1); ++y) {
|
||||
for (int z = 0; z < 16; ++z) {
|
||||
BlockVector3 pt = min.add(x, y, z);
|
||||
int index = y * 16 * 16 + z * 16 + x;
|
||||
history[index] = editSession.getFullBlock(pt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
getWorld().regenerateChunk(chunk.getBlockX(), chunk.getBlockZ());
|
||||
} catch (Throwable t) {
|
||||
logger.warn("Chunk generation via Bukkit raised an error", t);
|
||||
}
|
||||
|
||||
// Then restore
|
||||
for (int x = 0; x < 16; ++x) {
|
||||
for (int y = 0; y < (getMaxY() + 1); ++y) {
|
||||
for (int z = 0; z < 16; ++z) {
|
||||
BlockVector3 pt = min.add(x, y, z);
|
||||
int index = y * 16 * 16 + z * 16 + x;
|
||||
|
||||
// We have to restore the block if it was outside
|
||||
if (!region.contains(pt)) {
|
||||
editSession.smartSetBlock(pt, history[index]);
|
||||
} else { // Otherwise fool with history
|
||||
editSession.getChangeSet().add(new BlockChange(pt, history[index], editSession.getFullBlock(pt)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
*/
|
||||
return editSession.regenerate(region);
|
||||
// BaseBlock[] history = new BaseBlock[16 * 16 * (getMaxY() + 1)];
|
||||
//
|
||||
// for (BlockVector2 chunk : region.getChunks()) {
|
||||
// BlockVector3 min = BlockVector3.at(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
|
||||
//
|
||||
// // First save all the blocks inside
|
||||
// for (int x = 0; x < 16; ++x) {
|
||||
// for (int y = 0; y < (getMaxY() + 1); ++y) {
|
||||
// for (int z = 0; z < 16; ++z) {
|
||||
// BlockVector3 pt = min.add(x, y, z);
|
||||
// int index = y * 16 * 16 + z * 16 + x;
|
||||
// history[index] = editSession.getFullBlock(pt);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// getWorld().regenerateChunk(chunk.getBlockX(), chunk.getBlockZ());
|
||||
// } catch (Throwable t) {
|
||||
// logger.warn("Chunk generation via Bukkit raised an error", t);
|
||||
// }
|
||||
//
|
||||
// // Then restore
|
||||
// for (int x = 0; x < 16; ++x) {
|
||||
// for (int y = 0; y < (getMaxY() + 1); ++y) {
|
||||
// for (int z = 0; z < 16; ++z) {
|
||||
// BlockVector3 pt = min.add(x, y, z);
|
||||
// int index = y * 16 * 16 + z * 16 + x;
|
||||
//
|
||||
// // We have to restore the block if it was outside
|
||||
// if (!region.contains(pt)) {
|
||||
// editSession.smartSetBlock(pt, history[index]);
|
||||
// } else { // Otherwise fool with history
|
||||
// editSession.getChangeSet().add(new BlockChange(pt, history[index], editSession.getFullBlock(pt)));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -514,28 +516,38 @@ public class BukkitWorld extends AbstractWorld {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useItem(BlockVector3 position, BaseItem item, Direction face) {
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
if (adapter != null) {
|
||||
return adapter.simulateItemUse(getWorld(), position, item, face);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return BukkitAdapter.adapt(getWorld().getBiome(position.getBlockX(), position.getBlockZ()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
|
||||
throws WorldEditException {
|
||||
return setBlock(BlockVector3.at(x,y,z), block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
getWorld().setBiome(position.getBlockX(), position.getBlockZ(), BukkitAdapter.adapt(biome));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
|
||||
throws WorldEditException {
|
||||
return setBlock(BlockVector3.at(x,y,z), block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
return setBiome(BlockVector2.at(x,z), biome);
|
||||
@ -556,14 +568,4 @@ public class BukkitWorld extends AbstractWorld {
|
||||
org.bukkit.entity.Player bukkitPlayer = BukkitAdapter.adapt(player);
|
||||
WorldEditPlugin.getInstance().getBukkitImplAdapter().sendFakeChunk(getWorld(), bukkitPlayer, packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useItem(BlockVector3 position, BaseItem item, Direction face) {
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
if (adapter != null) {
|
||||
return adapter.simulateItemUse(getWorld(), position, item, face);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ import java.nio.charset.StandardCharsets;
|
||||
*/
|
||||
public class CUIChannelListener implements PluginMessageListener {
|
||||
|
||||
public static final Charset UTF_8_CHARSET = StandardCharsets.UTF_8;
|
||||
public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8");
|
||||
private final WorldEditPlugin plugin;
|
||||
|
||||
public CUIChannelListener(WorldEditPlugin plugin) {
|
||||
|
@ -341,20 +341,6 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public List<String> onTabComplete(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
// // Add the command to the array because the underlying command handling
|
||||
// // code of WorldEdit expects it
|
||||
// String[] split = new String[args.length + 1];
|
||||
// System.arraycopy(args, 0, split, 1, args.length);
|
||||
// split[0] = commandLabel;
|
||||
//
|
||||
// String arguments = Joiner.on(" ").join(split);
|
||||
// CommandSuggestionEvent event = new CommandSuggestionEvent(wrapCommandSender(sender), arguments);
|
||||
// getWorldEdit().getEventBus().post(event);
|
||||
// return CommandUtil.fixSuggestions(arguments, event.getSuggestions());
|
||||
// }
|
||||
|
||||
private void fail(Runnable run, String message) {
|
||||
try {
|
||||
run.run();
|
||||
@ -430,6 +416,22 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
||||
this.getServer().getScheduler().cancelTasks(this);
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
// Add the command to the array because the underlying command handling
|
||||
// code of WorldEdit expects it
|
||||
String[] split = new String[args.length + 1];
|
||||
System.arraycopy(args, 0, split, 1, args.length);
|
||||
split[0] = commandLabel;
|
||||
|
||||
String arguments = Joiner.on(" ").join(split);
|
||||
CommandSuggestionEvent event = new CommandSuggestionEvent(wrapCommandSender(sender), arguments);
|
||||
getWorldEdit().getEventBus().post(event);
|
||||
return CommandUtil.fixSuggestions(arguments, event.getSuggestions());
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Loads and reloads all configuration.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user