Worlds config beta

This commit is contained in:
T00thpick1 2013-05-15 18:57:41 -04:00
parent 2ee919b51f
commit fc935ce9dd
11 changed files with 406 additions and 124 deletions

View File

@ -0,0 +1,49 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.util.StringUtils;
public class WorldConfig extends ConfigLoader {
private static WorldConfig instance;
public WorldConfig() {
super("worlds.yml");
}
@Override
protected void loadKeys() { }
public static WorldConfig getInstance() {
if (instance == null) {
instance = new WorldConfig();
}
return instance;
}
// World settings
public boolean isSkillEnabled(SkillType skillType, String world) {
String skill = StringUtils.getCapitalized(skillType.toString());
return config.getBoolean("Worlds." + StringUtils.getCapitalized(world) + ".Skills." + skill + ".Enabled", isSkillEnabled(skill));
}
public boolean isAbilityEnabled(SkillType skillType, String world) {
String skill = StringUtils.getCapitalized(skillType.toString());
return config.getBoolean("Worlds." + StringUtils.getCapitalized(world) + ".Skills." + skill + ".AbilityEnabled", isAbilityEnabled(skill));
}
public boolean isBlockStoreEnabled(String world) { return config.getBoolean("Worlds." + StringUtils.getCapitalized(world) + ".BlockStore", isBlockStoreEnabled()); }
public boolean isMobHealthEnabled(String world) { return config.getBoolean("Worlds." + StringUtils.getCapitalized(world) + ".MobHealthBar", isMobHealthEnabled()); }
// Default settings
private boolean isSkillEnabled(String skill) { return config.getBoolean("Worlds.default.Skills." + skill + ".Enabled", true); }
private boolean isAbilityEnabled(String skill) { return config.getBoolean("Worlds.default.Skills." + skill + ".AbilityEnabled", true); }
private boolean isBlockStoreEnabled() { return config.getBoolean("Worlds.default.BlockStore", true); }
private boolean isMobHealthEnabled() { return config.getBoolean("Worlds.default.MobHealthBar", true); }
}

View File

