Skip to content
Permalink
Browse files

added enderman griefing config

  • Loading branch information...
dries007 committed Dec 20, 2014
1 parent 06819b3 commit a7b8aa87e189c1c4e614ab56fc77358b8a3f391f
@@ -28,7 +28,7 @@ apply plugin: "maven"
apply plugin: "idea-utils"

group = "net.doubledoordev.d3core"
version = "1.0.0"
version = "1.1.0"

targetCompatibility = 1.7
sourceCompatibility = 1.7
@@ -48,11 +48,13 @@
import net.doubledoordev.d3core.permissions.cmd.CommandGroup;
import net.doubledoordev.d3core.util.CoreHelper;
import net.doubledoordev.d3core.util.DevPerks;
import net.doubledoordev.d3core.util.EndermanGriefing;
import net.doubledoordev.d3core.util.ID3Mod;
import net.doubledoordev.d3core.util.libs.org.mcstats.Metrics;
import net.minecraft.util.IChatComponent;
import net.minecraftforge.common.config.ConfigElement;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.Logger;
import org.w3c.dom.Document;
@@ -92,6 +94,7 @@

private List<ModContainer> d3Mods = new ArrayList<>();
private List<CoreHelper.ModUpdateDate> updateDateList = new ArrayList<>();
private boolean pastPost;

@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
@@ -222,6 +225,9 @@ public void postInit(FMLPostInitializationEvent event)
logger.warn(String.format("Update available for %s (%s)! Current version: %s New version: %s. Please update ASAP!", updateDate.getName(), updateDate.getModId(), updateDate.getCurrentVersion(), updateDate.getLatestVersion()));
}

EndermanGriefing.init();
pastPost = true;

PermissionsDB.save();
}

@@ -266,6 +272,23 @@ public void syncConfig()
updateWarning = configuration.getBoolean("updateWarning", MODID, updateWarning, "Allow update warnings on login", "d3.core.config.updateWarning");
getDevPerks().update(sillyness);

final String catEnderGriefing = MODID + ".EndermanGriefing";
configuration.setCategoryLanguageKey(catEnderGriefing, "d3.core.config.EndermanGriefing");

EndermanGriefing.undo();

EndermanGriefing.disable = configuration.getBoolean("disable", catEnderGriefing, false, "Disable Enderman griefing completely.", "d3.core.config.EndermanGriefing.disable");

Property property = configuration.get(catEnderGriefing, "blacklist", new String[0], "List of blocks (minecraft:stone) that will never be allowed to be picked up.");
property.setLanguageKey("d3.core.config.EndermanGriefing.blacklist");
EndermanGriefing.blacklist = property.getStringList();

property = configuration.get(catEnderGriefing, "addlist", new String[0], "List of blocks (minecraft:stone) that will be added to the list of blocks Enderman pick up.");
property.setLanguageKey("d3.core.config.EndermanGriefing.addlist");
EndermanGriefing.addList = property.getStringList();

if (pastPost) EndermanGriefing.init();

if (configuration.hasChanged()) configuration.save();
}

@@ -0,0 +1,65 @@
package net.doubledoordev.d3core.util;

import cpw.mods.fml.common.registry.GameData;
import net.doubledoordev.d3core.D3Core;
import net.minecraft.block.Block;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.init.Blocks;

import java.util.HashMap;

/**
* @author Dries007
*/
public class EndermanGriefing
{
public static boolean disable;
public static String[] blacklist;
public static String[] addList;

private static HashMap<String, Boolean> reverseMap = new HashMap<>();

public static void init()
{
if (disable)
{
for (Object key : GameData.getBlockRegistry().getKeys())
{
Block block = (Block) GameData.getBlockRegistry().getObject(key);
reverseMap.put(GameData.getBlockRegistry().getNameForObject(block), EntityEnderman.getCarriable(block));
EntityEnderman.setCarriable(block, false);
}
}
else
{
for (String item : addList)
{
if (!GameData.getBlockRegistry().containsKey(item))
{
D3Core.getLogger().warn("Block %s does not exist...", item);
continue;
}
reverseMap.put(item, EntityEnderman.getCarriable(GameData.getBlockRegistry().getObject(item)));
EntityEnderman.setCarriable(GameData.getBlockRegistry().getObject(item), true);
}
for (String item : blacklist)
{
if (!GameData.getBlockRegistry().containsKey(item))
{
D3Core.getLogger().warn("Block %s does not exist...", item);
continue;
}
reverseMap.put(item, EntityEnderman.getCarriable(GameData.getBlockRegistry().getObject(item)));
EntityEnderman.setCarriable(GameData.getBlockRegistry().getObject(item), false);
}
}
}

public static void undo()
{
for (String entry : reverseMap.keySet())
{
EntityEnderman.setCarriable(GameData.getBlockRegistry().getObject(entry), reverseMap.get(entry));
}
}
}
@@ -12,6 +12,18 @@ d3.core.config.sillyness.tooltip=Please don't disable, unless you want to piss o
d3.core.config.updateWarning=Update warnings
d3.core.config.updateWarning.tooltip=Please don't disable, unless you are on a modpack.

d3.core.config.EndermanGriefing=Enderman Griefing
d3.core.config.EndermanGriefing.tooltip=Modify Enderman griefing

d3.core.config.EndermanGriefing.disable=Disable
d3.core.config.EndermanGriefing.disable.tooltip=Disable Enderman griefing completely.

d3.core.config.EndermanGriefing.blacklist=Blacklist
d3.core.config.EndermanGriefing.blacklist.tooltip=List of blocks (minecraft:stone) that will never be allowed to be picked up.

d3.core.config.EndermanGriefing.addlist=Addlist
d3.core.config.EndermanGriefing.addlist.tooltip=List of blocks (minecraft:stone) that will be added to the list of blocks Enderman pick up.

commands.d3group.usage='/d3group help' for help
commands.d3group.help.new=/d3group new <group> [parent group]
commands.d3group.help.remove=/d3group remove <group>

0 comments on commit a7b8aa8

Please sign in to comment.
You can’t perform that action at this time.