Moved project out of subfolder.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
|
||||
public class MetropolisCommand implements CommandExecutor {
|
||||
private MetropolisPlugin _plugin;
|
||||
|
||||
public MetropolisCommand(MetropolisPlugin plugin){
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
sender.sendMessage("Metropolis: version "+ _plugin.pdf.getVersion());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
|
||||
public class MetropolisDebugGenerateTestHomesCommand implements CommandExecutor {
|
||||
|
||||
private MetropolisPlugin _plugin;
|
||||
|
||||
public MetropolisDebugGenerateTestHomesCommand(MetropolisPlugin plugin) {
|
||||
_plugin = plugin;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
try{
|
||||
int numHomes = Integer.parseInt(args[0]);
|
||||
for(int i=1; i<= numHomes; i++){
|
||||
_plugin.generateHome(String.format("test%d", i));
|
||||
}
|
||||
|
||||
return true;
|
||||
}catch(NumberFormatException ex){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
public class MetropolisFlagResetCommand implements CommandExecutor {
|
||||
private MetropolisPlugin _plugin;
|
||||
|
||||
public MetropolisFlagResetCommand(MetropolisPlugin plugin){
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
ProtectedRegion cityRegion = _plugin.regionManager.getRegion("City");
|
||||
cityRegion.setFlag(DefaultFlag.PVP, StateFlag.State.DENY);
|
||||
cityRegion.setFlag(DefaultFlag.MOB_DAMAGE, StateFlag.State.DENY);
|
||||
cityRegion.setFlag(DefaultFlag.MOB_SPAWNING, StateFlag.State.DENY);
|
||||
cityRegion.setFlag(DefaultFlag.CREEPER_EXPLOSION, StateFlag.State.DENY);
|
||||
cityRegion.setFlag(DefaultFlag.ENDER_BUILD, StateFlag.State.DENY);
|
||||
cityRegion.setFlag(DefaultFlag.GHAST_FIREBALL, StateFlag.State.DENY);
|
||||
cityRegion.setFlag(DefaultFlag.TNT, StateFlag.State.DENY);
|
||||
cityRegion.setFlag(DefaultFlag.LAVA_FLOW, StateFlag.State.DENY);
|
||||
cityRegion.setFlag(DefaultFlag.SNOW_FALL, StateFlag.State.DENY);
|
||||
|
||||
for(ProtectedRegion homeRegion: _plugin.regionManager.getRegions().values()){
|
||||
if(homeRegion.getId().startsWith("h_")){
|
||||
homeRegion.setFlag(DefaultFlag.PVP, StateFlag.State.DENY);
|
||||
homeRegion.setFlag(DefaultFlag.MOB_DAMAGE, StateFlag.State.DENY);
|
||||
homeRegion.setFlag(DefaultFlag.MOB_SPAWNING, StateFlag.State.DENY);
|
||||
homeRegion.setFlag(DefaultFlag.CREEPER_EXPLOSION, StateFlag.State.DENY);
|
||||
homeRegion.setFlag(DefaultFlag.ENDER_BUILD, StateFlag.State.DENY);
|
||||
homeRegion.setFlag(DefaultFlag.GHAST_FIREBALL, StateFlag.State.DENY);
|
||||
homeRegion.setFlag(DefaultFlag.TNT, StateFlag.State.DENY);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage("Metropolis: flags have been reset");
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
|
||||
public class MetropolisHomeAcquire implements CommandExecutor {
|
||||
MetropolisPlugin _plugin;
|
||||
|
||||
public MetropolisHomeAcquire(MetropolisPlugin plugin){
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if(!(sender instanceof Player)){
|
||||
sender.sendMessage("This command can only be used by players");
|
||||
return false;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
if(_plugin.getNumPlots(player.getName()) >= _plugin.getMaxPlots(player.getName())){
|
||||
sender.sendMessage("You cannot have any more plots");
|
||||
return false;
|
||||
}
|
||||
|
||||
_plugin.assignPlot(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
public class MetropolisHomeEvictCommand implements CommandExecutor {
|
||||
MetropolisPlugin _plugin = null;
|
||||
|
||||
public MetropolisHomeEvictCommand(MetropolisPlugin plugin){
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
//get the player and region
|
||||
String playerName = "";
|
||||
|
||||
if(args.length == 0){
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
|
||||
public class MetropolisHomeGenerateCommand implements CommandExecutor {
|
||||
|
||||
private MetropolisPlugin _plugin;
|
||||
|
||||
public MetropolisHomeGenerateCommand(MetropolisPlugin plugin){
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(args.length < 1){
|
||||
return false;
|
||||
}
|
||||
|
||||
_plugin.generateHome(args[0]);
|
||||
|
||||
sender.sendMessage("[Metropolis] Home generated for " + args[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
import com.majinnaibu.bukkitplugins.metropolis.PlayerHome;
|
||||
|
||||
public class MetropolisHomeGoCommand implements CommandExecutor {
|
||||
MetropolisPlugin _plugin = null;
|
||||
|
||||
public MetropolisHomeGoCommand(MetropolisPlugin plugin){
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
Player player = null;
|
||||
if(sender instanceof Player){
|
||||
player = (Player)sender;
|
||||
|
||||
if(args.length >= 1){
|
||||
if(player.hasPermission("")){
|
||||
player = _plugin.getServer().getPlayer(args[0]);
|
||||
|
||||
if(player == null){
|
||||
sender.sendMessage(String.format("Unable to find player %s", args[0]));
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
sender.sendMessage("Permission denied");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(args.length >= 1){
|
||||
player = _plugin.getServer().getPlayer(args[0]);
|
||||
|
||||
if(player == null){
|
||||
sender.sendMessage(String.format("Unable to find player %s", args[0]));
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
sender.sendMessage("You must be a player");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
PlayerHome home = _plugin.getPlayerHome(player);
|
||||
|
||||
Location loc = null;
|
||||
Location bedSpawn = player.getBedSpawnLocation();
|
||||
|
||||
if(home.contains(bedSpawn)){
|
||||
loc = bedSpawn;
|
||||
}else {
|
||||
loc = home.getViableSpawnLocation(_plugin.getWorld());
|
||||
}
|
||||
|
||||
if(loc != null){
|
||||
player.teleport(loc);
|
||||
}else{
|
||||
if(sender == player){
|
||||
sender.sendMessage("There is no valid spawn location in your home");
|
||||
}else{
|
||||
sender.sendMessage(String.format("There is no valid spawn location in %s's home", player.getName()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
import com.majinnaibu.bukkitplugins.metropolis.Plot;
|
||||
|
||||
public class MetropolisHomeListCommand implements CommandExecutor {
|
||||
private MetropolisPlugin _plugin;
|
||||
|
||||
public MetropolisHomeListCommand(MetropolisPlugin plugin){
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
for(Plot cityBlock : _plugin.getCityBlocks()){
|
||||
sender.sendMessage(String.format("%s", cityBlock.toFriendlyString()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
|
||||
public class MetropolisHomeMoveCommand implements CommandExecutor {
|
||||
MetropolisPlugin _plugin;
|
||||
|
||||
public MetropolisHomeMoveCommand(MetropolisPlugin plugin) {
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
OfflinePlayer player = null;
|
||||
int newHomeNumber = 0;
|
||||
|
||||
if(sender instanceof OfflinePlayer){
|
||||
player = (OfflinePlayer)sender;
|
||||
}
|
||||
|
||||
if(args.length == 1){
|
||||
try{
|
||||
newHomeNumber = Integer.parseInt(args[0]);
|
||||
}catch(NumberFormatException ex){
|
||||
return false;
|
||||
}
|
||||
}else if(args.length >= 2){
|
||||
try{
|
||||
newHomeNumber = Integer.parseInt(args[0]);
|
||||
}catch(NumberFormatException ex){
|
||||
return false;
|
||||
}
|
||||
|
||||
player = _plugin.getOfflinePlayer(args[1]);
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(player == null || !_plugin.homeExists(player.getName(), newHomeNumber)){
|
||||
return false;
|
||||
}
|
||||
|
||||
_plugin.setHome(player.getName(), newHomeNumber);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
import com.majinnaibu.bukkitplugins.metropolis.Plot;
|
||||
|
||||
public class MetropolisPlotGoCommand implements CommandExecutor {
|
||||
MetropolisPlugin _plugin;
|
||||
|
||||
public MetropolisPlotGoCommand(MetropolisPlugin plugin) {
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
Player player = null;
|
||||
Plot plot = null;
|
||||
|
||||
if(sender instanceof Player){
|
||||
player = (Player) sender;
|
||||
}
|
||||
|
||||
if(args.length == 1 && player != null){
|
||||
plot = _plugin.getPlot(args[0]);
|
||||
}else if(args.length >= 2){
|
||||
player = _plugin.getPlayer(args[1]);
|
||||
plot = _plugin.getPlot(args[0]);
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(plot == null || player == null){
|
||||
return false;
|
||||
}
|
||||
|
||||
String errorMessage = _plugin.teleportPlayerToPlot(player, plot);
|
||||
if(errorMessage != null){
|
||||
sender.sendMessage(errorMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.Cuboid;
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||
|
||||
public class MetropolisPlotReserveCommand implements CommandExecutor {
|
||||
MetropolisPlugin _plugin;
|
||||
|
||||
public MetropolisPlotReserveCommand(MetropolisPlugin metropolisPlugin) {
|
||||
_plugin = metropolisPlugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
int minX = 0;
|
||||
int minY = 0;
|
||||
int minZ = 0;
|
||||
int maxX = 0;
|
||||
int maxY = 0;
|
||||
int maxZ = 0;
|
||||
Cuboid cuboid = new Cuboid();
|
||||
|
||||
if(sender instanceof Player && args.length == 1){
|
||||
Selection selection = _plugin.worldEdit.getSelection((Player) sender);
|
||||
cuboid = new Cuboid(selection);
|
||||
}else if(args.length == 6){
|
||||
try{
|
||||
minX = Integer.parseInt(args[1]);
|
||||
minY = Integer.parseInt(args[2]);
|
||||
minZ = Integer.parseInt(args[3]);
|
||||
maxX = Integer.parseInt(args[4]);
|
||||
maxY = Integer.parseInt(args[5]);
|
||||
maxZ = Integer.parseInt(args[6]);
|
||||
}catch(NumberFormatException ex){
|
||||
return false;
|
||||
}
|
||||
cuboid = new Cuboid(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}else if(args.length == 4){
|
||||
try{
|
||||
minX = Integer.parseInt(args[1]);
|
||||
minY = 0;
|
||||
minZ = Integer.parseInt(args[2]);
|
||||
maxX = Integer.parseInt(args[3]);
|
||||
maxY = _plugin.getWorld().getMaxHeight();
|
||||
maxZ = Integer.parseInt(args[4]);
|
||||
}catch(NumberFormatException ex){
|
||||
return false;
|
||||
}
|
||||
cuboid = new Cuboid(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
String regionName = args[0];
|
||||
|
||||
_plugin.reserveCuboid(regionName, cuboid);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user