mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-30 00:56:47 +01:00
Worlds config beta
This commit is contained in:
parent
2ee919b51f
commit
fc935ce9dd
49
src/main/java/com/gmail/nossr50/config/WorldConfig.java
Normal file
49
src/main/java/com/gmail/nossr50/config/WorldConfig.java
Normal 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); }
|
||||||
|
}
|
@ -22,6 +22,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.HiddenConfig;
|
import com.gmail.nossr50.config.HiddenConfig;
|
||||||
|
import com.gmail.nossr50.config.WorldConfig;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
@ -58,6 +59,10 @@ public class BlockListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||||
|
if (!WorldConfig.getInstance().isBlockStoreEnabled(event.getBlock().getWorld().getName()) || !HiddenConfig.getInstance().getChunkletsEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
List<Block> blocks = event.getBlocks();
|
List<Block> blocks = event.getBlocks();
|
||||||
BlockFace direction = event.getDirection();
|
BlockFace direction = event.getDirection();
|
||||||
Block futureEmptyBlock = event.getBlock().getRelative(direction); // Block that would be air after piston is finished
|
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) {
|
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||||
if (event.isSticky()) {
|
if (event.isSticky()) {
|
||||||
// Needed only because under some circumstances Minecraft doesn't move the block
|
// 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);
|
new StickyPistonTrackerTask(event.getDirection(), event.getBlock()).runTaskLater(plugin, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,47 +155,61 @@ public class BlockListener implements Listener {
|
|||||||
|
|
||||||
/* HERBALISM */
|
/* HERBALISM */
|
||||||
if (BlockUtils.affectedByGreenTerra(blockState)) {
|
if (BlockUtils.affectedByGreenTerra(blockState)) {
|
||||||
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
|
if (WorldConfig.getInstance().isSkillEnabled(SkillType.HERBALISM, blockState.getWorld().getName())) {
|
||||||
|
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
|
||||||
|
|
||||||
/* Green Terra */
|
/* Green Terra */
|
||||||
if (herbalismManager.canActivateAbility()) {
|
if (herbalismManager.canActivateAbility()) {
|
||||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.HERBALISM);
|
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.HERBALISM);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We don't check the block store here because herbalism has too many unusual edge cases.
|
* We don't check the block store here because Herbalism has too many unusual edge cases.
|
||||||
* Instead, we check it inside the drops handler.
|
* Instead, we check it inside the drops handler.
|
||||||
*/
|
*/
|
||||||
if (Permissions.skillEnabled(player, SkillType.HERBALISM)) {
|
if (Permissions.skillEnabled(player, SkillType.HERBALISM)) {
|
||||||
herbalismManager.herbalismBlockCheck(blockState);
|
herbalismManager.herbalismBlockCheck(blockState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* MINING */
|
/* MINING */
|
||||||
else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && Permissions.skillEnabled(player, SkillType.MINING) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
else if (BlockUtils.affectedBySuperBreaker(blockState)) {
|
||||||
MiningManager miningManager = mcMMOPlayer.getMiningManager();
|
if (WorldConfig.getInstance().isSkillEnabled(SkillType.MINING, blockState.getWorld().getName())) {
|
||||||
miningManager.miningBlockCheck(blockState);
|
if (ItemUtils.isPickaxe(heldItem) && Permissions.skillEnabled(player, SkillType.MINING) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||||
|
MiningManager miningManager = mcMMOPlayer.getMiningManager();
|
||||||
|
miningManager.miningBlockCheck(blockState);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* WOOD CUTTING */
|
/* WOOD CUTTING */
|
||||||
else if (BlockUtils.isLog(blockState) && Permissions.skillEnabled(player, SkillType.WOODCUTTING) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
else if (BlockUtils.isLog(blockState)) {
|
||||||
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
|
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)) {
|
if (woodcuttingManager.canUseTreeFeller(heldItem)) {
|
||||||
woodcuttingManager.processTreeFeller(blockState);
|
woodcuttingManager.processTreeFeller(blockState);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
woodcuttingManager.woodcuttingBlockCheck(blockState);
|
woodcuttingManager.woodcuttingBlockCheck(blockState);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EXCAVATION */
|
/* EXCAVATION */
|
||||||
else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && Permissions.skillEnabled(player, SkillType.EXCAVATION) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
else if (BlockUtils.affectedByGigaDrillBreaker(blockState)) {
|
||||||
ExcavationManager excavationManager = mcMMOPlayer.getExcavationManager();
|
if (WorldConfig.getInstance().isSkillEnabled(SkillType.EXCAVATION, blockState.getWorld().getName())) {
|
||||||
excavationManager.excavationBlockCheck(blockState);
|
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)) {
|
if (mcMMOPlayer.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) {
|
||||||
excavationManager.gigaDrillBreaker(blockState);
|
excavationManager.gigaDrillBreaker(blockState);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,6 +238,10 @@ public class BlockListener implements Listener {
|
|||||||
ItemStack heldItem = player.getItemInHand();
|
ItemStack heldItem = player.getItemInHand();
|
||||||
|
|
||||||
if (ItemUtils.isSword(heldItem)) {
|
if (ItemUtils.isSword(heldItem)) {
|
||||||
|
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.HERBALISM, blockState.getWorld().getName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
HerbalismManager herbalismManager = UserManager.getPlayer(player).getHerbalismManager();
|
HerbalismManager herbalismManager = UserManager.getPlayer(player).getHerbalismManager();
|
||||||
|
|
||||||
if (herbalismManager.canUseHylianLuck()) {
|
if (herbalismManager.canUseHylianLuck()) {
|
||||||
@ -225,6 +252,10 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ItemUtils.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH)) {
|
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();
|
SmeltingManager smeltingManager = UserManager.getPlayer(player).getSmeltingManager();
|
||||||
|
|
||||||
if (smeltingManager.canUseFluxMining(blockState)) {
|
if (smeltingManager.canUseFluxMining(blockState)) {
|
||||||
|
@ -33,7 +33,9 @@ import org.bukkit.metadata.FixedMetadataValue;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
|
import com.gmail.nossr50.config.WorldConfig;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
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.FakeEntityDamageByEntityEvent;
|
||||||
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
@ -59,6 +61,9 @@ public class EntityListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onEntityShootBow(EntityShootBowEvent event) {
|
public void onEntityShootBow(EntityShootBowEvent event) {
|
||||||
|
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.ARCHERY, event.getEntity().getWorld().getName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
ItemStack bow = event.getBow();
|
ItemStack bow = event.getBow();
|
||||||
|
|
||||||
if (bow != null) {
|
if (bow != null) {
|
||||||
@ -194,6 +199,10 @@ public class EntityListener implements Listener {
|
|||||||
|
|
||||||
switch (cause) {
|
switch (cause) {
|
||||||
case FALL:
|
case FALL:
|
||||||
|
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.ACROBATICS, player.getWorld().getName())) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
AcrobaticsManager acrobaticsManager = mcMMOPlayer.getAcrobaticsManager();
|
AcrobaticsManager acrobaticsManager = mcMMOPlayer.getAcrobaticsManager();
|
||||||
|
|
||||||
if (acrobaticsManager.canRoll()) {
|
if (acrobaticsManager.canRoll()) {
|
||||||
@ -207,6 +216,10 @@ public class EntityListener implements Listener {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BLOCK_EXPLOSION:
|
case BLOCK_EXPLOSION:
|
||||||
|
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.MINING, player.getWorld().getName())) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
MiningManager miningManager = mcMMOPlayer.getMiningManager();
|
MiningManager miningManager = mcMMOPlayer.getMiningManager();
|
||||||
|
|
||||||
if (miningManager.canUseDemolitionsExpertise()) {
|
if (miningManager.canUseDemolitionsExpertise()) {
|
||||||
@ -231,6 +244,10 @@ public class EntityListener implements Listener {
|
|||||||
Tameable pet = (Tameable) livingEntity;
|
Tameable pet = (Tameable) livingEntity;
|
||||||
AnimalTamer owner = pet.getOwner();
|
AnimalTamer owner = pet.getOwner();
|
||||||
|
|
||||||
|
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.TAMING, livingEntity.getWorld().getName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (Taming.canPreventDamage(pet, owner)) {
|
if (Taming.canPreventDamage(pet, owner)) {
|
||||||
Player player = (Player) owner;
|
Player player = (Player) owner;
|
||||||
Wolf wolf = (Wolf) pet;
|
Wolf wolf = (Wolf) pet;
|
||||||
@ -356,6 +373,10 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.MINING, entity.getWorld().getName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
|
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
|
||||||
|
|
||||||
if (miningManager.canUseBiggerBombs()) {
|
if (miningManager.canUseBiggerBombs()) {
|
||||||
@ -370,7 +391,7 @@ public class EntityListener implements Listener {
|
|||||||
* @param event The event to modify
|
* @param event The event to modify
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onEnitityExplode(EntityExplodeEvent event) {
|
public void onEntityExplode(EntityExplodeEvent event) {
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
|
|
||||||
if (entity instanceof TNTPrimed && entity.hasMetadata(mcMMO.tntMetadataKey)) {
|
if (entity instanceof TNTPrimed && entity.hasMetadata(mcMMO.tntMetadataKey)) {
|
||||||
@ -381,6 +402,10 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.MINING, entity.getWorld().getName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
|
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
|
||||||
|
|
||||||
if (miningManager.canUseBlastMining()) {
|
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 GOLDEN_CARROT: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
|
||||||
case MUSHROOM_SOUP: /* RESTORES 4 HUNGER - RESTORES 6 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 */
|
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)) {
|
if (Permissions.farmersDiet(player)) {
|
||||||
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel1, newFoodLevel));
|
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 MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||||
case POISONOUS_POTATO: /* 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 */
|
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)) {
|
if (Permissions.farmersDiet(player)) {
|
||||||
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel2, newFoodLevel));
|
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel2, newFoodLevel));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
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)) {
|
if (Permissions.fishermansDiet(player)) {
|
||||||
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel));
|
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
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)) {
|
if (Permissions.fishermansDiet(player)) {
|
||||||
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel2, newFoodLevel));
|
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel2, newFoodLevel));
|
||||||
}
|
}
|
||||||
@ -469,6 +510,10 @@ public class EntityListener implements Listener {
|
|||||||
Player player = (Player) event.getOwner();
|
Player player = (Player) event.getOwner();
|
||||||
LivingEntity entity = event.getEntity();
|
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)) {
|
if (Misc.isNPCEntity(player) || Misc.isNPCEntity(entity) || entity.hasMetadata(mcMMO.entityMetadataKey)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -490,6 +535,10 @@ public class EntityListener implements Listener {
|
|||||||
Player player = (Player) target;
|
Player player = (Player) target;
|
||||||
Tameable tameable = (Tameable) entity;
|
Tameable tameable = (Tameable) entity;
|
||||||
|
|
||||||
|
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.TAMING, player.getWorld().getName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!CombatUtils.isFriendlyPet(player, tameable)) {
|
if (!CombatUtils.isFriendlyPet(player, tameable)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import org.bukkit.metadata.MetadataValue;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.config.WorldConfig;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
@ -45,6 +46,10 @@ public class InventoryListener implements Listener {
|
|||||||
public void onInventoryOpen(InventoryOpenEvent event) {
|
public void onInventoryOpen(InventoryOpenEvent event) {
|
||||||
HumanEntity player = event.getPlayer();
|
HumanEntity player = event.getPlayer();
|
||||||
|
|
||||||
|
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.SMELTING, player.getWorld().getName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player)) {
|
if (Misc.isNPCEntity(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,6 +80,10 @@ public class InventoryListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.SMELTING, player.getWorld().getName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Inventory inventory = event.getInventory();
|
Inventory inventory = event.getInventory();
|
||||||
|
|
||||||
if (inventory instanceof FurnaceInventory) {
|
if (inventory instanceof FurnaceInventory) {
|
||||||
@ -99,6 +108,10 @@ public class InventoryListener implements Listener {
|
|||||||
Block furnaceBlock = event.getBlock();
|
Block furnaceBlock = event.getBlock();
|
||||||
BlockState furnaceState = furnaceBlock.getState();
|
BlockState furnaceState = furnaceBlock.getState();
|
||||||
|
|
||||||
|
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.SMELTING, furnaceState.getWorld().getName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (furnaceState instanceof Furnace) {
|
if (furnaceState instanceof Furnace) {
|
||||||
ItemStack smelting = ((Furnace) furnaceState).getInventory().getSmelting();
|
ItemStack smelting = ((Furnace) furnaceState).getInventory().getSmelting();
|
||||||
List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey);
|
List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey);
|
||||||
@ -121,6 +134,10 @@ public class InventoryListener implements Listener {
|
|||||||
Block furnaceBlock = event.getBlock();
|
Block furnaceBlock = event.getBlock();
|
||||||
BlockState furnaceState = furnaceBlock.getState();
|
BlockState furnaceState = furnaceBlock.getState();
|
||||||
|
|
||||||
|
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.SMELTING, furnaceState.getWorld().getName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (furnaceState instanceof Furnace) {
|
if (furnaceState instanceof Furnace) {
|
||||||
ItemStack smelting = ((Furnace) furnaceState).getInventory().getSmelting();
|
ItemStack smelting = ((Furnace) furnaceState).getInventory().getSmelting();
|
||||||
List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey);
|
List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey);
|
||||||
@ -151,6 +168,10 @@ public class InventoryListener implements Listener {
|
|||||||
Block furnaceBlock = event.getBlock();
|
Block furnaceBlock = event.getBlock();
|
||||||
BlockState furnaceState = furnaceBlock.getState();
|
BlockState furnaceState = furnaceBlock.getState();
|
||||||
|
|
||||||
|
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.SMELTING, furnaceState.getWorld().getName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (furnaceState instanceof Furnace) {
|
if (furnaceState instanceof Furnace) {
|
||||||
ItemStack result = ((Furnace) furnaceState).getInventory().getResult();
|
ItemStack result = ((Furnace) furnaceState).getInventory().getResult();
|
||||||
List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey);
|
List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey);
|
||||||
|
@ -31,12 +31,14 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.chat.ChatManager;
|
import com.gmail.nossr50.chat.ChatManager;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.config.WorldConfig;
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.ShareHandler;
|
import com.gmail.nossr50.party.ShareHandler;
|
||||||
|
import com.gmail.nossr50.runnables.skills.AbilityDisableTask;
|
||||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||||
import com.gmail.nossr50.skills.fishing.FishingManager;
|
import com.gmail.nossr50.skills.fishing.FishingManager;
|
||||||
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
||||||
@ -125,6 +127,16 @@ public class PlayerListener implements Listener {
|
|||||||
mcMMOPlayer.removeParty();
|
mcMMOPlayer.removeParty();
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Forbidden"));
|
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) {
|
public void onPlayerFish(PlayerFishEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.FISHING, player.getWorld().getName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.FISHING)) {
|
if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.FISHING)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -345,6 +361,10 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
/* REPAIR CHECKS */
|
/* REPAIR CHECKS */
|
||||||
if (blockID == Repair.repairAnvilId && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
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();
|
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
@ -356,6 +376,10 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
/* SALVAGE CHECKS */
|
/* SALVAGE CHECKS */
|
||||||
else if (blockID == Repair.salvageAnvilId && Permissions.salvage(player) && Repair.isSalvageable(heldItem) && !ItemUtils.isChainmailArmor(heldItem)) {
|
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();
|
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
@ -367,6 +391,10 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
/* BLAST MINING CHECK */
|
/* BLAST MINING CHECK */
|
||||||
else if (miningManager.canDetonate()) {
|
else if (miningManager.canDetonate()) {
|
||||||
|
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.MINING, player.getWorld().getName())) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (blockID == Material.TNT.getId()) {
|
if (blockID == Material.TNT.getId()) {
|
||||||
event.setCancelled(true); // Don't detonate the TNT if they're too close
|
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:
|
case LEFT_CLICK_BLOCK:
|
||||||
blockID = block.getTypeId();
|
blockID = block.getTypeId();
|
||||||
|
|
||||||
|
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.REPAIR, player.getWorld().getName())) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* REPAIR CHECKS */
|
/* REPAIR CHECKS */
|
||||||
if (blockID == Repair.repairAnvilId && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
if (blockID == Repair.repairAnvilId && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
||||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||||
@ -404,6 +436,10 @@ public class PlayerListener implements Listener {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case RIGHT_CLICK_AIR:
|
case RIGHT_CLICK_AIR:
|
||||||
|
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.MINING, player.getWorld().getName())) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* BLAST MINING CHECK */
|
/* BLAST MINING CHECK */
|
||||||
if (miningManager.canDetonate()) {
|
if (miningManager.canDetonate()) {
|
||||||
miningManager.remoteDetonation();
|
miningManager.remoteDetonation();
|
||||||
@ -460,6 +496,10 @@ public class PlayerListener implements Listener {
|
|||||||
ChimaeraWing.activationCheck(player);
|
ChimaeraWing.activationCheck(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.HERBALISM, player.getWorld().getName())) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* GREEN THUMB CHECK */
|
/* GREEN THUMB CHECK */
|
||||||
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
|
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
|
||||||
|
|
||||||
@ -500,6 +540,10 @@ public class PlayerListener implements Listener {
|
|||||||
case LEFT_CLICK_AIR:
|
case LEFT_CLICK_AIR:
|
||||||
case LEFT_CLICK_BLOCK:
|
case LEFT_CLICK_BLOCK:
|
||||||
|
|
||||||
|
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.TAMING, player.getWorld().getName())) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* CALL OF THE WILD CHECKS */
|
/* CALL OF THE WILD CHECKS */
|
||||||
if (player.isSneaking() && Permissions.callOfTheWild(player)) {
|
if (player.isSneaking() && Permissions.callOfTheWild(player)) {
|
||||||
Material type = heldItem.getType();
|
Material type = heldItem.getType();
|
||||||
|
@ -16,6 +16,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.config.HiddenConfig;
|
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.CustomArmorConfig;
|
||||||
import com.gmail.nossr50.config.mods.CustomBlockConfig;
|
import com.gmail.nossr50.config.mods.CustomBlockConfig;
|
||||||
import com.gmail.nossr50.config.mods.CustomEntityConfig;
|
import com.gmail.nossr50.config.mods.CustomEntityConfig;
|
||||||
@ -276,6 +277,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
TreasureConfig.getInstance();
|
TreasureConfig.getInstance();
|
||||||
HiddenConfig.getInstance();
|
HiddenConfig.getInstance();
|
||||||
AdvancedConfig.getInstance();
|
AdvancedConfig.getInstance();
|
||||||
|
WorldConfig.getInstance();
|
||||||
new ChildConfig();
|
new ChildConfig();
|
||||||
|
|
||||||
List<Repairable> repairables = new ArrayList<Repairable>();
|
List<Repairable> repairables = new ArrayList<Repairable>();
|
||||||
|
@ -10,6 +10,7 @@ import org.bukkit.metadata.FixedMetadataValue;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.config.WorldConfig;
|
||||||
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.runnables.MobHealthDisplayUpdaterTask;
|
import com.gmail.nossr50.runnables.MobHealthDisplayUpdaterTask;
|
||||||
@ -44,6 +45,10 @@ public final class MobHealthbarUtils {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!WorldConfig.getInstance().isMobHealthEnabled(player.getWorld().getName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
|
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
|
||||||
|
|
||||||
if (profile.getMobHealthbarType() == null) {
|
if (profile.getMobHealthbarType() == null) {
|
||||||
|
@ -17,6 +17,7 @@ import org.bukkit.block.BlockState;
|
|||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.config.WorldConfig;
|
||||||
import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionZDirectory;
|
import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionZDirectory;
|
||||||
|
|
||||||
public class HashChunkManager implements ChunkManager {
|
public class HashChunkManager implements ChunkManager {
|
||||||
@ -303,6 +304,10 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!WorldConfig.getInstance().isBlockStoreEnabled(world.getName())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int cx = x / 16;
|
int cx = x / 16;
|
||||||
int cz = z / 16;
|
int cz = z / 16;
|
||||||
String key = world.getName() + "," + cx + "," + cz;
|
String key = world.getName() + "," + cx + "," + cz;
|
||||||
@ -346,6 +351,10 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!WorldConfig.getInstance().isBlockStoreEnabled(world.getName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int cx = x / 16;
|
int cx = x / 16;
|
||||||
int cz = z / 16;
|
int cz = z / 16;
|
||||||
|
|
||||||
@ -392,6 +401,10 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!WorldConfig.getInstance().isBlockStoreEnabled(world.getName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int cx = x / 16;
|
int cx = x / 16;
|
||||||
int cz = z / 16;
|
int cz = z / 16;
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.config.WorldConfig;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
||||||
@ -65,103 +66,111 @@ public final class CombatUtils {
|
|||||||
ItemStack heldItem = player.getItemInHand();
|
ItemStack heldItem = player.getItemInHand();
|
||||||
|
|
||||||
if (target instanceof Tameable) {
|
if (target instanceof Tameable) {
|
||||||
if (heldItem.getType() == Material.BONE) {
|
if (WorldConfig.getInstance().isSkillEnabled(SkillType.TAMING, player.getWorld().getName())) {
|
||||||
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
|
if (heldItem.getType() == Material.BONE) {
|
||||||
|
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
|
||||||
|
|
||||||
if (tamingManager.canUseBeastLore()) {
|
if (tamingManager.canUseBeastLore()) {
|
||||||
tamingManager.beastLore(target);
|
tamingManager.beastLore(target);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isFriendlyPet(player, (Tameable) target)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFriendlyPet(player, (Tameable) target)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ItemUtils.isSword(heldItem)) {
|
if (ItemUtils.isSword(heldItem)) {
|
||||||
if (!shouldProcessSkill(target, SkillType.SWORDS)) {
|
if (WorldConfig.getInstance().isSkillEnabled(SkillType.SWORDS, player.getWorld().getName())) {
|
||||||
return;
|
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 (swordsManager.canUseBleed()) {
|
if (Permissions.skillEnabled(player, SkillType.SWORDS)) {
|
||||||
swordsManager.bleedCheck(target);
|
SwordsManager swordsManager = mcMMOPlayer.getSwordsManager();
|
||||||
}
|
|
||||||
|
|
||||||
if (swordsManager.canUseSerratedStrike()) {
|
if (swordsManager.canActivateAbility()) {
|
||||||
swordsManager.serratedStrikes(target, event.getDamage());
|
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)) {
|
else if (ItemUtils.isAxe(heldItem)) {
|
||||||
if (!shouldProcessSkill(target, SkillType.AXES)) {
|
if (WorldConfig.getInstance().isSkillEnabled(SkillType.AXES, player.getWorld().getName())) {
|
||||||
return;
|
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 (axesManager.canUseAxeMastery()) {
|
if (Permissions.skillEnabled(player, SkillType.AXES)) {
|
||||||
event.setDamage(axesManager.axeMasteryCheck(event.getDamage()));
|
AxesManager axesManager = mcMMOPlayer.getAxesManager();
|
||||||
}
|
|
||||||
|
|
||||||
if (axesManager.canCriticalHit(target)) {
|
if (axesManager.canActivateAbility()) {
|
||||||
event.setDamage(axesManager.criticalHitCheck(target, event.getDamage()));
|
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.AXES);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (axesManager.canImpact(target)) {
|
if (axesManager.canUseAxeMastery()) {
|
||||||
axesManager.impactCheck(target);
|
event.setDamage(axesManager.axeMasteryCheck(event.getDamage()));
|
||||||
}
|
}
|
||||||
else if (axesManager.canGreaterImpact(target)) {
|
|
||||||
event.setDamage(axesManager.greaterImpactCheck(target, event.getDamage()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (axesManager.canUseSkullSplitter(target)) {
|
if (axesManager.canCriticalHit(target)) {
|
||||||
axesManager.skullSplitterCheck(target, event.getDamage());
|
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) {
|
else if (heldItem.getType() == Material.AIR) {
|
||||||
if (!shouldProcessSkill(target, SkillType.UNARMED)) {
|
if (WorldConfig.getInstance().isSkillEnabled(SkillType.UNARMED, player.getWorld().getName())) {
|
||||||
return;
|
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 (unarmedManager.canUseIronArm()) {
|
if (Permissions.skillEnabled(player, SkillType.UNARMED)) {
|
||||||
event.setDamage(unarmedManager.ironArmCheck(event.getDamage()));
|
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
|
||||||
}
|
|
||||||
|
|
||||||
if (unarmedManager.canUseBerserk()) {
|
if (unarmedManager.canActivateAbility()) {
|
||||||
event.setDamage(unarmedManager.berserkDamage(event.getDamage()));
|
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.UNARMED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unarmedManager.canDisarm(target)) {
|
if (unarmedManager.canUseIronArm()) {
|
||||||
unarmedManager.disarmCheck((Player) target);
|
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()) {
|
switch (damager.getType()) {
|
||||||
case WOLF:
|
case WOLF:
|
||||||
Wolf wolf = (Wolf) damager;
|
Wolf wolf = (Wolf) damager;
|
||||||
|
|
||||||
|
if (!WorldConfig.getInstance().isSkillEnabled(SkillType.TAMING, wolf.getWorld().getName())) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (wolf.isTamed() && wolf.getOwner() instanceof Player) {
|
if (wolf.isTamed() && wolf.getOwner() instanceof Player) {
|
||||||
Player master = (Player) wolf.getOwner();
|
Player master = (Player) wolf.getOwner();
|
||||||
@ -206,7 +219,11 @@ public final class CombatUtils {
|
|||||||
case ARROW:
|
case ARROW:
|
||||||
LivingEntity shooter = ((Arrow) damager).getShooter();
|
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)) {
|
if (shooter == null || !(shooter instanceof Player)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -268,39 +285,45 @@ public final class CombatUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
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)) {
|
if (acrobaticsManager.canDodge(damager)) {
|
||||||
event.setDamage(acrobaticsManager.dodgeCheck(event.getDamage()));
|
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 (damager.getType() == EntityType.ARROW) {
|
if (WorldConfig.getInstance().isSkillEnabled(SkillType.SWORDS, player.getWorld().getName())) {
|
||||||
LivingEntity shooter = ((Arrow) damager).getShooter();
|
if (ItemUtils.isSword(player.getItemInHand())) {
|
||||||
|
if (!shouldProcessSkill(target, SkillType.SWORDS)) {
|
||||||
if (shooter instanceof Player || !SkillType.UNARMED.getPVEEnabled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
|
|
||||||
|
|
||||||
if (unarmedManager.canDeflect()) {
|
|
||||||
event.setCancelled(unarmedManager.deflectCheck());
|
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
|
||||||
return;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,8 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.config.HiddenConfig;
|
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.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
@ -293,6 +295,10 @@ public class SkillUtils {
|
|||||||
|
|
||||||
Player player = mcMMOPlayer.getPlayer();
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
PlayerProfile playerProfile = mcMMOPlayer.getProfile();
|
PlayerProfile playerProfile = mcMMOPlayer.getProfile();
|
||||||
|
|
||||||
|
if (!WorldConfig.getInstance().isAbilityEnabled(type, player.getWorld().getName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Axes and Woodcutting are odd because they share the same tool.
|
* Axes and Woodcutting are odd because they share the same tool.
|
||||||
|
39
src/main/resources/worlds.yml
Normal file
39
src/main/resources/worlds.yml
Normal 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
|
Loading…
Reference in New Issue
Block a user