Fixes language option and Fixes #633
This commit is contained in:
parent
03b4aaad3c
commit
f20a1002bb
@ -1,7 +1,12 @@
|
||||
package com.boydti.fawe.bukkit;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URL;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -49,6 +54,25 @@ public class BukkitMain extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (Bukkit.getPluginManager().getPlugin("WorldEdit") == null) {
|
||||
try {
|
||||
File output = new File(this.getDataFolder().getParentFile(), "WorldEdit.jar");
|
||||
URL worldEditUrl = new URL("https://addons.cursecdn.com/files/2431/372/worldedit-bukkit-6.1.7.2.jar");
|
||||
try (ReadableByteChannel rbc = Channels.newChannel(worldEditUrl.openStream())) {
|
||||
try (FileOutputStream fos = new FileOutputStream(output)) {
|
||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
Bukkit.getPluginManager().loadPlugin(output);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
Fawe.debug("====== INSTALL WORLDEDIT ======");
|
||||
Fawe.debug("FAWE requires WorldEdit to function correctly");
|
||||
Fawe.debug("Info: https://github.com/boy0001/FastAsyncWorldedit/releases/");
|
||||
Fawe.debug("===============================");
|
||||
return;
|
||||
}
|
||||
}
|
||||
FaweBukkit imp = new FaweBukkit(this);
|
||||
}
|
||||
}
|
@ -36,13 +36,9 @@ import com.sk89q.worldedit.bukkit.EditSessionBlockChangeDelegate;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.net.URL;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -112,25 +108,6 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
}
|
||||
|
||||
public void setupInjector() {
|
||||
if (Bukkit.getPluginManager().getPlugin("WorldEdit") == null) {
|
||||
try {
|
||||
File output = new File(getDirectory().getParentFile(), "WorldEdit.jar");
|
||||
URL worldEditUrl = new URL("http://builds.enginehub.org/job/worldedit/9819/download/worldedit-bukkit-6.1.8-SNAPSHOT-dist.jar");
|
||||
try (ReadableByteChannel rbc = Channels.newChannel(worldEditUrl.openStream())) {
|
||||
try (FileOutputStream fos = new FileOutputStream(output)) {
|
||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
Bukkit.getPluginManager().loadPlugin(output);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
Fawe.debug("====== INSTALL WORLDEDIT ======");
|
||||
Fawe.debug("FAWE requires WorldEdit to function correctly");
|
||||
Fawe.debug("Info: https://github.com/boy0001/FastAsyncWorldedit/releases/");
|
||||
Fawe.debug("===============================");
|
||||
return;
|
||||
}
|
||||
}
|
||||
Fawe.setupInjector();
|
||||
// Inject
|
||||
EditSessionBlockChangeDelegate.inject();
|
||||
|
@ -176,6 +176,7 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
setupAdapter = false;
|
||||
Fawe.debug("====== NO NATIVE WORLDEDIT ADAPTER ======");
|
||||
e.printStackTrace();
|
||||
Fawe.debug("Try updating WorldEdit: ");
|
||||
|
@ -78,7 +78,7 @@ public class BukkitChunk_1_12 extends CharFaweChunk<Chunk, BukkitQueue_1_12> {
|
||||
}
|
||||
|
||||
public boolean storeEntity(Entity ent) throws InvocationTargetException, IllegalAccessException {
|
||||
if (ent instanceof EntityPlayer) {
|
||||
if (ent instanceof EntityPlayer || BukkitQueue_0.adapter == null) {
|
||||
return false;
|
||||
}
|
||||
int x = ((int) Math.round(ent.locX) & 15);
|
||||
@ -90,7 +90,7 @@ public class BukkitChunk_1_12 extends CharFaweChunk<Chunk, BukkitQueue_1_12> {
|
||||
if (id != null) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
ent.save(tag); // readEntityIntoTag
|
||||
CompoundTag nativeTag = (CompoundTag) getParent().methodToNative.invoke(getParent().adapter, tag);
|
||||
CompoundTag nativeTag = (CompoundTag) BukkitQueue_0.methodToNative.invoke(getParent().adapter, tag);
|
||||
Map<String, Tag> map = ReflectionUtils.getMap(nativeTag.getValue());
|
||||
map.put("Id", new StringTag(id));
|
||||
setEntity(nativeTag);
|
||||
|
@ -143,6 +143,7 @@ import java.lang.management.MemoryUsage;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -419,8 +420,8 @@ public class Fawe {
|
||||
}
|
||||
|
||||
public void setupConfigs() {
|
||||
MainUtil.copyFile(MainUtil.getJarFile(), "de/messages.yml", null);
|
||||
MainUtil.copyFile(MainUtil.getJarFile(), "ru/messages.yml", null);
|
||||
MainUtil.copyFile(MainUtil.getJarFile(), "de/message.yml", null);
|
||||
MainUtil.copyFile(MainUtil.getJarFile(), "ru/message.yml", null);
|
||||
MainUtil.copyFile(MainUtil.getJarFile(), "ru/commands.yml", null);
|
||||
// Setting up config.yml
|
||||
File file = new File(this.IMP.getDirectory(), "config.yml");
|
||||
@ -437,9 +438,11 @@ public class Fawe {
|
||||
} catch (Throwable ignore) {}
|
||||
Settings.IMP.reload(file);
|
||||
// Setting up message.yml
|
||||
BBC.load(new File(this.IMP.getDirectory(), "message.yml"));
|
||||
String lang = Objects.toString(Settings.IMP.LANGUAGE);
|
||||
BBC.load(new File(this.IMP.getDirectory(), (lang.isEmpty() ? "" : lang + File.separator) + "message.yml"));
|
||||
}
|
||||
|
||||
|
||||
public WorldEdit getWorldEdit() {
|
||||
return WorldEdit.getInstance();
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.bukkit.BukkitCommand;
|
||||
import com.boydti.fawe.object.FaweCommand;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.thevoxelbox.voxelsniper.RangeBlockHelper;
|
||||
import com.thevoxelbox.voxelsniper.SnipeData;
|
||||
import com.thevoxelbox.voxelsniper.Sniper;
|
||||
@ -21,18 +22,32 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Favs extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
try {
|
||||
if (Bukkit.getPluginManager().getPlugin("VoxelSniper") == null) {
|
||||
try {
|
||||
File output = new File(this.getDataFolder().getParentFile(), "VoxelSniper.jar");
|
||||
File thisFile = MainUtil.getJarFile();
|
||||
String thisName = thisFile.getName().toLowerCase();
|
||||
File output = null;
|
||||
for (File file : getDataFolder().getParentFile().listFiles()) {
|
||||
String name = file.getName().toLowerCase();
|
||||
if (name.endsWith(".jar") && name.contains("voxelsniper") && !name.contains("fastasyncvoxelsniper")) {
|
||||
output = file;
|
||||
System.out.println("File " + file + " | " + thisName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (output == null) {
|
||||
output = new File(this.getDataFolder().getParentFile(), "VoxelSniper.jar");
|
||||
URL worldEditUrl = new URL("https://addons-origin.cursecdn.com/files/912/511/VoxelSniper-5.171.0-SNAPSHOT.jar");
|
||||
try (ReadableByteChannel rbc = Channels.newChannel(worldEditUrl.openStream())) {
|
||||
try (FileOutputStream fos = new FileOutputStream(output)) {
|
||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
Bukkit.getPluginManager().loadPlugin(output);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
|
@ -0,0 +1,30 @@
|
||||
package com.boydti.fawe.bukkit.favs;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.thevoxelbox.voxelsniper.SnipeData;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PatternUtil {
|
||||
public static Pattern parsePattern(Player player, SnipeData snipeData, String arg) {
|
||||
ParserContext context = new ParserContext();
|
||||
FawePlayer<Object> fp = FawePlayer.wrap(player);
|
||||
context.setActor(fp.getPlayer());
|
||||
context.setWorld(fp.getWorld());
|
||||
context.setSession(fp.getSession());
|
||||
try {
|
||||
Pattern pattern = WorldEdit.getInstance().getPatternFactory().parseFromInput(arg, context);
|
||||
snipeData.setPattern(pattern, arg);
|
||||
snipeData.sendMessage(ChatColor.GOLD + "Voxel: " + ChatColor.RED + arg);
|
||||
return pattern;
|
||||
} catch (InputParseException e) {
|
||||
fp.sendMessage(BBC.getPrefix() + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -5,19 +5,12 @@
|
||||
|
||||
package com.thevoxelbox.voxelsniper.command;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.boydti.fawe.bukkit.favs.PatternUtil;
|
||||
import com.thevoxelbox.voxelsniper.RangeBlockHelper;
|
||||
import com.thevoxelbox.voxelsniper.SnipeData;
|
||||
import com.thevoxelbox.voxelsniper.Sniper;
|
||||
import com.thevoxelbox.voxelsniper.VoxelSniper;
|
||||
import com.thevoxelbox.voxelsniper.api.command.VoxelCommand;
|
||||
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -59,18 +52,7 @@ public class VoxelVoxelCommand extends VoxelCommand {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
ParserContext context = new ParserContext();
|
||||
FawePlayer<Object> fp = FawePlayer.wrap(player);
|
||||
context.setActor(fp.getPlayer());
|
||||
context.setWorld(fp.getWorld());
|
||||
context.setSession(fp.getSession());
|
||||
try {
|
||||
Pattern pattern = WorldEdit.getInstance().getPatternFactory().parseFromInput(args[0], context);
|
||||
snipeData.setPattern(pattern, args[0]);
|
||||
snipeData.sendMessage(ChatColor.GOLD + "Voxel: " + ChatColor.RED + args[0]);
|
||||
} catch (InputParseException e) {
|
||||
fp.sendMessage(BBC.getPrefix() + e.getMessage());
|
||||
}
|
||||
PatternUtil.parsePattern(player, snipeData, args[0]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user