Added basic support for Mo' Creatures (and other entity mods) - specify

mob info in entities.yml
This commit is contained in:
GJ 2013-02-05 22:40:19 -05:00
parent 94a9230525
commit bb88812668
9 changed files with 286 additions and 1 deletions

View File

@ -26,6 +26,7 @@ Version 1.4.00-dev
+ Added particle effect for bleeding
+ Added methods to check if a player is in party or admin chat to the ChatAPI
+ Added /mcpurge functionality for Flatfile users
+ Added basic support for Mo' Creatures (and other entity mods) - specify mob info in entities.yml
= Fixed multiple commands not working properly on offline players
= Fixed /mmoedit not giving feedback when modifying another players stats
= Fixed the guide usage string showing up every time /skillname was called

View File

@ -78,6 +78,7 @@ public class Config extends ConfigLoader {
public boolean getToolModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
public boolean getArmorModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
public boolean getBlockModsEnabled() { return config.getBoolean("Mods.Block_Mods_Enabled", false); }
public boolean getEntityModsEnabled() { return config.getBoolean("Mods.Entity_Mods_Enabled", false); }
/* PARTY SETTINGS */
public int getAutoPartyKickInterval() { return config.getInt("Party.AutoKick_Interval", 12); }

View File

@ -43,6 +43,7 @@ import com.gmail.nossr50.listeners.PlayerListener;
import com.gmail.nossr50.listeners.WorldListener;
import com.gmail.nossr50.mods.config.CustomArmorConfig;
import com.gmail.nossr50.mods.config.CustomBlocksConfig;
import com.gmail.nossr50.mods.config.CustomEntityConfig;
import com.gmail.nossr50.mods.config.CustomToolsConfig;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.party.commands.PartyCommand;
@ -229,6 +230,10 @@ public class mcMMO extends JavaPlugin {
CustomBlocksConfig.getInstance();
}
if (configInstance.getEntityModsEnabled()) {
CustomEntityConfig.getInstance();
}
// Load repair configs, make manager, and register them at this time
RepairConfigManager rManager = new RepairConfigManager(this);
repairables.addAll(rManager.getLoadedRepairables());

View File

@ -1,14 +1,17 @@
package com.gmail.nossr50.mods;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.mods.config.CustomArmorConfig;
import com.gmail.nossr50.mods.config.CustomBlocksConfig;
import com.gmail.nossr50.mods.config.CustomEntityConfig;
import com.gmail.nossr50.mods.config.CustomToolsConfig;
import com.gmail.nossr50.mods.datatypes.CustomBlock;
import com.gmail.nossr50.mods.datatypes.CustomEntity;
import com.gmail.nossr50.mods.datatypes.CustomItem;
import com.gmail.nossr50.mods.datatypes.CustomTool;
@ -17,6 +20,7 @@ public final class ModChecks {
private static boolean customToolsEnabled = configInstance.getToolModsEnabled();
private static boolean customArmorEnabled = configInstance.getArmorModsEnabled();
private static boolean customBlocksEnabled = configInstance.getBlockModsEnabled();
private static boolean customEntitiesEnabled = configInstance.getEntityModsEnabled();
private ModChecks() {}
@ -62,6 +66,19 @@ public final class ModChecks {
return null;
}
public static CustomEntity getCustomEntity(Entity entity) {
if (!CustomEntityConfig.getInstance().customEntityIds.contains(entity.getEntityId()) && !CustomEntityConfig.getInstance().customEntityTypes.contains(entity.getType())) {
return null;
}
for (CustomEntity customEntity : CustomEntityConfig.getInstance().customEntities) {
if ((customEntity.getEntityID() == entity.getEntityId()) && (customEntity.getEntityType() == entity.getType())) {
return customEntity;
}
}
return null;
}
/**
* Check if a custom block is a custom block.
*
@ -169,4 +186,12 @@ public final class ModChecks {
return false;
}
public static boolean isCustomEntity(Entity entity) {
if (customEntitiesEnabled && CustomEntityConfig.getInstance().customEntityIds.contains(entity.getEntityId())) {
return true;
}
return false;
}
}

View File

@ -0,0 +1,82 @@
package com.gmail.nossr50.mods.config;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.mods.datatypes.CustomEntity;
public class CustomEntityConfig extends ConfigLoader {
private static CustomEntityConfig instance;
public List<Integer> customEntityIds = new ArrayList<Integer>();
public List<Integer> customHostileEntityIds = new ArrayList<Integer>();
public List<Integer> customNeutralEntityIds = new ArrayList<Integer>();
public List<Integer> customPassiveEntityIds = new ArrayList<Integer>();
public List<EntityType> customEntityTypes = new ArrayList<EntityType>();
public List<CustomEntity> customEntities = new ArrayList<CustomEntity>();
public CustomEntityConfig() {
super("ModConfigs", "entities.yml");
loadKeys();
}
public static CustomEntityConfig getInstance() {
if (instance == null) {
instance = new CustomEntityConfig();
}
return instance;
}
@Override
protected void loadKeys() {
loadMobs("Hostile", customHostileEntityIds);
loadMobs("Neutral", customNeutralEntityIds);
loadMobs("Passive", customPassiveEntityIds);
}
private void loadMobs(String entityType, List<Integer> entityIdList) {
ConfigurationSection entitySection = config.getConfigurationSection(entityType);
if (entitySection == null) {
return;
}
Set<String> entityConfigSet = entitySection.getKeys(false);
for (String entityName : entityConfigSet) {
int id = config.getInt(entityType + "." + entityName + ".ID", 0);
EntityType type = EntityType.fromId(id);
double xpMultiplier = config.getDouble(entityType + "." + entityName + ".XP_Multiplier", 1.0D);
boolean canBeTamed = config.getBoolean(entityType + "." + entityName + ".Tameable", false);
int tamingXp = config.getInt(entityType + "." + entityName + ".Tameable.Taming_XP", 0);
boolean canBeSummoned = config.getBoolean(entityType + "." + entityName + ".Tameable.CanBeSummoned", false);
int callOfTheWildId = config.getInt(entityType + "." + entityName + ".Tameable.COTW_Material_ID", 0);
int callOfTheWildData = config.getInt(entityType + "." + entityName + ".Tameable.COTW_Material_Data", 0);
int callOfTheWildAmount = config.getInt(entityType + "." + entityName + ".Tameable.COTW_Material_Amount", 0);
CustomEntity entity;
if (id == 0) {
plugin.getLogger().warning("Missing ID. This block will be skipped.");
continue;
}
if (canBeSummoned && (callOfTheWildId == 0 || callOfTheWildAmount == 0)) {
plugin.getLogger().warning("Incomplete Call of the Wild information. This enitity will not be able to be summoned by Call of the Wild.");
canBeSummoned = false;
}
entity = new CustomEntity(id, type, xpMultiplier, canBeTamed, tamingXp, canBeSummoned, new ItemStack(callOfTheWildId, callOfTheWildData), callOfTheWildAmount);
entityIdList.add(id);
customEntityTypes.add(type);
customEntities.add(entity);
}
}
}

View File

@ -0,0 +1,94 @@
package com.gmail.nossr50.mods.datatypes;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
public class CustomEntity {
private int entityID;
private EntityType entityType;
private double xpMultiplier;
private boolean canBeTamed;
private int tamingXP;
private boolean canBeSummoned;
private ItemStack callOfTheWildItem;
private int callOfTheWildAmount;
public CustomEntity(int entityID, EntityType entityType, double xpMultiplier, boolean canBeTamed, int tamingXP, boolean canBeSummoned, ItemStack callOfTheWildItem, int callOfTheWildAmount) {
this.entityID = entityID;
this.entityType = entityType;
this.xpMultiplier = xpMultiplier;
this.canBeTamed = canBeTamed;
this.tamingXP = tamingXP;
this.canBeSummoned = canBeSummoned;
this.callOfTheWildItem = callOfTheWildItem;
this.callOfTheWildAmount = callOfTheWildAmount;
}
public int getEntityID() {
return entityID;
}
public void setEntityID(int entityID) {
this.entityID = entityID;
}
public EntityType getEntityType() {
return entityType;
}
public void setEntityType(EntityType entityType) {
this.entityType = entityType;
}
public double getXpMultiplier() {
return xpMultiplier;
}
public void setXpMultiplier(double xpMultiplier) {
this.xpMultiplier = xpMultiplier;
}
public boolean isCanBeTamed() {
return canBeTamed;
}
public void setCanBeTamed(boolean canBeTamed) {
this.canBeTamed = canBeTamed;
}
public int getTamingXP() {
return tamingXP;
}
public void setTamingXP(int tamingXP) {
this.tamingXP = tamingXP;
}
public boolean isCanBeSummoned() {
return canBeSummoned;
}
public void setCanBeSummoned(boolean canBeSummoned) {
this.canBeSummoned = canBeSummoned;
}
public ItemStack getCallOfTheWildItem() {
return callOfTheWildItem;
}
public void setCallOfTheWildItem(ItemStack callOfTheWildItem) {
this.callOfTheWildItem = callOfTheWildItem;
}
public int getCallOfTheWildAmount() {
return callOfTheWildAmount;
}
public void setCallOfTheWildAmount(int callOfTheWildAmount) {
this.callOfTheWildAmount = callOfTheWildAmount;
}
}

View File

@ -26,6 +26,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mods.ModChecks;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.skills.acrobatics.Acrobatics;
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
@ -459,8 +460,13 @@ public final class CombatTools {
}
else if (!mcMMO.placeStore.isSpawnedMob(target)) {
if (target instanceof Animals && !mcMMO.placeStore.isSpawnedPet(target)) {
if (ModChecks.isCustomEntity(target)) {
baseXP = ModChecks.getCustomEntity(target).getXpMultiplier();
}
else {
baseXP = configInstance.getAnimalsXP();
}
}
else {
EntityType type = target.getType();
@ -546,6 +552,10 @@ public final class CombatTools {
break;
default:
if (ModChecks.isCustomEntity(target)) {
baseXP = ModChecks.getCustomEntity(target).getXpMultiplier();
}
break;
}
}

View File

@ -55,6 +55,7 @@ Mods:
Tool_Mods_Enabled: false
Armor_Mods_Enabled: false
Block_Mods_Enabled: false
Entity_Mods_Enabled: false
#
# Settings for Parties

View File

@ -0,0 +1,66 @@
#
# Settings for Hostile Mobs
###
Hostile:
Mob_1:
ID: 9999
XP_Multiplier: 1.0
Tameable: false
Taming_XP: 250
CanBeSummoned: false
COTW_Material_ID: 999
COTW_Material_Data: 9
COTW_Material_Amount: 99
Mob_2:
ID: 9999
XP_Multiplier: 1.0
Tameable: false
Taming_XP: 250
CanBeSummoned: false
COTW_Material_ID: 999
COTW_Material_Data: 9
COTW_Material_Amount: 99
#
# Settings for Neutral Mobs
###
Neutral:
Mob_1:
ID: 9999
XP_Multiplier: 1.0
Tameable: false
Taming_XP: 250
CanBeSummoned: false
COTW_Material_ID: 999
COTW_Material_Data: 9
COTW_Material_Amount: 99
Mob_2:
ID: 9999
XP_Multiplier: 1.0
Tameable: false
Taming_XP: 250
CanBeSummoned: false
COTW_Material_ID: 999
COTW_Material_Data: 9
COTW_Material_Amount: 99
#
# Settings for Passive Mobs
###
Passive:
Mob_1:
ID: 9999
XP_Multiplier: 1.0
Tameable: false
Taming_XP: 250
CanBeSummoned: false
COTW_Material_ID: 999
COTW_Material_Data: 9
COTW_Material_Amount: 99
Mob_2:
ID: 9999
XP_Multiplier: 1.0
Tameable: false
Taming_XP: 250
CanBeSummoned: false
COTW_Material_ID: 999
COTW_Material_Data: 9
COTW_Material_Amount: 99