mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-24 17:39:52 -05:00
Control Panel
Former-commit-id: a4fbf79cbe66df141611cf71ad011d975c3b5cde [formerly 664a01b22f288c506791d56ab11bd6e0527717b1] Former-commit-id: 7318599d633a414c05adef548e38270e3c67def7
This commit is contained in:
1 parent
6ec93724d9
commit
87a20f19b7
6 files changed
+307
-121
No files matched your search
@@ -1,8 +1,11 @@
|
||||
package org.maxgamer.quickshop.Command;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -11,7 +14,13 @@ import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.PistonMoveReaction;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -21,9 +30,12 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.BlockIterator;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Database.Database;
|
||||
import org.maxgamer.quickshop.Database.DatabaseHelper;
|
||||
import org.maxgamer.quickshop.Database.MySQLCore;
|
||||
import org.maxgamer.quickshop.Database.SQLiteCore;
|
||||
import org.maxgamer.quickshop.Shop.ContainerShop;
|
||||
@@ -31,6 +43,7 @@ import org.maxgamer.quickshop.Shop.Info;
|
||||
import org.maxgamer.quickshop.Shop.Shop;
|
||||
import org.maxgamer.quickshop.Shop.ShopAction;
|
||||
import org.maxgamer.quickshop.Shop.ShopChunk;
|
||||
import org.maxgamer.quickshop.Shop.ShopManager;
|
||||
import org.maxgamer.quickshop.Shop.ShopType;
|
||||
import org.maxgamer.quickshop.Util.MsgUtil;
|
||||
import org.maxgamer.quickshop.Util.Util;
|
||||
@@ -584,6 +597,9 @@ public class QS implements CommandExecutor {
|
||||
} else if (subArg.equals("about")) {
|
||||
about(sender);
|
||||
return true;
|
||||
} else if (subArg.equals("remove")) {
|
||||
remover(sender,args);
|
||||
return true;
|
||||
} else if (subArg.equals("info")) {
|
||||
if (sender.hasPermission("quickshop.info")) {
|
||||
int buying, selling, doubles, chunks, worlds;
|
||||
@@ -625,6 +641,26 @@ public class QS implements CommandExecutor {
|
||||
sendHelp(sender);
|
||||
return true;
|
||||
}
|
||||
// X Y Z WORLD
|
||||
private void remover(CommandSender sender, String[] args) {
|
||||
if(args.length<5) {
|
||||
return;
|
||||
}
|
||||
ShopManager manager = new ShopManager(plugin);
|
||||
try {
|
||||
Shop shop = manager.getShop(new Location(Bukkit.getWorld(args[4]), Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3])));
|
||||
if(shop==null) {
|
||||
sender.sendMessage(MsgUtil.getMessage("shop-not-exist"));
|
||||
return;
|
||||
}
|
||||
DatabaseHelper.removeShop(plugin.getDB(),Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3]), args[4]);
|
||||
shop.onUnload();
|
||||
sender.sendMessage(MsgUtil.getMessage("success-removed-shop"));
|
||||
} catch (NumberFormatException | SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns loc with modified pitch/yaw angles so it faces lookat
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.maxgamer.quickshop.Listeners;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -45,98 +46,121 @@ public class PlayerListener implements Listener {
|
||||
* clazz = clazz.getSuperclass(); } return classes; }
|
||||
*/
|
||||
/**
|
||||
* Handles players left clicking a chest. Left click a NORMAL chest with
|
||||
* item : Send creation menu Left click a SHOP chest : Send purchase menu
|
||||
* Handles players left clicking a chest. Left click a NORMAL chest with item :
|
||||
* Send creation menu Left click a SHOP chest : Send purchase menu
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled=true)
|
||||
//Ignore already cancelled event... Player shouldn't create shop in there...
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
// Ignore already cancelled event... Player shouldn't create shop in there...
|
||||
public void onClick(PlayerInteractEvent e) {
|
||||
if (e.getAction() != Action.LEFT_CLICK_BLOCK)
|
||||
return;
|
||||
Block b = e.getClickedBlock();
|
||||
if (!Util.canBeShop(b) && b.getType() != Material.WALL_SIGN)
|
||||
return;
|
||||
Player p = e.getPlayer();
|
||||
if (plugin.sneak && !p.isSneaking()) {
|
||||
// Sneak only
|
||||
return;
|
||||
}
|
||||
Location loc = b.getLocation();
|
||||
ItemStack item = e.getItem();
|
||||
// Get the shop
|
||||
Shop shop = plugin.getShopManager().getShop(loc);
|
||||
// If that wasn't a shop, search nearby shops
|
||||
if (shop == null) {
|
||||
Block attached = null;
|
||||
|
||||
if (b.getType() == Material.WALL_SIGN) {
|
||||
attached = Util.getAttached(b);
|
||||
if (attached != null) {
|
||||
shop = plugin.getShopManager().getShop(attached.getLocation());
|
||||
}
|
||||
} else if (b.getType() == Material.CHEST || b.getType() == Material.TRAPPED_CHEST) {
|
||||
attached = Util.getSecondHalf(b);
|
||||
if (attached != null) {
|
||||
Shop secondHalfShop = plugin.getShopManager().getShop(attached.getLocation());
|
||||
if (secondHalfShop != null && !p.getUniqueId().equals(secondHalfShop.getOwner())) {
|
||||
// If player not the owner of the shop, make him select the second half of the shop
|
||||
// Otherwise owner will be able to create new double chest shop
|
||||
shop = secondHalfShop;
|
||||
if (e.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
|
||||
Block b = e.getClickedBlock();
|
||||
if (!Util.canBeShop(b) && b.getType() != Material.WALL_SIGN)
|
||||
return;
|
||||
Player p = e.getPlayer();
|
||||
if (plugin.sneak && !p.isSneaking()) {
|
||||
// Sneak only
|
||||
return;
|
||||
}
|
||||
Location loc = b.getLocation();
|
||||
ItemStack item = e.getItem();
|
||||
// Get the shop
|
||||
Shop shop = plugin.getShopManager().getShop(loc);
|
||||
// If that wasn't a shop, search nearby shops
|
||||
if (shop == null) {
|
||||
Block attached = null;
|
||||
|
||||
if (b.getType() == Material.WALL_SIGN) {
|
||||
attached = Util.getAttached(b);
|
||||
if (attached != null) {
|
||||
shop = plugin.getShopManager().getShop(attached.getLocation());
|
||||
}
|
||||
} else if (b.getType() == Material.CHEST || b.getType() == Material.TRAPPED_CHEST) {
|
||||
attached = Util.getSecondHalf(b);
|
||||
if (attached != null) {
|
||||
Shop secondHalfShop = plugin.getShopManager().getShop(attached.getLocation());
|
||||
if (secondHalfShop != null && !p.getUniqueId().equals(secondHalfShop.getOwner())) {
|
||||
// If player not the owner of the shop, make him select the second half of the
|
||||
// shop
|
||||
// Otherwise owner will be able to create new double chest shop
|
||||
shop = secondHalfShop;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Purchase handling
|
||||
if (shop != null && p.hasPermission("quickshop.use") && (plugin.sneakTrade == false || p.isSneaking())) {
|
||||
shop.onClick();
|
||||
// Text menu
|
||||
MsgUtil.sendShopInfo(p, shop);
|
||||
shop.setSignText();
|
||||
if (shop.isSelling()) {
|
||||
p.sendMessage(MsgUtil.getMessage("how-many-buy"));
|
||||
// Purchase handling
|
||||
if (shop != null && p.hasPermission("quickshop.use") && (plugin.sneakTrade == false || p.isSneaking())) {
|
||||
shop.onClick();
|
||||
// Text menu
|
||||
MsgUtil.sendShopInfo(p, shop);
|
||||
shop.setSignText();
|
||||
if (shop.isSelling()) {
|
||||
p.sendMessage(MsgUtil.getMessage("how-many-buy"));
|
||||
} else {
|
||||
int items = Util.countItems(p.getInventory(), shop.getItem());
|
||||
p.sendMessage(MsgUtil.getMessage("how-many-sell", "" + items));
|
||||
}
|
||||
// Add the new action
|
||||
HashMap<UUID, Info> actions = plugin.getShopManager().getActions();
|
||||
Info info = new Info(shop.getLocation(), ShopAction.BUY, null, null, shop);
|
||||
actions.put(p.getUniqueId(), info);
|
||||
return;
|
||||
}
|
||||
// Handles creating shops
|
||||
else if (!e.isCancelled() && shop == null && item != null && item.getType() != Material.AIR
|
||||
&& p.hasPermission("quickshop.create.sell") && Util.canBeShop(b)
|
||||
&& p.getGameMode() != GameMode.CREATIVE && (plugin.sneakCreate == false || p.isSneaking())) {
|
||||
if (!plugin.getShopManager().canBuildShop(p, b, e.getBlockFace())) {
|
||||
// As of the new checking system, most plugins will tell the
|
||||
// player why they can't create a shop there.
|
||||
// So telling them a message would cause spam etc.
|
||||
return;
|
||||
}
|
||||
if (Util.getSecondHalf(b) != null && !p.hasPermission("quickshop.create.double")) {
|
||||
p.sendMessage(MsgUtil.getMessage("no-double-chests"));
|
||||
return;
|
||||
}
|
||||
if (Util.isBlacklisted(item.getType())
|
||||
&& !p.hasPermission("quickshop.bypass." + item.getType().name())) {
|
||||
p.sendMessage(MsgUtil.getMessage("blacklisted-item"));
|
||||
return;
|
||||
}
|
||||
// Finds out where the sign should be placed for the shop
|
||||
Block last = null;
|
||||
Location from = p.getLocation().clone();
|
||||
from.setY(b.getY());
|
||||
from.setPitch(0);
|
||||
BlockIterator bIt = new BlockIterator(from, 0, 7);
|
||||
while (bIt.hasNext()) {
|
||||
Block n = bIt.next();
|
||||
if (n.equals(b))
|
||||
break;
|
||||
last = n;
|
||||
}
|
||||
// Send creation menu.
|
||||
Info info = new Info(b.getLocation(), ShopAction.CREATE, e.getItem(), last);
|
||||
plugin.getShopManager().getActions().put(p.getUniqueId(), info);
|
||||
p.sendMessage(
|
||||
MsgUtil.getMessage("how-much-to-trade-for", MsgUtil.getItemi18n(Util.getName(info.getItem()))));
|
||||
}
|
||||
} else if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
|
||||
/** @TODO: ControlPanel **/
|
||||
ShopManager manager = new ShopManager(plugin);
|
||||
Shop shop = null;
|
||||
if (manager.getShop(e.getClickedBlock().getLocation()) != null) {
|
||||
shop = manager.getShop(e.getClickedBlock().getLocation());
|
||||
} else {
|
||||
int items = Util.countItems(p.getInventory(), shop.getItem());
|
||||
p.sendMessage(MsgUtil.getMessage("how-many-sell", "" + items));
|
||||
Block block = Util.getAttached(e.getClickedBlock());
|
||||
if (manager.getShop(block.getLocation()) != null) {
|
||||
shop = manager.getShop(block.getLocation());
|
||||
} else {
|
||||
shop = null;
|
||||
}
|
||||
}
|
||||
if (shop != null) {
|
||||
MsgUtil.sendControlPanelInfo((CommandSender) e.getPlayer(), shop);
|
||||
}
|
||||
// Add the new action
|
||||
HashMap<UUID, Info> actions = plugin.getShopManager().getActions();
|
||||
Info info = new Info(shop.getLocation(), ShopAction.BUY, null, null, shop);
|
||||
actions.put(p.getUniqueId(), info);
|
||||
return;
|
||||
}
|
||||
// Handles creating shops
|
||||
else if (!e.isCancelled() && shop == null && item != null && item.getType() != Material.AIR && p.hasPermission("quickshop.create.sell") && Util.canBeShop(b) && p.getGameMode() != GameMode.CREATIVE && (plugin.sneakCreate == false || p.isSneaking())) {
|
||||
if (!plugin.getShopManager().canBuildShop(p, b, e.getBlockFace())) {
|
||||
// As of the new checking system, most plugins will tell the
|
||||
// player why they can't create a shop there.
|
||||
// So telling them a message would cause spam etc.
|
||||
return;
|
||||
}
|
||||
if (Util.getSecondHalf(b) != null && !p.hasPermission("quickshop.create.double")) {
|
||||
p.sendMessage(MsgUtil.getMessage("no-double-chests"));
|
||||
return;
|
||||
}
|
||||
if (Util.isBlacklisted(item.getType()) && !p.hasPermission("quickshop.bypass." + item.getType().name())) {
|
||||
p.sendMessage(MsgUtil.getMessage("blacklisted-item"));
|
||||
return;
|
||||
}
|
||||
// Finds out where the sign should be placed for the shop
|
||||
Block last = null;
|
||||
Location from = p.getLocation().clone();
|
||||
from.setY(b.getY());
|
||||
from.setPitch(0);
|
||||
BlockIterator bIt = new BlockIterator(from, 0, 7);
|
||||
while (bIt.hasNext()) {
|
||||
Block n = bIt.next();
|
||||
if (n.equals(b))
|
||||
break;
|
||||
last = n;
|
||||
}
|
||||
// Send creation menu.
|
||||
Info info = new Info(b.getLocation(), ShopAction.CREATE, e.getItem(), last);
|
||||
plugin.getShopManager().getActions().put(p.getUniqueId(), info);
|
||||
p.sendMessage(MsgUtil.getMessage("how-much-to-trade-for", MsgUtil.getItemi18n(Util.getName(info.getItem()))));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
|
||||
@@ -147,24 +147,7 @@ public class QuickShop extends JavaPlugin {
|
||||
if (mPlugin != null) {
|
||||
getLogger().info("Successfully loaded MultiverseCore support!");
|
||||
}
|
||||
|
||||
int CurrentConfigVersion = 6;
|
||||
|
||||
if (getConfig().getInt("config-version") != CurrentConfigVersion) {
|
||||
if (!updateConfig(getConfig().getInt("config-version"), CurrentConfigVersion)) {
|
||||
getLogger().warning(
|
||||
"WARNING! You not have lastet version config.yml, And Failed to auto update, Please follow SpigotMC updatelog to update your config.yml!");
|
||||
getLogger().warning(
|
||||
"WARNING! You not have lastet version config.yml, And Failed to auto update, Please follow SpigotMC updatelog to update your config.yml!");
|
||||
getLogger().warning("WARNING! Server will continue boot in 5 seconds...");
|
||||
}
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
updateConfig(getConfig().getInt("config-version"));
|
||||
|
||||
// Initialize Util
|
||||
Util.initialize();
|
||||
@@ -724,15 +707,8 @@ public class QuickShop extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean updateConfig(int oldConfigVersion, int currentConfigVersion) {
|
||||
updateConfig(oldConfigVersion);
|
||||
|
||||
getLogger().info("Complete config update!");
|
||||
return true;
|
||||
}
|
||||
|
||||
public void updateConfig(int selectedVersion) {
|
||||
getLogger().info("Auto updateing config.yml ...");
|
||||
if (selectedVersion == 1) {
|
||||
getConfig().set("disabled-metrics", false);
|
||||
getConfig().set("config-version", 2);
|
||||
@@ -763,6 +739,11 @@ public class QuickShop extends JavaPlugin {
|
||||
getConfig().set("config-version", 6);
|
||||
selectedVersion = 6;
|
||||
}
|
||||
if (selectedVersion == 7) {
|
||||
getConfig().set("shop.sneak-to-control", false);
|
||||
getConfig().set("config-version", 7);
|
||||
selectedVersion = 7;
|
||||
}
|
||||
}
|
||||
|
||||
/** Reloads QuickShops config */
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -26,6 +27,11 @@ import org.bukkit.potion.PotionEffectType;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Shop.Shop;
|
||||
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
public class MsgUtil {
|
||||
static QuickShop plugin = QuickShop.instance;
|
||||
private static YamlConfiguration messages;
|
||||
@@ -56,6 +62,134 @@ public class MsgUtil {
|
||||
messages.setDefaults(defMessages);
|
||||
// Parse colour codes
|
||||
Util.parseColours(messages);
|
||||
|
||||
|
||||
if(messages.getInt("language-version")==0) {
|
||||
messages.set("language-version", 1 );
|
||||
}
|
||||
updateMessages(messages.getInt("language-version"));
|
||||
}
|
||||
|
||||
public static void updateMessages(int selectedVersion) {
|
||||
plugin.getLogger().info("Auto updateing messages.yml ...");
|
||||
if (selectedVersion == 1) {
|
||||
messages.set("shop-not-exist", "&cThere had no shop.");
|
||||
messages.set("controlpanel.infomation", "&aShop Control Panel:");
|
||||
messages.set("controlpanel.setowner", "&aOwner: &b{0} &e[&d&lChange&e]");
|
||||
messages.set("controlpanel.setowner-hover", "&eLooking you want changing shop and click to switch owner.");
|
||||
messages.set("controlpanel.unlimited", "&aUnlimited: {0} &e[&rSwitch&e]");
|
||||
messages.set("controlpanel.unlimited-hover", "&eLooking you want changing shop and click to switch enabled or disabled.");
|
||||
messages.set("controlpanel.mode-selling", "&aShop mode: &bSelling &e[&d&lSwitch&e]");
|
||||
messages.set("controlpanel.mode-selling-hover", "&eLooking you want changing shop and click to switch enabled or disabled.");
|
||||
messages.set("controlpanel.mode-buying", "&aShop mode: &bBuying &e[&d&lSwitch&e]");
|
||||
messages.set("controlpanel.mode-buying-hover", "&eLooking you want changing shop and click to switch enabled or disabled.");
|
||||
messages.set("controlpanel.price", "&aPrice: &b{0} &e[&d&lSet&e]");
|
||||
messages.set("controlpanel.price-hover", "&eLooking you want changing shop and click to set new price.");
|
||||
messages.set("controlpanel.refill", "&aRefill: Refill the shop items &e[&d&lOK&e]");
|
||||
messages.set("controlpanel.refill-hover", "&eLooking you want changing shop and click to refill.");
|
||||
messages.set("controlpanel.empty", "&aEmpty: Remove shop all items &e[&d&lOK&e]");
|
||||
messages.set("controlpanel.empty-hover", "&eLooking you want changing shop and click to clear.");
|
||||
messages.set("controlpanel.remove", "&c&l[Remove Shop]");
|
||||
messages.set("controlpanel.remove-hover", "&eClick to remove this shop.");
|
||||
messages.set("config-version", 2);
|
||||
selectedVersion = 2;
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendControlPanelInfo(CommandSender sender, Shop shop) {
|
||||
if (!sender.hasPermission("quickshop.use")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getConfig().getBoolean("sneak-to-control"))
|
||||
if (sender instanceof Player)
|
||||
if (!((Player) sender).isSneaking())
|
||||
return;
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
|
||||
sender.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.getMessage("controlpanel.infomation"));
|
||||
// Owner
|
||||
if (!sender.hasPermission("quickshop.setowner")) {
|
||||
sender.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.getMessage("menu.owner", shop.ownerName()));
|
||||
} else {
|
||||
String Text = MsgUtil.getMessage("controlpanel.setowner");
|
||||
String hoverText = MsgUtil.getMessage("controlpanel.setowner-hover");
|
||||
String clickCommand = "/qs setowner [Player]";
|
||||
TextComponent message = new TextComponent(ChatColor.DARK_PURPLE + "| " + Text);
|
||||
message.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, clickCommand));
|
||||
message.setHoverEvent(
|
||||
new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(hoverText).create()));
|
||||
sender.spigot().sendMessage(message);
|
||||
}
|
||||
// Unlimited
|
||||
if (sender.hasPermission("quickshop.unlimited")) {
|
||||
String Text = MsgUtil.getMessage("controlpanel.unlimited", bool2String(shop.isUnlimited()));
|
||||
String hoverText = MsgUtil.getMessage("controlpanel.unlimited-hover");
|
||||
String clickCommand = "/qs unlimited";
|
||||
MsgUtil.sendPanelMessage(sender, Text, hoverText, clickCommand);
|
||||
}
|
||||
// Buying/Selling Mode
|
||||
if (sender.hasPermission("quickshop.create.buy") && sender.hasPermission("quickshop.create.sell")) {
|
||||
if (shop.isSelling()) {
|
||||
String Text = MsgUtil.getMessage("controlpanel.mode-selling");
|
||||
String hoverText = MsgUtil.getMessage("controlpanel.mode-selling-hover");
|
||||
String clickCommand = "/qs buy";
|
||||
MsgUtil.sendPanelMessage(sender, Text, hoverText, clickCommand);
|
||||
} else if (shop.isBuying()) {
|
||||
String Text = MsgUtil.getMessage("controlpanel.mode-buying");
|
||||
String hoverText = MsgUtil.getMessage("controlpanel.mode-buying-hover");
|
||||
String clickCommand = "/qs sell";
|
||||
MsgUtil.sendPanelMessage(sender, Text, hoverText, clickCommand);
|
||||
}
|
||||
}
|
||||
// Set Price
|
||||
if (sender.hasPermission("quickshop.other.price")) {
|
||||
String Text = MsgUtil.getMessage("controlpanel.price", String.valueOf(shop.getPrice()));
|
||||
String hoverText = MsgUtil.getMessage("controlpanel.mode-buying-hover");
|
||||
String clickCommand = "/qs price [New Price]";
|
||||
TextComponent message = new TextComponent(ChatColor.DARK_PURPLE + "| " + Text);
|
||||
message.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, clickCommand));
|
||||
message.setHoverEvent(
|
||||
new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(hoverText).create()));
|
||||
sender.spigot().sendMessage(message);
|
||||
}
|
||||
// Refill
|
||||
if (sender.hasPermission("quickshop.refill")) {
|
||||
String Text = MsgUtil.getMessage("controlpanel.refill", String.valueOf(shop.getPrice()));
|
||||
String hoverText = MsgUtil.getMessage("controlpanel.refill-hover");
|
||||
String clickCommand = "/qs refill";
|
||||
MsgUtil.sendPanelMessage(sender, Text, hoverText, clickCommand);
|
||||
}
|
||||
// Refill
|
||||
if (sender.hasPermission("quickshop.empty")) {
|
||||
String Text = MsgUtil.getMessage("controlpanel.empty", String.valueOf(shop.getPrice()));
|
||||
String hoverText = MsgUtil.getMessage("controlpanel.empty-hover");
|
||||
String clickCommand = "/qs empty";
|
||||
MsgUtil.sendPanelMessage(sender, Text, hoverText, clickCommand);
|
||||
}
|
||||
// Remove
|
||||
if (sender.hasPermission("quickshop.other.destroy") || shop.getOwner().equals(((Player)sender).getUniqueId())) {
|
||||
String Text = MsgUtil.getMessage("controlpanel.remove", String.valueOf(shop.getPrice()));
|
||||
String hoverText = MsgUtil.getMessage("controlpanel.remove-hover");
|
||||
String clickCommand = "/qs remove "+shop.getLocation().getBlockX()+" "+shop.getLocation().getBlockY()+" "+shop.getLocation().getBlockZ();
|
||||
MsgUtil.sendPanelMessage(sender, Text, hoverText, clickCommand);
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
|
||||
}
|
||||
public static void sendPanelMessage(CommandSender sender, String Text,String hoverText, String clickCommand) {
|
||||
TextComponent message = new TextComponent(ChatColor.DARK_PURPLE + "| " + Text);
|
||||
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, clickCommand));
|
||||
message.setHoverEvent(new HoverEvent (HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(hoverText).create()));
|
||||
sender.spigot().sendMessage(message);
|
||||
}
|
||||
public static String bool2String(boolean bool) {
|
||||
if(bool) {
|
||||
return ChatColor.GREEN + "✔";
|
||||
}else {
|
||||
return ChatColor.RED + "✘";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,8 +267,7 @@ public class MsgUtil {
|
||||
return Itemname_i18n;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void loadEnchi18n() {
|
||||
plugin.getLogger().info("Starting loading Enchantment i18n...");
|
||||
|
||||
Reference in new issue
Block a user