mirror of
https://github.com/chylex/Hardcore-Ender-Expansion.git
synced 2025-04-10 20:15:42 +02:00
Update API to use MORE LAMBDAS
This commit is contained in:
parent
3a79adebda
commit
1c2ead237e
src/main/java/chylex/hee/api/message
@ -0,0 +1,6 @@
|
||||
package chylex.hee.api.message;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface IMessageHandler{
|
||||
void call(MessageRunner runner);
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package chylex.hee.api.message;
|
||||
|
||||
public abstract class MessageHandler{
|
||||
public abstract void call(MessageRunner runner);
|
||||
}
|
@ -6,9 +6,9 @@ import chylex.hee.api.message.utils.MessageLogger;
|
||||
|
||||
public final class MessagePattern{
|
||||
private final PreconditionComposite<?> conditions = PreconditionComposite.noValue();
|
||||
private final MessageHandler handler;
|
||||
private final IMessageHandler handler;
|
||||
|
||||
MessagePattern(MessageHandler handler){
|
||||
MessagePattern(IMessageHandler handler){
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ public final class MessageRegistry{
|
||||
private static Map<String,MessagePattern> registry;
|
||||
private static Map<String,RunEvent> events;
|
||||
|
||||
public static MessagePattern register(String key, MessageHandler handler, RunEvent event){
|
||||
public static MessagePattern register(String key, IMessageHandler handler, RunEvent event){
|
||||
MessagePattern pattern = new MessagePattern(handler);
|
||||
if (registry.put(key,pattern) != null)throw new IllegalArgumentException("Cannot register duplicate IMC message key: "+key);
|
||||
events.put(key,event);
|
||||
|
@ -7,7 +7,6 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
import chylex.hee.api.message.MessageRunner;
|
||||
import chylex.hee.api.message.element.base.Optional;
|
||||
import chylex.hee.api.message.element.base.PreconditionComposite;
|
||||
import com.google.common.base.Function;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ItemStackValue extends PreconditionComposite<ItemStack>{
|
||||
@ -15,12 +14,7 @@ public class ItemStackValue extends PreconditionComposite<ItemStack>{
|
||||
return new ItemStackValue();
|
||||
}
|
||||
|
||||
public static final StringValue itemString = StringValue.function(new Function<String,Boolean>(){
|
||||
@Override
|
||||
public Boolean apply(String input){
|
||||
return Boolean.valueOf(getItemFromString(input) != null);
|
||||
}
|
||||
});
|
||||
public static final StringValue itemString = StringValue.function(input -> getItemFromString(input) != null);
|
||||
|
||||
public static final Pair<String,String> parseItemName(String fullName){
|
||||
String modid = "minecraft", name = "";
|
||||
|
@ -4,19 +4,15 @@ import net.minecraft.entity.EntityLiving;
|
||||
import chylex.hee.api.message.MessageRunner;
|
||||
import chylex.hee.api.message.element.base.PreconditionComposite;
|
||||
import chylex.hee.world.util.SpawnEntry;
|
||||
import com.google.common.base.Function;
|
||||
|
||||
public class SpawnEntryValue extends PreconditionComposite<SpawnEntry>{
|
||||
public static SpawnEntryValue any(){
|
||||
return new SpawnEntryValue();
|
||||
}
|
||||
|
||||
public static final StringValue livingMobString = StringValue.function(new Function<String,Boolean>(){
|
||||
@Override
|
||||
public Boolean apply(String input){
|
||||
Class<?> cls = (Class<?>)EntityList.stringToClassMapping.get(input);
|
||||
return Boolean.valueOf(cls != null && EntityLiving.class.isAssignableFrom(cls));
|
||||
}
|
||||
public static final StringValue livingMobString = StringValue.function(input -> {
|
||||
Class<?> cls = (Class<?>)EntityList.stringToClassMapping.get(input);
|
||||
return cls != null && EntityLiving.class.isAssignableFrom(cls);
|
||||
});
|
||||
|
||||
private SpawnEntryValue(){
|
||||
|
@ -1,11 +1,11 @@
|
||||
package chylex.hee.api.message.element;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Predicate;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import chylex.hee.api.message.element.base.Precondition;
|
||||
import com.google.common.base.Function;
|
||||
|
||||
public abstract class StringValue extends Precondition<String>{
|
||||
public static StringValue any(){
|
||||
@ -16,7 +16,7 @@ public abstract class StringValue extends Precondition<String>{
|
||||
return new StringValueArray(validValues);
|
||||
}
|
||||
|
||||
public static StringValue function(Function<String,Boolean> checkFunction){
|
||||
public static StringValue function(Predicate<String> checkFunction){
|
||||
return new StringValueFunction(checkFunction);
|
||||
}
|
||||
|
||||
@ -55,15 +55,15 @@ public abstract class StringValue extends Precondition<String>{
|
||||
}
|
||||
|
||||
private static class StringValueFunction extends StringValue{
|
||||
private final Function<String,Boolean> checkFunction;
|
||||
private final Predicate<String> checkFunction;
|
||||
|
||||
private StringValueFunction(Function<String,Boolean> checkFunction){
|
||||
private StringValueFunction(Predicate<String> checkFunction){
|
||||
this.checkFunction = checkFunction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkValue(NBTBase tag){
|
||||
return checkFunction.apply(getValue(tag)).booleanValue();
|
||||
return checkFunction.test(getValue(tag));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
package chylex.hee.api.message.handlers;
|
||||
import java.util.Iterator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import chylex.hee.api.message.MessageHandler;
|
||||
import chylex.hee.api.message.MessageRunner;
|
||||
import chylex.hee.api.message.IMessageHandler;
|
||||
import chylex.hee.api.message.element.IntValue;
|
||||
import chylex.hee.api.message.element.ItemPatternValue;
|
||||
import chylex.hee.api.message.element.ItemStackValue;
|
||||
@ -14,46 +13,40 @@ import chylex.hee.mechanics.essence.handler.dragon.AltarItemRecipe;
|
||||
import chylex.hee.system.util.ItemPattern;
|
||||
|
||||
public final class ImcEssenceHandlers extends ImcHandler{
|
||||
private static final MessageHandler dragonEssenceAdd = new MessageHandler(){
|
||||
@Override
|
||||
public void call(MessageRunner runner){
|
||||
ItemStack input = runner.<ItemStack>getValue("input");
|
||||
|
||||
for(AltarItemRecipe recipe:DragonEssenceHandler.recipes){
|
||||
if (ItemStack.areItemStacksEqual(recipe.input,input) && ItemStack.areItemStackTagsEqual(recipe.input,input)){
|
||||
MessageLogger.logFail("Duplicate input item, ignoring.");
|
||||
return;
|
||||
}
|
||||
private static final IMessageHandler dragonEssenceAdd = runner -> {
|
||||
ItemStack input = runner.getValue("input");
|
||||
|
||||
for(AltarItemRecipe recipe:DragonEssenceHandler.recipes){
|
||||
if (ItemStack.areItemStacksEqual(recipe.input,input) && ItemStack.areItemStackTagsEqual(recipe.input,input)){
|
||||
MessageLogger.logFail("Duplicate input item, ignoring.");
|
||||
return;
|
||||
}
|
||||
|
||||
DragonEssenceHandler.recipes.add(new AltarItemRecipe(input,runner.<ItemStack>getValue("output"),runner.getInt("cost")));
|
||||
MessageLogger.logOk("Added 1 recipe.");
|
||||
}
|
||||
|
||||
DragonEssenceHandler.recipes.add(new AltarItemRecipe(input,runner.getValue("output"),runner.getInt("cost")));
|
||||
MessageLogger.logOk("Added 1 recipe.");
|
||||
};
|
||||
|
||||
private static final MessageHandler dragonEssenceRemove = new MessageHandler(){
|
||||
@Override
|
||||
public void call(MessageRunner runner){
|
||||
boolean input = runner.getString("type").equals("input");
|
||||
ItemPattern pattern = runner.<ItemPattern>getValue("search");
|
||||
int limit = runner.getInt("limit");
|
||||
private static final IMessageHandler dragonEssenceRemove = runner -> {
|
||||
boolean input = runner.getString("type").equals("input");
|
||||
ItemPattern pattern = runner.getValue("search");
|
||||
int limit = runner.getInt("limit");
|
||||
|
||||
int size = DragonEssenceHandler.recipes.size();
|
||||
|
||||
for(Iterator<AltarItemRecipe> iter = DragonEssenceHandler.recipes.iterator(); iter.hasNext();){
|
||||
AltarItemRecipe recipe = iter.next();
|
||||
|
||||
int size = DragonEssenceHandler.recipes.size();
|
||||
|
||||
for(Iterator<AltarItemRecipe> iter = DragonEssenceHandler.recipes.iterator(); iter.hasNext();){
|
||||
AltarItemRecipe recipe = iter.next();
|
||||
|
||||
if (pattern.matches(input ? recipe.input : recipe.output)){
|
||||
iter.remove();
|
||||
if (limit > 0 && --limit == 0)break;
|
||||
}
|
||||
if (pattern.matches(input ? recipe.input : recipe.output)){
|
||||
iter.remove();
|
||||
if (limit > 0 && --limit == 0)break;
|
||||
}
|
||||
|
||||
size = size-DragonEssenceHandler.recipes.size();
|
||||
|
||||
if (size == 0)MessageLogger.logWarn("Did not find any items to remove.");
|
||||
else MessageLogger.logOk("Removed $0 item(s).",size);
|
||||
}
|
||||
|
||||
size = size-DragonEssenceHandler.recipes.size();
|
||||
|
||||
if (size == 0)MessageLogger.logWarn("Did not find any items to remove.");
|
||||
else MessageLogger.logOk("Removed $0 item(s).",size);
|
||||
};
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
package chylex.hee.api.message.handlers;
|
||||
import chylex.hee.api.message.MessageHandler;
|
||||
import chylex.hee.api.message.IMessageHandler;
|
||||
import chylex.hee.api.message.MessagePattern;
|
||||
import chylex.hee.api.message.MessageRegistry;
|
||||
import chylex.hee.api.message.utils.RunEvent;
|
||||
@ -18,7 +18,7 @@ public abstract class ImcHandler{
|
||||
for(ImcHandler handler:handlers)handler.register();
|
||||
}
|
||||
|
||||
protected final MessagePattern register(String key, MessageHandler handler, RunEvent event){
|
||||
protected final MessagePattern register(String key, IMessageHandler handler, RunEvent event){
|
||||
return MessageRegistry.register(key,handler,event);
|
||||
}
|
||||
|
||||
|
@ -1,18 +1,14 @@
|
||||
package chylex.hee.api.message.handlers;
|
||||
import chylex.hee.api.message.MessageHandler;
|
||||
import chylex.hee.api.message.MessageRunner;
|
||||
import chylex.hee.api.message.IMessageHandler;
|
||||
import chylex.hee.api.message.element.SpawnEntryValue;
|
||||
import chylex.hee.api.message.utils.MessageLogger;
|
||||
import chylex.hee.api.message.utils.RunEvent;
|
||||
import chylex.hee.entity.GlobalMobData;
|
||||
|
||||
public final class ImcMobHandlers extends ImcHandler{
|
||||
private static final MessageHandler enderGooTolerantAdd = new MessageHandler(){
|
||||
@Override
|
||||
public void call(MessageRunner runner){
|
||||
if (GlobalMobData.setEnderGooTolerant(runner.getString("id")))MessageLogger.logOk("Added 1 mob to the list.");
|
||||
else MessageLogger.logFail("The mob was already in the list.");
|
||||
}
|
||||
private static final IMessageHandler enderGooTolerantAdd = runner -> {
|
||||
if (GlobalMobData.setEnderGooTolerant(runner.getString("id")))MessageLogger.logOk("Added 1 mob to the list.");
|
||||
else MessageLogger.logFail("The mob was already in the list.");
|
||||
};
|
||||
|
||||
@Override
|
||||
|
@ -3,8 +3,7 @@ import java.util.Iterator;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.boss.IBossDisplayData;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import chylex.hee.api.message.MessageHandler;
|
||||
import chylex.hee.api.message.MessageRunner;
|
||||
import chylex.hee.api.message.IMessageHandler;
|
||||
import chylex.hee.api.message.element.ItemPatternValue;
|
||||
import chylex.hee.api.message.element.SpawnEntryValue;
|
||||
import chylex.hee.api.message.utils.MessageLogger;
|
||||
@ -16,48 +15,39 @@ import chylex.hee.mechanics.orb.WeightedItemList;
|
||||
import chylex.hee.system.util.ItemPattern;
|
||||
|
||||
public class ImcOrbHandlers extends ImcHandler{
|
||||
private static final MessageHandler itemBlacklist = new MessageHandler(){
|
||||
@Override
|
||||
public void call(MessageRunner runner){
|
||||
ItemPattern pattern = runner.<ItemPattern>getValue("pattern");
|
||||
private static final IMessageHandler itemBlacklist = runner -> {
|
||||
ItemPattern pattern = runner.getValue("pattern");
|
||||
|
||||
WeightedItemList list = OrbAcquirableItems.idList;
|
||||
int size = list.size(), damageRemoved = 0;
|
||||
|
||||
for(Iterator<WeightedItem> iter = list.iterator(); iter.hasNext();){
|
||||
Pair<Integer,Boolean> info = iter.next().runBlacklistPattern(pattern);
|
||||
|
||||
WeightedItemList list = OrbAcquirableItems.idList;
|
||||
int size = list.size(), damageRemoved = 0;
|
||||
|
||||
for(Iterator<WeightedItem> iter = list.iterator(); iter.hasNext();){
|
||||
Pair<Integer,Boolean> info = iter.next().runBlacklistPattern(pattern);
|
||||
|
||||
if (info.getRight())iter.remove();
|
||||
damageRemoved += info.getLeft();
|
||||
}
|
||||
|
||||
size = size-list.size();
|
||||
|
||||
if (size == 0 && damageRemoved == 0)MessageLogger.logWarn("Did not find any items to remove.");
|
||||
else if (size == 0)MessageLogger.logOk("Removed $0 damage value(s) from items.",damageRemoved);
|
||||
else MessageLogger.logOk("Removed $0 item(s) and $1 damage value(s) in total.",size,damageRemoved);
|
||||
|
||||
if (list.size() == 0)MessageLogger.logWarn("No items left in the list, falling back to generic chest loot.");
|
||||
if (info.getRight())iter.remove();
|
||||
damageRemoved += info.getLeft();
|
||||
}
|
||||
|
||||
size = size-list.size();
|
||||
|
||||
if (size == 0 && damageRemoved == 0)MessageLogger.logWarn("Did not find any items to remove.");
|
||||
else if (size == 0)MessageLogger.logOk("Removed $0 damage value(s) from items.",damageRemoved);
|
||||
else MessageLogger.logOk("Removed $0 item(s) and $1 damage value(s) in total.",size,damageRemoved);
|
||||
|
||||
if (list.size() == 0)MessageLogger.logWarn("No items left in the list, falling back to generic chest loot.");
|
||||
};
|
||||
|
||||
private static final MessageHandler mobAdd = new MessageHandler(){
|
||||
@Override
|
||||
public void call(MessageRunner runner){
|
||||
Class<?> cls = (Class<?>)EntityList.stringToClassMapping.get(runner.getString("id"));
|
||||
|
||||
if (IBossDisplayData.class.isAssignableFrom(cls))MessageLogger.logFail("Cannot add boss mobs to the list.");
|
||||
else if (OrbSpawnableMobs.classList.add(cls))MessageLogger.logOk("Added 1 mob to the list.");
|
||||
else MessageLogger.logFail("The mob was already in the list.");
|
||||
}
|
||||
private static final IMessageHandler mobAdd = runner -> {
|
||||
Class<?> cls = (Class<?>)EntityList.stringToClassMapping.get(runner.getString("id"));
|
||||
|
||||
if (IBossDisplayData.class.isAssignableFrom(cls))MessageLogger.logFail("Cannot add boss mobs to the list.");
|
||||
else if (OrbSpawnableMobs.classList.add(cls))MessageLogger.logOk("Added 1 mob to the list.");
|
||||
else MessageLogger.logFail("The mob was already in the list.");
|
||||
};
|
||||
|
||||
private static final MessageHandler mobRemove = new MessageHandler(){
|
||||
@Override
|
||||
public void call(MessageRunner runner){
|
||||
if (OrbSpawnableMobs.classList.remove(EntityList.stringToClassMapping.get(runner.getString("id"))))MessageLogger.logOk("Removed 1 mob from the list.");
|
||||
else MessageLogger.logFail("The mob was not present in the list.");
|
||||
}
|
||||
private static final IMessageHandler mobRemove = runner -> {
|
||||
if (OrbSpawnableMobs.classList.remove(EntityList.stringToClassMapping.get(runner.getString("id"))))MessageLogger.logOk("Removed 1 mob from the list.");
|
||||
else MessageLogger.logFail("The mob was not present in the list.");
|
||||
};
|
||||
|
||||
@Override
|
||||
|
@ -1,18 +1,14 @@
|
||||
package chylex.hee.api.message.handlers;
|
||||
import chylex.hee.api.message.MessageHandler;
|
||||
import chylex.hee.api.message.MessageRunner;
|
||||
import chylex.hee.api.message.IMessageHandler;
|
||||
import chylex.hee.api.message.element.StringValue;
|
||||
import chylex.hee.api.message.utils.MessageLogger;
|
||||
import chylex.hee.api.message.utils.RunEvent;
|
||||
import chylex.hee.game.integration.ModIntegrationManager;
|
||||
|
||||
public class ImcSystemHandlers extends ImcHandler{
|
||||
private static final MessageHandler disableIntegration = new MessageHandler(){
|
||||
@Override
|
||||
public void call(MessageRunner runner){
|
||||
if (ModIntegrationManager.blacklistedMods.add(runner.getString("modid")))MessageLogger.logOk("Added 1 mod ID to the list.");
|
||||
else MessageLogger.logFail("The mod ID was already in the list.");
|
||||
}
|
||||
private static final IMessageHandler disableIntegration = runner -> {
|
||||
if (ModIntegrationManager.blacklistedMods.add(runner.getString("modid")))MessageLogger.logOk("Added 1 mod ID to the list.");
|
||||
else MessageLogger.logFail("The mod ID was already in the list.");
|
||||
};
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,5 @@
|
||||
package chylex.hee.api.message.handlers;
|
||||
import chylex.hee.api.message.MessageHandler;
|
||||
import chylex.hee.api.message.MessageRunner;
|
||||
import chylex.hee.api.message.IMessageHandler;
|
||||
import chylex.hee.api.message.element.DecimalValue;
|
||||
import chylex.hee.api.message.element.IntValue;
|
||||
import chylex.hee.api.message.element.ItemDamagePairValue;
|
||||
@ -14,28 +13,19 @@ import chylex.hee.system.util.ItemPattern;
|
||||
import chylex.hee.tileentity.TileEntityExperienceTable;
|
||||
|
||||
public final class ImcTableHandlers extends ImcHandler{
|
||||
private static final MessageHandler decompositionBlacklist = new MessageHandler(){
|
||||
@Override
|
||||
public void call(MessageRunner runner){
|
||||
StardustDecomposition.addToBlacklist(runner.<ItemPattern>getValue("pattern"));
|
||||
MessageLogger.logOk("Added 1 pattern to the list.");
|
||||
}
|
||||
private static final IMessageHandler decompositionBlacklist = runner -> {
|
||||
StardustDecomposition.addToBlacklist(runner.<ItemPattern>getValue("pattern"));
|
||||
MessageLogger.logOk("Added 1 pattern to the list.");
|
||||
};
|
||||
|
||||
private static final MessageHandler energySet = new MessageHandler(){
|
||||
@Override
|
||||
public void call(MessageRunner runner){
|
||||
if (EnergyValues.setItemEnergy(runner.<ItemDamagePair>getValue("item"),(float)runner.getDouble("units")))MessageLogger.logOk("Added 1 item to the list.");
|
||||
else MessageLogger.logFail("The item was already in the list.");
|
||||
}
|
||||
private static final IMessageHandler energySet = runner -> {
|
||||
if (EnergyValues.setItemEnergy(runner.<ItemDamagePair>getValue("item"),(float)runner.getDouble("units")))MessageLogger.logOk("Added 1 item to the list.");
|
||||
else MessageLogger.logFail("The item was already in the list.");
|
||||
};
|
||||
|
||||
private static final MessageHandler expTableAdd = new MessageHandler(){
|
||||
@Override
|
||||
public void call(MessageRunner runner){
|
||||
if (TileEntityExperienceTable.addDirectConversion(runner.<ItemDamagePair>getValue("item"),(byte)runner.getInt("bottles")))MessageLogger.logOk("Added 1 item to the list.");
|
||||
else MessageLogger.logFail("The item was already in the list.");
|
||||
}
|
||||
private static final IMessageHandler expTableAdd = runner -> {
|
||||
if (TileEntityExperienceTable.addDirectConversion(runner.<ItemDamagePair>getValue("item"),(byte)runner.getInt("bottles")))MessageLogger.logOk("Added 1 item to the list.");
|
||||
else MessageLogger.logFail("The item was already in the list.");
|
||||
};
|
||||
|
||||
@Override
|
||||
|
@ -2,8 +2,7 @@ package chylex.hee.api.message.handlers;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import chylex.hee.api.message.MessageHandler;
|
||||
import chylex.hee.api.message.MessageRunner;
|
||||
import chylex.hee.api.message.IMessageHandler;
|
||||
import chylex.hee.api.message.element.IntValue;
|
||||
import chylex.hee.api.message.element.ItemPatternValue;
|
||||
import chylex.hee.api.message.element.SpawnEntryValue;
|
||||
@ -16,7 +15,6 @@ import chylex.hee.world.structure.island.biome.IslandBiomeEnchantedIsland;
|
||||
import chylex.hee.world.structure.island.biome.IslandBiomeInfestedForest;
|
||||
import chylex.hee.world.structure.island.biome.data.BiomeContentVariation;
|
||||
import chylex.hee.world.util.SpawnEntry;
|
||||
import com.google.common.base.Function;
|
||||
|
||||
public final class ImcWorldHandlers extends ImcHandler{
|
||||
// TODO private static final Map<String,WeightedLootList> lootNames = new HashMap<>();
|
||||
@ -45,74 +43,55 @@ public final class ImcWorldHandlers extends ImcHandler{
|
||||
biomeNames.put("EnchantedIsland.Laboratory",Pair.of(IslandBiomeBase.enchantedIsland,IslandBiomeEnchantedIsland.LABORATORY));
|
||||
}
|
||||
|
||||
private static final StringValue lootName = StringValue.function(new Function<String,Boolean>(){
|
||||
@Override
|
||||
public Boolean apply(String input){
|
||||
return Boolean.valueOf(false);// TODO lootNames.containsKey(input));
|
||||
}
|
||||
});
|
||||
private static final StringValue lootName = StringValue.function(input -> false); // TODO lootNames.containsKey(input));
|
||||
|
||||
private static final StringValue biomeName = StringValue.function(new Function<String,Boolean>(){
|
||||
@Override
|
||||
public Boolean apply(String input){
|
||||
return Boolean.valueOf(biomeNames.containsKey(input));
|
||||
}
|
||||
});
|
||||
private static final StringValue biomeName = StringValue.function(biomeNames::containsKey);
|
||||
|
||||
private static final MessageHandler lootAdd = new MessageHandler(){
|
||||
@Override
|
||||
public void call(MessageRunner runner){
|
||||
// TODO
|
||||
/*WeightedLootList list = lootNames.get(runner.getString("list"));
|
||||
LootItemStack toAdd = runner.<LootItemStack>getValue("item");
|
||||
|
||||
for(LootItemStack item:list){
|
||||
if (item.getItem() == toAdd.getItem()){
|
||||
MessageLogger.logFail("The item was already in the list.");
|
||||
return;
|
||||
}
|
||||
/*private static final IMessageHandler lootAdd = runner -> {
|
||||
// TODO
|
||||
/*WeightedLootList list = lootNames.get(runner.getString("list"));
|
||||
LootItemStack toAdd = runner.<LootItemStack>getValue("item");
|
||||
|
||||
for(LootItemStack item:list){
|
||||
if (item.getItem() == toAdd.getItem()){
|
||||
MessageLogger.logFail("The item was already in the list.");
|
||||
return;
|
||||
}
|
||||
|
||||
list.add(toAdd);
|
||||
MessageLogger.logOk("Added 1 item to the list.");*/
|
||||
}
|
||||
|
||||
list.add(toAdd);
|
||||
MessageLogger.logOk("Added 1 item to the list.");*/
|
||||
//};
|
||||
|
||||
private static final IMessageHandler lootRemove = runner -> {
|
||||
// TODO
|
||||
/*WeightedLootList list = lootNames.get(runner.getString("list"));
|
||||
int limit = runner.getInt("limit");
|
||||
|
||||
ItemPattern pattern = runner.<ItemPattern>getValue("search");
|
||||
pattern.setDamageValues(ArrayUtils.EMPTY_INT_ARRAY);
|
||||
pattern.setNBT(null);
|
||||
// reset search
|
||||
|
||||
int size = list.size();
|
||||
|
||||
for(Iterator<LootItemStack> iter = list.iterator(); iter.hasNext();){
|
||||
if (pattern.matches(new ItemStack(iter.next().getItem()))){
|
||||
iter.remove();
|
||||
if (limit > 0 && --limit == 0)break;
|
||||
}
|
||||
}
|
||||
|
||||
size = size-list.size();
|
||||
|
||||
if (size == 0)MessageLogger.logWarn("Did not find any items to remove.");
|
||||
else MessageLogger.logOk("Removed $0 item(s).",size);*/
|
||||
};
|
||||
|
||||
private static final MessageHandler lootRemove = new MessageHandler(){
|
||||
@Override
|
||||
public void call(MessageRunner runner){
|
||||
// TODO
|
||||
/*WeightedLootList list = lootNames.get(runner.getString("list"));
|
||||
int limit = runner.getInt("limit");
|
||||
|
||||
ItemPattern pattern = runner.<ItemPattern>getValue("search");
|
||||
pattern.setDamageValues(ArrayUtils.EMPTY_INT_ARRAY);
|
||||
pattern.setNBT(null);
|
||||
// reset search
|
||||
|
||||
int size = list.size();
|
||||
|
||||
for(Iterator<LootItemStack> iter = list.iterator(); iter.hasNext();){
|
||||
if (pattern.matches(new ItemStack(iter.next().getItem()))){
|
||||
iter.remove();
|
||||
if (limit > 0 && --limit == 0)break;
|
||||
}
|
||||
}
|
||||
|
||||
size = size-list.size();
|
||||
|
||||
if (size == 0)MessageLogger.logWarn("Did not find any items to remove.");
|
||||
else MessageLogger.logOk("Removed $0 item(s).",size);*/
|
||||
}
|
||||
};
|
||||
|
||||
private static final MessageHandler biomeMobAdd = new MessageHandler(){
|
||||
@Override
|
||||
public void call(MessageRunner runner){
|
||||
Pair<IslandBiomeBase,BiomeContentVariation> pair = biomeNames.get(runner.getString("biome"));
|
||||
pair.getLeft().getSpawnEntries(pair.getRight()).add(runner.<SpawnEntry>getValue("mob"));
|
||||
MessageLogger.logOk("Added 1 entry to the list.");
|
||||
}
|
||||
private static final IMessageHandler biomeMobAdd = runner -> {
|
||||
Pair<IslandBiomeBase,BiomeContentVariation> pair = biomeNames.get(runner.getString("biome"));
|
||||
pair.getLeft().getSpawnEntries(pair.getRight()).add(runner.<SpawnEntry>getValue("mob"));
|
||||
MessageLogger.logOk("Added 1 entry to the list.");
|
||||
};
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user