mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-25 09:59:49 -05:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
6e1156a418
9 files changed
+200
-146
No files matched your search
@@ -624,7 +624,7 @@ public class QuickShop extends JavaPlugin {
|
||||
shopManager.clear();
|
||||
}
|
||||
if (DisplayItem.getNowUsing() == DisplayType.VIRTUALITEM) {
|
||||
VirtualDisplayItem.unloadManager();
|
||||
VirtualDisplayItem.VirtualDisplayItemManager.unload();
|
||||
}
|
||||
|
||||
Util.debugLog("Cleaning up database queues...");
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package org.maxgamer.quickshop.chat.platform.minedown;
|
||||
|
||||
import de.themoep.minedown.MineDown;
|
||||
import net.md_5.bungee.api.chat.*;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -53,7 +52,7 @@ public class BungeeQuickChat implements QuickChat {
|
||||
if (StringUtils.isEmpty(message)) {
|
||||
return;
|
||||
}
|
||||
receiver.spigot().sendMessage(MineDown.parse(message));
|
||||
receiver.spigot().sendMessage(TextComponent.fromLegacyText(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,29 +74,29 @@ public class BungeeQuickChat implements QuickChat {
|
||||
|
||||
@Override
|
||||
public void sendItemHologramChat(@NotNull Player player, @NotNull String text, @NotNull ItemStack itemStack) {
|
||||
BaseComponent[] errorComponents = MineDown.parse((MsgUtil.getMessage("menu.item-holochat-error", player)));
|
||||
TextComponent errorComponent = new TextComponent(MsgUtil.getMessage("menu.item-holochat-error", player));
|
||||
try {
|
||||
String json = ReflectFactory.convertBukkitItemStackToJson(itemStack);
|
||||
TextComponent centerItem = new TextComponent(MineDown.parse(text));
|
||||
TextComponent centerItem = new TextComponent(text);
|
||||
ComponentBuilder cBuilder = new ComponentBuilder(json);
|
||||
centerItem.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, cBuilder.create())); //FIXME: Update this when drop 1.15 supports
|
||||
player.spigot().sendMessage(centerItem);
|
||||
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException | InstantiationException e) {
|
||||
plugin.getLogger().log(Level.WARNING, "Failed to process chat component", e);
|
||||
player.spigot().sendMessage(errorComponents);
|
||||
player.spigot().sendMessage(errorComponent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull QuickComponent getItemHologramChat(@NotNull Shop shop, @NotNull ItemStack itemStack, @NotNull Player player, @NotNull String message) {
|
||||
TextComponent errorComponent = new TextComponent(MineDown.parse(MsgUtil.getMessage("menu.item-holochat-error", player)));
|
||||
TextComponent errorComponent = new TextComponent(MsgUtil.getMessage("menu.item-holochat-error", player));
|
||||
try {
|
||||
|
||||
String json = ReflectFactory.convertBukkitItemStackToJson(itemStack);
|
||||
if (json == null) {
|
||||
return new QuickComponentImpl(errorComponent);
|
||||
}
|
||||
TextComponent normalmessage = new TextComponent(MineDown.parse(message + " " + MsgUtil.getMessage("menu.preview", player)));
|
||||
TextComponent normalmessage = new TextComponent(message + " " + MsgUtil.getMessage("menu.preview", player));
|
||||
ComponentBuilder cBuilder = new ComponentBuilder(json);
|
||||
if (QuickShop.getPermissionManager().hasPermission(player, "quickshop.preview")) {
|
||||
normalmessage.setClickEvent(new ClickEvent(
|
||||
@@ -116,7 +115,7 @@ public class BungeeQuickChat implements QuickChat {
|
||||
|
||||
@Override
|
||||
public @NotNull QuickComponent getItemTextComponent(@NotNull Player player, @NotNull ItemStack itemStack, @NotNull String normalText) {
|
||||
TextComponent errorComponent = new TextComponent(MineDown.parse(MsgUtil.getMessage("menu.item-holochat-error", player)));
|
||||
TextComponent errorComponent = new TextComponent(MsgUtil.getMessage("menu.item-holochat-error", player));
|
||||
|
||||
String json;
|
||||
try {
|
||||
@@ -129,7 +128,7 @@ public class BungeeQuickChat implements QuickChat {
|
||||
return new QuickComponentImpl(errorComponent);
|
||||
}
|
||||
|
||||
TextComponent component = new TextComponent(MineDown.parse(normalText + " " + MsgUtil.getMessage("menu.preview", player)));
|
||||
TextComponent component = new TextComponent(normalText + " " + MsgUtil.getMessage("menu.preview", player));
|
||||
ComponentBuilder cBuilder = new ComponentBuilder(json);
|
||||
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, cBuilder.create()));
|
||||
return new QuickComponentImpl(component);
|
||||
@@ -139,7 +138,7 @@ public class BungeeQuickChat implements QuickChat {
|
||||
@Override
|
||||
public void sendExecutableChat(@NotNull CommandSender receiver, @NotNull String message, @NotNull String hoverText, @NotNull String command) {
|
||||
TextComponent component =
|
||||
new TextComponent(MineDown.parse(ChatColor.DARK_PURPLE + MsgUtil.getMessage("tableformat.left_begin", receiver) + message));
|
||||
new TextComponent(ChatColor.DARK_PURPLE + MsgUtil.getMessage("tableformat.left_begin", receiver) + message);
|
||||
component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command));
|
||||
component.setHoverEvent(
|
||||
new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(hoverText).create())); //FIXME: Update this when drop 1.15 supports
|
||||
@@ -149,7 +148,7 @@ public class BungeeQuickChat implements QuickChat {
|
||||
@Override
|
||||
public void sendSuggestedChat(@NotNull CommandSender receiver, @NotNull String message, @NotNull String hoverText, @NotNull String command) {
|
||||
TextComponent component =
|
||||
new TextComponent(MineDown.parse(ChatColor.DARK_PURPLE + MsgUtil.getMessage("tableformat.left_begin", receiver) + message));
|
||||
new TextComponent(ChatColor.DARK_PURPLE + MsgUtil.getMessage("tableformat.left_begin", receiver) + message);
|
||||
component.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command));
|
||||
component.setHoverEvent(
|
||||
new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(hoverText).create())); //FIXME: Update this when drop 1.15 supports
|
||||
|
||||
@@ -43,15 +43,36 @@ public class SubCommand_Help implements CommandHandler<CommandSender> {
|
||||
|
||||
private void sendHelp(@NotNull CommandSender s, @NotNull String commandLabel) {
|
||||
MsgUtil.sendMessage(s, "command.description.title");
|
||||
commandCheckLoop:
|
||||
|
||||
commandPrintingLoop:
|
||||
for (CommandContainer container : plugin.getCommandManager().getCmds()) {
|
||||
final List<String> requirePermissions = container.getPermissions();
|
||||
if (!container.isHidden() && requirePermissions != null && !requirePermissions.isEmpty()) {
|
||||
for (String requirePermission : requirePermissions) {
|
||||
if (requirePermission != null && !QuickShop.getPermissionManager().hasPermission(s, requirePermission)) {
|
||||
continue commandCheckLoop;
|
||||
if (!container.isHidden()) {
|
||||
boolean passed = false;
|
||||
//selectivePermissions
|
||||
final List<String> selectivePermissions = container.getSelectivePermissions();
|
||||
if (selectivePermissions != null) {
|
||||
for (String selectivePermission : container.getSelectivePermissions()) {
|
||||
if (selectivePermission != null && !selectivePermission.isEmpty()) {
|
||||
if (QuickShop.getPermissionManager().hasPermission(s, selectivePermission)) {
|
||||
passed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//requirePermissions
|
||||
final List<String> requirePermissions = container.getPermissions();
|
||||
if (requirePermissions != null) {
|
||||
for (String requirePermission : requirePermissions) {
|
||||
if (requirePermission != null && !requirePermission.isEmpty() && !QuickShop.getPermissionManager().hasPermission(s, requirePermission)) {
|
||||
continue commandPrintingLoop;
|
||||
}
|
||||
}
|
||||
passed = true;
|
||||
}
|
||||
if (!passed) {
|
||||
continue;
|
||||
}
|
||||
String commandDesc = MsgUtil.getMessage("command.description." + container.getPrefix(), s);
|
||||
if (container.getDescription() != null) {
|
||||
commandDesc = container.getDescription();
|
||||
@@ -59,30 +80,12 @@ public class SubCommand_Help implements CommandHandler<CommandSender> {
|
||||
commandDesc = "Error: Subcommand " + container.getPrefix() + " # " + container.getClass().getCanonicalName() + " doesn't register the correct help description.";
|
||||
}
|
||||
}
|
||||
if (!container.isDisabled()) {
|
||||
if (container.isDisabled()) {
|
||||
if (QuickShop.getPermissionManager().hasPermission(s, "quickshop.showdisabled")) {
|
||||
MsgUtil.sendDirectMessage(s, MsgUtil.getMessage("command.format", s, commandLabel, container.getPrefix(), container.getDisableText(s)));
|
||||
}
|
||||
} else {
|
||||
MsgUtil.sendDirectMessage(s, MsgUtil.getMessage("command.format", s, commandLabel, container.getPrefix(), commandDesc));
|
||||
|
||||
|
||||
// MsgUtil.sendDirectMessage(s,
|
||||
// ChatColor.GREEN //TODO: Color custom ability
|
||||
// + "/"
|
||||
// + commandLabel
|
||||
// + " "
|
||||
// + container.getPrefix()
|
||||
// + ChatColor.YELLOW
|
||||
// + " - "
|
||||
// + commandDesc);
|
||||
} else if (QuickShop.getPermissionManager().hasPermission(s, "quickshop.showdisabled")) {
|
||||
// MsgUtil.sendDirectMessage(s,
|
||||
// ChatColor.RED
|
||||
// + "/"
|
||||
// + commandLabel
|
||||
// + " "
|
||||
// + container.getPrefix()
|
||||
// + ChatColor.GRAY
|
||||
// + " - "
|
||||
// + MsgUtil.getMessage("command.disabled", s, ChatColor.GRAY + container.getDisableText(s)));
|
||||
MsgUtil.sendDirectMessage(s, MsgUtil.getMessage("command.format", s, commandLabel, container.getPrefix(), container.getDisableText(s)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+30
-24
@@ -119,30 +119,10 @@ public class GriefPreventionIntegration extends QSIntegratedPlugin {
|
||||
return;
|
||||
}
|
||||
for (Claim claim : event.getClaims()) {
|
||||
for (Chunk chunk : claim.getChunks()) {
|
||||
Map<Location, Shop> shops = plugin.getShopManager().getShops(chunk);
|
||||
if (shops == null) {
|
||||
continue;
|
||||
}
|
||||
for (Shop shop : shops.values()) {
|
||||
if (shop.getOwner().equals(claim.getOwnerID())) {
|
||||
continue;
|
||||
}
|
||||
Claim shopClaim = griefPrevention.dataStore.getClaimAt(shop.getLocation(), false, false, null);
|
||||
if (shopClaim == null || !shopClaim.getID().equals(claim.getID())) {
|
||||
continue;
|
||||
}
|
||||
if (event.getIdentifier().equals(shop.getOwner().toString())) {
|
||||
plugin.log("[SHOP DELETE] GP Integration: Single delete (Claim/Subclaim Trust Changed) #" + shop.ownerName());
|
||||
shop.delete();
|
||||
} else if (event.getIdentifier().contains(shop.getOwner().toString())) {
|
||||
plugin.log("[SHOP DELETE] GP Integration: Group delete (Claim/Subclaim Trust Changed)#" + shop.ownerName());
|
||||
shop.delete();
|
||||
} else if ("all".equals(event.getIdentifier()) || "public".equals(event.getIdentifier())) {
|
||||
plugin.log("[SHOP DELETE] GP Integration: All/Public delete (Claim/Subclaim Trust Changed) #" + shop.ownerName());
|
||||
shop.delete();
|
||||
}
|
||||
}
|
||||
if (claim.parent != null) {
|
||||
handleClaimTrustChanged(claim.parent, event);
|
||||
} else {
|
||||
handleClaimTrustChanged(claim, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -211,6 +191,32 @@ public class GriefPreventionIntegration extends QSIntegratedPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
// Helper to the Claim Trust Changed Event Handler (to avoid duplicate code above)
|
||||
private void handleClaimTrustChanged(Claim claim, TrustChangedEvent event) {
|
||||
for (Chunk chunk : claim.getChunks()) {
|
||||
Map<Location, Shop> shops = plugin.getShopManager().getShops(chunk);
|
||||
if (shops == null) {
|
||||
continue;
|
||||
}
|
||||
for (Shop shop : shops.values()) {
|
||||
if (shop.getOwner().equals(claim.getOwnerID())) {
|
||||
continue;
|
||||
}
|
||||
if (event.getIdentifier().equals(shop.getOwner().toString())) {
|
||||
plugin.log("[SHOP DELETE] GP Integration: Single delete (Claim/Subclaim Trust Changed) #" + shop.ownerName());
|
||||
shop.delete();
|
||||
} else if (event.getIdentifier().contains(shop.getOwner().toString())) {
|
||||
plugin.log("[SHOP DELETE] GP Integration: Group delete (Claim/Subclaim Trust Changed)#" + shop.ownerName());
|
||||
shop.delete();
|
||||
} else if ("all".equals(event.getIdentifier()) || "public".equals(event.getIdentifier())) {
|
||||
plugin.log("[SHOP DELETE] GP Integration: All/Public delete (Claim/Subclaim Trust Changed) #" + shop.ownerName());
|
||||
shop.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If it is the main claim, then we will delete all the shops that were inside of it.
|
||||
private void handleMainClaimUnclaimedOrExpired(Claim claim, String logMessage) {
|
||||
for (Chunk chunk : claim.getChunks()) {
|
||||
|
||||
@@ -54,8 +54,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
public class VirtualDisplayItem extends DisplayItem {
|
||||
private static final AtomicInteger counter = new AtomicInteger(0);
|
||||
private static final GameVersion version = QuickShop.getInstance().getGameVersion();
|
||||
private static final AtomicBoolean managerLoaded = new AtomicBoolean(false);
|
||||
private static final Map<ShopChunk, VirtualDisplayItem> chunksMapping = new ConcurrentHashMap<>();
|
||||
private static final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
|
||||
private static PacketAdapter packetAdapter = null;
|
||||
//cache chunk x and z
|
||||
@@ -64,9 +62,7 @@ public class VirtualDisplayItem extends DisplayItem {
|
||||
public VirtualDisplayItem(@NotNull Shop shop) throws RuntimeException {
|
||||
super(shop);
|
||||
|
||||
if (!managerLoaded.get()) {
|
||||
loadManager();
|
||||
}
|
||||
VirtualDisplayItemManager.load();
|
||||
}
|
||||
|
||||
//unique EntityID
|
||||
@@ -89,51 +85,22 @@ public class VirtualDisplayItem extends DisplayItem {
|
||||
|
||||
private PacketContainer fakeItemDestroyPacket;
|
||||
|
||||
public static void loadManager() {
|
||||
Util.debugLog("Loading VirtualDisplayItem chunks mapping manager...");
|
||||
if (packetAdapter == null) {
|
||||
packetAdapter = new PacketAdapter(plugin, ListenerPriority.HIGH, PacketType.Play.Server.MAP_CHUNK) {
|
||||
@Override
|
||||
public void onPacketSending(@NotNull PacketEvent event) {
|
||||
//is really full chunk data
|
||||
//In 1.17, this value was removed, so read safely
|
||||
Boolean boxedIsFull = event.getPacket().getBooleans().readSafely(0);
|
||||
boolean isFull = boxedIsFull == null || boxedIsFull;
|
||||
Player player = event.getPlayer();
|
||||
if (player instanceof TemporaryPlayer) {
|
||||
return;
|
||||
}
|
||||
if (player == null || !player.isOnline()) {
|
||||
return;
|
||||
}
|
||||
StructureModifier<Integer> integerStructureModifier = event.getPacket().getIntegers();
|
||||
//chunk x
|
||||
int x = integerStructureModifier.read(0);
|
||||
//chunk z
|
||||
int z = integerStructureModifier.read(1);
|
||||
|
||||
VirtualDisplayItem target = chunksMapping.get(new ShopChunk(player.getWorld().getName(), x, z));
|
||||
if (target != null) {
|
||||
if (!target.shop.isLoaded() || !target.isDisplay || !isFull || target.shop.isLeftShop()) {
|
||||
return;
|
||||
}
|
||||
target.packetSenders.add(player.getUniqueId());
|
||||
target.sendFakeItem(player);
|
||||
}
|
||||
//Due to the delay task in ChunkListener
|
||||
//We must move load task to first spawn to prevent some bug and make the check lesser
|
||||
private void load() {
|
||||
Util.ensureThread(false);
|
||||
//some time shop can be loaded when world isn't loaded
|
||||
Chunk chunk = shop.getLocation().getChunk();
|
||||
chunkLocation = new ShopChunk(chunk.getWorld().getName(), chunk.getX(), chunk.getZ());
|
||||
VirtualDisplayItemManager.put(chunkLocation, this);
|
||||
if (Util.isLoaded(shop.getLocation())) {
|
||||
//Let nearby player can saw fake item
|
||||
Collection<Entity> entityCollection = shop.getLocation().getWorld().getNearbyEntities(shop.getLocation(), plugin.getServer().getViewDistance() * 16, shop.getLocation().getWorld().getMaxHeight(), plugin.getServer().getViewDistance() * 16);
|
||||
for (Entity entity : entityCollection) {
|
||||
if (entity instanceof Player) {
|
||||
packetSenders.add(entity.getUniqueId());
|
||||
}
|
||||
};
|
||||
}
|
||||
Util.debugLog("Registering the packet listener...");
|
||||
protocolManager.addPacketListener(packetAdapter);
|
||||
managerLoaded.set(true);
|
||||
}
|
||||
|
||||
public static void unloadManager() {
|
||||
Util.debugLog("Unloading VirtualDisplayItem chunks mapping manager...");
|
||||
if (!managerLoaded.get()) {
|
||||
Util.debugLog("Unregistering the packet listener...");
|
||||
protocolManager.removePacketListener(packetAdapter);
|
||||
managerLoaded.set(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,28 +221,88 @@ public class VirtualDisplayItem extends DisplayItem {
|
||||
isDisplay = true;
|
||||
}
|
||||
|
||||
//Due to the delay task in ChunkListener
|
||||
//We must move load task to first spawn to prevent some bug and make the check lesser
|
||||
private void load() {
|
||||
Util.ensureThread(false);
|
||||
//some time shop can be loaded when world isn't loaded
|
||||
Chunk chunk = shop.getLocation().getChunk();
|
||||
chunkLocation = new ShopChunk(chunk.getWorld().getName(), chunk.getX(), chunk.getZ());
|
||||
chunksMapping.put(chunkLocation, this);
|
||||
if (Util.isLoaded(shop.getLocation())) {
|
||||
//Let nearby player can saw fake item
|
||||
Collection<Entity> entityCollection = shop.getLocation().getWorld().getNearbyEntities(shop.getLocation(), plugin.getServer().getViewDistance() * 16, shop.getLocation().getWorld().getMaxHeight(), plugin.getServer().getViewDistance() * 16);
|
||||
for (Entity entity : entityCollection) {
|
||||
if (entity instanceof Player) {
|
||||
packetSenders.add(entity.getUniqueId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void unload() {
|
||||
packetSenders.clear();
|
||||
chunksMapping.remove(chunkLocation);
|
||||
VirtualDisplayItemManager.remove(chunkLocation, this);
|
||||
}
|
||||
|
||||
public static class VirtualDisplayItemManager {
|
||||
private static final AtomicBoolean loaded = new AtomicBoolean(false);
|
||||
private static final Map<ShopChunk, List<VirtualDisplayItem>> chunksMapping = new ConcurrentHashMap<>();
|
||||
|
||||
public static void put(@NotNull ShopChunk key, @NotNull VirtualDisplayItem value) {
|
||||
List<VirtualDisplayItem> lists = chunksMapping.get(key);
|
||||
if (lists == null) {
|
||||
List<VirtualDisplayItem> virtualDisplayItems = Collections.synchronizedList(new LinkedList<>());
|
||||
virtualDisplayItems.add(value);
|
||||
chunksMapping.put(key, virtualDisplayItems);
|
||||
} else {
|
||||
lists.add(value);
|
||||
}
|
||||
}
|
||||
|
||||
public static void remove(@NotNull ShopChunk key, @NotNull VirtualDisplayItem value) {
|
||||
List<VirtualDisplayItem> lists = chunksMapping.get(key);
|
||||
if (lists != null) {
|
||||
lists.remove(value);
|
||||
}
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
if (loaded.get()) {
|
||||
return;
|
||||
}
|
||||
Util.debugLog("Loading VirtualDisplayItem chunks mapping manager...");
|
||||
if (packetAdapter == null) {
|
||||
packetAdapter = new PacketAdapter(plugin, ListenerPriority.HIGH, PacketType.Play.Server.MAP_CHUNK) {
|
||||
@Override
|
||||
public void onPacketSending(@NotNull PacketEvent event) {
|
||||
//is really full chunk data
|
||||
//In 1.17, this value was removed, so read safely
|
||||
Boolean boxedIsFull = event.getPacket().getBooleans().readSafely(0);
|
||||
boolean isFull = boxedIsFull == null || boxedIsFull;
|
||||
if (!isFull) {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
if (player instanceof TemporaryPlayer) {
|
||||
return;
|
||||
}
|
||||
if (player == null || !player.isOnline()) {
|
||||
return;
|
||||
}
|
||||
StructureModifier<Integer> integerStructureModifier = event.getPacket().getIntegers();
|
||||
//chunk x
|
||||
int x = integerStructureModifier.read(0);
|
||||
//chunk z
|
||||
int z = integerStructureModifier.read(1);
|
||||
|
||||
List<VirtualDisplayItem> targetList = chunksMapping.get(new ShopChunk(player.getWorld().getName(), x, z));
|
||||
if (targetList != null) {
|
||||
for (VirtualDisplayItem target : targetList) {
|
||||
if (!target.shop.isLoaded() || !target.isDisplay || target.shop.isLeftShop()) {
|
||||
return;
|
||||
}
|
||||
target.packetSenders.add(player.getUniqueId());
|
||||
target.sendFakeItem(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
Util.debugLog("Registering the packet listener...");
|
||||
protocolManager.addPacketListener(packetAdapter);
|
||||
loaded.set(true);
|
||||
}
|
||||
|
||||
public static void unload() {
|
||||
Util.debugLog("Unloading VirtualDisplayItem chunks mapping manager...");
|
||||
if (!loaded.get()) {
|
||||
Util.debugLog("Unregistering the packet listener...");
|
||||
protocolManager.removePacketListener(packetAdapter);
|
||||
loaded.set(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendFakeItem(@NotNull Player player) {
|
||||
|
||||
@@ -331,8 +331,8 @@ public class MsgUtil {
|
||||
|
||||
updateMessages(messagei18n.getInt("language-version"));
|
||||
|
||||
//Color will be handled by minedown
|
||||
messagei18n.loadFromString(messagei18n.saveToString());
|
||||
//Update colors
|
||||
Util.parseColours(messagei18n);
|
||||
/* Print to console this language file's author, contributors, and region*/
|
||||
if (!inited) {
|
||||
plugin.getLogger().info(getMessage("translation-author", null));
|
||||
|
||||
@@ -19,10 +19,14 @@
|
||||
|
||||
package org.maxgamer.quickshop.util;
|
||||
|
||||
import de.themoep.minedown.MineDown;
|
||||
import de.themoep.minedown.MineDownParser;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.SneakyThrows;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -31,6 +35,7 @@ import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.EnderChest;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Directional;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@@ -1054,12 +1059,14 @@ public class Util {
|
||||
return list2.containsAll(list1);
|
||||
}
|
||||
|
||||
private static final MineDown mineDown = new MineDown("");
|
||||
|
||||
/**
|
||||
* Parse colors for the YamlConfiguration.
|
||||
*
|
||||
* @param config yaml config
|
||||
*/
|
||||
public static void parseColours(@NotNull YamlConfiguration config) {
|
||||
public static void parseColours(@NotNull ConfigurationSection config) {
|
||||
Set<String> keys = config.getKeys(true);
|
||||
for (String key : keys) {
|
||||
String filtered = config.getString(key);
|
||||
@@ -1085,8 +1092,20 @@ public class Util {
|
||||
if (StringUtils.isEmpty(text)) {
|
||||
return "";
|
||||
}
|
||||
text = ChatColor.translateAlternateColorCodes('&', text);
|
||||
return text;
|
||||
MineDownParser parser = mineDown.parser();
|
||||
parser.reset();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
BaseComponent[] components = parser.enable(MineDownParser.Option.LEGACY_COLORS).parse(text).create();
|
||||
for (BaseComponent component : components) {
|
||||
ChatColor color = component.getColorRaw();
|
||||
String legacyText = component.toLegacyText();
|
||||
if (color == null && legacyText.startsWith("§f")) {
|
||||
//Remove redundant §f added by toLegacyText
|
||||
legacyText = legacyText.substring(2);
|
||||
}
|
||||
builder.append(legacyText);
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -144,14 +144,14 @@
|
||||
"wrong-args": "&c無效的參數 。 使用 &l/qs help &c 查看指令列表。",
|
||||
"description": {
|
||||
"title": "&aQuickShop 說明",
|
||||
"unlimited": "&e將商店設為庫存無限。",
|
||||
"unlimited": "&e將商店設為無限庫存。",
|
||||
"setowner": "&e為商店設置新的店主。",
|
||||
"owner": "&e為商店設置新的店主。",
|
||||
"buy": "&e切換到 &d收購 &e模式",
|
||||
"sell": "&e切換到 &d出售 &e模式",
|
||||
"price": "&e切換 收購/出售 的價格",
|
||||
"buy": "&e修改成 &d收購 &e模式",
|
||||
"sell": "&e修改成 &d出售 &e模式",
|
||||
"price": "&e修改 收購/出售 的價格",
|
||||
"clean": "&e刪除所有 (已載入) 沒有商品的商店",
|
||||
"find": "&e在附近搜尋具有指定物品類型的商店 。",
|
||||
"find": "&e在附近搜尋具有指定物品類型的商店。",
|
||||
"reload": "&e重新載入 QuickShop",
|
||||
"refill": "&e將一定數量的商品加到商店",
|
||||
"empty": "&e清空商店空間",
|
||||
@@ -171,7 +171,7 @@
|
||||
"language": "&e修改正在使用的語言",
|
||||
"removeall": "&e刪除該玩家的所有商店",
|
||||
"transfer": "&e我們將某人的所有商店轉移給其他人",
|
||||
"removeworld": "&e指定世界的商店已全部刪除",
|
||||
"removeworld": "&e刪除指定世界的商店",
|
||||
"currency": "&e設置或移除目前商店的貨幣設定",
|
||||
"ban": "&e解除封禁商店中的玩家",
|
||||
"unban": "&e解除封禁商店中的玩家",
|
||||
|
||||
Reference in new issue
Block a user