merge master

This commit is contained in:
nossr50
2023-04-03 12:12:17 -07:00
18 changed files with 188 additions and 149 deletions

View File

@ -24,8 +24,10 @@ public class McnotifyCommand implements TabExecutor {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
//Not Loaded yet
if (mcMMOPlayer == null)
if (mcMMOPlayer == null) {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.Notifications." + (mcMMOPlayer.useChatNotifications() ? "Off" : "On")));
mcMMOPlayer.toggleChatNotifications();

View File

@ -47,21 +47,28 @@ public class InspectCommand implements TabExecutor {
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName));
// Sum power level
int powerLevel = 0;
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
for (PrimarySkillType skill : mcMMO.p.getSkillTools().GATHERING_SKILLS) {
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
powerLevel += profile.getSkillLevel(skill);
}
sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
for (PrimarySkillType skill : mcMMO.p.getSkillTools().COMBAT_SKILLS) {
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
powerLevel += profile.getSkillLevel(skill);
}
sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
for (PrimarySkillType skill : mcMMO.p.getSkillTools().MISC_SKILLS) {
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
powerLevel += profile.getSkillLevel(skill);
}
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", powerLevel));
} else {
Player target = mcMMOPlayer.getPlayer();
boolean isVanished = false;
@ -95,9 +102,7 @@ public class InspectCommand implements TabExecutor {
CommandUtils.printCombatSkills(target, sender);
CommandUtils.printMiscSkills(target, sender);
if (!isVanished) {
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel()));
}
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel()));
}
return true;

View File

@ -777,6 +777,10 @@ public class AdvancedConfig extends BukkitConfig {
return config.getDouble("Skills.Mining.BlastMining.OreBonus.Rank_" + rank);
}
public boolean isBlastMiningBonusDropsEnabled() {
return config.getBoolean("Skills.Mining.BlastMining.Bonus_Drops.Enabled", true);
}
public double getDebrisReduction(int rank) {
return config.getDouble("Skills.Mining.BlastMining.DebrisReduction.Rank_" + rank);
}

View File

