mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 19:39:07 +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);
|
||||
}
|
||||
|
||||
@@ -22,193 +22,185 @@ import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
|
||||
@Command(
|
||||
name="config",
|
||||
desc="Some config things you can set ",
|
||||
usage=""
|
||||
name = "config",
|
||||
desc = "Some config things you can set ",
|
||||
usage = ""
|
||||
)
|
||||
public class CmdConfig extends ChMcLogger {
|
||||
|
||||
public CmdConfig(Object sender) {
|
||||
super (sender);
|
||||
super(sender);
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="Disable/Enable the natural leaves decay",
|
||||
usage="<true/false>",
|
||||
permissions={OpOnly.class},
|
||||
hasEmptyCall = true
|
||||
desc = "Disable/Enable the natural leaves decay",
|
||||
usage = "<true/false>",
|
||||
permissions = {OpOnly.class},
|
||||
hasEmptyCall = true
|
||||
)
|
||||
public boolean leavesdecay(String[] args){
|
||||
if(args.length == 0){
|
||||
sendmessage("LeavesDecay: " + ConfigMain.LeavesDecayEnabled);
|
||||
}
|
||||
else{
|
||||
ConfigMain.LeavesDecayEnabled = Boolean.parseBoolean(args[0]);
|
||||
ConfigMain.LeavesDecayEnabledProperty.set(ConfigMain.LeavesDecayEnabled);
|
||||
if(ConfigMain.config.hasChanged()){
|
||||
ConfigMain.config.save();
|
||||
}
|
||||
public boolean leavesdecay(String[] args) {
|
||||
if (args.length == 0) {
|
||||
sendmessage("LeavesDecay: " + ConfigMain.LeavesDecayEnabled);
|
||||
} else {
|
||||
ConfigMain.LeavesDecayEnabled = Boolean.parseBoolean(args[0]);
|
||||
ConfigMain.LeavesDecayEnabledProperty.set(ConfigMain.LeavesDecayEnabled);
|
||||
if (ConfigMain.config.hasChanged()) {
|
||||
ConfigMain.config.save();
|
||||
}
|
||||
Set<String> names = Block.blockRegistry.getKeys();
|
||||
for(String name : names){
|
||||
Block block = (Block) Block.blockRegistry.getObject(name);
|
||||
if(block instanceof BlockLeavesBase){
|
||||
block.setTickRandomly(ConfigMain.LeavesDecayEnabled);
|
||||
}
|
||||
for (String name : names) {
|
||||
Block block = (Block) Block.blockRegistry.getObject(name);
|
||||
if (block instanceof BlockLeavesBase) {
|
||||
block.setTickRandomly(ConfigMain.LeavesDecayEnabled);
|
||||
}
|
||||
}
|
||||
sendmessage("LeavesDecay is now " + ConfigMain.LeavesDecayEnabled);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="Disable/Enable the vines growing",
|
||||
usage="<true/false>",
|
||||
permissions={OpOnly.class},
|
||||
hasEmptyCall = true
|
||||
desc = "Disable/Enable the vines growing",
|
||||
usage = "<true/false>",
|
||||
permissions = {OpOnly.class},
|
||||
hasEmptyCall = true
|
||||
)
|
||||
public boolean vinegrowth(String[] args){
|
||||
if(args.length == 0){
|
||||
sendmessage("VineGrowth: " + ConfigMain.VineGrowthEnabled);
|
||||
}
|
||||
else{
|
||||
ConfigMain.VineGrowthEnabled = Boolean.parseBoolean(args[0]);
|
||||
ConfigMain.VineGrowthEnabledProperty.set(ConfigMain.VineGrowthEnabled);
|
||||
if(ConfigMain.config.hasChanged()){
|
||||
ConfigMain.config.save();
|
||||
}
|
||||
public boolean vinegrowth(String[] args) {
|
||||
if (args.length == 0) {
|
||||
sendmessage("VineGrowth: " + ConfigMain.VineGrowthEnabled);
|
||||
} else {
|
||||
ConfigMain.VineGrowthEnabled = Boolean.parseBoolean(args[0]);
|
||||
ConfigMain.VineGrowthEnabledProperty.set(ConfigMain.VineGrowthEnabled);
|
||||
if (ConfigMain.config.hasChanged()) {
|
||||
ConfigMain.config.save();
|
||||
}
|
||||
Set<String> names = Block.blockRegistry.getKeys();
|
||||
for(String name : names){
|
||||
Block block = (Block) Block.blockRegistry.getObject(name);
|
||||
if(block instanceof BlockVine){
|
||||
block.setTickRandomly(ConfigMain.VineGrowthEnabled);
|
||||
}
|
||||
for (String name : names) {
|
||||
Block block = (Block) Block.blockRegistry.getObject(name);
|
||||
if (block instanceof BlockVine) {
|
||||
block.setTickRandomly(ConfigMain.VineGrowthEnabled);
|
||||
}
|
||||
}
|
||||
sendmessage("VineGrowth is now " + ConfigMain.VineGrowthEnabled);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="Disable/Enable the ice melting",
|
||||
usage="<true/false>",
|
||||
permissions={OpOnly.class},
|
||||
hasEmptyCall = true
|
||||
desc = "Disable/Enable the ice melting",
|
||||
usage = "<true/false>",
|
||||
permissions = {OpOnly.class},
|
||||
hasEmptyCall = true
|
||||
)
|
||||
public boolean icemelts(String[] args){
|
||||
if(args.length == 0){
|
||||
sendmessage("IceMelts: " + ConfigMain.IceMeltsEnabled);
|
||||
}
|
||||
else{
|
||||
ConfigMain.IceMeltsEnabled = Boolean.parseBoolean(args[0]);
|
||||
ConfigMain.IceMeltsEnabledProperty.set(ConfigMain.IceMeltsEnabled);
|
||||
if(ConfigMain.config.hasChanged()){
|
||||
ConfigMain.config.save();
|
||||
}
|
||||
public boolean icemelts(String[] args) {
|
||||
if (args.length == 0) {
|
||||
sendmessage("IceMelts: " + ConfigMain.IceMeltsEnabled);
|
||||
} else {
|
||||
ConfigMain.IceMeltsEnabled = Boolean.parseBoolean(args[0]);
|
||||
ConfigMain.IceMeltsEnabledProperty.set(ConfigMain.IceMeltsEnabled);
|
||||
if (ConfigMain.config.hasChanged()) {
|
||||
ConfigMain.config.save();
|
||||
}
|
||||
Set<String> names = Block.blockRegistry.getKeys();
|
||||
for(String name : names){
|
||||
Block block = (Block) Block.blockRegistry.getObject(name);
|
||||
if(block instanceof BlockIce){
|
||||
block.setTickRandomly(ConfigMain.IceMeltsEnabled);
|
||||
}
|
||||
for (String name : names) {
|
||||
Block block = (Block) Block.blockRegistry.getObject(name);
|
||||
if (block instanceof BlockIce) {
|
||||
block.setTickRandomly(ConfigMain.IceMeltsEnabled);
|
||||
}
|
||||
}
|
||||
sendmessage("IceMelts is now " + ConfigMain.IceMeltsEnabled);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="Disable/Enable guns shooting",
|
||||
usage="<true/false>",
|
||||
permissions={OpOnly.class},
|
||||
hasEmptyCall = true
|
||||
desc = "Disable/Enable guns shooting",
|
||||
usage = "<true/false>",
|
||||
permissions = {OpOnly.class},
|
||||
hasEmptyCall = true
|
||||
)
|
||||
public boolean guns(String[] args){
|
||||
if(args.length == 0){
|
||||
sendmessage("GunsEnabled: " + ConfigItem.GunsEnabled);
|
||||
}
|
||||
else{
|
||||
ConfigItem.GunsEnabled = Boolean.parseBoolean(args[0]);
|
||||
ConfigItem.GunsEnabledProperty.set(ConfigItem.GunsEnabled);
|
||||
if(ConfigMain.config.hasChanged()){
|
||||
ConfigMain.config.save();
|
||||
}
|
||||
public boolean guns(String[] args) {
|
||||
if (args.length == 0) {
|
||||
sendmessage("GunsEnabled: " + ConfigItem.GunsEnabled);
|
||||
} else {
|
||||
ConfigItem.GunsEnabled = Boolean.parseBoolean(args[0]);
|
||||
ConfigItem.GunsEnabledProperty.set(ConfigItem.GunsEnabled);
|
||||
if (ConfigMain.config.hasChanged()) {
|
||||
ConfigMain.config.save();
|
||||
}
|
||||
sendmessage("GunsEnabled is now " + ConfigItem.GunsEnabled);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="Freezes/Unfreezes npcs",
|
||||
usage="<true/false>",
|
||||
permissions={OpOnly.class},
|
||||
hasEmptyCall = true
|
||||
desc = "Freezes/Unfreezes npcs",
|
||||
usage = "<true/false>",
|
||||
permissions = {OpOnly.class},
|
||||
hasEmptyCall = true
|
||||
)
|
||||
public boolean freezenpcs(String[] args){
|
||||
if(args.length == 0){
|
||||
sendmessage("Frozen NPCs: " + CustomNpcs.FreezeNPCs);
|
||||
}
|
||||
else{
|
||||
CustomNpcs.FreezeNPCs = Boolean.parseBoolean(args[0]);
|
||||
public boolean freezenpcs(String[] args) {
|
||||
if (args.length == 0) {
|
||||
sendmessage("Frozen NPCs: " + CustomNpcs.FreezeNPCs);
|
||||
} else {
|
||||
CustomNpcs.FreezeNPCs = Boolean.parseBoolean(args[0]);
|
||||
sendmessage("FrozenNPCs is now " + CustomNpcs.FreezeNPCs);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="Set how many active chunkloaders you can have",
|
||||
usage="<number>",
|
||||
permissions={OpOnly.class},
|
||||
hasEmptyCall = true
|
||||
desc = "Set how many active chunkloaders you can have",
|
||||
usage = "<number>",
|
||||
permissions = {OpOnly.class},
|
||||
hasEmptyCall = true
|
||||
)
|
||||
public boolean chunkloaders(String[] args){
|
||||
if(args.length == 0){
|
||||
sendmessage("ChunkLoaders: " + ChunkController.Instance.size() + "/" + ConfigMain.ChunkLoaders);
|
||||
}
|
||||
else{
|
||||
try{
|
||||
ConfigMain.ChunkLoaders = Integer.parseInt(args[0]);
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
sendmessage("Didnt get a number");
|
||||
return false;
|
||||
}
|
||||
public boolean chunkloaders(String[] args) {
|
||||
if (args.length == 0) {
|
||||
sendmessage("ChunkLoaders: " + ChunkController.Instance.size() + "/" + ConfigMain.ChunkLoaders);
|
||||
} else {
|
||||
try {
|
||||
ConfigMain.ChunkLoaders = Integer.parseInt(args[0]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendmessage("Didnt get a number");
|
||||
return false;
|
||||
}
|
||||
|
||||
ConfigMain.ChunkLoadersProperty.set(ConfigMain.ChunkLoaders);
|
||||
if(ConfigMain.config.hasChanged()){
|
||||
ConfigMain.config.save();
|
||||
}
|
||||
int size = ChunkController.Instance.size();
|
||||
if(size > ConfigMain.ChunkLoaders){
|
||||
ChunkController.Instance.unload(size - ConfigMain.ChunkLoaders);
|
||||
sendmessage(size - ConfigMain.ChunkLoaders + " chunksloaders unloaded");
|
||||
}
|
||||
sendmessage("ChunkLoaders: " + ChunkController.Instance.size() + "/" + ConfigMain.ChunkLoaders);
|
||||
}
|
||||
ConfigMain.ChunkLoadersProperty.set(ConfigMain.ChunkLoaders);
|
||||
if (ConfigMain.config.hasChanged()) {
|
||||
ConfigMain.config.save();
|
||||
}
|
||||
int size = ChunkController.Instance.size();
|
||||
if (size > ConfigMain.ChunkLoaders) {
|
||||
ChunkController.Instance.unload(size - ConfigMain.ChunkLoaders);
|
||||
sendmessage(size - ConfigMain.ChunkLoaders + " chunksloaders unloaded");
|
||||
}
|
||||
sendmessage("ChunkLoaders: " + ChunkController.Instance.size() + "/" + ConfigMain.ChunkLoaders);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@SubCommand(
|
||||
desc="Get/Set font",
|
||||
usage="[type] [size]",
|
||||
permissions={PlayerOnly.class},
|
||||
hasEmptyCall = true
|
||||
desc = "Get/Set font",
|
||||
usage = "[type] [size]",
|
||||
permissions = {PlayerOnly.class},
|
||||
hasEmptyCall = true
|
||||
)
|
||||
public void font(String[] args){
|
||||
int size = 18;
|
||||
if(args.length > 1){
|
||||
try{
|
||||
size = Integer.parseInt(args[args.length - 1]);
|
||||
args = Arrays.copyOfRange(args, 0, args.length - 1);
|
||||
}
|
||||
catch(Exception e){
|
||||
public void font(String[] args) {
|
||||
int size = 18;
|
||||
if (args.length > 1) {
|
||||
try {
|
||||
size = Integer.parseInt(args[args.length - 1]);
|
||||
args = Arrays.copyOfRange(args, 0, args.length - 1);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
String font = "";
|
||||
for(int i = 0; i < args.length; i++){
|
||||
font += " " + args[i];
|
||||
}
|
||||
PacketHandler.Instance.sendToPlayer(new ConfigCommandPacket(EnumConfigOperation.FONT, font.trim(), size), (EntityPlayerMP)this.pcParam);
|
||||
}
|
||||
}
|
||||
String font = "";
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
font += " " + args[i];
|
||||
}
|
||||
PacketHandler.Instance.sendToPlayer(new ConfigCommandPacket(EnumConfigOperation.FONT, font.trim(), size), (EntityPlayerMP) this.pcParam);
|
||||
}
|
||||
}
|
||||
@@ -19,9 +19,9 @@ import noppes.npcs.entity.EntityDialogNpc;
|
||||
import java.util.List;
|
||||
|
||||
@Command(
|
||||
name="dialog",
|
||||
desc="dialog operations",
|
||||
usage="help"
|
||||
name = "dialog",
|
||||
desc = "dialog operations",
|
||||
usage = "help"
|
||||
)
|
||||
public class CmdDialog extends ChMcLogger {
|
||||
|
||||
@@ -31,15 +31,15 @@ public class CmdDialog extends ChMcLogger {
|
||||
|
||||
|
||||
@SubCommand(
|
||||
desc="force read",
|
||||
usage="<player> <dialog>",
|
||||
permissions={OpOnly.class, ParamCheck.class}
|
||||
desc = "force read",
|
||||
usage = "<player> <dialog>",
|
||||
permissions = {OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public boolean read(String args[]){
|
||||
String playername=args[0];
|
||||
public boolean read(String args[]) {
|
||||
String playername = args[0];
|
||||
int diagid;
|
||||
try {
|
||||
diagid = Integer.parseInt(args[1]);
|
||||
diagid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendmessage("DialogID must be an integer");
|
||||
return false;
|
||||
@@ -49,24 +49,24 @@ public class CmdDialog extends ChMcLogger {
|
||||
sendmessage(String.format("Unknow player '%s'", playername));
|
||||
return false;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.dialogData.dialogsRead.add(diagid);
|
||||
playerdata.save();
|
||||
for (PlayerData playerdata : data) {
|
||||
playerdata.dialogData.dialogsRead.add(diagid);
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="force unread dialog",
|
||||
usage="<player> <dialog>",
|
||||
permissions={OpOnly.class, ParamCheck.class}
|
||||
desc = "force unread dialog",
|
||||
usage = "<player> <dialog>",
|
||||
permissions = {OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public boolean unread(String args[]){
|
||||
String playername=args[0];
|
||||
public boolean unread(String args[]) {
|
||||
String playername = args[0];
|
||||
int diagid;
|
||||
try {
|
||||
diagid = Integer.parseInt(args[1]);
|
||||
diagid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendmessage("DialogID must be an integer");
|
||||
return false;
|
||||
@@ -76,56 +76,57 @@ public class CmdDialog extends ChMcLogger {
|
||||
sendmessage(String.format("Unknow player '%s'", playername));
|
||||
return false;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.dialogData.dialogsRead.remove(diagid);
|
||||
playerdata.save();
|
||||
for (PlayerData playerdata : data) {
|
||||
playerdata.dialogData.dialogsRead.remove(diagid);
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="reload dialogs from disk",
|
||||
permissions={OpOnly.class}
|
||||
desc = "reload dialogs from disk",
|
||||
permissions = {OpOnly.class}
|
||||
)
|
||||
public boolean reload(String args[]){
|
||||
new DialogController().load();
|
||||
public boolean reload(String args[]) {
|
||||
new DialogController().load();
|
||||
SyncController.syncAllDialogs();
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@SubCommand(
|
||||
desc="show dialog",
|
||||
usage="<player> <dialog> <name>",
|
||||
permissions={OpOnly.class}
|
||||
desc = "show dialog",
|
||||
usage = "<player> <dialog> <name>",
|
||||
permissions = {OpOnly.class}
|
||||
)
|
||||
public void show(String args[]){
|
||||
EntityPlayer player = CommandBase.getPlayer(pcParam, args[0]);
|
||||
if(player == null){
|
||||
public void show(String args[]) {
|
||||
EntityPlayer player = CommandBase.getPlayer(pcParam, args[0]);
|
||||
if (player == null) {
|
||||
sendmessage(String.format("Unknow player '%s'", args[0]));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int diagid;
|
||||
try {
|
||||
diagid = Integer.parseInt(args[1]);
|
||||
diagid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendmessage("DialogID must be an integer: " + args[1]);
|
||||
return;
|
||||
}
|
||||
Dialog dialog = DialogController.Instance.dialogs.get(diagid);
|
||||
if(dialog == null){
|
||||
if (dialog == null) {
|
||||
sendmessage("Unknown dialog id: " + args[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
EntityDialogNpc npc = new EntityDialogNpc(this.pcParam.getEntityWorld());
|
||||
npc.display.name = args[2];
|
||||
EntityUtil.Copy(player, npc);
|
||||
DialogOption option = new DialogOption();
|
||||
option.dialogId = diagid;
|
||||
option.title = dialog.title;
|
||||
npc.dialogs.put(0, option);
|
||||
NoppesUtilServer.openDialog(player, npc, dialog, 0);
|
||||
EntityDialogNpc npc = new EntityDialogNpc(this.pcParam.getEntityWorld());
|
||||
npc.display.name = args[2];
|
||||
EntityUtil.Copy(player, npc);
|
||||
DialogOption option = new DialogOption();
|
||||
option.dialogId = diagid;
|
||||
option.title = dialog.title;
|
||||
npc.dialogs.put(0, option);
|
||||
NoppesUtilServer.openDialog(player, npc, dialog, 0);
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,8 @@ import noppes.npcs.controllers.data.PlayerFactionData;
|
||||
import java.util.List;
|
||||
|
||||
@Command(
|
||||
name = "faction",
|
||||
desc = "operations about relationship between player and faction"
|
||||
name = "faction",
|
||||
desc = "operations about relationship between player and faction"
|
||||
)
|
||||
public class CmdFaction extends ChMcLogger {
|
||||
|
||||
@@ -27,9 +27,9 @@ public class CmdFaction extends ChMcLogger {
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Add points",
|
||||
usage = "<points>",
|
||||
permissions={OpOnly.class, ParamCheck.class}
|
||||
desc = "Add points",
|
||||
usage = "<points>",
|
||||
permissions = {OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean add(String[] args) {
|
||||
int points;
|
||||
@@ -41,8 +41,8 @@ public class CmdFaction extends ChMcLogger {
|
||||
}
|
||||
int factionid = this.selectedFaction.id;
|
||||
|
||||
for(PlayerData playerdata : data){
|
||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||
for (PlayerData playerdata : data) {
|
||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||
playerfactiondata.increasePoints(factionid, points, playerdata.player);
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
@@ -50,9 +50,9 @@ public class CmdFaction extends ChMcLogger {
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Substract points",
|
||||
usage = "<points>",
|
||||
permissions={OpOnly.class, ParamCheck.class}
|
||||
desc = "Substract points",
|
||||
usage = "<points>",
|
||||
permissions = {OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean subtract(String[] args) {
|
||||
int points;
|
||||
@@ -63,8 +63,8 @@ public class CmdFaction extends ChMcLogger {
|
||||
return false;
|
||||
}
|
||||
int factionid = this.selectedFaction.id;
|
||||
for(PlayerData playerdata : data){
|
||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||
for (PlayerData playerdata : data) {
|
||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||
playerfactiondata.increasePoints(factionid, -points, playerdata.player);
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
@@ -72,22 +72,22 @@ public class CmdFaction extends ChMcLogger {
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Reset points to default",
|
||||
usage = "",
|
||||
permissions={OpOnly.class}
|
||||
desc = "Reset points to default",
|
||||
usage = "",
|
||||
permissions = {OpOnly.class}
|
||||
)
|
||||
public Boolean reset(String[] args) {
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.factionData.factionData.put(this.selectedFaction.id, this.selectedFaction.defaultPoints);
|
||||
for (PlayerData playerdata : data) {
|
||||
playerdata.factionData.factionData.put(this.selectedFaction.id, this.selectedFaction.defaultPoints);
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Set points",
|
||||
usage = "<points>",
|
||||
permissions={OpOnly.class, ParamCheck.class}
|
||||
desc = "Set points",
|
||||
usage = "<points>",
|
||||
permissions = {OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean set(String[] args) {
|
||||
int points;
|
||||
@@ -97,22 +97,22 @@ public class CmdFaction extends ChMcLogger {
|
||||
sendmessage("Must be an integer");
|
||||
return false;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||
playerfactiondata.factionData.put(this.selectedFaction.id,points);
|
||||
for (PlayerData playerdata : data) {
|
||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||
playerfactiondata.factionData.put(this.selectedFaction.id, points);
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="Drop relationship",
|
||||
usage="",
|
||||
permissions={OpOnly.class}
|
||||
desc = "Drop relationship",
|
||||
usage = "",
|
||||
permissions = {OpOnly.class}
|
||||
)
|
||||
public Boolean drop(String[] args){
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.factionData.factionData.remove(this.selectedFaction.id);
|
||||
public Boolean drop(String[] args) {
|
||||
for (PlayerData playerdata : data) {
|
||||
playerdata.factionData.factionData.remove(this.selectedFaction.id);
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -30,194 +30,194 @@ import noppes.npcs.entity.EntityNPCInterface;
|
||||
import java.util.*;
|
||||
|
||||
@Command(
|
||||
name = "noppes",
|
||||
desc = "noppes root command",
|
||||
sub = {CmdClone.class, CmdScript.class, CmdQuest.class, CmdDialog.class, CmdConfig.class}
|
||||
name = "noppes",
|
||||
desc = "noppes root command",
|
||||
sub = {CmdClone.class, CmdScript.class, CmdQuest.class, CmdDialog.class, CmdConfig.class}
|
||||
)
|
||||
public class CmdNoppes extends ChMcLogger {
|
||||
|
||||
public CmdFaction cmdfaction = new CmdFaction(ctorParm);
|
||||
public CmdNpc cmdnpc = new CmdNpc(ctorParm);
|
||||
public static Map<String, Class<?>> SlayMap = new LinkedHashMap<String, Class<?>>();
|
||||
public CmdFaction cmdfaction = new CmdFaction(ctorParm);
|
||||
public CmdNpc cmdnpc = new CmdNpc(ctorParm);
|
||||
public static Map<String, Class<?>> SlayMap = new LinkedHashMap<String, Class<?>>();
|
||||
|
||||
public CmdNoppes(Object sender) {
|
||||
super(sender);
|
||||
public CmdNoppes(Object sender) {
|
||||
super(sender);
|
||||
|
||||
SlayMap.clear();
|
||||
SlayMap.clear();
|
||||
|
||||
SlayMap.put("all", EntityLivingBase.class);
|
||||
SlayMap.put("mobs", EntityMob.class);
|
||||
SlayMap.put("animals", EntityAnimal.class);
|
||||
SlayMap.put("items", EntityItem.class);
|
||||
SlayMap.put("xporbs", EntityXPOrb.class);
|
||||
SlayMap.put("npcs", EntityNPCInterface.class);
|
||||
SlayMap.put("all", EntityLivingBase.class);
|
||||
SlayMap.put("mobs", EntityMob.class);
|
||||
SlayMap.put("animals", EntityAnimal.class);
|
||||
SlayMap.put("items", EntityItem.class);
|
||||
SlayMap.put("xporbs", EntityXPOrb.class);
|
||||
SlayMap.put("npcs", EntityNPCInterface.class);
|
||||
|
||||
HashMap<String, Class<?>> list = new HashMap<String, Class<?>>(EntityList.stringToClassMapping);
|
||||
for (String name : list.keySet()) {
|
||||
Class<?> cls = list.get(name);
|
||||
if (EntityNPCInterface.class.isAssignableFrom(cls))
|
||||
continue;
|
||||
if (!EntityLivingBase.class.isAssignableFrom(cls))
|
||||
continue;
|
||||
SlayMap.put(name.toLowerCase(), list.get(name));
|
||||
}
|
||||
HashMap<String, Class<?>> list = new HashMap<String, Class<?>>(EntityList.stringToClassMapping);
|
||||
for (String name : list.keySet()) {
|
||||
Class<?> cls = list.get(name);
|
||||
if (EntityNPCInterface.class.isAssignableFrom(cls))
|
||||
continue;
|
||||
if (!EntityLivingBase.class.isAssignableFrom(cls))
|
||||
continue;
|
||||
SlayMap.put(name.toLowerCase(), list.get(name));
|
||||
}
|
||||
|
||||
SlayMap.remove("monster");
|
||||
SlayMap.remove("mob");
|
||||
}
|
||||
SlayMap.remove("monster");
|
||||
SlayMap.remove("mob");
|
||||
}
|
||||
|
||||
|
||||
@SubCommand(
|
||||
name = "faction",
|
||||
desc = "Faction operations",
|
||||
usage = "<player> <faction> <command>",
|
||||
permissions = {OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean faction(String[] args) {
|
||||
String playername = args[0];
|
||||
String factionname = args[1];
|
||||
@SubCommand(
|
||||
name = "faction",
|
||||
desc = "Faction operations",
|
||||
usage = "<player> <faction> <command>",
|
||||
permissions = {OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean faction(String[] args) {
|
||||
String playername = args[0];
|
||||
String factionname = args[1];
|
||||
|
||||
cmdfaction.data = getPlayersData(playername);
|
||||
if (cmdfaction.data.isEmpty()) {
|
||||
sendmessage(String.format("Unknow player '%s'", playername));
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
cmdfaction.selectedFaction = FactionController.getInstance().get(Integer.parseInt(factionname));
|
||||
} catch (NumberFormatException e) {
|
||||
cmdfaction.selectedFaction = FactionController.getInstance().getFactionFromName(factionname); // get faction data
|
||||
}
|
||||
if (cmdfaction.selectedFaction == null) {
|
||||
sendmessage(String.format("Unknow facion '%s", factionname));
|
||||
return false;
|
||||
}
|
||||
args = Arrays.copyOfRange(args, 2, args.length);
|
||||
cmdfaction.processCommand(this.pcParam, args);
|
||||
cmdfaction.data = getPlayersData(playername);
|
||||
if (cmdfaction.data.isEmpty()) {
|
||||
sendmessage(String.format("Unknow player '%s'", playername));
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
cmdfaction.selectedFaction = FactionController.getInstance().get(Integer.parseInt(factionname));
|
||||
} catch (NumberFormatException e) {
|
||||
cmdfaction.selectedFaction = FactionController.getInstance().getFactionFromName(factionname); // get faction data
|
||||
}
|
||||
if (cmdfaction.selectedFaction == null) {
|
||||
sendmessage(String.format("Unknow facion '%s", factionname));
|
||||
return false;
|
||||
}
|
||||
args = Arrays.copyOfRange(args, 2, args.length);
|
||||
cmdfaction.processCommand(this.pcParam, args);
|
||||
|
||||
for (PlayerData playerdata : cmdfaction.data) {
|
||||
playerdata.save();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
for (PlayerData playerdata : cmdfaction.data) {
|
||||
playerdata.save();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "NPC manipulations",
|
||||
usage = "<npc> <command>",
|
||||
permissions = {OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public boolean npc(String[] args) {
|
||||
String npcname = args[0].replace("%", " ");
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
if (args[0].equalsIgnoreCase("create")) {
|
||||
cmdnpc.processCommand(this.pcParam, new String[]{args[0], npcname});
|
||||
return true;
|
||||
}
|
||||
int x = pcParam.getPlayerCoordinates().posX;
|
||||
int y = pcParam.getPlayerCoordinates().posY;
|
||||
int z = pcParam.getPlayerCoordinates().posZ;
|
||||
List<EntityNPCInterface> list = getNearbeEntityFromPlayer(EntityNPCInterface.class, pcParam.getEntityWorld(), x, y, z, 80);
|
||||
EntityNPCInterface closest = null;
|
||||
for (EntityNPCInterface npc : list) {
|
||||
String name = npc.display.name.replace(" ", "_");
|
||||
if (name.equalsIgnoreCase(npcname)) {
|
||||
if (closest == null || closest.getDistanceSq(x, y, z) > npc.getDistanceSq(x, y, z))
|
||||
closest = npc;
|
||||
}
|
||||
}
|
||||
if (closest != null) {
|
||||
cmdnpc.selectedNpc = closest;
|
||||
cmdnpc.processCommand(this.pcParam, args);
|
||||
cmdnpc.selectedNpc = null;
|
||||
} else
|
||||
sendmessage(String.format("NPC '%s' was not found", npcname));
|
||||
return true;
|
||||
}
|
||||
@SubCommand(
|
||||
desc = "NPC manipulations",
|
||||
usage = "<npc> <command>",
|
||||
permissions = {OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public boolean npc(String[] args) {
|
||||
String npcname = args[0].replace("%", " ");
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
if (args[0].equalsIgnoreCase("create")) {
|
||||
cmdnpc.processCommand(this.pcParam, new String[]{args[0], npcname});
|
||||
return true;
|
||||
}
|
||||
int x = pcParam.getPlayerCoordinates().posX;
|
||||
int y = pcParam.getPlayerCoordinates().posY;
|
||||
int z = pcParam.getPlayerCoordinates().posZ;
|
||||
List<EntityNPCInterface> list = getNearbeEntityFromPlayer(EntityNPCInterface.class, pcParam.getEntityWorld(), x, y, z, 80);
|
||||
EntityNPCInterface closest = null;
|
||||
for (EntityNPCInterface npc : list) {
|
||||
String name = npc.display.name.replace(" ", "_");
|
||||
if (name.equalsIgnoreCase(npcname)) {
|
||||
if (closest == null || closest.getDistanceSq(x, y, z) > npc.getDistanceSq(x, y, z))
|
||||
closest = npc;
|
||||
}
|
||||
}
|
||||
if (closest != null) {
|
||||
cmdnpc.selectedNpc = closest;
|
||||
cmdnpc.processCommand(this.pcParam, args);
|
||||
cmdnpc.selectedNpc = null;
|
||||
} else
|
||||
sendmessage(String.format("NPC '%s' was not found", npcname));
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
name = "slay",
|
||||
desc = "Kills given entity within range. Also has all, mobs, animal options. Can have multiple types",
|
||||
usage = "<type>.. [range]",
|
||||
permissions = {PlayerOnly.class, OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean slay(String[] args) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) pcParam;
|
||||
ArrayList<Class<?>> toDelete = new ArrayList<Class<?>>();
|
||||
boolean deleteNPCs = false;
|
||||
for (String delete : args) {
|
||||
delete = delete.toLowerCase();
|
||||
Class<?> cls = SlayMap.get(delete);
|
||||
if (cls != null)
|
||||
toDelete.add(cls);
|
||||
if (delete.equals("mobs")) {
|
||||
toDelete.add(EntityGhast.class);
|
||||
toDelete.add(EntityDragon.class);
|
||||
}
|
||||
if (delete.equals("npcs"))
|
||||
deleteNPCs = true;
|
||||
}
|
||||
int count = 0;
|
||||
int range = 120;
|
||||
try {
|
||||
range = Integer.parseInt(args[args.length - 1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
@SubCommand(
|
||||
name = "slay",
|
||||
desc = "Kills given entity within range. Also has all, mobs, animal options. Can have multiple types",
|
||||
usage = "<type>.. [range]",
|
||||
permissions = {PlayerOnly.class, OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean slay(String[] args) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) pcParam;
|
||||
ArrayList<Class<?>> toDelete = new ArrayList<Class<?>>();
|
||||
boolean deleteNPCs = false;
|
||||
for (String delete : args) {
|
||||
delete = delete.toLowerCase();
|
||||
Class<?> cls = SlayMap.get(delete);
|
||||
if (cls != null)
|
||||
toDelete.add(cls);
|
||||
if (delete.equals("mobs")) {
|
||||
toDelete.add(EntityGhast.class);
|
||||
toDelete.add(EntityDragon.class);
|
||||
}
|
||||
if (delete.equals("npcs"))
|
||||
deleteNPCs = true;
|
||||
}
|
||||
int count = 0;
|
||||
int range = 120;
|
||||
try {
|
||||
range = Integer.parseInt(args[args.length - 1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
|
||||
}
|
||||
AxisAlignedBB box = player.boundingBox.expand(range, range, range);
|
||||
List<Entity> list = player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, box);
|
||||
}
|
||||
AxisAlignedBB box = player.boundingBox.expand(range, range, range);
|
||||
List<Entity> list = player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, box);
|
||||
|
||||
for (Entity entity : list) {
|
||||
if (entity instanceof EntityPlayer)
|
||||
continue;
|
||||
if (entity instanceof EntityTameable && ((EntityTameable) entity).isTamed())
|
||||
continue;
|
||||
if (entity instanceof EntityNPCInterface && !deleteNPCs)
|
||||
continue;
|
||||
if (delete(entity, toDelete))
|
||||
count++;
|
||||
}
|
||||
if (toDelete.contains(EntityXPOrb.class)) {
|
||||
list = player.worldObj.getEntitiesWithinAABB(EntityXPOrb.class, box);
|
||||
for (Entity entity : list) {
|
||||
entity.isDead = true;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (toDelete.contains(EntityItem.class)) {
|
||||
list = player.worldObj.getEntitiesWithinAABB(EntityItem.class, box);
|
||||
for (Entity entity : list) {
|
||||
entity.isDead = true;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
for (Entity entity : list) {
|
||||
if (entity instanceof EntityPlayer)
|
||||
continue;
|
||||
if (entity instanceof EntityTameable && ((EntityTameable) entity).isTamed())
|
||||
continue;
|
||||
if (entity instanceof EntityNPCInterface && !deleteNPCs)
|
||||
continue;
|
||||
if (delete(entity, toDelete))
|
||||
count++;
|
||||
}
|
||||
if (toDelete.contains(EntityXPOrb.class)) {
|
||||
list = player.worldObj.getEntitiesWithinAABB(EntityXPOrb.class, box);
|
||||
for (Entity entity : list) {
|
||||
entity.isDead = true;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (toDelete.contains(EntityItem.class)) {
|
||||
list = player.worldObj.getEntitiesWithinAABB(EntityItem.class, box);
|
||||
for (Entity entity : list) {
|
||||
entity.isDead = true;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
player.addChatMessage(new ChatComponentTranslation(count + " entities deleted"));
|
||||
return true;
|
||||
}
|
||||
player.addChatMessage(new ChatComponentTranslation(count + " entities deleted"));
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean delete(Entity entity, ArrayList<Class<?>> toDelete) {
|
||||
for (Class<?> delete : toDelete) {
|
||||
if (delete == EntityAnimal.class && (entity instanceof EntityHorse)) {
|
||||
continue;
|
||||
}
|
||||
if (delete.isAssignableFrom(entity.getClass())) {
|
||||
entity.isDead = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private boolean delete(Entity entity, ArrayList<Class<?>> toDelete) {
|
||||
for (Class<?> delete : toDelete) {
|
||||
if (delete == EntityAnimal.class && (entity instanceof EntityHorse)) {
|
||||
continue;
|
||||
}
|
||||
if (delete.isAssignableFrom(entity.getClass())) {
|
||||
entity.isDead = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List addTabCompletion(ICommandSender par1, String[] args) {
|
||||
if (args[0].equalsIgnoreCase("slay")) {
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, SlayMap.keySet().toArray(new String[SlayMap.size()]));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("npc") && args.length == 3) {
|
||||
return cmdnpc.addTabCompletion(par1, Arrays.copyOfRange(args, 1, args.length));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("faction") && args.length == 4) {
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"add", "subtract", "set", "reset", "drop", "create"});
|
||||
}
|
||||
return super.addTabCompletion(par1, args);
|
||||
}
|
||||
@Override
|
||||
public List addTabCompletion(ICommandSender par1, String[] args) {
|
||||
if (args[0].equalsIgnoreCase("slay")) {
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, SlayMap.keySet().toArray(new String[SlayMap.size()]));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("npc") && args.length == 3) {
|
||||
return cmdnpc.addTabCompletion(par1, Arrays.copyOfRange(args, 1, args.length));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("faction") && args.length == 4) {
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"add", "subtract", "set", "reset", "drop", "create"});
|
||||
}
|
||||
return super.addTabCompletion(par1, args);
|
||||
}
|
||||
}
|
||||
@@ -22,29 +22,29 @@ import noppes.npcs.roles.RoleFollower;
|
||||
import java.util.List;
|
||||
|
||||
@Command(
|
||||
name="npc",
|
||||
desc="NPC manipulation",
|
||||
usage="<name> <command>"
|
||||
name = "npc",
|
||||
desc = "NPC manipulation",
|
||||
usage = "<name> <command>"
|
||||
)
|
||||
public class CmdNpc extends ChMcLogger {
|
||||
|
||||
CmdNpc(Object ctorParm) {
|
||||
super (ctorParm);
|
||||
super(ctorParm);
|
||||
}
|
||||
|
||||
public EntityNPCInterface selectedNpc;
|
||||
|
||||
|
||||
@SubCommand(
|
||||
desc="Set Home (respawn place)",
|
||||
usage=""
|
||||
desc = "Set Home (respawn place)",
|
||||
usage = ""
|
||||
)
|
||||
public void home(String[] args){
|
||||
public void home(String[] args) {
|
||||
double posX = pcParam.getPlayerCoordinates().posX;
|
||||
double posY = pcParam.getPlayerCoordinates().posY;
|
||||
double posZ = pcParam.getPlayerCoordinates().posZ;
|
||||
|
||||
if(args.length == 3){
|
||||
if (args.length == 3) {
|
||||
posX = CommandBase.func_110666_a(pcParam, selectedNpc.posX, args[0]);
|
||||
posY = CommandBase.func_110665_a(pcParam, selectedNpc.posY, args[1].trim(), 0, 0);
|
||||
posZ = CommandBase.func_110666_a(pcParam, selectedNpc.posZ, args[2]);
|
||||
@@ -54,111 +54,110 @@ public class CmdNpc extends ChMcLogger {
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="Set npc visibility",
|
||||
usage=""
|
||||
desc = "Set npc visibility",
|
||||
usage = ""
|
||||
)
|
||||
public void visible(String[] args){
|
||||
if(args.length < 1)
|
||||
return;
|
||||
boolean bo = args[0].equalsIgnoreCase("true");
|
||||
boolean semi = args[0].equalsIgnoreCase("semi");
|
||||
public void visible(String[] args) {
|
||||
if (args.length < 1)
|
||||
return;
|
||||
boolean bo = args[0].equalsIgnoreCase("true");
|
||||
boolean semi = args[0].equalsIgnoreCase("semi");
|
||||
|
||||
int current = selectedNpc.display.visible;
|
||||
if(semi)
|
||||
selectedNpc.display.visible = 2;
|
||||
else if(bo)
|
||||
selectedNpc.display.visible = 0;
|
||||
else
|
||||
selectedNpc.display.visible = 1;
|
||||
int current = selectedNpc.display.visible;
|
||||
if (semi)
|
||||
selectedNpc.display.visible = 2;
|
||||
else if (bo)
|
||||
selectedNpc.display.visible = 0;
|
||||
else
|
||||
selectedNpc.display.visible = 1;
|
||||
|
||||
if(current != selectedNpc.display.visible)
|
||||
selectedNpc.updateClient = true;
|
||||
if (current != selectedNpc.display.visible)
|
||||
selectedNpc.updateClient = true;
|
||||
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="Delete an NPC",
|
||||
usage=""
|
||||
desc = "Delete an NPC",
|
||||
usage = ""
|
||||
)
|
||||
public void delete(String[] args){
|
||||
selectedNpc.delete();
|
||||
public void delete(String[] args) {
|
||||
selectedNpc.delete();
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="Owner",
|
||||
usage=""
|
||||
desc = "Owner",
|
||||
usage = ""
|
||||
)
|
||||
public void owner(String[] args){
|
||||
if(args.length < 1){
|
||||
EntityPlayer player = null;
|
||||
if(selectedNpc.roleInterface instanceof RoleFollower)
|
||||
player = ((RoleFollower)selectedNpc.roleInterface).owner;
|
||||
public void owner(String[] args) {
|
||||
if (args.length < 1) {
|
||||
EntityPlayer player = null;
|
||||
if (selectedNpc.roleInterface instanceof RoleFollower)
|
||||
player = ((RoleFollower) selectedNpc.roleInterface).owner;
|
||||
|
||||
if(selectedNpc.roleInterface instanceof RoleCompanion)
|
||||
player = ((RoleCompanion)selectedNpc.roleInterface).owner;
|
||||
if (selectedNpc.roleInterface instanceof RoleCompanion)
|
||||
player = ((RoleCompanion) selectedNpc.roleInterface).owner;
|
||||
|
||||
if(player == null)
|
||||
sendmessage("No owner");
|
||||
else
|
||||
sendmessage("Owner is: " + player.getCommandSenderName());
|
||||
}
|
||||
else{
|
||||
EntityPlayerMP player = CommandBase.getPlayer(pcParam, args[0]);
|
||||
if(selectedNpc.roleInterface instanceof RoleFollower)
|
||||
((RoleFollower)selectedNpc.roleInterface).setOwner(player);
|
||||
if (player == null)
|
||||
sendmessage("No owner");
|
||||
else
|
||||
sendmessage("Owner is: " + player.getCommandSenderName());
|
||||
} else {
|
||||
EntityPlayerMP player = CommandBase.getPlayer(pcParam, args[0]);
|
||||
if (selectedNpc.roleInterface instanceof RoleFollower)
|
||||
((RoleFollower) selectedNpc.roleInterface).setOwner(player);
|
||||
|
||||
if(selectedNpc.roleInterface instanceof RoleCompanion)
|
||||
((RoleCompanion)selectedNpc.roleInterface).setOwner(player);
|
||||
}
|
||||
if (selectedNpc.roleInterface instanceof RoleCompanion)
|
||||
((RoleCompanion) selectedNpc.roleInterface).setOwner(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SubCommand(
|
||||
desc="Set npc name",
|
||||
usage=""
|
||||
desc = "Set npc name",
|
||||
usage = ""
|
||||
)
|
||||
public void name(String[] args){
|
||||
if(args.length < 1)
|
||||
return;
|
||||
public void name(String[] args) {
|
||||
if (args.length < 1)
|
||||
return;
|
||||
|
||||
String name = args[0];
|
||||
for(int i = 1; i < args.length; i++){
|
||||
name += " " + args[i];
|
||||
}
|
||||
String name = args[0];
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
name += " " + args[i];
|
||||
}
|
||||
|
||||
if(!selectedNpc.display.name.equals(name)){
|
||||
selectedNpc.display.name = name;
|
||||
selectedNpc.updateClient = true;
|
||||
}
|
||||
if (!selectedNpc.display.name.equals(name)) {
|
||||
selectedNpc.display.name = name;
|
||||
selectedNpc.updateClient = true;
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Creates an NPC",
|
||||
usage = "[name]",
|
||||
permissions = {PlayerOnly.class, OpOnly.class}
|
||||
desc = "Creates an NPC",
|
||||
usage = "[name]",
|
||||
permissions = {PlayerOnly.class, OpOnly.class}
|
||||
)
|
||||
public void create(String[] args) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) pcParam;
|
||||
World pw = player.getEntityWorld();
|
||||
EntityCustomNpc npc = new EntityCustomNpc(pw);
|
||||
if(args.length > 0)
|
||||
npc.display.name = args[0];
|
||||
if (args.length > 0)
|
||||
npc.display.name = args[0];
|
||||
npc.setPositionAndRotation(player.posX, player.posY, player.posZ, player.cameraYaw, player.cameraPitch);
|
||||
npc.ais.startPos = new int[]{MathHelper.floor_double(player.posX),MathHelper.floor_double(player.posY),MathHelper.floor_double(player.posZ)};
|
||||
npc.ais.startPos = new int[]{MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY), MathHelper.floor_double(player.posZ)};
|
||||
pw.spawnEntityInWorld(npc);
|
||||
npc.setHealth(npc.getMaxHealth());
|
||||
NoppesUtilServer.sendOpenGui(player, EnumGuiType.MainMenuDisplay, npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List addTabCompletion(ICommandSender par1, String[] args) {
|
||||
if(args.length == 2){
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"create", "home", "visible", "delete", "owner", "name"});
|
||||
}
|
||||
if(args.length == 3 && args[1].equalsIgnoreCase("owner")){
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames());
|
||||
}
|
||||
public List addTabCompletion(ICommandSender par1, String[] args) {
|
||||
if (args.length == 2) {
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"create", "home", "visible", "delete", "owner", "name"});
|
||||
}
|
||||
if (args.length == 3 && args[1].equalsIgnoreCase("owner")) {
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames());
|
||||
}
|
||||
|
||||
return super.addTabCompletion(par1, args);
|
||||
return super.addTabCompletion(par1, args);
|
||||
}
|
||||
}
|
||||
@@ -17,26 +17,26 @@ import noppes.npcs.controllers.data.QuestData;
|
||||
import java.util.List;
|
||||
|
||||
@Command(
|
||||
name = "quest",
|
||||
usage = "help",
|
||||
desc = "Quest operations"
|
||||
name = "quest",
|
||||
usage = "help",
|
||||
desc = "Quest operations"
|
||||
)
|
||||
public class CmdQuest extends ChMcLogger{
|
||||
public class CmdQuest extends ChMcLogger {
|
||||
|
||||
public CmdQuest(Object sender) {
|
||||
super(sender);
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Start a quest",
|
||||
usage = "<player> <quest>",
|
||||
permissions = {OpOnly.class, ParamCheck.class}
|
||||
desc = "Start a quest",
|
||||
usage = "<player> <quest>",
|
||||
permissions = {OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean start(String[] args) {
|
||||
String playername=args[0];
|
||||
String playername = args[0];
|
||||
int questid;
|
||||
try {
|
||||
questid = Integer.parseInt(args[1]);
|
||||
questid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendmessage("QuestID must be an integer");
|
||||
return false;
|
||||
@@ -47,37 +47,36 @@ public class CmdQuest extends ChMcLogger{
|
||||
return false;
|
||||
}
|
||||
Quest quest = QuestController.Instance.quests.get(questid);
|
||||
if (quest == null){
|
||||
if (quest == null) {
|
||||
sendmessage("Unknown QuestID");
|
||||
return false;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
if(playerdata.questData.activeQuests.containsKey(questid))
|
||||
continue;
|
||||
QuestData questdata = new QuestData(quest);
|
||||
playerdata.questData.activeQuests.put(questid, questdata);
|
||||
playerdata.save();
|
||||
if(playerdata.player != null){
|
||||
for (PlayerData playerdata : data) {
|
||||
if (playerdata.questData.activeQuests.containsKey(questid))
|
||||
continue;
|
||||
QuestData questdata = new QuestData(quest);
|
||||
playerdata.questData.activeQuests.put(questid, questdata);
|
||||
playerdata.save();
|
||||
if (playerdata.player != null) {
|
||||
AchievementPacket.sendAchievement((EntityPlayerMP) playerdata.player, false, "quest.newquest", quest.title);
|
||||
ChatAlertPacket.sendChatAlert((EntityPlayerMP) playerdata.player, "quest.newquest", ": ", quest.title);
|
||||
}
|
||||
}
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Finish a quest",
|
||||
usage = "<player> <quest>",
|
||||
permissions = {OpOnly.class, ParamCheck.class}
|
||||
desc = "Finish a quest",
|
||||
usage = "<player> <quest>",
|
||||
permissions = {OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean finish(String args[]){
|
||||
String playername=args[0];
|
||||
public Boolean finish(String args[]) {
|
||||
String playername = args[0];
|
||||
int questid;
|
||||
try {
|
||||
questid = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch (NumberFormatException ex) {
|
||||
questid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendmessage("QuestID must be an integer");
|
||||
return false;
|
||||
}
|
||||
@@ -88,28 +87,28 @@ public class CmdQuest extends ChMcLogger{
|
||||
}
|
||||
|
||||
Quest quest = QuestController.Instance.quests.get(questid);
|
||||
if (quest == null){
|
||||
if (quest == null) {
|
||||
sendmessage("Unknown QuestID");
|
||||
return false;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.questData.finishedQuests.put(questid, System.currentTimeMillis());
|
||||
playerdata.save();
|
||||
for (PlayerData playerdata : data) {
|
||||
playerdata.questData.finishedQuests.put(questid, System.currentTimeMillis());
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Stop a started quest",
|
||||
usage = "<player> <quest>",
|
||||
permissions = {OpOnly.class, ParamCheck.class}
|
||||
desc = "Stop a started quest",
|
||||
usage = "<player> <quest>",
|
||||
permissions = {OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean stop(String[] args) {
|
||||
String playername=args[0];
|
||||
String playername = args[0];
|
||||
int questid;
|
||||
try {
|
||||
questid = Integer.parseInt(args[1]);
|
||||
questid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendmessage("QuestID must be an integer");
|
||||
return false;
|
||||
@@ -120,28 +119,28 @@ public class CmdQuest extends ChMcLogger{
|
||||
return false;
|
||||
}
|
||||
Quest quest = QuestController.Instance.quests.get(questid);
|
||||
if (quest == null){
|
||||
if (quest == null) {
|
||||
sendmessage("Unknown QuestID");
|
||||
return false;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.questData.activeQuests.remove(questid);
|
||||
playerdata.save();
|
||||
for (PlayerData playerdata : data) {
|
||||
playerdata.questData.activeQuests.remove(questid);
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Removes a quest from finished and active quests",
|
||||
usage = "<player> <quest>",
|
||||
permissions = {OpOnly.class, ParamCheck.class}
|
||||
desc = "Removes a quest from finished and active quests",
|
||||
usage = "<player> <quest>",
|
||||
permissions = {OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean remove(String[] args) {
|
||||
String playername=args[0];
|
||||
String playername = args[0];
|
||||
int questid;
|
||||
try {
|
||||
questid = Integer.parseInt(args[1]);
|
||||
questid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendmessage("QuestID must be an integer");
|
||||
return false;
|
||||
@@ -152,26 +151,27 @@ public class CmdQuest extends ChMcLogger{
|
||||
return false;
|
||||
}
|
||||
Quest quest = QuestController.Instance.quests.get(questid);
|
||||
if (quest == null){
|
||||
if (quest == null) {
|
||||
sendmessage("Unknown QuestID");
|
||||
return false;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.questData.activeQuests.remove(questid);
|
||||
playerdata.questData.finishedQuests.remove(questid);
|
||||
playerdata.save();
|
||||
for (PlayerData playerdata : data) {
|
||||
playerdata.questData.activeQuests.remove(questid);
|
||||
playerdata.questData.finishedQuests.remove(questid);
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="reload quests from disk",
|
||||
permissions={OpOnly.class}
|
||||
desc = "reload quests from disk",
|
||||
permissions = {OpOnly.class}
|
||||
)
|
||||
public boolean reload(String args[]){
|
||||
new QuestController().load();
|
||||
public boolean reload(String args[]) {
|
||||
new QuestController().load();
|
||||
SyncController.syncAllQuests();
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ import foxz.commandhelper.permissions.OpOnly;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
|
||||
@Command(
|
||||
name = "script",
|
||||
desc = "Script operation"
|
||||
name = "script",
|
||||
desc = "Script operation"
|
||||
)
|
||||
public class CmdScript extends ChMcLogger {
|
||||
|
||||
@@ -17,14 +17,14 @@ public class CmdScript extends ChMcLogger {
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Reload scripts and saved data from disks script folder.",
|
||||
permissions={OpOnly.class}
|
||||
desc = "Reload scripts and saved data from disks script folder.",
|
||||
permissions = {OpOnly.class}
|
||||
)
|
||||
public Boolean reload(String args[]) {
|
||||
if(ScriptController.Instance.loadStoredData())
|
||||
sendmessage("Reload succesful");
|
||||
else
|
||||
sendmessage("Failed reloading stored data");
|
||||
if (ScriptController.Instance.loadStoredData())
|
||||
sendmessage("Reload succesful");
|
||||
else
|
||||
sendmessage("Failed reloading stored data");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -25,12 +25,12 @@ public class CommandNoppes extends CommandBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List addTabCompletionOptions(ICommandSender par1, String[] par2){
|
||||
public List addTabCompletionOptions(ICommandSender par1, String[] par2) {
|
||||
return noppes.addTabCompletion(par1, par2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel(){
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
@@ -51,12 +51,13 @@ public class ScriptedCommand extends CommandBase implements ICommand {
|
||||
public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_) {
|
||||
}
|
||||
|
||||
public int getRequiredPermissionLevel()
|
||||
{
|
||||
public int getRequiredPermissionLevel() {
|
||||
return this.permissionLevel;
|
||||
}
|
||||
|
||||
public int getPermissionLevel() { return this.getRequiredPermissionLevel(); }
|
||||
public int getPermissionLevel() {
|
||||
return this.getRequiredPermissionLevel();
|
||||
}
|
||||
|
||||
public List<?> getCommandAliases() {
|
||||
return this.aliases;
|
||||
|
||||
Reference in new issue
Block a user