mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
Fix metrics
This commit is contained in:
parent
cfb1510503
commit
bbff5c60b2
@ -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);
|
||||
@ -194,7 +199,9 @@ 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
|
||||
@ -227,8 +234,15 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
||||
}
|
||||
}
|
||||
|
||||
// Enable metrics
|
||||
// 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);
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user