mirror of
https://gitlab.com/SamB440/rpgregions-2.git
synced 2025-12-19 14:59:19 +00:00
Add further command tab completions, add more stats for bStats
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.id="RPGRegions" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="net.islandearth" external.system.module.version="1.0.5" type="JAVA_MODULE" version="4">
|
||||
<component name="ExternalSystem" externalSystem="GRADLE" externalSystemModuleGroup="net.islandearth" externalSystemModuleVersion="1.2.3" linkedProjectId="RPGRegions" linkedProjectPath="$MODULE_DIR$" rootProjectPath="$MODULE_DIR$" />
|
||||
<component name="ExternalSystem" externalSystem="GRADLE" externalSystemModuleGroup="net.islandearth" externalSystemModuleVersion="1.2.4" linkedProjectId="RPGRegions" linkedProjectPath="$MODULE_DIR$" rootProjectPath="$MODULE_DIR$" />
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
pluginGroup=net.islandearth
|
||||
pluginVersion=1.2.3
|
||||
pluginVersion=1.2.4
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package net.islandearth.rpgregions;
|
||||
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import co.aikar.commands.PaperCommandManager;
|
||||
import co.aikar.idb.DB;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import net.islandearth.languagy.language.Language;
|
||||
@@ -18,6 +20,8 @@ import net.islandearth.rpgregions.listener.ConnectionListener;
|
||||
import net.islandearth.rpgregions.listener.MoveListener;
|
||||
import net.islandearth.rpgregions.listener.RegionListener;
|
||||
import net.islandearth.rpgregions.managers.RPGRegionsManagers;
|
||||
import net.islandearth.rpgregions.managers.data.account.RPGRegionsAccount;
|
||||
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
||||
import net.islandearth.rpgregions.requirements.RegionRequirement;
|
||||
import net.islandearth.rpgregions.rewards.DiscoveryReward;
|
||||
import net.islandearth.rpgregions.translation.Translations;
|
||||
@@ -25,6 +29,7 @@ import net.islandearth.rpgregions.utils.XMaterial;
|
||||
import net.islandearth.rpgregions.utils.XSound;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
@@ -49,13 +54,13 @@ public final class RPGRegions extends JavaPlugin implements RPGRegionsAPI, Langu
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
new Metrics(this, 2066);
|
||||
plugin = this;
|
||||
this.createConfig();
|
||||
this.generateLang();
|
||||
this.managers = new RPGRegionsManagers(this);
|
||||
this.registerListeners();
|
||||
this.registerCommands();
|
||||
this.registerMetrics();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -173,6 +178,16 @@ public final class RPGRegions extends JavaPlugin implements RPGRegionsAPI, Langu
|
||||
|
||||
private void registerCommands() {
|
||||
PaperCommandManager manager = new PaperCommandManager(this);
|
||||
manager.getCommandCompletions().registerAsyncCompletion("regions", context -> ImmutableList.copyOf(getManagers().getRegionsCache().getConfiguredRegions().keySet()));
|
||||
manager.getCommandContexts().registerContext(ConfiguredRegion.class, context -> {
|
||||
String id = context.popFirstArg();
|
||||
for (ConfiguredRegion region : plugin.getManagers().getRegionsCache().getConfiguredRegions().values()) {
|
||||
if (region.getId().equals(id)) {
|
||||
return region;
|
||||
}
|
||||
}
|
||||
throw new InvalidCommandArgument("Could not find a region with that id.");
|
||||
});
|
||||
manager.registerCommand(new RPGRegionsCommand(this));
|
||||
}
|
||||
|
||||
@@ -219,4 +234,19 @@ public final class RPGRegions extends JavaPlugin implements RPGRegionsAPI, Langu
|
||||
}
|
||||
return "WorldGuard";
|
||||
}
|
||||
|
||||
private void registerMetrics() {
|
||||
Metrics metrics = new Metrics(this, 2066);
|
||||
metrics.addCustomChart(new Metrics.SingleLineChart("regions_discovered", () -> {
|
||||
int discoveries = 0;
|
||||
for (OfflinePlayer offlinePlayer : Bukkit.getOfflinePlayers()) {
|
||||
RPGRegionsAccount account = getManagers().getStorageManager().getAccount(offlinePlayer.getUniqueId()).get();
|
||||
discoveries = discoveries + account.getDiscoveredRegions().size();
|
||||
getManagers().getStorageManager().removeCachedAccount(offlinePlayer.getUniqueId()); // Cleanup so we don't use memory
|
||||
}
|
||||
return discoveries;
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new Metrics.SimplePie("storage_mode", () -> getConfig().getString("settings.integration.name", getIntegration())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.islandearth.rpgregions.commands;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Default;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
@@ -32,7 +33,7 @@ public class RPGRegionsCommand extends BaseCommand {
|
||||
}
|
||||
|
||||
@Default
|
||||
public void onDefault(CommandSender sender, String[] args) {
|
||||
public void onDefault(CommandSender sender) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "Wiki > " + plugin.getDescription().getWebsite());
|
||||
sender.sendMessage(ChatColor.YELLOW + "Bugs > https://gitlab.com/SamB440/rpgregions-2");
|
||||
sender.sendMessage(ChatColor.YELLOW + "Discord > https://discord.gg/fh62mxU");
|
||||
@@ -55,9 +56,8 @@ public class RPGRegionsCommand extends BaseCommand {
|
||||
|
||||
@Subcommand("add")
|
||||
@CommandPermission("rpgregions.add")
|
||||
public void onAdd(Player player, String[] args) {
|
||||
if (args.length == 1) {
|
||||
String region = args[0];
|
||||
@CommandCompletion("@regions")
|
||||
public void onAdd(Player player, String region) {
|
||||
if (!plugin.getManagers().getIntegrationManager().exists(player.getLocation().getWorld(), region)) {
|
||||
player.sendMessage(StringUtils.colour("&cThat region does not exist in your protection plugin."));
|
||||
return;
|
||||
@@ -75,34 +75,26 @@ public class RPGRegionsCommand extends BaseCommand {
|
||||
+ region
|
||||
+ " to edit it!"));*/
|
||||
player.sendMessage(StringUtils.colour("&e&oUse /rpgregions save to save this to file for editing."));
|
||||
} else {
|
||||
player.sendMessage(StringUtils.colour("&cUsage: /rpgregions add <region>"));
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("remove")
|
||||
@CommandPermission("rpgregions.remove")
|
||||
public void onRemove(CommandSender sender, String[] args) {
|
||||
if (args.length == 1) {
|
||||
String region = args[0];
|
||||
ConfiguredRegion configuredRegion = plugin.getManagers().getRegionsCache().getConfiguredRegion(region);
|
||||
@CommandCompletion("@regions")
|
||||
public void onRemove(CommandSender sender, ConfiguredRegion configuredRegion) {
|
||||
if (configuredRegion != null) {
|
||||
configuredRegion.delete(plugin);
|
||||
plugin.getManagers().getRegionsCache().removeConfiguredRegion(region);
|
||||
sender.sendMessage(StringUtils.colour("&cRemoved configured region " + region + "!"));
|
||||
plugin.getManagers().getRegionsCache().removeConfiguredRegion(configuredRegion.getId());
|
||||
sender.sendMessage(StringUtils.colour("&cRemoved configured region " + configuredRegion.getId() + "!"));
|
||||
} else {
|
||||
sender.sendMessage(StringUtils.colour("&cA region by that name is not yet configured."));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StringUtils.colour("&cUsage: /rpgregions remove <region>"));
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("edit")
|
||||
@CommandPermission("rpgregions.edit")
|
||||
public void onEdit(Player player, String[] args) {
|
||||
if (args.length == 1) {//TODO gui
|
||||
String region = args[0];
|
||||
@CommandCompletion("@regions")
|
||||
public void onEdit(Player player, ConfiguredRegion configuredRegion) {
|
||||
//TODO gui
|
||||
/*Gui gui = new Gui(plugin, 1, "Editing: " + region);
|
||||
OutlinePane pane = new OutlinePane(0, 0, 9, 1);
|
||||
GuiItem item = new GuiItem(new ItemStackBuilder(Material.BARRIER)
|
||||
@@ -114,9 +106,6 @@ public class RPGRegionsCommand extends BaseCommand {
|
||||
gui.addPane(pane);
|
||||
player.openInventory(gui.getInventory());*/
|
||||
player.sendMessage(ChatColor.RED + "Not ready yet! Coming in a future update.");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "Usage: /rpgregions edit <region>");
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("list|discoveries")
|
||||
@@ -127,10 +116,8 @@ public class RPGRegionsCommand extends BaseCommand {
|
||||
|
||||
@Subcommand("additem")
|
||||
@CommandPermission("rpgregions.additem")
|
||||
public void onAddItem(Player player, String[] args) {
|
||||
if (args.length > 0) {
|
||||
String region = args[0];
|
||||
ConfiguredRegion configuredRegion = plugin.getManagers().getRegionsCache().getConfiguredRegion(region);
|
||||
@CommandCompletion("@regions")
|
||||
public void onAddItem(Player player, ConfiguredRegion configuredRegion) {
|
||||
if (configuredRegion != null) {
|
||||
configuredRegion.getRewards().add(new ItemReward(player.getInventory().getItemInMainHand()));
|
||||
player.sendMessage(ChatColor.GREEN + "Item added to configuration!");
|
||||
@@ -138,11 +125,10 @@ public class RPGRegionsCommand extends BaseCommand {
|
||||
player.sendMessage(ChatColor.RED + "No region exists by that name.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("reload")
|
||||
@CommandPermission("rpgregions.reload")
|
||||
public void onReload(CommandSender sender, String[] args) {
|
||||
public void onReload(CommandSender sender) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Reloading region files...");
|
||||
long startTime = System.currentTimeMillis();
|
||||
File folder = new File(plugin.getDataFolder() + "/regions/");
|
||||
@@ -171,7 +157,7 @@ public class RPGRegionsCommand extends BaseCommand {
|
||||
|
||||
@Subcommand("save")
|
||||
@CommandPermission("rpgregions.save")
|
||||
public void onSave(CommandSender sender, String[] args) {
|
||||
public void onSave(CommandSender sender) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Saving data...");
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
@@ -197,6 +183,7 @@ public class RPGRegionsCommand extends BaseCommand {
|
||||
|
||||
@Subcommand("reset")
|
||||
@CommandPermission("rpgregions.reset")
|
||||
@CommandCompletion("@players @regions")
|
||||
public void onReset(CommandSender sender, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1: {
|
||||
@@ -234,24 +221,19 @@ public class RPGRegionsCommand extends BaseCommand {
|
||||
|
||||
@Subcommand("delete")
|
||||
@CommandPermission("rpgregions.delete")
|
||||
public void onDelete(CommandSender sender, String[] args) {
|
||||
if (args.length > 0) {
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
@CommandCompletion("@players")
|
||||
public void onDelete(CommandSender sender, Player player) {
|
||||
if (player != null) {
|
||||
plugin.getManagers().getStorageManager().deleteAccount(player.getUniqueId());
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "That player cannot be found.");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Usage: /rpgregions delete <player>");
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("setlocation")
|
||||
@CommandPermission("rpgregions.setlocation")
|
||||
public void onSetLocation(Player player, String[] args) {
|
||||
if (args.length > 0) {
|
||||
ConfiguredRegion configuredRegion = plugin.getManagers().getRegionsCache().getConfiguredRegion(args[0]);
|
||||
@CommandCompletion("@regions")
|
||||
public void onSetLocation(Player player, ConfiguredRegion configuredRegion) {
|
||||
if (configuredRegion != null) {
|
||||
Location location = player.getLocation();
|
||||
configuredRegion.setX(location.getBlockX());
|
||||
@@ -263,4 +245,3 @@ public class RPGRegionsCommand extends BaseCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user