Skip to content

Commit

Permalink
removed header/footer anti-override entirely
Browse files Browse the repository at this point in the history
it was rather useless and very resource intensive
  • Loading branch information
NEZNAMY committed Apr 10, 2021
1 parent fcf5636 commit c9077e1
Show file tree
Hide file tree
Showing 10 changed files with 1 addition and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,6 @@ public void write(ChannelHandlerContext context, Object packet, ChannelPromise c
if (antiOverrideObjectives && nms.PacketPlayOutScoreboardObjective.isInstance(packet)) {
tab.getFeatureManager().onObjective(player, packet);
}
if (nms.PacketPlayOutPlayerListHeaderFooter.isInstance(packet) && antiOverrideHeaderFooter && tab.getFeatureManager().onHeaderFooter(player, packet)) {
return;
}
tab.getFeatureManager().onPacketSend(player, packet);
} catch (Throwable e){
tab.getErrorManager().printError("An error occurred when reading packets", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import me.neznamy.tab.shared.features.PipelineInjector;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.protocol.packet.Login;
import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter;
import net.md_5.bungee.protocol.packet.PlayerListItem;
import net.md_5.bungee.protocol.packet.ScoreboardDisplay;
import net.md_5.bungee.protocol.packet.ScoreboardObjective;
Expand Down Expand Up @@ -132,10 +131,6 @@ public void write(ChannelHandlerContext context, Object packet, ChannelPromise c
//TODO add support for serialized packets as above with teams
tab.getFeatureManager().onObjective(player, packet);
}
if (packet instanceof PlayerListHeaderFooter && antiOverrideHeaderFooter && tab.getFeatureManager().onHeaderFooter(player, packet)) {
//TODO add support for serialized packets as above with teams
return;
}
//client reset packet
if (packet instanceof Login) {
//making sure to not send own packets before login packet is actually sent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ public void write(ChannelHandlerContext context, Object packet, ChannelPromise c
case "ScoreboardObjective":
if (antiOverrideObjectives) tab.getFeatureManager().onObjective(player, packet);
break;
case "HeaderAndFooter":
//TODO add deserialization
if (antiOverrideHeaderFooter && tab.getFeatureManager().onHeaderFooter(player, packet)) return;
break;
default:
break;
}
Expand Down
23 changes: 0 additions & 23 deletions src/main/java/me/neznamy/tab/shared/FeatureManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@
import me.neznamy.tab.shared.features.types.event.SneakEventListener;
import me.neznamy.tab.shared.features.types.event.WorldChangeListener;
import me.neznamy.tab.shared.features.types.packet.DisplayObjectivePacketListener;
import me.neznamy.tab.shared.features.types.packet.HeaderFooterPacketListener;
import me.neznamy.tab.shared.features.types.packet.LoginPacketListener;
import me.neznamy.tab.shared.features.types.packet.ObjectivePacketListener;
import me.neznamy.tab.shared.features.types.packet.PlayerInfoPacketListener;
import me.neznamy.tab.shared.features.types.packet.RawPacketListener;
import me.neznamy.tab.shared.packets.PacketPlayOutPlayerInfo;
import me.neznamy.tab.shared.packets.PacketPlayOutPlayerListHeaderFooter;
import me.neznamy.tab.shared.packets.PacketPlayOutScoreboardDisplayObjective;
import me.neznamy.tab.shared.packets.PacketPlayOutScoreboardObjective;

Expand Down Expand Up @@ -364,27 +362,6 @@ public void onObjective(TabPlayer packetReceiver, Object packet) throws Exceptio
}
}

