From 567a5461e11e971641878c45edfeb71688e339f5 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 27 Jul 2020 21:19:25 -0700 Subject: [PATCH] Add some more mmodebug related to furnaces --- .../nossr50/util/skills/SmeltingTracker.java | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/util/skills/SmeltingTracker.java b/src/main/java/com/gmail/nossr50/util/skills/SmeltingTracker.java index 6fa99bed8..761e8714e 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SmeltingTracker.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SmeltingTracker.java @@ -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,13 +20,45 @@ import java.util.HashMap; public class SmeltingTracker { - private HashMap furnaceOwners; + private final HashMap furnaceOwners; public SmeltingTracker() { furnaceOwners = new HashMap<>(); } private void changeFurnaceOwnership(Furnace furnace, Player player) { + + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + + /* + Debug output + */ + if(mcMMOPlayer != null) { + if(mcMMOPlayer.isDebugMode()) { + mcMMOPlayer.getPlayer().sendMessage("Furnace ownership " + + ChatColor.GREEN +"gained " + ChatColor.RESET + + "at location: " + furnace.getLocation().toString()); + } + + 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()); + } + } + } + } + } + + + furnaceOwners.put(furnace, player); }