add silent info

Former-commit-id: 24d3bd823d2a58cfd29969ba0abb0a7c10afd168 [formerly 54023d1a510557cf72d7c2e860bc0bbdd22b6f00]
Former-commit-id: 0ecfd1f9ca6c57c9b2c0e114c3492fe5d5b1bef4
This commit is contained in:
Ghost_chu committed 2018-11-21 18:37:23 +08:00
1 parent b4eb28edf7
commit 2e245c738d
3 files changed
+83 -28

No files matched your search

@@ -208,7 +208,25 @@ public class QS implements CommandExecutor {
return;
}
}
private void silentUnlimited(CommandSender sender, String[]args) {
if (sender.hasPermission("quickshop.unlimited")) {
Shop shop = plugin.getShopManager().getShop(new Location(Bukkit.getWorld(args[1]), Integer.valueOf(args[2]),
Integer.valueOf(args[3]), Integer.valueOf(args[4])));
if (shop != null) {
shop.setUnlimited(!shop.isUnlimited());
shop.setSignText();
shop.update();
sender.sendMessage(MsgUtil.getMessage("command.toggle-unlimited",
(shop.isUnlimited() ? "unlimited" : "limited")));
return;
}
} else {
sender.sendMessage(MsgUtil.getMessage("no-permission"));
return;
}
}
private void sign(CommandSender sender, String[] args) {
if (!(sender instanceof Player))
return;
@@ -812,6 +830,9 @@ public class QS implements CommandExecutor {
if (subArg.equals("unlimited")) {
setUnlimited(sender);
return true;
} else if (subArg.startsWith("unlimited")) {
silentUnlimited(sender, args);
return true;
} else if (subArg.equals("setowner")) {
setOwner(sender, args);
return true;
@@ -13,6 +13,7 @@ import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.UUID;
import org.apache.commons.io.output.ThresholdingOutputStream;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@@ -212,11 +213,15 @@ public class MsgUtil {
sender.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
}
public static void sendControlPanelInfo(CommandSender sender, Shop shop) {
if (!sender.hasPermission("quickshop.use")) {
return;
}
if (plugin.protocolLibPlugin == null) {
sendNormalControlPanelInfo(sender, shop);
return;
}
if (plugin.getConfig().getBoolean("sneak-to-control"))
if (sender instanceof Player)
if (!((Player) sender).isSneaking())
@@ -229,20 +234,26 @@ public class MsgUtil {
if (!sender.hasPermission("quickshop.setowner")) {
sender.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.getMessage("menu.owner", shop.ownerName()));
} else {
String Text = MsgUtil.getMessage("controlpanel.setowner",shop.ownerName());
String Text = MsgUtil.getMessage("controlpanel.setowner", shop.ownerName());
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);
String type = "owner";
String clickCommand = "/qs sign " + shop.getLocation().getWorld().getName() + " "
+ shop.getLocation().getBlockX() + " " + shop.getLocation().getBlockY() + " "
+ shop.getLocation().getBlockZ() + " " + type + " " + "controlpanel.sign." + type + ".line1" + " "
+ "controlpanel.sign." + type + ".line2" + " " + "controlpanel.sign." + type + ".line3" + " "
+ "controlpanel.sign." + type + ".line4";
MsgUtil.sendPanelMessage(sender, Text, hoverText, clickCommand);
}
// 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";
String type = "unlimited";
String clickCommand = "/qs silentunlimited " + shop.getLocation().getWorld().getName() + " "
+ shop.getLocation().getBlockX() + " " + shop.getLocation().getBlockY() + " "
+ shop.getLocation().getBlockZ() + " " + "controlpanel.sign." + type + ".line1" + " "
+ "controlpanel.sign." + type + ".line2" + " " + "controlpanel.sign." + type + ".line3" + " "
+ "controlpanel.sign." + type + ".line4";
MsgUtil.sendPanelMessage(sender, Text, hoverText, clickCommand);
}
// Buying/Selling Mode
@@ -250,12 +261,22 @@ public class MsgUtil {
if (shop.isSelling()) {
String Text = MsgUtil.getMessage("controlpanel.mode-selling");
String hoverText = MsgUtil.getMessage("controlpanel.mode-selling-hover");
String clickCommand = "/qs buy";
String type = "buy";
String clickCommand = "/qs silentbuy " + shop.getLocation().getWorld().getName() + " "
+ shop.getLocation().getBlockX() + " " + shop.getLocation().getBlockY() + " "
+ shop.getLocation().getBlockZ() + " " + "controlpanel.sign." + type + ".line1"
+ " " + "controlpanel.sign." + type + ".line2" + " " + "controlpanel.sign." + type + ".line3"
+ " " + "controlpanel.sign." + type + ".line4";
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";
String type = "sell";
String clickCommand = "/qs silentsell " + shop.getLocation().getWorld().getName() + " "
+ shop.getLocation().getBlockX() + " " + shop.getLocation().getBlockY() + " "
+ shop.getLocation().getBlockZ() + " " +"controlpanel.sign." + type + ".line1"
+ " " + "controlpanel.sign." + type + ".line2" + " " + "controlpanel.sign." + type + ".line3"
+ " " + "controlpanel.sign." + type + ".line4";
MsgUtil.sendPanelMessage(sender, Text, hoverText, clickCommand);
}
}
@@ -263,36 +284,49 @@ public class MsgUtil {
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);
String type = "price";
String clickCommand = "/qs sign " + shop.getLocation().getWorld().getName() + " "
+ shop.getLocation().getBlockX() + " " + shop.getLocation().getBlockY() + " "
+ shop.getLocation().getBlockZ() + " " + type + " " + "controlpanel.sign." + type + ".line1" + " "
+ "controlpanel.sign." + type + ".line2" + " " + "controlpanel.sign." + type + ".line3" + " "
+ "controlpanel.sign." + type + ".line4";
MsgUtil.sendPanelMessage(sender, Text, hoverText, clickCommand);
}
// 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 [Amount]";
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);
String type = "refill";
String clickCommand = "/qs sign " + shop.getLocation().getWorld().getName() + " "
+ shop.getLocation().getBlockX() + " " + shop.getLocation().getBlockY() + " "
+ shop.getLocation().getBlockZ() + " " + type + " " + "controlpanel.sign." + type + ".line1" + " "
+ "controlpanel.sign." + type + ".line2" + " " + "controlpanel.sign." + type + ".line3" + " "
+ "controlpanel.sign." + type + ".line4";
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";
String type = "empty";
String clickCommand = "/qs silentempty " + shop.getLocation().getWorld().getName() + " "
+ shop.getLocation().getBlockX() + " " + shop.getLocation().getBlockY() + " "
+ shop.getLocation().getBlockZ() + " " +"controlpanel.sign." + type + ".line1" + " "
+ "controlpanel.sign." + type + ".line2" + " " + "controlpanel.sign." + type + ".line3" + " "
+ "controlpanel.sign." + type + ".line4";
MsgUtil.sendPanelMessage(sender, Text, hoverText, clickCommand);
}
// Remove
if (sender.hasPermission("quickshop.other.destroy") || shop.getOwner().equals(((Player)sender).getUniqueId())) {
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();
String type = "remove";
String clickCommand = "/qs silentremove " + shop.getLocation().getWorld().getName() + " "
+ shop.getLocation().getBlockX() + " " + shop.getLocation().getBlockY() + " "
+ shop.getLocation().getBlockZ() + " " + "controlpanel.sign." + type + ".line1" + " "
+ "controlpanel.sign." + type + ".line2" + " " + "controlpanel.sign." + type + ".line3" + " "
+ "controlpanel.sign." + type + ".line4";
MsgUtil.sendPanelMessage(sender, Text, hoverText, clickCommand);
}
@@ -201,7 +201,7 @@ public class Util {
NbtCompound compound = (NbtCompound) dataPacket.getNbtModifier().read(0);
for (int index = 0; index < 4; index++) {
compound.put("Text" + (index + 1), "{\"extra\":[{\"text\":\"" + texts[index] + "\"}],\"text\":\"\"}");
compound.put("Text" + (index + 1), "{\"extra\":[{\"text\":\"" + MsgUtil.getMessage(texts[index]) + "\"}],\"text\":\"\"}");
}
dataPacket.getNbtModifier().write(0, compound);