mirror of
https://github.com/NEZNAMY/TAB.git
synced 2026-11-26 10:29:49 -05:00
no longer refreshing when plugin message is received, prevents unwanted cpu leak
This commit is contained in:
1 parent
41af32e159
commit
5572ab7bb2
5 files changed
+7
-41
No files matched your search
@@ -100,13 +100,7 @@ public class BungeeMethods implements PlatformMethods {
|
||||
Placeholders.registerPlaceholder(new PlayerPlaceholder(identifier, cooldown){
|
||||
public String get(ITabPlayer p) {
|
||||
Main.plm.requestPlaceholder(p, identifier);
|
||||
String name;
|
||||
if (p == null) {
|
||||
name = "null";
|
||||
} else {
|
||||
name = p.getName();
|
||||
}
|
||||
return lastValue.get(name);
|
||||
return getLastValue(p);
|
||||
}
|
||||
}, true);
|
||||
return;
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
package me.neznamy.tab.platforms.bungee;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
import me.neznamy.tab.shared.ITabPlayer;
|
||||
import me.neznamy.tab.shared.Shared;
|
||||
import me.neznamy.tab.shared.cpu.UsageType;
|
||||
import me.neznamy.tab.shared.features.PlaceholderManager;
|
||||
import me.neznamy.tab.shared.features.interfaces.Refreshable;
|
||||
import me.neznamy.tab.shared.placeholders.Placeholders;
|
||||
import me.neznamy.tab.shared.placeholders.PlayerPlaceholder;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
@@ -57,13 +52,6 @@ public class PluginMessenger implements Listener {
|
||||
PlayerPlaceholder pl = (PlayerPlaceholder) Placeholders.getPlaceholder(placeholder); //all bridge placeholders are marked as player
|
||||
if (pl != null) {
|
||||
pl.lastValue.put(receiver.getName(), output);
|
||||
pl.lastValue.put("null", output);
|
||||
Set<Refreshable> update = PlaceholderManager.getPlaceholderUsage(pl.getIdentifier());
|
||||
for (Refreshable r : update) {
|
||||
long startTime = System.nanoTime();
|
||||
r.refresh(receiver, false);
|
||||
Shared.cpu.addTime(r.getFeatureType(), UsageType.REFRESHING, System.nanoTime()-startTime);
|
||||
}
|
||||
Shared.cpu.addBridgePlaceholderTime(pl.getIdentifier(), cpu);
|
||||
} else {
|
||||
Shared.debug("Received output for unknown placeholder " + placeholder);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package me.neznamy.tab.platforms.velocity;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
@@ -13,9 +11,6 @@ import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
|
||||
import me.neznamy.tab.shared.ITabPlayer;
|
||||
import me.neznamy.tab.shared.Shared;
|
||||
import me.neznamy.tab.shared.cpu.UsageType;
|
||||
import me.neznamy.tab.shared.features.PlaceholderManager;
|
||||
import me.neznamy.tab.shared.features.interfaces.Refreshable;
|
||||
import me.neznamy.tab.shared.placeholders.Placeholders;
|
||||
import me.neznamy.tab.shared.placeholders.PlayerPlaceholder;
|
||||
|
||||
@@ -69,13 +64,6 @@ public class PluginMessenger{
|
||||
PlayerPlaceholder pl = (PlayerPlaceholder) Placeholders.getPlaceholder(placeholder); //all bridge placeholders are marked as player
|
||||
if (pl != null) {
|
||||
pl.lastValue.put(receiver.getName(), output);
|
||||
pl.lastValue.put("null", output);
|
||||
Set<Refreshable> update = PlaceholderManager.getPlaceholderUsage(pl.getIdentifier());
|
||||
for (Refreshable r : update) {
|
||||
long startTime = System.nanoTime();
|
||||
r.refresh(receiver, false);
|
||||
Shared.cpu.addTime(r.getFeatureType(), UsageType.REFRESHING, System.nanoTime()-startTime);
|
||||
}
|
||||
Shared.cpu.addBridgePlaceholderTime(pl.getIdentifier(), cpu);
|
||||
} else {
|
||||
Shared.debug("Received output for unknown placeholder " + placeholder);
|
||||
|
||||
@@ -94,13 +94,7 @@ public class VelocityMethods implements PlatformMethods {
|
||||
Placeholders.registerPlaceholder(new PlayerPlaceholder(identifier, cooldown){
|
||||
public String get(ITabPlayer p) {
|
||||
Main.plm.requestPlaceholder(p, identifier);
|
||||
String name;
|
||||
if (p == null) {
|
||||
name = "null";
|
||||
} else {
|
||||
name = p.getName();
|
||||
}
|
||||
return lastValue.get(name);
|
||||
return getLastValue(p);
|
||||
}
|
||||
}, true);
|
||||
return;
|
||||
|
||||
@@ -16,18 +16,20 @@ public abstract class PlayerPlaceholder extends Placeholder {
|
||||
super(identifier, cooldown);
|
||||
}
|
||||
public boolean update(ITabPlayer p) {
|
||||
String name = (p == null ? "null" : p.getName());
|
||||
String newValue = get(p);
|
||||
if (newValue == null) newValue = "";
|
||||
if (!newValue.equals("ERROR") && (!lastValue.containsKey(p.getName()) || !lastValue.get(p.getName()).equals(newValue))) {
|
||||
lastValue.put(name, newValue);
|
||||
lastValue.put(p.getName(), newValue);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public String getLastValue(ITabPlayer p) {
|
||||
if (p == null) return identifier;
|
||||
if (!lastValue.containsKey(p.getName())) update(p);
|
||||
if (!lastValue.containsKey(p.getName())) {
|
||||
lastValue.put(p.getName(), ""); //preventing stack overflow on bungee when initializing
|
||||
update(p);
|
||||
}
|
||||
return lastValue.get(p.getName());
|
||||
}
|
||||
public abstract String get(ITabPlayer p);
|
||||
|
||||
Reference in new issue
Block a user