Dieser Commit ist enthalten in:
N0tMyFaultOG 2020-08-14 05:59:49 -04:00 committet von MattBDev
Ursprung cfb1510503
Commit bbff5c60b2
2 geänderte Dateien mit 59 neuen und 26 gelöschten Zeilen

Datei anzeigen

@ -22,7 +22,7 @@ package com.sk89q.worldedit.bukkit;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.bukkit.FaweBukkit;
import com.sk89q.worldedit.bukkit.adapter.impl.FAWE_Spigot_v1_14_R4;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.util.MainUtil;
import com.google.common.base.Joiner;
import com.sk89q.util.yaml.YAMLProcessor;
@ -33,6 +33,7 @@ import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.adapter.AdapterLoadException;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplLoader;
import com.sk89q.worldedit.bukkit.adapter.impl.FAWE_Spigot_v1_14_R4;
import com.sk89q.worldedit.bukkit.adapter.impl.FAWE_Spigot_v1_15_R2;
import com.sk89q.worldedit.bukkit.adapter.impl.FAWE_Spigot_v1_16_R1;
import com.sk89q.worldedit.event.platform.CommandEvent;
@ -42,8 +43,8 @@ import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.internal.command.CommandUtil;
import com.sk89q.worldedit.internal.anvil.ChunkDeleter;
import com.sk89q.worldedit.internal.command.CommandUtil;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockCategory;
import com.sk89q.worldedit.world.entity.EntityType;
@ -51,9 +52,6 @@ import com.sk89q.worldedit.world.gamemode.GameModes;
import com.sk89q.worldedit.world.item.ItemCategory;
import com.sk89q.worldedit.world.weather.WeatherTypes;
import io.papermc.lib.PaperLib;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@ -75,22 +73,25 @@ import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.java.JavaPluginLoader;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import static com.google.common.base.Preconditions.checkNotNull;
@ -112,6 +113,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
private BukkitConfiguration config;
private static Map<String, Plugin> lookupNames;
static {
// Disable AWE as otherwise both fail to load
PluginManager manager = Bukkit.getPluginManager();
@ -142,7 +144,8 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
return super.put(key, plugin);
}
});
} catch (Throwable ignore) {}
} catch (Throwable ignored) {
}
}
public WorldEditPlugin() {
@ -167,7 +170,9 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
@Override
public void onLoad() {
if (INSTANCE != null) return;
if (INSTANCE != null) {
return;
}
rename();
INSTANCE = this;
FaweBukkit imp = new FaweBukkit(this);
@ -185,8 +190,8 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
if (Files.exists(delChunks)) {
ChunkDeleter.runFromFile(delChunks, true);
}
fail(() -> PermissionsResolverManager.initialize(INSTANCE), "Failed to initialize permissions resolver");
fail(() -> PermissionsResolverManager.initialize(INSTANCE), "Failed to initialize permissions resolver");
}
/**
@ -194,15 +199,17 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
*/
@Override
public void onEnable() {
if (INSTANCE != null) return;
if (INSTANCE != null) {
return;
}
onLoad();
PermissionsResolverManager.initialize(this); // Setup permission resolver
// Register CUI
fail(() -> {
getServer().getMessenger().registerIncomingPluginChannel(this, CUI_PLUGIN_CHANNEL, new CUIChannelListener(this));
getServer().getMessenger().registerOutgoingPluginChannel(this, CUI_PLUGIN_CHANNEL);
getServer().getMessenger().registerIncomingPluginChannel(this, CUI_PLUGIN_CHANNEL, new CUIChannelListener(this));
getServer().getMessenger().registerOutgoingPluginChannel(this, CUI_PLUGIN_CHANNEL);
}, "Failed to register CUI");
// Now we can register events
@ -227,8 +234,15 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
}
}
// Enable metrics
new Metrics(this, BSTATS_PLUGIN_ID);
// Setup metrics
if (Settings.IMP.ENABLED_COMPONENTS.BSTATS) {
new Metrics(this, BSTATS_PLUGIN_ID);
} else {
getLogger().warning("bStats is disabled. Please enable it in /plugins/FastAsyncWorldEdit/config.yml. It helps the developers to identify the features most used");
getLogger().warning("and organize future updates better. Cheers.");
}
// Suggest PaperMC
PaperLib.suggestPaper(this);
}
@ -248,8 +262,11 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
// Biome
for (Biome biome : Biome.values()) {
String lowerCaseBiomeName = biome.name().toLowerCase(Locale.ROOT);
BiomeType biomeType = BiomeType.REGISTRY.register("minecraft:" + lowerCaseBiomeName, new BiomeType("minecraft:" + lowerCaseBiomeName));
if (bukkitAdapter != null) biomeType.setLegacyId(bukkitAdapter.getInternalBiomeId(biomeType));
BiomeType biomeType = BiomeType.REGISTRY.register(
"minecraft:" + lowerCaseBiomeName, new BiomeType("minecraft:" + lowerCaseBiomeName));
if (bukkitAdapter != null) {
biomeType.setLegacyId(bukkitAdapter.getInternalBiomeId(biomeType));
}
}
// Block & Item
/*for (Material material : Material.values()) {
@ -321,7 +338,9 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
File pluginsFolder = MainUtil.getJarFile().getParentFile();
for (File file : pluginsFolder.listFiles()) {
if (file.length() == 2052) return;
if (file.length() == 2052) {
return;
}
}
Plugin plugin = Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit");
File dummy = MainUtil.copyFile(MainUtil.getJarFile(), "DummyFawe.src", pluginsFolder, "DummyFawe.jar");
@ -396,9 +415,9 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
if (platform instanceof BukkitServerInterface) {
log.warn(e.getMessage());
} else {
log.info("WorldEdit could not find a Bukkit adapter for this MC version, " +
"but it seems that you have another implementation of WorldEdit installed (" + platform.getPlatformName() + ") " +
"that handles the world editing.");
log.info("WorldEdit could not find a Bukkit adapter for this MC version, "
+ "but it seems that you have another implementation of WorldEdit installed (" + platform.getPlatformName() + ") "
+ "that handles the world editing.");
}
}
}
@ -439,7 +458,9 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
File actual = new File(getDataFolder(), name);
if (!actual.exists()) {
try (InputStream stream = getResource("defaults/" + name)) {
if (stream == null) throw new FileNotFoundException();
if (stream == null) {
throw new FileNotFoundException();
}
copyDefaultConfig(stream, actual, name);
} catch (IOException e) {
getLogger().severe("Unable to read default configuration: " + name);
@ -630,9 +651,12 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
private class WorldInitListener implements Listener {
private boolean loaded = false;
@EventHandler(priority = EventPriority.LOWEST)
public void onWorldInit(@SuppressWarnings("unused") WorldInitEvent event) {
if (loaded) return;
if (loaded) {
return;
}
loaded = true;
setupWorldData();
}
@ -645,17 +669,23 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
@SuppressWarnings("UnnecessaryFullyQualifiedName")
@EventHandler(ignoreCancelled = true)
public void onAsyncTabComplete(com.destroystokyo.paper.event.server.AsyncTabCompleteEvent event) {
if (!event.isCommand()) return;
if (!event.isCommand()) {
return;
}
String buffer = event.getBuffer();
int firstSpace = buffer.indexOf(' ');
if (firstSpace < 0) return;
if (firstSpace < 0) {
return;
}
String label = buffer.substring(0, firstSpace);
// Strip leading slash, if present.
label = label.startsWith("/") ? label.substring(1) : label;
final Optional<org.enginehub.piston.Command> command
= WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getCommandManager().getCommand(label);
if (!command.isPresent()) return;
if (!command.isPresent()) {
return;
}
CommandSuggestionEvent suggestEvent = new CommandSuggestionEvent(wrapCommandSender(event.getSender()), buffer);
getWorldEdit().getEventBus().post(suggestEvent);

Datei anzeigen

@ -80,6 +80,9 @@ public class Settings extends Config {
"Specific aspects can be turned on and off further below"
})
public boolean PLOTSQUARED_HOOK = true;
@Comment({"Send anonymous FAWE statistics to https://bstats.org/.",
"Please keep this setting enabled. It helps us identifying which parts of FAWE are used the most to organize future updates better."})
public boolean BSTATS = true;
}
@Comment("Paths for various directories")