Fixed a bug where removing something from a blacklist didn't trigger a save, added some commands for adding/removing the currently held item to/from a blacklist, and changed the set energy commands to manage blacklist entries depending on values used (if the value is 0 then the item is blacklisted)

This commit is contained in:
Pahimar 2016-05-24 14:58:56 -04:00
parent 2046edf3fb
commit c179405dab
11 changed files with 306 additions and 33 deletions

View file

@ -131,12 +131,14 @@ public class BlacklistRegistry {
if (wrappedStack != null && !MinecraftForge.EVENT_BUS.post(new KnowledgeWhitelistEvent(object))) {
LogHelper.trace(KNOWLEDGE_WHITELIST_MARKER, "[{}] Mod with ID '{}' removed object {} from the player knowledge blacklist", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), wrappedStack);
knowledgeBlacklist.remove(wrappedStack);
save(blacklist);
}
}
else if (blacklist == Blacklist.EXCHANGE) {
if (wrappedStack != null && !MinecraftForge.EVENT_BUS.post(new ExchangeWhitelistEvent(object))) {
LogHelper.trace(EXCHANGE_WHITELIST_MARKER, "[{}] Mod with ID '{}' removed object {} from the exchange blacklist", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), wrappedStack);
exchangeBlacklist.remove(wrappedStack);
save(blacklist);
}
}
}

View file

