Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
Remove Blacklist module functionality.
Browse files Browse the repository at this point in the history
The Blacklist module was poorly maintained, and there are much better solutions out there. We are there retiring the module, it does not really belong in an essentials like plugin.

A migrator for ProtectionPerms is available, GP will come soon after they version bump. An API is available to get the old data.

* Fix @scan scanner not being restricted to a specific Java package.

Fixes #822
  • Loading branch information
dualspiral committed May 9, 2017
1 parent b1ce87c commit 7e668af
Show file tree
Hide file tree
Showing 22 changed files with 337 additions and 826 deletions.
Expand Up @@ -7,6 +7,7 @@
import io.github.nucleuspowered.nucleus.api.service.NucleusAFKService;
import io.github.nucleuspowered.nucleus.api.service.NucleusAPIMetaService;
import io.github.nucleuspowered.nucleus.api.service.NucleusBackService;
import io.github.nucleuspowered.nucleus.api.service.NucleusBlacklistMigrationService;
import io.github.nucleuspowered.nucleus.api.service.NucleusHomeService;
import io.github.nucleuspowered.nucleus.api.service.NucleusJailService;
import io.github.nucleuspowered.nucleus.api.service.NucleusKitService;
Expand Down Expand Up @@ -94,7 +95,7 @@ public static Optional<NucleusAFKService> getAFKService() {
}

/**
* Gets the {@link NucleusAFKService}, if it exists.
* Gets the {@link NucleusBackService}, if it exists.
*
* <p>
* Requires the "back" module.
Expand All @@ -106,6 +107,19 @@ public static Optional<NucleusBackService> getBackService() {
return getService(NucleusBackService.class);
}

/**
* Gets the {@link NucleusBlacklistMigrationService}, if it exists.
*
* <p>
* Requires the "blacklist" module.
* </p>
*
* @return The {@link NucleusBlacklistMigrationService}
*/
public static Optional<NucleusBlacklistMigrationService> getBlacklistMigrationService() {
return getService(NucleusBlacklistMigrationService.class);
}

/**
* Gets the {@link NucleusHomeService}, if it exists.
*
Expand Down
@@ -0,0 +1,55 @@
/*
* This file is part of Nucleus, licensed under the MIT License (MIT). See the LICENSE.txt file
* at the root of this project for more details.
*/
package io.github.nucleuspowered.nucleus.api.service;

import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.item.ItemType;

import java.util.Map;

