Inspect, Salvage, and Locale fixes

This commit is contained in:
nossr50 2019-06-21 08:05:57 -07:00
parent 5698d8282c
commit c6d604bbbc
9 changed files with 76 additions and 27 deletions

View File

@ -1,3 +1,17 @@
Version 2.1.86
Players will no longer be told they got a perfect result when salvaging if they are below max skill level
Salvage results will now travel towards the player instead of moving in a random direction
(FIX) You cannot view stats of players who are offline if your server limits the range on inspect for you via permissions or settings
(FIX) Players will no longer be told they lack skill in salvage if they already qualify for the best possible result for the item
(FIX) Fixed a bug where arcane salvage was being used to calculate salvage results instead of scrap collector
Added the missing locale color for 'Commands.Party.Commands'
Modified colors used in locale strings 'Salvage.Skills.Lottery.Normal', 'Salvage.Skills.Lottery.Perfect', and 'Profile.Loading.FailurePlayer'
When failing to load a profile mcMMO will increase the amount of time it waits before reattempting to load the profile for each failure
NOTES:
You can (and always have been able) to turn off the inspect range check by setting it to 0 in the config
2.2 is around the corner, most things are functional, still a lot of work left to do.
Version 2.1.85
Fixed a nearly 6 year old bug where Super Repair was not included as a child permission under Repair ability permission nodes (which meant some players would not have access to this skill)
Fixed a bug that could prevent salvage from working for certain players

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>2.1.85</version>
<version>2.1.86-SNAPSHOT</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<scm>

View File

