mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-25 10:14:43 +02:00
Merge 2.1.50
This commit is contained in:
@ -33,16 +33,13 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.block.*;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
|
||||
import java.util.List;
|
||||
@ -216,37 +213,6 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor falling blocks.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onFallingBlock(EntityChangeBlockEvent event) {
|
||||
/* WORLD BLACKLIST CHECK */
|
||||
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
|
||||
return;
|
||||
|
||||
if (BlockUtils.shouldBeWatched(event.getBlock().getState()) && event.getEntityType().equals(EntityType.FALLING_BLOCK)) {
|
||||
if (event.getTo().equals(Material.AIR) && mcMMO.getPlaceStore().isTrue(event.getBlock())) {
|
||||
event.getEntity().setMetadata("mcMMOBlockFall", new FixedMetadataValue(plugin, event.getBlock().getLocation()));
|
||||
} else {
|
||||
List<MetadataValue> values = event.getEntity().getMetadata("mcMMOBlockFall");
|
||||
|
||||
if (!values.isEmpty()) {
|
||||
|
||||
if (values.get(0).value() == null) return;
|
||||
Block spawn = ((org.bukkit.Location) values.get(0).value()).getBlock();
|
||||
|
||||
|
||||
mcMMO.getPlaceStore().setTrue(event.getBlock());
|
||||
mcMMO.getPlaceStore().setFalse(spawn);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor BlockPlace events.
|
||||
*
|
||||
|
@ -147,7 +147,9 @@ public class EntityListener implements Listener {
|
||||
// When the event is fired for the falling block that changes back to a
|
||||
// normal block
|
||||
// event.getBlock().getType() returns AIR
|
||||
if (!BlockUtils.shouldBeWatched(block.getState()) && block.getType() != Material.AIR) {
|
||||
if (!BlockUtils.shouldBeWatched(block.getState())
|
||||
&& block.getState().getType() != Material.WATER
|
||||
&& block.getType() != Material.AIR) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -380,8 +380,11 @@ public class InventoryListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
|
||||
/* WORLD BLACKLIST CHECK */
|
||||
if (WorldBlacklist.isWorldBlacklisted(event.getSource().getLocation().getWorld()))
|
||||
return;
|
||||
|
||||
//Location can be null here
|
||||
if(event.getSource().getLocation() != null)
|
||||
if(WorldBlacklist.isWorldBlacklisted(event.getSource().getLocation().getWorld()))
|
||||
return;
|
||||
|
||||
Inventory inventory = event.getDestination();
|
||||
|
||||
|
@ -31,6 +31,8 @@ import com.gmail.nossr50.util.sounds.SoundType;
|
||||
import com.gmail.nossr50.worldguard.WorldGuardManager;
|
||||
import com.gmail.nossr50.worldguard.WorldGuardUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -744,16 +746,17 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
FakePlayerAnimationEvent fakeSwing = new FakePlayerAnimationEvent(event.getPlayer()); //PlayerAnimationEvent compat
|
||||
if (herbalismManager.canGreenThumbBlock(blockState)) {
|
||||
Bukkit.getPluginManager().callEvent(fakeSwing);
|
||||
player.getInventory().setItemInMainHand(new ItemStack(Material.WHEAT_SEEDS, heldItem.getAmount() - 1));
|
||||
|
||||
if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
|
||||
blockState.update(true);
|
||||
}
|
||||
}
|
||||
|
||||
/* SHROOM THUMB CHECK */
|
||||
else if (herbalismManager.canUseShroomThumb(blockState)) {
|
||||
Bukkit.getPluginManager().callEvent(fakeSwing);
|
||||
event.setCancelled(true);
|
||||
if (herbalismManager.processShroomThumb(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
|
||||
blockState.update(true);
|
||||
|
@ -88,6 +88,17 @@ public class SelfListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
int earlyLevelBonusXPCap = mcMMO.isRetroModeEnabled() ? 50 : 5;
|
||||
|
||||
int earlyGameBonusXP = 0;
|
||||
|
||||
//Give some bonus XP for low levels
|
||||
if(mcMMOPlayer.getSkillLevel(primarySkillType) < earlyLevelBonusXPCap)
|
||||
{
|
||||
earlyGameBonusXP += (mcMMOPlayer.getXpToLevel(primarySkillType) * 0.05);
|
||||
event.setRawXpGained(event.getRawXpGained() + earlyGameBonusXP);
|
||||
}
|
||||
|
||||
int threshold = ExperienceConfig.getInstance().getDiminishedReturnsThreshold(primarySkillType);
|
||||
|
||||
if (threshold <= 0 || !ExperienceConfig.getInstance().getDiminishedReturnsEnabled()) {
|
||||
@ -95,7 +106,6 @@ public class SelfListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (event.getRawXpGained() <= 0) {
|
||||
// Don't calculate for XP subtraction
|
||||
return;
|
||||
@ -105,16 +115,6 @@ public class SelfListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
int earlyLevelBonusXPCap = mcMMO.isRetroModeEnabled() ? 50 : 5;
|
||||
|
||||
int earlyGameBonusXP = 0;
|
||||
|
||||
//Give some bonus XP for low levels
|
||||
if (mcMMOPlayer.getSkillLevel(primarySkillType) < earlyLevelBonusXPCap) {
|
||||
earlyGameBonusXP += (mcMMOPlayer.getXpToLevel(primarySkillType) * 0.05);
|
||||
event.setRawXpGained(event.getRawXpGained() + earlyGameBonusXP);
|
||||
}
|
||||
|
||||
final float rawXp = event.getRawXpGained();
|
||||
|
||||
float guaranteedMinimum = ExperienceConfig.getInstance().getDiminishedReturnsCap() * rawXp;
|
||||
|
@ -63,7 +63,7 @@ public class AbilityDisableTask extends BukkitRunnable {
|
||||
|
||||
|
||||
SkillUtils.sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS, ability.getAbilityPlayerOff());
|
||||
new AbilityCooldownTask(mcMMOPlayer, ability).runTaskLaterAsynchronously(mcMMO.p, PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TICK_CONVERSION_FACTOR);
|
||||
new AbilityCooldownTask(mcMMOPlayer, ability).runTaskLater(mcMMO.p, PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TICK_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
private void resendChunkRadiusAt(Player player) {
|
||||
|
@ -174,9 +174,7 @@ public class HerbalismManager extends SkillManager {
|
||||
}
|
||||
|
||||
public boolean isOneBlockPlant(Material material) {
|
||||
return !(material == Material.CACTUS || material == Material.CHORUS_PLANT
|
||||
|| material == Material.SUGAR_CANE || material == Material.KELP_PLANT || material == Material.KELP
|
||||
|| material == Material.TALL_SEAGRASS || material == Material.TALL_GRASS);
|
||||
return !mcMMO.getMaterialMapStore().isMultiBlock(material);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -7,8 +7,9 @@ import java.util.HashSet;
|
||||
/**
|
||||
* Stores hash tables for item and block names
|
||||
* This allows for better support across multiple versions of Minecraft
|
||||
* <p>
|
||||
*
|
||||
* This is a temporary class, mcMMO is spaghetti and I'l clean it up later
|
||||
*
|
||||
*/
|
||||
public class MaterialMapStore {
|
||||
|
||||
@ -19,8 +20,10 @@ public class MaterialMapStore {
|
||||
private HashSet<String> herbalismAbilityBlackList;
|
||||
private HashSet<String> blockCrackerWhiteList;
|
||||
private HashSet<String> canMakeShroomyWhiteList;
|
||||
private HashSet<String> multiBlockEntities;
|
||||
|
||||
public MaterialMapStore() {
|
||||
public MaterialMapStore()
|
||||
{
|
||||
abilityBlackList = new HashSet<>();
|
||||
toolBlackList = new HashSet<>();
|
||||
mossyWhiteList = new HashSet<>();
|
||||
@ -28,39 +31,53 @@ public class MaterialMapStore {
|
||||
herbalismAbilityBlackList = new HashSet<>();
|
||||
blockCrackerWhiteList = new HashSet<>();
|
||||
canMakeShroomyWhiteList = new HashSet<>();
|
||||
multiBlockEntities = new HashSet<>();
|
||||
|
||||
fillHardcodedHashSets();
|
||||
}
|
||||
|
||||
public boolean isAbilityActivationBlackListed(Material material) {
|
||||
public boolean isMultiBlock(Material material)
|
||||
{
|
||||
return multiBlockEntities.contains(material.getKey().getKey());
|
||||
}
|
||||
|
||||
public boolean isAbilityActivationBlackListed(Material material)
|
||||
{
|
||||
return abilityBlackList.contains(material.getKey().getKey());
|
||||
}
|
||||
|
||||
public boolean isToolActivationBlackListed(Material material) {
|
||||
public boolean isToolActivationBlackListed(Material material)
|
||||
{
|
||||
return toolBlackList.contains(material.getKey().getKey());
|
||||
}
|
||||
|
||||
public boolean isMossyWhiteListed(Material material) {
|
||||
public boolean isMossyWhiteListed(Material material)
|
||||
{
|
||||
return mossyWhiteList.contains(material.getKey().getKey());
|
||||
}
|
||||
|
||||
public boolean isLeavesWhiteListed(Material material) {
|
||||
public boolean isLeavesWhiteListed(Material material)
|
||||
{
|
||||
return leavesWhiteList.contains(material.getKey().getKey());
|
||||
}
|
||||
|
||||
public boolean isHerbalismAbilityWhiteListed(Material material) {
|
||||
public boolean isHerbalismAbilityWhiteListed(Material material)
|
||||
{
|
||||
return herbalismAbilityBlackList.contains(material.getKey().getKey());
|
||||
}
|
||||
|
||||
public boolean isBlockCrackerWhiteListed(Material material) {
|
||||
public boolean isBlockCrackerWhiteListed(Material material)
|
||||
{
|
||||
return blockCrackerWhiteList.contains(material.getKey().getKey());
|
||||
}
|
||||
|
||||
public boolean isShroomyWhiteListed(Material material) {
|
||||
public boolean isShroomyWhiteListed(Material material)
|
||||
{
|
||||
return canMakeShroomyWhiteList.contains(material.getKey().getKey());
|
||||
}
|
||||
|
||||
private void fillHardcodedHashSets() {
|
||||
private void fillHardcodedHashSets()
|
||||
{
|
||||
fillAbilityBlackList();
|
||||
filltoolBlackList();
|
||||
fillMossyWhiteList();
|
||||
@ -68,26 +85,43 @@ public class MaterialMapStore {
|
||||
fillHerbalismAbilityBlackList();
|
||||
fillBlockCrackerWhiteList();
|
||||
fillShroomyWhiteList();
|
||||
fillMultiBlockEntitiesList();
|
||||
}
|
||||
|
||||
private void fillShroomyWhiteList() {
|
||||
private void fillMultiBlockEntitiesList()
|
||||
{
|
||||
multiBlockEntities.add("cactus");
|
||||
multiBlockEntities.add("chorus_plant");
|
||||
multiBlockEntities.add("sugar_cane");
|
||||
multiBlockEntities.add("kelp_plant");
|
||||
multiBlockEntities.add("kelp");
|
||||
multiBlockEntities.add("tall_seagrass");
|
||||
multiBlockEntities.add("tall_grass");
|
||||
multiBlockEntities.add("bamboo");
|
||||
}
|
||||
|
||||
private void fillShroomyWhiteList()
|
||||
{
|
||||
canMakeShroomyWhiteList.add("dirt");
|
||||
canMakeShroomyWhiteList.add("grass");
|
||||
canMakeShroomyWhiteList.add("grass_path");
|
||||
}
|
||||
|
||||
private void fillBlockCrackerWhiteList() {
|
||||
private void fillBlockCrackerWhiteList()
|
||||
{
|
||||
blockCrackerWhiteList.add("stone_bricks");
|
||||
}
|
||||
|
||||
private void fillHerbalismAbilityBlackList() {
|
||||
private void fillHerbalismAbilityBlackList()
|
||||
{
|
||||
herbalismAbilityBlackList.add("dirt");
|
||||
herbalismAbilityBlackList.add("grass");
|
||||
herbalismAbilityBlackList.add("grass_path");
|
||||
herbalismAbilityBlackList.add("farmland");
|
||||
}
|
||||
|
||||
private void fillLeavesWhiteList() {
|
||||
private void fillLeavesWhiteList()
|
||||
{
|
||||
leavesWhiteList.add("oak_leaves");
|
||||
leavesWhiteList.add("acacia_leaves");
|
||||
leavesWhiteList.add("birch_leaves");
|
||||
@ -96,7 +130,8 @@ public class MaterialMapStore {
|
||||
leavesWhiteList.add("spruce_leaves");
|
||||
}
|
||||
|
||||
private void fillMossyWhiteList() {
|
||||
private void fillMossyWhiteList()
|
||||
{
|
||||
mossyWhiteList.add("cobblestone");
|
||||
mossyWhiteList.add("dirt");
|
||||
mossyWhiteList.add("grass_path");
|
||||
@ -104,7 +139,8 @@ public class MaterialMapStore {
|
||||
mossyWhiteList.add("cobblestone_wall");
|
||||
}
|
||||
|
||||
private void fillAbilityBlackList() {
|
||||
private void fillAbilityBlackList()
|
||||
{
|
||||
abilityBlackList.add("black_bed");
|
||||
abilityBlackList.add("blue_bed");
|
||||
abilityBlackList.add("brown_bed");
|
||||
@ -203,8 +239,9 @@ public class MaterialMapStore {
|
||||
abilityBlackList.add("wall_sign"); //1.13 and lower?
|
||||
abilityBlackList.add("sign"); //1.13 and lower?
|
||||
}
|
||||
|
||||
private void filltoolBlackList() {
|
||||
|
||||
private void filltoolBlackList()
|
||||
{
|
||||
//TODO: Add anvils / missing logs
|
||||
toolBlackList.add("black_bed");
|
||||
toolBlackList.add("blue_bed");
|
||||
@ -327,7 +364,8 @@ public class MaterialMapStore {
|
||||
toolBlackList.add("spruce_wood");
|
||||
}
|
||||
|
||||
private void addToHashSet(String string, HashSet<String> stringHashSet) {
|
||||
private void addToHashSet(String string, HashSet<String> stringHashSet)
|
||||
{
|
||||
stringHashSet.add(string.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user