Implemented /metropolis-home-evict command
This commit is contained in:
@@ -242,7 +242,6 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_occupiedPlots = new ArrayList<Plot>();
|
_occupiedPlots = new ArrayList<Plot>();
|
||||||
fillOccupiedPlots();
|
fillOccupiedPlots();
|
||||||
resizeCityRegion();
|
resizeCityRegion();
|
||||||
@@ -805,4 +804,34 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
public int getWallheight(){
|
public int getWallheight(){
|
||||||
return wallHeight;
|
return wallHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ProtectedRegion getRegion(String regionName) {
|
||||||
|
if(regionManager == null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return regionManager.getRegion(regionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeRegion(String regionId) {
|
||||||
|
if(regionManager == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try{
|
||||||
|
regionManager.removeRegion(regionId);
|
||||||
|
}catch(Exception ex){
|
||||||
|
log.info(String.format("[ERROR] Metropolis: Unable to remove region {%s}.", regionId));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveRegions() {
|
||||||
|
try {
|
||||||
|
regionManager.save();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
log.info(String.format("[SEVERE] Metropolis: Unable to save WorldGuard regions."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||||
|
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||||
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
|
||||||
public class MetropolisHomeEvictCommand implements CommandExecutor {
|
public class MetropolisHomeEvictCommand implements CommandExecutor {
|
||||||
MetropolisPlugin _plugin = null;
|
MetropolisPlugin _plugin = null;
|
||||||
@@ -15,9 +18,44 @@ public class MetropolisHomeEvictCommand implements CommandExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
|
//get the player and region
|
||||||
|
String playerName = "";
|
||||||
|
|
||||||
// TODO Auto-generated method stub
|
if(args.length == 0){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(args.length >= 1){
|
||||||
|
playerName = args[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
OfflinePlayer player = _plugin.getServer().getOfflinePlayer(playerName);
|
||||||
|
if(player == null){
|
||||||
|
sender.sendMessage(String.format("The requested player {%s}does not appear to exist.", playerName));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProtectedRegion region = _plugin.getRegion(String.format("h_%s", player.getName()));
|
||||||
|
if(region == null){
|
||||||
|
sender.sendMessage(String.format("The player {%s} has no home to be evicted from."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//remove the player as owner and/or member of the region
|
||||||
|
region.getMembers().removePlayer(playerName);
|
||||||
|
region.getOwners().removePlayer(playerName);
|
||||||
|
|
||||||
|
//if the region has no owners delete the region
|
||||||
|
if(region.getMembers().size() == 0 && region.getOwners().size() == 0){
|
||||||
|
_plugin.removeRegion(region.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
_plugin.saveRegions();
|
||||||
|
|
||||||
|
//?optionally regen the region
|
||||||
|
//_plugin.worldEdit.getCommand("regen").execute(_plugin.getServer().getConsoleSender(), "regen", new String[]{});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,14 +7,16 @@ import org.bukkit.command.CommandSender;
|
|||||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||||
|
|
||||||
public class MetropolisHomeMoveCommand implements CommandExecutor {
|
public class MetropolisHomeMoveCommand implements CommandExecutor {
|
||||||
|
MetropolisPlugin _plugin;
|
||||||
|
|
||||||
public MetropolisHomeMoveCommand(MetropolisPlugin metropolisPlugin) {
|
public MetropolisHomeMoveCommand(MetropolisPlugin plugin) {
|
||||||
// TODO Auto-generated constructor stub
|
_plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender arg0, Command arg1, String arg2,
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
String[] arg3) {
|
|
||||||
|
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user