9
0
mirror of https://gitlab.com/SamB440/rpgregions-2.git synced 2025-12-31 04:36:29 +00:00

Add /rpgri migrate

This commit is contained in:
SamB440
2022-11-15 16:05:42 +00:00
parent b1b1162686
commit c978875b14
2 changed files with 22 additions and 1 deletions

View File

@@ -24,6 +24,7 @@ import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -59,6 +60,10 @@ public class RPGRegionsIntegration implements IntegrationManager {
* API METHODS
*/
public Collection<RPGRegionsRegion> getRegions() {
return regions.values();
}
public Set<RPGRegionsRegion> getRegions(final Location location) {
List<RPGRegionsRegion> foundRegions = new ArrayList<>();
for (RPGRegionsRegion region : regions.values()) {
@@ -82,7 +87,6 @@ public class RPGRegionsIntegration implements IntegrationManager {
public void removeRegion(final String name) {
regions.remove(name);
}
/*
* OVERRIDES
*/

View File

@@ -131,4 +131,21 @@ public class RPGRegionsIntegrationCommand extends BaseCommand {
region.setWorld(world.getUID());
sender.sendMessage(ChatColor.GREEN + "Set region '" + region.getName() + "' world to '" + world.getName() + "'.");
}
@Subcommand("migrate")
@CommandCompletion("@worlds")
public void onMigrate(final CommandSender sender, final String worldName) {
final World world = Bukkit.getWorld(worldName);
if (world == null) {
sender.sendMessage(ChatColor.RED + "That world could not be found.");
return;
}
RPGRegionsIntegration integration = (RPGRegionsIntegration) plugin.getManagers().getIntegrationManager();
for (RPGRegionsRegion region : integration.getRegions()) {
region.setWorld(world.getUID());
}
sender.sendMessage(ChatColor.GREEN + "Set all regions to world '" + worldName + "'.");
}
}