mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-29 16:46:46 +01:00
Remove reflection
This commit is contained in:
parent
1edc12af3b
commit
bada2f5d0d
@ -2,31 +2,22 @@ package com.gmail.nossr50;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.gmail.nossr50.config.mods.ArmorConfigManager;
|
||||
import com.gmail.nossr50.config.mods.BlockConfigManager;
|
||||
import com.gmail.nossr50.config.mods.EntityConfigManager;
|
||||
import com.gmail.nossr50.config.mods.ToolConfigManager;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.util.ModManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventException;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.plugin.EventExecutor;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.HiddenConfig;
|
||||
import com.gmail.nossr50.config.mods.ArmorConfigManager;
|
||||
import com.gmail.nossr50.config.mods.BlockConfigManager;
|
||||
import com.gmail.nossr50.config.mods.EntityConfigManager;
|
||||
import com.gmail.nossr50.config.mods.ToolConfigManager;
|
||||
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
|
||||
import com.gmail.nossr50.config.skills.repair.RepairConfigManager;
|
||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||
@ -37,6 +28,7 @@ import com.gmail.nossr50.listeners.EntityListener;
|
||||
import com.gmail.nossr50.listeners.InventoryListener;
|
||||
import com.gmail.nossr50.listeners.PlayerListener;
|
||||
import com.gmail.nossr50.listeners.SelfListener;
|
||||
import com.gmail.nossr50.listeners.TagListener;
|
||||
import com.gmail.nossr50.listeners.WorldListener;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.metrics.MetricsManager;
|
||||
@ -56,6 +48,7 @@ import com.gmail.nossr50.util.ChimaeraWing;
|
||||
import com.gmail.nossr50.util.HolidayManager;
|
||||
import com.gmail.nossr50.util.LogFilter;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
|
||||
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
|
||||
@ -457,49 +450,7 @@ public class mcMMO extends JavaPlugin {
|
||||
pluginManager.registerEvents(new WorldListener(this), this);
|
||||
|
||||
if (tagapiPluginEnabled) {
|
||||
try {
|
||||
final Class cls = Class.forName("org.kitteh.tag.AsyncPlayerReceiveNameTagEvent");
|
||||
|
||||
pluginManager.registerEvent(cls, new Listener() {}, EventPriority.MONITOR, new EventExecutor() {
|
||||
@Override
|
||||
public void execute(Listener listener, Event event) throws EventException {
|
||||
Object tagEvent = cls.cast(event);
|
||||
|
||||
try {
|
||||
Method method = cls.getDeclaredMethod("getNamedPlayer", new Class[0]);
|
||||
Player player = (Player) method.invoke(tagEvent, null);
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player, true);
|
||||
|
||||
if (mcMMOPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
method = cls.getDeclaredMethod("getTag", new Class[0]);
|
||||
String tag = (String) method.invoke(tagEvent, null);
|
||||
String colorlessTag = ChatColor.stripColor(tag);
|
||||
|
||||
if (colorlessTag.equals(tag)) {
|
||||
mcMMOPlayer.setNameTag(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (colorlessTag.equals(player.getName()) && (mcMMOPlayer.getNameTag() == null || !mcMMOPlayer.getNameTag().equals(tag))) {
|
||||
mcMMOPlayer.setNameTag(tag);
|
||||
ScoreboardManager.tagUpdate(player);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
// If it passed the first check, it *shouldn't* throw another error here, but print it just to be safe.
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, this, true);
|
||||
}
|
||||
catch (Exception e) {
|
||||
// If it passed the first check, it *shouldn't* throw another error here, but print it just to be safe.
|
||||
e.printStackTrace();
|
||||
}
|
||||
pluginManager.registerEvents(new TagListener(), this);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user