@ -22,6 +22,7 @@ import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.config.WorldConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
@ -58,6 +59,10 @@ public class BlockListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
if (!WorldConfig.getInstance().isBlockStoreEnabled(event.getBlock().getWorld().getName()) || !HiddenConfig.getInstance().getChunkletsEnabled()) {
return;
}
List<Block> blocks = event.getBlocks();
BlockFace direction = event.getDirection();
Block futureEmptyBlock = event.getBlock().getRelative(direction); // Block that would be air after piston is finished
@ -88,6 +93,10 @@ public class BlockListener implements Listener {
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
if (event.isSticky()) {
// Needed only because under some circumstances Minecraft doesn't move the block
if (!WorldConfig.getInstance().isBlockStoreEnabled(event.getBlock().getWorld().getName()) || !HiddenConfig.getInstance().getChunkletsEnabled()) {
return;
}
new StickyPistonTrackerTask(event.getDirection(), event.getBlock()).runTaskLater(plugin, 2);
}
}
@ -146,47 +155,61 @@ public class BlockListener implements Listener {
/* HERBALISM */
if (BlockUtils.affectedByGreenTerra(blockState)) {
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
if (WorldConfig.getInstance().isSkillEnabled(SkillType.HERBALISM, blockState.getWorld().getName())) {
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
/* Green Terra */
if (herbalismManager.canActivateAbility()) {
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.HERBALISM);
}
/* Green Terra */
if (herbalismManager.canActivateAbility()) {
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.HERBALISM);
}
/*
* We don't check the block store here because herbalism has too many unusual edge cases.
* Instead, we check it inside the drops handler.
*/
if (Permissions.skillEnabled(player, SkillType.HERBALISM)) {
herbalismManager.herbalismBlockCheck(blockState);
/*
* We don't check the block store here because Herbalism has too many unusual edge cases.
* Instead, we check it inside the drops handler.
*/
if (Permissions.skillEnabled(player, SkillType.HERBALISM)) {
herbalismManager.herbalismBlockCheck(blockState);
}
}
}
/* MINING */
else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && Permissions.skillEnabled(player, SkillType.MINING) && !mcMMO.getPlaceStore().isTrue(blockState)) {
MiningManager miningManager = mcMMOPlayer.getMiningManager();
miningManager.miningBlockCheck(blockState);
else if (BlockUtils.affectedBySuperBreaker(blockState)) {
if (WorldConfig.getInstance().isSkillEnabled(SkillType.MINING, blockState.getWorld().getName())) {
if (ItemUtils.isPickaxe(heldItem) && Permissions.skillEnabled(player, SkillType.MINING) && !mcMMO.getPlaceStore().isTrue(blockState)) {
MiningManager miningManager = mcMMOPlayer.getMiningManager();
miningManager.miningBlockCheck(blockState);
}
}
}
/* WOOD CUTTING */
else if (BlockUtils.isLog(blockState) && Permissions.skillEnabled(player, SkillType.WOODCUTTING) && !mcMMO.getPlaceStore().isTrue(blockState)) {
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
else if (BlockUtils.isLog(blockState)) {
if (WorldConfig.getInstance().isSkillEnabled(SkillType.WOODCUTTING, blockState.getWorld().getName())) {
if (Permissions.skillEnabled(player, SkillType.WOODCUTTING) && !mcMMO.getPlaceStore().isTrue(blockState)) {
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
if (woodcuttingManager.canUseTreeFeller(heldItem)) {
woodcuttingManager.processTreeFeller(blockState);
}
else {
woodcuttingManager.woodcuttingBlockCheck(blockState);
if (woodcuttingManager.canUseTreeFeller(heldItem)) {
woodcuttingManager.processTreeFeller(blockState);
}
else {
woodcuttingManager.woodcuttingBlockCheck(blockState);
}
}
}
}
/* EXCAVATION */
else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && Permissions.skillEnabled(player, SkillType.EXCAVATION) && !mcMMO.getPlaceStore().isTrue(blockState)) {
ExcavationManager excavationManager = mcMMOPlayer.getExcavationManager();
excavationManager.excavationBlockCheck(blockState);
else if (BlockUtils.affectedByGigaDrillBreaker(blockState)) {
if (WorldConfig.getInstance().isSkillEnabled(SkillType.EXCAVATION, blockState.getWorld().getName())) {
if (ItemUtils.isShovel(heldItem) && Permissions.skillEnabled(player, SkillType.EXCAVATION) && !mcMMO.getPlaceStore().isTrue(blockState)) {
ExcavationManager excavationManager = mcMMOPlayer.getExcavationManager();
excavationManager.excavationBlockCheck(blockState);
if (mcMMOPlayer.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) {
excavationManager.gigaDrillBreaker(blockState);
if (mcMMOPlayer.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) {
excavationManager.gigaDrillBreaker(blockState);
}
}
}
}
@ -215,6 +238,10 @@ public class BlockListener implements Listener {
ItemStack heldItem = player.getItemInHand();
if (ItemUtils.isSword(heldItem)) {
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.HERBALISM, blockState.getWorld().getName())) {
return;
}
HerbalismManager herbalismManager = UserManager.getPlayer(player).getHerbalismManager();
if (herbalismManager.canUseHylianLuck()) {
@ -225,6 +252,10 @@ public class BlockListener implements Listener {
}
}
else if (ItemUtils.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH)) {
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.MINING, blockState.getWorld().getName())) {
return;
}
SmeltingManager smeltingManager = UserManager.getPlayer(player).getSmeltingManager();
if (smeltingManager.canUseFluxMining(blockState)) {

View File

@ -33,7 +33,9 @@ import org.bukkit.metadata.FixedMetadataValue;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.WorldConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
import com.gmail.nossr50.party.PartyManager;
@ -59,6 +61,9 @@ public class EntityListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityShootBow(EntityShootBowEvent event) {
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.ARCHERY, event.getEntity().getWorld().getName())) {
return;
}
ItemStack bow = event.getBow();
if (bow != null) {
@ -194,6 +199,10 @@ public class EntityListener implements Listener {
switch (cause) {
case FALL:
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.ACROBATICS, player.getWorld().getName())) {
break;
}
AcrobaticsManager acrobaticsManager = mcMMOPlayer.getAcrobaticsManager();
if (acrobaticsManager.canRoll()) {
@ -207,6 +216,10 @@ public class EntityListener implements Listener {
break;
case BLOCK_EXPLOSION:
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.MINING, player.getWorld().getName())) {
break;
}
MiningManager miningManager = mcMMOPlayer.getMiningManager();
if (miningManager.canUseDemolitionsExpertise()) {
@ -231,6 +244,10 @@ public class EntityListener implements Listener {
Tameable pet = (Tameable) livingEntity;
AnimalTamer owner = pet.getOwner();
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.TAMING, livingEntity.getWorld().getName())) {
return;
}
if (Taming.canPreventDamage(pet, owner)) {
Player player = (Player) owner;
Wolf wolf = (Wolf) pet;
@ -356,6 +373,10 @@ public class EntityListener implements Listener {
return;
}
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.MINING, entity.getWorld().getName())) {
return;
}
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
if (miningManager.canUseBiggerBombs()) {
@ -370,7 +391,7 @@ public class EntityListener implements Listener {
* @param event The event to modify
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEnitityExplode(EntityExplodeEvent event) {
public void onEntityExplode(EntityExplodeEvent event) {
Entity entity = event.getEntity();
if (entity instanceof TNTPrimed && entity.hasMetadata(mcMMO.tntMetadataKey)) {
@ -381,6 +402,10 @@ public class EntityListener implements Listener {
return;
}
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.MINING, entity.getWorld().getName())) {
return;
}
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
if (miningManager.canUseBlastMining()) {
@ -427,6 +452,10 @@ public class EntityListener implements Listener {
case GOLDEN_CARROT: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
case MUSHROOM_SOUP: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
case PUMPKIN_PIE: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.HERBALISM, player.getWorld().getName())) {
return;
}
if (Permissions.farmersDiet(player)) {
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel1, newFoodLevel));
}
@ -436,18 +465,30 @@ public class EntityListener implements Listener {
case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.HERBALISM, player.getWorld().getName())) {
return;
}
if (Permissions.farmersDiet(player)) {
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel2, newFoodLevel));
}
return;
case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.FISHING, player.getWorld().getName())) {
return;
}
if (Permissions.fishermansDiet(player)) {
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel));
}
return;
case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.FISHING, player.getWorld().getName())) {
return;
}
if (Permissions.fishermansDiet(player)) {
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel2, newFoodLevel));
}
@ -469,6 +510,10 @@ public class EntityListener implements Listener {
Player player = (Player) event.getOwner();
LivingEntity entity = event.getEntity();
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.TAMING, player.getWorld().getName())) {
return;
}
if (Misc.isNPCEntity(player) || Misc.isNPCEntity(entity) || entity.hasMetadata(mcMMO.entityMetadataKey)) {
return;
}
@ -490,6 +535,10 @@ public class EntityListener implements Listener {
Player player = (Player) target;
Tameable tameable = (Tameable) entity;
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.TAMING, player.getWorld().getName())) {
return;
}
if (!CombatUtils.isFriendlyPet(player, tameable)) {
return;
}