/**
* This service provides methods to support obtaining Nucleus' blacklist entries
* for use by another plugin.
*/
public interface NucleusBlacklistMigrationService {

/**
* Gets all the {@link BlockState}s that had a restriction on them.
*
* @return The {@link BlockState} and the results.
*/
Map<BlockState, Result> getBlacklistedBlockstates();

/**
* Gets all the {@link ItemType}s that had a restriction on them.
*
* @return The {@link ItemType}s and the results.
*/
Map<ItemType, Result> getBlacklistedItemtypes();

interface Result {

/**
* If true, Nucleus blocked this type from being placed/broken.
*
* @return <code>true</code> if blacklisted
*/
boolean environment();

/**
* If true, Nucleus blocked this item type from being used.
*
* @return <code>true</code> if blacklisted
*/
boolean use();

/**
* If true, Nucleus blocked this item type from being possessed.
*
* @return <code>true</code> if blacklisted
*/
boolean possession();
}
}
Expand Up @@ -10,13 +10,13 @@
@ConfigSerializable
public class BlacklistNode {

@Setting(value = "block-environment", comment = "loc:config.itemdatanode.blacklist.environment")
@Setting(value = "block-environment")
private boolean environment = false;

@Setting(value = "block-possesion", comment = "loc:config.itemdatanode.blacklist.possesion")
@Setting(value = "block-possesion")
private boolean inventory = false;

@Setting(value = "block-use", comment = "loc:config.itemdatanode.blacklist.block-use")
@Setting(value = "block-use")
private boolean use = false;

public boolean isEnvironment() {
Expand Down
Expand Up @@ -76,24 +76,29 @@ <T extends StandardAbstractCommand<?>> Optional<T> buildCommand(Class<T> command
cn.removeChild("aliases");
}

// Register the commands.
if (rootCmd) {
// This will return true for the first anyway
String first = c.getAliases()[0];
String[] aliases = Arrays.stream(c.getAliases()).filter(x -> x.equals(first) || node.getNode(x).getBoolean(true))
.toArray(String[]::new);
Sponge.getCommandManager().register(plugin, c, aliases);
}
try {
// Register the commands.
if (rootCmd) {
// This will return true for the first anyway
String first = c.getAliases()[0];
String[] aliases = Arrays.stream(c.getAliases()).filter(x -> x.equals(first) || node.getNode(x).getBoolean(true))
.toArray(String[]::new);
Sponge.getCommandManager().register(plugin, c, aliases);
}

// Register as another full blown command.
for (String s : c.getRootCommandAliases()) {
if (plugin.getCommandsConfig().getCommandNode(c.getCommandConfigAlias()).getNode("aliases", s).getBoolean(true)) {
Sponge.getCommandManager().register(plugin, c, s);
// Register as another full blown command.
for (String s : c.getRootCommandAliases()) {
if (plugin.getCommandsConfig().getCommandNode(c.getCommandConfigAlias()).getNode("aliases", s).getBoolean(true)) {
Sponge.getCommandManager().register(plugin, c, s);
}
}
}

if (c instanceof StandardAbstractCommand.Reloadable) {
plugin.registerReloadable(((StandardAbstractCommand.Reloadable) c)::onReload);
if (c instanceof StandardAbstractCommand.Reloadable) {
plugin.registerReloadable(((StandardAbstractCommand.Reloadable) c)::onReload);
}
} catch (Exception e) {
throw new IllegalStateException(plugin.getMessageProvider().getMessageWithFormat("startup.commandfailiure", c.getAliases()[0],
commandClass.getName()));
}

registeredCommands.add(c.getClass());
Expand Down
Expand Up @@ -16,8 +16,6 @@
import io.github.hsyyid.essentialcmds.utils.Utils;
import io.github.nucleuspowered.nucleus.Nucleus;
import io.github.nucleuspowered.nucleus.api.service.NucleusWarpService;
import io.github.nucleuspowered.nucleus.configurate.datatypes.item.BlacklistNode;
import io.github.nucleuspowered.nucleus.dataservices.ItemDataService;
import io.github.nucleuspowered.nucleus.modules.environment.datamodule.EnvironmentWorldDataModule;
import io.github.nucleuspowered.nucleus.modules.home.datamodules.HomeUserDataModule;
import io.github.nucleuspowered.nucleus.modules.jail.data.JailData;
Expand All @@ -32,8 +30,6 @@
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.entity.Transform;
import org.spongepowered.api.entity.living.player.User;
import org.spongepowered.api.item.ItemType;
import org.spongepowered.api.item.ItemTypes;
import org.spongepowered.api.service.user.UserStorageService;
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;
Expand Down Expand Up @@ -71,22 +67,6 @@ public void migrate(CommandSource src) throws Exception {
src.sendMessage(Nucleus.getNucleus().getMessageProvider().getTextMessageWithFormat("command.nucleus.migrate.warps"));
}

// Blacklisted items
ItemDataService ids = this.plugin.getItemDataService();
for (String item : Utils.getBlacklistItems()) {
ItemType itemType = Sponge.getRegistry().getType(ItemType.class, item).orElse(ItemTypes.NONE);

if (itemType != ItemTypes.NONE) {
BlacklistNode bn = ids.getDataForItem(itemType.getId()).getBlacklist();
bn.setUse(true);
bn.setEnvironment(true);
bn.setInventory(true);
ids.save();
}
}

src.sendMessage(Nucleus.getNucleus().getMessageProvider().getTextMessageWithFormat("command.nucleus.migrate.blacklist"));

// Homes
Configurable homesConfig = HomeConfig.getConfig();

Expand Down
Expand Up @@ -107,6 +107,7 @@ private void loadCommands() {

// Find all commands that are also scannable.
performFilter(plugin.getModuleContainer().getLoadedClasses().stream()
.filter(x -> x.getPackage().getName().startsWith(packageName))
.filter(x -> x.isAnnotationPresent(Scan.class))
.flatMap(x -> Arrays.stream(x.getDeclaredClasses()))
.filter(StandardAbstractCommand.class::isAssignableFrom)
Expand Down
Expand Up @@ -4,17 +4,30 @@
*/
package io.github.nucleuspowered.nucleus.modules.blacklist;

import io.github.nucleuspowered.nucleus.internal.qsml.module.ConfigurableModule;
import io.github.nucleuspowered.nucleus.modules.blacklist.config.BlacklistConfigAdapter;
import io.github.nucleuspowered.nucleus.api.service.NucleusBlacklistMigrationService;
import io.github.nucleuspowered.nucleus.internal.qsml.module.StandardModule;
import io.github.nucleuspowered.nucleus.modules.blacklist.handler.BlacklistMigrationHandler;
import org.spongepowered.api.Sponge;
import uk.co.drnaylor.quickstart.annotations.ModuleData;

@ModuleData(id = BlacklistModule.ID, name = "Blacklist")
public class BlacklistModule extends ConfigurableModule<BlacklistConfigAdapter> {
@ModuleData(id = "blacklist", name = "Blacklist")
public class BlacklistModule extends StandardModule {

public final static String ID = "blacklist";
@Override public void onEnable() {
super.onEnable();

@Override
public BlacklistConfigAdapter createAdapter() {
return new BlacklistConfigAdapter();
plugin.getLogger().warn("-----------------------------------");
plugin.getLogger().warn("NOTICE OF REMOVAL: BLACKLIST MODULE");
plugin.getLogger().warn("-----------------------------------");
plugin.getLogger().warn("The item blacklist module has been removed from Nucleus. Please use some other protection plugin, such as "
+ "GriefPrevention that can block these items.");
plugin.getLogger().warn("A migrator for those of you that use ProtectionPerms has been provided, run `/blacklist migrate pp` to "
+ "attempt to migrate.");
plugin.getLogger().warn("A migrator for those of you that use GriefPrevention will be provided soon.");
plugin.getLogger().warn("-----------------------------------");

BlacklistMigrationHandler bmh = new BlacklistMigrationHandler();
plugin.getInternalServiceManager().registerService(BlacklistMigrationHandler.class, bmh);
Sponge.getServiceManager().setProvider(plugin, NucleusBlacklistMigrationService.class, bmh);
}
}

This file was deleted.

This file was deleted.

0 comments on commit 7e668af

Please sign in to comment.