9
0
mirror of https://github.com/Xiao-MoMi/Custom-Nameplates.git synced 2025-12-19 15:09:23 +00:00
This commit is contained in:
XiaoMoMi
2025-07-19 23:48:06 +08:00
parent 2ebb781721
commit df5a1faa19
3 changed files with 76 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
# Project settings
# Rule: [major update].[feature update].[bug fix]
project_version=3.0.29
project_version=3.0.30
config_version=38
project_group=net.momirealms
@@ -22,10 +22,10 @@ adventure_bundle_version=4.23.0
adventure_platform_version=4.4.0
cloud_core_version=2.0.0
cloud_services_version=2.0.0
cloud_brigadier_version=2.0.0-beta.10
cloud_bukkit_version=2.0.0-beta.10
cloud_paper_version=2.0.0-beta.10
cloud_minecraft_extras_version=2.0.0-beta.10
cloud_brigadier_version=2.0.0-beta.11
cloud_bukkit_version=2.0.0-beta.11
cloud_paper_version=2.0.0-beta.11
cloud_minecraft_extras_version=2.0.0-beta.11
boosted_yaml_version=1.3.7
byte_buddy_version=1.17.5
mojang_brigadier_version=1.0.18

View File

@@ -53,6 +53,14 @@ public class BukkitRequirementManager extends AbstractRequirementManager {
this.registerBedrock();
this.registerDisguise();
this.registerPassenger();
this.registerTeammates();
}
private void registerTeammates() {
this.registerRequirement((args, interval) -> {
boolean is = (boolean) args;
return new TeammatesRequirement(interval, is);
}, "teammates");
}
private void registerPassenger() {

View File

@@ -0,0 +1,63 @@
/*
* 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.bukkit.requirement.builtin;
import net.momirealms.customnameplates.api.CNPlayer;
import net.momirealms.customnameplates.backend.requirement.AbstractRequirement;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Team;
public class TeammatesRequirement extends AbstractRequirement {
private final boolean is;
public TeammatesRequirement(int refreshInterval, boolean is) {
super(refreshInterval);
this.is = is;
}
@Override
public boolean isSatisfied(CNPlayer p1, CNPlayer p2) {
Player player1 = (Player) p1.player();
Player player2 = (Player) p2.player();
Team team1 = Bukkit.getScoreboardManager().getMainScoreboard().getEntityTeam(player1);
Team team2 = Bukkit.getScoreboardManager().getMainScoreboard().getEntityTeam(player2);
if (this.is) {
return team1 != null && team1.equals(team2);
} else {
return team1 == null || !team1.equals(team2);
}
}
@Override
public String type() {
return "teammates";
}
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TeammatesRequirement that = (TeammatesRequirement) o;
return that.is == this.is;
}
@Override
public int hashCode() {
return this.is ? 17 : 3;
}
}