View File

@ -26,6 +26,7 @@ import org.bukkit.metadata.MetadataValue;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.WorldConfig;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.skills.smelting.SmeltingManager;
import com.gmail.nossr50.util.ItemUtils;
@ -45,6 +46,10 @@ public class InventoryListener implements Listener {
public void onInventoryOpen(InventoryOpenEvent event) {
HumanEntity player = event.getPlayer();
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.SMELTING, player.getWorld().getName())) {
return;
}
if (Misc.isNPCEntity(player)) {
return;
}
@ -75,6 +80,10 @@ public class InventoryListener implements Listener {
return;
}
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.SMELTING, player.getWorld().getName())) {
return;
}
Inventory inventory = event.getInventory();
if (inventory instanceof FurnaceInventory) {
@ -99,6 +108,10 @@ public class InventoryListener implements Listener {
Block furnaceBlock = event.getBlock();
BlockState furnaceState = furnaceBlock.getState();
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.SMELTING, furnaceState.getWorld().getName())) {
return;
}
if (furnaceState instanceof Furnace) {
ItemStack smelting = ((Furnace) furnaceState).getInventory().getSmelting();
List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey);
@ -121,6 +134,10 @@ public class InventoryListener implements Listener {
Block furnaceBlock = event.getBlock();
BlockState furnaceState = furnaceBlock.getState();
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.SMELTING, furnaceState.getWorld().getName())) {
return;
}
if (furnaceState instanceof Furnace) {
ItemStack smelting = ((Furnace) furnaceState).getInventory().getSmelting();
List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey);
@ -151,6 +168,10 @@ public class InventoryListener implements Listener {
Block furnaceBlock = event.getBlock();
BlockState furnaceState = furnaceBlock.getState();
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.SMELTING, furnaceState.getWorld().getName())) {
return;
}
if (furnaceState instanceof Furnace) {
ItemStack result = ((Furnace) furnaceState).getInventory().getResult();
List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey);

