Merge branch 'master' of github.com:mcMMO-Dev/mcMMO into tridentsxbows

This commit is contained in:
nossr50 2020-07-27 21:53:12 -07:00
commit 515d58f04f
4 changed files with 50 additions and 8 deletions

View File

@ -48,6 +48,8 @@ Version 2.2.000
Notes:
These are the first new skills that I've written for mcMMO in about 9 years, I'll be listening closely to feedback and tweaking them often.
Version 2.1.136
Furnace ownership was made more reliable
Version 2.1.135
Furnaces no longer simulate block break checks when assigning ownership as it caused some unwanted plugin conflicts

View File

@ -14,7 +14,8 @@ public class FurnaceCleanupTask extends BukkitRunnable {
@Override
public void run() {
if(furnace != null && furnace.getInventory().getResult() == null) {
if(furnace != null
&& furnace.getInventory().getSmelting() == null) {
//Furnace is empty so stop tracking it
mcMMO.getSmeltingTracker().untrackFurnace(furnace);
}

View File

@ -432,8 +432,8 @@ public final class CommandRegistrationManager {
private static void registerXPBarCommand() {
PluginCommand command = mcMMO.p.getCommand("mmoxpbar"); //TODO: Localize
command.setDescription(LocaleLoader.getString("Commands.Description.mmoxpbar"));
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mmoxpbar", "<reset>"));
command.setUsage(command.getUsage() +"\n" + LocaleLoader.getString("Commands.Usage.2", "mmoxpbar", "<skillname>", "<show | hide>"));
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mmoxpbar", "<reset | disable>"));
command.setUsage(command.getUsage() +"\n" + LocaleLoader.getString("Commands.Usage.2", "mmoxpbar", "<show | hide | disable>", "<skillname>"));
command.setExecutor(new XPBarCommand());
}

View File

@ -1,11 +1,14 @@
package com.gmail.nossr50.util.skills;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.smelting.Smelting;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Furnace;
import org.bukkit.entity.Player;
@ -17,16 +20,55 @@ import java.util.HashMap;
public class SmeltingTracker {
private HashMap<Furnace, OfflinePlayer> furnaceOwners;
private final HashMap<Furnace, OfflinePlayer> furnaceOwners;
public SmeltingTracker() {
furnaceOwners = new HashMap<>();
}
private void changeFurnaceOwnership(Furnace furnace, Player player) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
/*
Debug output
*/
printOwnershipGainDebug(furnace, mcMMOPlayer);
printOwnershipLossDebug(furnace);
furnaceOwners.put(furnace, player);
}
private void printOwnershipGainDebug(Furnace furnace, McMMOPlayer mcMMOPlayer) {
if(mcMMOPlayer != null) {
if(mcMMOPlayer.isDebugMode()) {
mcMMOPlayer.getPlayer().sendMessage("Furnace ownership " +
ChatColor.GREEN +"gained " + ChatColor.RESET +
"at location: " + furnace.getLocation().toString());
}
}
}
private void printOwnershipLossDebug(Furnace furnace) {
if(furnaceOwners.get(furnace) != null) {
OfflinePlayer furnaceOwner = furnaceOwners.get(furnace);
if(furnaceOwner.isOnline()) {
McMMOPlayer furnaceOwnerProfile = UserManager.getPlayer(furnaceOwner.getPlayer());
if(furnaceOwnerProfile != null) {
if(furnaceOwnerProfile.isDebugMode()) {
furnaceOwnerProfile.getPlayer().sendMessage("Furnace ownership " +
ChatColor.RED + "lost " + ChatColor.RESET +
"at location: " + furnace.getLocation().toString());
}
}
}
}
}
@Nullable
public Furnace getFurnaceFromInventory(Inventory inventory) {
if (!(inventory instanceof FurnaceInventory)) {
@ -45,10 +87,6 @@ public class SmeltingTracker {
return furnaceOwners.get(furnace) != null;
}
public void removeFurnaceOwner(Furnace furnace) {
furnaceOwners.remove(furnace);
}
public void processFurnaceOwnership(Furnace furnace, Player player) {
if(!Permissions.skillEnabled(player, PrimarySkillType.SMELTING))
return;
@ -57,6 +95,7 @@ public class SmeltingTracker {
}
public void untrackFurnace(Furnace furnace) {
printOwnershipLossDebug(furnace);
furnaceOwners.remove(furnace);
}
}