mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-25 09:59:49 -05:00
[TODO]New language system + Adventure chat
This commit is contained in:
1 parent
f611d428ab
commit
1fd8dfcc89
56 files changed
+1937
-1689
No files matched your search
@@ -30,7 +30,6 @@ import me.minebuilders.clearlag.listeners.ItemMergeListener;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@@ -47,9 +46,9 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.api.QuickShopAPI;
|
||||
import org.maxgamer.quickshop.chat.QuickChat;
|
||||
import org.maxgamer.quickshop.chat.QuickChatType;
|
||||
import org.maxgamer.quickshop.chat.platform.minedown.AdventureQuickChat;
|
||||
//import org.maxgamer.quickshop.chat.QuickChat;
|
||||
//import org.maxgamer.quickshop.chat.QuickChatType;
|
||||
//import org.maxgamer.quickshop.chat.platform.minedown.AdventureQuickChat;
|
||||
import org.maxgamer.quickshop.command.CommandManager;
|
||||
import org.maxgamer.quickshop.database.*;
|
||||
import org.maxgamer.quickshop.economy.*;
|
||||
@@ -67,6 +66,7 @@ import org.maxgamer.quickshop.util.*;
|
||||
import org.maxgamer.quickshop.util.compatibility.CompatibilityManager;
|
||||
import org.maxgamer.quickshop.util.config.ConfigProvider;
|
||||
import org.maxgamer.quickshop.util.envcheck.*;
|
||||
import org.maxgamer.quickshop.util.language.text.TextManager;
|
||||
import org.maxgamer.quickshop.util.matcher.item.BukkitItemMatcherImpl;
|
||||
import org.maxgamer.quickshop.util.matcher.item.ItemMatcher;
|
||||
import org.maxgamer.quickshop.util.matcher.item.QuickShopItemMatcherImpl;
|
||||
@@ -238,8 +238,8 @@ public class QuickShop extends JavaPlugin {
|
||||
DisplayDupeRemoverWatcher displayDupeRemoverWatcher;
|
||||
@Getter
|
||||
private boolean enabledAsyncDisplayDespawn;
|
||||
@Getter
|
||||
private String previewProtectionLore;
|
||||
// @Getter
|
||||
// private String previewProtectionLore;
|
||||
@Getter
|
||||
private Plugin blockHubPlugin;
|
||||
@Getter
|
||||
@@ -255,15 +255,15 @@ public class QuickShop extends JavaPlugin {
|
||||
private UpdateWatcher updateWatcher;
|
||||
@Getter
|
||||
private BuildInfo buildInfo;
|
||||
@Getter
|
||||
private QuickChatType quickChatType = QuickChatType.ADVENTURE;
|
||||
@Getter
|
||||
private QuickChat quickChat = new AdventureQuickChat();
|
||||
// @Getter
|
||||
// private QuickChatType quickChatType = QuickChatType.ADVENTURE;
|
||||
// @Getter
|
||||
// private QuickChat quickChat = new AdventureQuickChat();
|
||||
@Getter
|
||||
@Nullable
|
||||
private String currency = null;
|
||||
@Getter
|
||||
private ShopControlPanel shopControlPanelManager;
|
||||
// @Getter
|
||||
// private ShopControlPanel shopControlPanelManager;
|
||||
@Getter
|
||||
private CalendarWatcher calendarWatcher;
|
||||
@Getter
|
||||
@@ -271,6 +271,8 @@ public class QuickShop extends JavaPlugin {
|
||||
@Getter
|
||||
private WorldEditAdapter worldEditAdapter;
|
||||
private BukkitAudiences adventure;
|
||||
@Getter
|
||||
private final TextManager textManager = new TextManager(this);
|
||||
|
||||
/**
|
||||
* Use for mock bukkit
|
||||
@@ -542,8 +544,8 @@ public class QuickShop extends JavaPlugin {
|
||||
this.priceChangeRequiresFee = this.getConfig().getBoolean("shop.price-change-requires-fee");
|
||||
this.displayItemCheckTicks = this.getConfig().getInt("shop.display-items-check-ticks");
|
||||
this.allowStack = this.getConfig().getBoolean("shop.allow-stacks");
|
||||
this.quickChatType = QuickChatType.fromID(this.getConfig().getInt("chat-type"));
|
||||
this.quickChat = QuickChatType.createByType(this.quickChatType);
|
||||
// this.quickChatType = QuickChatType.fromID(this.getConfig().getInt("chat-type"));
|
||||
// this.quickChat = QuickChatType.createByType(this.quickChatType);
|
||||
this.currency = this.getConfig().getString("currency");
|
||||
if (StringUtils.isEmpty(this.currency)) {
|
||||
this.currency = null;
|
||||
@@ -787,8 +789,8 @@ public class QuickShop extends JavaPlugin {
|
||||
getLogger().info("Original author: Netherfoam, Timtower, KaiNoMood");
|
||||
getLogger().info("Let's start loading the plugin");
|
||||
this.adventure = BukkitAudiences.create(this);
|
||||
getLogger().info("Chat processor selected: " + this.quickChatType.name());
|
||||
|
||||
//getLogger().info("Chat processor selected: " + this.quickChatType.name());
|
||||
getLogger().info("Chat processor selected: Hardcoded Adventure Lib");
|
||||
/* Process Metrics and Sentry error reporter. */
|
||||
metrics = new Metrics(this, 3320);
|
||||
|
||||
@@ -814,11 +816,11 @@ public class QuickShop extends JavaPlugin {
|
||||
MsgUtil.loadItemi18n();
|
||||
MsgUtil.loadEnchi18n();
|
||||
MsgUtil.loadPotioni18n();
|
||||
shopControlPanelManager = new ShopControlPanel(this);
|
||||
this.previewProtectionLore = MsgUtil.getMessageOfflinePlayer("quickshop-gui-preview", null);
|
||||
if (this.previewProtectionLore == null || this.previewProtectionLore.isEmpty()) {
|
||||
this.previewProtectionLore = ChatColor.RED + "FIXME: DON'T SET THIS TO EMPTY STRING";
|
||||
}
|
||||
// shopControlPanelManager = new ShopControlPanel(this);
|
||||
// this.previewProtectionLore = MsgUtil.getMessageOfflinePlayer("quickshop-gui-preview", null);
|
||||
// if (this.previewProtectionLore == null || this.previewProtectionLore.isEmpty()) {
|
||||
// this.previewProtectionLore = ChatColor.RED + "FIXME: DON'T SET THIS TO EMPTY STRING";
|
||||
// }
|
||||
|
||||
/* Load 3rd party supports */
|
||||
load3rdParty();
|
||||
@@ -1059,7 +1061,7 @@ public class QuickShop extends JavaPlugin {
|
||||
metrics.addCustomChart(new Metrics.SimplePie("display_type", () -> DisplayItem.getNowUsing().name()));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("itemmatcher_type", () -> this.getItemMatcher().getName()));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("use_stack_item", () -> String.valueOf(this.isAllowStack())));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("chat_adapter", () -> this.getQuickChatType().name()));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("chat_adapter", () -> "Hardcoded Adventure"));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("event_adapter", () -> eventAdapter));
|
||||
metrics.addCustomChart(new Metrics.SingleLineChart("shops_created_on_all_servers", () -> this.getShopManager().getAllShops().size()));
|
||||
// Exp for stats, maybe i need improve this, so i add this.// Submit now!
|
||||
@@ -1963,4 +1965,8 @@ public class QuickShop extends JavaPlugin {
|
||||
}
|
||||
return this.adventure;
|
||||
}
|
||||
|
||||
public @NotNull TextManager text(){
|
||||
return textManager;
|
||||
}
|
||||
}
|
||||
@@ -1,92 +1,92 @@
|
||||
/*
|
||||
* This file is a part of project QuickShop, the name is QuickChat.java
|
||||
* Copyright (C) PotatoCraft Studio and contributors
|
||||
*
|
||||
* 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
|
||||
* (at your option) 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.maxgamer.quickshop.chat;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.shop.Shop;
|
||||
|
||||
/**
|
||||
* QuickChat is a system to allow us to processing plain text and also MineDown
|
||||
*/
|
||||
public interface QuickChat {
|
||||
/**
|
||||
* Send plain text to specified receiver
|
||||
*
|
||||
* @param receiver The receiver will receive this message
|
||||
* @param message The plain text to be sent
|
||||
*/
|
||||
void send(@NotNull CommandSender receiver, @Nullable String message);
|
||||
|
||||
/**
|
||||
* Send QuickComponent to specified receiver
|
||||
*
|
||||
* @param receiver The receiver will receive this message
|
||||
* @param component The plain text to be sent
|
||||
*/
|
||||
void send(@NotNull CommandSender receiver, @Nullable QuickComponent component);
|
||||
|
||||
/**
|
||||
* Send chat with hover-item to specified receiver
|
||||
*
|
||||
* @param player The PLAYER will receive this message
|
||||
* @param text The text will sent
|
||||
* @param itemStack The ItemStack will append to text in message
|
||||
*/
|
||||
void sendItemHologramChat(
|
||||
@NotNull Player player,
|
||||
@NotNull String text,
|
||||
@NotNull ItemStack itemStack);
|
||||
|
||||
@NotNull QuickComponent getItemHologramChat(@NotNull Shop shop, @NotNull ItemStack itemStack, @NotNull Player player, @NotNull String message);
|
||||
|
||||
/**
|
||||
* Create chat with hover-item to specified receiver
|
||||
*
|
||||
* @param player The PLAYER will receive this message
|
||||
* @param text The text will sent
|
||||
* @param itemStack The ItemStack will append to text in message
|
||||
* @return The QuickComponent created by this method
|
||||
*/
|
||||
@NotNull QuickComponent getItemTextComponent(@NotNull Player player, @NotNull ItemStack itemStack, @NotNull String text);
|
||||
|
||||
/**
|
||||
* Send click-run-command chat to specified receiver
|
||||
*
|
||||
* @param receiver The PLAYER will receive this message
|
||||
* @param message The text will sent
|
||||
* @param hoverText The will show when hover on chat
|
||||
* @param command The command when click to be run
|
||||
*/
|
||||
void sendExecutableChat(@NotNull CommandSender receiver, @NotNull String message, @NotNull String hoverText, @NotNull String command);
|
||||
|
||||
/**
|
||||
* Send click-suggest-command chat to specified receiver
|
||||
*
|
||||
* @param receiver The PLAYER will receive this message
|
||||
* @param message The text will sent
|
||||
* @param command The command when click to be suggest
|
||||
*/
|
||||
void sendSuggestedChat(@NotNull CommandSender receiver, @NotNull String message, @NotNull String hoverText, @NotNull String command);
|
||||
|
||||
}
|
||||
///*
|
||||
// * This file is a part of project QuickShop, the name is QuickChat.java
|
||||
// * Copyright (C) PotatoCraft Studio and contributors
|
||||
// *
|
||||
// * 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
|
||||
// * (at your option) 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 <http://www.gnu.org/licenses/>.
|
||||
// *
|
||||
// */
|
||||
//
|
||||
//package org.maxgamer.quickshop.chat;
|
||||
//
|
||||
//import org.bukkit.command.CommandSender;
|
||||
//import org.bukkit.entity.Player;
|
||||
//import org.bukkit.inventory.ItemStack;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//import org.jetbrains.annotations.Nullable;
|
||||
//import org.maxgamer.quickshop.shop.Shop;
|
||||
//
|
||||
///**
|
||||
// * QuickChat is a system to allow us to processing plain text and also MineDown
|
||||
// */
|
||||
//public interface QuickChat {
|
||||
// /**
|
||||
// * Send plain text to specified receiver
|
||||
// *
|
||||
// * @param receiver The receiver will receive this message
|
||||
// * @param message The plain text to be sent
|
||||
// */
|
||||
// void send(@NotNull CommandSender receiver, @Nullable String message);
|
||||
//
|
||||
// /**
|
||||
// * Send QuickComponent to specified receiver
|
||||
// *
|
||||
// * @param receiver The receiver will receive this message
|
||||
// * @param component The plain text to be sent
|
||||
// */
|
||||
// void send(@NotNull CommandSender receiver, @Nullable QuickComponent component);
|
||||
//
|
||||
// /**
|
||||
// * Send chat with hover-item to specified receiver
|
||||
// *
|
||||
// * @param player The PLAYER will receive this message
|
||||
// * @param text The text will sent
|
||||
// * @param itemStack The ItemStack will append to text in message
|
||||
// */
|
||||
// void sendItemHologramChat(
|
||||
// @NotNull Player player,
|
||||
// @NotNull String text,
|
||||
// @NotNull ItemStack itemStack);
|
||||
//
|
||||
// @NotNull QuickComponent getItemHologramChat(@NotNull Shop shop, @NotNull ItemStack itemStack, @NotNull Player player, @NotNull String message);
|
||||
//
|
||||
// /**
|
||||
// * Create chat with hover-item to specified receiver
|
||||
// *
|
||||
// * @param player The PLAYER will receive this message
|
||||
// * @param text The text will sent
|
||||
// * @param itemStack The ItemStack will append to text in message
|
||||
// * @return The QuickComponent created by this method
|
||||
// */
|
||||
// @NotNull QuickComponent getItemTextComponent(@NotNull Player player, @NotNull ItemStack itemStack, @NotNull String text);
|
||||
//
|
||||
// /**
|
||||
// * Send click-run-command chat to specified receiver
|
||||
// *
|
||||
// * @param receiver The PLAYER will receive this message
|
||||
// * @param message The text will sent
|
||||
// * @param hoverText The will show when hover on chat
|
||||
// * @param command The command when click to be run
|
||||
// */
|
||||
// void sendExecutableChat(@NotNull CommandSender receiver, @NotNull String message, @NotNull String hoverText, @NotNull String command);
|
||||
//
|
||||
// /**
|
||||
// * Send click-suggest-command chat to specified receiver
|
||||
// *
|
||||
// * @param receiver The PLAYER will receive this message
|
||||
// * @param message The text will sent
|
||||
// * @param command The command when click to be suggest
|
||||
// */
|
||||
// void sendSuggestedChat(@NotNull CommandSender receiver, @NotNull String message, @NotNull String hoverText, @NotNull String command);
|
||||
//
|
||||
//}
|
||||
@@ -1,70 +1,70 @@
|
||||
/*
|
||||
* This file is a part of project QuickShop, the name is QuickChatType.java
|
||||
* Copyright (C) PotatoCraft Studio and contributors
|
||||
*
|
||||
* 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
|
||||
* (at your option) 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.maxgamer.quickshop.chat;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.maxgamer.quickshop.chat.platform.minedown.AdventureQuickChat;
|
||||
|
||||
public enum QuickChatType {
|
||||
/*
|
||||
* BUNGEECHAT = Use the chat lib that Spigot offered.
|
||||
* ADVENTURE = Use the chat lib Adventure, it can resolve player disconnected issue but have no message output bug.
|
||||
*/
|
||||
//BUNGEECHAT(0),
|
||||
ADVENTURE(1);
|
||||
|
||||
private final int id;
|
||||
|
||||
QuickChatType(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public static @NotNull QuickChatType fromID(int id) {
|
||||
for (QuickChatType type : QuickChatType.values()) {
|
||||
if (type.id == id) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return ADVENTURE;
|
||||
}
|
||||
|
||||
public static int toID(@NotNull QuickChatType type) {
|
||||
return type.id;
|
||||
}
|
||||
|
||||
public static QuickChat createById(int id) {
|
||||
QuickChatType type = fromID(id);
|
||||
if (type == QuickChatType.ADVENTURE) {
|
||||
return new AdventureQuickChat();
|
||||
}
|
||||
return new AdventureQuickChat();
|
||||
// return new BungeeQuickChat();
|
||||
}
|
||||
|
||||
public static QuickChat createByType(QuickChatType type) {
|
||||
if (type == QuickChatType.ADVENTURE) {
|
||||
return new AdventureQuickChat();
|
||||
}
|
||||
return new AdventureQuickChat();
|
||||
}
|
||||
public int toID() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file is a part of project QuickShop, the name is QuickChatType.java
|
||||
// * Copyright (C) PotatoCraft Studio and contributors
|
||||
// *
|
||||
// * 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
|
||||
// * (at your option) 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 <http://www.gnu.org/licenses/>.
|
||||
// *
|
||||
// */
|
||||
//
|
||||
//package org.maxgamer.quickshop.chat;
|
||||
//
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//import org.maxgamer.quickshop.chat.platform.minedown.AdventureQuickChat;
|
||||
//
|
||||
//public enum QuickChatType {
|
||||
// /*
|
||||
// * BUNGEECHAT = Use the chat lib that Spigot offered.
|
||||
// * ADVENTURE = Use the chat lib Adventure, it can resolve player disconnected issue but have no message output bug.
|
||||
// */
|
||||
// //BUNGEECHAT(0),
|
||||
// ADVENTURE(1);
|
||||
//
|
||||
// private final int id;
|
||||
//
|
||||
// QuickChatType(int id) {
|
||||
// this.id = id;
|
||||
// }
|
||||
//
|
||||
// public static @NotNull QuickChatType fromID(int id) {
|
||||
// for (QuickChatType type : QuickChatType.values()) {
|
||||
// if (type.id == id) {
|
||||
// return type;
|
||||
// }
|
||||
// }
|
||||
// return ADVENTURE;
|
||||
// }
|
||||
//
|
||||
// public static int toID(@NotNull QuickChatType type) {
|
||||
// return type.id;
|
||||
// }
|
||||
//
|
||||
// public static QuickChat createById(int id) {
|
||||
// QuickChatType type = fromID(id);
|
||||
// if (type == QuickChatType.ADVENTURE) {
|
||||
// return new AdventureQuickChat();
|
||||
// }
|
||||
// return new AdventureQuickChat();
|
||||
// // return new BungeeQuickChat();
|
||||
// }
|
||||
//
|
||||
// public static QuickChat createByType(QuickChatType type) {
|
||||
// if (type == QuickChatType.ADVENTURE) {
|
||||
// return new AdventureQuickChat();
|
||||
// }
|
||||
// return new AdventureQuickChat();
|
||||
// }
|
||||
// public int toID() {
|
||||
// return id;
|
||||
// }
|
||||
//}
|
||||
@@ -1,41 +1,41 @@
|
||||
/*
|
||||
* This file is a part of project QuickShop, the name is QuickComponent.java
|
||||
* Copyright (C) PotatoCraft Studio and contributors
|
||||
*
|
||||
* 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
|
||||
* (at your option) 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.maxgamer.quickshop.chat;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Pack the MineDown
|
||||
*/
|
||||
public interface QuickComponent {
|
||||
/**
|
||||
* Gets QuickComponent object (BungeeChatComponent or AdventureChatComponent)
|
||||
*
|
||||
* @return The component
|
||||
*/
|
||||
@NotNull Object get();
|
||||
|
||||
/**
|
||||
* Sets QuickComponent object (BungeeChatComponent or AdventureChatComponent)
|
||||
*
|
||||
* @param component The component
|
||||
*/
|
||||
void set(@NotNull Object component);
|
||||
}
|
||||
///*
|
||||
// * This file is a part of project QuickShop, the name is QuickComponent.java
|
||||
// * Copyright (C) PotatoCraft Studio and contributors
|
||||
// *
|
||||
// * 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
|
||||
// * (at your option) 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 <http://www.gnu.org/licenses/>.
|
||||
// *
|
||||
// */
|
||||
//
|
||||
//package org.maxgamer.quickshop.chat;
|
||||
//
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//
|
||||
///**
|
||||
// * Pack the MineDown
|
||||
// */
|
||||
//public interface QuickComponent {
|
||||
// /**
|
||||
// * Gets QuickComponent object (BungeeChatComponent or AdventureChatComponent)
|
||||
// *
|
||||
// * @return The component
|
||||
// */
|
||||
// @NotNull Object get();
|
||||
//
|
||||
// /**
|
||||
// * Sets QuickComponent object (BungeeChatComponent or AdventureChatComponent)
|
||||
// *
|
||||
// * @param component The component
|
||||
// */
|
||||
// void set(@NotNull Object component);
|
||||
//}
|
||||
@@ -1,42 +1,42 @@
|
||||
/*
|
||||
* This file is a part of project QuickShop, the name is QuickComponentImpl.java
|
||||
* Copyright (C) PotatoCraft Studio and contributors
|
||||
*
|
||||
* 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
|
||||
* (at your option) 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.maxgamer.quickshop.chat;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Data
|
||||
public class QuickComponentImpl implements QuickComponent {
|
||||
private Object component;
|
||||
|
||||
@Override
|
||||
public @NotNull Object get() {
|
||||
return this.component;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(@NotNull Object component) {
|
||||
this.component = component;
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file is a part of project QuickShop, the name is QuickComponentImpl.java
|
||||
// * Copyright (C) PotatoCraft Studio and contributors
|
||||
// *
|
||||
// * 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
|
||||
// * (at your option) 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 <http://www.gnu.org/licenses/>.
|
||||
// *
|
||||
// */
|
||||
//
|
||||
//package org.maxgamer.quickshop.chat;
|
||||
//
|
||||
//import lombok.AllArgsConstructor;
|
||||
//import lombok.Builder;
|
||||
//import lombok.Data;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//
|
||||
//@AllArgsConstructor
|
||||
//@Builder
|
||||
//@Data
|
||||
//public class QuickComponentImpl implements QuickComponent {
|
||||
// private Object component;
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull Object get() {
|
||||
// return this.component;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void set(@NotNull Object component) {
|
||||
// this.component = component;
|
||||
// }
|
||||
//}
|
||||
+126
-126
@@ -1,126 +1,126 @@
|
||||
/*
|
||||
* This file is a part of project QuickShop, the name is AdventureQuickChat.java
|
||||
* Copyright (C) PotatoCraft Studio and contributors
|
||||
*
|
||||
* 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
|
||||
* (at your option) 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.maxgamer.quickshop.chat.platform.minedown;
|
||||
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.nbt.api.BinaryTagHolder;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.ComponentLike;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.chat.QuickChat;
|
||||
import org.maxgamer.quickshop.chat.QuickComponent;
|
||||
import org.maxgamer.quickshop.chat.QuickComponentImpl;
|
||||
import org.maxgamer.quickshop.shop.Shop;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
import org.maxgamer.quickshop.util.Util;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class AdventureQuickChat implements QuickChat {
|
||||
private final QuickShop plugin = QuickShop.getInstance();
|
||||
|
||||
@Override
|
||||
public void send(@NotNull CommandSender receiver, @Nullable String message) {
|
||||
if (StringUtils.isEmpty(message)) {
|
||||
return;
|
||||
}
|
||||
plugin.adventure().sender(receiver).sendMessage(LegacyComponentSerializer.legacySection().deserialize(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(@NotNull CommandSender receiver, @Nullable QuickComponent component) {
|
||||
if (component == null) {
|
||||
return;
|
||||
}
|
||||
if ((component.get() instanceof ComponentLike)) {
|
||||
plugin.adventure().sender(receiver).sendMessage(Identity.nil(), (ComponentLike) component.get());
|
||||
return;
|
||||
}
|
||||
Util.debugLog("Illegal component " + component.get().getClass().getName() + " sending to " + this.getClass().getName() + " processor, rejected.");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendItemHologramChat(@NotNull Player player, @NotNull String text, @NotNull ItemStack itemStack) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull QuickComponent getItemHologramChat(@NotNull Shop shop, @NotNull ItemStack itemStack, @NotNull Player player, @NotNull String message) {
|
||||
Component component = (Component) getItemTextComponent( player,itemStack, message).get();
|
||||
if (QuickShop.getPermissionManager().hasPermission(player, "quickshop.preview")) {
|
||||
component = component.clickEvent(ClickEvent.runCommand(MsgUtil.fillArgs(
|
||||
"/qs silentpreview {0}",
|
||||
shop.getRuntimeRandomUniqueId().toString())));
|
||||
}
|
||||
return new QuickComponentImpl(component);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull QuickComponent getItemTextComponent( @NotNull Player player,@NotNull ItemStack itemStack, @NotNull String normalText) {
|
||||
TextComponent errorComponent = Component.text(MsgUtil.getMessage("menu.item-holochat-error", player));
|
||||
try {
|
||||
String json = ItemNMS.saveJsonfromNMS(itemStack);
|
||||
if (json != null) {
|
||||
return new QuickComponentImpl(Component
|
||||
.text(normalText + " " + MsgUtil.getMessage("menu.preview", player))
|
||||
.hoverEvent(HoverEvent.showItem()));
|
||||
}
|
||||
} catch (Throwable throwable) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Failed to saving item to json for holochat", throwable);
|
||||
}
|
||||
return new QuickComponentImpl(errorComponent);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendExecutableChat(@NotNull CommandSender receiver, @NotNull String message, @NotNull String hoverText, @NotNull String command) {
|
||||
TextComponent component = Component.text(MsgUtil.getMessage("tableformat.left_begin", receiver) + message)
|
||||
.color(NamedTextColor.DARK_PURPLE)
|
||||
.clickEvent(ClickEvent.runCommand(command))
|
||||
.hoverEvent(HoverEvent.showText(Component.text(hoverText)));
|
||||
|
||||
audiences.sender(receiver).sendMessage(component);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendSuggestedChat(@NotNull CommandSender receiver, @NotNull String message, @NotNull String hoverText, @NotNull String command) {
|
||||
TextComponent component = Component.text(MsgUtil.getMessage("tableformat.left_begin", receiver) + message)
|
||||
.color(NamedTextColor.DARK_PURPLE)
|
||||
.clickEvent(ClickEvent.suggestCommand(command))
|
||||
.hoverEvent(HoverEvent.showText(Component.text(hoverText)));
|
||||
audiences.sender(receiver).sendMessage(component);
|
||||
}
|
||||
|
||||
}
|
||||
///*
|
||||
// * This file is a part of project QuickShop, the name is AdventureQuickChat.java
|
||||
// * Copyright (C) PotatoCraft Studio and contributors
|
||||
// *
|
||||
// * 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
|
||||
// * (at your option) 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 <http://www.gnu.org/licenses/>.
|
||||
// *
|
||||
// */
|
||||
//
|
||||
//package org.maxgamer.quickshop.chat.platform.minedown;
|
||||
//
|
||||
//import net.kyori.adventure.identity.Identity;
|
||||
//import net.kyori.adventure.key.Key;
|
||||
//import net.kyori.adventure.nbt.api.BinaryTagHolder;
|
||||
//import net.kyori.adventure.text.Component;
|
||||
//import net.kyori.adventure.text.ComponentLike;
|
||||
//import net.kyori.adventure.text.TextComponent;
|
||||
//import net.kyori.adventure.text.event.ClickEvent;
|
||||
//import net.kyori.adventure.text.event.HoverEvent;
|
||||
//import net.kyori.adventure.text.format.NamedTextColor;
|
||||
//import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
//import org.apache.commons.lang.StringUtils;
|
||||
//import org.bukkit.command.CommandSender;
|
||||
//import org.bukkit.entity.Player;
|
||||
//import org.bukkit.inventory.ItemStack;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//import org.jetbrains.annotations.Nullable;
|
||||
//import org.maxgamer.quickshop.QuickShop;
|
||||
//import org.maxgamer.quickshop.chat.QuickChat;
|
||||
//import org.maxgamer.quickshop.chat.QuickComponent;
|
||||
//import org.maxgamer.quickshop.chat.QuickComponentImpl;
|
||||
//import org.maxgamer.quickshop.shop.Shop;
|
||||
//import org.maxgamer.quickshop.util.MsgUtil;
|
||||
//import org.maxgamer.quickshop.util.Util;
|
||||
//
|
||||
//import java.util.logging.Level;
|
||||
//
|
||||
//public class AdventureQuickChat implements QuickChat {
|
||||
// private final QuickShop plugin = QuickShop.getInstance();
|
||||
//
|
||||
// @Override
|
||||
// public void send(@NotNull CommandSender receiver, @Nullable String message) {
|
||||
// if (StringUtils.isEmpty(message)) {
|
||||
// return;
|
||||
// }
|
||||
// plugin.adventure().sender(receiver).sendMessage(LegacyComponentSerializer.legacySection().deserialize(message));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void send(@NotNull CommandSender receiver, @Nullable QuickComponent component) {
|
||||
// if (component == null) {
|
||||
// return;
|
||||
// }
|
||||
// if ((component.get() instanceof ComponentLike)) {
|
||||
// plugin.adventure().sender(receiver).sendMessage(Identity.nil(), (ComponentLike) component.get());
|
||||
// return;
|
||||
// }
|
||||
// Util.debugLog("Illegal component " + component.get().getClass().getName() + " sending to " + this.getClass().getName() + " processor, rejected.");
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void sendItemHologramChat(@NotNull Player player, @NotNull String text, @NotNull ItemStack itemStack) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull QuickComponent getItemHologramChat(@NotNull Shop shop, @NotNull ItemStack itemStack, @NotNull Player player, @NotNull String message) {
|
||||
// Component component = (Component) getItemTextComponent( player,itemStack, message).get();
|
||||
// if (QuickShop.getPermissionManager().hasPermission(player, "quickshop.preview")) {
|
||||
// component = component.clickEvent(ClickEvent.runCommand(MsgUtil.fillArgs(
|
||||
// "/qs silentpreview {0}",
|
||||
// shop.getRuntimeRandomUniqueId().toString())));
|
||||
// }
|
||||
// return new QuickComponentImpl(component);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull QuickComponent getItemTextComponent( @NotNull Player player,@NotNull ItemStack itemStack, @NotNull String normalText) {
|
||||
// TextComponent errorComponent = Component.text(MsgUtil.getMessage("menu.item-holochat-error", player));
|
||||
// try {
|
||||
// String json = ItemNMS.saveJsonfromNMS(itemStack);
|
||||
// if (json != null) {
|
||||
// return new QuickComponentImpl(Component
|
||||
// .text(normalText + " " + MsgUtil.getMessage("menu.preview", player))
|
||||
// .hoverEvent(HoverEvent.showItem()));
|
||||
// }
|
||||
// } catch (Throwable throwable) {
|
||||
// plugin.getLogger().log(Level.SEVERE, "Failed to saving item to json for holochat", throwable);
|
||||
// }
|
||||
// return new QuickComponentImpl(errorComponent);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void sendExecutableChat(@NotNull CommandSender receiver, @NotNull String message, @NotNull String hoverText, @NotNull String command) {
|
||||
// TextComponent component = Component.text(MsgUtil.getMessage("tableformat.left_begin", receiver) + message)
|
||||
// .color(NamedTextColor.DARK_PURPLE)
|
||||
// .clickEvent(ClickEvent.runCommand(command))
|
||||
// .hoverEvent(HoverEvent.showText(Component.text(hoverText)));
|
||||
//
|
||||
// audiences.sender(receiver).sendMessage(component);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void sendSuggestedChat(@NotNull CommandSender receiver, @NotNull String message, @NotNull String hoverText, @NotNull String command) {
|
||||
// TextComponent component = Component.text(MsgUtil.getMessage("tableformat.left_begin", receiver) + message)
|
||||
// .color(NamedTextColor.DARK_PURPLE)
|
||||
// .clickEvent(ClickEvent.suggestCommand(command))
|
||||
// .hoverEvent(HoverEvent.showText(Component.text(hoverText)));
|
||||
// audiences.sender(receiver).sendMessage(component);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -397,17 +397,17 @@ public class CommandManager implements TabCompleter, CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
if (!isAdapt(container, sender)) {
|
||||
MsgUtil.sendMessage(sender, "command-type-mismatch", container.getExecutorType().getSimpleName());
|
||||
plugin.text().of(sender, "command-type-mismatch", container.getExecutorType().getSimpleName()).send();
|
||||
return true;
|
||||
}
|
||||
List<String> requirePermissions = container.getPermissions();
|
||||
List<String> selectivePermissions = container.getSelectivePermissions();
|
||||
if (!checkPermissions(sender, commandLabel, passThroughArgs, requirePermissions, PermissionType.REQUIRE, Action.EXECUTE)) {
|
||||
MsgUtil.sendMessage(sender, "no-permission");
|
||||
plugin.text().of(sender, "no-permission").send();
|
||||
return true;
|
||||
}
|
||||
if (!checkPermissions(sender, commandLabel, passThroughArgs, selectivePermissions, PermissionType.SELECTIVE, Action.EXECUTE)) {
|
||||
MsgUtil.sendMessage(sender, "no-permission");
|
||||
plugin.text().of(sender, "no-permission").send();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,12 +37,12 @@ public class SubCommand_Amount implements CommandHandler<Player> {
|
||||
@Override
|
||||
public void onCommand(@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
|
||||
if (cmdArg.length < 1) {
|
||||
MsgUtil.sendMessage(sender, "command.wrong-args");
|
||||
plugin.text().of(sender, "command.wrong-args").send();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.getShopManager().getActions().containsKey(sender.getUniqueId())) {
|
||||
MsgUtil.sendMessage(sender, "no-pending-action");
|
||||
plugin.text().of(sender, "no-pending-action").send();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.command.CommandHandler;
|
||||
import org.maxgamer.quickshop.shop.Shop;
|
||||
import org.maxgamer.quickshop.shop.ShopType;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
import org.maxgamer.quickshop.util.Util;
|
||||
|
||||
@AllArgsConstructor
|
||||
@@ -41,7 +40,7 @@ public class SubCommand_Buy implements CommandHandler<Player> {
|
||||
BlockIterator bIt = new BlockIterator(sender, 10);
|
||||
|
||||
if (!bIt.hasNext()) {
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -53,14 +52,14 @@ public class SubCommand_Buy implements CommandHandler<Player> {
|
||||
if (shop.getModerator().isModerator(sender.getUniqueId()) || QuickShop.getPermissionManager().hasPermission(sender, "quickshop.other.control")) {
|
||||
shop.setShopType(ShopType.BUYING);
|
||||
shop.update();
|
||||
MsgUtil.sendMessage(sender, "command.now-buying", Util.getItemStackName(shop.getItem()));
|
||||
plugin.text().of(sender, "command.now-buying", Util.getItemStackName(shop.getItem())).send();
|
||||
} else {
|
||||
MsgUtil.sendMessage(sender, "not-managed-shop");
|
||||
plugin.text().of(sender, "not-managed-shop").send();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public class SubCommand_Clean implements CommandHandler<CommandSender> {
|
||||
|
||||
@Override
|
||||
public void onCommand(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
|
||||
MsgUtil.sendMessage(sender, "command.cleaning");
|
||||
plugin.text().of(sender, "command.cleaning").send();
|
||||
|
||||
final List<Shop> pendingRemoval = new ArrayList<>();
|
||||
int i = 0;
|
||||
@@ -70,7 +70,7 @@ public class SubCommand_Clean implements CommandHandler<CommandSender> {
|
||||
}
|
||||
|
||||
MsgUtil.clean();
|
||||
MsgUtil.sendMessage(sender, "command.cleaned", Integer.toString(i));
|
||||
plugin.text().of(sender, "command.cleaned", Integer.toString(i)).send();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -77,18 +77,18 @@ public class SubCommand_Create implements CommandHandler<Player> {
|
||||
BlockIterator bIt = new BlockIterator(sender, 10);
|
||||
ItemStack item;
|
||||
if (cmdArg.length < 1) {
|
||||
MsgUtil.sendMessage(sender, "command.wrong-args");
|
||||
plugin.text().of(sender, "command.wrong-args").send();
|
||||
return;
|
||||
} else if (cmdArg.length == 1) {
|
||||
item = sender.getInventory().getItemInMainHand();
|
||||
if (item.getType().isAir()) {
|
||||
MsgUtil.sendMessage(sender, "no-anythings-in-your-hand");
|
||||
plugin.text().of(sender, "no-anythings-in-your-hand").send();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
Material material = matchMaterial(cmdArg[1]);
|
||||
if (material == null) {
|
||||
MsgUtil.sendMessage(sender, "item-not-exist", cmdArg[1]);
|
||||
plugin.text().of(sender, "item-not-exist", cmdArg[1]).send();
|
||||
return;
|
||||
}
|
||||
if (cmdArg.length > 2 && QuickShop.getPermissionManager().hasPermission(sender, "quicshop.create.stack") && plugin.isAllowStack()) {
|
||||
@@ -118,7 +118,7 @@ public class SubCommand_Create implements CommandHandler<Player> {
|
||||
|
||||
Result result = plugin.getPermissionChecker().canBuild(sender, b);
|
||||
if (!result.isSuccess()) {
|
||||
MsgUtil.sendMessage(sender, "3rd-plugin-build-check-failed", result.getMessage());
|
||||
plugin.text().of(sender, "3rd-plugin-build-check-failed", result.getMessage()).send();
|
||||
Util.debugLog("Failed to create shop because the protection check has failed! Reason:" + result.getMessage());
|
||||
return;
|
||||
}
|
||||
@@ -135,14 +135,14 @@ public class SubCommand_Create implements CommandHandler<Player> {
|
||||
|
||||
if (Util.isDoubleChest(b.getBlockData())
|
||||
&& !QuickShop.getPermissionManager().hasPermission(sender, "quickshop.create.double")) {
|
||||
MsgUtil.sendMessage(sender, "no-double-chests");
|
||||
plugin.text().of(sender, "no-double-chests").send();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Util.isBlacklisted(item)
|
||||
&& !QuickShop.getPermissionManager()
|
||||
.hasPermission(sender, "quickshop.bypass." + item.getType().name())) {
|
||||
MsgUtil.sendMessage(sender, "blacklisted-item");
|
||||
plugin.text().of(sender, "blacklisted-item").send();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ public class SubCommand_Create implements CommandHandler<Player> {
|
||||
plugin.getShopManager().handleChat(sender, price);
|
||||
return;
|
||||
}
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.command.CommandHandler;
|
||||
import org.maxgamer.quickshop.shop.Shop;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -51,28 +50,28 @@ public class SubCommand_Currency implements CommandHandler<Player> {
|
||||
if (shop.getModerator().isModerator(sender.getUniqueId()) || QuickShop.getPermissionManager().hasPermission(sender, "quickshop.other.currency")) {
|
||||
if (cmdArg.length < 1) {
|
||||
shop.setCurrency(null);
|
||||
MsgUtil.sendMessage(sender, "currency-unset");
|
||||
plugin.text().of(sender, "currency-unset").send();
|
||||
return;
|
||||
}
|
||||
if (!plugin.getEconomy().supportCurrency()) {
|
||||
MsgUtil.sendMessage(sender, "currency-not-support");
|
||||
plugin.text().of(sender, "currency-not-support").send();
|
||||
return;
|
||||
}
|
||||
if (!plugin.getEconomy().hasCurrency(Objects.requireNonNull(shop.getLocation().getWorld()), cmdArg[0])) {
|
||||
MsgUtil.sendMessage(sender, "currency-not-exists");
|
||||
plugin.text().of(sender, "currency-not-exists").send();
|
||||
return;
|
||||
}
|
||||
shop.setCurrency(cmdArg[0]);
|
||||
MsgUtil.sendMessage(sender, "currency-set", cmdArg[0]);
|
||||
plugin.text().of(sender, "currency-set", cmdArg[0]).send();
|
||||
return;
|
||||
|
||||
} else {
|
||||
MsgUtil.sendMessage(sender, "not-managed-shop");
|
||||
plugin.text().of(sender, "not-managed-shop").send();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -91,7 +91,7 @@ public class SubCommand_Debug implements CommandHandler<CommandSender> {
|
||||
case "signs":
|
||||
final BlockIterator bIt = new BlockIterator((LivingEntity) sender, 10);
|
||||
if (!bIt.hasNext()) {
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
return;
|
||||
}
|
||||
while (bIt.hasNext()) {
|
||||
@@ -123,14 +123,14 @@ public class SubCommand_Debug implements CommandHandler<CommandSender> {
|
||||
plugin.getConfig().set("dev-mode", false);
|
||||
plugin.saveConfig();
|
||||
plugin.reload();
|
||||
MsgUtil.sendMessage(sender, "command.now-nolonger-debuging");
|
||||
plugin.text().of(sender, "command.now-nolonger-debuging").send();
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getConfig().set("dev-mode", true);
|
||||
plugin.saveConfig();
|
||||
plugin.reload();
|
||||
MsgUtil.sendMessage(sender, "command.now-debuging");
|
||||
plugin.text().of(sender, "command.now-debuging").send();
|
||||
}
|
||||
|
||||
public void printHandlerList(@NotNull CommandSender sender, String event) {
|
||||
|
||||
@@ -29,7 +29,6 @@ import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.command.CommandHandler;
|
||||
import org.maxgamer.quickshop.shop.ContainerShop;
|
||||
import org.maxgamer.quickshop.shop.Shop;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class SubCommand_Empty implements CommandHandler<Player> {
|
||||
@@ -41,7 +40,7 @@ public class SubCommand_Empty implements CommandHandler<Player> {
|
||||
BlockIterator bIt = new BlockIterator(sender, 10);
|
||||
|
||||
if (!bIt.hasNext()) {
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -62,15 +61,14 @@ public class SubCommand_Empty implements CommandHandler<Player> {
|
||||
}
|
||||
|
||||
cs.getInventory().clear();
|
||||
MsgUtil.sendMessage(sender, "empty-success");
|
||||
plugin.text().of(sender, "empty-success").send();
|
||||
} else {
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public class SubCommand_Find implements CommandHandler<Player> {
|
||||
@Override
|
||||
public void onCommand(@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
|
||||
if (cmdArg.length == 0) {
|
||||
MsgUtil.sendMessage(sender, "command.no-type-given");
|
||||
plugin.text().of(sender, "command.no-type-given").send();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public class SubCommand_Find implements CommandHandler<Player> {
|
||||
}
|
||||
//Check if no shops found
|
||||
if (aroundShops.isEmpty()) {
|
||||
MsgUtil.sendMessage(sender, "no-nearby-shop", lookFor);
|
||||
plugin.text().of(sender, "no-nearby-shop", lookFor).send();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public class SubCommand_Find implements CommandHandler<Player> {
|
||||
Location lookAt = closest.getKey().getLocation().clone().add(0.5, 0.5, 0.5);
|
||||
PaperLib.teleportAsync(sender, Util.lookAt(sender.getEyeLocation(), lookAt).add(0, -1.62, 0),
|
||||
PlayerTeleportEvent.TeleportCause.UNKNOWN);
|
||||
MsgUtil.sendMessage(sender, "nearby-shop-this-way", String.valueOf(closest.getValue().intValue()));
|
||||
plugin.text().of(sender, "nearby-shop-this-way", String.valueOf(closest.getValue().intValue())).send();
|
||||
} else {
|
||||
StringBuilder stringBuilder = new StringBuilder(MsgUtil.getMessage("nearby-shop-header", sender, lookFor)).append("\n");
|
||||
for (Map.Entry<Shop, Double> shopDoubleEntry : sortedShops) {
|
||||
|
||||
@@ -42,7 +42,7 @@ public class SubCommand_Help implements CommandHandler<CommandSender> {
|
||||
|
||||
|
||||
private void sendHelp(@NotNull CommandSender s, @NotNull String commandLabel) {
|
||||
MsgUtil.sendMessage(s, "command.description.title");
|
||||
plugin.text().of(s, "command.description.title").send();
|
||||
|
||||
commandPrintingLoop:
|
||||
for (CommandContainer container : plugin.getCommandManager().getCmds()) {
|
||||
|
||||
@@ -29,7 +29,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.command.CommandHandler;
|
||||
import org.maxgamer.quickshop.shop.Shop;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
import org.maxgamer.quickshop.util.PriceLimiter;
|
||||
import org.maxgamer.quickshop.util.Util;
|
||||
|
||||
@@ -42,7 +41,7 @@ public class SubCommand_Item implements CommandHandler<Player> {
|
||||
BlockIterator bIt = new BlockIterator(sender, 10);
|
||||
// Loop through every block they're looking at upto 10 blocks away
|
||||
if (!bIt.hasNext()) {
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
return;
|
||||
}
|
||||
while (bIt.hasNext()) {
|
||||
@@ -51,16 +50,16 @@ public class SubCommand_Item implements CommandHandler<Player> {
|
||||
|
||||
if (shop != null) {
|
||||
if (!shop.getModerator().isModerator(sender.getUniqueId()) && !QuickShop.getPermissionManager().hasPermission(sender, "quickshop.other.item")) {
|
||||
MsgUtil.sendMessage(sender, "not-managed-shop");
|
||||
plugin.text().of(sender, "not-managed-shop").send();
|
||||
return;
|
||||
}
|
||||
ItemStack itemStack = sender.getInventory().getItemInMainHand().clone();
|
||||
if (itemStack.getType() == Material.AIR) {
|
||||
MsgUtil.sendMessage(sender, "command.no-trade-item");
|
||||
plugin.text().of(sender, "command.no-trade-item").send();
|
||||
return;
|
||||
}
|
||||
if (Util.isBlacklisted(itemStack) && !QuickShop.getPermissionManager().hasPermission(sender, "quickshop.bypass." + itemStack.getType().name())) {
|
||||
MsgUtil.sendMessage(sender, "blacklisted-item");
|
||||
plugin.text().of(sender, "blacklisted-item").send();
|
||||
return;
|
||||
}
|
||||
if (!plugin.isAllowStack() && !QuickShop.getPermissionManager().hasPermission(sender, "quickshop.create.stacks")) {
|
||||
@@ -73,17 +72,17 @@ public class SubCommand_Item implements CommandHandler<Player> {
|
||||
plugin.getConfig().getBoolean("whole-number-prices-only"));
|
||||
PriceLimiter.CheckResult checkResult = limiter.check(itemStack, shop.getPrice());
|
||||
if (checkResult.getStatus() != PriceLimiter.Status.PASS) {
|
||||
MsgUtil.sendMessage(sender, "restricted-prices", Util.getItemStackName(shop.getItem()),
|
||||
plugin.text().of(sender, "restricted-prices", Util.getItemStackName(shop.getItem()),
|
||||
String.valueOf(checkResult.getMin()),
|
||||
String.valueOf(checkResult.getMax()));
|
||||
String.valueOf(checkResult.getMax())).send();
|
||||
return;
|
||||
}
|
||||
shop.setItem(itemStack);
|
||||
plugin.getQuickChat().send(sender, plugin.getQuickChat().getItemHologramChat(shop, shop.getItem(), sender, MsgUtil.getMessage("command.trade-item-now", sender, Integer.toString(shop.getItem().getAmount()), Util.getItemStackName(shop.getItem()))));
|
||||
plugin.text().of(sender,"command.trade-item-now", Integer.toString(shop.getItem().getAmount()),Util.getItemStackName(shop.getItem())).send();
|
||||
return;
|
||||
}
|
||||
}
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public class SubCommand_Price implements CommandHandler<Player> {
|
||||
@Override
|
||||
public void onCommand(@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
|
||||
if (cmdArg.length < 1) {
|
||||
MsgUtil.sendMessage(sender, "no-price-given");
|
||||
plugin.text().of(sender, "no-price-given").send();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -57,12 +57,12 @@ public class SubCommand_Price implements CommandHandler<Player> {
|
||||
} catch (NumberFormatException ex) {
|
||||
// No number input
|
||||
Util.debugLog(ex.getMessage());
|
||||
MsgUtil.sendMessage(sender, "not-a-number", cmdArg[0]);
|
||||
plugin.text().of(sender, "not-a-number", cmdArg[0]).send();
|
||||
return;
|
||||
}
|
||||
// No number input
|
||||
if (Double.isInfinite(price) || Double.isNaN(price)) {
|
||||
MsgUtil.sendMessage(sender, "not-a-number", cmdArg[0]);
|
||||
plugin.text().of(sender, "not-a-number", cmdArg[0]).send();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class SubCommand_Price implements CommandHandler<Player> {
|
||||
final BlockIterator bIt = new BlockIterator(sender, 10);
|
||||
// Loop through every block they're looking at upto 10 blocks away
|
||||
if (!bIt.hasNext()) {
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -100,23 +100,23 @@ public class SubCommand_Price implements CommandHandler<Player> {
|
||||
|
||||
if (shop.getPrice() == price) {
|
||||
// Stop here if there isn't a price change
|
||||
MsgUtil.sendMessage(sender, "no-price-change");
|
||||
plugin.text().of(sender, "no-price-change").send();
|
||||
return;
|
||||
}
|
||||
|
||||
PriceLimiter.CheckResult checkResult = limiter.check(shop.getItem(), price);
|
||||
if (checkResult.getStatus() == PriceLimiter.Status.REACHED_PRICE_MIN_LIMIT) {
|
||||
MsgUtil.sendMessage(sender, "price-too-cheap", (format) ? MsgUtil.decimalFormat(checkResult.getMin()) : Double.toString(checkResult.getMin()));
|
||||
plugin.text().of(sender, "price-too-cheap", (format) ? MsgUtil.decimalFormat(checkResult.getMin()) : Double.toString(checkResult.getMin())).send();
|
||||
return;
|
||||
}
|
||||
if (checkResult.getStatus() == PriceLimiter.Status.REACHED_PRICE_MAX_LIMIT) {
|
||||
MsgUtil.sendMessage(sender, "price-too-high", (format) ? MsgUtil.decimalFormat(checkResult.getMax()) : Double.toString(checkResult.getMax()));
|
||||
plugin.text().of(sender, "price-too-high", (format) ? MsgUtil.decimalFormat(checkResult.getMax()) : Double.toString(checkResult.getMax())).send();
|
||||
return;
|
||||
}
|
||||
if (checkResult.getStatus() == PriceLimiter.Status.PRICE_RESTRICTED) {
|
||||
MsgUtil.sendMessage(sender, "restricted-prices", Util.getItemStackName(shop.getItem()),
|
||||
plugin.text().of(sender, "restricted-prices", Util.getItemStackName(shop.getItem()),
|
||||
String.valueOf(checkResult.getMin()),
|
||||
String.valueOf(checkResult.getMax()));
|
||||
String.valueOf(checkResult.getMax())).send();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -132,13 +132,11 @@ public class SubCommand_Price implements CommandHandler<Player> {
|
||||
if (!transaction.failSafeCommit()) {
|
||||
EconomyTransaction.TransactionSteps steps = transaction.getSteps();
|
||||
if (steps == EconomyTransaction.TransactionSteps.CHECK) {
|
||||
MsgUtil.sendMessage(sender,
|
||||
|
||||
"you-cant-afford-to-change-price", plugin.getEconomy().format(fee, shop.getLocation().getWorld(), shop.getCurrency()));
|
||||
plugin.text().of(sender,
|
||||
"you-cant-afford-to-change-price", plugin.getEconomy().format(fee, shop.getLocation().getWorld(), shop.getCurrency())).send();
|
||||
} else {
|
||||
MsgUtil.sendMessage(sender,
|
||||
|
||||
"fee-charged-for-price-change", plugin.getEconomy().format(fee, shop.getLocation().getWorld(), shop.getCurrency()));
|
||||
plugin.text().of(sender,
|
||||
"fee-charged-for-price-change", plugin.getEconomy().format(fee, shop.getLocation().getWorld(), shop.getCurrency())).send();
|
||||
plugin.getLogger().log(Level.WARNING, "QuickShop can't pay taxes to the configured tax account! Please set the tax account name in the config.yml to an existing player: " + transaction.getLastError());
|
||||
}
|
||||
return;
|
||||
@@ -147,8 +145,8 @@ public class SubCommand_Price implements CommandHandler<Player> {
|
||||
// Update the shop
|
||||
shop.setPrice(price);
|
||||
shop.update();
|
||||
MsgUtil.sendMessage(sender,
|
||||
"price-is-now", plugin.getEconomy().format(shop.getPrice(), Objects.requireNonNull(shop.getLocation().getWorld()), shop.getCurrency()));
|
||||
plugin.text().of(sender,
|
||||
"price-is-now", plugin.getEconomy().format(shop.getPrice(), Objects.requireNonNull(shop.getLocation().getWorld()), shop.getCurrency())).send();
|
||||
// Chest shops can be double shops.
|
||||
if (!(shop instanceof ContainerShop)) {
|
||||
return;
|
||||
@@ -169,17 +167,17 @@ public class SubCommand_Price implements CommandHandler<Player> {
|
||||
|
||||
if (cs.isSelling()) {
|
||||
if (cs.getPrice() < nextTo.getPrice()) {
|
||||
MsgUtil.sendMessage(sender, "buying-more-than-selling");
|
||||
plugin.text().of(sender, "buying-more-than-selling").send();
|
||||
}
|
||||
}
|
||||
// Buying
|
||||
else if (cs.getPrice() > nextTo.getPrice()) {
|
||||
MsgUtil.sendMessage(sender, "buying-more-than-selling");
|
||||
plugin.text().of(sender, "buying-more-than-selling").send();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -41,7 +41,7 @@ public class SubCommand_Refill implements CommandHandler<Player> {
|
||||
@Override
|
||||
public void onCommand(@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
|
||||
if (cmdArg.length < 1) {
|
||||
MsgUtil.sendMessage(sender, "command.no-amount-given");
|
||||
plugin.text().of(sender, "command.no-amount-given").send();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class SubCommand_Refill implements CommandHandler<Player> {
|
||||
final BlockIterator bIt = new BlockIterator(sender, 10);
|
||||
|
||||
if (!bIt.hasNext()) {
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
return;
|
||||
}
|
||||
while (bIt.hasNext()) {
|
||||
@@ -65,16 +65,15 @@ public class SubCommand_Refill implements CommandHandler<Player> {
|
||||
if (cmdArg[0].equals(plugin.getConfig().getString("shop.word-for-trade-all-items"))) {
|
||||
add = shop.getRemainingSpace();
|
||||
} else {
|
||||
MsgUtil.sendMessage(sender, "thats-not-a-number");
|
||||
plugin.text().of(sender, "thats-not-a-number").send();
|
||||
return;
|
||||
}
|
||||
}
|
||||
shop.add(shop.getItem(), add);
|
||||
MsgUtil.sendMessage(sender, "refill-success");
|
||||
plugin.text().of(sender, "refill-success").send();
|
||||
return;
|
||||
}
|
||||
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.command.CommandHandler;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class SubCommand_Reload implements CommandHandler<CommandSender> {
|
||||
@@ -34,7 +33,7 @@ public class SubCommand_Reload implements CommandHandler<CommandSender> {
|
||||
@Override
|
||||
public void onCommand(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
|
||||
//MsgUtil.sendMessage(sender, "server-crash-warning");
|
||||
MsgUtil.sendMessage(sender, "command.reloading");
|
||||
plugin.text().of(sender, "command.reloading").send();
|
||||
plugin.reloadConfig();
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.command.CommandHandler;
|
||||
import org.maxgamer.quickshop.shop.Shop;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class SubCommand_Remove implements CommandHandler<Player> {
|
||||
@@ -39,7 +38,7 @@ public class SubCommand_Remove implements CommandHandler<Player> {
|
||||
BlockIterator bIt = new BlockIterator(sender, 10);
|
||||
|
||||
if (!bIt.hasNext()) {
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -55,13 +54,13 @@ public class SubCommand_Remove implements CommandHandler<Player> {
|
||||
shop.delete();
|
||||
plugin.log("Deleting shop " + shop + " as requested by the /qs remove command.");
|
||||
} else {
|
||||
MsgUtil.sendMessage(sender, "no-permission");
|
||||
plugin.text().of(sender, "no-permission").send();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,7 +28,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.command.CommandHandler;
|
||||
import org.maxgamer.quickshop.shop.Shop;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -54,14 +53,14 @@ public class SubCommand_RemoveAll implements CommandHandler<CommandSender> {
|
||||
}
|
||||
}
|
||||
if (shopOwner == null) {
|
||||
MsgUtil.sendMessage(sender, "unknown-player");
|
||||
plugin.text().of(sender, "unknown-player").send();
|
||||
return;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
if (!shopOwner.equals(sender)) { //Non-self shop
|
||||
if (!sender.hasPermission("quickshop.removeall.other")) {
|
||||
MsgUtil.sendMessage(sender, "no-permission");
|
||||
plugin.text().of(sender, "no-permission").send();
|
||||
return;
|
||||
}
|
||||
for (Shop shop : tempList) {
|
||||
@@ -73,7 +72,7 @@ public class SubCommand_RemoveAll implements CommandHandler<CommandSender> {
|
||||
}
|
||||
} else { //Self shop
|
||||
if (!sender.hasPermission("quickshop.removeall.self")) {
|
||||
MsgUtil.sendMessage(sender, "no-permission");
|
||||
plugin.text().of(sender, "no-permission").send();
|
||||
return;
|
||||
}
|
||||
if (!(sender instanceof OfflinePlayer)) {
|
||||
@@ -88,9 +87,9 @@ public class SubCommand_RemoveAll implements CommandHandler<CommandSender> {
|
||||
}
|
||||
}
|
||||
}
|
||||
MsgUtil.sendMessage(sender, "command.some-shops-removed", Integer.toString(i));
|
||||
plugin.text().of(sender, "command.some-shops-removed", Integer.toString(i)).send();
|
||||
} else {
|
||||
MsgUtil.sendMessage(sender, "command.no-owner-given");
|
||||
plugin.text().of(sender, "command.no-owner-given").send();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.command.CommandHandler;
|
||||
import org.maxgamer.quickshop.shop.Shop;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
import org.maxgamer.quickshop.util.Util;
|
||||
|
||||
@AllArgsConstructor
|
||||
@@ -38,12 +37,12 @@ public class SubCommand_RemoveWorld implements CommandHandler<CommandSender> {
|
||||
@Override
|
||||
public void onCommand(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
|
||||
if (cmdArg.length < 1) {
|
||||
MsgUtil.sendMessage(sender, "command.no-world-given");
|
||||
plugin.text().of(sender, "command.no-world-given").send();
|
||||
return;
|
||||
}
|
||||
World world = Bukkit.getWorld(cmdArg[0]);
|
||||
if (world == null) {
|
||||
MsgUtil.sendMessage(sender, "world-not-exists", cmdArg[0]);
|
||||
plugin.text().of(sender, "world-not-exists", cmdArg[0]).send();
|
||||
return;
|
||||
}
|
||||
int shopsDeleted = 0;
|
||||
@@ -55,7 +54,7 @@ public class SubCommand_RemoveWorld implements CommandHandler<CommandSender> {
|
||||
}
|
||||
Util.debugLog("Successfully deleted all shops in world " + cmdArg[0] + "!");
|
||||
|
||||
MsgUtil.sendMessage(sender, "shops-removed-in-world", String.valueOf(shopsDeleted), world.getName());
|
||||
plugin.text().of(sender, "shops-removed-in-world", String.valueOf(shopsDeleted), world.getName()).send();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public class SubCommand_Reset implements CommandHandler<CommandSender> {
|
||||
@SneakyThrows
|
||||
public void onCommand(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
|
||||
if (cmdArg.length < 1) {
|
||||
MsgUtil.sendMessage(sender, "command.no-type-given");
|
||||
plugin.text().of(sender, "command.no-type-given").send();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class SubCommand_Reset implements CommandHandler<CommandSender> {
|
||||
MsgUtil.loadItemi18n();
|
||||
MsgUtil.loadEnchi18n();
|
||||
MsgUtil.loadPotioni18n();
|
||||
MsgUtil.sendMessage(sender, "complete");
|
||||
plugin.text().of(sender, "complete").send();
|
||||
break;
|
||||
case "config":
|
||||
File config = new File(plugin.getDataFolder(), "config.yml");
|
||||
@@ -73,16 +73,16 @@ public class SubCommand_Reset implements CommandHandler<CommandSender> {
|
||||
plugin.reloadConfig();
|
||||
plugin.getServer().getPluginManager().disablePlugin(plugin);
|
||||
plugin.getServer().getPluginManager().enablePlugin(plugin);
|
||||
MsgUtil.sendMessage(sender, "complete");
|
||||
plugin.text().of(sender, "complete").send();
|
||||
break;
|
||||
case "messages":
|
||||
File msgs = new File(plugin.getDataFolder(), "messages.json");
|
||||
msgs.delete();
|
||||
MsgUtil.loadI18nFile();
|
||||
MsgUtil.sendMessage(sender, "complete");
|
||||
plugin.text().of(sender, "complete").send();
|
||||
break;
|
||||
default:
|
||||
MsgUtil.sendMessage(sender, "command.wrong-args");
|
||||
plugin.text().of(sender, "command.wrong-args").send();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.command.CommandHandler;
|
||||
import org.maxgamer.quickshop.shop.Shop;
|
||||
import org.maxgamer.quickshop.shop.ShopType;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
import org.maxgamer.quickshop.util.Util;
|
||||
|
||||
@AllArgsConstructor
|
||||
@@ -41,7 +40,7 @@ public class SubCommand_Sell implements CommandHandler<Player> {
|
||||
BlockIterator bIt = new BlockIterator(sender, 10);
|
||||
|
||||
if (!bIt.hasNext()) {
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -53,14 +52,14 @@ public class SubCommand_Sell implements CommandHandler<Player> {
|
||||
if (shop.getModerator().isModerator(sender.getUniqueId()) || QuickShop.getPermissionManager().hasPermission(sender, "quickshop.other.control")) {
|
||||
shop.setShopType(ShopType.SELLING);
|
||||
shop.update();
|
||||
MsgUtil.sendMessage(sender, "command.now-selling", Util.getItemStackName(shop.getItem()));
|
||||
plugin.text().of(sender, "command.now-selling", Util.getItemStackName(shop.getItem())).send();
|
||||
} else {
|
||||
MsgUtil.sendMessage(sender, "not-managed-shop");
|
||||
plugin.text().of(sender, "not-managed-shop").send();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,7 +28,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.command.CommandHandler;
|
||||
import org.maxgamer.quickshop.shop.Shop;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -44,14 +43,14 @@ public class SubCommand_SetOwner implements CommandHandler<Player> {
|
||||
public void onCommand(@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
|
||||
|
||||
if (cmdArg.length < 1) {
|
||||
MsgUtil.sendMessage(sender, "command.no-owner-given");
|
||||
plugin.text().of(sender, "command.no-owner-given").send();
|
||||
return;
|
||||
}
|
||||
|
||||
final BlockIterator bIt = new BlockIterator(sender, 10);
|
||||
|
||||
if (!bIt.hasNext()) {
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -65,15 +64,15 @@ public class SubCommand_SetOwner implements CommandHandler<Player> {
|
||||
|
||||
@SuppressWarnings("deprecation") final OfflinePlayer newShopOwner = plugin.getServer().getOfflinePlayer(cmdArg[0]);
|
||||
if (newShopOwner.getName() == null) {
|
||||
MsgUtil.sendMessage(sender, "unknown-player");
|
||||
plugin.text().of(sender, "unknown-player").send();
|
||||
return;
|
||||
}
|
||||
shop.setOwner(newShopOwner.getUniqueId());
|
||||
MsgUtil.sendMessage(sender, "command.new-owner", newShopOwner.getName());
|
||||
plugin.text().of(sender, "command.new-owner", newShopOwner.getName()).send();
|
||||
return;
|
||||
}
|
||||
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -46,14 +46,14 @@ public class SubCommand_SilentBuy implements CommandHandler<Player> {
|
||||
Shop shop = plugin.getShopManager().getShopFromRuntimeRandomUniqueId(UUID.fromString(cmdArg[0]));
|
||||
|
||||
if (shop == null || !shop.getModerator().isModerator(sender.getUniqueId())) {
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
return;
|
||||
}
|
||||
|
||||
shop.setShopType(ShopType.BUYING);
|
||||
shop.update();
|
||||
MsgUtil.sendControlPanelInfo(sender, shop);
|
||||
MsgUtil.sendMessage(sender, "command.now-buying", Util.getItemStackName(shop.getItem()));
|
||||
plugin.text().of(sender, "command.now-buying", Util.getItemStackName(shop.getItem())).send();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class SubCommand_SilentEmpty implements CommandHandler<Player> {
|
||||
Shop shop = plugin.getShopManager().getShopFromRuntimeRandomUniqueId(UUID.fromString(cmdArg[0]));
|
||||
|
||||
if (!(shop instanceof ContainerShop)) {
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class SubCommand_SilentEmpty implements CommandHandler<Player> {
|
||||
|
||||
inventory.clear();
|
||||
MsgUtil.sendControlPanelInfo(sender, shop);
|
||||
MsgUtil.sendMessage(sender, "empty-success");
|
||||
plugin.text().of(sender, "empty-success").send();
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -26,7 +26,6 @@ import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.command.CommandHandler;
|
||||
import org.maxgamer.quickshop.shop.ContainerShop;
|
||||
import org.maxgamer.quickshop.shop.Shop;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
import org.maxgamer.quickshop.util.Util;
|
||||
|
||||
import java.util.UUID;
|
||||
@@ -47,7 +46,8 @@ public class SubCommand_SilentPreview implements CommandHandler<Player> {
|
||||
|
||||
|
||||
if (!(shop instanceof ContainerShop)) {
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
// This should never happen
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
return;
|
||||
}
|
||||
shop.openPreview(sender);
|
||||
|
||||
+2
-3
@@ -25,7 +25,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.command.CommandHandler;
|
||||
import org.maxgamer.quickshop.shop.Shop;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
import org.maxgamer.quickshop.util.Util;
|
||||
|
||||
import java.util.UUID;
|
||||
@@ -45,13 +44,13 @@ public class SubCommand_SilentRemove implements CommandHandler<Player> {
|
||||
Shop shop = plugin.getShopManager().getShopFromRuntimeRandomUniqueId(UUID.fromString(cmdArg[0]));
|
||||
|
||||
if (shop == null) {
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!shop.getModerator().isModerator(sender.getUniqueId())
|
||||
&& !QuickShop.getPermissionManager().hasPermission(sender, "quickshop.other.destroy")) {
|
||||
MsgUtil.sendMessage(sender, "no-permission");
|
||||
plugin.text().of(sender, "no-permission").send();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,14 +46,14 @@ public class SubCommand_SilentSell implements CommandHandler<Player> {
|
||||
Shop shop = plugin.getShopManager().getShopFromRuntimeRandomUniqueId(UUID.fromString(cmdArg[0]));
|
||||
|
||||
if (shop == null || !shop.getModerator().isModerator(sender.getUniqueId())) {
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
return;
|
||||
}
|
||||
|
||||
shop.setShopType(ShopType.SELLING);
|
||||
shop.update();
|
||||
MsgUtil.sendControlPanelInfo(sender, shop);
|
||||
MsgUtil.sendMessage(sender,
|
||||
"command.now-selling", Util.getItemStackName(shop.getItem()));
|
||||
plugin.text().of(sender,
|
||||
"command.now-selling", Util.getItemStackName(shop.getItem())).send();
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -44,7 +44,7 @@ public class SubCommand_SilentUnlimited implements CommandHandler<Player> {
|
||||
Shop shop = plugin.getShopManager().getShopFromRuntimeRandomUniqueId(UUID.fromString(cmdArg[0]));
|
||||
|
||||
if (shop == null) {
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -53,16 +53,16 @@ public class SubCommand_SilentUnlimited implements CommandHandler<Player> {
|
||||
MsgUtil.sendControlPanelInfo(sender, shop);
|
||||
|
||||
if (shop.isUnlimited()) {
|
||||
MsgUtil.sendMessage(sender, "command.toggle-unlimited.unlimited");
|
||||
plugin.text().of(sender, "command.toggle-unlimited.unlimited").send();
|
||||
if (plugin.getConfig().getBoolean("unlimited-shop-owner-change")) {
|
||||
plugin.getShopManager().migrateOwnerToUnlimitedShopOwner(shop);
|
||||
MsgUtil.sendMessage(sender, "unlimited-shop-owner-changed", plugin.getShopManager().getCacheUnlimitedShopAccount().getName());
|
||||
plugin.text().of(sender, "unlimited-shop-owner-changed", plugin.getShopManager().getCacheUnlimitedShopAccount().getName()).send();
|
||||
}
|
||||
return;
|
||||
}
|
||||
MsgUtil.sendMessage(sender, "command.toggle-unlimited.limited");
|
||||
plugin.text().of(sender, "command.toggle-unlimited.limited").send();
|
||||
if (plugin.getConfig().getBoolean("unlimited-shop-owner-change")) {
|
||||
MsgUtil.sendMessage(sender, "unlimited-shop-owner-keeped");
|
||||
plugin.text().of(sender, "unlimited-shop-owner-keeped").send();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,20 +43,20 @@ public class SubCommand_Size implements CommandHandler<Player> {
|
||||
@Override
|
||||
public void onCommand(@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
|
||||
if (cmdArg.length < 1) {
|
||||
MsgUtil.sendMessage(sender, "command.bulk-size-not-set");
|
||||
plugin.text().of(sender, "command.bulk-size-not-set").send();
|
||||
return;
|
||||
}
|
||||
int amount;
|
||||
try {
|
||||
amount = Integer.parseInt(cmdArg[0]);
|
||||
} catch (NumberFormatException e) {
|
||||
MsgUtil.sendMessage(sender, "not-a-integer", cmdArg[0]);
|
||||
plugin.text().of(sender, "not-a-integer", cmdArg[0]).send();
|
||||
return;
|
||||
}
|
||||
final BlockIterator bIt = new BlockIterator(sender, 10);
|
||||
// Loop through every block they're looking at upto 10 blocks away
|
||||
if (!bIt.hasNext()) {
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
return;
|
||||
}
|
||||
while (bIt.hasNext()) {
|
||||
@@ -65,7 +65,7 @@ public class SubCommand_Size implements CommandHandler<Player> {
|
||||
if (shop != null) {
|
||||
if (shop.getModerator().isModerator(sender.getUniqueId()) || sender.hasPermission("quickshop.other.amount")) {
|
||||
if (amount <= 0 || amount > Util.getItemMaxStackSize(shop.getItem().getType())) {
|
||||
MsgUtil.sendMessage(sender, "command.invalid-bulk-amount", Integer.toString(amount));
|
||||
plugin.text().of(sender, "command.invalid-bulk-amount", Integer.toString(amount)).send();
|
||||
return;
|
||||
}
|
||||
ItemStack pendingItemStack = shop.getItem().clone();
|
||||
@@ -77,20 +77,20 @@ public class SubCommand_Size implements CommandHandler<Player> {
|
||||
plugin.getConfig().getBoolean("whole-number-prices-only"));
|
||||
PriceLimiter.CheckResult checkResult = limiter.check(pendingItemStack, shop.getPrice());
|
||||
if (checkResult.getStatus() != PriceLimiter.Status.PASS) {
|
||||
MsgUtil.sendMessage(sender, "restricted-prices", Util.getItemStackName(shop.getItem()),
|
||||
plugin.text().of(sender, "restricted-prices", Util.getItemStackName(shop.getItem()),
|
||||
String.valueOf(checkResult.getMin()),
|
||||
String.valueOf(checkResult.getMax()));
|
||||
String.valueOf(checkResult.getMax())).send();
|
||||
return;
|
||||
}
|
||||
shop.setItem(pendingItemStack);
|
||||
MsgUtil.sendMessage(sender, "command.bulk-size-now", Integer.toString(shop.getItem().getAmount()), Util.getItemStackName(shop.getItem()));
|
||||
plugin.text().of(sender, "command.bulk-size-now", Integer.toString(shop.getItem().getAmount()), Util.getItemStackName(shop.getItem())).send();
|
||||
return;
|
||||
} else {
|
||||
MsgUtil.sendMessage(sender, "not-managed-shop");
|
||||
plugin.text().of(sender, "not-managed-shop").send();
|
||||
}
|
||||
}
|
||||
}
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class SubCommand_Staff implements CommandHandler<Player> {
|
||||
public void onCommand(@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
|
||||
BlockIterator bIt = new BlockIterator(sender, 10);
|
||||
if (!bIt.hasNext()) {
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
return;
|
||||
}
|
||||
while (bIt.hasNext()) {
|
||||
@@ -64,7 +64,7 @@ public class SubCommand_Staff implements CommandHandler<Player> {
|
||||
switch (cmdArg[0]) {
|
||||
case "clear":
|
||||
shop.clearStaffs();
|
||||
MsgUtil.sendMessage(sender, "shop-staff-cleared");
|
||||
plugin.text().of(sender, "shop-staff-cleared").send();
|
||||
return;
|
||||
case "list":
|
||||
final List<UUID> staffs = shop.getStaffs();
|
||||
@@ -85,7 +85,7 @@ public class SubCommand_Staff implements CommandHandler<Player> {
|
||||
case "add":
|
||||
case "del":
|
||||
default:
|
||||
MsgUtil.sendMessage(sender, "command.wrong-args");
|
||||
plugin.text().of(sender, "command.wrong-args").send();
|
||||
return;
|
||||
}
|
||||
case 2:
|
||||
@@ -99,24 +99,24 @@ public class SubCommand_Staff implements CommandHandler<Player> {
|
||||
switch (cmdArg[0]) {
|
||||
case "add":
|
||||
shop.addStaff(offlinePlayer.getUniqueId());
|
||||
MsgUtil.sendMessage(sender, "shop-staff-added", offlinePlayerName);
|
||||
plugin.text().of(sender, "shop-staff-added", offlinePlayerName).send();
|
||||
return;
|
||||
case "del":
|
||||
shop.delStaff(offlinePlayer.getUniqueId());
|
||||
MsgUtil.sendMessage(sender,
|
||||
"shop-staff-deleted", offlinePlayerName);
|
||||
plugin.text().of(sender,
|
||||
"shop-staff-deleted", offlinePlayerName).send();
|
||||
return;
|
||||
default:
|
||||
MsgUtil.sendMessage(sender, "command.wrong-args");
|
||||
plugin.text().of(sender, "command.wrong-args").send();
|
||||
return;
|
||||
}
|
||||
default:
|
||||
MsgUtil.sendMessage(sender, "command.wrong-args");
|
||||
plugin.text().of(sender, "command.wrong-args").send();
|
||||
return;
|
||||
}
|
||||
}
|
||||
//no match shop
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -45,7 +45,7 @@ public class SubCommand_SuperCreate implements CommandHandler<Player> {
|
||||
public void onCommand(@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
|
||||
ItemStack item = sender.getInventory().getItemInMainHand();
|
||||
if (item.getType() == Material.AIR) {
|
||||
MsgUtil.sendMessage(sender, "no-anythings-in-your-hand");
|
||||
plugin.text().of(sender, "no-anythings-in-your-hand").send();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -66,10 +66,10 @@ public class SubCommand_SuperCreate implements CommandHandler<Player> {
|
||||
final Info info = new Info(b.getLocation(), ShopAction.CREATE, sender.getInventory().getItemInMainHand(), b.getRelative(sender.getFacing().getOppositeFace()));
|
||||
|
||||
plugin.getShopManager().getActions().put(sender.getUniqueId(), info);
|
||||
MsgUtil.sendMessage(sender, "how-much-to-trade-for", Util.getItemStackName(item), Integer.toString(plugin.isAllowStack() && QuickShop.getPermissionManager().hasPermission(sender, "quickshop.create.stacks") ? item.getAmount() : 1));
|
||||
plugin.text().of(sender, "how-much-to-trade-for", Util.getItemStackName(item), Integer.toString(plugin.isAllowStack() && QuickShop.getPermissionManager().hasPermission(sender, "quickshop.create.stacks") ? item.getAmount() : 1)).send();
|
||||
return;
|
||||
}
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -61,10 +61,10 @@ public class SubCommand_Transfer implements CommandHandler<ConsoleCommandSender>
|
||||
for (Shop shop : shopList) {
|
||||
shop.setOwner(targetPlayerUUID);
|
||||
}
|
||||
MsgUtil.sendMessage(sender, "command.transfer-success", Integer.toString(shopList.size()), targetPlayerName);
|
||||
plugin.text().of(sender, "command.transfer-success", Integer.toString(shopList.size()), targetPlayerName).send();
|
||||
} else if (cmdArg.length == 2) {
|
||||
if (!QuickShop.getPermissionManager().hasPermission(sender, "quickshop.transfer.other")) {
|
||||
MsgUtil.sendMessage(sender, "no-permission");
|
||||
plugin.text().of(sender, "no-permission").send();
|
||||
return;
|
||||
}
|
||||
//noinspection deprecation
|
||||
@@ -85,10 +85,10 @@ public class SubCommand_Transfer implements CommandHandler<ConsoleCommandSender>
|
||||
for (Shop shop : shopList) {
|
||||
shop.setOwner(targetPlayerUUID);
|
||||
}
|
||||
MsgUtil.sendMessage(sender, "command.transfer-success-other", Integer.toString(shopList.size()), fromPlayerName, targetPlayerName);
|
||||
plugin.text().of(sender, "command.transfer-success-other", Integer.toString(shopList.size()), fromPlayerName, targetPlayerName).send();
|
||||
|
||||
} else {
|
||||
MsgUtil.sendMessage(sender, "command.wrong-args");
|
||||
plugin.text().of(sender, "command.wrong-args").send();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.command.CommandHandler;
|
||||
import org.maxgamer.quickshop.shop.Shop;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class SubCommand_Unlimited implements CommandHandler<Player> {
|
||||
@@ -39,7 +38,7 @@ public class SubCommand_Unlimited implements CommandHandler<Player> {
|
||||
BlockIterator bIt = new BlockIterator(sender, 10);
|
||||
|
||||
if (!bIt.hasNext()) {
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -52,20 +51,20 @@ public class SubCommand_Unlimited implements CommandHandler<Player> {
|
||||
shop.setUnlimited(!shop.isUnlimited());
|
||||
shop.update();
|
||||
if (shop.isUnlimited()) {
|
||||
MsgUtil.sendMessage(sender, "command.toggle-unlimited.unlimited");
|
||||
plugin.text().of(sender, "command.toggle-unlimited.unlimited").send();
|
||||
if (plugin.getConfig().getBoolean("unlimited-shop-owner-change")) {
|
||||
plugin.getShopManager().migrateOwnerToUnlimitedShopOwner(shop);
|
||||
MsgUtil.sendMessage(sender, "unlimited-shop-owner-changed", plugin.getShopManager().getCacheUnlimitedShopAccount().getName());
|
||||
plugin.text().of(sender, "unlimited-shop-owner-changed", plugin.getShopManager().getCacheUnlimitedShopAccount().getName()).send();
|
||||
}
|
||||
return;
|
||||
}
|
||||
MsgUtil.sendMessage(sender, "command.toggle-unlimited.limited");
|
||||
plugin.text().of(sender, "command.toggle-unlimited.limited").send();
|
||||
if (plugin.getConfig().getBoolean("unlimited-shop-owner-change")) {
|
||||
MsgUtil.sendMessage(sender, "unlimited-shop-owner-keeped");
|
||||
plugin.text().of(sender, "unlimited-shop-owner-keeped").send();
|
||||
}
|
||||
return;
|
||||
}
|
||||
MsgUtil.sendMessage(sender, "not-looking-at-shop");
|
||||
plugin.text().of(sender, "not-looking-at-shop").send();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -84,14 +84,14 @@ public class BlockListener extends ProtectionListenerBase {
|
||||
if (p.getInventory().getItemInMainHand().getType() == Material.GOLDEN_AXE) {
|
||||
if (getPlugin().getConfig().getBoolean("shop.disable-super-tool")) {
|
||||
e.setCancelled(true);
|
||||
MsgUtil.sendMessage(p, "supertool-is-disabled");
|
||||
plugin.text().of(p, "supertool-is-disabled").send();
|
||||
return;
|
||||
}
|
||||
MsgUtil.sendMessage(p, "break-shop-use-supertool");
|
||||
plugin.text().of(p, "break-shop-use-supertool").send();
|
||||
return;
|
||||
}
|
||||
e.setCancelled(true);
|
||||
MsgUtil.sendMessage(p, "no-creative-break", MsgUtil.getItemi18n(Material.GOLDEN_AXE.name()));
|
||||
plugin.text().of(p, "no-creative-break", MsgUtil.getItemi18n(Material.GOLDEN_AXE.name())).send();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ public class BlockListener extends ProtectionListenerBase {
|
||||
|
||||
plugin.log("Deleting shop " + shop + " request by block break.");
|
||||
shop.delete();
|
||||
MsgUtil.sendMessage(p, "success-removed-shop");
|
||||
plugin.text().of(p, "success-removed-shop").send();
|
||||
} else if (Util.isWallSign(b.getType())) {
|
||||
BlockState state = PaperLib.getBlockState(b, false).getState();
|
||||
if (state instanceof Sign) {
|
||||
@@ -128,16 +128,16 @@ public class BlockListener extends ProtectionListenerBase {
|
||||
if (p.getInventory().getItemInMainHand().getType() == Material.GOLDEN_AXE) {
|
||||
if (getPlugin().getConfig().getBoolean("shop.disable-super-tool")) {
|
||||
e.setCancelled(true);
|
||||
MsgUtil.sendMessage(p, "supertool-is-disabled");
|
||||
plugin.text().of(p, "supertool-is-disabled").send();
|
||||
return;
|
||||
}
|
||||
MsgUtil.sendMessage(p, "break-shop-use-supertool");
|
||||
plugin.text().of(p, "break-shop-use-supertool").send();
|
||||
plugin.log("Deleting shop " + shop + " request by block break (super tool).");
|
||||
shop.delete();
|
||||
return;
|
||||
}
|
||||
e.setCancelled(true);
|
||||
MsgUtil.sendMessage(p, "no-creative-break", MsgUtil.getItemi18n(Material.GOLDEN_AXE.name()));
|
||||
plugin.text().of(p, "no-creative-break", MsgUtil.getItemi18n(Material.GOLDEN_AXE.name())).send();
|
||||
return;
|
||||
}
|
||||
//Allow Shop owner break the shop sign(for sign replacement)
|
||||
@@ -200,7 +200,7 @@ public class BlockListener extends ProtectionListenerBase {
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
if (!shop.getModerator().isModerator(player.getUniqueId())) {
|
||||
MsgUtil.sendMessage(player, "not-managed-shop");
|
||||
plugin.text().of(player, "not-managed-shop").send();
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@@ -261,11 +261,11 @@ public class BlockListener extends ProtectionListenerBase {
|
||||
if (shop != null) {
|
||||
if (!QuickShop.getPermissionManager().hasPermission(player, "quickshop.create.double")) {
|
||||
e.setCancelled(true);
|
||||
MsgUtil.sendMessage(player, "no-double-chests");
|
||||
plugin.text().of(player, "no-double-chests").send();
|
||||
|
||||
} else if (!shop.getModerator().isModerator(player.getUniqueId())) {
|
||||
e.setCancelled(true);
|
||||
MsgUtil.sendMessage(player, "not-managed-shop");
|
||||
plugin.text().of(player, "not-managed-shop").send();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.event.*;
|
||||
import org.maxgamer.quickshop.shop.ShopType;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
import org.maxgamer.quickshop.util.Util;
|
||||
import org.maxgamer.quickshop.util.reload.ReloadResult;
|
||||
import org.maxgamer.quickshop.util.reload.ReloadStatus;
|
||||
@@ -65,7 +64,7 @@ public class InternalListener extends QSListener {
|
||||
public void shopCreate(ShopCreateEvent event) {
|
||||
if (isForbidden(event.getShop().getLocation().getBlock().getType(), event.getShop().getItem().getType())) {
|
||||
event.setCancelled(true);
|
||||
MsgUtil.sendMessage(event.getCreator(), "forbidden-vanilla-behavior");
|
||||
plugin.text().of(event.getCreator(), "forbidden-vanilla-behavior").send();
|
||||
return;
|
||||
}
|
||||
if (loggingAction) {
|
||||
@@ -113,7 +112,7 @@ public class InternalListener extends QSListener {
|
||||
public void shopPrePurchase(ShopPurchaseEvent event) {
|
||||
if (isForbidden(event.getShop().getLocation().getBlock().getType(), event.getShop().getItem().getType())) {
|
||||
event.setCancelled(true);
|
||||
MsgUtil.sendMessage(event.getPurchaser(), "forbidden-vanilla-behavior");
|
||||
plugin.text().of(event.getPurchaser(), "forbidden-vanilla-behavior").send();
|
||||
return;
|
||||
}
|
||||
if (loggingBalance) {
|
||||
@@ -172,7 +171,7 @@ public class InternalListener extends QSListener {
|
||||
if (event.getPurchaser().equals(event.getShop().getOwner())) {
|
||||
Player player = Bukkit.getPlayer(event.getPurchaser());
|
||||
if (player != null) {
|
||||
MsgUtil.sendMessage(player, "shop-owner-self-trade");
|
||||
plugin.text().of(player, "shop-owner-self-trade").send();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.Cache;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.shop.Shop;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
import org.maxgamer.quickshop.util.Util;
|
||||
import org.maxgamer.quickshop.util.reload.ReloadResult;
|
||||
import org.maxgamer.quickshop.util.reload.ReloadStatus;
|
||||
@@ -95,7 +94,7 @@ public class LockListener extends ProtectionListenerBase {
|
||||
if (!shop.getOwner().equals(p.getUniqueId())
|
||||
&& !QuickShop.getPermissionManager().hasPermission(p, "quickshop.other.destroy")) {
|
||||
e.setCancelled(true);
|
||||
MsgUtil.sendMessage(p, "no-permission");
|
||||
plugin.text().of(p, "no-permission").send();
|
||||
}
|
||||
} else if (Util.isWallSign(b.getType())) {
|
||||
if (b instanceof Sign) {
|
||||
@@ -123,7 +122,7 @@ public class LockListener extends ProtectionListenerBase {
|
||||
if (!shop.getOwner().equals(p.getUniqueId())
|
||||
&& !QuickShop.getPermissionManager().hasPermission(p, "quickshop.other.destroy")) {
|
||||
e.setCancelled(true);
|
||||
MsgUtil.sendMessage(p, "no-permission");
|
||||
plugin.text().of(p, "no-permission").send();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,7 +146,7 @@ public class LockListener extends ProtectionListenerBase {
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
if (!shop.getModerator().isOwner(player.getUniqueId())) {
|
||||
MsgUtil.sendMessage(player, "that-is-locked");
|
||||
plugin.text().of(player, "that-is-locked").send();
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@@ -179,10 +178,10 @@ public class LockListener extends ProtectionListenerBase {
|
||||
|
||||
if (!shop.getModerator().isModerator(p.getUniqueId())) {
|
||||
if (QuickShop.getPermissionManager().hasPermission(p, "quickshop.other.open")) {
|
||||
MsgUtil.sendMessage(p, "bypassing-lock");
|
||||
plugin.text().of(p, "bypassing-lock").send();
|
||||
return;
|
||||
}
|
||||
MsgUtil.sendMessage(p, "that-is-locked");
|
||||
plugin.text().of(p, "that-is-locked").send();
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@@ -206,11 +205,11 @@ public class LockListener extends ProtectionListenerBase {
|
||||
}
|
||||
|
||||
if (QuickShop.getPermissionManager().hasPermission(p, "quickshop.other.open")) {
|
||||
MsgUtil.sendMessage(p, "bypassing-lock");
|
||||
plugin.text().of(p, "bypassing-lock").send();
|
||||
return;
|
||||
}
|
||||
|
||||
MsgUtil.sendMessage(p, "that-is-locked");
|
||||
plugin.text().of(p, "that-is-locked").send();
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -202,9 +202,9 @@ public class PlayerListener extends QSListener {
|
||||
itemAmount = 0;
|
||||
}
|
||||
if (shop.isStackingShop()) {
|
||||
MsgUtil.sendMessage(p, "how-many-buy-stack", Integer.toString(shop.getItem().getAmount()), Integer.toString(itemAmount));
|
||||
plugin.text().of(p, "how-many-buy-stack", Integer.toString(shop.getItem().getAmount()), Integer.toString(itemAmount)).send();
|
||||
} else {
|
||||
MsgUtil.sendMessage(p, "how-many-buy", Integer.toString(itemAmount));
|
||||
plugin.text().of(p, "how-many-buy", Integer.toString(itemAmount)).send();
|
||||
}
|
||||
} else {
|
||||
final double ownerBalance = eco.getBalance(shop.getOwner(), shop.getLocation().getWorld(), shop.getCurrency());
|
||||
@@ -226,9 +226,9 @@ public class PlayerListener extends QSListener {
|
||||
items = 0;
|
||||
}
|
||||
if (shop.isStackingShop()) {
|
||||
MsgUtil.sendMessage(p, "how-many-sell-stack", Integer.toString(shop.getItem().getAmount()), Integer.toString(items));
|
||||
plugin.text().of(p, "how-many-sell-stack", Integer.toString(shop.getItem().getAmount()), Integer.toString(items)).send();
|
||||
} else {
|
||||
MsgUtil.sendMessage(p, "how-many-sell", Integer.toString(items));
|
||||
plugin.text().of(p, "how-many-sell", Integer.toString(items)).send();
|
||||
}
|
||||
}
|
||||
// Add the new action
|
||||
@@ -254,13 +254,13 @@ public class PlayerListener extends QSListener {
|
||||
}
|
||||
if (Util.isDoubleChest(b.getBlockData())
|
||||
&& !QuickShop.getPermissionManager().hasPermission(p, "quickshop.create.double")) {
|
||||
MsgUtil.sendMessage(p, "no-double-chests");
|
||||
plugin.text().of(p, "no-double-chests").send();
|
||||
return;
|
||||
}
|
||||
if (Util.isBlacklisted(item)
|
||||
&& !QuickShop.getPermissionManager()
|
||||
.hasPermission(p, "quickshop.bypass." + item.getType().name())) {
|
||||
MsgUtil.sendMessage(p, "blacklisted-item");
|
||||
plugin.text().of(p, "blacklisted-item").send();
|
||||
return;
|
||||
}
|
||||
if (b.getType() == Material.ENDER_CHEST //FIXME: Need a better impl
|
||||
@@ -289,7 +289,7 @@ public class PlayerListener extends QSListener {
|
||||
final Info info = new Info(b.getLocation(), ShopAction.CREATE, e.getItem(), last);
|
||||
|
||||
plugin.getShopManager().getActions().put(p.getUniqueId(), info);
|
||||
MsgUtil.sendMessage(p, "how-much-to-trade-for", Util.getItemStackName(Objects.requireNonNull(e.getItem())), Integer.toString(plugin.isAllowStack() && QuickShop.getPermissionManager().hasPermission(p, "quickshop.create.stacks") ? item.getAmount() : 1));
|
||||
plugin.text().of(p, "how-much-to-trade-for", Util.getItemStackName(Objects.requireNonNull(e.getItem())), Integer.toString(plugin.isAllowStack() && QuickShop.getPermissionManager().hasPermission(p, "quickshop.create.stacks") ? item.getAmount() : 1)).send();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,10 +352,10 @@ public class PlayerListener extends QSListener {
|
||||
final Location loc2 = p.getLocation();
|
||||
if (loc1.getWorld() != loc2.getWorld() || loc1.distanceSquared(loc2) > 25) {
|
||||
if (info.getAction() == ShopAction.BUY) {
|
||||
MsgUtil.sendMessage(p, "shop-purchase-cancelled");
|
||||
plugin.text().of(p, "shop-purchase-cancelled").send();
|
||||
Util.debugLog(p.getName() + " too far with the shop location.");
|
||||
} else if (info.getAction() == ShopAction.CREATE) {
|
||||
MsgUtil.sendMessage(p, "shop-creation-cancelled");
|
||||
plugin.text().of(p, "shop-creation-cancelled").send();
|
||||
Util.debugLog(p.getName() + " too far with the shop location.");
|
||||
}
|
||||
plugin.getShopManager().getActions().remove(p.getUniqueId());
|
||||
|
||||
@@ -488,14 +488,13 @@ public class ContainerShop implements Shop {
|
||||
OfflinePlayer player = plugin.getServer().getOfflinePlayer(this.getOwner());
|
||||
String name = player.getName();
|
||||
if (name == null || name.isEmpty()) {
|
||||
name = MsgUtil.getMessageOfflinePlayer(
|
||||
"unknown-owner", player);
|
||||
name = plugin.text().of( "unknown-owner").forLocale();
|
||||
}
|
||||
if (forceUsername) {
|
||||
return name;
|
||||
}
|
||||
if (isUnlimited()) {
|
||||
return MsgUtil.getMessageOfflinePlayer("admin-shop", player);
|
||||
return plugin.text().of("admin-shop").forLocale();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
@@ -615,7 +614,7 @@ public class ContainerShop implements Shop {
|
||||
//Line 1
|
||||
OfflinePlayer player = plugin.getServer().getOfflinePlayer(this.getOwner());
|
||||
String statusStringKey = inventoryAvailable() ? "signs.status-available" : "signs.status-unavailable";
|
||||
lines[0] = MsgUtil.getMessageOfflinePlayer("signs.header", player, this.ownerName(false), MsgUtil.getMessageOfflinePlayer(statusStringKey, player));
|
||||
lines[0] = plugin.text().of("signs.header", this.ownerName(false), plugin.text().of(statusStringKey).forLocale()).forLocale();
|
||||
|
||||
//Line 2
|
||||
String tradingStringKey;
|
||||
@@ -641,27 +640,27 @@ public class ContainerShop implements Shop {
|
||||
switch (shopRemaining) {
|
||||
//Unlimited
|
||||
case -1:
|
||||
lines[1] = MsgUtil.getMessageOfflinePlayer(tradingStringKey, player, MsgUtil.getMessageOfflinePlayer("signs.unlimited", player));
|
||||
lines[1] = plugin.text().of(tradingStringKey, plugin.text().of("signs.unlimited").forLocale()).forLocale();
|
||||
break;
|
||||
//No remaining
|
||||
case 0:
|
||||
lines[1] = MsgUtil.getMessageOfflinePlayer(noRemainingStringKey, player);
|
||||
lines[1] =plugin.text().of(noRemainingStringKey).forLocale();
|
||||
break;
|
||||
//Has remaining
|
||||
default:
|
||||
lines[1] = MsgUtil.getMessageOfflinePlayer(tradingStringKey, player, Integer.toString(shopRemaining));
|
||||
lines[1] = plugin.text().of(tradingStringKey, Integer.toString(shopRemaining)).forLocale();
|
||||
}
|
||||
|
||||
//line 3
|
||||
lines[2] = MsgUtil.getMessageOfflinePlayer("signs.item", player, Util.getItemStackName(this.getItem()));
|
||||
lines[2] = plugin.text().of("signs.item", Util.getItemStackName(this.getItem())).forLocale();
|
||||
|
||||
//line 4
|
||||
if (this.isStackingShop()) {
|
||||
lines[3] = MsgUtil.getMessageOfflinePlayer("signs.stack-price", player,
|
||||
lines[3] = plugin.text().of("signs.stack-price",
|
||||
Util.format(this.getPrice(), this), Integer.toString(item.getAmount()),
|
||||
Util.getItemStackName(item));
|
||||
Util.getItemStackName(item)).forLocale();
|
||||
} else {
|
||||
lines[3] = MsgUtil.getMessageOfflinePlayer("signs.price", player, Util.format(this.getPrice(), this));
|
||||
lines[3] = plugin.text().of("signs.price", Util.format(this.getPrice(), this)).forLocale();
|
||||
}
|
||||
|
||||
//New pattern for recognizing shop sign
|
||||
|
||||
@@ -21,6 +21,7 @@ package org.maxgamer.quickshop.shop;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -37,6 +38,7 @@ import org.maxgamer.quickshop.util.holder.QuickShopPreviewGUIHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A class to create a GUI item preview quickly
|
||||
@@ -50,6 +52,9 @@ public class InventoryPreview implements Listener {
|
||||
private final QuickShop plugin = QuickShop.getInstance();
|
||||
@Nullable
|
||||
private Inventory inventory;
|
||||
private final String previewStr;
|
||||
private static final NamespacedKey key = new NamespacedKey(QuickShop.getInstance(), "preview-item");
|
||||
;
|
||||
|
||||
/**
|
||||
* Create a preview item GUI for a player.
|
||||
@@ -62,20 +67,21 @@ public class InventoryPreview implements Listener {
|
||||
Util.ensureThread(false);
|
||||
this.itemStack = itemStack.clone();
|
||||
this.player = player;
|
||||
|
||||
ItemMeta itemMeta;
|
||||
if (itemStack.hasItemMeta()) {
|
||||
itemMeta = this.itemStack.getItemMeta();
|
||||
} else {
|
||||
itemMeta = plugin.getServer().getItemFactory().getItemMeta(itemStack.getType());
|
||||
}
|
||||
// TODO use persis data storage container
|
||||
previewStr = plugin.text().of(player, "quickshop-gui-preview").forLocale();
|
||||
if (itemMeta != null) {
|
||||
if (itemMeta.hasLore()) {
|
||||
itemMeta.getLore().add(plugin.getPreviewProtectionLore());
|
||||
itemMeta.getLore().add(previewStr);
|
||||
} else {
|
||||
itemMeta.setLore(Collections.singletonList(plugin.getPreviewProtectionLore()));
|
||||
itemMeta.setLore(Collections.singletonList(previewStr));
|
||||
}
|
||||
|
||||
itemMeta.getPersistentDataContainer().set(key, PreviewGuiPersistentDataType.INSTANCE, UUID.randomUUID());
|
||||
this.itemStack.setItemMeta(itemMeta);
|
||||
}
|
||||
}
|
||||
@@ -88,13 +94,7 @@ public class InventoryPreview implements Listener {
|
||||
if (!stack.hasItemMeta() || !stack.getItemMeta().hasLore()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (String string : stack.getItemMeta().getLore()) {
|
||||
if (QuickShop.instance.getPreviewProtectionLore().equals(string)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return stack.getItemMeta().getPersistentDataContainer().get(key, PreviewGuiPersistentDataType.INSTANCE) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* This file is a part of project QuickShop, the name is DisplayItemPersistentDataType.java
|
||||
* Copyright (C) PotatoCraft Studio and contributors
|
||||
*
|
||||
* 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
|
||||
* (at your option) 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.maxgamer.quickshop.shop;
|
||||
|
||||
import org.bukkit.persistence.PersistentDataAdapterContext;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PreviewGuiPersistentDataType
|
||||
implements PersistentDataType<String, UUID> {
|
||||
static final PreviewGuiPersistentDataType INSTANCE = new PreviewGuiPersistentDataType();
|
||||
|
||||
@Override
|
||||
public @NotNull Class<String> getPrimitiveType() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Class<UUID> getComplexType() {
|
||||
return UUID.class;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String toPrimitive(
|
||||
@NotNull UUID complex, @NotNull PersistentDataAdapterContext context) {
|
||||
return complex.toString();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public UUID fromPrimitive(
|
||||
@NotNull String primitive, @NotNull PersistentDataAdapterContext context) {
|
||||
try {
|
||||
return UUID.fromString(primitive);
|
||||
}catch (Exception exception){
|
||||
return new UUID(0L,0L);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,192 +1,193 @@
|
||||
/*
|
||||
* This file is a part of project QuickShop, the name is ShopControlPanel.java
|
||||
* Copyright (C) PotatoCraft Studio and contributors
|
||||
*
|
||||
* 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
|
||||
* (at your option) 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.maxgamer.quickshop.shop;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.chat.QuickComponent;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class ShopControlPanel {
|
||||
private final Map<Plugin, TreeSet<Entry>> panelRegistry = new ConcurrentHashMap<>();
|
||||
private final QuickShop plugin;
|
||||
|
||||
public ShopControlPanel(QuickShop plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register the ControlPanel Entry to registry
|
||||
*
|
||||
* @param namespace The plugin instance
|
||||
* @param priority The entry priority
|
||||
* @param executor The executor, should returns an QuickComponent or null if no out-put needs
|
||||
*/
|
||||
public void register(@NotNull Plugin namespace, int priority, @NotNull Function<Map.Entry<@NotNull CommandSender, @NotNull Shop>, @Nullable QuickComponent> executor) {
|
||||
TreeSet<Entry> entries = this.panelRegistry.get(namespace);
|
||||
if (entries == null) {
|
||||
entries = new TreeSet<>(new Comparator());
|
||||
}
|
||||
Entry entry = new Entry(priority, executor);
|
||||
if (entries.contains(entry)) {
|
||||
return;
|
||||
}
|
||||
entries.add(entry);
|
||||
this.panelRegistry.put(namespace, entries);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a registered executor from registry
|
||||
*
|
||||
* @param namespace The plugin instance
|
||||
* @param priority The entry priority
|
||||
* @param executor The executor, should returns an QuickComponent or null if no out-put needs
|
||||
*/
|
||||
public void unregister(@NotNull Plugin namespace, int priority, @NotNull Function<Map.Entry<@NotNull CommandSender, @NotNull Shop>, @Nullable QuickComponent> executor) {
|
||||
TreeSet<Entry> entries = this.panelRegistry.get(namespace);
|
||||
if (entries == null) {
|
||||
return;
|
||||
}
|
||||
Entry entry = new Entry(priority, executor);
|
||||
entries.remove(entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a registered executor from registry
|
||||
*
|
||||
* @param namespace The plugin instance
|
||||
* @param executor The executor, should returns an QuickComponent or null if no out-put needs
|
||||
*/
|
||||
public void unregister(@NotNull Plugin namespace, @NotNull Function<Map.Entry<@NotNull CommandSender, @NotNull Shop>, @Nullable QuickComponent> executor) {
|
||||
TreeSet<Entry> entries = this.panelRegistry.get(namespace);
|
||||
if (entries == null) {
|
||||
return;
|
||||
}
|
||||
entries.removeIf(entry -> entry.getExecutor().equals(executor));
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister plugin's all registered executor from registry
|
||||
*
|
||||
* @param namespace The plugin instance
|
||||
*/
|
||||
public void unregisterAll(@NotNull Plugin namespace) {
|
||||
this.panelRegistry.remove(namespace);
|
||||
}
|
||||
|
||||
@EqualsAndHashCode
|
||||
public static class Entry {
|
||||
private final int priority;
|
||||
private final Function<Map.Entry<@NotNull CommandSender, @NotNull Shop>, @Nullable QuickComponent> executor;
|
||||
|
||||
public Entry(int priority, @NotNull Function<Map.Entry<@NotNull CommandSender, @NotNull Shop>, @Nullable QuickComponent> executor) {
|
||||
this.priority = priority;
|
||||
this.executor = executor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets this entry priority
|
||||
*
|
||||
* @return The priority
|
||||
*/
|
||||
public int getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the executor
|
||||
*
|
||||
* @return The executor
|
||||
*/
|
||||
@NotNull
|
||||
public Function<Map.Entry<@NotNull CommandSender, @NotNull Shop>, @Nullable QuickComponent> getExecutor() {
|
||||
return executor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the executor and gets an QuickComponent (or null for no out-put)
|
||||
*
|
||||
* @param data The input data that is an entry contains sender and shop object
|
||||
* @return The QuickComponent or null for no out-put
|
||||
*/
|
||||
@Nullable
|
||||
public QuickComponent get(@NotNull Map.Entry<@NotNull CommandSender, @NotNull Shop> data) {
|
||||
return this.executor.apply(data);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Comparator implements java.util.Comparator<Entry>, Serializable {
|
||||
|
||||
/**
|
||||
* Compares its two arguments for order. Returns a negative integer,
|
||||
* zero, or a positive integer as the first argument is less than, equal
|
||||
* to, or greater than the second.<p>
|
||||
* <p>
|
||||
* The implementor must ensure that {@code sgn(compare(x, y)) ==
|
||||
* -sgn(compare(y, x))} for all {@code x} and {@code y}. (This
|
||||
* implies that {@code compare(x, y)} must throw an exception if and only
|
||||
* if {@code compare(y, x)} throws an exception.)<p>
|
||||
* <p>
|
||||
* The implementor must also ensure that the relation is transitive:
|
||||
* {@code ((compare(x, y)>0) && (compare(y, z)>0))} implies
|
||||
* {@code compare(x, z)>0}.<p>
|
||||
* <p>
|
||||
* Finally, the implementor must ensure that {@code compare(x, y)==0}
|
||||
* implies that {@code sgn(compare(x, z))==sgn(compare(y, z))} for all
|
||||
* {@code z}.<p>
|
||||
* <p>
|
||||
* It is generally the case, but <i>not</i> strictly required that
|
||||
* {@code (compare(x, y)==0) == (x.equals(y))}. Generally speaking,
|
||||
* any comparator that violates this condition should clearly indicate
|
||||
* this fact. The recommended language is "Note: this comparator
|
||||
* imposes orderings that are inconsistent with equals."<p>
|
||||
* <p>
|
||||
* In the foregoing description, the notation
|
||||
* {@code sgn(}<i>expression</i>{@code )} designates the mathematical
|
||||
* <i>signum</i> function, which is defined to return one of {@code -1},
|
||||
* {@code 0}, or {@code 1} according to whether the value of
|
||||
* <i>expression</i> is negative, zero, or positive, respectively.
|
||||
*
|
||||
* @param o1 the first object to be compared.
|
||||
* @param o2 the second object to be compared.
|
||||
* @return a negative integer, zero, or a positive integer as the
|
||||
* first argument is less than, equal to, or greater than the
|
||||
* second.
|
||||
* @throws NullPointerException if an argument is null and this
|
||||
* comparator does not permit null arguments
|
||||
* @throws ClassCastException if the arguments' types prevent them from
|
||||
* being compared by this comparator.
|
||||
*/
|
||||
@Override
|
||||
public int compare(Entry o1, Entry o2) {
|
||||
return o1.priority - o2.priority;
|
||||
}
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file is a part of project QuickShop, the name is ShopControlPanel.java
|
||||
// * Copyright (C) PotatoCraft Studio and contributors
|
||||
// *
|
||||
// * 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
|
||||
// * (at your option) 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 <http://www.gnu.org/licenses/>.
|
||||
// *
|
||||
// */
|
||||
//
|
||||
//package org.maxgamer.quickshop.shop;
|
||||
//
|
||||
//import lombok.EqualsAndHashCode;
|
||||
//import org.bukkit.command.CommandSender;
|
||||
//import org.bukkit.plugin.Plugin;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//import org.jetbrains.annotations.Nullable;
|
||||
//import org.maxgamer.quickshop.QuickShop;
|
||||
//
|
||||
//import java.io.Serializable;
|
||||
//import java.util.Map;
|
||||
//import java.util.TreeSet;
|
||||
//import java.util.concurrent.ConcurrentHashMap;
|
||||
//import java.util.function.Function;
|
||||
//
|
||||
////import org.maxgamer.quickshop.chat.QuickComponent;
|
||||
//
|
||||
//public class ShopControlPanel {
|
||||
// private final Map<Plugin, TreeSet<Entry>> panelRegistry = new ConcurrentHashMap<>();
|
||||
// private final QuickShop plugin;
|
||||
//
|
||||
// public ShopControlPanel(QuickShop plugin) {
|
||||
// this.plugin = plugin;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * Register the ControlPanel Entry to registry
|
||||
// *
|
||||
// * @param namespace The plugin instance
|
||||
// * @param priority The entry priority
|
||||
// * @param executor The executor, should returns an QuickComponent or null if no out-put needs
|
||||
// */
|
||||
// public void register(@NotNull Plugin namespace, int priority, @NotNull Function<Map.Entry<@NotNull CommandSender, @NotNull Shop>, @Nullable QuickComponent> executor) {
|
||||
// TreeSet<Entry> entries = this.panelRegistry.get(namespace);
|
||||
// if (entries == null) {
|
||||
// entries = new TreeSet<>(new Comparator());
|
||||
// }
|
||||
// Entry entry = new Entry(priority, executor);
|
||||
// if (entries.contains(entry)) {
|
||||
// return;
|
||||
// }
|
||||
// entries.add(entry);
|
||||
// this.panelRegistry.put(namespace, entries);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Unregister a registered executor from registry
|
||||
// *
|
||||
// * @param namespace The plugin instance
|
||||
// * @param priority The entry priority
|
||||
// * @param executor The executor, should returns an QuickComponent or null if no out-put needs
|
||||
// */
|
||||
// public void unregister(@NotNull Plugin namespace, int priority, @NotNull Function<Map.Entry<@NotNull CommandSender, @NotNull Shop>, @Nullable QuickComponent> executor) {
|
||||
// TreeSet<Entry> entries = this.panelRegistry.get(namespace);
|
||||
// if (entries == null) {
|
||||
// return;
|
||||
// }
|
||||
// Entry entry = new Entry(priority, executor);
|
||||
// entries.remove(entry);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Unregister a registered executor from registry
|
||||
// *
|
||||
// * @param namespace The plugin instance
|
||||
// * @param executor The executor, should returns an QuickComponent or null if no out-put needs
|
||||
// */
|
||||
// public void unregister(@NotNull Plugin namespace, @NotNull Function<Map.Entry<@NotNull CommandSender, @NotNull Shop>, @Nullable QuickComponent> executor) {
|
||||
// TreeSet<Entry> entries = this.panelRegistry.get(namespace);
|
||||
// if (entries == null) {
|
||||
// return;
|
||||
// }
|
||||
// entries.removeIf(entry -> entry.getExecutor().equals(executor));
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Unregister plugin's all registered executor from registry
|
||||
// *
|
||||
// * @param namespace The plugin instance
|
||||
// */
|
||||
// public void unregisterAll(@NotNull Plugin namespace) {
|
||||
// this.panelRegistry.remove(namespace);
|
||||
// }
|
||||
//
|
||||
// @EqualsAndHashCode
|
||||
// public static class Entry {
|
||||
// private final int priority;
|
||||
// private final Function<Map.Entry<@NotNull CommandSender, @NotNull Shop>, @Nullable QuickComponent> executor;
|
||||
//
|
||||
// public Entry(int priority, @NotNull Function<Map.Entry<@NotNull CommandSender, @NotNull Shop>, @Nullable QuickComponent> executor) {
|
||||
// this.priority = priority;
|
||||
// this.executor = executor;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Gets this entry priority
|
||||
// *
|
||||
// * @return The priority
|
||||
// */
|
||||
// public int getPriority() {
|
||||
// return priority;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Gets the executor
|
||||
// *
|
||||
// * @return The executor
|
||||
// */
|
||||
// @NotNull
|
||||
// public Function<Map.Entry<@NotNull CommandSender, @NotNull Shop>, @Nullable QuickComponent> getExecutor() {
|
||||
// return executor;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Execute the executor and gets an QuickComponent (or null for no out-put)
|
||||
// *
|
||||
// * @param data The input data that is an entry contains sender and shop object
|
||||
// * @return The QuickComponent or null for no out-put
|
||||
// */
|
||||
// @Nullable
|
||||
// public QuickComponent get(@NotNull Map.Entry<@NotNull CommandSender, @NotNull Shop> data) {
|
||||
// return this.executor.apply(data);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public static class Comparator implements java.util.Comparator<Entry>, Serializable {
|
||||
//
|
||||
// /**
|
||||
// * Compares its two arguments for order. Returns a negative integer,
|
||||
// * zero, or a positive integer as the first argument is less than, equal
|
||||
// * to, or greater than the second.<p>
|
||||
// * <p>
|
||||
// * The implementor must ensure that {@code sgn(compare(x, y)) ==
|
||||
// * -sgn(compare(y, x))} for all {@code x} and {@code y}. (This
|
||||
// * implies that {@code compare(x, y)} must throw an exception if and only
|
||||
// * if {@code compare(y, x)} throws an exception.)<p>
|
||||
// * <p>
|
||||
// * The implementor must also ensure that the relation is transitive:
|
||||
// * {@code ((compare(x, y)>0) && (compare(y, z)>0))} implies
|
||||
// * {@code compare(x, z)>0}.<p>
|
||||
// * <p>
|
||||
// * Finally, the implementor must ensure that {@code compare(x, y)==0}
|
||||
// * implies that {@code sgn(compare(x, z))==sgn(compare(y, z))} for all
|
||||
// * {@code z}.<p>
|
||||
// * <p>
|
||||
// * It is generally the case, but <i>not</i> strictly required that
|
||||
// * {@code (compare(x, y)==0) == (x.equals(y))}. Generally speaking,
|
||||
// * any comparator that violates this condition should clearly indicate
|
||||
// * this fact. The recommended language is "Note: this comparator
|
||||
// * imposes orderings that are inconsistent with equals."<p>
|
||||
// * <p>
|
||||
// * In the foregoing description, the notation
|
||||
// * {@code sgn(}<i>expression</i>{@code )} designates the mathematical
|
||||
// * <i>signum</i> function, which is defined to return one of {@code -1},
|
||||
// * {@code 0}, or {@code 1} according to whether the value of
|
||||
// * <i>expression</i> is negative, zero, or positive, respectively.
|
||||
// *
|
||||
// * @param o1 the first object to be compared.
|
||||
// * @param o2 the second object to be compared.
|
||||
// * @return a negative integer, zero, or a positive integer as the
|
||||
// * first argument is less than, equal to, or greater than the
|
||||
// * second.
|
||||
// * @throws NullPointerException if an argument is null and this
|
||||
// * comparator does not permit null arguments
|
||||
// * @throws ClassCastException if the arguments' types prevent them from
|
||||
// * being compared by this comparator.
|
||||
// */
|
||||
// @Override
|
||||
// public int compare(Entry o1, Entry o2) {
|
||||
// return o1.priority - o2.priority;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -155,7 +155,8 @@ public class ShopManager implements Reloadable {
|
||||
}
|
||||
int max = plugin.getShopLimit(p);
|
||||
if (owned + 1 > max) {
|
||||
MsgUtil.sendMessage(p, "reached-maximum-can-create", String.valueOf(owned), String.valueOf(max));
|
||||
plugin.text().of(p,"reached-maximum-can-create", String.valueOf(owned), String.valueOf(max)).send();
|
||||
//MsgUtil.sendMessage(p, "reached-maximum-can-create", String.valueOf(owned), String.valueOf(max));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -278,7 +279,8 @@ public class ShopManager implements Reloadable {
|
||||
this.processWaterLoggedSign(shop.getLocation().getBlock(), info.getSignBlock());
|
||||
} else {
|
||||
if (!plugin.getConfig().getBoolean("shop.allow-shop-without-space-for-sign")) {
|
||||
MsgUtil.sendMessage(player, "failed-to-put-sign");
|
||||
plugin.text().of(player, "failed-to-put-sign").send();
|
||||
// MsgUtil.sendMessage(player, "failed-to-put-sign");
|
||||
Util.debugLog("Sign cannot placed cause no enough space(Not air block)");
|
||||
return;
|
||||
}
|
||||
@@ -307,7 +309,8 @@ public class ShopManager implements Reloadable {
|
||||
plugin.getDatabaseHelper().createShop(shop, null, e2 -> {
|
||||
plugin.getLogger()
|
||||
.log(Level.SEVERE, "Shop create failed, auto fix failed, the changes may won't commit to database.", e2);
|
||||
MsgUtil.sendMessage(player, "shop-creation-failed");
|
||||
// MsgUtil.sendMessage(player, "shop-creation-failed");
|
||||
plugin.text().of(player,"shop-creation-failed").send();
|
||||
Util.mainThreadRun(() -> {
|
||||
shop.onUnload();
|
||||
removeShop(shop);
|
||||
@@ -493,7 +496,7 @@ public class ShopManager implements Reloadable {
|
||||
}
|
||||
if (info.getLocation().getWorld() != p.getLocation().getWorld()
|
||||
|| info.getLocation().distanceSquared(p.getLocation()) > 25) {
|
||||
MsgUtil.sendMessage(p, "not-looking-at-shop");
|
||||
plugin.text().of(p, "not-looking-at-shop").send();
|
||||
return;
|
||||
}
|
||||
if (info.getAction() == ShopAction.CREATE) {
|
||||
@@ -651,21 +654,21 @@ public class ShopManager implements Reloadable {
|
||||
space = 10000;
|
||||
}
|
||||
if (space < amount) {
|
||||
MsgUtil.sendMessage(buyer, "shop-has-no-space", Integer.toString(space), Util.getItemStackName(shop.getItem()));
|
||||
plugin.text().of(buyer, "shop-has-no-space", Integer.toString(space), Util.getItemStackName(shop.getItem())).send();
|
||||
return;
|
||||
}
|
||||
int count = Util.countItems(buyerInventory, shop.getItem());
|
||||
// Not enough items
|
||||
if (amount > count) {
|
||||
MsgUtil.sendMessage(buyer,
|
||||
plugin.text().of(buyer,
|
||||
"you-dont-have-that-many-items",
|
||||
Integer.toString(count),
|
||||
Util.getItemStackName(shop.getItem()));
|
||||
Util.getItemStackName(shop.getItem())).send();
|
||||
return;
|
||||
}
|
||||
if (amount < 1) {
|
||||
// & Dumber
|
||||
MsgUtil.sendMessage(buyer, "negative-amount");
|
||||
plugin.text().of(buyer, "negative-amount").send();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -697,12 +700,12 @@ public class ShopManager implements Reloadable {
|
||||
}
|
||||
if (!transaction.failSafeCommit()) {
|
||||
if (transaction.getSteps() == EconomyTransaction.TransactionSteps.CHECK) {
|
||||
MsgUtil.sendMessage(buyer, "the-owner-cant-afford-to-buy-from-you",
|
||||
plugin.text().of(buyer, "the-owner-cant-afford-to-buy-from-you",
|
||||
Objects.requireNonNull(format(total, shop.getLocation().getWorld(), shop.getCurrency())),
|
||||
Objects.requireNonNull(format(eco.getBalance(shop.getOwner(), shop.getLocation().getWorld(),
|
||||
shop.getCurrency()), shop.getLocation().getWorld(), shop.getCurrency())));
|
||||
shop.getCurrency()), shop.getLocation().getWorld(), shop.getCurrency()))).send();
|
||||
} else {
|
||||
MsgUtil.sendMessage(buyer, "purchase-failed");
|
||||
plugin.text().of(buyer, "purchase-failed").send();
|
||||
plugin.getLogger().severe("EconomyTransaction Failed, last error:" + transaction.getLastError());
|
||||
QuickShop.getInstance().log("EconomyTransaction Failed, last error:" + transaction.getLastError());
|
||||
}
|
||||
@@ -800,23 +803,23 @@ public class ShopManager implements Reloadable {
|
||||
if (!bypassProtectionChecks) {
|
||||
Result result = plugin.getPermissionChecker().canBuild(p, info.getLocation());
|
||||
if (!result.isSuccess()) {
|
||||
MsgUtil.sendMessage(p, "3rd-plugin-build-check-failed", result.getMessage());
|
||||
plugin.text().of(p, "3rd-plugin-build-check-failed", result.getMessage()).send();
|
||||
Util.debugLog("Failed to create shop because protection check failed, found:" + result.getMessage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getShopManager().getShop(info.getLocation()) != null) {
|
||||
MsgUtil.sendMessage(p, "shop-already-owned");
|
||||
plugin.text().of(p, "shop-already-owned").send();
|
||||
return;
|
||||
}
|
||||
if (Util.isDoubleChest(info.getLocation().getBlock().getBlockData())
|
||||
&& !QuickShop.getPermissionManager().hasPermission(p, "quickshop.create.double")) {
|
||||
MsgUtil.sendMessage(p, "no-double-chests");
|
||||
plugin.text().of(p, "no-double-chests").send();
|
||||
return;
|
||||
}
|
||||
if (!Util.canBeShop(info.getLocation().getBlock())) {
|
||||
MsgUtil.sendMessage(p, "chest-was-removed");
|
||||
plugin.text().of(p, "chest-was-removed").send();
|
||||
return;
|
||||
}
|
||||
if (info.getLocation().getBlock().getType()
|
||||
@@ -829,7 +832,7 @@ public class ShopManager implements Reloadable {
|
||||
if (autoSign) {
|
||||
if (info.getSignBlock() == null) {
|
||||
if (!plugin.getConfig().getBoolean("shop.allow-shop-without-space-for-sign")) {
|
||||
MsgUtil.sendMessage(p, "failed-to-put-sign");
|
||||
plugin.text().of(p, "failed-to-put-sign").send();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -837,7 +840,7 @@ public class ShopManager implements Reloadable {
|
||||
if (signType != Material.WATER
|
||||
&& !signType.isAir()
|
||||
&& !plugin.getConfig().getBoolean("shop.allow-shop-without-space-for-sign")) {
|
||||
MsgUtil.sendMessage(p, "failed-to-put-sign");
|
||||
plugin.text().of(p, "failed-to-put-sign").send();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -848,7 +851,7 @@ public class ShopManager implements Reloadable {
|
||||
try {
|
||||
price = Double.parseDouble(message);
|
||||
if (Double.isInfinite(price)) {
|
||||
MsgUtil.sendMessage(p, "exceeded-maximum", message);
|
||||
plugin.text().of(p, "exceeded-maximum", message).send();
|
||||
return;
|
||||
}
|
||||
String strFormat = new DecimalFormat("#.#########").format(Math.abs(price))
|
||||
@@ -859,13 +862,13 @@ public class ShopManager implements Reloadable {
|
||||
.getInt("maximum-digits-in-price", -1);
|
||||
if (processedDouble[1].length() > maximumDigitsLimit
|
||||
&& maximumDigitsLimit != -1) {
|
||||
MsgUtil.sendMessage(p, "digits-reach-the-limit", String.valueOf(maximumDigitsLimit));
|
||||
plugin.text().of(p, "digits-reach-the-limit", String.valueOf(maximumDigitsLimit)).send();
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (NumberFormatException ex) {
|
||||
Util.debugLog(ex.getMessage());
|
||||
MsgUtil.sendMessage(p, "not-a-number", message);
|
||||
plugin.text().of(p, "not-a-number", message).send();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -876,26 +879,26 @@ public class ShopManager implements Reloadable {
|
||||
|
||||
switch (priceCheckResult.getStatus()) {
|
||||
case REACHED_PRICE_MIN_LIMIT:
|
||||
MsgUtil.sendMessage(p, "price-too-cheap",
|
||||
plugin.text().of(p, "price-too-cheap",
|
||||
(decFormat) ? MsgUtil.decimalFormat(this.priceLimiter.getMaxPrice())
|
||||
: Double.toString(this.priceLimiter.getMinPrice()));
|
||||
return;
|
||||
case REACHED_PRICE_MAX_LIMIT:
|
||||
MsgUtil.sendMessage(p, "price-too-high",
|
||||
plugin.text().of(p, "price-too-high",
|
||||
(decFormat) ? MsgUtil.decimalFormat(this.priceLimiter.getMaxPrice())
|
||||
: Double.toString(this.priceLimiter.getMinPrice()));
|
||||
return;
|
||||
case PRICE_RESTRICTED:
|
||||
MsgUtil.sendMessage(p, "restricted-prices",
|
||||
plugin.text().of(p, "restricted-prices",
|
||||
Util.getItemStackName(info.getItem()),
|
||||
String.valueOf(priceCheckResult.getMin()),
|
||||
String.valueOf(priceCheckResult.getMax()));
|
||||
String.valueOf(priceCheckResult.getMax())).send();
|
||||
return;
|
||||
case NOT_VALID:
|
||||
MsgUtil.sendMessage(p, "not-a-number", message);
|
||||
plugin.text().of(p, "not-a-number", message).send();
|
||||
return;
|
||||
case NOT_A_WHOLE_NUMBER:
|
||||
MsgUtil.sendMessage(p, "not-a-integer", message);
|
||||
plugin.text().of(p, "not-a-integer", message).send();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -918,7 +921,7 @@ public class ShopManager implements Reloadable {
|
||||
Result result = plugin.getIntegrationHelper()
|
||||
.callIntegrationsCanCreate(p, info.getLocation());
|
||||
if (!result.isSuccess()) {
|
||||
MsgUtil.sendMessage(p, "integrations-check-failed-create", result.getMessage());
|
||||
plugin.text().of(p, "integrations-check-failed-create", result.getMessage()).send();
|
||||
Util.debugLog("Cancelled by integrations: " + result);
|
||||
return;
|
||||
}
|
||||
@@ -952,11 +955,11 @@ public class ShopManager implements Reloadable {
|
||||
.build();
|
||||
if (!economyTransaction.failSafeCommit()) {
|
||||
if (economyTransaction.getSteps() == EconomyTransaction.TransactionSteps.CHECK) {
|
||||
MsgUtil.sendMessage(p, "you-cant-afford-a-new-shop",
|
||||
plugin.text().of(p, "you-cant-afford-a-new-shop",
|
||||
Objects.requireNonNull(format(createCost, shop.getLocation().getWorld(),
|
||||
shop.getCurrency())));
|
||||
shop.getCurrency()))).send();
|
||||
} else {
|
||||
MsgUtil.sendMessage(p, "purchase-failed");
|
||||
plugin.text().of(p, "purchase-failed").send();
|
||||
plugin.getLogger().severe("EconomyTransaction Failed, last error:" + economyTransaction.getLastError());
|
||||
plugin.log("EconomyTransaction Failed, last error:" + economyTransaction.getLastError());
|
||||
}
|
||||
@@ -967,7 +970,7 @@ public class ShopManager implements Reloadable {
|
||||
// The shop about successfully created
|
||||
createShop(shop, info);
|
||||
if (!plugin.getConfig().getBoolean("shop.lock")) {
|
||||
MsgUtil.sendMessage(p, "shops-arent-locked");
|
||||
plugin.text().of(p, "shops-arent-locked").send();
|
||||
}
|
||||
|
||||
// Figures out which way we should put the sign on and
|
||||
@@ -977,7 +980,7 @@ public class ShopManager implements Reloadable {
|
||||
if (Objects.requireNonNull(nextTo).getPrice() > shop.getPrice()) {
|
||||
// The one next to it must always be a
|
||||
// buying shop.
|
||||
MsgUtil.sendMessage(p, "buying-more-than-selling");
|
||||
plugin.text().of(p, "buying-more-than-selling").send();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1013,18 +1016,18 @@ public class ShopManager implements Reloadable {
|
||||
stock = 10000;
|
||||
}
|
||||
if (stock < amount) {
|
||||
MsgUtil.sendMessage(seller, "shop-stock-too-low", Integer.toString(stock),
|
||||
Util.getItemStackName(shop.getItem()));
|
||||
plugin.text().of(seller, "shop-stock-too-low", Integer.toString(stock),
|
||||
Util.getItemStackName(shop.getItem())).send();
|
||||
return;
|
||||
}
|
||||
if (amount < 1) {
|
||||
// & Dumber
|
||||
MsgUtil.sendMessage(seller, "negative-amount");
|
||||
plugin.text().of(seller, "negative-amount").send();
|
||||
return;
|
||||
}
|
||||
int pSpace = Util.countSpace(sellerInventory, shop.getItem());
|
||||
if (amount > pSpace) {
|
||||
MsgUtil.sendMessage(seller, "not-enough-space", String.valueOf(pSpace));
|
||||
plugin.text().of(seller, "not-enough-space", String.valueOf(pSpace)).send();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1058,15 +1061,15 @@ public class ShopManager implements Reloadable {
|
||||
}
|
||||
if (!transaction.failSafeCommit()) {
|
||||
if (transaction.getSteps() == EconomyTransaction.TransactionSteps.CHECK) {
|
||||
MsgUtil.sendMessage(seller, "you-cant-afford-to-buy",
|
||||
plugin.text().of(seller, "you-cant-afford-to-buy",
|
||||
Objects.requireNonNull(
|
||||
format(total, shop.getLocation().getWorld(), shop.getCurrency())),
|
||||
Objects.requireNonNull(format(
|
||||
eco.getBalance(seller, shop.getLocation().getWorld(),
|
||||
shop.getCurrency()), shop.getLocation().getWorld(),
|
||||
shop.getCurrency())));
|
||||
shop.getCurrency()))).send();
|
||||
} else {
|
||||
MsgUtil.sendMessage(seller, "purchase-failed");
|
||||
plugin.text().of(seller, "purchase-failed").send();
|
||||
plugin.getLogger().severe("EconomyTransaction Failed, last error:" + transaction.getLastError());
|
||||
QuickShop.getInstance().log("EconomyTransaction Failed, last error:" + transaction.getLastError());
|
||||
}
|
||||
@@ -1125,11 +1128,11 @@ public class ShopManager implements Reloadable {
|
||||
return true;
|
||||
}
|
||||
if (!Util.canBeShop(info.getLocation().getBlock())) {
|
||||
MsgUtil.sendMessage(p, "chest-was-removed");
|
||||
plugin.text().of(p, "chest-was-removed").send();
|
||||
return true;
|
||||
}
|
||||
if (info.hasChanged(shop)) {
|
||||
MsgUtil.sendMessage(p, "shop-has-changed");
|
||||
plugin.text().of(p, "shop-has-changed").send();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -1144,7 +1147,7 @@ public class ShopManager implements Reloadable {
|
||||
Result result = plugin.getIntegrationHelper()
|
||||
.callIntegrationsCanTrade(p, info.getLocation());
|
||||
if (!result.isSuccess()) {
|
||||
MsgUtil.sendMessage(p, "integrations-check-failed-trade", result.getMessage());
|
||||
plugin.text().of(p, "integrations-check-failed-trade", result.getMessage()).send();
|
||||
Util.debugLog("Cancel by integrations.");
|
||||
return;
|
||||
}
|
||||
@@ -1154,16 +1157,16 @@ public class ShopManager implements Reloadable {
|
||||
Shop shop = plugin.getShopManager().getShop(info.getLocation());
|
||||
// It's not valid anymore
|
||||
if (shop == null || !Util.canBeShop(info.getLocation().getBlock())) {
|
||||
MsgUtil.sendMessage(p, "chest-was-removed");
|
||||
plugin.text().of(p, "chest-was-removed").send();
|
||||
return;
|
||||
}
|
||||
if (p.getGameMode() == GameMode.CREATIVE && plugin.getConfig().getBoolean("shop.disable-creative-mode-trading")) {
|
||||
MsgUtil.sendMessage(p, "trading-in-creative-mode-is-disabled");
|
||||
plugin.text().of(p, "trading-in-creative-mode-is-disabled").send();
|
||||
return;
|
||||
}
|
||||
int amount;
|
||||
if (info.hasChanged(shop)) {
|
||||
MsgUtil.sendMessage(p, "shop-has-changed");
|
||||
plugin.text().of(p, "shop-has-changed").send();
|
||||
return;
|
||||
}
|
||||
if (shop.isBuying()) {
|
||||
@@ -1202,8 +1205,8 @@ public class ShopManager implements Reloadable {
|
||||
if (amount < 1) { // typed 'all' but the auto set amount is 0
|
||||
if (shopHaveSpaces == 0) {
|
||||
// when typed 'all' but the shop doesn't have any empty space
|
||||
MsgUtil.sendMessage(p, "shop-has-no-space", Integer.toString(shopHaveSpaces),
|
||||
Util.getItemStackName(shop.getItem()));
|
||||
plugin.text().of(p, "shop-has-no-space", Integer.toString(shopHaveSpaces),
|
||||
Util.getItemStackName(shop.getItem())).send();
|
||||
return;
|
||||
}
|
||||
if (ownerCanAfford == 0
|
||||
@@ -1211,25 +1214,25 @@ public class ShopManager implements Reloadable {
|
||||
|| plugin.getConfig().getBoolean("shop.pay-unlimited-shop-owners"))) {
|
||||
// when typed 'all' but the shop owner doesn't have enough money to buy at least 1
|
||||
// item (and shop isn't unlimited or pay-unlimited is true)
|
||||
MsgUtil.sendMessage(p, "the-owner-cant-afford-to-buy-from-you",
|
||||
plugin.text().of(p, "the-owner-cant-afford-to-buy-from-you",
|
||||
Objects.requireNonNull(
|
||||
format(shop.getPrice(), shop.getLocation().getWorld(),
|
||||
shop.getCurrency())),
|
||||
Objects.requireNonNull(
|
||||
format(ownerBalance, shop.getLocation().getWorld(),
|
||||
shop.getCurrency())));
|
||||
shop.getCurrency()))).send();
|
||||
return;
|
||||
}
|
||||
// when typed 'all' but player doesn't have any items to sell
|
||||
MsgUtil.sendMessage(p, "you-dont-have-that-many-items",
|
||||
plugin.text().of(p, "you-dont-have-that-many-items",
|
||||
Integer.toString(amount),
|
||||
Util.getItemStackName(shop.getItem()));
|
||||
Util.getItemStackName(shop.getItem())).send();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// instead of output cancelled message (when typed neither integer or 'all'), just let
|
||||
// player know that there should be positive number or 'all'
|
||||
MsgUtil.sendMessage(p, "not-a-integer", message);
|
||||
plugin.text().of(p, "not-a-integer", message).send();
|
||||
Util.debugLog(
|
||||
"Receive the chat " + message + " and it format failed: " + message);
|
||||
return;
|
||||
@@ -1259,30 +1262,30 @@ public class ShopManager implements Reloadable {
|
||||
// when typed 'all' but player can't buy any items
|
||||
if (!shop.isUnlimited() && shopHaveItems < 1) {
|
||||
// but also the shop's stock is 0
|
||||
MsgUtil.sendMessage(p, "shop-stock-too-low",
|
||||
plugin.text().of(p, "shop-stock-too-low",
|
||||
Integer.toString(shop.getRemainingStock()),
|
||||
Util.getItemStackName(shop.getItem()));
|
||||
Util.getItemStackName(shop.getItem())).send();
|
||||
} else {
|
||||
// when if player's inventory is full
|
||||
if (invHaveSpaces <= 0) {
|
||||
MsgUtil.sendMessage(p, "not-enough-space",
|
||||
String.valueOf(invHaveSpaces));
|
||||
plugin.text().of(p, "not-enough-space",
|
||||
String.valueOf(invHaveSpaces)).send();
|
||||
return;
|
||||
}
|
||||
MsgUtil.sendMessage(p, "you-cant-afford-to-buy",
|
||||
plugin.text().of(p, "you-cant-afford-to-buy",
|
||||
Objects.requireNonNull(
|
||||
format(price, shop.getLocation().getWorld(),
|
||||
shop.getCurrency())),
|
||||
Objects.requireNonNull(
|
||||
format(balance, shop.getLocation().getWorld(),
|
||||
shop.getCurrency())));
|
||||
shop.getCurrency()))).send();
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// instead of output cancelled message, just let player know that there should be positive
|
||||
// number or 'all'
|
||||
MsgUtil.sendMessage(p, "not-a-integer", message);
|
||||
plugin.text().of(p, "not-a-integer", message).send();
|
||||
Util.debugLog(
|
||||
"Receive the chat " + message + " and it format failed: " + message);
|
||||
return;
|
||||
@@ -1290,7 +1293,7 @@ public class ShopManager implements Reloadable {
|
||||
}
|
||||
actionSell(p.getUniqueId(), p.getInventory(), eco, info, shop, amount);
|
||||
} else {
|
||||
MsgUtil.sendMessage(p, "shop-purchase-cancelled");
|
||||
plugin.text().of(p, "shop-purchase-cancelled").send();
|
||||
plugin.getLogger().warning("Shop data broken? Loc:" + shop.getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,9 @@ package org.maxgamer.quickshop.util;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -49,7 +52,11 @@ public class ChatSheetPrinter {
|
||||
|
||||
public void printExecutableCmdLine(
|
||||
@NotNull String text, @NotNull String hoverText, @NotNull String executeCmd) {
|
||||
QuickShop.getInstance().getQuickChat().sendExecutableChat(p, text, hoverText, executeCmd);
|
||||
QuickShop.getInstance().adventure().sender(p).sendMessage(Component.text(text)
|
||||
.hoverEvent(HoverEvent.showText(Component.text(text)))
|
||||
.clickEvent(ClickEvent.runCommand(executeCmd))
|
||||
);
|
||||
// QuickShop.getInstance().getQuickChat().sendExecutableChat(p, text, hoverText, executeCmd);
|
||||
}
|
||||
|
||||
public void printFooter() {
|
||||
@@ -71,8 +78,11 @@ public class ChatSheetPrinter {
|
||||
|
||||
public void printSuggestedCmdLine(
|
||||
@NotNull String text, @NotNull String hoverText, @NotNull String suggestCmd) {
|
||||
QuickShop.getInstance().getQuickChat().sendSuggestedChat(p, text, hoverText, suggestCmd);
|
||||
|
||||
QuickShop.getInstance().adventure().sender(p)
|
||||
.sendMessage(Component.text(text)
|
||||
.hoverEvent(HoverEvent.showText(Component.text(hoverText)))
|
||||
.clickEvent(ClickEvent.suggestCommand(suggestCmd)));
|
||||
// QuickShop.getInstance().getQuickChat().sendSuggestedChat(p, text, hoverText, suggestCmd);
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -19,14 +19,14 @@
|
||||
|
||||
package org.maxgamer.quickshop.util;
|
||||
|
||||
import de.themoep.minedown.MineDown;
|
||||
import de.themoep.minedown.MineDownParser;
|
||||
import de.themoep.minedown.adventure.MineDown;
|
||||
import de.themoep.minedown.adventure.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 net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -1039,18 +1039,19 @@ public class Util {
|
||||
}
|
||||
MineDownParser parser = mineDown.get().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();
|
||||
// StringBuilder builder = new StringBuilder();
|
||||
Component components = parser.enable(MineDownParser.Option.LEGACY_COLORS).parse(text).asComponent();
|
||||
return LegacyComponentSerializer.builder().hexColors().build().serialize(components);
|
||||
// for (Component component : components.children()) {
|
||||
// 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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package org.maxgamer.quickshop.util.language.text;
|
||||
|
||||
import com.dumptruckman.bukkit.configuration.json.JsonConfiguration;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.util.MsgUtil;
|
||||
import org.maxgamer.quickshop.util.Util;
|
||||
import org.maxgamer.quickshop.util.language.text.distributions.Distribution;
|
||||
import org.maxgamer.quickshop.util.language.text.distributions.crowdin.CrowdinOTA;
|
||||
@@ -19,11 +22,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class TextManager {
|
||||
@@ -66,7 +65,7 @@ public class TextManager {
|
||||
JsonConfiguration override = new JsonConfiguration();
|
||||
File localOverrideFile = new File(overrideFilesFolder, availableLanguage + ".json");
|
||||
if (localOverrideFile.exists()) {
|
||||
override.loadFromString(Files.readString(localOverrideFile.toPath()));
|
||||
override.loadFromString(Util.readToString(localOverrideFile));
|
||||
for (String key : override.getKeys(true)) {
|
||||
configuration.set(key, override.get(key));
|
||||
}
|
||||
@@ -80,11 +79,107 @@ public class TextManager {
|
||||
postProcessors.add(new PlaceHolderApiProcessor());
|
||||
}
|
||||
|
||||
public Text of(CommandSender sender, String path, String... args) {
|
||||
return new Text(this, sender, locale2ContentMapping.get(languageFileCrowdin), path, args);
|
||||
public Text of(@NotNull String path, String... args) {
|
||||
return new Text(this, (CommandSender)null, locale2ContentMapping.get(languageFileCrowdin), path, args);
|
||||
}
|
||||
|
||||
static class Text {
|
||||
public Text of(@Nullable CommandSender sender, @NotNull String path, String... args) {
|
||||
return new Text(this, sender, locale2ContentMapping.get(languageFileCrowdin), path, args);
|
||||
}
|
||||
public Text of(@Nullable UUID sender, @NotNull String path, String... args) {
|
||||
return new Text(this, sender, locale2ContentMapping.get(languageFileCrowdin), path, args);
|
||||
}
|
||||
public TextList ofList(@NotNull String path, String... args) {
|
||||
return new TextList(this, (CommandSender) null, locale2ContentMapping.get(languageFileCrowdin), path, args);
|
||||
}
|
||||
|
||||
public TextList ofList(@Nullable UUID sender, @NotNull String path, String... args) {
|
||||
return new TextList(this, sender, locale2ContentMapping.get(languageFileCrowdin), path, args);
|
||||
}
|
||||
public TextList ofList(@Nullable CommandSender sender, @NotNull String path, String... args) {
|
||||
return new TextList(this, sender, locale2ContentMapping.get(languageFileCrowdin), path, args);
|
||||
}
|
||||
|
||||
public static class TextList {
|
||||
private final TextManager manager;
|
||||
private final String path;
|
||||
private final QuickShop plugin;
|
||||
private final Map<String, JsonConfiguration> mapping;
|
||||
private final CommandSender sender;
|
||||
private final String[] args;
|
||||
|
||||
private TextList(TextManager manager, CommandSender sender, Map<String, JsonConfiguration> mapping, String path, String... args) {
|
||||
this.plugin = manager.plugin;
|
||||
this.manager = manager;
|
||||
this.sender = sender;
|
||||
this.mapping = mapping;
|
||||
this.path = path;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
private TextList(TextManager manager, UUID sender, Map<String, JsonConfiguration> mapping, String path, String... args) {
|
||||
this.plugin = manager.plugin;
|
||||
this.manager = manager;
|
||||
if(sender != null)
|
||||
this.sender = Bukkit.getPlayer(sender);
|
||||
else
|
||||
this.sender = null;
|
||||
this.mapping = mapping;
|
||||
this.path = path;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
private @NotNull List<String> fallbackLocal() {
|
||||
return manager.bundledLang.getStringList(path);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<String> postProcess(@NotNull List<String> text) {
|
||||
List<String> texts = new ArrayList<>();
|
||||
for (PostProcessor postProcessor : this.manager.postProcessors)
|
||||
for (String s : text) {
|
||||
texts.add(postProcessor.process(s, sender, args));
|
||||
}
|
||||
return texts;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<String> forLocale(@NotNull String locale) {
|
||||
JsonConfiguration index = mapping.get(locale);
|
||||
if (index == null && locale.equals("en")) {
|
||||
List<String> str = fallbackLocal();
|
||||
if (str.isEmpty())
|
||||
return Collections.singletonList("Fallback Missing Language Key: " + path + ", report to QuickShop!");
|
||||
}
|
||||
if (index == null)
|
||||
return forLocale("en");
|
||||
List<String> str = index.getStringList(locale);
|
||||
if (str.isEmpty())
|
||||
return Collections.singletonList("Missing Language Key: " + path);
|
||||
return postProcess(str);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<String> forLocale() {
|
||||
if (sender instanceof Player) {
|
||||
return forLocale(((Player) sender).getLocale());
|
||||
} else {
|
||||
return forLocale("en");
|
||||
}
|
||||
}
|
||||
|
||||
public void send() {
|
||||
if(sender == null)
|
||||
return;
|
||||
for (String s : forLocale()) {
|
||||
if (StringUtils.isEmpty(s))
|
||||
continue;
|
||||
MsgUtil.sendDirectMessage(sender, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Text {
|
||||
private final TextManager manager;
|
||||
private final String path;
|
||||
private final QuickShop plugin;
|
||||
@@ -101,6 +196,18 @@ public class TextManager {
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
private Text(TextManager manager, UUID sender, Map<String, JsonConfiguration> mapping, String path, String... args) {
|
||||
this.plugin = manager.plugin;
|
||||
this.manager = manager;
|
||||
if(sender != null)
|
||||
this.sender = Bukkit.getPlayer(sender);
|
||||
else
|
||||
this.sender = null;
|
||||
this.mapping = mapping;
|
||||
this.path = path;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String fallbackLocal() {
|
||||
return manager.bundledLang.getString(path);
|
||||
@@ -130,8 +237,22 @@ public class TextManager {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String forLocale(@NotNull Player player){
|
||||
return forLocale(player.getLocale());
|
||||
public String forLocale() {
|
||||
if (sender instanceof Player) {
|
||||
return forLocale(((Player) sender).getLocale());
|
||||
} else {
|
||||
return forLocale("en");
|
||||
}
|
||||
}
|
||||
|
||||
public void send() {
|
||||
if(sender == null)
|
||||
return;
|
||||
String lang = forLocale();
|
||||
if (StringUtils.isEmpty(lang))
|
||||
return;
|
||||
MsgUtil.sendDirectMessage(sender,lang);
|
||||
// plugin.getQuickChat().send(sender, lang);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -16,7 +16,6 @@ import org.maxgamer.quickshop.util.language.text.distributions.crowdin.bean.Mani
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -97,7 +96,7 @@ public class CrowdinOTA implements Distribution {
|
||||
File metadataFile = new File(Util.getCacheFolder(), "i18n.metadata");
|
||||
YamlConfiguration cacheMetadata = YamlConfiguration.loadConfiguration(metadataFile);
|
||||
long localeTimestamp = cacheMetadata.getLong(pathHash + ".timestamp");
|
||||
String data = Files.readString(new File(Util.getCacheFolder(), pathHash).toPath());
|
||||
String data = Util.readToString(new File(Util.getCacheFolder(), pathHash));
|
||||
// invalidate cache, flush it
|
||||
if (localeTimestamp != manifest.getTimestamp() || forceFlush) {
|
||||
String url = CROWDIN_OTA_HOST + "content/" + fileCrowdinPath.replace("%locale%", postProcessingPath);
|
||||
|
||||
+1
@@ -11,4 +11,5 @@ public class ColorProcessor implements PostProcessor {
|
||||
public @NotNull String process(@NotNull String text, @Nullable CommandSender sender, String... args) {
|
||||
return Util.parseColours(text);
|
||||
}
|
||||
|
||||
}
|
||||
+3
-2
@@ -11,11 +11,12 @@ import org.maxgamer.quickshop.util.language.text.postprocessing.PostProcessor;
|
||||
public class PlaceHolderApiProcessor implements PostProcessor {
|
||||
@Override
|
||||
public @NotNull String process(@NotNull String text, @Nullable CommandSender sender, String... args) {
|
||||
if(sender instanceof OfflinePlayer) {
|
||||
if (sender instanceof OfflinePlayer) {
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("PlaceHolderAPI")) {
|
||||
return PlaceholderAPI.setPlaceholders((OfflinePlayer) sender,text);
|
||||
return PlaceholderAPI.setPlaceholders((OfflinePlayer) sender, text);
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public class Paste {
|
||||
finalReport.append("\tBuild Commit: ").append(plugin.getBuildInfo().getGitCommit()).append("\n");
|
||||
finalReport.append("\tBuild URL: ").append(plugin.getBuildInfo().getBuildUrl()).append("\n");
|
||||
finalReport.append("\tBuild Tag: ").append(plugin.getBuildInfo().getBuildTag()).append("\n");
|
||||
finalReport.append("\tChat System: ").append(plugin.getQuickChatType().name()).append("\n");
|
||||
finalReport.append("\tChat System: ").append("Hardcoded Adventure").append("\n");
|
||||
finalReport.append("\tServer ID: ").append(plugin.getServerUniqueID()).append("\n");
|
||||
finalReport
|
||||
.append("\tOpenInv Hook: ")
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package org.maxgamer.quickshop.watcher;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@@ -98,17 +97,17 @@ public class OngoingFeeWatcher extends BukkitRunnable {
|
||||
*/
|
||||
public void removeShop(@NotNull Shop shop) {
|
||||
Util.mainThreadRun(shop::delete);
|
||||
MsgUtil.send(shop, shop.getOwner(), new MsgUtil.TransactionMessage(MsgUtil.getMessageOfflinePlayer(
|
||||
"shop-removed-cause-ongoing-fee",
|
||||
Bukkit.getOfflinePlayer(shop.getOwner()),
|
||||
"World:"
|
||||
|
||||
MsgUtil.send(shop, shop.getOwner(), new MsgUtil.TransactionMessage(
|
||||
plugin.text().of("shop-removed-cause-ongoing-fee","World:"
|
||||
+ Objects.requireNonNull(shop.getLocation().getWorld()).getName()
|
||||
+ " X:"
|
||||
+ shop.getLocation().getBlockX()
|
||||
+ " Y:"
|
||||
+ shop.getLocation().getBlockY()
|
||||
+ " Z:"
|
||||
+ shop.getLocation().getBlockZ()), null, null));
|
||||
+ shop.getLocation().getBlockZ()).forLocale()
|
||||
, null, null));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public class UpdateWatcher implements Listener {
|
||||
if (QuickShop.getPermissionManager()
|
||||
.hasPermission(player, "quickshop.alerts")) {
|
||||
List<String> notifys =
|
||||
MsgUtil.getI18nFile().getStringList("updatenotify.list");
|
||||
QuickShop.getInstance().text().ofList(player,"updatenotify.list").forLocale();
|
||||
int notifyNum = -1;
|
||||
if (notifys.size() > 1) {
|
||||
notifyNum = random.nextInt(notifys.size());
|
||||
@@ -103,7 +103,7 @@ public class UpdateWatcher implements Listener {
|
||||
if (!QuickShop.getPermissionManager().hasPermission(e.getPlayer(), "quickshop.alerts") || getUpdater().isLatest(getUpdater().getCurrentRunning())) {
|
||||
return;
|
||||
}
|
||||
List<String> notifys = MsgUtil.getI18nFile().getStringList("updatenotify.list");
|
||||
List<String> notifys = QuickShop.getInstance().text().ofList(e.getPlayer(),"updatenotify.list").forLocale();
|
||||
int notifyNum = random.nextInt(notifys.size());
|
||||
String notify = notifys.get(notifyNum);
|
||||
notify = MsgUtil.fillArgs(notify, updater.getRemoteServerVersion(), QuickShop.getInstance().getBuildInfo().getBuildTag());
|
||||
|
||||
Reference in new issue
Block a user