Merge branch 'configurable' into gradlelize

This commit is contained in:
Shane Freeder 2019-09-30 21:18:56 +01:00
commit ba5c24fa3c
No known key found for this signature in database
GPG Key ID: A3F61EA5A085289C
10 changed files with 53 additions and 64 deletions

View File

@ -261,6 +261,8 @@ public final class ConfigManager {
customSerializers.registerType(new TypeToken<FormulaType>() {}, new CustomEnumValueSerializer());
customSerializers.registerType(new TypeToken<MMOItem<?>>() {}, new ItemStackSerializer());
customSerializers.registerType(new TypeToken<Set<?>>() {}, new SetSerializer());
customSerializers.registerType(new TypeToken<ItemMatch<?>>() {}, new CustomItemTargetSerializer());
customSerializers.registerType(new TypeToken<SimpleRepairCost>() {}, new SimpleRepairCostSerializer());
customSerializers.registerType(TypeToken.of(TamingSummon.class), new TamingSummonSerializer());
@ -274,7 +276,6 @@ public final class ConfigManager {
customSerializers.registerType(TypeToken.of(PlayerNotificationSettings.class), new PlayerNotificationSerializer());
customSerializers.registerType(TypeToken.of(SoundSetting.class), new SoundSettingSerializer());
customSerializers.registerType(TypeToken.of(ItemWildcards.class), new ItemWildcardSerializer());
customSerializers.registerType(TypeToken.of(ItemMatch.class), new CustomItemTargetSerializer());
customSerializers.registerType(TypeToken.of(RepairTransaction.class), new RepairTransactionSerializer());
customSerializers.registerType(TypeToken.of(RawNBT.class), new RawNBTSerializer());
}

View File

@ -13,9 +13,9 @@ import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.HashSet;
public class CustomItemTargetSerializer implements TypeSerializer<ItemMatch> {
public class CustomItemTargetSerializer implements TypeSerializer<ItemMatch<?>> {
private static final String ITEM_CONSUMED_FOR_REPAIR = "Item-Consumed-For-Repair";
private static final String ITEM_CONSUMED_FOR_REPAIR = "Target-Item";
private static final String NBT_REQUIREMENTS = "NBT-Requirements";
@Nullable
@ -32,7 +32,7 @@ public class CustomItemTargetSerializer implements TypeSerializer<ItemMatch> {
}
@Override
public void serialize(@NonNull TypeToken<?> type, @Nullable ItemMatch obj, @NonNull ConfigurationNode value) throws ObjectMappingException {
public void serialize(@NonNull TypeToken<?> type, @Nullable ItemMatch<?> obj, @NonNull ConfigurationNode value) throws ObjectMappingException {
value.getNode(ITEM_CONSUMED_FOR_REPAIR).setValue(obj.getItem());
if(obj.getItemMatchProperties().size() > 0) {

View File

@ -1,7 +1,9 @@
package com.gmail.nossr50.config.hocon.skills.archery;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigArcheryLimitBreak {
private static final boolean DEFAULT_PVE = false;

View File

@ -118,6 +118,7 @@ public final class LocaleManager {
pluginRef.getLogger().log(Level.WARNING, "Failed to load locale from " + localePath, e);
}
}
bundle = ResourceBundle.getBundle(BUNDLE_ROOT, locale);
enBundle = ResourceBundle.getBundle(BUNDLE_ROOT, java.util.Locale.US);
}

View File

@ -77,7 +77,6 @@ public class mcMMO extends JavaPlugin {
private NotificationManager notificationManager;
private CommandRegistrationManager commandRegistrationManager;
// private NBTManager nbtManager;
private WorldGuardManager worldGuardManager;
private PartyManager partyManager;
private LocaleManager localeManager;
private ChatManager chatManager;
@ -139,9 +138,6 @@ public class mcMMO extends JavaPlugin {
PluginManager pluginManager = getServer().getPluginManager();
healthBarPluginEnabled = pluginManager.getPlugin("HealthBar") != null;
//Init Locale Manager
localeManager = new LocaleManager(this);
//Init Permission Tools
permissionTools = new PermissionTools(this);
@ -149,9 +145,16 @@ public class mcMMO extends JavaPlugin {
setupFilePaths();
//modManager = new ModManager();
//Init config manager etc
loadConfigFiles();
//Init Locale Manager
localeManager = new LocaleManager(this);
//Init Skill Tools
skillTools = new SkillTools(this);
//Init DST
registerDynamicSettings(); //Do this after configs are loaded
//Init TextComponentFactory
@ -269,9 +272,6 @@ public class mcMMO extends JavaPlugin {
//Init Scoreboard Manager
scoreboardManager = new ScoreboardManager(this);
//Init Skill Tools
skillTools = new SkillTools(this);
//Init Combat Tools
combatTools = new CombatTools(this);
@ -284,9 +284,6 @@ public class mcMMO extends JavaPlugin {
//Init Item Tools
itemTools = new ItemTools(this);
//Init World Guard Utils (Not sure about the order of this one, might need to be loaded earlier)
worldGuardUtils = new WorldGuardUtils(this);
//Init MOTD Utils
messageOfTheDayUtils = new MessageOfTheDayUtils(this);
@ -306,10 +303,14 @@ public class mcMMO extends JavaPlugin {
@Override
public void onLoad()
{
worldGuardManager = new WorldGuardManager();
if(getServer().getPluginManager().getPlugin("WorldGuard") != null) {
worldGuardManager.registerFlags();
worldGuardUtils = new WorldGuardUtils(); //Init WGU
if(worldGuardUtils.isWorldGuardLoaded()) {
//Register flags
System.out.println("[mcMMO - Registering World Guard Flags...]");
worldGuardUtils.getWorldGuardManager().registerFlags();
}
}
}
@ -755,7 +756,7 @@ public class mcMMO extends JavaPlugin {
}
public WorldGuardManager getWorldGuardManager() {
return worldGuardManager;
return worldGuardUtils.getWorldGuardManager();
}
public PartyManager getPartyManager() {

View File

@ -21,8 +21,8 @@ import com.gmail.nossr50.events.hardcore.McMMOPlayerVampirismEvent;
import com.gmail.nossr50.events.party.McMMOPartyLevelUpEvent;
import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
import com.gmail.nossr50.events.party.McMMOPartyXpGainEvent;
import com.gmail.nossr50.events.skills.McMMOPlayerNotificationEvent;
import com.gmail.nossr50.events.players.McMMOPlayerProfileLoadEvent;
import com.gmail.nossr50.events.skills.McMMOPlayerNotificationEvent;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent;

View File

@ -8,7 +8,6 @@ import com.gmail.nossr50.events.scoreboard.McMMOScoreboardMakeboardEvent;
import com.gmail.nossr50.events.scoreboard.ScoreboardEventReason;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot;

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.worldguard;
import com.gmail.nossr50.mcMMO;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldguard.WorldGuard;
@ -9,12 +8,8 @@ import com.sk89q.worldguard.protection.flags.registry.FlagConflictException;
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
import com.sk89q.worldguard.protection.regions.RegionQuery;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import static org.bukkit.Bukkit.getServer;
public class WorldGuardManager {
private WorldGuardPlugin worldGuardPluginRef;
public boolean hasMainFlag(Player player)
{
@ -63,18 +58,6 @@ public class WorldGuardManager {
return query.testState(loc, WorldGuardPlugin.inst().wrapPlayer(player), WorldGuardFlags.MCMMO_HARDCORE_WG_FLAG);
}
private WorldGuardPlugin getWorldGuard() {
Plugin plugin = getServer().getPluginManager().getPlugin("WorldGuard");
// WorldGuard may not be loaded
if (!(plugin instanceof WorldGuardPlugin)) {
return null; // Maybe you want throw an exception instead
}
worldGuardPluginRef = (WorldGuardPlugin) plugin;
return worldGuardPluginRef;
}
public void registerFlags()
{
try {

View File

@ -1,9 +1,6 @@
package com.gmail.nossr50.worldguard;
import com.gmail.nossr50.mcMMO;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.registry.SimpleFlagRegistry;
import org.bukkit.plugin.Plugin;
import java.util.ArrayList;
@ -15,10 +12,9 @@ public class WorldGuardUtils {
private boolean isLoaded = false;
private boolean detectedIncompatibleWG = false;
private static final ArrayList<String> WGClassList;
private final mcMMO pluginRef;
private WorldGuardManager worldGuardManager;
public WorldGuardUtils(mcMMO pluginRef) {
this.pluginRef = pluginRef;
public WorldGuardUtils() {
}
static {
@ -72,7 +68,7 @@ public class WorldGuardUtils {
if(plugin == null) {
//WG is not present
detectedIncompatibleWG = true;
pluginRef.getLogger().info("WorldGuard was not detected.");
System.out.println("[mcMMO WorldGuardUtils Debug] WorldGuard was not detected.");
} else {
//Check that its actually of class WorldGuardPlugin
if(plugin instanceof WorldGuardPlugin)
@ -81,6 +77,9 @@ public class WorldGuardUtils {
{
worldGuardPluginRef = (WorldGuardPlugin) plugin;
isLoaded = true;
//Init WG Manager
worldGuardManager = new WorldGuardManager();
}
} else {
//Plugin is not of the expected type
@ -88,7 +87,6 @@ public class WorldGuardUtils {
}
}
return worldGuardPluginRef;
}
@ -100,7 +98,7 @@ public class WorldGuardUtils {
*/
private boolean isCompatibleVersion(Plugin plugin) {
//Check that the version of WG is at least version 7.xx
boolean allClassesFound = true;
// boolean allClassesFound = true;
if (!plugin.getDescription().getVersion().startsWith("7")) {
markWGIncompatible();
@ -111,8 +109,8 @@ public class WorldGuardUtils {
Class<?> checkForClass = Class.forName(classString);
detectedIncompatibleWG = false; //In case this was set to true previously
} catch (ClassNotFoundException | NoClassDefFoundError e) {
allClassesFound = false;
pluginRef.getLogger().severe("Missing WorldGuard class - "+classString);
// allClassesFound = false;
System.out.println("[mcMMO WorldGuardUtils Debug] Missing WorldGuard class - "+classString);
markWGIncompatible();
}
}
@ -120,17 +118,17 @@ public class WorldGuardUtils {
/*
* If WG appears to have all of its classes we can then check to see if its been initialized properly
*/
try {
if(allClassesFound) {
if(!((SimpleFlagRegistry) WorldGuard.getInstance().getFlagRegistry()).isInitialized()) {
markWGIncompatible();
pluginRef.getLogger().severe("WG did not initialize properly, this can cause errors with mcMMO so mcMMO is disabling certain features.");
}
}
} catch (Exception e) {
markWGIncompatible();
e.printStackTrace();
}
// try {
// if(allClassesFound) {
// if(!((SimpleFlagRegistry) WorldGuard.getInstance().getFlagRegistry()).isInitialized()) {
// markWGIncompatible();
// System.out.println("[mcMMO WorldGuardUtils Debug] WG did not initialize properly, this can cause errors with mcMMO so mcMMO is disabling certain features.");
// }
// }
// } catch (Exception e) {
// markWGIncompatible();
// e.printStackTrace();
// }
}
return !detectedIncompatibleWG;
@ -140,10 +138,14 @@ public class WorldGuardUtils {
* Mark WG as being incompatible to avoid unnecessary operations
*/
private void markWGIncompatible() {
pluginRef.getLogger().severe("You are using a version of WG that is not compatible with mcMMO, " +
System.out.println("[mcMMO WorldGuardUtils Debug] You are using a version of WG that is not compatible with mcMMO, " +
"WG features for mcMMO will be disabled. mcMMO requires you to be using a new version of WG7 " +
"in order for it to use WG features. Not all versions of WG7 are compatible.");
pluginRef.getLogger().severe("mcMMO will continue to function normally, but if you wish to use WG support you must use a compatible version.");
System.out.println("[mcMMO WorldGuardUtils Debug] mcMMO will continue to function normally, but if you wish to use WG support you must use a compatible version.");
detectedIncompatibleWG = true;
}
public WorldGuardManager getWorldGuardManager() {
return worldGuardManager;
}
}

View File

@ -14,7 +14,7 @@ author: nossr50
authors: [GJ, NuclearW, bm01, Glitchfinder, TfT_02, t00thpick1, Riking, electronicboy, kashike]
website: https://www.mcmmo.org
main: com.gmail.nossr50.mcMMO
softdepend: [WorldGuard, CombatTag, HealthBar]
softdepend: [WorldGuard, WorldEdit, CombatTag, HealthBar]
load: POSTWORLD
api-version: 1.13