mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-24 18:44:26 +00:00
Proper Reformating
This commit is contained in:
1 parent
ce75880aba
commit
180d257024
1179 files changed
+59847
-61583
No files matched your search
@@ -21,8 +21,8 @@ import noppes.npcs.entity.EntityNPCInterface;
|
||||
import java.util.List;
|
||||
|
||||
@Command(
|
||||
name = "clone",
|
||||
desc = "Clone operation (server side)"
|
||||
name = "clone",
|
||||
desc = "Clone operation (server side)"
|
||||
)
|
||||
public class CmdClone extends ChMcLogger {
|
||||
|
||||
@@ -31,17 +31,16 @@ public class CmdClone extends ChMcLogger {
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Add NPC(s) to clone storage",
|
||||
usage = "<npc> <tab> [clonedname]",
|
||||
permissions = {OpOnly.class ,PlayerOnly.class, ParamCheck.class}
|
||||
desc = "Add NPC(s) to clone storage",
|
||||
usage = "<npc> <tab> [clonedname]",
|
||||
permissions = {OpOnly.class, PlayerOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean add(String[] args) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) pcParam;
|
||||
int tab = 0;
|
||||
try{
|
||||
tab = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
try {
|
||||
tab = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
|
||||
}
|
||||
List<EntityNPCInterface> list = Utils.getNearbeEntityFromPlayer(EntityNPCInterface.class, player, 80);
|
||||
@@ -51,24 +50,23 @@ public class CmdClone extends ChMcLogger {
|
||||
if (args.length > 2) {
|
||||
name = args[2];
|
||||
}
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
if(!npc.writeToNBTOptional(compound))
|
||||
return false;
|
||||
ServerCloneController.Instance.addClone(compound, name, tab);
|
||||
return true;
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
if (!npc.writeToNBTOptional(compound))
|
||||
return false;
|
||||
ServerCloneController.Instance.addClone(compound, name, tab);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(desc = "List NPC from clone storage", usage = "<tab>", permissions={OpOnly.class ,ParamCheck.class})
|
||||
@SubCommand(desc = "List NPC from clone storage", usage = "<tab>", permissions = {OpOnly.class, ParamCheck.class})
|
||||
public Boolean list(String[] args) {
|
||||
sendmessage("--- Stored NPCs --- (server side)");
|
||||
int tab = 0;
|
||||
try{
|
||||
tab = Integer.parseInt(args[0]);
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
try {
|
||||
tab = Integer.parseInt(args[0]);
|
||||
} catch (NumberFormatException ex) {
|
||||
|
||||
}
|
||||
for (String name : ServerCloneController.Instance.getClones(tab)) {
|
||||
@@ -78,205 +76,201 @@ public class CmdClone extends ChMcLogger {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(desc = "Remove NPC from clone storage", usage = "<name> <tab>", permissions={OpOnly.class ,ParamCheck.class})
|
||||
@SubCommand(desc = "Remove NPC from clone storage", usage = "<name> <tab>", permissions = {OpOnly.class, ParamCheck.class})
|
||||
public Boolean del(String[] args) {
|
||||
String nametodel = args[0];
|
||||
int tab = 0;
|
||||
try{
|
||||
tab = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
try {
|
||||
tab = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
|
||||
}
|
||||
boolean deleted = false;
|
||||
for(String name : ServerCloneController.Instance.getClones(tab)){
|
||||
if(nametodel.equalsIgnoreCase(name)){
|
||||
ServerCloneController.Instance.removeClone(name, tab);
|
||||
deleted = true;
|
||||
break;
|
||||
}
|
||||
for (String name : ServerCloneController.Instance.getClones(tab)) {
|
||||
if (nametodel.equalsIgnoreCase(name)) {
|
||||
ServerCloneController.Instance.removeClone(name, tab);
|
||||
deleted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!ServerCloneController.Instance.removeClone(nametodel, tab)) {
|
||||
sendmessage(String.format("Npc '%s' wasn't found", nametodel));
|
||||
return false;
|
||||
}
|
||||
;
|
||||
;
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Spawn cloned NPC",
|
||||
usage = "<name> <tab> [[world:]x,y,z]] [newname]",
|
||||
permissions={OpOnly.class ,ParamCheck.class})
|
||||
desc = "Spawn cloned NPC",
|
||||
usage = "<name> <tab> [[world:]x,y,z]] [newname]",
|
||||
permissions = {OpOnly.class, ParamCheck.class})
|
||||
public boolean spawn(String[] args) {
|
||||
String name = args[0].replaceAll("%", " "); // if name of npc separed by space, user must use % in place of space
|
||||
int tab = 0;
|
||||
try{
|
||||
tab = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
try {
|
||||
tab = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
|
||||
}
|
||||
String newname=null;
|
||||
String newname = null;
|
||||
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(this.pcParam, name, tab);
|
||||
if(compound == null){
|
||||
sendmessage("Unknown npc");
|
||||
return false;
|
||||
if (compound == null) {
|
||||
sendmessage("Unknown npc");
|
||||
return false;
|
||||
}
|
||||
World world = pcParam.getEntityWorld();
|
||||
double posX = pcParam.getPlayerCoordinates().posX;
|
||||
double posY = pcParam.getPlayerCoordinates().posY;
|
||||
double posZ = pcParam.getPlayerCoordinates().posZ;
|
||||
|
||||
if(args.length > 2){
|
||||
String location = args[2];
|
||||
String[] par;
|
||||
if (location.contains(":")){
|
||||
par = location.split(":");
|
||||
location = par[1];
|
||||
world = Utils.getWorld(par[0]);
|
||||
if (world == null){
|
||||
sendmessage (String.format("'%s' is an unknown world",par[0]));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (args.length > 2) {
|
||||
String location = args[2];
|
||||
String[] par;
|
||||
if (location.contains(":")) {
|
||||
par = location.split(":");
|
||||
location = par[1];
|
||||
world = Utils.getWorld(par[0]);
|
||||
if (world == null) {
|
||||
sendmessage(String.format("'%s' is an unknown world", par[0]));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (location.contains(",")){
|
||||
par = location.split(",");
|
||||
if (par.length != 3){
|
||||
sendmessage("Location need be x,y,z");
|
||||
return false;
|
||||
}
|
||||
try{
|
||||
posX = CommandBase.func_110666_a(pcParam, posX, par[0]);
|
||||
posY = CommandBase.func_110665_a(pcParam, posY, par[1].trim(), 0, 0);
|
||||
posZ = CommandBase.func_110666_a(pcParam, posZ, par[2]);
|
||||
} catch(NumberFormatException ex){
|
||||
sendmessage("Location should be in numbers");
|
||||
return false;
|
||||
}
|
||||
if (args.length > 3){
|
||||
newname = args[3];
|
||||
}
|
||||
} else {
|
||||
newname = location;
|
||||
}
|
||||
if (location.contains(",")) {
|
||||
par = location.split(",");
|
||||
if (par.length != 3) {
|
||||
sendmessage("Location need be x,y,z");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
posX = CommandBase.func_110666_a(pcParam, posX, par[0]);
|
||||
posY = CommandBase.func_110665_a(pcParam, posY, par[1].trim(), 0, 0);
|
||||
posZ = CommandBase.func_110666_a(pcParam, posZ, par[2]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendmessage("Location should be in numbers");
|
||||
return false;
|
||||
}
|
||||
if (args.length > 3) {
|
||||
newname = args[3];
|
||||
}
|
||||
} else {
|
||||
newname = location;
|
||||
}
|
||||
}
|
||||
|
||||
if (posX == 0 && posY == 0 && posZ == 0){//incase it was called from the console and not pos was given
|
||||
sendmessage ("Location needed");
|
||||
if (posX == 0 && posY == 0 && posZ == 0) {//incase it was called from the console and not pos was given
|
||||
sendmessage("Location needed");
|
||||
return false;
|
||||
}
|
||||
|
||||
Entity entity = EntityList.createEntityFromNBT(compound, world);
|
||||
entity.setPosition(posX + 0.5, posY + 1, posZ + 0.5);
|
||||
if(entity instanceof EntityNPCInterface){
|
||||
EntityNPCInterface npc = (EntityNPCInterface) entity;
|
||||
npc.ais.startPos = new int[]{MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)};
|
||||
if(newname != null && !newname.isEmpty())
|
||||
npc.display.name = newname.replaceAll("%", " "); // like name, newname must use % in place of space to keep a logical way
|
||||
if (entity instanceof EntityNPCInterface) {
|
||||
EntityNPCInterface npc = (EntityNPCInterface) entity;
|
||||
npc.ais.startPos = new int[]{MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)};
|
||||
if (newname != null && !newname.isEmpty())
|
||||
npc.display.name = newname.replaceAll("%", " "); // like name, newname must use % in place of space to keep a logical way
|
||||
}
|
||||
world.spawnEntityInWorld(entity);
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Spawn cloned NPC",
|
||||
usage = "<name> <tab> <lenght> <width> [[world:]x,y,z]] [newname]",
|
||||
permissions={OpOnly.class ,ParamCheck.class})
|
||||
desc = "Spawn cloned NPC",
|
||||
usage = "<name> <tab> <lenght> <width> [[world:]x,y,z]] [newname]",
|
||||
permissions = {OpOnly.class, ParamCheck.class})
|
||||
public boolean grid(String[] args) {
|
||||
String name = args[0].replaceAll("%", " "); // if name of npc separed by space, user must use % in place of space
|
||||
int tab = 0;
|
||||
try{
|
||||
tab = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
try {
|
||||
tab = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
|
||||
}
|
||||
|
||||
int width, height;
|
||||
try{
|
||||
width = Integer.parseInt(args[2]);
|
||||
height = Integer.parseInt(args[3]);
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
sendmessage("lenght or width wasnt a number");
|
||||
return false;
|
||||
try {
|
||||
width = Integer.parseInt(args[2]);
|
||||
height = Integer.parseInt(args[3]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendmessage("lenght or width wasnt a number");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
String newname=null;
|
||||
String newname = null;
|
||||
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(this.pcParam, name, tab);
|
||||
if(compound == null){
|
||||
sendmessage("Unknown npc");
|
||||
return false;
|
||||
if (compound == null) {
|
||||
sendmessage("Unknown npc");
|
||||
return false;
|
||||
}
|
||||
World world = pcParam.getEntityWorld();
|
||||
double posX = pcParam.getPlayerCoordinates().posX;
|
||||
double posY = pcParam.getPlayerCoordinates().posY;
|
||||
double posZ = pcParam.getPlayerCoordinates().posZ;
|
||||
|
||||
if(args.length > 4){
|
||||
String location = args[4];
|
||||
String[] par;
|
||||
if (location.contains(":")){
|
||||
par = location.split(":");
|
||||
location = par[1];
|
||||
world = Utils.getWorld(par[0]);
|
||||
if (world == null){
|
||||
sendmessage (String.format("'%s' is an unknown world",par[0]));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (args.length > 4) {
|
||||
String location = args[4];
|
||||
String[] par;
|
||||
if (location.contains(":")) {
|
||||
par = location.split(":");
|
||||
location = par[1];
|
||||
world = Utils.getWorld(par[0]);
|
||||
if (world == null) {
|
||||
sendmessage(String.format("'%s' is an unknown world", par[0]));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (location.contains(",")){
|
||||
par = location.split(",");
|
||||
if (par.length != 3){
|
||||
sendmessage("Location need be x,y,z");
|
||||
return false;
|
||||
}
|
||||
try{
|
||||
posX = CommandBase.func_110666_a(pcParam, posX, par[0]);
|
||||
posY = CommandBase.func_110665_a(pcParam, posY, par[1].trim(), 0, 0);
|
||||
posZ = CommandBase.func_110666_a(pcParam, posZ, par[2]);
|
||||
} catch(NumberFormatException ex){
|
||||
sendmessage("Location should be in numbers");
|
||||
return false;
|
||||
}
|
||||
if (args.length > 5){
|
||||
newname = args[5];
|
||||
}
|
||||
} else {
|
||||
newname = location;
|
||||
}
|
||||
if (location.contains(",")) {
|
||||
par = location.split(",");
|
||||
if (par.length != 3) {
|
||||
sendmessage("Location need be x,y,z");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
posX = CommandBase.func_110666_a(pcParam, posX, par[0]);
|
||||
posY = CommandBase.func_110665_a(pcParam, posY, par[1].trim(), 0, 0);
|
||||
posZ = CommandBase.func_110666_a(pcParam, posZ, par[2]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendmessage("Location should be in numbers");
|
||||
return false;
|
||||
}
|
||||
if (args.length > 5) {
|
||||
newname = args[5];
|
||||
}
|
||||
} else {
|
||||
newname = location;
|
||||
}
|
||||
}
|
||||
|
||||
if (posX == 0 && posY == 0 && posZ == 0){//incase it was called from the console and not pos was given
|
||||
sendmessage ("Location needed");
|
||||
if (posX == 0 && posY == 0 && posZ == 0) {//incase it was called from the console and not pos was given
|
||||
sendmessage("Location needed");
|
||||
return false;
|
||||
}
|
||||
|
||||
for(int x = 0; x < width; x++){
|
||||
for(int z = 0; z < height; z++){
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int z = 0; z < height; z++) {
|
||||
Entity entity = EntityList.createEntityFromNBT(compound, world);
|
||||
int xx = MathHelper.floor_double(posX) + x;
|
||||
int yy = Math.max(MathHelper.floor_double(posY) - 2, 1);
|
||||
int zz = MathHelper.floor_double(posZ) + z;
|
||||
|
||||
for(int y = 0; y < 10; y++){
|
||||
Block b = world.getBlock(xx, yy + y, zz);
|
||||
Block b2 = world.getBlock(xx, yy + y + 1, zz);
|
||||
if(b != null && (b2 == null || b2.getCollisionBoundingBoxFromPool(world, xx, yy + y + 1, zz) == null)){
|
||||
yy += y;
|
||||
break;
|
||||
}
|
||||
for (int y = 0; y < 10; y++) {
|
||||
Block b = world.getBlock(xx, yy + y, zz);
|
||||
Block b2 = world.getBlock(xx, yy + y + 1, zz);
|
||||
if (b != null && (b2 == null || b2.getCollisionBoundingBoxFromPool(world, xx, yy + y + 1, zz) == null)) {
|
||||
yy += y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
entity.setPosition(posX + 0.5 + x, yy + 1, posZ + 0.5 + z);
|
||||
if(entity instanceof EntityNPCInterface){
|
||||
EntityNPCInterface npc = (EntityNPCInterface) entity;
|
||||
npc.ais.startPos = new int[]{xx, yy, zz};
|
||||
if(newname != null && !newname.isEmpty())
|
||||
npc.display.name = newname.replaceAll("%", " "); // like name, newname must use % in place of space to keep a logical way
|
||||
if (entity instanceof EntityNPCInterface) {
|
||||
EntityNPCInterface npc = (EntityNPCInterface) entity;
|
||||
npc.ais.startPos = new int[]{xx, yy, zz};
|
||||
if (newname != null && !newname.isEmpty())
|
||||
npc.display.name = newname.replaceAll("%", " "); // like name, newname must use % in place of space to keep a logical way
|
||||
}
|
||||
world.spawnEntityInWorld(entity);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user