@ -27,40 +27,6 @@ public enum PrimarySkillType {
TAMING,
UNARMED,
WOODCUTTING;
// boolean issueWarning = true;
/*
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
* Everything below here will be removed in 2.2 (Tridents & Crossbows)
*/
// private void processWarning() {
// if(issueWarning) {
// StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
// Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, () -> {
// mcMMO.p.getLogger().severe("A plugin that hooks into mcMMO via the mcMMO API is using soon to be deprecated API calls. Contact the plugin author and inform them to update their code before it breaks.");
// mcMMO.p.getLogger().severe("Deprecation Call from: " + stackTraceElements[2].toString());
// mcMMO.p.getLogger().severe("This warning will not repeat itself. Nothing is broken for now, but in the future it will be.");
// });
//
// issueWarning = !issueWarning;
// }
// }
/**
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead

View File

@ -38,6 +38,7 @@ import org.bukkit.event.block.*;
import org.bukkit.inventory.ItemStack;
import java.util.HashSet;
import java.util.Locale;
public class BlockListener implements Listener {
private final mcMMO plugin;
@ -56,6 +57,12 @@ public class BlockListener implements Listener {
return;
}
int tileEntityTolerance = 1;
// beetroot hotfix, potentially other plants may need this fix
if(event.getBlockState().getType() == Material.BEETROOTS)
tileEntityTolerance = 2;
//Track how many "things" are being dropped
HashSet<Material> uniqueMaterials = new HashSet<>();
boolean dontRewardTE = false; //If we suspect TEs are mixed in with other things don't reward bonus drops for anything that isn't a block
@ -70,7 +77,7 @@ public class BlockListener implements Listener {
blockCount++;
}
if(uniqueMaterials.size() > 1) {
if(uniqueMaterials.size() > tileEntityTolerance) {
//Too many things are dropping, assume tile entities might be duped
//Technically this would also prevent something like coal from being bonus dropped if you placed a TE above a coal ore when mining it but that's pretty edge case and this is a good solution for now
dontRewardTE = true;

View File

@ -361,40 +361,30 @@ public class EntityListener implements Listener {
//Friendly fire checks
if (defender instanceof Player defendingPlayer) {
Player attackingPlayer;
//If the attacker is a Player or a projectile belonging to a player
if(attacker instanceof Projectile || attacker instanceof Player) {
if(attacker instanceof Projectile projectile) {
if(((Projectile) attacker).getShooter() instanceof Player) {
attackingPlayer = (Player) projectile.getShooter();
if(attacker instanceof Projectile projectile) {
if(projectile.getShooter() instanceof Player attackingPlayer && !attackingPlayer.equals(defendingPlayer)) {
//Check for party friendly fire and cancel the event
if (checkParties(event, defendingPlayer, attackingPlayer)) {
return;
}
}
//Check for party friendly fire and cancel the event
if (checkParties(event, defendingPlayer, attackingPlayer))
{
//Deflect checks
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(defendingPlayer);
if (mcMMOPlayer != null) {
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
if (unarmedManager.canDeflect()) {
if (projectile instanceof Arrow && unarmedManager.deflectCheck()) {
event.setCancelled(true);
return;
}
}
//Deflect checks
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(defendingPlayer);
if (mcMMOPlayer != null) {
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
if (unarmedManager.canDeflect()) {
if (projectile instanceof Arrow && unarmedManager.deflectCheck()) {
event.setCancelled(true);
return;
}
}
}
} else {
attackingPlayer = (Player) attacker;
//Check for party friendly fire and cancel the event
if (checkParties(event, defendingPlayer, attackingPlayer))
return;
}
} else if (attacker instanceof Player attackingPlayer){
if (checkParties(event, defendingPlayer, attackingPlayer))
return;
}
}

View File

@ -40,10 +40,7 @@ import org.bukkit.inventory.PlayerInventory;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.*;
public class HerbalismManager extends SkillManager {
public HerbalismManager(McMMOPlayer mcMMOPlayer) {
@ -771,35 +768,39 @@ public class HerbalismManager extends SkillManager {
PlayerInventory playerInventory = player.getInventory();
Material seed;
switch (blockState.getType()) {
case CARROTS:
seed = Material.CARROT;
switch (blockState.getType().getKey().getKey().toLowerCase(Locale.ROOT)) {
case "carrots":
seed = Material.matchMaterial("CARROT");
break;
case WHEAT:
seed = Material.WHEAT_SEEDS;
case "wheat":
seed = Material.matchMaterial("WHEAT_SEEDS");
break;
case NETHER_WART:
seed = Material.NETHER_WART;
case "nether_wart":
seed = Material.getMaterial("NETHER_WART");
break;
case POTATOES:
seed = Material.POTATO;
case "potatoes":
seed = Material.matchMaterial("POTATO");
break;
case BEETROOTS:
seed = Material.BEETROOT_SEEDS;
case "beetroots":
seed = Material.matchMaterial("BEETROOT_SEEDS");
break;
case COCOA:
seed = Material.COCOA_BEANS;
case "cocoa":
seed = Material.matchMaterial("COCOA_BEANS");
break;
case "torchflower":
seed = Material.matchMaterial("TORCHFLOWER_SEEDS");
break;
default:
return false;
}
ItemStack seedStack = new ItemStack(seed);
if (ItemUtils.isAxe(blockBreakEvent.getPlayer().getInventory().getItemInMainHand())
@ -850,17 +851,17 @@ public class HerbalismManager extends SkillManager {
return true;
}
switch (blockState.getType()) {
switch (blockState.getType().getKey().getKey()) {
case POTATOES:
case CARROTS:
case WHEAT:
case "potatoes":
case "carrots":
case "wheat":
finalAge = getGreenThumbStage(greenTerra);
break;
case BEETROOTS:
case NETHER_WART:
case "beetroots":
case "nether_wart":
if (greenTerra || greenThumbStage > 2) {
finalAge = 2;
@ -871,9 +872,9 @@ public class HerbalismManager extends SkillManager {
else {
finalAge = 0;
}
break;
break;
case COCOA:
case "cocoa":
if (getGreenThumbStage(greenTerra) >= 2) {
finalAge = 1;
@ -887,6 +888,7 @@ public class HerbalismManager extends SkillManager {
return false;
}
//Start the delayed replant
startReplantTask(finalAge, blockBreakEvent, blockState, false);
return true;

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.skills.mining;
import com.gmail.nossr50.api.ItemSpawnReason;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
@ -216,7 +217,7 @@ public class MiningManager extends SkillManager {
Misc.spawnItem(getPlayer(), Misc.getBlockCenter(blockState), new ItemStack(blockState.getType()), ItemSpawnReason.BLAST_MINING_ORES); // Initial block that would have been dropped
if (!mcMMO.getPlaceStore().isTrue(blockState)) {
if (mcMMO.p.getAdvancedConfig().isBlastMiningBonusDropsEnabled() && !mcMMO.getPlaceStore().isTrue(blockState)) {
for (int i = 1; i < dropMultiplier; i++) {
// Bukkit.broadcastMessage("Bonus Drop on Ore: "+blockState.getType().toString());
Misc.spawnItem(getPlayer(), Misc.getBlockCenter(blockState), new ItemStack(blockState.getType()), ItemSpawnReason.BLAST_MINING_ORES_BONUS_DROP); // Initial block that would have been dropped
@ -303,21 +304,16 @@ public class MiningManager extends SkillManager {
* @return the Blast Mining tier
*/
public int getDropMultiplier() {
switch(getBlastMiningTier()) {
case 8:
case 7:
return 3;
case 6:
case 5:
case 4:
case 3:
return 2;
case 2:
case 1:
return 1;
default:
return 0;
if (mcMMO.p.getAdvancedConfig().isBlastMiningBonusDropsEnabled()) {
return 0;
}
return switch (getBlastMiningTier()) {
case 8, 7 -> 3;
case 6, 5, 4, 3 -> 2;
case 2, 1 -> 1;
default -> 0;
};
}
/**

View File

@ -22,6 +22,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
public final class ItemUtils {
/**
@ -413,31 +414,31 @@ public final class ItemUtils {
*/
public static boolean isHerbalismDrop(ItemStack item) {
//TODO: 1.14 This needs to be updated
switch (item.getType()) {
case WHEAT:
case WHEAT_SEEDS:
case CARROT:
case CHORUS_FRUIT:
case CHORUS_FLOWER:
case POTATO:
case BEETROOT:
case BEETROOTS:
case BEETROOT_SEEDS:
case NETHER_WART:
case BROWN_MUSHROOM:
case RED_MUSHROOM:
case ROSE_BUSH:
case DANDELION:
case CACTUS:
case SUGAR_CANE:
case MELON:
case MELON_SEEDS:
case PUMPKIN:
case PUMPKIN_SEEDS:
case LILY_PAD:
case VINE:
case TALL_GRASS:
case COCOA_BEANS:
switch (item.getType().getKey().getKey().toLowerCase()) {
case "wheat":
case "wheat_seeds":
case "carrot":
case "chorus_fruit":
case "chorus_flower":
case "potato":
case "beetroot":
case "beetroots":
case "beetroot_seeds":
case "nether_wart":
case "brown_mushroom":
case "red_mushroom":
case "rose_bush":
case "dandelion":
case "cactus":
case "sugar_cane":
case "melon":
case "melon_seeds":
case "pumpkin":
case "pumpkin_seeds":
case "lily_pad":
case "vine":
case "tall_grass":
case "cocoa_beans":
return true;
default:
@ -445,6 +446,7 @@ public final class ItemUtils {
}
}
/**
* Checks to see if an item is a mob drop.
*

View File

@ -1017,6 +1017,7 @@ public class MaterialMapStore {
private void fillTreeFellerDestructibleWhiteList()
{
treeFellerDestructibleWhiteList.add("oak_leaves");
treeFellerDestructibleWhiteList.add("cherry_leaves");
treeFellerDestructibleWhiteList.add("acacia_leaves");
treeFellerDestructibleWhiteList.add("birch_leaves");
treeFellerDestructibleWhiteList.add("dark_oak_leaves");
@ -1171,6 +1172,7 @@ public class MaterialMapStore {
private void fillToolBlackList()
{
toolBlackList.add("chiseled_bookshelf");
toolBlackList.add("black_bed");
toolBlackList.add("blue_bed");
toolBlackList.add("brown_bed");
@ -1256,17 +1258,28 @@ public class MaterialMapStore {
toolBlackList.add("yellow_shulker_box");
toolBlackList.add("shulker_box");
toolBlackList.add("acacia_sign");
toolBlackList.add("acacia_hanging_sign");
toolBlackList.add("acacia_wall_sign");
toolBlackList.add("birch_sign");
toolBlackList.add("birch_hanging_sign");
toolBlackList.add("birch_wall_sign");
toolBlackList.add("dark_oak_sign");
toolBlackList.add("dark_oak_hanging_sign");
toolBlackList.add("dark_oak_wall_sign");
toolBlackList.add("jungle_sign");
toolBlackList.add("jungle_hanging_sign");
toolBlackList.add("jungle_wall_sign");
toolBlackList.add("spruce_sign");
toolBlackList.add("spruce_hanging_sign");
toolBlackList.add("spruce_wall_sign");
toolBlackList.add("oak_sign");
toolBlackList.add("oak_hanging_sign");
toolBlackList.add("oak_wall_sign");
toolBlackList.add("cherry_sign");
toolBlackList.add("cherry_hanging_sign");
toolBlackList.add("cherry_wall_sign");
toolBlackList.add("stripped_cherry_log");
toolBlackList.add("stripped_cherry_wood");
toolBlackList.add("stripped_acacia_log");
toolBlackList.add("stripped_acacia_wood");
toolBlackList.add("stripped_birch_log");
@ -1308,6 +1321,7 @@ public class MaterialMapStore {
toolBlackList.add("lodestone");
toolBlackList.add("respawn_anchor");
toolBlackList.add("sweet_berry_bush");
toolBlackList.add("smithing_table");
}
public boolean isIntendedToolPickaxe(@NotNull Material material) {

View File

@ -8,6 +8,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.metadata.MobMetaFlagType;
import com.gmail.nossr50.metadata.MobMetadataService;
@ -885,8 +886,14 @@ public final class CombatUtils {
return false;
}
public static boolean canDamage(@NotNull Entity attacker, @NotNull Entity target, @NotNull DamageCause damageCause, double damage) {
EntityDamageEvent damageEvent = new FakeEntityDamageByEntityEvent(attacker, target, damageCause, damage);
public static boolean canDamage(@Nullable Entity attacker, @NotNull Entity target, @NotNull DamageCause damageCause, double damage) {
EntityDamageEvent damageEvent;
if (attacker != null) {
damageEvent = new FakeEntityDamageByEntityEvent(attacker, target, damageCause, damage);
} else {
damageEvent = new FakeEntityDamageEvent(target, damageCause, damage);
}
mcMMO.p.getServer().getPluginManager().callEvent(damageEvent);
return !damageEvent.isCancelled();