Add fetchMessage, Add tabComplete

Former-commit-id: ea15b864b591fe0f35607bf3769535be8b92cf59 [formerly 66cfb2eca3e86c383edf4e1593567e375764a678]
Former-commit-id: 43234c81912272df8b0edd3310091832bdab656a
This commit is contained in:
Ghost_chu committed 2019-01-15 22:01:19 +08:00
1 parent fa778858ff
commit f3eb3b99b8
6 files changed
+108 -35

No files matched your search

@@ -748,7 +748,8 @@ public class QS implements CommandExecutor{
+ " chunks spread over " + worlds + " worlds.");
sender.sendMessage(ChatColor.GREEN + "" + doubles + " double shops. ");
sender.sendMessage(ChatColor.GREEN + "" + nostock
+ " selling shops (excluding doubles) which will be removed by /qs clean.");
+ " nostock selling shops (excluding doubles) which will be removed by /qs clean.");
sender.sendMessage(ChatColor.GREEN + "QuickShop "+QuickShop.getVersion());
return true;
}
sender.sendMessage(MsgUtil.getMessage("no-permission"));
@@ -840,6 +841,7 @@ public class QS implements CommandExecutor{
}
}
public void sendHelp(CommandSender s) {
s.sendMessage(MsgUtil.getMessage("command.description.title"));
if (s.hasPermission("quickshop.unlimited"))
s.sendMessage(ChatColor.GREEN + "/qs unlimited" + ChatColor.YELLOW + " - "
@@ -878,4 +880,5 @@ public class QS implements CommandExecutor{
// s.sendMessage(ChatColor.GREEN + "/qs export mysql|sqlite" + ChatColor.YELLOW + " - "
// + MsgUtil.getMessage("command.description.export"));
}
}
@@ -0,0 +1,67 @@
package org.maxgamer.quickshop.Command;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.maxgamer.quickshop.QuickShop;
public class Tab implements TabCompleter {
QuickShop plugin;
public Tab(QuickShop plugin) {
this.plugin = plugin;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
for (int i = 0; i < args.length; i++) {
args[i] = args[i].toLowerCase();
//Make all is low case
}
ArrayList<String> tabList = new ArrayList<>();
if(args.length==1) {
if (sender.hasPermission("quickshop.unlimited"))
tabList.add("unlimited");
if (sender.hasPermission("quickshop.setowner"))
tabList.add("setowner");
if (sender.hasPermission("quickshop.create.buy"))
tabList.add("buy");
if (sender.hasPermission("quickshop.create.sell")) {
tabList.add("sell");
tabList.add("create");
}
if (sender.hasPermission("quickshop.create.changeprice"))
tabList.add("price");
if (sender.hasPermission("quickshop.clean"))
tabList.add("clean");
if (sender.hasPermission("quickshop.find"))
tabList.add("find");
if (sender.hasPermission("quickshop.refill"))
tabList.add("refill");
if (sender.hasPermission("quickshop.empty"))
tabList.add("empty");
if (sender.hasPermission("quickshop.fetchmessage"))
tabList.add("fetchmessage");
return tabList;
}else if(args.length==2) {
if (args[1].equals("create")&&sender.hasPermission("quickshop.create.sell")) {
tabList.add("[price]");
}
if (args[1].equals("price")&&sender.hasPermission("quickshop.create.changeprice")) {
tabList.add("[price]");
}
if (args[1].equals("find")&&sender.hasPermission("quickshop.find")) {
tabList.add("[range]");
}
if (args[1].equals("refill")&&sender.hasPermission("quickshop.refill")) {
tabList.add("[amount]");
}
return tabList;
}else {
return null;
}
}
}
@@ -13,6 +13,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import org.maxgamer.quickshop.Command.QS;
import org.maxgamer.quickshop.Command.Tab;
import org.maxgamer.quickshop.Database.*;
import org.maxgamer.quickshop.Database.Database.ConnectionException;
import org.maxgamer.quickshop.Economy.Economy;
@@ -91,6 +92,7 @@ public class QuickShop extends JavaPlugin {
private boolean noopDisable;
private boolean setupDBonEnableding = false;
public String dbPrefix="";
private Tab commandTabCompleter;
public int getShopLimit(Player p) {
int max = getConfig().getInt("limits.default");
for (Entry<String, Integer> entry : limits.entrySet()) {
@@ -398,6 +400,8 @@ public class QuickShop extends JavaPlugin {
// Command handlers
commandExecutor = new QS(this);
getCommand("qs").setExecutor(commandExecutor);
commandTabCompleter = new Tab(this);
getCommand("qs").setTabCompleter(commandTabCompleter);
if (getConfig().getInt("shop.find-distance") > 100) {
getLogger().severe("Shop.find-distance is too high! It may cause lag! Pick a number under 100!");
}
@@ -530,7 +534,32 @@ public class QuickShop extends JavaPlugin {
UpdateWatcher.init();
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
getLogger().info("YAY Tab!");
List<String> commands = new ArrayList<>();
commands.add("unlimited");
commands.add("buy");
commands.add("sell");
commands.add("create");
commands.add("price");
commands.add("clean");
commands.add("range");
commands.add("refill");
commands.add("empty");
commands.add("setowner");
commands.add("fetchmessage");
if (args != null && args.length == 1) {
List<String> list = new ArrayList<>();
for (String s : commands) {
if (s.startsWith(args[0])) {
list.add(s);
}
}
return list;
}
return null;
}
public boolean setupDatabase() {
try {
ConfigurationSection dbCfg = getConfig().getConfigurationSection("database");
@@ -710,8 +739,10 @@ public class QuickShop extends JavaPlugin {
reloadConfig();
}
if (selectedVersion == 15) {
getConfig().set("ongoingfee",null);
getConfig().set("shop.display-item-use-name",null);
getConfig().set("shop.display-item-show-name",false);
getConfig().set("shop.auto-fetch-shop-messages",true);
getConfig().set("config-version", 16);
selectedVersion = 16;
saveConfig();
@@ -840,36 +871,4 @@ public class QuickShop extends JavaPlugin {
return QuickShop.instance.getDescription().getVersion();
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
for (int i = 0; i < args.length; i++) {
args[i] = args[i].toLowerCase();
//Make all is low case
}
if(args!=null&&args.length==1) {
ArrayList<String> tabList = new ArrayList<>();
tabList.add("unlimited");
tabList.add("buy");
tabList.add("sell");
tabList.add("create");
tabList.add("price");
tabList.add("clean");
tabList.add("range");
tabList.add("refill");
tabList.add("empty");
tabList.add("setowner");
tabList.add("fetchmessage");
ArrayList<String> finalTabList = new ArrayList<>();
for (String s : tabList) {
if (s.startsWith(args[0])) {
finalTabList.add(s);
}
}
return finalTabList;
}else {
return null;
}
}
}
@@ -142,6 +142,7 @@ public class MsgUtil {
}
if (selectedVersion == 5) {
messagei18n.set("command.description.fetchmessage", "&eFetch unread shop message");
messagei18n.set("nothing-to-flush", "&aYou had no new shop message.");
messagei18n.set("language-version", 6);
selectedVersion = 6;
messagei18n.save(messageFile);
@@ -504,6 +505,8 @@ public class MsgUtil {
}
plugin.getDB().execute("DELETE FROM messages WHERE owner = ?", pName.toString());
msgs.clear();
}else {
p.getPlayer().sendMessage(getMessage("nothing-to-flush"));
}
return true;
}
+1
View File
@@ -59,6 +59,7 @@ owner-bypass-check: "&eBypass all check,Trade successful! (You are shop owner)"
reached-maximum-can-create: "&cYou have already created a maximum of {0}/{1} shops!"
restricted-prices: "&cRestricted prices for {0}: min {1} , max {2}"
no-enough-money-to-keep-shops: "&cYou had no money to keep your shops! All shops removed..."
nothing-to-flush: "&aYou had no new shop message."
menu:
successful-purchase: "&aSuccessfully Purchased:"
successfully-sold: "&aSuccessfully Sold:"
+1 -1
View File
@@ -13,7 +13,7 @@ commands:
qs:
description: QuickShop command
usage: /qs
aliases: [shop]
aliases: [shop,qsshop,qshop,quickshop]
permissions:
quickshop.create.sell: