2013-01-16 11:33:14 +00:00
|
|
|
package de.jaschastarke.minecraft.limitedcreative;
|
|
|
|
|
2013-07-02 09:43:13 +00:00
|
|
|
import java.util.WeakHashMap;
|
|
|
|
|
|
|
|
import org.bukkit.entity.Entity;
|
|
|
|
|
2013-01-16 11:33:14 +00:00
|
|
|
import de.jaschastarke.bukkit.lib.CoreModule;
|
2013-09-21 20:12:40 +00:00
|
|
|
import de.jaschastarke.bukkit.lib.modules.AttachedBlocksDestroy;
|
2013-02-05 20:04:05 +00:00
|
|
|
import de.jaschastarke.minecraft.limitedcreative.limits.BlockListener;
|
|
|
|
import de.jaschastarke.minecraft.limitedcreative.limits.EntityListener;
|
2013-02-01 21:25:43 +00:00
|
|
|
import de.jaschastarke.minecraft.limitedcreative.limits.LimitConfig;
|
2013-02-05 20:04:05 +00:00
|
|
|
import de.jaschastarke.minecraft.limitedcreative.limits.PlayerListener;
|
2013-01-16 11:33:14 +00:00
|
|
|
import de.jaschastarke.modularize.IModule;
|
|
|
|
import de.jaschastarke.modularize.ModuleEntry;
|
2013-02-05 20:04:05 +00:00
|
|
|
import de.jaschastarke.modularize.ModuleEntry.ModuleState;
|
2013-01-16 11:33:14 +00:00
|
|
|
|
2013-01-18 21:51:08 +00:00
|
|
|
public class ModCreativeLimits extends CoreModule<LimitedCreative> {
|
2013-02-01 21:25:43 +00:00
|
|
|
protected LimitConfig config;
|
2013-07-02 09:43:13 +00:00
|
|
|
private WeakHashMap<Entity, Void> no_xp_mobs = new WeakHashMap<Entity, Void>();
|
2013-02-01 21:25:43 +00:00
|
|
|
|
2013-01-18 21:51:08 +00:00
|
|
|
public ModCreativeLimits(LimitedCreative plugin) {
|
2013-01-16 11:33:14 +00:00
|
|
|
super(plugin);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected FeatureBlockItemSpawn blockDrops = null;
|
2013-02-05 20:04:05 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getName() {
|
|
|
|
return "Limits";
|
|
|
|
}
|
2013-01-16 11:33:14 +00:00
|
|
|
|
|
|
|
@Override
|
2013-02-01 21:25:43 +00:00
|
|
|
public void initialize(ModuleEntry<IModule> entry) {
|
|
|
|
super.initialize(entry);
|
2013-02-05 20:04:05 +00:00
|
|
|
listeners.addListener(new PlayerListener(this));
|
|
|
|
listeners.addListener(new EntityListener(this));
|
|
|
|
listeners.addListener(new BlockListener(this));
|
|
|
|
config = plugin.getPluginConfig().registerSection(new LimitConfig(this, entry));
|
|
|
|
|
2013-09-21 20:12:40 +00:00
|
|
|
blockDrops = plugin.getModule(FeatureBlockItemSpawn.class);
|
2013-01-16 11:33:14 +00:00
|
|
|
if (blockDrops == null)
|
|
|
|
blockDrops = plugin.addModule(new FeatureBlockItemSpawn(plugin)).getModule();
|
2013-09-21 20:12:40 +00:00
|
|
|
|
|
|
|
if (plugin.getModule(AttachedBlocksDestroy.class) == null) {
|
|
|
|
plugin.addModule(new AttachedBlocksDestroy(plugin));
|
|
|
|
}
|
|
|
|
|
2013-02-05 20:04:05 +00:00
|
|
|
if (!config.getEnabled()) {
|
|
|
|
entry.initialState = ModuleState.DISABLED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-21 20:12:40 +00:00
|
|
|
public FeatureBlockItemSpawn getBlockSpawn() {
|
|
|
|
return blockDrops;
|
|
|
|
}
|
|
|
|
|
2013-02-05 20:04:05 +00:00
|
|
|
@Override
|
|
|
|
public void onEnable() {
|
|
|
|
super.onEnable();
|
|
|
|
getLog().info(plugin.getLocale().trans("basic.loaded.module"));
|
|
|
|
}
|
|
|
|
|
|
|
|
public LimitConfig getConfig() {
|
|
|
|
return config;
|
2013-01-16 11:33:14 +00:00
|
|
|
}
|
2013-07-02 09:43:13 +00:00
|
|
|
|
|
|
|
public WeakHashMap<Entity, Void> getNoXPMobs() {
|
|
|
|
return no_xp_mobs;
|
|
|
|
}
|
2013-01-16 11:33:14 +00:00
|
|
|
|
|
|
|
}
|