mirror of
https://github.com/CivMC/Civ.git
synced 2026-07-18 00:20:44 +00:00
Changed all integers to doubles. Fixed circular spawn area's.
This commit is contained in:
@@ -36,15 +36,17 @@ public class InfoCommand extends AbstractCommand {
|
||||
player.sendMessage(ChatColor.AQUA + "Random spawn on: " + ChatColor.WHITE + flags);
|
||||
|
||||
if(plugin.yamlHandler.worlds.contains(worldname + ".spawnarea")){
|
||||
player.sendMessage(ChatColor.AQUA + "Spawnarea:");
|
||||
player.sendMessage(ChatColor.AQUA + "Spawnarea " + plugin.yamlHandler.worlds.getString(worldname +".spawnarea.type","square") + ":");
|
||||
|
||||
int xmin = plugin.yamlHandler.worlds.getInt(worldname +".spawnarea.x-min");
|
||||
int xmax = plugin.yamlHandler.worlds.getInt(worldname +".spawnarea.x-max");
|
||||
int zmin = plugin.yamlHandler.worlds.getInt(worldname +".spawnarea.z-min");
|
||||
int zmax = plugin.yamlHandler.worlds.getInt(worldname +".spawnarea.z-max");
|
||||
double xmin = plugin.yamlHandler.worlds.getDouble(worldname +".spawnarea.x-min");
|
||||
double xmax = plugin.yamlHandler.worlds.getDouble(worldname +".spawnarea.x-max");
|
||||
double zmin = plugin.yamlHandler.worlds.getDouble(worldname +".spawnarea.z-min");
|
||||
double zmax = plugin.yamlHandler.worlds.getDouble(worldname +".spawnarea.z-max");
|
||||
|
||||
player.sendMessage("x-min = "+ xmin + " | x-max = " + xmax);
|
||||
player.sendMessage("z-min = "+ zmin + " | z-max = " + zmax);
|
||||
player.sendMessage("x-min = "+ xmin);
|
||||
player.sendMessage("x-max = " + xmax);
|
||||
player.sendMessage("z-min = "+ zmin);
|
||||
player.sendMessage("z-max = " + zmax);
|
||||
}else
|
||||
{
|
||||
player.sendMessage("There is no spawn area set. Refering to defaults:");
|
||||
@@ -57,11 +59,11 @@ public class InfoCommand extends AbstractCommand {
|
||||
if(plugin.yamlHandler.worlds.contains(worldname + ".firstspawn")){
|
||||
player.sendMessage(ChatColor.AQUA + "Firstspawn:");
|
||||
|
||||
int x = plugin.yamlHandler.worlds.getInt(worldname +".firstspawn.x");
|
||||
int y = plugin.yamlHandler.worlds.getInt(worldname +".firstspawn.y");
|
||||
int z = plugin.yamlHandler.worlds.getInt(worldname +".firstspawn.z");
|
||||
double yaw = plugin.yamlHandler.worlds.getInt(worldname +".firstspawn.yaw");
|
||||
double pitch = plugin.yamlHandler.worlds.getInt(worldname +".firstspawn.pitch");
|
||||
double x = plugin.yamlHandler.worlds.getDouble(worldname +".firstspawn.x");
|
||||
double y = plugin.yamlHandler.worlds.getDouble(worldname +".firstspawn.y");
|
||||
double z = plugin.yamlHandler.worlds.getDouble(worldname +".firstspawn.z");
|
||||
double yaw = plugin.yamlHandler.worlds.getDouble(worldname +".firstspawn.yaw");
|
||||
double pitch = plugin.yamlHandler.worlds.getDouble(worldname +".firstspawn.pitch");
|
||||
|
||||
player.sendMessage("x = "+ x + " | y = " + y + " | z = " + z + " | yaw = " + yaw + " | pitch = " + pitch);
|
||||
}else
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.Josvth.RandomSpawn.Commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import me.Josvth.RandomSpawn.RandomSpawn;
|
||||
@@ -9,21 +10,31 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SetAreaCommand extends AbstractCommand{
|
||||
|
||||
|
||||
public SetAreaCommand(RandomSpawn instance){
|
||||
super(instance,"setarea");
|
||||
}
|
||||
|
||||
|
||||
public boolean onCommand(CommandSender sender, List<String> args){
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (args.size() == 1 && args.get(0).matches("[0-9]+")) {
|
||||
double xmin = 0;
|
||||
double xmax = 0;
|
||||
double zmin = 0;
|
||||
double zmax = 0;
|
||||
|
||||
if (args.size() == 1) {
|
||||
Location reference = player.getLocation();
|
||||
|
||||
int xmin = (int) (reference.getX() - Integer.parseInt(args.get(0)));
|
||||
int xmax = (int) (reference.getX() + Integer.parseInt(args.get(0)));
|
||||
int zmin = (int) (reference.getZ() - Integer.parseInt(args.get(0)));
|
||||
int zmax = (int) (reference.getZ() + Integer.parseInt(args.get(0)));
|
||||
try{
|
||||
xmin = reference.getX() - Double.parseDouble(args.get(0));
|
||||
xmax = reference.getX() + Double.parseDouble(args.get(0));
|
||||
zmin = reference.getZ() - Double.parseDouble(args.get(0));
|
||||
zmax = reference.getZ() + Double.parseDouble(args.get(0));
|
||||
} catch(NumberFormatException e){
|
||||
sender.sendMessage("Invalid number.");
|
||||
return false;
|
||||
}
|
||||
|
||||
String worldname = reference.getWorld().getName();
|
||||
|
||||
@@ -41,90 +52,117 @@ public class SetAreaCommand extends AbstractCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.size() == 2 && args.get(1).matches("[0-9]+")) {
|
||||
if (args.get(0).matches("square")) {
|
||||
Location reference = player.getLocation();
|
||||
if (args.size() == 2 && (args.get(0).equalsIgnoreCase("circle") || args.get(0).equalsIgnoreCase("square"))) {
|
||||
|
||||
int xmin = (int) (reference.getX() - Integer.parseInt(args.get(1)));
|
||||
int xmax = (int) (reference.getX() + Integer.parseInt(args.get(1)));
|
||||
int zmin = (int) (reference.getZ() - Integer.parseInt(args.get(1)));
|
||||
int zmax = (int) (reference.getZ() + Integer.parseInt(args.get(1)));
|
||||
Location reference = player.getLocation();
|
||||
|
||||
String worldname = reference.getWorld().getName();
|
||||
try{
|
||||
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.x-min", xmin);
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.x-max", xmax);
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.z-min", zmin);
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.z-max", zmax);
|
||||
xmin = reference.getX() - Double.parseDouble(args.get(1));
|
||||
xmax = reference.getX() + Double.parseDouble(args.get(1));
|
||||
zmin = reference.getZ() - Double.parseDouble(args.get(1));
|
||||
zmax = reference.getZ() + Double.parseDouble(args.get(1));
|
||||
|
||||
plugin.yamlHandler.worlds.set(worldname + ".randomspawnenabled", true);
|
||||
|
||||
plugin.yamlHandler.saveWorlds();
|
||||
|
||||
plugin.playerInfo(player, "Spawn area set!");
|
||||
|
||||
return true;
|
||||
} catch(NumberFormatException e){
|
||||
sender.sendMessage("Invalid number.");
|
||||
return false;
|
||||
}
|
||||
|
||||
String worldname = reference.getWorld().getName();
|
||||
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.x-min", xmin);
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.x-max", xmax);
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.z-min", zmin);
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.z-max", zmax);
|
||||
|
||||
List<String> rsflags = new ArrayList<String>();
|
||||
rsflags.add("respawn");
|
||||
|
||||
plugin.yamlHandler.worlds.set(worldname + ".randomspawnon", rsflags);
|
||||
|
||||
if (args.get(0).matches("circle")) {
|
||||
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.type", "circle");
|
||||
}else{
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.type", "square");
|
||||
}
|
||||
return false;
|
||||
|
||||
plugin.playerInfo(player, "Spawn area set!");
|
||||
|
||||
plugin.yamlHandler.saveWorlds();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.size() == 2) {
|
||||
if (args.get(0).matches("-{0,1}[0-9]+") && args.get(1).matches("-{0,1}[0-9]+")){
|
||||
Location reference = player.getLocation();
|
||||
if (args.size() == 2){
|
||||
|
||||
Location reference = player.getLocation();
|
||||
|
||||
int xmin = (int) (reference.getX() - Integer.parseInt(args.get(0))/2);
|
||||
int xmax = (int) (reference.getX() + Integer.parseInt(args.get(0))/2);
|
||||
int zmin = (int) (reference.getZ() - Integer.parseInt(args.get(1))/2);
|
||||
int zmax = (int) (reference.getZ() + Integer.parseInt(args.get(1))/2);
|
||||
|
||||
String worldname = reference.getWorld().getName();
|
||||
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.x-min", xmin);
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.x-max", xmax);
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.z-min", zmin);
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.z-max", zmax);
|
||||
|
||||
plugin.yamlHandler.worlds.set(worldname + ".randomspawnenabled", true);
|
||||
|
||||
plugin.yamlHandler.saveWorlds();
|
||||
|
||||
plugin.playerInfo(player, "Spawn area set!");
|
||||
|
||||
return true;
|
||||
try{
|
||||
xmin = reference.getX() - (Double.parseDouble(args.get(0)) / 2);
|
||||
xmax = reference.getX() + (Double.parseDouble(args.get(0)) / 2);
|
||||
zmin = reference.getZ() - (Double.parseDouble(args.get(1)) / 2);
|
||||
zmax = reference.getZ() + (Double.parseDouble(args.get(1)) / 2);
|
||||
}catch(NumberFormatException e){
|
||||
sender.sendMessage("Invalid number.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
String worldname = reference.getWorld().getName();
|
||||
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.x-min", xmin);
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.x-max", xmax);
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.z-min", zmin);
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.z-max", zmax);
|
||||
|
||||
List<String> rsflags = new ArrayList<String>();
|
||||
rsflags.add("respawn");
|
||||
|
||||
plugin.yamlHandler.worlds.set(worldname + ".randomspawnon", rsflags);
|
||||
|
||||
plugin.yamlHandler.saveWorlds();
|
||||
|
||||
plugin.playerInfo(player, "Spawn area set!");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.size() == 4) {
|
||||
if (args.get(0).matches("-{0,1}[0-9]+") && args.get(1).matches("-{0,1}[0-9]+") && args.get(2).matches("-{0,1}[0-9]+") && args.get(3).matches("-{0,1}[0-9]+")){
|
||||
Location reference = player.getLocation();
|
||||
|
||||
int xmin = Integer.parseInt(args.get(0));
|
||||
int xmax = Integer.parseInt(args.get(1));
|
||||
int zmin = Integer.parseInt(args.get(2));
|
||||
int zmax = Integer.parseInt(args.get(3));
|
||||
if (args.size() == 4){
|
||||
Location reference = player.getLocation();
|
||||
|
||||
String worldname = reference.getWorld().getName();
|
||||
try{
|
||||
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.x-min", xmin);
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.x-max", xmax);
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.z-min", zmin);
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.z-max", zmax);
|
||||
xmin = Double.parseDouble(args.get(0));
|
||||
xmax = Double.parseDouble(args.get(1));
|
||||
zmin = Double.parseDouble(args.get(2));
|
||||
zmax = Double.parseDouble(args.get(3));
|
||||
|
||||
plugin.yamlHandler.worlds.set(worldname + ".randomspawnenabled", true);
|
||||
|
||||
plugin.yamlHandler.saveWorlds();
|
||||
|
||||
plugin.playerInfo(player, "Spawn area set!");
|
||||
|
||||
return true;
|
||||
} catch(NumberFormatException e){
|
||||
sender.sendMessage("Invalid number.");
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
String worldname = reference.getWorld().getName();
|
||||
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.x-min", xmin);
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.x-max", xmax);
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.z-min", zmin);
|
||||
plugin.yamlHandler.worlds.set(worldname + ".spawnarea.z-max", zmax);
|
||||
|
||||
List<String> rsflags = new ArrayList<String>();
|
||||
rsflags.add("respawn");
|
||||
|
||||
plugin.yamlHandler.worlds.set(worldname + ".randomspawnon", rsflags);
|
||||
|
||||
plugin.yamlHandler.saveWorlds();
|
||||
|
||||
plugin.playerInfo(player, "Spawn area set!");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user