Skip to content

Commit

Permalink
added support for TAB 2.8.11-pre9
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanguygab committed Mar 29, 2021
1 parent c70de4b commit db5a4e1
Show file tree
Hide file tree
Showing 15 changed files with 82 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import me.neznamy.tab.shared.Property;
import me.neznamy.tab.shared.TAB;
import me.neznamy.tab.shared.config.YamlConfigurationFile;
import me.neznamy.tab.shared.cpu.TabFeature;
import me.neznamy.tab.shared.features.PlaceholderManager;
import me.neznamy.tab.shared.features.types.Loadable;
import me.neznamy.tab.shared.placeholders.Placeholder;
import me.neznamy.tab.shared.placeholders.conditions.Condition;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -117,7 +117,7 @@ public void loadFiles() {
nametagInRange = config.getInt("features.nametag-in-range", 0);
tablistNamesRadius = config.getInt("features.tablist-names-radius", 0);
onlyyou = config.getBoolean("features.only-you",false);
if (config.hasConfigOption("features.unlimited-item-lines") && Bukkit.getServer().getVersion().contains("1.16.5"))
if (config.hasConfigOption("features.unlimited-item-lines") && Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3].equals("v1_16_R3"))
unlimitedItemLines = config.getBoolean("features.unlimited-item-lines");

}
Expand All @@ -140,47 +140,11 @@ public void reload() {
public void disable() {
FeatureManager fm = TAB.getInstance().getFeatureManager();

//ActionBar
fm.getFeature("ActionBar");

//Title
fm.unregisterFeature("Title");

//Chat
if (fm.isFeatureEnabled("Chat"))
((ChatManager)fm.getFeature("Chat")).unload();
fm.unregisterFeature("Chat");

//Layout
if (fm.isFeatureEnabled("TAB+ Layout"))
((LayoutManager)fm.getFeature("TAB+ Layout")).unload();
fm.unregisterFeature("TAB+ Layout");
//RFP
if (fm.isFeatureEnabled("Real Fake Players"))
((RFPManager)fm.getFeature("Real Fake Players")).unload();
fm.unregisterFeature("Real Fake Players");

//Sneak Hide Nametag
fm.unregisterFeature("Sneak Hide Nametag");

//Nametag in Range
if (fm.isFeatureEnabled("Nametag in Range"))
((NametagInRange)fm.getFeature("Nametag in Range")).unload();
fm.unregisterFeature("Nametag in Range");

//Tablist Names Radius
if (fm.isFeatureEnabled("Tablist Names Radius"))
((TablistNamesRadius)fm.getFeature("Tablist Names Radius")).unload();
fm.unregisterFeature("Tablist Names Radius");

//Only You
if (fm.isFeatureEnabled("Only You"))
((OnlyYou)fm.getFeature("Only You")).unload();
fm.unregisterFeature("Only You");

//Unlimited Item Lines
if (unlimitedItemLines)
fm.unregisterFeature("Unlimited Item Lines");
for (TAFeature feature : TAFeature.values()) {
if (fm.isFeatureEnabled(feature.toString()) && fm.getFeature(feature.toString()) instanceof Loadable)
((Loadable) fm.getFeature(feature.toString())).unload();
fm.unregisterFeature(feature.toString());
}

enabled = false;
TAB.getInstance().unload();
Expand All @@ -200,34 +164,34 @@ private void loadFeatures() {
FeatureManager fm = TAB.getInstance().getFeatureManager();
//ActionBar
if (actionbarsEnabled)
fm.registerFeature("ActionBar", new ActionBar(TabFeature.ADDON_FEATURE_1));
fm.registerFeature(TAFeature.ACTIONBAR.toString(), new ActionBar());
//Title
if (titlesEnabled)
fm.registerFeature("Title", new Title(TabFeature.ADDON_FEATURE_2));
fm.registerFeature(TAFeature.TITLE.toString(), new Title());
//Chat
if (chatEnabled)
fm.registerFeature("Chat", new ChatManager(TabFeature.ADDON_FEATURE_3));
fm.registerFeature(TAFeature.CHAT.toString(), new ChatManager());
//Layout
if (layoutEnabled && TAB.getInstance().isPremium())
fm.registerFeature("TAB+ Layout",new LayoutManager(TabFeature.ADDON_FEATURE_4));
fm.registerFeature(TAFeature.TA_LAYOUT.toString(), new LayoutManager());
//RFP
if (rfpEnabled)
fm.registerFeature("Real Fake Players",new RFPManager(TabFeature.ADDON_FEATURE_5));
fm.registerFeature(TAFeature.RFP.toString(), new RFPManager());
//Sneak Hide Nametag
if (sneakhideEnabled)
fm.registerFeature("Sneak Hide Nametag", new SneakHideNametag(TabFeature.ADDON_FEATURE_6));
fm.registerFeature(TAFeature.SNEAK_HIDE_NAMETAG.toString(), new SneakHideNametag());
//Nametag in Range
if (nametagInRange != 0)
fm.registerFeature("Nametag in Range",new NametagInRange(TabFeature.ADDON_FEATURE_7));
fm.registerFeature(TAFeature.NAMETAG_IN_RANGE.toString(), new NametagInRange());
//Tablist Names Radius
if (tablistNamesRadius != 0)
fm.registerFeature("Tablist Names Radius",new TablistNamesRadius(TabFeature.ADDON_FEATURE_8));
fm.registerFeature(TAFeature.TABLIST_NAMES_RADIUS.toString(), new TablistNamesRadius());
//Only You
if (onlyyou)
fm.registerFeature("Only You",new OnlyYou(TabFeature.ADDON_FEATURE_9));
fm.registerFeature(TAFeature.ONLY_YOU.toString(), new OnlyYou());
//Unlimited Item Lines
if (TAB.getInstance().getFeatureManager().isFeatureEnabled("nametagx") && unlimitedItemLines)
fm.registerFeature("Unlimited Item Lines",new UnlimitedItemLines(TabFeature.ADDON_FEATURE_10));
fm.registerFeature(TAFeature.UNLIMITED_ITEM_LINES.toString(), new UnlimitedItemLines());
}

private void loadPlaceholders() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ else if (!name.equals("~Console~"))
}
title = instance.parsePlaceholders(title,p);
subtitle = instance.parsePlaceholders(subtitle,p);
p.sendCustomPacket(PacketPlayOutTitle.TITLE(title));
p.sendCustomPacket(PacketPlayOutTitle.SUBTITLE(subtitle));
p.sendCustomPacket(PacketPlayOutTitle.TIMES(fadeIn,stay,fadeOut));
p.sendCustomPacket(PacketPlayOutTitle.title(title));
p.sendCustomPacket(PacketPlayOutTitle.subtitle(subtitle));
p.sendCustomPacket(PacketPlayOutTitle.times(fadeIn,stay,fadeOut));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@

public class ActionBar implements JoinEventListener {

private final TabFeature feature;

public ActionBar(TabFeature feature) {
feature.setDisplayName("&aActionBar");
this.feature = feature;

}

@Override
public void onJoin(TabPlayer p) {
p.loadPropertyFromConfig("actionbar");
Expand All @@ -39,7 +31,7 @@ public List<String> getLists() {
}

@Override
public TabFeature getFeatureType() {
return feature;
public Object getFeatureType() {
return TAFeature.ACTIONBAR;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,15 @@
import io.github.tanguygab.tabadditions.shared.TABAdditions;
import me.neznamy.tab.api.TabPlayer;
import me.neznamy.tab.shared.TAB;
import me.neznamy.tab.shared.cpu.TabFeature;
import me.neznamy.tab.shared.cpu.UsageType;
import me.neznamy.tab.shared.features.types.Loadable;
import me.neznamy.tab.shared.features.types.event.JoinEventListener;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;

public class NametagInRange implements Loadable, JoinEventListener {

private final TabFeature feature;

public NametagInRange(TabFeature feature) {
feature.setDisplayName("&aNametag in Range");
this.feature = feature;
public NametagInRange() {
for (TabPlayer p : TAB.getInstance().getPlayers()) {
for (TabPlayer p2 : TAB.getInstance().getPlayers()) {
if (p != p2)
Expand All @@ -37,7 +31,7 @@ public void onJoin(TabPlayer p) {

@Override
public void load() {
TAB.getInstance().getCPUManager().startRepeatingMeasuredTask(500,"handling Nametag In Range", feature, UsageType.REPEATING_TASK,()->{
TAB.getInstance().getCPUManager().startRepeatingMeasuredTask(500,"handling Nametag In Range", TAFeature.NAMETAG_IN_RANGE, UsageType.REPEATING_TASK,()->{
int zone = (int) Math.pow(TABAdditions.getInstance().nametagInRange, 2);
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
Expand Down Expand Up @@ -65,7 +59,7 @@ public void unload() {
}

@Override
public TabFeature getFeatureType() {
return feature;
public Object getFeatureType() {
return TAFeature.NAMETAG_IN_RANGE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@

public class OnlyYou implements JoinEventListener, Loadable {

private final TabFeature feature;
private final Plugin plugin;

public OnlyYou(TabFeature feature) {
feature.setDisplayName("&aOnly You");
this.feature = feature;
public OnlyYou() {
plugin = (Plugin) TABAdditions.getInstance().getPlugin();
load();
}
Expand Down Expand Up @@ -54,7 +51,7 @@ public void onJoin(TabPlayer tabPlayer) {
}

@Override
public TabFeature getFeatureType() {
return feature;
public Object getFeatureType() {
return TAFeature.ONLY_YOU;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,8 @@

public class SneakHideNametag implements SneakEventListener {

private final TabFeature feature;

private final Map<TabPlayer, Boolean> tag = new HashMap<>();

public SneakHideNametag(TabFeature feature) {
feature.setDisplayName("&aSneak Hide Nametag");
this.feature = feature;
}

@Override
public void onSneak(TabPlayer p, boolean isSneaking) {
if (TABAdditions.getInstance().sneakhideEnabled) {
Expand All @@ -31,7 +24,7 @@ public void onSneak(TabPlayer p, boolean isSneaking) {
}

@Override
public TabFeature getFeatureType() {
return feature;
public Object getFeatureType() {
return TAFeature.SNEAK_HIDE_NAMETAG;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.github.tanguygab.tabadditions.shared.features;

public enum TAFeature {

ACTIONBAR("ActionBar&r"),
TITLE("Title"),
CHAT("Chat"),
TA_LAYOUT("TAB+ Layout"),
RFP("Real Fake Players"),
SNEAK_HIDE_NAMETAG("Sneak Hide Nametag"),
NAMETAG_IN_RANGE("Nametag in Range"),
TABLIST_NAMES_RADIUS("Tablist Names Radius"),
ONLY_YOU("Only You"),
UNLIMITED_ITEM_LINES("Unlimited Item Lines");

private final String displayName;

TAFeature(String displayName){
this.displayName = displayName;
}

@Override
public String toString() {
return "&a"+displayName+"&r";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@

public class TablistNamesRadius implements Loadable, JoinEventListener {

private final TabFeature feature;
private final Plugin plugin;
private int task = -1;
private boolean enabled = true;

public TablistNamesRadius(TabFeature feature) {
feature.setDisplayName("Tablist Names Radius");
this.feature = feature;
public TablistNamesRadius() {
plugin = (Plugin) TABAdditions.getInstance().getPlugin();
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
for (Player p2 : Bukkit.getServer().getOnlinePlayers()) {
Expand Down Expand Up @@ -73,7 +70,7 @@ public void onJoin(TabPlayer tabPlayer) {
}

@Override
public TabFeature getFeatureType() {
return feature;
public Object getFeatureType() {
return TAFeature.TABLIST_NAMES_RADIUS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@

public class Title implements JoinEventListener {

private final TabFeature feature;

public Title(TabFeature feature) {
feature.setDisplayName("&aTitle");
this.feature = feature;
}

@Override
public void onJoin(TabPlayer p) {
p.loadPropertyFromConfig("title");
Expand All @@ -40,7 +33,7 @@ public List<String> getLists() {
}

@Override
public TabFeature getFeatureType() {
return feature;
public Object getFeatureType() {
return TAFeature.TITLE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,17 @@
import me.neznamy.tab.api.TabPlayer;
import me.neznamy.tab.shared.Property;
import me.neznamy.tab.shared.TAB;
import me.neznamy.tab.shared.cpu.TabFeature;
import me.neznamy.tab.shared.features.types.Loadable;
import me.neznamy.tab.shared.features.types.event.JoinEventListener;
import me.neznamy.tab.shared.features.types.event.WorldChangeListener;
import org.bukkit.Material;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

public class UnlimitedItemLines implements Loadable,WorldChangeListener, JoinEventListener {

private final TabFeature feature;

public UnlimitedItemLines(TabFeature feature) {
feature.setDisplayName("&aUnlimited Item Lines");
this.feature = feature;
public UnlimitedItemLines() {
load();
}

Expand Down Expand Up @@ -80,7 +74,7 @@ public BukkitItemLine createItemLine(TabPlayer p, ArmorStand as) {
}

@Override
public TabFeature getFeatureType() {
return feature;
public Object getFeatureType() {
return TAFeature.UNLIMITED_ITEM_LINES;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import io.github.tanguygab.tabadditions.shared.TABAdditions;
import me.neznamy.tab.api.TabPlayer;
import me.neznamy.tab.shared.TAB;
import me.neznamy.tab.shared.packets.IChatBaseComponent;
import me.neznamy.tab.shared.placeholders.conditions.Condition;
import java.util.ArrayList;
Expand Down
Loading

0 comments on commit db5a4e1

Please sign in to comment.