mirror of
https://github.com/Xiao-MoMi/Custom-Nameplates.git
synced 2025-12-19 15:09:23 +00:00
fix bugs
This commit is contained in:
@@ -217,7 +217,7 @@ public abstract class ConfigManager implements ConfigLoader, Reloadable {
|
|||||||
// Other settings
|
// Other settings
|
||||||
delaySend = config.getInt("other-settings.send-delay", 0);
|
delaySend = config.getInt("other-settings.send-delay", 0);
|
||||||
defaultPlaceholderRefreshInterval = config.getInt("other-settings.default-placeholder-refresh-interval", 1);
|
defaultPlaceholderRefreshInterval = config.getInt("other-settings.default-placeholder-refresh-interval", 1);
|
||||||
defaultConditionRefreshInterval = config.getInt("other-settings.ddefault-condition-refresh-interval", 1);
|
defaultConditionRefreshInterval = config.getInt("other-settings.default-condition-refresh-interval", 20);
|
||||||
catchOtherActionBar = config.getBoolean("other-settings.catch-other-plugin-actionbar", true);
|
catchOtherActionBar = config.getBoolean("other-settings.catch-other-plugin-actionbar", true);
|
||||||
otherActionBarStayTime = config.getInt("other-settings.other-actionbar-stay-time", 3000);
|
otherActionBarStayTime = config.getInt("other-settings.other-actionbar-stay-time", 3000);
|
||||||
displaySystemChat = config.getBoolean("other-settings.display-system-actionbar", true);
|
displaySystemChat = config.getBoolean("other-settings.display-system-actionbar", true);
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ public abstract class AbstractTag implements Tag {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void show(CNPlayer viewer) {
|
public void show(CNPlayer viewer) {
|
||||||
|
if (!renderer.isValid()) return;
|
||||||
if (!isShown()) throw new IllegalStateException("This tag is currently hidden");
|
if (!isShown()) throw new IllegalStateException("This tag is currently hidden");
|
||||||
viewers.add(viewer);
|
viewers.add(viewer);
|
||||||
resetViewerArray();
|
resetViewerArray();
|
||||||
|
|||||||
@@ -35,6 +35,13 @@ public interface TagRenderer {
|
|||||||
*/
|
*/
|
||||||
void hatOffset(double hatOffset);
|
void hatOffset(double hatOffset);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the tag is valid
|
||||||
|
*
|
||||||
|
* @return valid or not
|
||||||
|
*/
|
||||||
|
boolean isValid();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called every tick to update the state of the tags managed by this renderer.
|
* Called every tick to update the state of the tags managed by this renderer.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ public class TagRendererImpl implements TagRenderer {
|
|||||||
private Tag[] tagArray;
|
private Tag[] tagArray;
|
||||||
private Tag[] rTagsArray;
|
private Tag[] rTagsArray;
|
||||||
private double hatOffset;
|
private double hatOffset;
|
||||||
|
private boolean valid = true;
|
||||||
|
|
||||||
public TagRendererImpl(UnlimitedTagManager manager, CNPlayer owner) {
|
public TagRendererImpl(UnlimitedTagManager manager, CNPlayer owner) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
@@ -68,6 +69,11 @@ public class TagRendererImpl implements TagRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid() {
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTick() {
|
public void onTick() {
|
||||||
Set<CNPlayer> playersToUpdatePassengers = new ObjectOpenHashSet<>();
|
Set<CNPlayer> playersToUpdatePassengers = new ObjectOpenHashSet<>();
|
||||||
@@ -135,6 +141,7 @@ public class TagRendererImpl implements TagRenderer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
|
this.valid = false;
|
||||||
for (Tag tag : this.tagArray) {
|
for (Tag tag : this.tagArray) {
|
||||||
tag.hide();
|
tag.hide();
|
||||||
if (tag instanceof Feature feature) {
|
if (tag instanceof Feature feature) {
|
||||||
|
|||||||
@@ -142,7 +142,6 @@ public class UnlimitedTagManagerImpl implements UnlimitedTagManager, JoinQuitLis
|
|||||||
public void onPlayerJoin(CNPlayer player) {
|
public void onPlayerJoin(CNPlayer player) {
|
||||||
plugin.debug(() -> player.name() + " joined the server");
|
plugin.debug(() -> player.name() + " joined the server");
|
||||||
TagRendererImpl sender = new TagRendererImpl(this, player);
|
TagRendererImpl sender = new TagRendererImpl(this, player);
|
||||||
sender.onTick();
|
|
||||||
TagRendererImpl previous = tagRenderers.put(player.uuid(), sender);
|
TagRendererImpl previous = tagRenderers.put(player.uuid(), sender);
|
||||||
if (previous != null) {
|
if (previous != null) {
|
||||||
previous.destroy();
|
previous.destroy();
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ public abstract class AbstractRequirementManager implements RequirementManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void registerInternalRequirements() {
|
private void registerInternalRequirements() {
|
||||||
|
this.registerRequirement((args, interval) -> new LaggyRequirement(interval, (int) args), "laggy");
|
||||||
this.registerRequirement((args, interval) -> {
|
this.registerRequirement((args, interval) -> {
|
||||||
Section section = ConfigUtils.safeCast(args, Section.class);
|
Section section = ConfigUtils.safeCast(args, Section.class);
|
||||||
if (section == null) return Requirement.empty();
|
if (section == null) return Requirement.empty();
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) <2024> <XiaoMoMi>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.momirealms.customnameplates.backend.requirement.builtin;
|
||||||
|
|
||||||
|
import net.momirealms.customnameplates.api.CNPlayer;
|
||||||
|
import net.momirealms.customnameplates.api.ConfigManager;
|
||||||
|
import net.momirealms.customnameplates.api.requirement.Requirement;
|
||||||
|
import net.momirealms.customnameplates.backend.requirement.AbstractRequirement;
|
||||||
|
|
||||||
|
public class LaggyRequirement extends AbstractRequirement {
|
||||||
|
|
||||||
|
private final int time;
|
||||||
|
|
||||||
|
public LaggyRequirement(int refreshInterval, int time) {
|
||||||
|
super(refreshInterval);
|
||||||
|
this.time = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSatisfied(CNPlayer p1, CNPlayer p2) {
|
||||||
|
if (!ConfigManager.debug()) return true;
|
||||||
|
long time1 = System.currentTimeMillis();
|
||||||
|
while (true) {
|
||||||
|
if (System.currentTimeMillis() - time1 > time) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String type() {
|
||||||
|
return "laggy";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return type().hashCode() + time * 17;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (!(o instanceof LaggyRequirement that)) return false;
|
||||||
|
return time == that.time;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -66,7 +66,7 @@ other-settings:
|
|||||||
display-system-actionbar: true # Should the plugin display system actionbar and temporarily hide the custom actionbar?
|
display-system-actionbar: true # Should the plugin display system actionbar and temporarily hide the custom actionbar?
|
||||||
hide-team-names: true # Hide the team name sent by other plugins or vanilla team system
|
hide-team-names: true # Hide the team name sent by other plugins or vanilla team system
|
||||||
unsafe-chat-event: false # Listen for canceled(unsafe) chat events from unknown plugins
|
unsafe-chat-event: false # Listen for canceled(unsafe) chat events from unknown plugins
|
||||||
default-condition-refresh-interval: 1 # Set default condition refresh interval
|
default-condition-refresh-interval: 20 # Set default condition refresh interval
|
||||||
default-placeholder-refresh-interval: 1 # Set default placeholder refresh interval
|
default-placeholder-refresh-interval: 1 # Set default placeholder refresh interval
|
||||||
placeholder-refresh-interval: # Custom placeholder refresh intervals for performance optimization
|
placeholder-refresh-interval: # Custom placeholder refresh intervals for performance optimization
|
||||||
"%player_name%": 100
|
"%player_name%": 100
|
||||||
|
|||||||
@@ -4,18 +4,33 @@ conditional-text:
|
|||||||
priority_1:
|
priority_1:
|
||||||
text: '%np_background_other_actionbar%' # hides the money hud when a player rides something or dives in water
|
text: '%np_background_other_actionbar%' # hides the money hud when a player rides something or dives in water
|
||||||
conditions:
|
conditions:
|
||||||
'||':
|
condition_or:
|
||||||
is-passenger: true
|
type: "||"
|
||||||
'!=':
|
refresh-interval: 1
|
||||||
value1: '%player_remaining_air%'
|
value:
|
||||||
value2: "300"
|
condition_passenger:
|
||||||
'!gamemode': survival
|
type: is-passenger
|
||||||
|
refresh-interval: 1
|
||||||
|
value: true
|
||||||
|
condition_air:
|
||||||
|
type: "!="
|
||||||
|
refresh-interval: 1
|
||||||
|
value:
|
||||||
|
value1: '%player_remaining_air%'
|
||||||
|
value2: "300"
|
||||||
|
condition_gamemode:
|
||||||
|
type: "!gamemode"
|
||||||
|
refresh-interval: 1
|
||||||
|
value: survival
|
||||||
priority_2:
|
priority_2:
|
||||||
text: '%np_static_money_hud%%np_offset_-179%%np_static_other_actionbar%' # displays the money hud + other plugin's actionbar message
|
text: '%np_static_money_hud%%np_offset_-179%%np_static_other_actionbar%' # displays the money hud + other plugin's actionbar message
|
||||||
conditions:
|
conditions:
|
||||||
'!equals':
|
condition_other_actionbar:
|
||||||
value1: '%np_actionbar%'
|
type: "!equals"
|
||||||
value2: ""
|
refresh-interval: 1
|
||||||
|
value:
|
||||||
|
value1: '%np_actionbar%'
|
||||||
|
value2: ""
|
||||||
priority_3:
|
priority_3:
|
||||||
text: '%np_static_money_hud%' # displays the money hud only
|
text: '%np_static_money_hud%' # displays the money hud only
|
||||||
weather:
|
weather:
|
||||||
|
|||||||
Reference in New Issue
Block a user