mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-20 15:11:25 +01:00
review concerns
This commit is contained in:
parent
73426f42d3
commit
aad0ee5778
@ -432,6 +432,9 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
((Cancellable) event).setCancelled(true);
|
||||
}
|
||||
});
|
||||
if (getSettings().isDebug()) {
|
||||
LOGGER.log(Level.INFO, "Registered Paper Recipe Book Event Listener");
|
||||
}
|
||||
} catch (final ClassNotFoundException ignored) {
|
||||
}
|
||||
}
|
||||
@ -439,7 +442,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
execTimer.mark("Init(Providers)");
|
||||
reload();
|
||||
|
||||
// The item spawn blacklist is loaded with all other settings, before the item\
|
||||
// The item spawn blacklist is loaded with all other settings, before the item
|
||||
// DB, but it depends on the item DB, so we need to reload it again here:
|
||||
((Settings) settings)._lateLoadItemSpawnBlacklist();
|
||||
backup = new Backup(this);
|
||||
@ -667,12 +670,10 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
|
||||
// Check for disabled commands
|
||||
if (getSettings().isCommandDisabled(commandLabel)) {
|
||||
if (provider(KnownCommandsProvider.class).getKnownCommands().containsKey(commandLabel)) {
|
||||
final Command newCmd = provider(KnownCommandsProvider.class).getKnownCommands().get(commandLabel);
|
||||
if (!(newCmd instanceof PluginIdentifiableCommand) || ((PluginIdentifiableCommand) newCmd).getPlugin() != this) {
|
||||
if (newCmd != null && (!(newCmd instanceof PluginIdentifiableCommand) || ((PluginIdentifiableCommand) newCmd).getPlugin() != this)) {
|
||||
return newCmd.tabComplete(cSender, commandLabel, args);
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@ -778,12 +779,10 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
|
||||
// Check for disabled commands
|
||||
if (getSettings().isCommandDisabled(commandLabel)) {
|
||||
if (provider(KnownCommandsProvider.class).getKnownCommands().containsKey(commandLabel)) {
|
||||
final Command newCmd = provider(KnownCommandsProvider.class).getKnownCommands().get(commandLabel);
|
||||
if (!(newCmd instanceof PluginIdentifiableCommand) || !isEssentialsPlugin(((PluginIdentifiableCommand) newCmd).getPlugin())) {
|
||||
if (newCmd != null && (!(newCmd instanceof PluginIdentifiableCommand) || !isEssentialsPlugin(((PluginIdentifiableCommand) newCmd).getPlugin()))) {
|
||||
return newCmd.execute(cSender, commandLabel, args);
|
||||
}
|
||||
}
|
||||
sender.sendTl("commandDisabled", commandLabel);
|
||||
return true;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.earth2me.essentials;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import net.ess3.provider.Provider;
|
||||
import net.essentialsx.providers.NullableProvider;
|
||||
import net.essentialsx.providers.ProviderData;
|
||||
import net.essentialsx.providers.ProviderTest;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@ -55,6 +56,7 @@ public class ProviderFactory {
|
||||
public void finalizeRegistration() {
|
||||
for (final Map.Entry<Class<? extends Provider>, List<Class<? extends Provider>>> entry : registeredProviders.entrySet()) {
|
||||
final Class<? extends Provider> providerClass = entry.getKey();
|
||||
final boolean nullable = providerClass.isAnnotationPresent(NullableProvider.class);
|
||||
Class<? extends Provider> highestProvider = null;
|
||||
ProviderData highestProviderData = null;
|
||||
int highestWeight = -1;
|
||||
@ -70,12 +72,13 @@ public class ProviderFactory {
|
||||
essentials.getLogger().log(Level.SEVERE, "Failed to initialize provider " + provider.getName(), e);
|
||||
}
|
||||
}
|
||||
if (highestProvider == null) {
|
||||
throw new IllegalStateException("No provider found for " + providerClass.getName());
|
||||
}
|
||||
|
||||
if (highestProvider != null) {
|
||||
essentials.getLogger().info("Selected " + highestProviderData.description() + " as the provider for " + providerClass.getSimpleName());
|
||||
providers.put(providerClass, getProviderInstance(highestProvider));
|
||||
} else if (!nullable) {
|
||||
throw new IllegalStateException("No provider found for " + providerClass.getName());
|
||||
}
|
||||
}
|
||||
registeredProviders.clear();
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class RandomTeleport implements IConf {
|
||||
public RandomTeleport(final IEssentials essentials) {
|
||||
this.ess = essentials;
|
||||
config = new EssentialsConfiguration(new File(essentials.getDataFolder(), "tpr.yml"), "/tpr.yml",
|
||||
"Configuration for the random teleport command.\nSome settings may be defaulted, and can be changed via the /settpr command in-game.");
|
||||
"Configuration for the random teleport command.\nUse the /settpr command in-game to set random teleport locations.");
|
||||
}
|
||||
|
||||
public EssentialsConfiguration getConfig() {
|
||||
|
@ -1,8 +1,10 @@
|
||||
package net.ess3.provider;
|
||||
|
||||
import net.essentialsx.providers.NullableProvider;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
@NullableProvider
|
||||
public interface BiomeKeyProvider extends Provider {
|
||||
NamespacedKey getBiomeKey(Block block);
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
package net.ess3.provider;
|
||||
|
||||
import net.essentialsx.providers.NullableProvider;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
|
||||
@NullableProvider
|
||||
public interface ContainerProvider extends Provider {
|
||||
|
||||
InventoryView openAnvil(Player player);
|
||||
|
@ -1,7 +1,9 @@
|
||||
package net.ess3.provider;
|
||||
|
||||
import net.essentialsx.providers.NullableProvider;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@NullableProvider
|
||||
public interface SerializationProvider extends Provider {
|
||||
byte[] serializeItem(ItemStack stack);
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
package net.ess3.provider;
|
||||
|
||||
import net.essentialsx.providers.NullableProvider;
|
||||
import org.bukkit.block.Sign;
|
||||
|
||||
@NullableProvider
|
||||
public interface SignDataProvider extends Provider {
|
||||
void setSignData(Sign sign, String key, String value);
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
package net.essentialsx.providers;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Marks a provider as nullable, meaning that an error will not be thrown if no provider is found for the given type.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface NullableProvider {
|
||||
}
|
Loading…
Reference in New Issue
Block a user