@ -61,21 +61,24 @@ public class CommandEE extends CommandBase
return null;
}
static
{
static {
modCommands.add(new CommandSetEnergyValue());
modCommands.add(new CommandSetEnergyValueCurrentItem());
modCommands.add(new CommandSyncEnergyValues());
modCommands.add(new CommandRegenEnergyValues());
modCommands.add(new CommandPlayerLearnItem());
modCommands.add(new CommandPlayerLearnCurrentItem());
modCommands.add(new CommandPlayerForgetEverything());
modCommands.add(new CommandPlayerForgetItem());
modCommands.add(new CommandPlayerForgetCurrentItem());
modCommands.add(new CommandSetItemLearnable());
modCommands.add(new CommandSetCurrentItemLearnable());
modCommands.add(new CommandSetItemNotLearnable());
modCommands.add(new CommandSetCurrentItemNotLearnable());
modCommands.add(new CommandSetItemRecoverable());
modCommands.add(new CommandSetCurrentItemRecoverable());
modCommands.add(new CommandSetItemNotRecoverable());
modCommands.add(new CommandSetCurrentItemNotRecoverable());
modCommands.add(new CommandSyncEnergyValues());
modCommands.add(new CommandRegenEnergyValues());
modCommands.add(new CommandRunTest());
for (CommandBase commandBase : modCommands)

View file

@ -0,0 +1,55 @@
package com.pahimar.ee3.command;
import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy;
import com.pahimar.ee3.reference.Messages;
import com.pahimar.ee3.reference.Names;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentTranslation;
import java.util.List;
public class CommandSetCurrentItemLearnable extends CommandBase {
@Override
public String getCommandName() {
return Names.Commands.SET_CURRENT_ITEM_LEARNABLE;
}
@Override
public int getRequiredPermissionLevel() {
return 2;
}
@Override
public String getCommandUsage(ICommandSender commandSender) {
return Messages.Commands.SET_CURRENT_ITEM_LEARNABLE_USAGE;
}
@Override
public void processCommand(ICommandSender commandSender, String[] args) {
ItemStack itemStack = ((EntityPlayer) commandSender).getCurrentEquippedItem();
if (itemStack != null) {
if (!BlacklistRegistryProxy.isLearnable(itemStack)) {
BlacklistRegistryProxy.setAsLearnable(itemStack);
func_152373_a(commandSender, this, Messages.Commands.SET_CURRENT_ITEM_LEARNABLE_SUCCESS, new Object[]{commandSender.getCommandSenderName(), itemStack.func_151000_E()});
}
else {
commandSender.addChatMessage(new ChatComponentTranslation(Messages.Commands.SET_CURRENT_ITEM_LEARNABLE_NO_EFFECT, itemStack));
}
}
else {
throw new WrongUsageException(Messages.Commands.NO_ITEM);
}
}
@Override
public List addTabCompletionOptions(ICommandSender commandSender, String[] args) {
return null;
}
}

View file

@ -0,0 +1,55 @@
package com.pahimar.ee3.command;
import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy;
import com.pahimar.ee3.reference.Messages;
import com.pahimar.ee3.reference.Names;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentTranslation;
import java.util.List;
public class CommandSetCurrentItemNotLearnable extends CommandBase {
@Override
public String getCommandName() {
return Names.Commands.SET_CURRENT_ITEM_NOT_LEARNABLE;
}
@Override
public int getRequiredPermissionLevel() {
return 2;
}
@Override
public String getCommandUsage(ICommandSender commandSender) {
return Messages.Commands.SET_CURRENT_ITEM_NOT_LEARNABLE_USAGE;
}
@Override
public void processCommand(ICommandSender commandSender, String[] args) {
ItemStack itemStack = ((EntityPlayer) commandSender).getCurrentEquippedItem();
if (itemStack != null) {
if (BlacklistRegistryProxy.isLearnable(itemStack)) {
BlacklistRegistryProxy.setAsNotLearnable(itemStack);
func_152373_a(commandSender, this, Messages.Commands.SET_CURRENT_ITEM_NOT_LEARNABLE_SUCCESS, new Object[]{commandSender.getCommandSenderName(), itemStack.func_151000_E()});
}
else {
commandSender.addChatMessage(new ChatComponentTranslation(Messages.Commands.SET_CURRENT_ITEM_NOT_LEARNABLE_NO_EFFECT, itemStack));
}
}
else {
throw new WrongUsageException(Messages.Commands.NO_ITEM);
}
}
@Override
public List addTabCompletionOptions(ICommandSender commandSender, String[] args) {
return null;
}
}

View file

@ -0,0 +1,55 @@
package com.pahimar.ee3.command;
import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy;
import com.pahimar.ee3.reference.Messages;
import com.pahimar.ee3.reference.Names;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentTranslation;
import java.util.List;
public class CommandSetCurrentItemNotRecoverable extends CommandBase {
@Override
public String getCommandName() {
return Names.Commands.SET_CURRENT_ITEM_NOT_RECOVERABLE;
}
@Override
public int getRequiredPermissionLevel() {
return 2;
}
@Override
public String getCommandUsage(ICommandSender commandSender) {
return Messages.Commands.SET_CURRENT_ITEM_NOT_RECOVERABLE_USAGE;
}
@Override
public void processCommand(ICommandSender commandSender, String[] args) {
ItemStack itemStack = ((EntityPlayer) commandSender).getCurrentEquippedItem();
if (itemStack != null) {
if (BlacklistRegistryProxy.isExchangeable(itemStack)) {
BlacklistRegistryProxy.setAsNotExchangeable(itemStack);
func_152373_a(commandSender, this, Messages.Commands.SET_CURRENT_ITEM_NOT_RECOVERABLE_SUCCESS, new Object[]{commandSender.getCommandSenderName(), itemStack.func_151000_E()});
}
else {
commandSender.addChatMessage(new ChatComponentTranslation(Messages.Commands.SET_CURRENT_ITEM_NOT_RECOVERABLE_NO_EFFECT, itemStack));
}
}
else {
throw new WrongUsageException(Messages.Commands.NO_ITEM);
}
}
@Override
public List addTabCompletionOptions(ICommandSender commandSender, String[] args) {
return null;
}
}

View file

@ -0,0 +1,55 @@
package com.pahimar.ee3.command;
import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy;
import com.pahimar.ee3.reference.Messages;
import com.pahimar.ee3.reference.Names;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentTranslation;
import java.util.List;
public class CommandSetCurrentItemRecoverable extends CommandBase {
@Override
public String getCommandName() {
return Names.Commands.SET_CURRENT_ITEM_RECOVERABLE;
}
@Override
public int getRequiredPermissionLevel() {
return 2;
}
@Override
public String getCommandUsage(ICommandSender commandSender) {
return Messages.Commands.SET_CURRENT_ITEM_RECOVERABLE_USAGE;
}
@Override
public void processCommand(ICommandSender commandSender, String[] args) {
ItemStack itemStack = ((EntityPlayer) commandSender).getCurrentEquippedItem();
if (itemStack != null) {
if (!BlacklistRegistryProxy.isExchangeable(itemStack)) {
BlacklistRegistryProxy.setAsExchangeable(itemStack);
func_152373_a(commandSender, this, Messages.Commands.SET_CURRENT_ITEM_RECOVERABLE_SUCCESS, new Object[]{commandSender.getCommandSenderName(), itemStack.func_151000_E()});
}
else {
commandSender.addChatMessage(new ChatComponentTranslation(Messages.Commands.SET_CURRENT_ITEM_RECOVERABLE_NO_EFFECT, itemStack));
}
}
else {
throw new WrongUsageException(Messages.Commands.NO_ITEM);
}
}
@Override
public List addTabCompletionOptions(ICommandSender commandSender, String[] args) {
return null;
}
}

View file

@ -1,5 +1,6 @@
package com.pahimar.ee3.command;
import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy;
import com.pahimar.ee3.api.exchange.EnergyValue;
import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy;
import com.pahimar.ee3.exchange.EnergyValueRegistry;
@ -87,21 +88,30 @@ public class CommandSetEnergyValue extends CommandBase
WrappedStack wrappedStack = WrappedStack.wrap(itemStack);
EnergyValue newEnergyValue = new EnergyValue(energyValue);
if (wrappedStack != null && newEnergyValue != null && Float.compare(newEnergyValue.getValue(), 0) > 0)
if (wrappedStack != null && newEnergyValue != null)
{
if (args[1].equalsIgnoreCase("pre")) {
EnergyValueRegistryProxy.setEnergyValue(wrappedStack, newEnergyValue, EnergyValueRegistryProxy.Phase.PRE_CALCULATION);
}
else if (args[1].equalsIgnoreCase("post")) {
EnergyValueRegistryProxy.setEnergyValue(wrappedStack, newEnergyValue);
}
else {
throw new WrongUsageException(Messages.Commands.SET_ENERGY_VALUE_USAGE);
}
if (Float.compare(newEnergyValue.getValue(), 0) > 0) {
EnergyValueRegistry.INSTANCE.save();
// Notify admins and log the value change
func_152373_a(commandSender, this, Messages.Commands.SET_ENERGY_VALUE_SUCCESS, new Object[]{commandSender.getCommandSenderName(), args[1], itemStack.func_151000_E(), newEnergyValue.getChatComponent()});
if (args[1].equalsIgnoreCase("pre")) {
EnergyValueRegistryProxy.setEnergyValue(wrappedStack, newEnergyValue, EnergyValueRegistryProxy.Phase.PRE_CALCULATION);
}
else if (args[1].equalsIgnoreCase("post")) {
EnergyValueRegistryProxy.setEnergyValue(wrappedStack, newEnergyValue);
}
else {
throw new WrongUsageException(Messages.Commands.SET_ENERGY_VALUE_USAGE);
}
EnergyValueRegistry.INSTANCE.save();
// Notify admins and log the value change
func_152373_a(commandSender, this, Messages.Commands.SET_ENERGY_VALUE_SUCCESS, new Object[]{commandSender.getCommandSenderName(), args[1], itemStack.func_151000_E(), newEnergyValue.getChatComponent()});
}
else if (Float.compare(newEnergyValue.getValue(), 0) == 0) {
BlacklistRegistryProxy.setAsNotLearnable(wrappedStack);
BlacklistRegistryProxy.setAsNotExchangeable(wrappedStack);
func_152373_a(commandSender, this, "%s set %s as not learnable and not exchangeable", new Object[]{commandSender.getCommandSenderName(), itemStack.func_151000_E()});
}
}
else
{

View file

@ -1,5 +1,6 @@
package com.pahimar.ee3.command;
import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy;
import com.pahimar.ee3.api.exchange.EnergyValue;
import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy;
import com.pahimar.ee3.exchange.EnergyValueRegistry;
@ -57,23 +58,29 @@ public class CommandSetEnergyValueCurrentItem extends CommandBase
WrappedStack wrappedStack = WrappedStack.wrap(itemStack);
EnergyValue newEnergyValue = new EnergyValue(energyValue);
if (wrappedStack != null && newEnergyValue != null && Float.compare(newEnergyValue.getValue(), 0) > 0)
if (wrappedStack != null && newEnergyValue != null)
{
if (args[1].equalsIgnoreCase("pre"))
{
EnergyValueRegistryProxy.setEnergyValue(wrappedStack, newEnergyValue, EnergyValueRegistryProxy.Phase.PRE_CALCULATION);
}
else if (args[1].equalsIgnoreCase("post"))
{
EnergyValueRegistryProxy.setEnergyValue(wrappedStack, newEnergyValue);
}
else
{
throw new WrongUsageException(Messages.Commands.SET_ENERGY_VALUE_CURRENT_ITEM_USAGE);
}
if (Float.compare(newEnergyValue.getValue(), 0) > 0) {
// Notify admins and log the value change
func_152373_a(commandSender, this, Messages.Commands.SET_ENERGY_VALUE_CURRENT_ITEM_SUCCESS, new Object[]{commandSender.getCommandSenderName(), args[1], itemStack.func_151000_E(), newEnergyValue.getChatComponent()});
if (args[1].equalsIgnoreCase("pre")) {
EnergyValueRegistryProxy.setEnergyValue(wrappedStack, newEnergyValue, EnergyValueRegistryProxy.Phase.PRE_CALCULATION);
}
else if (args[1].equalsIgnoreCase("post")) {
EnergyValueRegistryProxy.setEnergyValue(wrappedStack, newEnergyValue);
}
else {
throw new WrongUsageException(Messages.Commands.SET_ENERGY_VALUE_CURRENT_ITEM_USAGE);
}
// Notify admins and log the value change
func_152373_a(commandSender, this, Messages.Commands.SET_ENERGY_VALUE_CURRENT_ITEM_SUCCESS, new Object[]{commandSender.getCommandSenderName(), args[1], itemStack.func_151000_E(), newEnergyValue.getChatComponent()});
}
else if (Float.compare(newEnergyValue.getValue(), 0) == 0) {
BlacklistRegistryProxy.setAsNotLearnable(wrappedStack);
BlacklistRegistryProxy.setAsNotExchangeable(wrappedStack);
func_152373_a(commandSender, this, "%s set %s as not learnable and not exchangeable", new Object[]{commandSender.getCommandSenderName(), itemStack.func_151000_E()});
}
}
else
{

View file

@ -75,15 +75,31 @@ public final class Messages {
public static final String SET_ITEM_LEARNABLE_USAGE = COMMAND_PREFIX + Names.Commands.SET_ITEM_LEARNABLE + ".usage";
public static final String SET_ITEM_LEARNABLE_SUCCESS = COMMAND_PREFIX + Names.Commands.SET_ITEM_LEARNABLE + ".success";
public static final String SET_CURRENT_ITEM_LEARNABLE_USAGE = COMMAND_PREFIX + Names.Commands.SET_ITEM_LEARNABLE + ".usage";
public static final String SET_CURRENT_ITEM_LEARNABLE_SUCCESS = COMMAND_PREFIX + Names.Commands.SET_ITEM_LEARNABLE + ".success";
public static final String SET_CURRENT_ITEM_LEARNABLE_NO_EFFECT = COMMAND_PREFIX + Names.Commands.SET_ITEM_LEARNABLE + ".no-effect";
public static final String SET_ITEM_NOT_LEARNABLE_USAGE = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_LEARNABLE + ".usage";
public static final String SET_ITEM_NOT_LEARNABLE_SUCCESS = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_LEARNABLE + ".success";
public static final String SET_CURRENT_ITEM_NOT_LEARNABLE_USAGE = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_LEARNABLE + ".usage";
public static final String SET_CURRENT_ITEM_NOT_LEARNABLE_SUCCESS = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_LEARNABLE + ".success";
public static final String SET_CURRENT_ITEM_NOT_LEARNABLE_NO_EFFECT = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_LEARNABLE + ".no-effect";
public static final String SET_ITEM_RECOVERABLE_USAGE = COMMAND_PREFIX + Names.Commands.SET_ITEM_RECOVERABLE + ".usage";
public static final String SET_ITEM_RECOVERABLE_SUCCESS = COMMAND_PREFIX + Names.Commands.SET_ITEM_RECOVERABLE + ".success";
public static final String SET_CURRENT_ITEM_RECOVERABLE_USAGE = COMMAND_PREFIX + Names.Commands.SET_ITEM_RECOVERABLE + ".usage";
public static final String SET_CURRENT_ITEM_RECOVERABLE_SUCCESS = COMMAND_PREFIX + Names.Commands.SET_ITEM_RECOVERABLE + ".success";
public static final String SET_CURRENT_ITEM_RECOVERABLE_NO_EFFECT = COMMAND_PREFIX + Names.Commands.SET_ITEM_RECOVERABLE + ".no-effect";
public static final String SET_ITEM_NOT_RECOVERABLE_USAGE = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_RECOVERABLE + ".usage";
public static final String SET_ITEM_NOT_RECOVERABLE_SUCCESS = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_RECOVERABLE + ".success";
public static final String SET_CURRENT_ITEM_NOT_RECOVERABLE_USAGE = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_RECOVERABLE + ".usage";
public static final String SET_CURRENT_ITEM_NOT_RECOVERABLE_SUCCESS = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_RECOVERABLE + ".success";
public static final String SET_CURRENT_ITEM_NOT_RECOVERABLE_NO_EFFECT = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_RECOVERABLE + ".no-effect";
public static final String RUN_TEST_USAGE = COMMAND_PREFIX + Names.Commands.RUN_TEST + ".usage";
public static final String RUN_TESTS_SUCCESS = COMMAND_PREFIX + Names.Commands.RUN_TEST + ".success";
public static final String RUN_TESTS_NOT_FOUND = COMMAND_PREFIX + Names.Commands.RUN_TEST + ".notfound";

View file

@ -148,9 +148,13 @@ public class Names
public static final String PLAYER_FORGET_ITEM = "player-forget-item";
public static final String PLAYER_FORGET_CURRENT_ITEM = "player-forget-current-item";
public static final String SET_ITEM_LEARNABLE = "set-item-learnable";
public static final String SET_CURRENT_ITEM_LEARNABLE = "set-current-item-learnable";
public static final String SET_ITEM_NOT_LEARNABLE = "set-item-not-learnable";
public static final String SET_CURRENT_ITEM_NOT_LEARNABLE = "set-current-item-not-learnable";
public static final String SET_ITEM_RECOVERABLE = "set-item-recoverable";
public static final String SET_CURRENT_ITEM_RECOVERABLE = "set-current-item-recoverable";
public static final String SET_ITEM_NOT_RECOVERABLE = "set-item-not-recoverable";
public static final String SET_CURRENT_ITEM_NOT_RECOVERABLE = "set-current-item-not-recoverable";
public static final String RUN_TEST = "run-tests";
public static final String DEBUG = "debug";
public static final String ADMIN_PANEL = "admin";

View file

@ -157,16 +157,27 @@ commands.ee3.player-forget-current-item.usage=/ee3 player-forget-current-item <p
commands.ee3.player-forget-current-item.success=%s made %s forget how to transmute %s
commands.ee3.set-item-learnable.usage=/ee3 set-item-learnable <item> <data> [dataTag]
commands.ee3.set-item-learnable.success=%s set %s as learnable for transmutations
commands.ee3.set-current-item-learnable.usage=/ee3 set-current-item-learnable
commands.ee3.set-current-item-learnable.success=%s set %s as learnable for transmutations
commands.ee3.set-current-item-learnable.no-effect=%s is already learnable
commands.ee3.set-item-not-learnable.usage=/ee3 set-item-not-learnable <item> <data> [dataTag]
commands.ee3.set-item-not-learnable.success=%s set %s as not learnable for transmutations
commands.ee3.set-current-item-not-learnable.usage=/ee3 set-current-item-not-learnable
commands.ee3.set-current-item-not-learnable.success=%s set %s as not learnable for transmutations
commands.ee3.set-current-item-not-learnable.no-effect=%s is already not learnable
commands.ee3.set-item-recoverable.usage=/ee3 set-item-recoverable <item> <data> [dataTag]
commands.ee3.set-item-recoverable.success=%s set %s as being able to have its energy value recovered
commands.ee3.set-current-item-recoverable.usage=/ee3 set-current-item-recoverable
commands.ee3.set-current-item-recoverable.success=%s set %s as being able to have its energy value recovered
commands.ee3.set-current-item-recoverable.no-effect=%s is already exchangeable
commands.ee3.set-item-not-recoverable.usage=/ee3 set-item-not-recoverable <item> <data> [dataTag]
commands.ee3.set-item-not-recoverable.success=%s set %s as not being able to have its energy value recovered
commands.ee3.set-current-item-not-recoverable.usage=/ee3 set-current-item-not-recoverable
commands.ee3.set-current-item-not-recoverable.success=%s set %s as not being able to have its energy value recovered
commands.ee3.set-current-item-not-recoverable.no-effect=%s is already not exchangeable
commands.ee3.run-tests.usage=/ee3 run-tests <file-name>
commands.ee3.run-tests.success=Executed test file '%s', check server log for results
commands.ee3.run-tests.notfound=Test file '%s' was not found!
commands.ee3.admin.usage=/ee3 admin
# Tooltips
tooltip.ee3:belongsTo=Belongs to %s