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:
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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 + "'.");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user