Skip to content

Commit

Permalink
adjusted things, made RFP use less CPU, 1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanguygab committed Feb 22, 2021
1 parent 5e6dc76 commit 849499f
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 30 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.apache.tools.ant.filters.ReplaceTokens
apply plugin: 'java'

group = 'io.github.tanguygab'
version = '1.4.4'
version = '1.5.0'

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class TABAdditions {
private final Platform platform;
private final File dataFolder;
private final Skins skins;
private final Map<String,Integer> tasks = new HashMap<>();

private YamlConfigurationFile config;
private YamlConfigurationFile layoutConfig;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.tanguygab.tabadditions.shared.commands;

import io.github.tanguygab.tabadditions.shared.Skins;
import io.github.tanguygab.tabadditions.shared.TABAdditions;
import io.github.tanguygab.tabadditions.shared.features.rfps.RFP;
import io.github.tanguygab.tabadditions.shared.features.rfps.RFPManager;
Expand Down Expand Up @@ -68,8 +69,12 @@ else if (args[1].equalsIgnoreCase("edit")) {
if (prop.equalsIgnoreCase("suffix"))
output = rfpm.getRFP(name).setSuffix(value);

for (TabPlayer p : TAB.getInstance().getPlayers())
rfpm.getRFP(name).forceUpdate(p,null);
for (TabPlayer p : TAB.getInstance().getPlayers()) {
Object skin = null;
if (prop.equalsIgnoreCase("skin"))
skin = Skins.getInstance().getIcon(value,p);
rfpm.getRFP(name).forceUpdate(p,skin);
}
}

instance.sendMessage(nameS,output);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public ActionBar(TabFeature feature) {
@Override
public void onJoin(TabPlayer p) {
p.loadPropertyFromConfig("actionbar");
String actionbar = TABAdditions.getInstance().getConfig(ConfigType.ACTIONBAR).getString("bars." + p.getProperty("actionbar").get(),"");
String prop = p.getProperty("actionbar").updateAndGet();
if (prop.equals("")) return;
String actionbar = TABAdditions.getInstance().getConfig(ConfigType.ACTIONBAR).getString("bars." + prop,"");
if (actionbar.equals("")) return;
actionbar = TABAdditions.getInstance().parsePlaceholders(actionbar,p);
p.sendCustomPacket(new PacketPlayOutChat(actionbar, PacketPlayOutChat.ChatMessageType.GAME_INFO));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import io.github.tanguygab.tabadditions.shared.TABAdditions;
import me.neznamy.tab.api.TabPlayer;
import me.neznamy.tab.shared.cpu.TabFeature;
import me.neznamy.tab.shared.features.types.Feature;
import me.neznamy.tab.shared.features.types.event.SneakEventListener;

import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public ChatFormat defFormat() {
Map<String,Object> components = new HashMap<>();
Map<String,Object> text = new HashMap<>();

text.put("text","%tab_chatprefix% %tab_customchatname% %tab_chatsuffix%&7» &r%msg%");
text.put("text","%tab_chatprefix% %tab_customchatname% %tab_chatsuffix%&7\u00bb &r%msg%");
components.put("text",text);
map.put("components",components);
return new ChatFormat("default", map);
Expand Down Expand Up @@ -146,7 +146,6 @@ public boolean onChat(TabPlayer p, String msg) {
}
format2.setExtra(list);

TAB.getInstance().getPlatform().sendConsoleMessage(format2+"", true);
TAB.getInstance().getPlatform().sendConsoleMessage(format2.toLegacyText(), true);
for (TabPlayer pl : TAB.getInstance().getPlayers())
pl.sendMessage(format2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public String getLayout(TabPlayer p) {
}

private void refresh() {
TAB.getInstance().getCPUManager().startRepeatingMeasuredTask(500,"handling TAB+ Layout",feature, UsageType.REPEATING_TASK,()->{
TAB.getInstance().getCPUManager().startRepeatingMeasuredTask(100,"handling TAB+ Layout",feature, UsageType.REPEATING_TASK,()->{
for (TabPlayer p : TAB.getInstance().getPlayers()) {
if (!TABAdditions.getInstance().checkBedrock(p) && players.containsKey(p) && !players.get(p).equals(getLayout(p))) {
toRemove.put(p, players.get(p));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
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.cpu.UsageType;
import me.neznamy.tab.shared.features.types.Loadable;
import me.neznamy.tab.shared.features.types.Refreshable;
import me.neznamy.tab.shared.features.types.event.JoinEventListener;
Expand All @@ -20,7 +21,6 @@ public class RFPManager implements JoinEventListener, Loadable {
private final TabFeature feature;
private final Map<String, RFP> rfps = new HashMap<>();
private final Map<TabPlayer,Map<RFP, Object>> skins = new HashMap<>();
private boolean refresh;

public RFPManager(TabFeature feature) {
feature.setDisplayName("&aReal Fake Players");
Expand Down Expand Up @@ -116,33 +116,33 @@ public void load() {
Map<String,Object> config = TABAdditions.getInstance().getConfig(ConfigType.MAIN).getConfigurationSection("fakeplayers");
for (Object rfp : config.keySet())
rfps.put(rfp+"",new RFP(rfp+"", (Map<String, Object>) config.get(rfp+"")));
refresh = TABAdditions.getInstance().getConfig(ConfigType.MAIN).getBoolean("real-fake-players-have-skins",true);
showRFPAll();
refresh();
}

@Override
public void unload() {
removeRFPAll();
refresh = false;
}

public void refresh() {
for (TabPlayer p : TAB.getInstance().getPlayers()) {
List<RFP> rfps = new ArrayList<>(this.rfps.values());
if (!skins.containsKey(p))
skins.put(p, new HashMap<>());

for (RFP rfp : rfps) {
Object skin = TABAdditions.getInstance().getSkins().getIcon(rfp.skin, p);
if (skin != null && skins.get(p).get(rfp) != skin) {
if (!refresh)
return;
if (p != null)
rfp.forceUpdate(p,skin);
TAB.getInstance().getCPUManager().runTask("refreshing RFPs skins for"+p.getName(),()->{
List<RFP> rfps = new ArrayList<>(this.rfps.values());
if (!skins.containsKey(p))
skins.put(p, new HashMap<>());

for (RFP rfp : rfps) {
TAB.getInstance().getCPUManager().runTask("refreshing RFP ("+rfp.getConfigName()+") skin for "+p.getName(),()->{
Object skin = TABAdditions.getInstance().getSkins().getIcon(rfp.skin, p);
if (skin != null && skins.get(p).get(rfp) != skin) {
if (p != null)
rfp.forceUpdate(p,skin);
}
skins.get(p).put(rfp, skin);
});
}
skins.get(p).put(rfp, skin);
}
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/bungee.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: TAB-Additions
version: 1.4.4
version: 1.5.0
main: io.github.tanguygab.tabadditions.bungee.TABAdditionsBungeeCord
description: More features for the plugin TAB !
softdepends: [floodgate-bungee]
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/chat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ chat-formats:
condition: 'true'
components:
prefix:
text: "%tab_chatprefix% "
text: "%prop-chatprefix% "
hover:
- "Prefix hover"
name:
text: "%tab_customchatname%"
text: "%prop-customchatname%"
hover:
- "&cHP: %player_health%"
- "&aMode: #00FF00%player_gamemode%"
suggest: "/msg %player_name% "
suffix:
text: " %tab_chatsuffix%"
text: " %prop-chatsuffix%"
hover:
- "Suffix hover"
msg:
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: TAB-Additions
version: 1.4.4
version: 1.5.0
main: io.github.tanguygab.tabadditions.spigot.TABAdditionsSpigot
api-version: 1.13
depend: [TAB]
Expand Down

0 comments on commit 849499f

Please sign in to comment.