mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-03-25 11:19:44 +01:00
parent
82af006ea4
commit
f69f88add7
@ -1,4 +1,5 @@
|
|||||||
Version 2.2.034
|
Version 2.2.034
|
||||||
|
Fixed bug where mcMMO would drop items in such a way that they get stuck in an adjacent block and float to the surface
|
||||||
Fixed a rare edge case where null entities during chunk unload would cause a NullPointerException and potentially lead to server instability
|
Fixed a rare edge case where null entities during chunk unload would cause a NullPointerException and potentially lead to server instability
|
||||||
Fixed bug where arrow would award archery xp after a crossbow trickshot bounce
|
Fixed bug where arrow would award archery xp after a crossbow trickshot bounce
|
||||||
|
|
||||||
|
@ -39,6 +39,8 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import static com.gmail.nossr50.util.Misc.getBlockCenter;
|
||||||
|
|
||||||
public class BlockListener implements Listener {
|
public class BlockListener implements Listener {
|
||||||
private final mcMMO plugin;
|
private final mcMMO plugin;
|
||||||
|
|
||||||
@ -103,11 +105,15 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event.getBlock().getMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS).size() > 0) {
|
if (event.getBlock().getMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS).size() > 0) {
|
||||||
BonusDropMeta bonusDropMeta = (BonusDropMeta) event.getBlock().getMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS).get(0);
|
final BonusDropMeta bonusDropMeta =
|
||||||
|
(BonusDropMeta) event.getBlock().getMetadata(
|
||||||
|
MetadataConstants.METADATA_KEY_BONUS_DROPS).get(0);
|
||||||
int bonusCount = bonusDropMeta.asInt();
|
int bonusCount = bonusDropMeta.asInt();
|
||||||
|
final Location centeredLocation = getBlockCenter(event.getBlock());
|
||||||
for (int i = 0; i < bonusCount; i++) {
|
for (int i = 0; i < bonusCount; i++) {
|
||||||
ItemUtils.spawnItemNaturally(event.getPlayer(), event.getBlockState().getLocation(), is, ItemSpawnReason.BONUS_DROPS);
|
|
||||||
|
ItemUtils.spawnItemNaturally(event.getPlayer(),
|
||||||
|
centeredLocation, is, ItemSpawnReason.BONUS_DROPS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,13 +50,13 @@ public class ExcavationManager extends SkillManager {
|
|||||||
|
|
||||||
if (!treasures.isEmpty()) {
|
if (!treasures.isEmpty()) {
|
||||||
int skillLevel = getSkillLevel();
|
int skillLevel = getSkillLevel();
|
||||||
Location location = Misc.getBlockCenter(block);
|
final Location centerOfBlock = Misc.getBlockCenter(block);
|
||||||
|
|
||||||
for (ExcavationTreasure treasure : treasures) {
|
for (ExcavationTreasure treasure : treasures) {
|
||||||
if (skillLevel >= treasure.getDropLevel()
|
if (skillLevel >= treasure.getDropLevel()
|
||||||
&& ProbabilityUtil.isStaticSkillRNGSuccessful(
|
&& ProbabilityUtil.isStaticSkillRNGSuccessful(
|
||||||
PrimarySkillType.EXCAVATION, mmoPlayer, treasure.getDropProbability())) {
|
PrimarySkillType.EXCAVATION, mmoPlayer, treasure.getDropProbability())) {
|
||||||
processExcavationBonusesOnBlock(treasure, location);
|
processExcavationBonusesOnBlock(treasure, centerOfBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ import java.util.*;
|
|||||||
|
|
||||||
import static com.gmail.nossr50.util.ItemUtils.hasItemIncludingOffHand;
|
import static com.gmail.nossr50.util.ItemUtils.hasItemIncludingOffHand;
|
||||||
import static com.gmail.nossr50.util.ItemUtils.removeItemIncludingOffHand;
|
import static com.gmail.nossr50.util.ItemUtils.removeItemIncludingOffHand;
|
||||||
|
import static com.gmail.nossr50.util.Misc.getBlockCenter;
|
||||||
import static com.gmail.nossr50.util.text.ConfigStringUtils.getMaterialConfigString;
|
import static com.gmail.nossr50.util.text.ConfigStringUtils.getMaterialConfigString;
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
@ -733,7 +734,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int skillLevel = getSkillLevel();
|
int skillLevel = getSkillLevel();
|
||||||
Location location = Misc.getBlockCenter(blockState);
|
final Location centerOfBlock = getBlockCenter(blockState);
|
||||||
|
|
||||||
for (HylianTreasure treasure : treasures) {
|
for (HylianTreasure treasure : treasures) {
|
||||||
if (skillLevel >= treasure.getDropLevel()
|
if (skillLevel >= treasure.getDropLevel()
|
||||||
@ -742,7 +743,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
blockState.setType(Material.AIR);
|
blockState.setType(Material.AIR);
|
||||||
ItemUtils.spawnItem(getPlayer(), location, treasure.getDrop(), ItemSpawnReason.HYLIAN_LUCK_TREASURE);
|
ItemUtils.spawnItem(getPlayer(), centerOfBlock, treasure.getDrop(), ItemSpawnReason.HYLIAN_LUCK_TREASURE);
|
||||||
NotificationManager.sendPlayerInformation(mmoPlayer.getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Herbalism.HylianLuck");
|
NotificationManager.sendPlayerInformation(mmoPlayer.getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Herbalism.HylianLuck");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static com.gmail.nossr50.util.ItemUtils.isPickaxe;
|
import static com.gmail.nossr50.util.ItemUtils.isPickaxe;
|
||||||
|
import static com.gmail.nossr50.util.Misc.getBlockCenter;
|
||||||
|
|
||||||
public class MiningManager extends SkillManager {
|
public class MiningManager extends SkillManager {
|
||||||
|
|
||||||
@ -214,7 +215,7 @@ public class MiningManager extends SkillManager {
|
|||||||
|
|
||||||
if (block.getType().isItem() && Probability.ofPercent(10).evaluate()) {
|
if (block.getType().isItem() && Probability.ofPercent(10).evaluate()) {
|
||||||
ItemUtils.spawnItem(getPlayer(),
|
ItemUtils.spawnItem(getPlayer(),
|
||||||
Misc.getBlockCenter(block),
|
getBlockCenter(block),
|
||||||
new ItemStack(block.getType()),
|
new ItemStack(block.getType()),
|
||||||
ItemSpawnReason.BLAST_MINING_DEBRIS_NON_ORES); // Initial block that would have been dropped
|
ItemSpawnReason.BLAST_MINING_DEBRIS_NON_ORES); // Initial block that would have been dropped
|
||||||
}
|
}
|
||||||
@ -234,14 +235,14 @@ public class MiningManager extends SkillManager {
|
|||||||
Collection<ItemStack> oreDrops = isPickaxe(mmoPlayer.getPlayer().getInventory().getItemInMainHand())
|
Collection<ItemStack> oreDrops = isPickaxe(mmoPlayer.getPlayer().getInventory().getItemInMainHand())
|
||||||
? block.getDrops(mmoPlayer.getPlayer().getInventory().getItemInMainHand())
|
? block.getDrops(mmoPlayer.getPlayer().getInventory().getItemInMainHand())
|
||||||
: List.of(new ItemStack(block.getType()));
|
: List.of(new ItemStack(block.getType()));
|
||||||
ItemUtils.spawnItems(getPlayer(), Misc.getBlockCenter(block),
|
ItemUtils.spawnItems(getPlayer(), getBlockCenter(block),
|
||||||
oreDrops, BLAST_MINING_BLACKLIST, ItemSpawnReason.BLAST_MINING_ORES);
|
oreDrops, BLAST_MINING_BLACKLIST, ItemSpawnReason.BLAST_MINING_ORES);
|
||||||
|
|
||||||
if (mcMMO.p.getAdvancedConfig().isBlastMiningBonusDropsEnabled()) {
|
if (mcMMO.p.getAdvancedConfig().isBlastMiningBonusDropsEnabled()) {
|
||||||
if (Probability.ofValue(0.5F).evaluate()) {
|
if (Probability.ofValue(0.5F).evaluate()) {
|
||||||
for (int i = 1; i < dropMultiplier; i++) {
|
for (int i = 1; i < dropMultiplier; i++) {
|
||||||
ItemUtils.spawnItems(getPlayer(),
|
ItemUtils.spawnItems(getPlayer(),
|
||||||
Misc.getBlockCenter(block),
|
getBlockCenter(block),
|
||||||
oreDrops,
|
oreDrops,
|
||||||
BLAST_MINING_BLACKLIST,
|
BLAST_MINING_BLACKLIST,
|
||||||
ItemSpawnReason.BLAST_MINING_ORES_BONUS_DROP);
|
ItemSpawnReason.BLAST_MINING_ORES_BONUS_DROP);
|
||||||
|
@ -109,7 +109,8 @@ public class UnarmedManager extends SkillManager {
|
|||||||
if (UserManager.getPlayer(defender) == null)
|
if (UserManager.getPlayer(defender) == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Item item = ItemUtils.spawnItem(getPlayer(), defender.getLocation(), defender.getInventory().getItemInMainHand(), ItemSpawnReason.UNARMED_DISARMED_ITEM);
|
final Item item = ItemUtils.spawnItem(getPlayer(), defender.getLocation(),
|
||||||
|
defender.getInventory().getItemInMainHand(), ItemSpawnReason.UNARMED_DISARMED_ITEM);
|
||||||
|
|
||||||
if (item != null && mcMMO.p.getAdvancedConfig().getDisarmProtected()) {
|
if (item != null && mcMMO.p.getAdvancedConfig().getDisarmProtected()) {
|
||||||
item.setMetadata(MetadataConstants.METADATA_KEY_DISARMED_ITEM, UserManager.getPlayer(defender).getPlayerMetadata());
|
item.setMetadata(MetadataConstants.METADATA_KEY_DISARMED_ITEM, UserManager.getPlayer(defender).getPlayerMetadata());
|
||||||
|
@ -759,7 +759,7 @@ public final class ItemUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We can't get the item until we spawn it and we want to make it cancellable, so we have a custom event.
|
// We can't get the item until we spawn it and we want to make it cancellable, so we have a custom event.
|
||||||
McMMOItemSpawnEvent event = new McMMOItemSpawnEvent(location, itemStack, itemSpawnReason, player);
|
final McMMOItemSpawnEvent event = new McMMOItemSpawnEvent(location, itemStack, itemSpawnReason, player);
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
@ -786,7 +786,7 @@ public final class ItemUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We can't get the item until we spawn it and we want to make it cancellable, so we have a custom event.
|
// We can't get the item until we spawn it and we want to make it cancellable, so we have a custom event.
|
||||||
McMMOItemSpawnEvent event = new McMMOItemSpawnEvent(location, itemStack, itemSpawnReason, player);
|
final McMMOItemSpawnEvent event = new McMMOItemSpawnEvent(location, itemStack, itemSpawnReason, player);
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
|
@ -109,7 +109,7 @@ public final class Misc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Location getBlockCenter(Location location) {
|
public static Location getBlockCenter(Location location) {
|
||||||
return location.add(0.5, 0.5, 0.5);
|
return location.clone().add(0.5, 0.5, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void profileCleanup(@NotNull String playerName) {
|
public static void profileCleanup(@NotNull String playerName) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user