@ -66,11 +66,9 @@ public class InspectCommand implements TabExecutor {
Player target = mcMMOPlayer.getPlayer();
if (CommandUtils.hidden(sender, target, Permissions.inspectHidden(sender))) {
if (!Permissions.inspectOffline(sender)) {
sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
return true;
}
}
else if (CommandUtils.tooFar(sender, target, Permissions.inspectFar(sender))) {
return true;
}

View File

@ -65,7 +65,7 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
// Increment attempt counter and try
attempt++;
new PlayerProfileLoadingTask(player, attempt).runTaskLaterAsynchronously(mcMMO.p, 100);
new PlayerProfileLoadingTask(player, attempt).runTaskLaterAsynchronously(mcMMO.p, (100 + (attempt * 100)));
}
private class ApplySuccessfulProfile extends BukkitRunnable {

View File

@ -11,10 +11,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.*;
import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
import com.gmail.nossr50.util.random.RandomChanceUtil;
@ -91,16 +88,14 @@ public class SalvageManager extends SkillManager {
return;
}
int maxAmountSalvageable = Salvage.calculateSalvageableAmount(item.getDurability(), salvageable.getMaximumDurability(), salvageable.getMaximumQuantity());
int potentialSalvageYield = Salvage.calculateSalvageableAmount(item.getDurability(), salvageable.getMaximumDurability(), salvageable.getMaximumQuantity());
int salvageableAmount = maxAmountSalvageable;
if (salvageableAmount == 0) {
if (potentialSalvageYield <= 0) {
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Salvage.Skills.TooDamaged");
return;
}
salvageableAmount = Math.min(salvageableAmount, getSalvageableAmount()); // Always get at least something back, if you're capable of salvaging it.
potentialSalvageYield = Math.min(potentialSalvageYield, getSalvageLimit()); // Always get at least something back, if you're capable of salvaging it.
player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
location.add(0.5, 1, 0.5);
@ -117,7 +112,7 @@ public class SalvageManager extends SkillManager {
int lotteryResults = 1;
int chanceOfSuccess = 99;
for(int x = 0; x < salvageableAmount-1; x++) {
for(int x = 0; x < potentialSalvageYield-1; x++) {
if(RandomChanceUtil.rollDice(chanceOfSuccess, 100)) {
chanceOfSuccess-=2;
@ -127,9 +122,9 @@ public class SalvageManager extends SkillManager {
}
}
if(lotteryResults == salvageableAmount && salvageableAmount != 1) {
if(lotteryResults == potentialSalvageYield && potentialSalvageYield != 1 && RankUtils.isPlayerMaxRankInSubSkill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE)) {
NotificationManager.sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Perfect", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType()));
} else if(RankUtils.isPlayerMaxRankInSubSkill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE) || salvageableAmount == 1) {
} else if(salvageable.getMaximumQuantity() == 1 || getSalvageLimit() >= salvageable.getMaximumQuantity()) {
NotificationManager.sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Normal", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType()));
} else {
NotificationManager.sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Untrained", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType()));
@ -146,7 +141,7 @@ public class SalvageManager extends SkillManager {
Misc.dropItem(location, enchantBook);
}
Misc.dropItems(location, salvageResults, 1);
Misc.spawnItemTowardsLocation(location, player.getLocation().add(0, 0.25, 0), salvageResults);
// BWONG BWONG BWONG - CLUNK!
if (Config.getInstance().getSalvageAnvilUseSoundsEnabled()) {
@ -163,8 +158,8 @@ public class SalvageManager extends SkillManager {
return Math.min((((Salvage.salvageMaxPercentage / Salvage.salvageMaxPercentageLevel) * getSkillLevel()) / 100.0D), Salvage.salvageMaxPercentage / 100.0D);
}*/
public int getSalvageableAmount() {
return (RankUtils.getRank(getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE) * 1);
public int getSalvageLimit() {
return (RankUtils.getRank(getPlayer(), SubSkillType.SALVAGE_SCRAP_COLLECTOR));
}
/**

View File

@ -10,6 +10,7 @@ import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.entity.*;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import java.util.Collection;
import java.util.Random;
@ -117,6 +118,45 @@ public final class Misc {
return location.getWorld().dropItem(location, itemStack);
}
/**
* Drop items at a given location.
*
* @param location The location to drop the items at
* @param is The items to drop
* @param quantity The amount of items to drop
*/
public static void spawnItemsTowardsLocation(Location location, Location targetLocation, ItemStack is, int quantity) {
for (int i = 0; i < quantity; i++) {
spawnItemTowardsLocation(location, targetLocation, is);
}
}
/**
* Drop an item at a given location.
*
* @param spawnLocation The location to drop the item at
* @param itemStack The item to drop
* @return Dropped Item entity or null if invalid or cancelled
*/
public static Item spawnItemTowardsLocation(Location spawnLocation, Location targetLocation, ItemStack itemStack) {
if (itemStack.getType() == Material.AIR) {
return null;
}
// 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(spawnLocation, itemStack);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return null;
}
Item item = spawnLocation.getWorld().dropItem(spawnLocation, itemStack);
Vector vector = targetLocation.toVector().subtract(spawnLocation.toVector()).normalize();
item.setVelocity(vector);
return item;
}
public static void profileCleanup(String playerName) {
Player player = mcMMO.p.getServer().getPlayerExact(playerName);

View File

@ -55,7 +55,6 @@ public final class Permissions {
public static boolean inspect(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.inspect")); }
public static boolean inspectFar(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.inspect.far")); }
public static boolean inspectHidden(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.inspect.hidden")); }
public static boolean inspectOffline(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.inspect.offline")); }
public static boolean kraken(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.kraken"); }
public static boolean krakenOthers(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.kraken.others"); }

View File

@ -34,7 +34,10 @@ public final class CommandUtils {
}
public static boolean tooFar(CommandSender sender, Player target, boolean hasPermission) {
if (sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), Config.getInstance().getInspectDistance()) && !hasPermission) {
if(!target.isOnline() && !hasPermission) {
sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
return true;
} else if (sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), Config.getInstance().getInspectDistance()) && !hasPermission) {
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
return true;
}

View File

@ -393,8 +393,8 @@ Salvage.Skills.ArcaneSuccess=[[GREEN]]You able to extract all of the knowledge c
Salvage.Listener.Anvil=[[DARK_RED]]You have placed a Salvage anvil, use this to Salvage tools and armor.
Salvage.Listener=Salvage:
Salvage.SkillName=SALVAGE
Salvage.Skills.Lottery.Normal=[[GOLD]]You were able to salvage [[GREEN]]{0}[[GOLD]] materials from [[DARK_AQUA]]{1}[[GOLD]].
Salvage.Skills.Lottery.Perfect=[[GREEN]][[BOLD]]Perfect![[RESET]][[GOLD]] You salvaged [[GREEN]]{1}[[GOLD]] effortlessly, retrieving [[DARK_AQUA]]{0}[[GOLD]] materials.
Salvage.Skills.Lottery.Normal=[[GOLD]]You were able to salvage [[DARK_AQUA]]{0}[[GOLD]] materials from [[YELLOW]]{1}[[GOLD]].
Salvage.Skills.Lottery.Perfect=[[GREEN]][[BOLD]]Perfect![[RESET]][[GOLD]] You salvaged [[DARK_AQUA]]{1}[[GOLD]] effortlessly, retrieving [[DARK_AQUA]]{0}[[GOLD]] materials.
Salvage.Skills.Lottery.Untrained=[[GRAY]]You aren't properly trained in salvaging. You were only able to recover [[RED]]{0}[[GRAY]] materials from [[GREEN]]{1}[[GRAY]].
#Anvil (Shared between SALVAGE and REPAIR)
Anvil.Unbreakable=This item is unbreakable!
@ -635,7 +635,7 @@ Commands.Party.MembersNear=[[DARK_GRAY]]NEAR YOU [[DARK_AQUA]]{0}[[DARK_GRAY]]/[
Commands.Party.Accept=[[GREEN]]- Accept party invite
Commands.Party.Chat.Off=Party Chat only [[RED]]Off
Commands.Party.Chat.On=Party Chat only [[GREEN]]On
Commands.Party.Commands=---[][[GREEN]]PARTY COMMANDS[[RED]][]---
Commands.Party.Commands=[[RED]]---[][[GREEN]]PARTY COMMANDS[[RED]][]---
Commands.Party.Invite.0=[[RED]]ALERT: [[GREEN]]You have received a party invite for {0} from {1}
Commands.Party.Invite.1=[[YELLOW]]Type [[GREEN]]/party accept[[YELLOW]] to accept the invite
Commands.Party.Invite=[[GREEN]]- Send party invite
@ -1087,7 +1087,7 @@ Scoreboard.Misc.Ability=Ability
#DATABASE RECOVERY
Profile.PendingLoad=[[RED]]Your mcMMO player data has not yet been loaded.
Profile.Loading.Success=[[GREEN]]Your mcMMO profile has been loaded.
Profile.Loading.FailurePlayer=[[RED]]mcMMO is having trouble loading your data, we have attempted to load it [[GREEN]]{0}[[RED]] times.[[LIGHT_GRAY]] You may want to contact the server admins about this issue. mcMMO will attempt to load your data until you disconnect, you will not gain XP or be able to use skills while the data is not loaded.
Profile.Loading.FailurePlayer=[[RED]]mcMMO is having trouble loading your data, we have attempted to load it [[GREEN]]{0}[[RED]] times.[[RED]] You may want to contact the server admins about this issue. mcMMO will attempt to load your data until you disconnect, you will not gain XP or be able to use skills while the data is not loaded.
Profile.Loading.FailureNotice=[[DARK_RED]][A][[RED]] mcMMO was unable to load the player data for [[YELLOW]]{0}[[RED]]. [[LIGHT_PURPLE]]Please inspect your database setup. Attempts made so far {1}.
#Holiday
Holiday.AprilFools.Levelup=[[GOLD]]{0} is now level [[GREEN]]{1}[[GOLD]]!