From b4bda6bfaf992df26815802d51ba5eb8ccfbfc3d Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Wed, 15 Aug 2018 12:49:25 +1000 Subject: [PATCH] NEEDS LATEST WORLDEDIT - Moved report framework to WorldEdit, and made most config values be accessible without the BukkitWorldGuardWorldConfiguration --- .../config/ConfigurationManager.java | 2 +- .../worldguard/config/WorldConfiguration.java | 100 +++++++++- .../config/YamlConfigurationManager.java | 2 +- .../config/YamlWorldConfiguration.java | 2 +- .../util/profiler/SamplerBuilder.java | 21 +- .../util/profiler/StackTraceNode.java | 8 +- .../util/profiler/ThreadIdFilter.java | 5 +- .../util/profiler/ThreadNameFilter.java | 5 +- .../worldguard}/util/report/ConfigReport.java | 24 +-- .../worldguard/util/report/DataReport.java | 177 ----------------- .../worldguard/util/report/RegionReport.java | 1 + .../sk89q/worldguard/util/report/Report.java | 26 --- .../worldguard/util/report/ReportList.java | 186 ------------------ .../util/report/ShallowObjectReport.java | 58 ------ .../util/report/StackTraceReport.java | 64 ------ .../util/report/SystemInfoReport.java | 91 --------- .../worldguard/util/report/Unreported.java | 33 ---- .../bukkit/BukkitConfigurationManager.java | 2 +- .../bukkit/BukkitWorldConfiguration.java | 113 +---------- .../bukkit/commands/WorldGuardCommands.java | 30 ++- .../listener/RegionProtectionListener.java | 2 +- .../bukkit/util/report/CancelReport.java | 4 +- .../bukkit/util/report/PerformanceReport.java | 2 +- .../bukkit/util/report/PluginReport.java | 2 +- .../bukkit/util/report/SchedulerReport.java | 11 +- .../bukkit/util/report/ServerReport.java | 2 +- .../bukkit/util/report/ServicesReport.java | 4 +- .../bukkit/util/report/WorldReport.java | 2 +- 28 files changed, 170 insertions(+), 809 deletions(-) rename {worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit => worldguard-core/src/main/java/com/sk89q/worldguard}/util/report/ConfigReport.java (79%) delete mode 100644 worldguard-core/src/main/java/com/sk89q/worldguard/util/report/DataReport.java delete mode 100644 worldguard-core/src/main/java/com/sk89q/worldguard/util/report/Report.java delete mode 100644 worldguard-core/src/main/java/com/sk89q/worldguard/util/report/ReportList.java delete mode 100644 worldguard-core/src/main/java/com/sk89q/worldguard/util/report/ShallowObjectReport.java delete mode 100644 worldguard-core/src/main/java/com/sk89q/worldguard/util/report/StackTraceReport.java delete mode 100644 worldguard-core/src/main/java/com/sk89q/worldguard/util/report/SystemInfoReport.java delete mode 100644 worldguard-core/src/main/java/com/sk89q/worldguard/util/report/Unreported.java diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/config/ConfigurationManager.java b/worldguard-core/src/main/java/com/sk89q/worldguard/config/ConfigurationManager.java index d2c1159b2..7d6ce7970 100644 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/config/ConfigurationManager.java +++ b/worldguard-core/src/main/java/com/sk89q/worldguard/config/ConfigurationManager.java @@ -25,7 +25,7 @@ import com.sk89q.worldguard.protection.managers.storage.DriverType; import com.sk89q.worldguard.protection.managers.storage.RegionDriver; import com.sk89q.worldguard.session.handler.WaterBreathing; -import com.sk89q.worldguard.util.report.Unreported; +import com.sk89q.worldedit.util.report.Unreported; import java.io.File; import java.util.HashMap; diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/config/WorldConfiguration.java b/worldguard-core/src/main/java/com/sk89q/worldguard/config/WorldConfiguration.java index a7faa7c44..6410e640a 100644 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/config/WorldConfiguration.java +++ b/worldguard-core/src/main/java/com/sk89q/worldguard/config/WorldConfiguration.java @@ -19,12 +19,15 @@ package com.sk89q.worldguard.config; +import com.sk89q.worldedit.world.entity.EntityType; import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldguard.blacklist.Blacklist; -import com.sk89q.worldguard.util.report.Unreported; +import com.sk89q.worldedit.util.report.Unreported; import java.io.File; import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.logging.Logger; import java.util.stream.Collectors; @@ -59,6 +62,101 @@ public abstract class WorldConfiguration { public boolean simulateSponge; public int spongeRadius; public boolean redstoneSponges; + public boolean summaryOnStart; + public boolean opPermissions; + public boolean buildPermissions; + public String buildPermissionDenyMessage = ""; + public boolean fireSpreadDisableToggle; + public boolean itemDurability; + public boolean disableExpDrops; + public boolean blockPotionsAlways; + public boolean pumpkinScuba; + public boolean noPhysicsGravel; + public boolean noPhysicsSand; + public boolean ropeLadders; + public boolean allowPortalAnywhere; + public Set preventWaterDamage; + public boolean blockLighter; + public boolean disableFireSpread; + public Set disableFireSpreadBlocks; + public boolean preventLavaFire; + public Set allowedLavaSpreadOver; + public boolean blockTNTExplosions; + public boolean blockTNTBlockDamage; + public boolean blockCreeperExplosions; + public boolean blockCreeperBlockDamage; + public boolean blockWitherExplosions; + public boolean blockWitherBlockDamage; + public boolean blockWitherSkullExplosions; + public boolean blockWitherSkullBlockDamage; + public boolean blockEnderDragonBlockDamage; + public boolean blockEnderDragonPortalCreation; + public boolean blockFireballExplosions; + public boolean blockFireballBlockDamage; + public boolean blockOtherExplosions; + public boolean blockEntityPaintingDestroy; + public boolean blockEntityItemFrameDestroy; + public boolean blockEntityArmorStandDestroy; + public boolean blockPluginSpawning; + public boolean blockGroundSlimes; + public boolean blockZombieDoorDestruction; + public boolean disableContactDamage; + public boolean disableFallDamage; + public boolean disableLavaDamage; + public boolean disableFireDamage; + public boolean disableLightningDamage; + public boolean disableDrowningDamage; + public boolean disableSuffocationDamage; + public boolean teleportOnSuffocation; + public boolean disableVoidDamage; + public boolean teleportOnVoid; + public boolean disableExplosionDamage; + public boolean disableMobDamage; + public boolean highFreqFlags; + public boolean checkLiquidFlow; + public String regionWand; + public Set blockCreatureSpawn; + public boolean allowTamedSpawns; + public int maxClaimVolume; + public boolean claimOnlyInsideExistingRegions; + public int maxRegionCountPerPlayer; + public boolean antiWolfDumbness; + public boolean signChestProtection; + public boolean disableSignChestProtectionCheck; + public boolean removeInfiniteStacks; + public boolean disableCreatureCropTrampling; + public boolean disablePlayerCropTrampling; + public boolean preventLightningFire; + public Set disallowedLightningBlocks; + public boolean disableThunder; + public boolean disableWeather; + public boolean alwaysRaining; + public boolean alwaysThundering; + public boolean disablePigZap; + public boolean disableCreeperPower; + public boolean disableHealthRegain; + public boolean disableMushroomSpread; + public boolean disableIceMelting; + public boolean disableSnowMelting; + public boolean disableSnowFormation; + public boolean disableIceFormation; + public boolean disableLeafDecay; + public boolean disableGrassGrowth; + public boolean disableMyceliumSpread; + public boolean disableVineGrowth; + public boolean disableEndermanGriefing; + public boolean disableSnowmanTrails; + public boolean disableSoilDehydration; + public Set allowedSnowFallOver; + public boolean regionInvinciblityRemovesMobs; + public boolean regionNetherPortalProtection; + public boolean fakePlayerBuildOverride; + public boolean explosionFlagCancellation; + public boolean disableDeathMessages; + public boolean disableObsidianGenerators; + public boolean strictEntitySpawn; + public boolean ignoreHopperMoveEvents; + protected Map maxRegionCounts; /** * Load the configuration. diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/config/YamlConfigurationManager.java b/worldguard-core/src/main/java/com/sk89q/worldguard/config/YamlConfigurationManager.java index 8588fef43..69b83b4b6 100644 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/config/YamlConfigurationManager.java +++ b/worldguard-core/src/main/java/com/sk89q/worldguard/config/YamlConfigurationManager.java @@ -26,7 +26,7 @@ import com.sk89q.worldguard.protection.managers.storage.RegionDriver; import com.sk89q.worldguard.protection.managers.storage.file.DirectoryYamlDriver; import com.sk89q.worldguard.protection.managers.storage.sql.SQLDriver; -import com.sk89q.worldguard.util.report.Unreported; +import com.sk89q.worldedit.util.report.Unreported; import com.sk89q.worldguard.util.sql.DataSourceConfig; import java.io.File; diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/config/YamlWorldConfiguration.java b/worldguard-core/src/main/java/com/sk89q/worldguard/config/YamlWorldConfiguration.java index c90a62fde..b6ed82ce2 100644 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/config/YamlWorldConfiguration.java +++ b/worldguard-core/src/main/java/com/sk89q/worldguard/config/YamlWorldConfiguration.java @@ -20,7 +20,7 @@ package com.sk89q.worldguard.config; import com.sk89q.util.yaml.YAMLProcessor; -import com.sk89q.worldguard.util.report.Unreported; +import com.sk89q.worldedit.util.report.Unreported; import java.util.ArrayList; import java.util.List; diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/util/profiler/SamplerBuilder.java b/worldguard-core/src/main/java/com/sk89q/worldguard/util/profiler/SamplerBuilder.java index 031cb3aba..adabd1fdc 100644 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/util/profiler/SamplerBuilder.java +++ b/worldguard-core/src/main/java/com/sk89q/worldguard/util/profiler/SamplerBuilder.java @@ -19,26 +19,29 @@ package com.sk89q.worldguard.util.profiler; -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; import java.lang.management.ManagementFactory; import java.lang.management.ThreadInfo; import java.lang.management.ThreadMXBean; -import java.util.*; +import java.util.Map; +import java.util.SortedMap; +import java.util.Timer; +import java.util.TimerTask; +import java.util.TreeMap; import java.util.concurrent.TimeUnit; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; +import java.util.function.Predicate; public class SamplerBuilder { private static final Timer timer = new Timer("WorldGuard Sampler", true); private int interval = 100; private long runTime = TimeUnit.MINUTES.toMillis(5); - private Predicate threadFilter = Predicates.alwaysTrue(); + private Predicate threadFilter = thread -> true; public int getInterval() { return interval; @@ -78,7 +81,7 @@ public static class Sampler extends TimerTask { private final Predicate threadFilter; private final long endTime; - private final SortedMap nodes = new TreeMap(); + private final SortedMap nodes = new TreeMap<>(); private final ThreadMXBean threadBean = ManagementFactory.getThreadMXBean(); private final SettableFuture future = SettableFuture.create(); @@ -119,7 +122,7 @@ public synchronized void run() { String threadName = threadInfo.getThreadName(); StackTraceElement[] stack = threadInfo.getStackTrace(); - if (threadName != null && stack != null && threadFilter.apply(threadInfo)) { + if (threadName != null && stack != null && threadFilter.test(threadInfo)) { StackNode node = getNode(threadName); node.log(stack, interval); } diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/util/profiler/StackTraceNode.java b/worldguard-core/src/main/java/com/sk89q/worldguard/util/profiler/StackTraceNode.java index ef0c48670..2f5c94fb4 100644 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/util/profiler/StackTraceNode.java +++ b/worldguard-core/src/main/java/com/sk89q/worldguard/util/profiler/StackTraceNode.java @@ -40,13 +40,7 @@ public String getMethodName() { @Override public int compareTo(StackNode o) { - if (getTotalTime() == o.getTotalTime()) { - return 0; - } else if (getTotalTime()> o.getTotalTime()) { - return -1; - } else { - return 1; - } + return Long.compare(o.getTotalTime(), getTotalTime()); } } diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/util/profiler/ThreadIdFilter.java b/worldguard-core/src/main/java/com/sk89q/worldguard/util/profiler/ThreadIdFilter.java index ee719ad95..2daaf6416 100644 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/util/profiler/ThreadIdFilter.java +++ b/worldguard-core/src/main/java/com/sk89q/worldguard/util/profiler/ThreadIdFilter.java @@ -19,9 +19,8 @@ package com.sk89q.worldguard.util.profiler; -import com.google.common.base.Predicate; - import java.lang.management.ThreadInfo; +import java.util.function.Predicate; public class ThreadIdFilter implements Predicate { @@ -32,7 +31,7 @@ public ThreadIdFilter(long id) { } @Override - public boolean apply(ThreadInfo threadInfo) { + public boolean test(ThreadInfo threadInfo) { return threadInfo.getThreadId() == id; } } diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/util/profiler/ThreadNameFilter.java b/worldguard-core/src/main/java/com/sk89q/worldguard/util/profiler/ThreadNameFilter.java index 09a483526..4054af5e5 100644 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/util/profiler/ThreadNameFilter.java +++ b/worldguard-core/src/main/java/com/sk89q/worldguard/util/profiler/ThreadNameFilter.java @@ -19,9 +19,8 @@ package com.sk89q.worldguard.util.profiler; -import com.google.common.base.Predicate; - import java.lang.management.ThreadInfo; +import java.util.function.Predicate; import static com.google.common.base.Preconditions.checkNotNull; @@ -35,7 +34,7 @@ public ThreadNameFilter(String name) { } @Override - public boolean apply(ThreadInfo threadInfo) { + public boolean test(ThreadInfo threadInfo) { return threadInfo.getThreadName().equalsIgnoreCase(name); } diff --git a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/ConfigReport.java b/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/ConfigReport.java similarity index 79% rename from worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/ConfigReport.java rename to worldguard-core/src/main/java/com/sk89q/worldguard/util/report/ConfigReport.java index fabb315be..edfc20937 100644 --- a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/ConfigReport.java +++ b/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/ConfigReport.java @@ -17,38 +17,34 @@ * along with this program. If not, see . */ -package com.sk89q.worldguard.bukkit.util.report; +package com.sk89q.worldguard.util.report; -import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.extension.platform.Capability; +import com.sk89q.worldedit.util.report.DataReport; +import com.sk89q.worldedit.util.report.ShallowObjectReport; +import com.sk89q.worldedit.world.World; import com.sk89q.worldguard.WorldGuard; import com.sk89q.worldguard.blacklist.Blacklist; -import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.config.WorldConfiguration; import com.sk89q.worldguard.protection.managers.RegionManager; import com.sk89q.worldguard.protection.regions.ProtectedRegion; -import com.sk89q.worldguard.util.report.DataReport; -import com.sk89q.worldguard.util.report.RegionReport; -import com.sk89q.worldguard.util.report.ShallowObjectReport; -import org.bukkit.Bukkit; -import org.bukkit.World; import java.util.List; public class ConfigReport extends DataReport { - public ConfigReport(WorldGuardPlugin plugin) { + public ConfigReport() { super("WorldGuard Configuration"); - List worlds = Bukkit.getServer().getWorlds(); + List worlds = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getWorlds(); append("Configuration", new ShallowObjectReport("Configuration", WorldGuard.getInstance().getPlatform().getGlobalStateManager())); for (World world : worlds) { - com.sk89q.worldedit.world.World weWorld = BukkitAdapter.adapt(world); - WorldConfiguration config = WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(weWorld); + WorldConfiguration config = WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(world); DataReport report = new DataReport("World: " + world.getName()); - report.append("UUID", world.getUID()); report.append("Configuration", new ShallowObjectReport("Configuration", config)); Blacklist blacklist = config.getBlacklist(); @@ -61,7 +57,7 @@ public ConfigReport(WorldGuardPlugin plugin) { report.append("Blacklist", ""); } - RegionManager regions = WorldGuard.getInstance().getPlatform().getRegionContainer().get(weWorld); + RegionManager regions = WorldGuard.getInstance().getPlatform().getRegionContainer().get(world); if (regions != null) { DataReport section = new DataReport("Regions"); section.append("Region Count", regions.size()); diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/DataReport.java b/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/DataReport.java deleted file mode 100644 index 466ab583f..000000000 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/DataReport.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * WorldGuard, a suite of tools for Minecraft - * Copyright (C) sk89q - * Copyright (C) WorldGuard team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldguard.util.report; - -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; - -import java.util.*; - -import static com.google.common.base.Preconditions.checkNotNull; - -public class DataReport implements Report { - - private final String title; - private final List lines = Lists.newArrayList(); - - public DataReport(String title) { - checkNotNull(title, "title"); - this.title = title; - } - - public void append(String key, String message) { - checkNotNull(key, "key"); - lines.add(new Line(key, message)); - } - - public void append(String key, String message, Object... values) { - checkNotNull(message, "values"); - checkNotNull(values, "values"); - append(key, String.format(message, values)); - } - - public void append(String key, byte value) { - append(key, String.valueOf(value)); - } - - public void append(String key, short value) { - append(key, String.valueOf(value)); - } - - public void append(String key, int value) { - append(key, String.valueOf(value)); - } - - public void append(String key, long value) { - append(key, String.valueOf(value)); - } - - public void append(String key, float value) { - append(key, String.valueOf(value)); - } - - public void append(String key, double value) { - append(key, String.valueOf(value)); - } - - public void append(String key, boolean value) { - append(key, String.valueOf(value)); - } - - public void append(String key, char value) { - append(key, String.valueOf(value)); - } - - public void append(String key, Object value) { - append(key, getStringValue(value, Sets.newHashSet())); - } - - private static String getStringValue(Object value, Set seen) { - if (seen.contains(value)) { - return ""; - } else { - seen.add(value); - } - - if (value instanceof Object[]) { - value = Arrays.asList(value); - } - - if (value instanceof Collection) { - StringBuilder builder = new StringBuilder(); - boolean first = true; - for (Object entry : (Collection) value) { - if (first) { - first = false; - } else { - builder.append("\n"); - } - builder.append(getStringValue(entry, Sets.newHashSet(seen))); - } - return builder.toString(); - } else if (value instanceof Map) { - StringBuilder builder = new StringBuilder(); - boolean first = true; - for (Map.Entry entry : ((Map) value).entrySet()) { - if (first) { - first = false; - } else { - builder.append("\n"); - } - - String key = getStringValue(entry.getKey(), Sets.newHashSet(seen)).replaceAll("[\r\n]", ""); - if (key.length() > 60) { - key = key.substring(0, 60) + "..."; - } - - builder - .append(key) - .append(": ") - .append(getStringValue(entry.getValue(), Sets.newHashSet(seen))); - } - return builder.toString(); - } else { - return String.valueOf(value); - } - } - - @Override - public String getTitle() { - return title; - } - - @Override - public String toString() { - if (!lines.isEmpty()) { - StringBuilder builder = new StringBuilder(); - boolean first = true; - for (Line line : lines) { - if (first) { - first = false; - } else { - builder.append("\n"); - } - builder.append(line.key).append(": "); - if (line.value == null) { - builder.append("null"); - } else if (line.value.contains("\n")) { - builder.append("\n"); - builder.append(line.value.replaceAll("(?m)^", "\t")); - } else { - builder.append(line.value); - } - } - return builder.toString(); - } else { - return "No data."; - } - } - - private static class Line { - private final String key; - private final String value; - - public Line(String key, String value) { - this.key = key; - this.value = value; - } - } - -} diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/RegionReport.java b/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/RegionReport.java index 8d2647523..ae36d7c08 100644 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/RegionReport.java +++ b/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/RegionReport.java @@ -19,6 +19,7 @@ package com.sk89q.worldguard.util.report; +import com.sk89q.worldedit.util.report.DataReport; import com.sk89q.worldguard.protection.regions.ProtectedRegion; /** diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/Report.java b/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/Report.java deleted file mode 100644 index 47717437b..000000000 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/Report.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * WorldGuard, a suite of tools for Minecraft - * Copyright (C) sk89q - * Copyright (C) WorldGuard team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldguard.util.report; - -public interface Report { - - String getTitle(); - -} diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/ReportList.java b/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/ReportList.java deleted file mode 100644 index 55bc610c7..000000000 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/ReportList.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * WorldGuard, a suite of tools for Minecraft - * Copyright (C) sk89q - * Copyright (C) WorldGuard team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldguard.util.report; - -import com.google.common.collect.Lists; - -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; - -public class ReportList implements Report, List { - - private final String title; - private final List reports = Lists.newArrayList(); - - public ReportList(String title) { - this.title = title; - } - - @Override - public String getTitle() { - return title; - } - - @Override - public int size() { - return reports.size(); - } - - @Override - public boolean isEmpty() { - return reports.isEmpty(); - } - - @Override - public boolean contains(Object o) { - return reports.contains(o); - } - - @Override - public Iterator iterator() { - return reports.iterator(); - } - - @Override - public Object[] toArray() { - return reports.toArray(); - } - - @Override - public T[] toArray(T[] a) { - return reports.toArray(a); - } - - @Override - public boolean add(Report report) { - return reports.add(report); - } - - @Override - public boolean remove(Object o) { - return reports.remove(o); - } - - @Override - public boolean containsAll(Collection c) { - return reports.containsAll(c); - } - - @Override - public boolean addAll(Collection c) { - return reports.addAll(c); - } - - @Override - public boolean addAll(int index, Collection c) { - return reports.addAll(index, c); - } - - @Override - public boolean removeAll(Collection c) { - return reports.removeAll(c); - } - - @Override - public boolean retainAll(Collection c) { - return reports.retainAll(c); - } - - @Override - public void clear() { - reports.clear(); - } - - @Override - public boolean equals(Object o) { - return reports.equals(o); - } - - @Override - public int hashCode() { - return reports.hashCode(); - } - - @Override - public Report get(int index) { - return reports.get(index); - } - - @Override - public Report set(int index, Report element) { - return reports.set(index, element); - } - - @Override - public void add(int index, Report element) { - reports.add(index, element); - } - - @Override - public Report remove(int index) { - return reports.remove(index); - } - - @Override - public int indexOf(Object o) { - return reports.indexOf(o); - } - - @Override - public int lastIndexOf(Object o) { - return reports.lastIndexOf(o); - } - - @Override - public ListIterator listIterator() { - return reports.listIterator(); - } - - @Override - public ListIterator listIterator(int index) { - return reports.listIterator(index); - } - - @Override - public List subList(int fromIndex, int toIndex) { - return reports.subList(fromIndex, toIndex); - } - - @Override - public String toString() { - if (!reports.isEmpty()) { - StringBuilder builder = new StringBuilder(); - for (Report report : reports) { - builder.append("================================\n") - .append(report.getTitle()) - .append("\n================================") - .append("\n\n") - .append(report.toString()) - .append("\n\n"); - } - return builder.toString(); - } else { - return "No reports."; - } - } - -} diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/ShallowObjectReport.java b/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/ShallowObjectReport.java deleted file mode 100644 index ac786bf84..000000000 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/ShallowObjectReport.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * WorldGuard, a suite of tools for Minecraft - * Copyright (C) sk89q - * Copyright (C) WorldGuard team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldguard.util.report; - -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.logging.Level; -import java.util.logging.Logger; - -import static com.google.common.base.Preconditions.checkNotNull; - -public class ShallowObjectReport extends DataReport { - - private static final Logger log = Logger.getLogger(ShallowObjectReport.class.getCanonicalName()); - - public ShallowObjectReport(String title, Object object) { - super(title); - checkNotNull(object, "object"); - - Class type = object.getClass(); - - for (Field field : type.getDeclaredFields()) { - if (Modifier.isStatic(field.getModifiers())) { - continue; - } - - if (field.getAnnotation(Unreported.class) != null) { - continue; - } - - field.setAccessible(true); - try { - Object value = field.get(object); - append(field.getName(), String.valueOf(value)); - } catch (IllegalAccessException e) { - log.log(Level.WARNING, "Failed to get value of '" + field.getName() + "' on " + type); - } - } - } - -} diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/StackTraceReport.java b/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/StackTraceReport.java deleted file mode 100644 index 75edf1bc9..000000000 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/StackTraceReport.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * WorldGuard, a suite of tools for Minecraft - * Copyright (C) sk89q - * Copyright (C) WorldGuard team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldguard.util.report; - -import static com.google.common.base.Preconditions.checkNotNull; - -public class StackTraceReport implements Report { - - private final StackTraceElement[] stackTrace; - - public StackTraceReport(StackTraceElement[] stackTrace) { - checkNotNull(stackTrace, "stackTrace"); - this.stackTrace = stackTrace; - } - - @Override - public String getTitle() { - return "Stack Trace"; - } - - @Override - public String toString() { - if (stackTrace.length > 0) { - StringBuilder builder = new StringBuilder(); - boolean first = true; - for (StackTraceElement element : stackTrace) { - if (first) { - first = false; - } else { - builder.append("\n"); - } - builder.append(element.getClassName()) - .append(".") - .append(element.getMethodName()) - .append("() (") - .append(element.getFileName()) - .append(":") - .append(element.getLineNumber()) - .append(")"); - } - return builder.toString(); - } else { - return "No stack trace available."; - } - } - -} diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/SystemInfoReport.java b/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/SystemInfoReport.java deleted file mode 100644 index d5c500ca9..000000000 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/SystemInfoReport.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * WorldGuard, a suite of tools for Minecraft - * Copyright (C) sk89q - * Copyright (C) WorldGuard team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldguard.util.report; - -import java.lang.management.*; -import java.util.List; -import java.util.concurrent.TimeUnit; - -public class SystemInfoReport extends DataReport { - - public SystemInfoReport() { - super("System Information"); - - Runtime runtime = Runtime.getRuntime(); - RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean(); - ClassLoadingMXBean classLoadingBean = ManagementFactory.getClassLoadingMXBean(); - List gcBeans = ManagementFactory.getGarbageCollectorMXBeans(); - OperatingSystemMXBean osBean = ManagementFactory.getOperatingSystemMXBean(); - ThreadMXBean threadBean = ManagementFactory.getThreadMXBean(); - - append("Java", "%s %s (%s)", - System.getProperty("java.vendor"), - System.getProperty("java.version"), - System.getProperty("java.vendor.url")); - append("Operating System", "%s %s (%s)", - System.getProperty("os.name"), - System.getProperty("os.version"), - System.getProperty("os.arch")); - append("Available Processors", runtime.availableProcessors()); - append("Free Memory", runtime.freeMemory() / 1024 / 1024 + " MB"); - append("Max Memory", runtime.maxMemory() / 1024 / 1024 + " MB"); - append("Total Memory", runtime.totalMemory() / 1024 / 1024 + " MB"); - append("System Load Average", osBean.getSystemLoadAverage()); - append("Java Uptime", TimeUnit.MINUTES.convert(runtimeBean.getUptime(), TimeUnit.MILLISECONDS) + " minutes"); - - DataReport startup = new DataReport("Startup"); - startup.append("Input Arguments", runtimeBean.getInputArguments()); - append(startup.getTitle(), startup); - - DataReport vm = new DataReport("Virtual Machine"); - vm.append("Name", runtimeBean.getVmName()); - vm.append("Vendor", runtimeBean.getVmVendor()); - vm.append("Version", runtimeBean.getVmVendor()); - append(vm.getTitle(), vm); - - DataReport spec = new DataReport("Specification"); - spec.append("Name", runtimeBean.getSpecName()); - spec.append("Vendor", runtimeBean.getSpecVendor()); - spec.append("Version", runtimeBean.getSpecVersion()); - append(spec.getTitle(), spec); - - DataReport classLoader = new DataReport("Class Loader"); - classLoader.append("Loaded Class Count", classLoadingBean.getLoadedClassCount()); - classLoader.append("Total Loaded Class Count", classLoadingBean.getTotalLoadedClassCount()); - classLoader.append("Unloaded Class Count", classLoadingBean.getUnloadedClassCount()); - append(classLoader.getTitle(), classLoader); - - DataReport gc = new DataReport("Garbage Collectors"); - for (GarbageCollectorMXBean bean : gcBeans) { - DataReport thisGC = new DataReport(bean.getName()); - thisGC.append("Collection Count", bean.getCollectionCount()); - thisGC.append("Collection Time", bean.getCollectionTime() + "ms"); - gc.append(thisGC.getTitle(), thisGC); - } - append(gc.getTitle(), gc); - - DataReport threads = new DataReport("Threads"); - for (ThreadInfo threadInfo : threadBean.dumpAllThreads(false, false)) { - threads.append("#" + threadInfo.getThreadId() + " " + threadInfo.getThreadName(), threadInfo.getThreadState()); - } - append(threads.getTitle(), threads); - } - -} diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/Unreported.java b/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/Unreported.java deleted file mode 100644 index 8b6660726..000000000 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/Unreported.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * WorldGuard, a suite of tools for Minecraft - * Copyright (C) sk89q - * Copyright (C) WorldGuard team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldguard.util.report; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Annotates properties that should not be exposed in the report. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface Unreported { -} diff --git a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/BukkitConfigurationManager.java b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/BukkitConfigurationManager.java index 8240904d1..5c58546c7 100644 --- a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/BukkitConfigurationManager.java +++ b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/BukkitConfigurationManager.java @@ -23,7 +23,7 @@ import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.world.World; import com.sk89q.worldguard.config.YamlConfigurationManager; -import com.sk89q.worldguard.util.report.Unreported; +import com.sk89q.worldedit.util.report.Unreported; import java.io.File; import java.util.concurrent.ConcurrentHashMap; diff --git a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/BukkitWorldConfiguration.java b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/BukkitWorldConfiguration.java index c35743f3a..db67e04d1 100644 --- a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/BukkitWorldConfiguration.java +++ b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/BukkitWorldConfiguration.java @@ -22,6 +22,9 @@ import com.sk89q.util.yaml.YAMLFormat; import com.sk89q.util.yaml.YAMLProcessor; import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.util.report.Unreported; +import com.sk89q.worldedit.world.entity.EntityType; +import com.sk89q.worldedit.world.entity.EntityTypes; import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldguard.LocalPlayer; import com.sk89q.worldguard.blacklist.Blacklist; @@ -31,13 +34,11 @@ import com.sk89q.worldguard.blacklist.logger.FileHandler; import com.sk89q.worldguard.blacklist.target.TargetMatcherParseException; import com.sk89q.worldguard.blacklist.target.TargetMatcherParser; -import com.sk89q.worldguard.chest.ChestProtection; import com.sk89q.worldguard.bukkit.chest.BukkitSignChestProtection; import com.sk89q.worldguard.bukkit.commands.CommandUtils; import com.sk89q.worldguard.bukkit.internal.TargetMatcherSet; +import com.sk89q.worldguard.chest.ChestProtection; import com.sk89q.worldguard.config.YamlWorldConfiguration; -import com.sk89q.worldguard.util.report.Unreported; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffectType; import org.yaml.snakeyaml.parser.ParserException; @@ -49,7 +50,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Set; import java.util.logging.Level; @@ -70,108 +70,9 @@ public class BukkitWorldConfiguration extends YamlWorldConfiguration { @Unreported private ChestProtection chestProtection = new BukkitSignChestProtection(); /* Configuration data start */ - public boolean summaryOnStart; - public boolean opPermissions; - public boolean buildPermissions; - public String buildPermissionDenyMessage = ""; - public boolean fireSpreadDisableToggle; - public boolean itemDurability; - public boolean disableExpDrops; public Set blockPotions; - public boolean blockPotionsAlways; - public boolean pumpkinScuba; - public boolean noPhysicsGravel; - public boolean noPhysicsSand; - public boolean ropeLadders; - public boolean allowPortalAnywhere; - public Set preventWaterDamage; - public boolean blockLighter; - public boolean disableFireSpread; - public Set disableFireSpreadBlocks; - public boolean preventLavaFire; - public Set allowedLavaSpreadOver; - public boolean blockTNTExplosions; - public boolean blockTNTBlockDamage; - public boolean blockCreeperExplosions; - public boolean blockCreeperBlockDamage; - public boolean blockWitherExplosions; - public boolean blockWitherBlockDamage; - public boolean blockWitherSkullExplosions; - public boolean blockWitherSkullBlockDamage; - public boolean blockEnderDragonBlockDamage; - public boolean blockEnderDragonPortalCreation; - public boolean blockFireballExplosions; - public boolean blockFireballBlockDamage; - public boolean blockOtherExplosions; - public boolean blockEntityPaintingDestroy; - public boolean blockEntityItemFrameDestroy; - public boolean blockEntityArmorStandDestroy; - public boolean blockPluginSpawning; - public boolean blockGroundSlimes; - public boolean blockZombieDoorDestruction; - public boolean disableContactDamage; - public boolean disableFallDamage; - public boolean disableLavaDamage; - public boolean disableFireDamage; - public boolean disableLightningDamage; - public boolean disableDrowningDamage; - public boolean disableSuffocationDamage; - public boolean teleportOnSuffocation; - public boolean disableVoidDamage; - public boolean teleportOnVoid; - public boolean disableExplosionDamage; - public boolean disableMobDamage; - public boolean highFreqFlags; - public boolean checkLiquidFlow; - public String regionWand; - public Set blockCreatureSpawn; - public boolean allowTamedSpawns; - // public boolean useiConomy; - // public boolean buyOnClaim; - // public double buyOnClaimPrice; - public int maxClaimVolume; - public boolean claimOnlyInsideExistingRegions; - public int maxRegionCountPerPlayer; - public boolean antiWolfDumbness; - public boolean signChestProtection; - public boolean disableSignChestProtectionCheck; - public boolean removeInfiniteStacks; - public boolean disableCreatureCropTrampling; - public boolean disablePlayerCropTrampling; - public boolean preventLightningFire; - public Set disallowedLightningBlocks; - public boolean disableThunder; - public boolean disableWeather; - public boolean alwaysRaining; - public boolean alwaysThundering; - public boolean disablePigZap; - public boolean disableCreeperPower; - public boolean disableHealthRegain; - public boolean disableMushroomSpread; - public boolean disableIceMelting; - public boolean disableSnowMelting; - public boolean disableSnowFormation; - public boolean disableIceFormation; - public boolean disableLeafDecay; - public boolean disableGrassGrowth; - public boolean disableMyceliumSpread; - public boolean disableVineGrowth; - public boolean disableEndermanGriefing; - public boolean disableSnowmanTrails; - public boolean disableSoilDehydration; - public Set allowedSnowFallOver; - public boolean regionInvinciblityRemovesMobs; - public boolean regionNetherPortalProtection; - public boolean fakePlayerBuildOverride; - public boolean explosionFlagCancellation; - public boolean disableDeathMessages; - public boolean disableObsidianGenerators; - public boolean strictEntitySpawn; public TargetMatcherSet allowAllInteract; - public boolean ignoreHopperMoveEvents; public TargetMatcherSet blockUseAtFeet; - private Map maxRegionCounts; - /* Configuration data end */ /** @@ -381,12 +282,10 @@ public void loadConfiguration() { blockCreatureSpawn = new HashSet<>(); for (String creatureName : getStringList("mobs.block-creature-spawn", null)) { - EntityType creature = EntityType.fromName(creatureName); + EntityType creature = EntityTypes.get(creatureName.toLowerCase()); if (creature == null) { - log.warning("Unknown mob type '" + creatureName + "'"); - } else if (!creature.isAlive()) { - log.warning("Entity type '" + creatureName + "' is not a creature"); + log.warning("Unknown entity type '" + creatureName + "'"); } else { blockCreatureSpawn.add(creature); } diff --git a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/commands/WorldGuardCommands.java b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/commands/WorldGuardCommands.java index 4c16b9bf1..8fa3c2119 100644 --- a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/commands/WorldGuardCommands.java +++ b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/commands/WorldGuardCommands.java @@ -19,35 +19,42 @@ package com.sk89q.worldguard.bukkit.commands; -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import com.google.common.io.Files; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.MoreExecutors; -import com.sk89q.minecraft.util.commands.*; +import com.sk89q.minecraft.util.commands.Command; +import com.sk89q.minecraft.util.commands.CommandContext; +import com.sk89q.minecraft.util.commands.CommandException; +import com.sk89q.minecraft.util.commands.CommandPermissions; +import com.sk89q.minecraft.util.commands.NestedCommand; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.platform.Capability; +import com.sk89q.worldedit.util.report.ReportList; +import com.sk89q.worldedit.util.report.SystemInfoReport; import com.sk89q.worldedit.world.World; import com.sk89q.worldguard.LocalPlayer; import com.sk89q.worldguard.WorldGuard; -import com.sk89q.worldguard.config.ConfigurationManager; import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.bukkit.util.logging.LoggerToChatHandler; -import com.sk89q.worldguard.bukkit.util.report.*; +import com.sk89q.worldguard.bukkit.util.report.PerformanceReport; +import com.sk89q.worldguard.bukkit.util.report.PluginReport; +import com.sk89q.worldguard.bukkit.util.report.SchedulerReport; +import com.sk89q.worldguard.bukkit.util.report.ServerReport; +import com.sk89q.worldguard.bukkit.util.report.ServicesReport; +import com.sk89q.worldguard.bukkit.util.report.WorldReport; +import com.sk89q.worldguard.config.ConfigurationManager; import com.sk89q.worldguard.util.profiler.SamplerBuilder; import com.sk89q.worldguard.util.profiler.SamplerBuilder.Sampler; import com.sk89q.worldguard.util.profiler.ThreadIdFilter; import com.sk89q.worldguard.util.profiler.ThreadNameFilter; -import com.sk89q.worldguard.util.report.ReportList; -import com.sk89q.worldguard.util.report.SystemInfoReport; +import com.sk89q.worldguard.util.report.ConfigReport; import com.sk89q.worldguard.util.task.Task; import com.sk89q.worldguard.util.task.TaskStateComparator; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import javax.annotation.Nullable; import java.io.File; import java.io.IOException; import java.lang.management.ThreadInfo; @@ -55,9 +62,12 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.TimeUnit; +import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; +import javax.annotation.Nullable; + public class WorldGuardCommands { private static final Logger log = Logger.getLogger(WorldGuardCommands.class.getCanonicalName()); @@ -128,7 +138,7 @@ public void report(CommandContext args, final CommandSender sender) throws Comma report.add(new ServicesReport()); report.add(new WorldReport()); report.add(new PerformanceReport()); - report.add(new ConfigReport(plugin)); + report.add(new ConfigReport()); String result = report.toString(); try { @@ -164,7 +174,7 @@ public void profile(final CommandContext args, final CommandSender sender) throw if (threadName == null) { threadFilter = new ThreadIdFilter(Thread.currentThread().getId()); } else if (threadName.equals("*")) { - threadFilter = Predicates.alwaysTrue(); + threadFilter = thread -> true; } else { threadFilter = new ThreadNameFilter(threadName); } diff --git a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/listener/RegionProtectionListener.java b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/listener/RegionProtectionListener.java index 8db1be709..af3909fac 100644 --- a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/listener/RegionProtectionListener.java +++ b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/listener/RegionProtectionListener.java @@ -477,7 +477,7 @@ public void onDamageEntity(DamageEntityEvent event) { Player defender = (Player) event.getEntity(); // if defender is an NPC - if (defender.hasMetadata("NPC")) { + if (Entities.isNPC(defender)) { return; } diff --git a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/CancelReport.java b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/CancelReport.java index 8b81330e7..e11c52a5e 100644 --- a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/CancelReport.java +++ b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/CancelReport.java @@ -21,8 +21,8 @@ import com.sk89q.worldguard.bukkit.event.debug.CancelAttempt; import com.sk89q.worldguard.bukkit.util.HandlerTracer; -import com.sk89q.worldguard.util.report.Report; -import com.sk89q.worldguard.util.report.StackTraceReport; +import com.sk89q.worldedit.util.report.Report; +import com.sk89q.worldedit.util.report.StackTraceReport; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.plugin.Plugin; diff --git a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/PerformanceReport.java b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/PerformanceReport.java index c5e50dd9b..736bcb0c5 100644 --- a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/PerformanceReport.java +++ b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/PerformanceReport.java @@ -20,7 +20,7 @@ package com.sk89q.worldguard.bukkit.util.report; import com.google.common.collect.Maps; -import com.sk89q.worldguard.util.report.DataReport; +import com.sk89q.worldedit.util.report.DataReport; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.World; diff --git a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/PluginReport.java b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/PluginReport.java index 7821594a3..e3e5e747e 100644 --- a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/PluginReport.java +++ b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/PluginReport.java @@ -19,7 +19,7 @@ package com.sk89q.worldguard.bukkit.util.report; -import com.sk89q.worldguard.util.report.DataReport; +import com.sk89q.worldedit.util.report.DataReport; import org.bukkit.Bukkit; import org.bukkit.plugin.Plugin; diff --git a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/SchedulerReport.java b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/SchedulerReport.java index 22531a0d8..d897162cf 100644 --- a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/SchedulerReport.java +++ b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/SchedulerReport.java @@ -19,18 +19,18 @@ package com.sk89q.worldguard.bukkit.util.report; -import com.google.common.base.Optional; import com.google.common.reflect.TypeToken; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; -import com.sk89q.worldguard.util.report.DataReport; +import com.sk89q.worldedit.util.report.DataReport; import org.bukkit.Bukkit; import org.bukkit.scheduler.BukkitTask; import javax.annotation.Nullable; import java.lang.reflect.Field; import java.util.List; +import java.util.Optional; import java.util.Set; public class SchedulerReport extends DataReport { @@ -42,9 +42,9 @@ public Optional load(Class clazz) throws Exception { try { Field field = clazz.getDeclaredField("task"); field.setAccessible(true); - return Optional.fromNullable(field); + return Optional.ofNullable(field); } catch (NoSuchFieldException ignored) { - return Optional.absent(); + return Optional.empty(); } } }); @@ -81,8 +81,7 @@ private Class getTaskClass(BukkitTask task) { return res == null ? null : res.getClass(); } } - } catch (IllegalAccessException ignored) { - } catch (NoClassDefFoundError ignored) { + } catch (IllegalAccessException | NoClassDefFoundError ignored) { } return null; diff --git a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/ServerReport.java b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/ServerReport.java index aa090bb37..77437ae67 100644 --- a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/ServerReport.java +++ b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/ServerReport.java @@ -19,7 +19,7 @@ package com.sk89q.worldguard.bukkit.util.report; -import com.sk89q.worldguard.util.report.DataReport; +import com.sk89q.worldedit.util.report.DataReport; import org.bukkit.Bukkit; import org.bukkit.Server; diff --git a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/ServicesReport.java b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/ServicesReport.java index e14c9e39e..09322bf67 100644 --- a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/ServicesReport.java +++ b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/ServicesReport.java @@ -19,13 +19,11 @@ package com.sk89q.worldguard.bukkit.util.report; -import com.sk89q.worldguard.util.report.DataReport; +import com.sk89q.worldedit.util.report.DataReport; import org.bukkit.Bukkit; import org.bukkit.plugin.ServicesManager; -import org.bukkit.scheduler.BukkitTask; import java.util.Collection; -import java.util.List; public class ServicesReport extends DataReport { diff --git a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/WorldReport.java b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/WorldReport.java index 3a47f90a1..c288f5b70 100644 --- a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/WorldReport.java +++ b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/util/report/WorldReport.java @@ -19,7 +19,7 @@ package com.sk89q.worldguard.bukkit.util.report; -import com.sk89q.worldguard.util.report.DataReport; +import com.sk89q.worldedit.util.report.DataReport; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.generator.ChunkGenerator;