mirror of
https://github.com/Xiao-MoMi/Custom-Nameplates.git
synced 2025-12-19 15:09:23 +00:00
3.0.9
This commit is contained in:
@@ -148,6 +148,8 @@ public class UnlimitedTagManagerImpl implements UnlimitedTagManager, JoinQuitLis
|
|||||||
}
|
}
|
||||||
if (isAlwaysShow()) {
|
if (isAlwaysShow()) {
|
||||||
setTempPreviewing(player, isAlwaysShow());
|
setTempPreviewing(player, isAlwaysShow());
|
||||||
|
} else if (player.isLoaded() && player.isTempPreviewing()) {
|
||||||
|
setTempPreviewing(player, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -167,13 +167,14 @@ other-settings:
|
|||||||
unicode:
|
unicode:
|
||||||
file: unicode_page_%02x.png # Default Unicode characters
|
file: unicode_page_%02x.png # Default Unicode characters
|
||||||
sizes: glyph_sizes.bin # Glyph size configuration
|
sizes: glyph_sizes.bin # Glyph size configuration
|
||||||
ttf:
|
ttf: {}
|
||||||
example:
|
# ttf:
|
||||||
generate: false # Should this TTF file be included in the generated pack
|
# example:
|
||||||
file: example.ttf # Define the TTF file to load the font from
|
# generate: false # Should this TTF file be included in the generated pack
|
||||||
size: 10.0 # Set font size
|
# file: example.ttf # Define the TTF file to load the font from
|
||||||
oversample: 8.0 # Oversample rate for TTF rendering
|
# size: 10.0 # Set font size
|
||||||
skip: [] # Skipped characters in list format
|
# oversample: 8.0 # Oversample rate for TTF rendering
|
||||||
|
# skip: [] # Skipped characters in list format
|
||||||
shift-fonts:
|
shift-fonts:
|
||||||
shift_0:
|
shift_0:
|
||||||
- space
|
- space
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public class BukkitChatManager extends AbstractChatManager {
|
|||||||
}
|
}
|
||||||
if (Bukkit.getPluginManager().isPluginEnabled("Oraxen")) {
|
if (Bukkit.getPluginManager().isPluginEnabled("Oraxen")) {
|
||||||
try {
|
try {
|
||||||
this.emojiProviders.add(new OraxenEmojiProvider());
|
this.emojiProviders.add(new OraxenEmojiProvider(Bukkit.getPluginManager().getPlugin("Oraxen").getDescription().getVersion().startsWith("1") ? 1 : 2));
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import net.momirealms.customnameplates.bukkit.command.BukkitCommandManager;
|
|||||||
import net.momirealms.customnameplates.bukkit.compatibility.NameplatesExpansion;
|
import net.momirealms.customnameplates.bukkit.compatibility.NameplatesExpansion;
|
||||||
import net.momirealms.customnameplates.bukkit.compatibility.NameplatesExtraExpansion;
|
import net.momirealms.customnameplates.bukkit.compatibility.NameplatesExtraExpansion;
|
||||||
import net.momirealms.customnameplates.bukkit.compatibility.cosmetic.MagicCosmeticsHook;
|
import net.momirealms.customnameplates.bukkit.compatibility.cosmetic.MagicCosmeticsHook;
|
||||||
|
import net.momirealms.customnameplates.bukkit.compatibility.region.WorldGuardRegion;
|
||||||
import net.momirealms.customnameplates.bukkit.requirement.BukkitRequirementManager;
|
import net.momirealms.customnameplates.bukkit.requirement.BukkitRequirementManager;
|
||||||
import net.momirealms.customnameplates.bukkit.scheduler.BukkitSchedulerAdapter;
|
import net.momirealms.customnameplates.bukkit.scheduler.BukkitSchedulerAdapter;
|
||||||
import net.momirealms.customnameplates.bukkit.util.SimpleLocation;
|
import net.momirealms.customnameplates.bukkit.util.SimpleLocation;
|
||||||
@@ -204,6 +205,12 @@ public class BukkitCustomNameplates extends CustomNameplates implements Listener
|
|||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (Bukkit.getPluginManager().isPluginEnabled("WorldGuard")) {
|
||||||
|
try {
|
||||||
|
WorldGuardRegion.register();
|
||||||
|
} catch (Exception ignore) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boolean downloadFromPolymart = polymart.equals("1");
|
boolean downloadFromPolymart = polymart.equals("1");
|
||||||
boolean downloadFromBBB = buildByBit.equals("true");
|
boolean downloadFromBBB = buildByBit.equals("true");
|
||||||
|
|||||||
@@ -204,24 +204,63 @@ public class BukkitPlatform implements Platform {
|
|||||||
}
|
}
|
||||||
}, "PacketPlayOutEntityDestroy", "ClientboundRemoveEntitiesPacket");
|
}, "PacketPlayOutEntityDestroy", "ClientboundRemoveEntitiesPacket");
|
||||||
|
|
||||||
|
// for skin plugin compatibility
|
||||||
|
registerPacketConsumer((player, event, packet) -> {
|
||||||
|
try {
|
||||||
|
UUID pUUID = player.uuid();
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<UUID> uuids = (List<UUID>) Reflections.field$ClientboundPlayerInfoRemovePacket$profileIds.get(packet);
|
||||||
|
for (UUID uuid : uuids) {
|
||||||
|
if (uuid.equals(pUUID)) {
|
||||||
|
CNPlayer removed = CustomNameplates.getInstance().getPlayer(uuid);
|
||||||
|
if (removed != null) {
|
||||||
|
removed.removePlayerFromTracker(player);
|
||||||
|
CustomNameplates.getInstance().getUnlimitedTagManager().onRemovePlayer(removed, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (ReflectiveOperationException e) {
|
||||||
|
CustomNameplates.getInstance().getPluginLogger().severe("Failed to handle ClientboundPlayerInfoRemovePacket", e);
|
||||||
|
}
|
||||||
|
}, "ClientboundPlayerInfoRemovePacket");
|
||||||
|
|
||||||
registerPacketConsumer((player, event, packet) -> {
|
registerPacketConsumer((player, event, packet) -> {
|
||||||
try {
|
try {
|
||||||
EnumSet<?> enums = (EnumSet<?>) Reflections.field$ClientboundPlayerInfoUpdatePacket$actions.get(packet);
|
EnumSet<?> enums = (EnumSet<?>) Reflections.field$ClientboundPlayerInfoUpdatePacket$actions.get(packet);
|
||||||
if (enums == null) return;
|
if (enums == null) return;
|
||||||
if (!enums.contains(Reflections.enum$ClientboundPlayerInfoUpdatePacket$Action$UPDATE_GAME_MODE)) return;
|
UUID pUUID = player.uuid();
|
||||||
|
boolean add_player = enums.contains(Reflections.enum$ClientboundPlayerInfoUpdatePacket$Action$ADD_PLAYER);
|
||||||
|
boolean update_gamemode = enums.contains(Reflections.enum$ClientboundPlayerInfoUpdatePacket$Action$UPDATE_GAME_MODE);
|
||||||
|
if (add_player || update_gamemode) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
List<Object> entries = (List<Object>) Reflections.field$ClientboundPlayerInfoUpdatePacket$entries.get(packet);
|
List<Object> entries = (List<Object>) Reflections.field$ClientboundPlayerInfoUpdatePacket$entries.get(packet);
|
||||||
for (Object entry : entries) {
|
for (Object entry : entries) {
|
||||||
UUID uuid = (UUID) Reflections.field$ClientboundPlayerInfoUpdatePacket$Entry$profileId.get(entry);
|
UUID uuid = (UUID) Reflections.field$ClientboundPlayerInfoUpdatePacket$Entry$profileId.get(entry);
|
||||||
if (uuid == null) continue;
|
if (uuid == null) continue;
|
||||||
|
|
||||||
|
// for skin plugin compatibility
|
||||||
|
if (add_player && uuid.equals(pUUID)) {
|
||||||
|
if (player.isTempPreviewing() || player.isToggleablePreviewing() || CustomNameplates.getInstance().getUnlimitedTagManager().isAlwaysShow()) {
|
||||||
|
Tracker tracker = player.addPlayerToTracker(player);
|
||||||
|
tracker.setScale(player.scale());
|
||||||
|
tracker.setCrouching(player.isCrouching());
|
||||||
|
tracker.setSpectator(player.isSpectator());
|
||||||
|
CustomNameplates.getInstance().getUnlimitedTagManager().onAddPlayer(player, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CNPlayer another = CustomNameplates.getInstance().getPlayer(uuid);
|
||||||
|
if (update_gamemode) {
|
||||||
Object gameType = Reflections.field$ClientboundPlayerInfoUpdatePacket$Entry$gameMode.get(entry);
|
Object gameType = Reflections.field$ClientboundPlayerInfoUpdatePacket$Entry$gameMode.get(entry);
|
||||||
if (gameType == null) continue;
|
if (gameType == null) continue;
|
||||||
int mode = (int) Reflections.method$GameType$getId.invoke(gameType);
|
int mode = (int) Reflections.method$GameType$getId.invoke(gameType);
|
||||||
boolean isSpectator = mode == 3;
|
boolean isSpectator = mode == 3;
|
||||||
CNPlayer another = CustomNameplates.getInstance().getPlayer(uuid);
|
|
||||||
if (another != null) {
|
if (another != null) {
|
||||||
CustomNameplates.getInstance().getUnlimitedTagManager().onPlayerGameModeChange(another, player, isSpectator);
|
CustomNameplates.getInstance().getUnlimitedTagManager().onPlayerGameModeChange(another, player, isSpectator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (ReflectiveOperationException e) {
|
} catch (ReflectiveOperationException e) {
|
||||||
CustomNameplates.getInstance().getPluginLogger().severe("Failed to handle ClientboundPlayerInfoUpdatePacket", e);
|
CustomNameplates.getInstance().getPluginLogger().severe("Failed to handle ClientboundPlayerInfoUpdatePacket", e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package net.momirealms.customnameplates.bukkit.command.feature;
|
|||||||
|
|
||||||
import net.momirealms.customnameplates.api.CNPlayer;
|
import net.momirealms.customnameplates.api.CNPlayer;
|
||||||
import net.momirealms.customnameplates.api.ConfigManager;
|
import net.momirealms.customnameplates.api.ConfigManager;
|
||||||
|
import net.momirealms.customnameplates.api.CustomNameplates;
|
||||||
import net.momirealms.customnameplates.api.feature.JoinQuitListener;
|
import net.momirealms.customnameplates.api.feature.JoinQuitListener;
|
||||||
import net.momirealms.customnameplates.bukkit.BukkitCustomNameplates;
|
import net.momirealms.customnameplates.bukkit.BukkitCustomNameplates;
|
||||||
import net.momirealms.customnameplates.bukkit.command.BukkitCommandFeature;
|
import net.momirealms.customnameplates.bukkit.command.BukkitCommandFeature;
|
||||||
@@ -45,6 +46,7 @@ public class NameplatesPreviewCommand extends BukkitCommandFeature<CommandSender
|
|||||||
.senderType(Player.class)
|
.senderType(Player.class)
|
||||||
.handler(context -> {
|
.handler(context -> {
|
||||||
if (!ConfigManager.nametagModule()) return;
|
if (!ConfigManager.nametagModule()) return;
|
||||||
|
if (CustomNameplates.getInstance().getUnlimitedTagManager().isAlwaysShow()) return;
|
||||||
CNPlayer player = plugin.getPlayer(context.sender().getUniqueId());
|
CNPlayer player = plugin.getPlayer(context.sender().getUniqueId());
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
throw new RuntimeException("Player should not be null");
|
throw new RuntimeException("Player should not be null");
|
||||||
|
|||||||
@@ -429,6 +429,18 @@ public class Reflections {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public static final Class<?> clazz$ClientboundPlayerInfoRemovePacket = requireNonNull(
|
||||||
|
ReflectionUtils.getClazz(
|
||||||
|
BukkitReflectionUtils.assembleMCClass("network.protocol.game.ClientboundPlayerInfoRemovePacket")
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
public static final Field field$ClientboundPlayerInfoRemovePacket$profileIds = requireNonNull(
|
||||||
|
ReflectionUtils.getInstanceDeclaredField(
|
||||||
|
clazz$ClientboundPlayerInfoRemovePacket, 0
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
public static final Field field$ClientboundRemoveEntitiesPacket$entityIds = requireNonNull(
|
public static final Field field$ClientboundRemoveEntitiesPacket$entityIds = requireNonNull(
|
||||||
ReflectionUtils.getInstanceDeclaredField(
|
ReflectionUtils.getInstanceDeclaredField(
|
||||||
clazz$ClientboundRemoveEntitiesPacket, 0
|
clazz$ClientboundRemoveEntitiesPacket, 0
|
||||||
@@ -819,7 +831,7 @@ public class Reflections {
|
|||||||
);
|
);
|
||||||
|
|
||||||
public static final Enum<?> enum$ClientboundPlayerInfoUpdatePacket$Action$UPDATE_GAME_MODE;
|
public static final Enum<?> enum$ClientboundPlayerInfoUpdatePacket$Action$UPDATE_GAME_MODE;
|
||||||
|
public static final Enum<?> enum$ClientboundPlayerInfoUpdatePacket$Action$ADD_PLAYER;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Enum<?> updateGameMode;
|
Enum<?> updateGameMode;
|
||||||
@@ -829,6 +841,14 @@ public class Reflections {
|
|||||||
updateGameMode = Enum.valueOf((Class<Enum>) clazz$ClientboundPlayerInfoUpdatePacket$Action, "c");
|
updateGameMode = Enum.valueOf((Class<Enum>) clazz$ClientboundPlayerInfoUpdatePacket$Action, "c");
|
||||||
}
|
}
|
||||||
enum$ClientboundPlayerInfoUpdatePacket$Action$UPDATE_GAME_MODE = updateGameMode;
|
enum$ClientboundPlayerInfoUpdatePacket$Action$UPDATE_GAME_MODE = updateGameMode;
|
||||||
|
|
||||||
|
Enum<?> addPlayer;
|
||||||
|
try {
|
||||||
|
addPlayer = Enum.valueOf((Class<Enum>) clazz$ClientboundPlayerInfoUpdatePacket$Action, "ADD_PLAYER");
|
||||||
|
} catch (Exception e) {
|
||||||
|
addPlayer = Enum.valueOf((Class<Enum>) clazz$ClientboundPlayerInfoUpdatePacket$Action, "a");
|
||||||
|
}
|
||||||
|
enum$ClientboundPlayerInfoUpdatePacket$Action$ADD_PLAYER = addPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Class<?> clazz$ClientboundPlayerInfoUpdatePacket$Entry = requireNonNull(
|
public static final Class<?> clazz$ClientboundPlayerInfoUpdatePacket$Entry = requireNonNull(
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ softdepend:
|
|||||||
- AdvancedChat
|
- AdvancedChat
|
||||||
- VentureChat
|
- VentureChat
|
||||||
- EssentialsChat
|
- EssentialsChat
|
||||||
|
- WorldGuard
|
||||||
permissions:
|
permissions:
|
||||||
nameplates.command.equip:
|
nameplates.command.equip:
|
||||||
default: true
|
default: true
|
||||||
|
|||||||
@@ -11,11 +11,16 @@ repositories {
|
|||||||
maven("https://repo.essentialsx.net/releases/") // ess
|
maven("https://repo.essentialsx.net/releases/") // ess
|
||||||
maven("https://repo.md-5.net/content/groups/public/") // disguise
|
maven("https://repo.md-5.net/content/groups/public/") // disguise
|
||||||
maven("https://repo.opencollab.dev/main/") // geyser
|
maven("https://repo.opencollab.dev/main/") // geyser
|
||||||
|
maven("https://maven.enginehub.org/repo/") // worldguard worldedit
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":api"))
|
compileOnly(project(":api"))
|
||||||
compileOnly(project(":common"))
|
compileOnly(project(":common"))
|
||||||
|
compileOnly(project(":backend"))
|
||||||
|
compileOnly("dev.dejvokep:boosted-yaml:${rootProject.properties["boosted_yaml_version"]}")
|
||||||
|
// WorldGuard
|
||||||
|
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.9")
|
||||||
// Platform
|
// Platform
|
||||||
compileOnly("dev.folia:folia-api:${rootProject.properties["paper_version"]}-R0.1-SNAPSHOT")
|
compileOnly("dev.folia:folia-api:${rootProject.properties["paper_version"]}-R0.1-SNAPSHOT")
|
||||||
// Chat
|
// Chat
|
||||||
|
|||||||
@@ -24,14 +24,24 @@ import net.momirealms.customnameplates.api.CNPlayer;
|
|||||||
import net.momirealms.customnameplates.api.feature.chat.emoji.EmojiProvider;
|
import net.momirealms.customnameplates.api.feature.chat.emoji.EmojiProvider;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class OraxenEmojiProvider implements EmojiProvider {
|
public class OraxenEmojiProvider implements EmojiProvider {
|
||||||
|
|
||||||
private final FontManager fontManager;
|
private final FontManager fontManager;
|
||||||
|
|
||||||
public OraxenEmojiProvider() {
|
public OraxenEmojiProvider(int version) {
|
||||||
|
if (version == 1) {
|
||||||
this.fontManager = OraxenPlugin.get().getFontManager();
|
this.fontManager = OraxenPlugin.get().getFontManager();
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
Method fm = OraxenPlugin.class.getMethod("fontManager");
|
||||||
|
this.fontManager = (FontManager) fm.invoke(OraxenPlugin.get());
|
||||||
|
} catch (ReflectiveOperationException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* 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.compatibility.region;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
|
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||||
|
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||||
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
import net.momirealms.customnameplates.api.CNPlayer;
|
||||||
|
import net.momirealms.customnameplates.backend.requirement.AbstractRequirement;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class RegionRequirement extends AbstractRequirement {
|
||||||
|
|
||||||
|
private final List<String> regions;
|
||||||
|
private final int mode;
|
||||||
|
|
||||||
|
public RegionRequirement(int refreshInterval, int mode, Collection<String> regions) {
|
||||||
|
super(refreshInterval);
|
||||||
|
this.regions = new ArrayList<>(regions);
|
||||||
|
this.mode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSatisfied(CNPlayer p1, CNPlayer p2) {
|
||||||
|
Location location = ((Player) p1.player()).getLocation();
|
||||||
|
RegionManager regionManager = WorldGuard.getInstance().getPlatform().getRegionContainer().get(BukkitAdapter.adapt(location.getWorld()));
|
||||||
|
if (regionManager != null) {
|
||||||
|
ApplicableRegionSet set = regionManager.getApplicableRegions(BlockVector3.at(location.getBlockX(), location.getBlockY(), location.getBlockZ()));
|
||||||
|
if (mode == 1) {
|
||||||
|
for (ProtectedRegion region : set) {
|
||||||
|
if (regions.contains(region.getId())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (mode == 2) {
|
||||||
|
outer: {
|
||||||
|
Set<String> ids = set.getRegions().stream().map(ProtectedRegion::getId).collect(Collectors.toSet());
|
||||||
|
for (String region : regions) {
|
||||||
|
if (!ids.contains(region)) {
|
||||||
|
break outer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String type() {
|
||||||
|
return "region";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* 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.compatibility.region;
|
||||||
|
|
||||||
|
import dev.dejvokep.boostedyaml.block.implementation.Section;
|
||||||
|
import net.momirealms.customnameplates.api.CustomNameplates;
|
||||||
|
import net.momirealms.customnameplates.api.requirement.EmptyRequirement;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class WorldGuardRegion {
|
||||||
|
|
||||||
|
public static void register() {
|
||||||
|
CustomNameplates.getInstance().getRequirementManager().registerRequirement((args, interval) -> {
|
||||||
|
HashSet<String> regions = new HashSet<>();
|
||||||
|
int mode = 1;
|
||||||
|
if (args instanceof Section section) {
|
||||||
|
mode = section.getInt("mode", 1);
|
||||||
|
regions.addAll(section.getStringList("values"));
|
||||||
|
} else {
|
||||||
|
if (args instanceof List<?> list) {
|
||||||
|
for (Object o : list) {
|
||||||
|
if (o instanceof String) {
|
||||||
|
regions.add((String) o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
CustomNameplates.getInstance().getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at region requirement which is expected be `Section` or `StringList`");
|
||||||
|
return EmptyRequirement.instance();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new RegionRequirement(interval, mode, regions);
|
||||||
|
}, "region");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Project settings
|
# Project settings
|
||||||
# Rule: [major update].[feature update].[bug fix]
|
# Rule: [major update].[feature update].[bug fix]
|
||||||
project_version=3.0.8
|
project_version=3.0.9
|
||||||
config_version=32
|
config_version=32
|
||||||
project_group=net.momirealms
|
project_group=net.momirealms
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user