/**
* Calls onPacketSend on all featurs that implement HeaderFooterPacketListener and measures how long it took them to process
* @param packetReceiver - player who received the packet
* @param packet - the packet
* @return true if packet should be cancelled, false if not
* @throws Exception - if something fails
*/
public boolean onHeaderFooter(TabPlayer packetReceiver, Object packet) throws Exception {
long time = System.nanoTime();
PacketPlayOutPlayerListHeaderFooter display = tab.getPacketBuilder().readHeaderFooter(packet, packetReceiver.getVersion());
tab.getCPUManager().addTime(TabFeature.PACKET_DESERIALIZING, UsageType.PACKET_HEADER_FOOTER, System.nanoTime()-time);
for (Feature f : getAllFeatures()) {
if (!(f instanceof HeaderFooterPacketListener)) continue;
time = System.nanoTime();
boolean cancel = ((HeaderFooterPacketListener)f).onPacketSend(packetReceiver, display);
tab.getCPUManager().addTime(f.getFeatureType(), UsageType.ANTI_OVERRIDE, System.nanoTime()-time);
if (cancel) return true;
}
return false;
}

/**
* Calls onChat on all featurs that implement ChatEventListener and measures how long it took them to process
* @param sender - player who sent chat message
Expand Down
1 change: 0 additions & 1 deletion src/main/java/me/neznamy/tab/shared/cpu/UsageType.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public enum UsageType {
PACKET_LOGIN("PacketLogin"),
PACKET_DISPLAY_OBJECTIVE("PacketPlayOutScoreboardDisplayObjective"),
PACKET_OBJECTIVE("PacketPlayOutScoreboardObjective"),
PACKET_HEADER_FOOTER("PacketPlayOutPlayerListHeaderFooter"),

//nametags
REFRESHING_COLLISION("Refreshing collision rule"),
Expand Down
13 changes: 1 addition & 12 deletions src/main/java/me/neznamy/tab/shared/features/HeaderFooter.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
import me.neznamy.tab.shared.features.types.Refreshable;
import me.neznamy.tab.shared.features.types.event.JoinEventListener;
import me.neznamy.tab.shared.features.types.event.WorldChangeListener;
import me.neznamy.tab.shared.features.types.packet.HeaderFooterPacketListener;
import me.neznamy.tab.shared.packets.IChatBaseComponent;
import me.neznamy.tab.shared.packets.PacketPlayOutPlayerListHeaderFooter;

/**
* Feature handler for header and footer
*/
public class HeaderFooter implements Loadable, JoinEventListener, WorldChangeListener, Refreshable, HeaderFooterPacketListener {
public class HeaderFooter implements Loadable, JoinEventListener, WorldChangeListener, Refreshable {

private TAB tab;
private List<String> usedPlaceholders;
Expand Down Expand Up @@ -112,14 +111,4 @@ public void refreshUsedPlaceholders() {
public TabFeature getFeatureType() {
return TabFeature.HEADER_FOOTER;
}

@Override
public boolean onPacketSend(TabPlayer packetReciver, PacketPlayOutPlayerListHeaderFooter packet) {
if (!isDisabledWorld(disabledWorlds, packetReciver.getWorldName()) && packet.header.getText() != null &&
!packet.header.getText().startsWith("\u00a70\u00a71\u00a72\u00a7r")) {
tab.getErrorManager().printError("Some plugin just tried to send header " + packet.header.toString() + " and footer " + packet.footer.toString(), null, false, tab.getErrorManager().antiOverrideLog);
return true;
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public abstract class PipelineInjector implements JoinEventListener, Loadable {
//anti-override rules
protected boolean antiOverrideTeams;
protected boolean antiOverrideObjectives;
protected boolean antiOverrideHeaderFooter;

/**
* Constructs new instance
Expand All @@ -40,7 +39,6 @@ public PipelineInjector(TAB tab) {
this.tab = tab;
antiOverrideTeams = tab.getConfiguration().config.getBoolean("anti-override.scoreboard-teams", true);
antiOverrideObjectives = tab.getConfiguration().config.getBoolean("anti-override.scoreboard-objectives", true);
antiOverrideHeaderFooter = tab.getConfiguration().config.getBoolean("anti-override.header-footer", true);
}

/**
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/bukkitconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ anti-override:
scoreboard-teams: true
scoreboard-objectives: true
tablist-names: true
header-footer: false
usernames: true

#permanently invisible nametags
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/bungeeconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ anti-override:
scoreboard-teams: true
scoreboard-objectives: true
tablist-names: true
header-footer: false
usernames: true

#permanently invisible nametags
Expand Down

0 comments on commit c9077e1

Please sign in to comment.