mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
parent
56e625a9df
commit
618cfad100
@ -8,6 +8,7 @@ Key:
|
|||||||
- Removal
|
- Removal
|
||||||
|
|
||||||
Version 1.5.01-dev
|
Version 1.5.01-dev
|
||||||
|
+ Added new feature to Herbalism. Instantly-regrown crops are protected from being broken for 1 second
|
||||||
+ Added option to config.yml to show the /mcstats scoreboard automatically after logging in
|
+ Added option to config.yml to show the /mcstats scoreboard automatically after logging in
|
||||||
+ Added support for `MATERIAL|data` format in treasures.yml
|
+ Added support for `MATERIAL|data` format in treasures.yml
|
||||||
= Fixed bug where the Updater was running on the main thread.
|
= Fixed bug where the Updater was running on the main thread.
|
||||||
|
@ -34,6 +34,7 @@ import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
|||||||
import com.gmail.nossr50.runnables.StickyPistonTrackerTask;
|
import com.gmail.nossr50.runnables.StickyPistonTrackerTask;
|
||||||
import com.gmail.nossr50.skills.alchemy.Alchemy;
|
import com.gmail.nossr50.skills.alchemy.Alchemy;
|
||||||
import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
||||||
|
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
||||||
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
||||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||||
@ -227,6 +228,11 @@ public class BlockListener implements Listener {
|
|||||||
BlockState blockState = event.getBlock().getState();
|
BlockState blockState = event.getBlock().getState();
|
||||||
ItemStack heldItem = player.getItemInHand();
|
ItemStack heldItem = player.getItemInHand();
|
||||||
|
|
||||||
|
if (Herbalism.isRecentlyRegrown(blockState)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ItemUtils.isSword(heldItem)) {
|
if (ItemUtils.isSword(heldItem)) {
|
||||||
HerbalismManager herbalismManager = UserManager.getPlayer(player).getHerbalismManager();
|
HerbalismManager herbalismManager = UserManager.getPlayer(player).getHerbalismManager();
|
||||||
|
|
||||||
|
@ -107,6 +107,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
public final static String customDamageKey = "mcMMO: Custom Damage";
|
public final static String customDamageKey = "mcMMO: Custom Damage";
|
||||||
public final static String disarmedItemKey = "mcMMO: Disarmed Item";
|
public final static String disarmedItemKey = "mcMMO: Disarmed Item";
|
||||||
public final static String playerDataKey = "mcMMO: Player Data";
|
public final static String playerDataKey = "mcMMO: Player Data";
|
||||||
|
public final static String greenThumbDataKey = "mcMMO: Green Thumb";
|
||||||
|
|
||||||
public static FixedMetadataValue metadataValue;
|
public static FixedMetadataValue metadataValue;
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import org.bukkit.material.SmoothBrick;
|
|||||||
|
|
||||||
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.util.skills.SkillUtils;
|
||||||
|
|
||||||
public class Herbalism {
|
public class Herbalism {
|
||||||
public static int farmersDietRankLevel1 = AdvancedConfig.getInstance().getFarmerDietRankChange();
|
public static int farmersDietRankLevel1 = AdvancedConfig.getInstance().getFarmerDietRankChange();
|
||||||
@ -93,4 +94,14 @@ public class Herbalism {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the block has a recently grown crop from Green Thumb
|
||||||
|
*
|
||||||
|
* @param blockState The {@link BlockState} to check green thumb regrown for
|
||||||
|
* @return true if the block is recently regrown, false otherwise
|
||||||
|
*/
|
||||||
|
public static boolean isRecentlyRegrown(BlockState blockState) {
|
||||||
|
return blockState.hasMetadata(mcMMO.greenThumbDataKey) && !SkillUtils.cooldownExpired(blockState.getMetadata(mcMMO.greenThumbDataKey).get(0).asInt(), 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import org.bukkit.material.CocoaPlant;
|
|||||||
import org.bukkit.material.CocoaPlant.CocoaPlantSize;
|
import org.bukkit.material.CocoaPlant.CocoaPlantSize;
|
||||||
import org.bukkit.material.Crops;
|
import org.bukkit.material.Crops;
|
||||||
import org.bukkit.material.NetherWarts;
|
import org.bukkit.material.NetherWarts;
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
@ -330,6 +331,8 @@ public class HerbalismManager extends SkillManager {
|
|||||||
private boolean handleBlockState(BlockState blockState, boolean greenTerra) {
|
private boolean handleBlockState(BlockState blockState, boolean greenTerra) {
|
||||||
byte greenThumbStage = getGreenThumbStage();
|
byte greenThumbStage = getGreenThumbStage();
|
||||||
|
|
||||||
|
blockState.setMetadata(mcMMO.greenThumbDataKey, new FixedMetadataValue(mcMMO.p, (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)));
|
||||||
|
|
||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
case CROPS:
|
case CROPS:
|
||||||
Crops crops = (Crops) blockState.getData();
|
Crops crops = (Crops) blockState.getData();
|
||||||
|
Loading…
Reference in New Issue
Block a user