Repository: mythicdrops/mythicdrops
Issue: Custom Socket Names Not Working

5.0.1 release candidate from the Discord, Spigot 1.13.2

Editing the socket-name in the socketting file stops the socket gems from working at all.

For example if I have it set to `&5Power Gem - &6%socketgem%` it works fine, however if I even change it just to`&5Power Gem &7- &6%socketgem%` the gems no longer do anything.

Ideally I'd like to be able to have custom symbols in it as well, such as having it as `&6✧ &5Power Gem &6✧ &7-- &d%socketgem%` due to having item drop names visible - the plugin parses the symbol fine and the item is given with the symbol, but as above due to the altered name it does nothing.

Changed files:
src/main/java/com/tealcube/minecraft/bukkit/mythicdrops/socketting/SockettingListener.java

diff --git a/src/main/java/com/tealcube/minecraft/bukkit/mythicdrops/socketting/SockettingListener.java b/src/main/java/com/tealcube/minecraft/bukkit/mythicdrops/socketting/SockettingListener.java
index 6c5b8e2a..2e1bad33 100644
--- a/src/main/java/com/tealcube/minecraft/bukkit/mythicdrops/socketting/SockettingListener.java
+++ b/src/main/java/com/tealcube/minecraft/bukkit/mythicdrops/socketting/SockettingListener.java
@@ -34,12 +34,6 @@ import com.tealcube.minecraft.bukkit.mythicdrops.utils.ItemUtil;
 import com.tealcube.minecraft.bukkit.mythicdrops.utils.SocketGemUtil;
 import com.tealcube.minecraft.bukkit.mythicdrops.utils.StringListUtil;
 import com.tealcube.minecraft.bukkit.mythicdrops.utils.TierUtil;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.logging.Logger;
 import org.bukkit.Bukkit;
 import org.bukkit.ChatColor;
 import org.bukkit.enchantments.Enchantment;
@@ -54,9 +48,13 @@ import org.bukkit.event.Listener;
 import org.bukkit.event.block.Action;
 import org.bukkit.event.entity.EntityDamageByEntityEvent;
 import org.bukkit.event.player.PlayerInteractEvent;
+import org.bukkit.inventory.EquipmentSlot;
 import org.bukkit.inventory.ItemStack;
 import org.bukkit.inventory.meta.ItemMeta;
 
+import java.util.*;
+import java.util.logging.Logger;
+
 public final class SockettingListener implements Listener {
 
   private static final Logger LOGGER = MythicLoggerFactory.getLogger(SockettingListener.class);
@@ -79,6 +77,10 @@ public final class SockettingListener implements Listener {
       LOGGER.fine("event.getAction() != RIGHT_CLICK_AIR && event.getAction() != RIGHT_CLICK_BLOCK");
       return;
     }
+    if (event.getHand() != EquipmentSlot.HAND) {
+      LOGGER.fine("event.getHand() != EquipmentSlot.HAND");
+      return;
+    }
     Player player = event.getPlayer();
     if (player.getEquipment() == null) {
       LOGGER.fine("player.getEquipment() == null");
@@ -99,10 +101,10 @@ public final class SockettingListener implements Listener {
       LOGGER.fine("heldSocket.containsKey(" + player.getName() + ")");
       socketItem(event, player, itemInMainHand, itemInMainHandType);
       heldSocket.remove(player.getName());
-    } else {
-      LOGGER.fine("!heldSocket.containsKey(" + player.getName() + ")");
-      addHeldSocket(event, player, itemInMainHand);
+      return;
     }
+    LOGGER.fine("!heldSocket.containsKey(" + player.getName() + ")");
+    addHeldSocket(event, player, itemInMainHand);
   }
 
   private void addHeldSocket(PlayerInteractEvent event, final Player player, ItemStack itemInHand) {
@@ -122,7 +124,8 @@ public final class SockettingListener implements Listener {
     String socketGemNameFormat = replaceArgs(mythicDrops.getSockettingSettings().getSocketGemName(), new String[][]{{"%socketgem%", ""}});
     String coloredSocketGemNameFormat = socketGemNameFormat.replace('&', '\\u00A7').replace("\\u00A7\\u00A7", "&");
     String strippedSocketGemNameFormat = ChatColor.stripColor(coloredSocketGemNameFormat);
-    String type = ChatColor.stripColor(im.getDisplayName().replace(strippedSocketGemNameFormat, ""));
+    String strippedImDisplayName = ChatColor.stripColor(im.getDisplayName());
+    String type = ChatColor.stripColor(strippedImDisplayName.replace(strippedSocketGemNameFormat, ""));
     if (type == null) {
       LOGGER.fine("type == null");
       return;
@@ -130,7 +133,6 @@ public final class SockettingListener implements Listener {
     String socketGemNameFormatWithType = replaceArgs(mythicDrops.getSockettingSettings().getSocketGemName(), new String[][]{{"%socketgem%", type}});
     String coloredSocketGemNameFormatWithType = socketGemNameFormatWithType.replace('&', '\\u00A7').replace("\\u00A7\\u00A7", "&");
     String strippedSocketGemNameFormatWithType = ChatColor.stripColor(coloredSocketGemNameFormatWithType);
-    String strippedImDisplayName = ChatColor.stripColor(im.getDisplayName());
     if (!strippedSocketGemNameFormatWithType.equals(strippedImDisplayName)) {
       LOGGER.fine("!strippedSocketGemNameFormatWithType.equals(strippedImDisplayName): " +
           "strippedSocketGemNameFormatWithType=\\"" + strippedSocketGemNameFormatWithType + "\\" " +