Update WorldEditPlugin

Dieser Commit ist enthalten in:
MattBDev 2020-08-24 12:54:22 -04:00
Ursprung 034b910d57
Commit 525da53462

Datei anzeigen

@ -3,18 +3,18 @@
* Copyright (C) sk89q <http://www.sk89q.com> * Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors * Copyright (C) WorldEdit team and contributors
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify
* under the terms of the GNU Lesser General Public License as published by the * it under the terms of the GNU General Public License as published by
* Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful,
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * but WITHOUT ANY WARRANTY; without even the implied warranty of
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
@ -50,6 +50,7 @@ import com.sk89q.worldedit.world.block.BlockCategory;
import com.sk89q.worldedit.world.entity.EntityType; import com.sk89q.worldedit.world.entity.EntityType;
import com.sk89q.worldedit.world.gamemode.GameModes; import com.sk89q.worldedit.world.gamemode.GameModes;
import com.sk89q.worldedit.world.item.ItemCategory; import com.sk89q.worldedit.world.item.ItemCategory;
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.weather.WeatherTypes; import com.sk89q.worldedit.world.weather.WeatherTypes;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import org.bstats.bukkit.Metrics; import org.bstats.bukkit.Metrics;
@ -102,6 +103,19 @@ import static com.sk89q.worldedit.internal.anvil.ChunkDeleter.DELCHUNKS_FILE_NAM
*/ */
public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
// This must be before the Logger is initialized, which fails in 1.8
private static final String FAILED_VERSION_CHECK =
"\n**********************************************\n"
+ "** This Minecraft version (%s) is not supported by this version of WorldEdit.\n"
+ "** Please download an OLDER version of WorldEdit which does.\n"
+ "**********************************************\n";
static {
if (PaperLib.getMinecraftVersion() < 13) {
throw new IllegalStateException(String.format(FAILED_VERSION_CHECK, Bukkit.getVersion()));
}
}
private static final Logger log = LoggerFactory.getLogger(WorldEditPlugin.class); private static final Logger log = LoggerFactory.getLogger(WorldEditPlugin.class);
public static final String CUI_PLUGIN_CHANNEL = "worldedit:cui"; public static final String CUI_PLUGIN_CHANNEL = "worldedit:cui";
private static WorldEditPlugin INSTANCE; private static WorldEditPlugin INSTANCE;
@ -234,6 +248,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
} }
} }
//todo consider removing this again because it is better to stay consistent with upstream
// Setup metrics // Setup metrics
if (Settings.IMP.ENABLED_COMPONENTS.BSTATS) { if (Settings.IMP.ENABLED_COMPONENTS.BSTATS) {
new Metrics(this, BSTATS_PLUGIN_ID); new Metrics(this, BSTATS_PLUGIN_ID);
@ -258,6 +273,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent()); WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent());
} }
@SuppressWarnings({ "deprecation", "unchecked" })
private void initializeRegistries() { private void initializeRegistries() {
// Biome // Biome
for (Biome biome : Biome.values()) { for (Biome biome : Biome.values()) {
@ -269,8 +285,9 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
} }
} }
// Block & Item // Block & Item
/*for (Material material : Material.values()) { for (Material material : Material.values()) {
if (material.isBlock() && !material.isLegacy()) { if (material.isBlock() && !material.isLegacy()) {
/*
BlockType.REGISTRY.register(material.getKey().toString(), new BlockType(material.getKey().toString(), blockState -> { BlockType.REGISTRY.register(material.getKey().toString(), new BlockType(material.getKey().toString(), blockState -> {
// TODO Use something way less hacky than this. // TODO Use something way less hacky than this.
ParserContext context = new ParserContext(); ParserContext context = new ParserContext();
@ -292,12 +309,12 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
return blockState; return blockState;
} }
})); }));
*/
} }
if (material.isItem() && !material.isLegacy()) { if (material.isItem() && !material.isLegacy()) {
ItemType.REGISTRY.register(material.getKey().toString(), new ItemType(material.getKey().toString())); ItemType.REGISTRY.register(material.getKey().toString(), new ItemType(material.getKey().toString()));
} }
} }
*/
// Entity // Entity
for (org.bukkit.entity.EntityType entityType : org.bukkit.entity.EntityType.values()) { for (org.bukkit.entity.EntityType entityType : org.bukkit.entity.EntityType.values()) {
String mcid = entityType.getName(); String mcid = entityType.getName();