View File

@ -31,12 +31,14 @@ import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.chat.ChatManager;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.WorldConfig;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.ShareHandler;
import com.gmail.nossr50.runnables.skills.AbilityDisableTask;
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
import com.gmail.nossr50.skills.fishing.FishingManager;
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
@ -125,6 +127,16 @@ public class PlayerListener implements Listener {
mcMMOPlayer.removeParty();
player.sendMessage(LocaleLoader.getString("Party.Forbidden"));
}
for (AbilityType abilityType : AbilityType.values()) {
if (mcMMOPlayer.getAbilityMode(abilityType)) {
if (!WorldConfig.getInstance().isAbilityEnabled(SkillType.byAbility(abilityType), player.getWorld().getName())) {
// Make sure to handle any important deactivation processes
new AbilityDisableTask(mcMMOPlayer, abilityType).run();
}
}
}
}
/**
@ -170,6 +182,10 @@ public class PlayerListener implements Listener {
public void onPlayerFish(PlayerFishEvent event) {
Player player = event.getPlayer();
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.FISHING, player.getWorld().getName())) {
return;
}
if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.FISHING)) {
return;
}
@ -345,6 +361,10 @@ public class PlayerListener implements Listener {
/* REPAIR CHECKS */
if (blockID == Repair.repairAnvilId && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.REPAIR, player.getWorld().getName())) {
break;
}
RepairManager repairManager = mcMMOPlayer.getRepairManager();
event.setCancelled(true);
@ -356,6 +376,10 @@ public class PlayerListener implements Listener {
}
/* SALVAGE CHECKS */
else if (blockID == Repair.salvageAnvilId && Permissions.salvage(player) && Repair.isSalvageable(heldItem) && !ItemUtils.isChainmailArmor(heldItem)) {
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.REPAIR, player.getWorld().getName())) {
break;
}
RepairManager repairManager = mcMMOPlayer.getRepairManager();
event.setCancelled(true);
@ -367,6 +391,10 @@ public class PlayerListener implements Listener {
}
/* BLAST MINING CHECK */
else if (miningManager.canDetonate()) {
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.MINING, player.getWorld().getName())) {
break;
}
if (blockID == Material.TNT.getId()) {
event.setCancelled(true); // Don't detonate the TNT if they're too close
}
@ -380,6 +408,10 @@ public class PlayerListener implements Listener {
case LEFT_CLICK_BLOCK:
blockID = block.getTypeId();
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.REPAIR, player.getWorld().getName())) {
break;
}
/* REPAIR CHECKS */
if (blockID == Repair.repairAnvilId && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
RepairManager repairManager = mcMMOPlayer.getRepairManager();
@ -404,6 +436,10 @@ public class PlayerListener implements Listener {
break;
case RIGHT_CLICK_AIR:
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.MINING, player.getWorld().getName())) {
break;
}
/* BLAST MINING CHECK */
if (miningManager.canDetonate()) {
miningManager.remoteDetonation();
@ -460,6 +496,10 @@ public class PlayerListener implements Listener {
ChimaeraWing.activationCheck(player);
}
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.HERBALISM, player.getWorld().getName())) {
break;
}
/* GREEN THUMB CHECK */
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
@ -500,6 +540,10 @@ public class PlayerListener implements Listener {
case LEFT_CLICK_AIR:
case LEFT_CLICK_BLOCK:
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.TAMING, player.getWorld().getName())) {
break;
}
/* CALL OF THE WILD CHECKS */
if (player.isSneaking() && Permissions.callOfTheWild(player)) {
Material type = heldItem.getType();

View File

@ -16,6 +16,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.config.WorldConfig;
import com.gmail.nossr50.config.mods.CustomArmorConfig;
import com.gmail.nossr50.config.mods.CustomBlockConfig;
import com.gmail.nossr50.config.mods.CustomEntityConfig;
@ -276,6 +277,7 @@ public class mcMMO extends JavaPlugin {
TreasureConfig.getInstance();
HiddenConfig.getInstance();
AdvancedConfig.getInstance();
WorldConfig.getInstance();
new ChildConfig();
List<Repairable> repairables = new ArrayList<Repairable>();

View File

@ -10,6 +10,7 @@ import org.bukkit.metadata.FixedMetadataValue;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.WorldConfig;
import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.runnables.MobHealthDisplayUpdaterTask;
@ -44,6 +45,10 @@ public final class MobHealthbarUtils {
return;
}
if (!WorldConfig.getInstance().isMobHealthEnabled(player.getWorld().getName())) {
return;
}
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
if (profile.getMobHealthbarType() == null) {

View File

@ -17,6 +17,7 @@ import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.WorldConfig;
import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionZDirectory;
public class HashChunkManager implements ChunkManager {
@ -303,6 +304,10 @@ public class HashChunkManager implements ChunkManager {
return false;
}
if (!WorldConfig.getInstance().isBlockStoreEnabled(world.getName())) {
return false;
}
int cx = x / 16;
int cz = z / 16;
String key = world.getName() + "," + cx + "," + cz;
@ -346,6 +351,10 @@ public class HashChunkManager implements ChunkManager {
return;
}
if (!WorldConfig.getInstance().isBlockStoreEnabled(world.getName())) {
return;
}
int cx = x / 16;
int cz = z / 16;
@ -392,6 +401,10 @@ public class HashChunkManager implements ChunkManager {
return;
}
if (!WorldConfig.getInstance().isBlockStoreEnabled(world.getName())) {
return;
}
int cx = x / 16;
int cz = z / 16;

View File

@ -20,6 +20,7 @@ import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.WorldConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
@ -65,103 +66,111 @@ public final class CombatUtils {
ItemStack heldItem = player.getItemInHand();
if (target instanceof Tameable) {
if (heldItem.getType() == Material.BONE) {
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
if (WorldConfig.getInstance().isSkillEnabled(SkillType.TAMING, player.getWorld().getName())) {
if (heldItem.getType() == Material.BONE) {
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
if (tamingManager.canUseBeastLore()) {
tamingManager.beastLore(target);
event.setCancelled(true);
if (tamingManager.canUseBeastLore()) {
tamingManager.beastLore(target);
event.setCancelled(true);
return;
}
}
if (isFriendlyPet(player, (Tameable) target)) {
return;
}
}
if (isFriendlyPet(player, (Tameable) target)) {
return;
}
}
if (ItemUtils.isSword(heldItem)) {
if (!shouldProcessSkill(target, SkillType.SWORDS)) {
return;
}
if (Permissions.skillEnabled(player, SkillType.SWORDS)) {
SwordsManager swordsManager = mcMMOPlayer.getSwordsManager();
if (swordsManager.canActivateAbility()) {
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.SWORDS);
if (WorldConfig.getInstance().isSkillEnabled(SkillType.SWORDS, player.getWorld().getName())) {
if (!shouldProcessSkill(target, SkillType.SWORDS)) {
return;
}
if (swordsManager.canUseBleed()) {
swordsManager.bleedCheck(target);
}
if (Permissions.skillEnabled(player, SkillType.SWORDS)) {
SwordsManager swordsManager = mcMMOPlayer.getSwordsManager();
if (swordsManager.canUseSerratedStrike()) {
swordsManager.serratedStrikes(target, event.getDamage());
}
if (swordsManager.canActivateAbility()) {
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.SWORDS);
}
startGainXp(mcMMOPlayer, target, SkillType.SWORDS);
if (swordsManager.canUseBleed()) {
swordsManager.bleedCheck(target);
}
if (swordsManager.canUseSerratedStrike()) {
swordsManager.serratedStrikes(target, event.getDamage());
}
startGainXp(mcMMOPlayer, target, SkillType.SWORDS);
}
}
}
else if (ItemUtils.isAxe(heldItem)) {
if (!shouldProcessSkill(target, SkillType.AXES)) {
return;
}
if (Permissions.skillEnabled(player, SkillType.AXES)) {
AxesManager axesManager = mcMMOPlayer.getAxesManager();
if (axesManager.canActivateAbility()) {
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.AXES);
if (WorldConfig.getInstance().isSkillEnabled(SkillType.AXES, player.getWorld().getName())) {
if (!shouldProcessSkill(target, SkillType.AXES)) {
return;
}
if (axesManager.canUseAxeMastery()) {
event.setDamage(axesManager.axeMasteryCheck(event.getDamage()));
}
if (Permissions.skillEnabled(player, SkillType.AXES)) {
AxesManager axesManager = mcMMOPlayer.getAxesManager();
if (axesManager.canCriticalHit(target)) {
event.setDamage(axesManager.criticalHitCheck(target, event.getDamage()));
}
if (axesManager.canActivateAbility()) {
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.AXES);
}
if (axesManager.canImpact(target)) {
axesManager.impactCheck(target);
}
else if (axesManager.canGreaterImpact(target)) {
event.setDamage(axesManager.greaterImpactCheck(target, event.getDamage()));
}
if (axesManager.canUseAxeMastery()) {
event.setDamage(axesManager.axeMasteryCheck(event.getDamage()));
}
if (axesManager.canUseSkullSplitter(target)) {
axesManager.skullSplitterCheck(target, event.getDamage());
}
if (axesManager.canCriticalHit(target)) {
event.setDamage(axesManager.criticalHitCheck(target, event.getDamage()));
}
startGainXp(mcMMOPlayer, target, SkillType.AXES);
if (axesManager.canImpact(target)) {
axesManager.impactCheck(target);
}
else if (axesManager.canGreaterImpact(target)) {
event.setDamage(axesManager.greaterImpactCheck(target, event.getDamage()));
}
if (axesManager.canUseSkullSplitter(target)) {
axesManager.skullSplitterCheck(target, event.getDamage());
}
startGainXp(mcMMOPlayer, target, SkillType.AXES);
}
}
}
else if (heldItem.getType() == Material.AIR) {
if (!shouldProcessSkill(target, SkillType.UNARMED)) {
return;
}
if (Permissions.skillEnabled(player, SkillType.UNARMED)) {
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
if (unarmedManager.canActivateAbility()) {
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.UNARMED);
if (WorldConfig.getInstance().isSkillEnabled(SkillType.UNARMED, player.getWorld().getName())) {
if (!shouldProcessSkill(target, SkillType.UNARMED)) {
return;
}
if (unarmedManager.canUseIronArm()) {
event.setDamage(unarmedManager.ironArmCheck(event.getDamage()));
}
if (Permissions.skillEnabled(player, SkillType.UNARMED)) {
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
if (unarmedManager.canUseBerserk()) {
event.setDamage(unarmedManager.berserkDamage(event.getDamage()));
}
if (unarmedManager.canActivateAbility()) {
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.UNARMED);
}
if (unarmedManager.canDisarm(target)) {
unarmedManager.disarmCheck((Player) target);
}
if (unarmedManager.canUseIronArm()) {
event.setDamage(unarmedManager.ironArmCheck(event.getDamage()));
}
startGainXp(mcMMOPlayer, target, SkillType.UNARMED);
if (unarmedManager.canUseBerserk()) {
event.setDamage(unarmedManager.berserkDamage(event.getDamage()));
}
if (unarmedManager.canDisarm(target)) {
unarmedManager.disarmCheck((Player) target);
}
startGainXp(mcMMOPlayer, target, SkillType.UNARMED);
}
}
}
}
@ -169,6 +178,10 @@ public final class CombatUtils {
switch (damager.getType()) {
case WOLF:
Wolf wolf = (Wolf) damager;
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.TAMING, wolf.getWorld().getName())) {
break;
}
if (wolf.isTamed() && wolf.getOwner() instanceof Player) {
Player master = (Player) wolf.getOwner();
@ -206,7 +219,11 @@ public final class CombatUtils {
case ARROW:
LivingEntity shooter = ((Arrow) damager).getShooter();
/* Break instead of return due to Dodge/Counter/Deflect abilities */
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.ARCHERY, shooter.getWorld().getName())) {
break;
}
// Break instead of return due to Dodge/Counter/Deflect abilities
if (shooter == null || !(shooter instanceof Player)) {
break;
}
@ -268,39 +285,45 @@ public final class CombatUtils {
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
AcrobaticsManager acrobaticsManager = mcMMOPlayer.getAcrobaticsManager();
if (WorldConfig.getInstance().isSkillEnabled(SkillType.ACROBATICS, player.getWorld().getName())) {
AcrobaticsManager acrobaticsManager = mcMMOPlayer.getAcrobaticsManager();
if (acrobaticsManager.canDodge(damager)) {
event.setDamage(acrobaticsManager.dodgeCheck(event.getDamage()));
}
if (ItemUtils.isSword(player.getItemInHand())) {
if (!shouldProcessSkill(target, SkillType.SWORDS)) {
return;
}
SwordsManager swordsManager = mcMMOPlayer.getSwordsManager();
if (swordsManager.canUseCounterAttack(damager)) {
swordsManager.counterAttackChecks((LivingEntity) damager, event.getDamage());
if (acrobaticsManager.canDodge(damager)) {
event.setDamage(acrobaticsManager.dodgeCheck(event.getDamage()));
}
}
if (damager.getType() == EntityType.ARROW) {
LivingEntity shooter = ((Arrow) damager).getShooter();
if (shooter instanceof Player || !SkillType.UNARMED.getPVEEnabled()) {
return;
}
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
if (unarmedManager.canDeflect()) {
event.setCancelled(unarmedManager.deflectCheck());
if (event.isCancelled()) {
if (WorldConfig.getInstance().isSkillEnabled(SkillType.SWORDS, player.getWorld().getName())) {
if (ItemUtils.isSword(player.getItemInHand())) {
if (!shouldProcessSkill(target, SkillType.SWORDS)) {
return;
}
SwordsManager swordsManager = mcMMOPlayer.getSwordsManager();
if (swordsManager.canUseCounterAttack(damager)) {
swordsManager.counterAttackChecks((LivingEntity) damager, event.getDamage());
}
}
}
if (WorldConfig.getInstance().isSkillEnabled(SkillType.UNARMED, player.getWorld().getName())) {
if (damager.getType() == EntityType.ARROW) {
LivingEntity shooter = ((Arrow) damager).getShooter();
if (shooter instanceof Player || !SkillType.UNARMED.getPVEEnabled()) {
return;
}
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
if (unarmedManager.canDeflect()) {
event.setCancelled(unarmedManager.deflectCheck());
if (event.isCancelled()) {
return;
}
}
}
}
}

View File

@ -18,6 +18,8 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.config.WorldConfig;
import com.gmail.nossr50.config.spout.SpoutConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.AbilityType;
@ -293,6 +295,10 @@ public class SkillUtils {
Player player = mcMMOPlayer.getPlayer();
PlayerProfile playerProfile = mcMMOPlayer.getProfile();
if (!WorldConfig.getInstance().isAbilityEnabled(type, player.getWorld().getName())) {
return;
}
/*
* Axes and Woodcutting are odd because they share the same tool.

View File

@ -0,0 +1,39 @@
Worlds:
## Copy the default section and replace 'default' with the name of a world to enable world specific settings for that world
default:
Skills:
Acrobatics:
Enabled: true
Archery:
Enabled: true
Axes:
Enabled: true
AbilityEnabled: true
Excavation:
Enabled: true
AbilityEnabled: true
Fishing:
Enabled: true
Herbalism:
Enabled: true
AbilityEnabled: true
Mining:
Enabled: true
AbilityEnabled: true
Repair:
Enabled: true
Smelting:
Enabled: true
Swords:
Enabled: true
AbilityEnabled: true
Taming:
Enabled: true
Unarmed:
Enabled: true
AbilityEnabled: true
Woodcutting:
Enabled: true
AbilityEnabled: true
BlockStore: true
MobHealthBar: true