mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 12:15:11 +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;
|
||||
|
||||
@@ -99,16 +99,17 @@ public abstract class AbstractCommandHelper extends CommandHelper {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List addTabCompletion(ICommandSender par1, String[] args) {
|
||||
public List addTabCompletion(ICommandSender par1, String[] args) {
|
||||
String[] np = currentHelper.usage.split(" ");
|
||||
if(np.length < args.length)
|
||||
return null;
|
||||
if (np.length < args.length)
|
||||
return null;
|
||||
String parameter = np[args.length - 1];
|
||||
if(parameter.equals("<player>"))
|
||||
if (parameter.equals("<player>"))
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames());
|
||||
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
public Method method;
|
||||
@@ -144,7 +145,7 @@ public abstract class AbstractCommandHelper extends CommandHelper {
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
|
||||
if ((cmd.equals("HELP") || args.length == 0) && doHelp(param, args, cmd)) {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
CommandHelper ch = commands.get(cmd);
|
||||
@@ -157,8 +158,7 @@ public abstract class AbstractCommandHelper extends CommandHelper {
|
||||
f.parentCmdHelper = this;
|
||||
f.rootCmdHelper = this.rootCmdHelper;
|
||||
return f.processCommand(param, args);
|
||||
}
|
||||
else if (ch instanceof MethodSubCmd) {
|
||||
} else if (ch instanceof MethodSubCmd) {
|
||||
MethodSubCmd m = (MethodSubCmd) ch;
|
||||
m.method.setAccessible(true);
|
||||
currentHelper = ch.commandHelper;
|
||||
@@ -174,72 +174,68 @@ public abstract class AbstractCommandHelper extends CommandHelper {
|
||||
Logger.getLogger(AbstractCommandHelper.class.getName()).log(Level.SEVERE, m.commandHelper.name, ex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
} else
|
||||
cmdError(cmd);
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean doHelp(ICommandSender param, String[] args, String cmd){
|
||||
boolean isHelp = cmd.equals("HELP");
|
||||
if(args.length > 0){
|
||||
cmd = args[0];
|
||||
}
|
||||
CommandHelper ch = commands.get(cmd.toUpperCase());
|
||||
if(ch != null){
|
||||
if(ch.commandHelper.hasEmptyCall && !isHelp)
|
||||
return false;
|
||||
if(ch instanceof AbstractCommandHelper){
|
||||
((AbstractCommandHelper)ch).pcParam = param;
|
||||
((AbstractCommandHelper)ch).allHelp();
|
||||
}
|
||||
else if(ch instanceof MethodSubCmd && ((MethodSubCmd)ch).commandHelper.usage.isEmpty())
|
||||
return false;
|
||||
else
|
||||
help(ch.commandHelper.name, ch.commandHelper.desc, ch.commandHelper.usage);
|
||||
}
|
||||
else
|
||||
allHelp();
|
||||
private boolean doHelp(ICommandSender param, String[] args, String cmd) {
|
||||
boolean isHelp = cmd.equals("HELP");
|
||||
if (args.length > 0) {
|
||||
cmd = args[0];
|
||||
}
|
||||
CommandHelper ch = commands.get(cmd.toUpperCase());
|
||||
if (ch != null) {
|
||||
if (ch.commandHelper.hasEmptyCall && !isHelp)
|
||||
return false;
|
||||
if (ch instanceof AbstractCommandHelper) {
|
||||
((AbstractCommandHelper) ch).pcParam = param;
|
||||
((AbstractCommandHelper) ch).allHelp();
|
||||
} else if (ch instanceof MethodSubCmd && ((MethodSubCmd) ch).commandHelper.usage.isEmpty())
|
||||
return false;
|
||||
else
|
||||
help(ch.commandHelper.name, ch.commandHelper.desc, ch.commandHelper.usage);
|
||||
} else
|
||||
allHelp();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List addTabCompletion(ICommandSender par1, String[] args) {
|
||||
if(args.length <= 1){
|
||||
List<String> list = new ArrayList<String>();
|
||||
for(String command : commands.keySet())
|
||||
list.add(command.toLowerCase());
|
||||
list.add("help");
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, list.toArray(new String[list.size()]));
|
||||
}
|
||||
public List addTabCompletion(ICommandSender par1, String[] args) {
|
||||
if (args.length <= 1) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (String command : commands.keySet())
|
||||
list.add(command.toLowerCase());
|
||||
list.add("help");
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, list.toArray(new String[list.size()]));
|
||||
}
|
||||
CommandHelper ch = commands.get(args[0].toUpperCase());
|
||||
if(ch == null)
|
||||
return null;
|
||||
if (ch == null)
|
||||
return null;
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
currentHelper = ch.commandHelper;
|
||||
return ch.addTabCompletion(par1, args);
|
||||
}
|
||||
return ch.addTabCompletion(par1, args);
|
||||
}
|
||||
|
||||
public List<PlayerData> getPlayersData(String username){
|
||||
ArrayList<PlayerData> list = new ArrayList<PlayerData>();
|
||||
EntityPlayerMP[] players = PlayerSelector.matchPlayers(pcParam, username);
|
||||
if(players == null || players.length == 0){
|
||||
PlayerData data = PlayerDataController.Instance.getDataFromUsername(username);
|
||||
if(data != null)
|
||||
list.add(data);
|
||||
}
|
||||
else{
|
||||
for(EntityPlayer player : players){
|
||||
list.add(PlayerDataController.Instance.getPlayerData(player));
|
||||
public List<PlayerData> getPlayersData(String username) {
|
||||
ArrayList<PlayerData> list = new ArrayList<PlayerData>();
|
||||
EntityPlayerMP[] players = PlayerSelector.matchPlayers(pcParam, username);
|
||||
if (players == null || players.length == 0) {
|
||||
PlayerData data = PlayerDataController.Instance.getDataFromUsername(username);
|
||||
if (data != null)
|
||||
list.add(data);
|
||||
} else {
|
||||
for (EntityPlayer player : players) {
|
||||
list.add(PlayerDataController.Instance.getPlayerData(player));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
return list;
|
||||
}
|
||||
|
||||
public <T> List<T> getNearbeEntityFromPlayer(Class<? extends T> cls, World world, int x, int y, int z, int range) {
|
||||
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1).expand(range, range, range);
|
||||
List<T> list = world.getEntitiesWithinAABB(cls, bb);
|
||||
return list;
|
||||
}
|
||||
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1).expand(range, range, range);
|
||||
List<T> list = world.getEntitiesWithinAABB(cls, bb);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -16,10 +16,10 @@ public class ChMcLogger extends AbstractCommandHelper {
|
||||
|
||||
@Override
|
||||
public void help(String cmd, String desc, String usa) {
|
||||
if(usa.isEmpty())
|
||||
sendmessage(String.format("%s = %s", cmd, desc));
|
||||
else
|
||||
sendmessage(String.format("%s %s = %s", cmd, usa, desc));
|
||||
if (usa.isEmpty())
|
||||
sendmessage(String.format("%s = %s", cmd, desc));
|
||||
else
|
||||
sendmessage(String.format("%s %s = %s", cmd, usa, desc));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,8 +13,10 @@ public abstract class CommandHelper {
|
||||
public String desc;
|
||||
public boolean hasEmptyCall;
|
||||
}
|
||||
|
||||
public Helper commandHelper = new Helper();
|
||||
public List addTabCompletion(ICommandSender par1, String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List addTabCompletion(ICommandSender par1, String[] args) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -13,9 +13,9 @@ public class OpOnly extends AbstractPermission {
|
||||
|
||||
@Override
|
||||
public boolean delegate(AbstractCommandHelper parent, String[] args) {
|
||||
if(!(parent.pcParam instanceof EntityPlayer))
|
||||
return true;
|
||||
return MinecraftServer.getServer().getConfigurationManager().func_152596_g(((EntityPlayer)parent.pcParam).getGameProfile());
|
||||
if (!(parent.pcParam instanceof EntityPlayer))
|
||||
return true;
|
||||
return MinecraftServer.getServer().getConfigurationManager().func_152596_g(((EntityPlayer) parent.pcParam).getGameProfile());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,9 +15,9 @@ public class ParamCheck extends AbstractPermission {
|
||||
public boolean delegate(AbstractCommandHelper parent, String[] args) {
|
||||
String[] np = parent.currentHelper.usage.split(" ");
|
||||
int countRequired = 0;
|
||||
for(String command : np){
|
||||
if(command.startsWith("<"))
|
||||
countRequired++;
|
||||
for (String command : np) {
|
||||
if (command.startsWith("<"))
|
||||
countRequired++;
|
||||
}
|
||||
if (args.length < countRequired) {
|
||||
err = np[args.length] + " missing";
|
||||
|
||||
@@ -9,7 +9,6 @@ import foxz.commandhelper.AbstractCommandHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author foxz
|
||||
*/
|
||||
public class PlayerOnly extends AbstractPermission {
|
||||
|
||||
@@ -25,13 +25,13 @@ public class Market {
|
||||
private static final CacheHashMap<String, MarketCachedObject> marketCache = new CacheHashMap<>(5 * 60 * 1000, 1 * 60 * 1000);
|
||||
|
||||
public static void save(RoleTrader r, String name) {
|
||||
if(name.isEmpty())
|
||||
if (name.isEmpty())
|
||||
return;
|
||||
|
||||
NBTTagCompound roleCompound = r.writeNBT(new NBTTagCompound());
|
||||
roleCompound.setString("SaveName", name);
|
||||
putMarketCache(name, roleCompound);
|
||||
if(r.recordHistory)
|
||||
if (r.recordHistory)
|
||||
return;
|
||||
|
||||
saveFile(roleCompound);
|
||||
@@ -43,12 +43,12 @@ public class Market {
|
||||
File file1 = getFile(name);
|
||||
customNPCThread.execute(() -> {
|
||||
try {
|
||||
if(ConfigMain.MarketDatFormat){
|
||||
if (ConfigMain.MarketDatFormat) {
|
||||
CompressedStreamTools.writeCompressed(compound, new FileOutputStream(file));
|
||||
} else {
|
||||
NBTJsonUtil.SaveFile(file, compound);
|
||||
}
|
||||
if(file1.exists()){
|
||||
if (file1.exists()) {
|
||||
file1.delete();
|
||||
}
|
||||
file.renameTo(file1);
|
||||
@@ -58,9 +58,9 @@ public class Market {
|
||||
});
|
||||
}
|
||||
|
||||
public static void getMarket(RoleTrader role, String name){
|
||||
public static void getMarket(RoleTrader role, String name) {
|
||||
NBTTagCompound data = getMarketCache(name);
|
||||
if(data != null){
|
||||
if (data != null) {
|
||||
role.readNBT(data);
|
||||
return;
|
||||
}
|
||||
@@ -84,56 +84,53 @@ public class Market {
|
||||
}
|
||||
|
||||
|
||||
static public void load(RoleTrader role, String name){
|
||||
if(role.npc.worldObj.isRemote)
|
||||
static public void load(RoleTrader role, String name) {
|
||||
if (role.npc.worldObj.isRemote)
|
||||
return;
|
||||
File file = getFile(name);
|
||||
if(!file.exists())
|
||||
if (!file.exists())
|
||||
return;
|
||||
|
||||
try {
|
||||
if(ConfigMain.MarketDatFormat){
|
||||
if (ConfigMain.MarketDatFormat) {
|
||||
NBTTagCompound compound = NBTJsonUtil.loadNBTData(file);
|
||||
role.readNBT(compound);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
role.readNBT(NBTJsonUtil.LoadFile(file));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
public static File getMarketDir(){
|
||||
try{
|
||||
File file = new File(CustomNpcs.getWorldSaveDirectory(),"markets");
|
||||
if(!file.exists())
|
||||
public static File getMarketDir() {
|
||||
try {
|
||||
File file = new File(CustomNpcs.getWorldSaveDirectory(), "markets");
|
||||
if (!file.exists())
|
||||
file.mkdir();
|
||||
return file;
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static File getNewMarketDir(){
|
||||
try{
|
||||
File file = new File(CustomNpcs.getWorldSaveDirectory(),"markets_new");
|
||||
if(file.exists()){
|
||||
public static File getNewMarketDir() {
|
||||
try {
|
||||
File file = new File(CustomNpcs.getWorldSaveDirectory(), "markets_new");
|
||||
if (file.exists()) {
|
||||
return null;
|
||||
}
|
||||
file.mkdir();
|
||||
return file;
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static File getFile(String name){
|
||||
private static File getFile(String name) {
|
||||
String filename = name.toLowerCase();
|
||||
if(ConfigMain.MarketDatFormat){
|
||||
if (ConfigMain.MarketDatFormat) {
|
||||
filename += ".dat";
|
||||
} else {
|
||||
filename += ".json";
|
||||
@@ -143,27 +140,26 @@ public class Market {
|
||||
}
|
||||
|
||||
static public void setMarket(EntityNPCInterface npc, String marketName) {
|
||||
if(marketName.isEmpty())
|
||||
if (marketName.isEmpty())
|
||||
return;
|
||||
if(!getFile(marketName).exists())
|
||||
if (!getFile(marketName).exists())
|
||||
Market.save((RoleTrader) npc.roleInterface, marketName);
|
||||
|
||||
Market.getMarket((RoleTrader) npc.roleInterface, marketName);
|
||||
}
|
||||
|
||||
|
||||
public static void convertMarketFiles(final EntityPlayerMP sender, final boolean type){
|
||||
public static void convertMarketFiles(final EntityPlayerMP sender, final boolean type) {
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
executor.execute(() -> {
|
||||
String fileType;
|
||||
if(type){
|
||||
if (type) {
|
||||
fileType = ".dat";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
fileType = ".json";
|
||||
}
|
||||
|
||||
if(sender != null){
|
||||
if (sender != null) {
|
||||
LogWriter.info("Market Conversion queued by " + sender.getCommandSenderName());
|
||||
sender.addChatMessage(new ChatComponentText("Market Conversion to " + fileType + " format"));
|
||||
}
|
||||
@@ -171,58 +167,58 @@ public class Market {
|
||||
File dir = getMarketDir();
|
||||
LogWriter.info("Converting Market to " + fileType + " format");
|
||||
File[] files = dir.listFiles(); // Get an array of all files in the directory
|
||||
if(files != null){
|
||||
if (files != null) {
|
||||
int length = files.length;
|
||||
if(length != 0){
|
||||
if(length > 100){
|
||||
if (length != 0) {
|
||||
if (length > 100) {
|
||||
LogWriter.info("Found " + length + " Market files... This may take a few minutes");
|
||||
}
|
||||
int tenPercent = (int) ((double) length * 0.1);
|
||||
int progress = 0;
|
||||
File saveDir = getNewMarketDir();
|
||||
if(saveDir == null){
|
||||
if(sender != null){
|
||||
if (saveDir == null) {
|
||||
if (sender != null) {
|
||||
sender.addChatMessage(new ChatComponentText("markets_new folder already exists please delete it or rename it"));
|
||||
}
|
||||
LogWriter.error("markets_new folder already exists please delete it or rename it");
|
||||
return;
|
||||
}
|
||||
// Load the files in parallel using a stream
|
||||
for(int i = 0; i < length; i++){
|
||||
for (int i = 0; i < length; i++) {
|
||||
File file = files[i];
|
||||
if(file.isDirectory() || (!file.getName().endsWith(".json") && !file.getName().endsWith(".dat")))
|
||||
if (file.isDirectory() || (!file.getName().endsWith(".json") && !file.getName().endsWith(".dat")))
|
||||
continue;
|
||||
try {
|
||||
String filename = "error";
|
||||
boolean valid = false;
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
if(type){
|
||||
if(file.getName().endsWith(".json")){
|
||||
if (type) {
|
||||
if (file.getName().endsWith(".json")) {
|
||||
compound = NBTJsonUtil.LoadFile(file);
|
||||
if(compound.hasKey("PlayerName")) {
|
||||
if (compound.hasKey("PlayerName")) {
|
||||
filename = file.getName().substring(0, file.getName().length() - 5);
|
||||
valid = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(file.getName().endsWith(".dat")){
|
||||
if (file.getName().endsWith(".dat")) {
|
||||
compound = NBTJsonUtil.loadNBTData(file);
|
||||
if(compound.hasKey("PlayerName")){
|
||||
if (compound.hasKey("PlayerName")) {
|
||||
filename = file.getName().substring(0, file.getName().length() - 4);
|
||||
valid = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(valid){
|
||||
if (valid) {
|
||||
try {
|
||||
File newFile = new File(saveDir, filename + "_new" + fileType);
|
||||
File oldFile = new File(saveDir, filename + fileType);
|
||||
if(type){
|
||||
if (type) {
|
||||
CompressedStreamTools.writeCompressed(compound, new FileOutputStream(newFile));
|
||||
} else {
|
||||
NBTJsonUtil.SaveFile(newFile, compound);
|
||||
}
|
||||
if(oldFile.exists()){
|
||||
if (oldFile.exists()) {
|
||||
oldFile.delete();
|
||||
}
|
||||
newFile.renameTo(oldFile);
|
||||
@@ -233,8 +229,8 @@ public class Market {
|
||||
} catch (Exception e) {
|
||||
LogWriter.error("Error loading: " + file.getAbsolutePath(), e);
|
||||
}
|
||||
if(tenPercent != 0 ){
|
||||
if(progress != 100){
|
||||
if (tenPercent != 0) {
|
||||
if (progress != 100) {
|
||||
if (i % tenPercent == 0) {
|
||||
progress += 10;
|
||||
LogWriter.info("Converting Market: Progress: " + progress + "%");
|
||||
@@ -244,7 +240,7 @@ public class Market {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(sender != null){
|
||||
if (sender != null) {
|
||||
sender.addChatMessage(new ChatComponentText("Market Conversion complete"));
|
||||
}
|
||||
LogWriter.info("Market Converted - Please rename the markets_new folder to markets and restart");
|
||||
|
||||
@@ -11,23 +11,23 @@ import java.util.List;
|
||||
|
||||
public class Utils {
|
||||
|
||||
static public <T> List<T> getNearbeEntityFromPlayer(Class<? extends T> cls,EntityPlayerMP player, int dis) {
|
||||
static public <T> List<T> getNearbeEntityFromPlayer(Class<? extends T> cls, EntityPlayerMP player, int dis) {
|
||||
AxisAlignedBB range = player.boundingBox.expand(dis, dis, dis);
|
||||
List<T> list = player.worldObj.getEntitiesWithinAABB(cls, range);
|
||||
return list;
|
||||
}
|
||||
|
||||
static public EntityPlayer getOnlinePlayer(String playername){
|
||||
static public EntityPlayer getOnlinePlayer(String playername) {
|
||||
return MinecraftServer.getServer().getConfigurationManager().func_152612_a(playername);
|
||||
}
|
||||
|
||||
static public World getWorld(String t){
|
||||
WorldServer[] ws=MinecraftServer.getServer().worldServers;
|
||||
for (WorldServer w:ws){
|
||||
if (w!=null){
|
||||
if ((w.provider.dimensionId + "").equalsIgnoreCase(t)){
|
||||
return w;
|
||||
}
|
||||
static public World getWorld(String t) {
|
||||
WorldServer[] ws = MinecraftServer.getServer().worldServers;
|
||||
for (WorldServer w : ws) {
|
||||
if (w != null) {
|
||||
if ((w.provider.dimensionId + "").equalsIgnoreCase(t)) {
|
||||
return w;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -3,9 +3,9 @@ package kamkeel.npcs;
|
||||
import kamkeel.npcs.controllers.AttributeController;
|
||||
import kamkeel.npcs.controllers.data.attribute.AttributeDefinition;
|
||||
import kamkeel.npcs.controllers.data.attribute.AttributeValueType;
|
||||
import kamkeel.npcs.controllers.data.attribute.requirement.RequirementCheckerRegistry;
|
||||
import kamkeel.npcs.controllers.data.attribute.requirement.types.QuestActiveRequirement;
|
||||
import kamkeel.npcs.controllers.data.attribute.requirement.types.QuestCompletedRequirement;
|
||||
import kamkeel.npcs.controllers.data.attribute.requirement.RequirementCheckerRegistry;
|
||||
|
||||
/**
|
||||
* ModAttributes registers the core attributes (both non–magic and magic–based).
|
||||
@@ -38,7 +38,7 @@ public class CustomAttributes {
|
||||
public static AttributeDefinition MAGIC_DEFENSE;
|
||||
public static AttributeDefinition MAGIC_RESISTANCE;
|
||||
|
||||
public CustomAttributes(){
|
||||
public CustomAttributes() {
|
||||
HEALTH = AttributeController.registerAttribute(HEALTH_KEY, "Health", 'c', AttributeValueType.FLAT, AttributeDefinition.AttributeSection.BASE);
|
||||
|
||||
MAIN_ATTACK = AttributeController.registerAttribute(MAIN_ATTACK_KEY, "Main Attack Damage", '4', AttributeValueType.FLAT, AttributeDefinition.AttributeSection.BASE);
|
||||
|
||||
@@ -9,12 +9,12 @@ public class AddonManager {
|
||||
// Manager class to easily disable mixin manipulated
|
||||
// addons for debugging and testing
|
||||
|
||||
public AddonManager(){
|
||||
public AddonManager() {
|
||||
Instance = this;
|
||||
load();
|
||||
}
|
||||
|
||||
public void load(){
|
||||
public void load() {
|
||||
// Gecko Addon Initialization
|
||||
new GeckoAddon();
|
||||
new GeckoAddonClient();
|
||||
|
||||
@@ -18,7 +18,7 @@ public class DBCAddon {
|
||||
* The Addon Mod will replace all blank functions within
|
||||
* this class to change the ongoing code.
|
||||
*/
|
||||
public DBCAddon(){
|
||||
public DBCAddon() {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
@@ -26,21 +26,29 @@ public class DBCAddon {
|
||||
return Loader.isModLoaded("npcdbc");
|
||||
}
|
||||
|
||||
public void dbcCopyData(EntityLivingBase copied, EntityLivingBase entity){}
|
||||
public void dbcCopyData(EntityLivingBase copied, EntityLivingBase entity) {
|
||||
}
|
||||
|
||||
// AI / STATS
|
||||
public boolean canDBCAttack(EntityNPCInterface npc, float attackStrength, Entity receiver){
|
||||
public boolean canDBCAttack(EntityNPCInterface npc, float attackStrength, Entity receiver) {
|
||||
return false;
|
||||
}
|
||||
public void doDBCDamage(EntityNPCInterface npc, float attackStrength, Entity receiver){}
|
||||
public boolean isKO(EntityNPCInterface npc, EntityPlayer player){
|
||||
|
||||
public void doDBCDamage(EntityNPCInterface npc, float attackStrength, Entity receiver) {
|
||||
}
|
||||
|
||||
public boolean isKO(EntityNPCInterface npc, EntityPlayer player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// PlayerData NBT
|
||||
public void writeToNBT(PlayerData playerData, NBTTagCompound nbtTagCompound){}
|
||||
public void readFromNBT(PlayerData playerData, NBTTagCompound nbtTagCompound){}
|
||||
public void writeToNBT(PlayerData playerData, NBTTagCompound nbtTagCompound) {
|
||||
}
|
||||
|
||||
public void readFromNBT(PlayerData playerData, NBTTagCompound nbtTagCompound) {
|
||||
}
|
||||
|
||||
// Client Sync
|
||||
public void syncPlayer(EntityPlayerMP playerMP){}
|
||||
public void syncPlayer(EntityPlayerMP playerMP) {
|
||||
}
|
||||
}
|
||||
@@ -11,10 +11,11 @@ public class GeckoAddon {
|
||||
* The Addon Mod will replace all blank functions within
|
||||
* this class to change the ongoing code.
|
||||
*/
|
||||
public GeckoAddon(){
|
||||
public GeckoAddon() {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public void geckoCopyData(EntityLivingBase copied, EntityLivingBase entity){}
|
||||
public void geckoCopyData(EntityLivingBase copied, EntityLivingBase entity) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,20 +17,29 @@ public class DBCClient {
|
||||
* The fewer classes modified by mixins the safer.
|
||||
* These are for mixins affecting only client-side classes.
|
||||
*/
|
||||
public DBCClient(){
|
||||
public DBCClient() {
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
// Stat Buttons
|
||||
public void showDBCStatButtons(GuiNpcStats stats, EntityLivingBase entity){}
|
||||
public void showDBCStatActionPerformed(GuiNpcStats stats, GuiNpcButton btn){}
|
||||
public void showDBCStatButtons(GuiNpcStats stats, EntityLivingBase entity) {
|
||||
}
|
||||
|
||||
public void showDBCStatActionPerformed(GuiNpcStats stats, GuiNpcButton btn) {
|
||||
}
|
||||
|
||||
|
||||
// Render Auras
|
||||
public void renderDBCAuras(EntityNPCInterface npcInterface){}
|
||||
public void renderDBCAuras(EntityNPCInterface npcInterface) {
|
||||
}
|
||||
|
||||
// Manage Custom Forms
|
||||
public GuiNPCInterface2 manageCustomForms(EntityNPCInterface npcInterface){ return null; }
|
||||
public GuiNPCInterface2 manageCustomForms(EntityNPCInterface npcInterface) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Manage Custom Forms
|
||||
public GuiNPCInterface2 manageCustomAuras(EntityNPCInterface npcInterface){ return null; }
|
||||
public GuiNPCInterface2 manageCustomAuras(EntityNPCInterface npcInterface) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -19,19 +19,29 @@ public class GeckoAddonClient {
|
||||
* The fewer classes modified by mixins the safer.
|
||||
* These are for mixins affecting only client-side classes.
|
||||
*/
|
||||
public GeckoAddonClient(){
|
||||
public GeckoAddonClient() {
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
// Creation Screen Mixins
|
||||
public void showGeckoButtons(GuiCreationScreen creationScreen, EntityLivingBase entity){}
|
||||
public void geckoGuiCreationScreenActionPerformed(GuiCreationScreen creationScreen, GuiNpcButton btn){}
|
||||
public void showGeckoButtons(GuiCreationScreen creationScreen, EntityLivingBase entity) {
|
||||
}
|
||||
|
||||
public void geckoGuiCreationScreenActionPerformed(GuiCreationScreen creationScreen, GuiNpcButton btn) {
|
||||
}
|
||||
|
||||
// Npc Display Mixins
|
||||
public void geckoNpcDisplayInitGui(GuiNPCInterface2 guiNPCInterface){}
|
||||
public void geckoNpcDisplayActionPerformed(GuiNPCInterface2 guiNPCInterface, GuiNpcButton btn){}
|
||||
public void geckoNpcDisplayInitGui(GuiNPCInterface2 guiNPCInterface) {
|
||||
}
|
||||
|
||||
public void geckoNpcDisplayActionPerformed(GuiNPCInterface2 guiNPCInterface, GuiNpcButton btn) {
|
||||
}
|
||||
|
||||
// Render Npc Mixins
|
||||
public boolean isGeckoModel(ModelBase mainModel){ return false;}
|
||||
public void geckoRenderModel(ModelMPM mainModel, EntityNPCInterface npc, float rotationYaw, float renderPartialTicks) {}
|
||||
public boolean isGeckoModel(ModelBase mainModel) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void geckoRenderModel(ModelMPM mainModel, EntityNPCInterface npc, float rotationYaw, float renderPartialTicks) {
|
||||
}
|
||||
}
|
||||
@@ -14,22 +14,22 @@ import static kamkeel.npcs.util.ColorUtil.sendResult;
|
||||
|
||||
public class AnimationCommand extends CommandKamkeelBase {
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "animation";
|
||||
}
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "animation";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Animation operations";
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Animation operations";
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "set an animation to a player",
|
||||
usage = "<player> <num>"
|
||||
desc = "set an animation to a player",
|
||||
usage = "<player> <num>"
|
||||
)
|
||||
public void set(ICommandSender sender, String args[]) throws CommandException{
|
||||
String playername=args[0];
|
||||
public void set(ICommandSender sender, String args[]) throws CommandException {
|
||||
String playername = args[0];
|
||||
int animationId;
|
||||
try {
|
||||
animationId = Integer.parseInt(args[1]);
|
||||
@@ -44,12 +44,12 @@ public class AnimationCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
IAnimation animation = AnimationController.getInstance().get(animationId);
|
||||
if(animation == null){
|
||||
if (animation == null) {
|
||||
sendError(sender, "No Animation ID found: " + animationId);
|
||||
return;
|
||||
}
|
||||
|
||||
for(PlayerData playerdata : data){
|
||||
for (PlayerData playerdata : data) {
|
||||
playerdata.animationData.setEnabled(false);
|
||||
playerdata.animationData.setAnimation(animation);
|
||||
playerdata.animationData.updateClient();
|
||||
@@ -60,18 +60,18 @@ public class AnimationCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "clear an animation from a player",
|
||||
usage = "<player>"
|
||||
desc = "clear an animation from a player",
|
||||
usage = "<player>"
|
||||
)
|
||||
public void clear(ICommandSender sender, String args[]) throws CommandException{
|
||||
String playername=args[0];
|
||||
public void clear(ICommandSender sender, String args[]) throws CommandException {
|
||||
String playername = args[0];
|
||||
List<PlayerData> data = PlayerDataController.Instance.getPlayersData(sender, playername);
|
||||
if (data.isEmpty()) {
|
||||
sendError(sender, "Unknown player: " + playername);
|
||||
return;
|
||||
}
|
||||
|
||||
for(PlayerData playerdata : data){
|
||||
for (PlayerData playerdata : data) {
|
||||
playerdata.animationData.setEnabled(false);
|
||||
playerdata.animationData.setAnimation(null);
|
||||
playerdata.animationData.updateClient();
|
||||
@@ -82,19 +82,19 @@ public class AnimationCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "enable an animation on a player",
|
||||
usage = "<player>"
|
||||
desc = "enable an animation on a player",
|
||||
usage = "<player>"
|
||||
)
|
||||
public void enable(ICommandSender sender, String args[]) throws CommandException{
|
||||
String playername=args[0];
|
||||
public void enable(ICommandSender sender, String args[]) throws CommandException {
|
||||
String playername = args[0];
|
||||
List<PlayerData> data = PlayerDataController.Instance.getPlayersData(sender, playername);
|
||||
if (data.isEmpty()) {
|
||||
sendError(sender, "Unknown player: " + playername);
|
||||
return;
|
||||
}
|
||||
|
||||
for(PlayerData playerdata : data){
|
||||
if(playerdata.animationData.getAnimation() == null){
|
||||
for (PlayerData playerdata : data) {
|
||||
if (playerdata.animationData.getAnimation() == null) {
|
||||
sendError(sender, String.format("Player '\u00A7b%s\u00A74' does not have an animation set", playerdata.playername));
|
||||
return;
|
||||
}
|
||||
@@ -108,19 +108,19 @@ public class AnimationCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "disable an animation on a player",
|
||||
usage = "<player>"
|
||||
desc = "disable an animation on a player",
|
||||
usage = "<player>"
|
||||
)
|
||||
public void disable(ICommandSender sender, String args[]) throws CommandException{
|
||||
String playername=args[0];
|
||||
public void disable(ICommandSender sender, String args[]) throws CommandException {
|
||||
String playername = args[0];
|
||||
List<PlayerData> data = PlayerDataController.Instance.getPlayersData(sender, playername);
|
||||
if (data.isEmpty()) {
|
||||
sendError(sender, "Unknown player: " + playername);
|
||||
return;
|
||||
}
|
||||
|
||||
for(PlayerData playerdata : data){
|
||||
if(playerdata.animationData.getAnimation() == null){
|
||||
for (PlayerData playerdata : data) {
|
||||
if (playerdata.animationData.getAnimation() == null) {
|
||||
sendError(sender, String.format("Player '\u00A7b%s\u00A74' does not have an animation set", playerdata.playername));
|
||||
return;
|
||||
}
|
||||
@@ -134,7 +134,7 @@ public class AnimationCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "reload animations"
|
||||
desc = "reload animations"
|
||||
)
|
||||
public void reload(ICommandSender sender, String args[]) {
|
||||
AnimationController.Instance.load();
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
package kamkeel.npcs.command;
|
||||
|
||||
import kamkeel.npcs.controllers.AttributeController;
|
||||
import kamkeel.npcs.controllers.data.attribute.AttributeDefinition;
|
||||
import kamkeel.npcs.controllers.data.attribute.AttributeValueType;
|
||||
import kamkeel.npcs.util.AttributeItemUtil;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import noppes.npcs.controllers.MagicController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import kamkeel.npcs.controllers.AttributeController;
|
||||
import kamkeel.npcs.controllers.data.attribute.AttributeDefinition;
|
||||
import kamkeel.npcs.controllers.data.attribute.AttributeValueType;
|
||||
import kamkeel.npcs.util.AttributeItemUtil;
|
||||
import noppes.npcs.controllers.MagicController;
|
||||
|
||||
import static kamkeel.npcs.util.ColorUtil.sendError;
|
||||
import static kamkeel.npcs.util.ColorUtil.sendResult;
|
||||
|
||||
@@ -38,7 +38,7 @@ public class AttributeCommand extends CommandKamkeelBase {
|
||||
public void list(ICommandSender sender, String[] args) throws CommandException {
|
||||
// Get all registered attributes.
|
||||
List<AttributeDefinition> defs = new ArrayList<AttributeDefinition>(AttributeController.getAllAttributes());
|
||||
if(defs.isEmpty()){
|
||||
if (defs.isEmpty()) {
|
||||
sendError(sender, "No attributes found.");
|
||||
return;
|
||||
}
|
||||
@@ -52,18 +52,18 @@ public class AttributeCommand extends CommandKamkeelBase {
|
||||
|
||||
// Determine which page to show.
|
||||
int page = 1;
|
||||
if(args.length > 0) {
|
||||
if (args.length > 0) {
|
||||
try {
|
||||
page = Integer.parseInt(args[0]);
|
||||
} catch(NumberFormatException e) {
|
||||
} catch (NumberFormatException e) {
|
||||
// If parsing fails, default to page 1.
|
||||
}
|
||||
}
|
||||
int perPage = 10;
|
||||
int total = defs.size();
|
||||
int totalPages = (int)Math.ceil(total / (double) perPage);
|
||||
if(page < 1) page = 1;
|
||||
if(page > totalPages) page = totalPages;
|
||||
int totalPages = (int) Math.ceil(total / (double) perPage);
|
||||
if (page < 1) page = 1;
|
||||
if (page > totalPages) page = totalPages;
|
||||
int startIndex = (page - 1) * perPage;
|
||||
int endIndex = Math.min(startIndex + perPage, total);
|
||||
|
||||
@@ -85,28 +85,28 @@ public class AttributeCommand extends CommandKamkeelBase {
|
||||
desc = "Applies an attribute to your held item. For magic attributes, provide a magicID."
|
||||
)
|
||||
public void apply(ICommandSender sender, String[] args) throws CommandException {
|
||||
if(!(sender instanceof EntityPlayer)){
|
||||
if (!(sender instanceof EntityPlayer)) {
|
||||
sendError(sender, "Only players can use this command.");
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer player = (EntityPlayer)sender;
|
||||
EntityPlayer player = (EntityPlayer) sender;
|
||||
ItemStack held = player.getHeldItem();
|
||||
if(held == null){
|
||||
if (held == null) {
|
||||
sendError(sender, "You are not holding an item.");
|
||||
return;
|
||||
}
|
||||
|
||||
String attrKey = args[0];
|
||||
AttributeDefinition def = AttributeController.getAttribute(attrKey);
|
||||
if(def == null){
|
||||
if (def == null) {
|
||||
sendError(sender, "Unknown attribute: " + attrKey);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if this is a magic attribute.
|
||||
if(def.getValueType() == AttributeValueType.MAGIC) {
|
||||
if(args.length < 3){
|
||||
if (def.getValueType() == AttributeValueType.MAGIC) {
|
||||
if (args.length < 3) {
|
||||
sendError(sender, "Usage for magic attribute: apply <attribute> <value> <magicID>");
|
||||
return;
|
||||
}
|
||||
@@ -115,12 +115,12 @@ public class AttributeCommand extends CommandKamkeelBase {
|
||||
try {
|
||||
value = Float.parseFloat(args[1]);
|
||||
magicId = Integer.parseInt(args[2]);
|
||||
} catch(NumberFormatException e) {
|
||||
} catch (NumberFormatException e) {
|
||||
sendError(sender, "Invalid number format for magicID or value.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(MagicController.getInstance().getMagic(magicId) == null){
|
||||
if (MagicController.getInstance().getMagic(magicId) == null) {
|
||||
sendError(sender, "No Magic Found for Magic ID %d", magicId);
|
||||
return;
|
||||
}
|
||||
@@ -128,14 +128,14 @@ public class AttributeCommand extends CommandKamkeelBase {
|
||||
AttributeItemUtil.writeMagicAttribute(held, attrKey, magicId, value);
|
||||
sendResult(sender, "Applied magic attribute " + attrKey + " with magicID " + magicId + " and value " + value + " to held item.");
|
||||
} else {
|
||||
if(args.length < 2){
|
||||
if (args.length < 2) {
|
||||
sendError(sender, "Usage: <attribute> <value>");
|
||||
return;
|
||||
}
|
||||
float value;
|
||||
try {
|
||||
value = Float.parseFloat(args[1]);
|
||||
} catch(NumberFormatException e) {
|
||||
} catch (NumberFormatException e) {
|
||||
sendError(sender, "Invalid number format for value.");
|
||||
return;
|
||||
}
|
||||
@@ -150,38 +150,38 @@ public class AttributeCommand extends CommandKamkeelBase {
|
||||
desc = "Removes an attribute from your held item. For magic attributes, provide a magicID."
|
||||
)
|
||||
public void remove(ICommandSender sender, String[] args) throws CommandException {
|
||||
if(!(sender instanceof EntityPlayer)){
|
||||
if (!(sender instanceof EntityPlayer)) {
|
||||
sendError(sender, "Only players can use this command.");
|
||||
return;
|
||||
}
|
||||
EntityPlayer player = (EntityPlayer)sender;
|
||||
EntityPlayer player = (EntityPlayer) sender;
|
||||
ItemStack held = player.getHeldItem();
|
||||
if(held == null){
|
||||
if (held == null) {
|
||||
sendError(sender, "You are not holding an item.");
|
||||
return;
|
||||
}
|
||||
|
||||
String attrKey = args[0];
|
||||
AttributeDefinition def = AttributeController.getAttribute(attrKey);
|
||||
if(def == null){
|
||||
if (def == null) {
|
||||
sendError(sender, "Unknown attribute: " + attrKey);
|
||||
return;
|
||||
}
|
||||
|
||||
if(def.getValueType() == AttributeValueType.MAGIC) {
|
||||
if(args.length < 2){
|
||||
if (def.getValueType() == AttributeValueType.MAGIC) {
|
||||
if (args.length < 2) {
|
||||
sendError(sender, "Usage for magic attribute: remove <attribute> <magicID>");
|
||||
return;
|
||||
}
|
||||
int magicId;
|
||||
try {
|
||||
magicId = Integer.parseInt(args[1]);
|
||||
} catch(NumberFormatException e) {
|
||||
} catch (NumberFormatException e) {
|
||||
sendError(sender, "Invalid magicID format.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(MagicController.getInstance().getMagic(magicId) == null){
|
||||
if (MagicController.getInstance().getMagic(magicId) == null) {
|
||||
sendError(sender, "No Magic Found for Magic ID %d", magicId);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -21,31 +21,30 @@ import static kamkeel.npcs.util.ColorUtil.*;
|
||||
|
||||
public class CloneCommand extends CommandKamkeelBase {
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "clone";
|
||||
}
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "clone";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Clone operation (server side)";
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Clone operation (server side)";
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Add NPC(s) to clone storage",
|
||||
usage = "<npc> <tab> [clonedname]",
|
||||
permission = 4
|
||||
desc = "Add NPC(s) to clone storage",
|
||||
usage = "<npc> <tab> [clonedname]",
|
||||
permission = 4
|
||||
)
|
||||
public void add(ICommandSender sender, String[] args) {
|
||||
int tab = 0;
|
||||
try{
|
||||
tab = Integer.parseInt(args[1]);
|
||||
if(tab < 0 || tab > 15){
|
||||
try {
|
||||
tab = Integer.parseInt(args[1]);
|
||||
if (tab < 0 || tab > 15) {
|
||||
sendError(sender, "Tab must be within 1-15");
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, String.format("Tab is not a number: %s", args[1]));
|
||||
return;
|
||||
}
|
||||
@@ -60,31 +59,30 @@ public class CloneCommand extends CommandKamkeelBase {
|
||||
if (args.length > 2) {
|
||||
name = args[2];
|
||||
}
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
if(!npc.writeToNBTOptional(compound))
|
||||
return;
|
||||
ServerCloneController.Instance.addClone(compound, name, tab);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
if (!npc.writeToNBTOptional(compound))
|
||||
return;
|
||||
ServerCloneController.Instance.addClone(compound, name, tab);
|
||||
sendResult(sender, String.format("Added NPC \u00A7e%s\u00A77 to Tab \u00A7b%d\u00A77", name, tab));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "List NPC from clone storage",
|
||||
usage = "<tab>",
|
||||
permission = 2
|
||||
desc = "List NPC from clone storage",
|
||||
usage = "<tab>",
|
||||
permission = 2
|
||||
)
|
||||
public void list(ICommandSender sender, String[] args) {
|
||||
sendMessage(sender, "--- Stored NPCs --- (server side)");
|
||||
int tab = 0;
|
||||
try{
|
||||
try {
|
||||
tab = Integer.parseInt(args[1]);
|
||||
if(tab < 0 || tab > 15){
|
||||
if (tab < 0 || tab > 15) {
|
||||
sendError(sender, "Tab must be within 1-15");
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, String.format("Tab is not a number: %s", args[1]));
|
||||
return;
|
||||
}
|
||||
@@ -96,32 +94,31 @@ public class CloneCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Remove NPC from clone storage",
|
||||
usage = "<name> <tab>",
|
||||
permission = 4
|
||||
desc = "Remove NPC from clone storage",
|
||||
usage = "<name> <tab>",
|
||||
permission = 4
|
||||
)
|
||||
public void del(ICommandSender sender, String[] args) throws CommandException {
|
||||
String nametodel = args[0];
|
||||
int tab = 0;
|
||||
try{
|
||||
try {
|
||||
tab = Integer.parseInt(args[1]);
|
||||
if(tab < 0 || tab > 15){
|
||||
if (tab < 0 || tab > 15) {
|
||||
sendError(sender, String.format("Tab must be within 1-15"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, String.format("Tab is not a number: %s", args[1]));
|
||||
return;
|
||||
}
|
||||
|
||||
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)) {
|
||||
sendError(sender, String.format("NPC '%s' was not found", nametodel));
|
||||
@@ -131,28 +128,27 @@ public class CloneCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Spawn cloned NPC",
|
||||
usage = "<name> <tab> [[world:]x,y,z]] [newname]",
|
||||
permission = 2
|
||||
desc = "Spawn cloned NPC",
|
||||
usage = "<name> <tab> [[world:]x,y,z]] [newname]",
|
||||
permission = 2
|
||||
)
|
||||
public void spawn(ICommandSender sender, String[] args) throws CommandException {
|
||||
String name = args[0].replaceAll("%", " "); // if name of npc separed by space, user must use % in place of space
|
||||
int tab = 0;
|
||||
try{
|
||||
try {
|
||||
tab = Integer.parseInt(args[1]);
|
||||
if(tab < 0 || tab > 15){
|
||||
if (tab < 0 || tab > 15) {
|
||||
sendError(sender, String.format("Tab must be within 1-15"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, String.format("Tab is not a number: %s", args[1]));
|
||||
return;
|
||||
}
|
||||
|
||||
String newname=null;
|
||||
String newname = null;
|
||||
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(sender, name, tab);
|
||||
if(compound == null){
|
||||
if (compound == null) {
|
||||
sendError(sender, "Unknown npc");
|
||||
return;
|
||||
}
|
||||
@@ -161,34 +157,34 @@ public class CloneCommand extends CommandKamkeelBase {
|
||||
double posY = sender.getPlayerCoordinates().posY;
|
||||
double posZ = sender.getPlayerCoordinates().posZ;
|
||||
|
||||
if(args.length > 2){
|
||||
if (args.length > 2) {
|
||||
String location = args[2];
|
||||
String[] par;
|
||||
if (location.contains(":")){
|
||||
if (location.contains(":")) {
|
||||
par = location.split(":");
|
||||
location = par[1];
|
||||
world = Utils.getWorld(par[0]);
|
||||
if (world == null){
|
||||
if (world == null) {
|
||||
sendError(sender, String.format("'%s' is an unknown world", par[0]));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (location.contains(",")){
|
||||
if (location.contains(",")) {
|
||||
par = location.split(",");
|
||||
if (par.length != 3){
|
||||
if (par.length != 3) {
|
||||
sendError(sender, "Location need be x,y,z");
|
||||
return;
|
||||
}
|
||||
try{
|
||||
try {
|
||||
posX = func_110666_a(sender, posX, par[0]);
|
||||
posY = func_110665_a(sender, posY, par[1].trim(), 0, 0);
|
||||
posZ = func_110666_a(sender, posZ, par[2]);
|
||||
} catch(NumberFormatException ex){
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, "Location should be in numbers");
|
||||
return;
|
||||
}
|
||||
if (args.length > 3){
|
||||
if (args.length > 3) {
|
||||
newname = args[3];
|
||||
}
|
||||
} else {
|
||||
@@ -196,56 +192,54 @@ public class CloneCommand extends CommandKamkeelBase {
|
||||
}
|
||||
}
|
||||
|
||||
if (posX == 0 && posY == 0 && posZ == 0){//incase it was called from the console and not pos was given
|
||||
if (posX == 0 && posY == 0 && posZ == 0) {//incase it was called from the console and not pos was given
|
||||
sendError(sender, "Location needed");
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = EntityList.createEntityFromNBT(compound, world);
|
||||
entity.setPosition(posX + 0.5, posY + 1, posZ + 0.5);
|
||||
if(entity instanceof EntityNPCInterface){
|
||||
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())
|
||||
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);
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Spawn cloned NPC",
|
||||
usage = "<name> <tab> [[world:]x,y,z]] [newname]",
|
||||
permission = 2
|
||||
desc = "Spawn cloned NPC",
|
||||
usage = "<name> <tab> [[world:]x,y,z]] [newname]",
|
||||
permission = 2
|
||||
)
|
||||
public void grid(ICommandSender sender, String[] args) throws CommandException {
|
||||
String name = args[0].replaceAll("%", " "); // if name of npc separed by space, user must use % in place of space
|
||||
int tab = 0;
|
||||
try{
|
||||
try {
|
||||
tab = Integer.parseInt(args[1]);
|
||||
if(tab < 0 || tab > 15){
|
||||
if (tab < 0 || tab > 15) {
|
||||
sendError(sender, String.format("Tab must be within 1-15"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, String.format("Tab is not a number: %s", args[1]));
|
||||
return;
|
||||
}
|
||||
|
||||
int width, height;
|
||||
try{
|
||||
try {
|
||||
width = Integer.parseInt(args[2]);
|
||||
height = Integer.parseInt(args[3]);
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, "length or width was not a number");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String newname=null;
|
||||
String newname = null;
|
||||
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(sender, name, tab);
|
||||
if(compound == null){
|
||||
if (compound == null) {
|
||||
sendError(sender, "Unknown npc");
|
||||
return;
|
||||
}
|
||||
@@ -254,33 +248,33 @@ public class CloneCommand extends CommandKamkeelBase {
|
||||
double posY = sender.getPlayerCoordinates().posY;
|
||||
double posZ = sender.getPlayerCoordinates().posZ;
|
||||
|
||||
if(args.length > 4){
|
||||
if (args.length > 4) {
|
||||
String location = args[4];
|
||||
String[] par;
|
||||
if (location.contains(":")){
|
||||
if (location.contains(":")) {
|
||||
par = location.split(":");
|
||||
location = par[1];
|
||||
world = Utils.getWorld(par[0]);
|
||||
if (world == null){
|
||||
if (world == null) {
|
||||
sendError(sender, String.format("'%s' is an unknown world", par[0]));
|
||||
}
|
||||
}
|
||||
|
||||
if (location.contains(",")){
|
||||
if (location.contains(",")) {
|
||||
par = location.split(",");
|
||||
if (par.length != 3){
|
||||
if (par.length != 3) {
|
||||
sendError(sender, "Location need be x,y,z");
|
||||
return;
|
||||
}
|
||||
try{
|
||||
try {
|
||||
posX = func_110666_a(sender, posX, par[0]);
|
||||
posY = func_110665_a(sender, posY, par[1].trim(), 0, 0);
|
||||
posZ = func_110666_a(sender, posZ, par[2]);
|
||||
} catch(NumberFormatException ex){
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, "Location should be in numbers");
|
||||
return;
|
||||
}
|
||||
if (args.length > 5){
|
||||
if (args.length > 5) {
|
||||
newname = args[5];
|
||||
}
|
||||
} else {
|
||||
@@ -288,31 +282,31 @@ public class CloneCommand extends CommandKamkeelBase {
|
||||
}
|
||||
}
|
||||
|
||||
if (posX == 0 && posY == 0 && posZ == 0){//incase it was called from the console and not pos was given
|
||||
if (posX == 0 && posY == 0 && posZ == 0) {//incase it was called from the console and not pos was given
|
||||
sendError(sender, "Location needed");
|
||||
return;
|
||||
}
|
||||
|
||||
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++){
|
||||
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)){
|
||||
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){
|
||||
if (entity instanceof EntityNPCInterface) {
|
||||
EntityNPCInterface npc = (EntityNPCInterface) entity;
|
||||
npc.ais.startPos = new int[]{xx, yy, zz};
|
||||
if(newname != null && !newname.isEmpty())
|
||||
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);
|
||||
@@ -321,13 +315,13 @@ public class CloneCommand extends CommandKamkeelBase {
|
||||
return;
|
||||
}
|
||||
|
||||
public World getWorld(String t){
|
||||
WorldServer[] ws=MinecraftServer.getServer().worldServers;
|
||||
for (WorldServer w:ws){
|
||||
if (w!=null){
|
||||
if ((w.provider.dimensionId + "").equalsIgnoreCase(t)){
|
||||
return w;
|
||||
}
|
||||
public World getWorld(String t) {
|
||||
WorldServer[] ws = MinecraftServer.getServer().worldServers;
|
||||
for (WorldServer w : ws) {
|
||||
if (w != null) {
|
||||
if ((w.provider.dimensionId + "").equalsIgnoreCase(t)) {
|
||||
return w;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package kamkeel.npcs.command;
|
||||
|
||||
import kamkeel.npcs.controllers.AttributeController;
|
||||
import kamkeel.npcs.controllers.data.attribute.AttributeDefinition;
|
||||
import kamkeel.npcs.controllers.data.attribute.requirement.RequirementCheckerRegistry;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
@@ -7,8 +9,6 @@ import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
import kamkeel.npcs.controllers.AttributeController;
|
||||
import kamkeel.npcs.controllers.data.attribute.AttributeDefinition;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
|
||||
@@ -17,13 +17,13 @@ import java.util.*;
|
||||
|
||||
import static kamkeel.npcs.command.EffectCommand.getSortedEffectNames;
|
||||
|
||||
public class CommandKamkeel extends CommandBase{
|
||||
public class CommandKamkeel extends CommandBase {
|
||||
|
||||
public Map<String, CommandKamkeelBase> map = new HashMap<String, CommandKamkeelBase>();
|
||||
public HelpCommand help = new HelpCommand(this);
|
||||
public String[] alias = {"kam"};
|
||||
|
||||
public CommandKamkeel(){
|
||||
public CommandKamkeel() {
|
||||
registerCommand(help);
|
||||
registerCommand(new ScriptCommand());
|
||||
registerCommand(new SlayCommand());
|
||||
@@ -39,13 +39,13 @@ public class CommandKamkeel extends CommandBase{
|
||||
registerCommand(new OverlayCommand());
|
||||
registerCommand(new CommandCommand());
|
||||
registerCommand(new EffectCommand());
|
||||
if(ConfigMain.AttributesEnabled)
|
||||
if (ConfigMain.AttributesEnabled)
|
||||
registerCommand(new AttributeCommand());
|
||||
}
|
||||
|
||||
public void registerCommand(CommandKamkeelBase command){
|
||||
public void registerCommand(CommandKamkeelBase command) {
|
||||
String name = command.getCommandName().toLowerCase();
|
||||
if(map.containsKey(name))
|
||||
if (map.containsKey(name))
|
||||
throw new CustomNPCsException("Already a subcommand with the name: " + name);
|
||||
map.put(name, command);
|
||||
}
|
||||
@@ -56,8 +56,7 @@ public class CommandKamkeel extends CommandBase{
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getCommandAliases()
|
||||
{
|
||||
public List getCommandAliases() {
|
||||
return Arrays.asList(alias);
|
||||
}
|
||||
|
||||
@@ -68,25 +67,25 @@ public class CommandKamkeel extends CommandBase{
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
if(args.length == 0){
|
||||
if (args.length == 0) {
|
||||
help.processCommand(sender, args);
|
||||
return;
|
||||
}
|
||||
|
||||
CommandKamkeelBase command = getCommand(args);
|
||||
if(command == null)
|
||||
if (command == null)
|
||||
throw new CommandException("Unknown command " + args[0]);
|
||||
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
if(command.subcommands.isEmpty() || !command.runSubCommands()){
|
||||
if(!canSendCommand(sender, command))
|
||||
if (command.subcommands.isEmpty() || !command.runSubCommands()) {
|
||||
if (!canSendCommand(sender, command))
|
||||
throw new CommandException("You are not allowed to use this command: " + command);
|
||||
command.canRun(sender, command.getUsage(), args);
|
||||
command.processCommand(sender, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if(args.length == 0){
|
||||
if (args.length == 0) {
|
||||
help.processCommand(sender, new String[]{command.getCommandName()});
|
||||
return;
|
||||
}
|
||||
@@ -95,28 +94,27 @@ public class CommandKamkeel extends CommandBase{
|
||||
}
|
||||
|
||||
@Override
|
||||
public List addTabCompletionOptions(ICommandSender sender, String[] args){
|
||||
if(args.length == 1)
|
||||
public List addTabCompletionOptions(ICommandSender sender, String[] args) {
|
||||
if (args.length == 1)
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, map.keySet().toArray(new String[map.size()]));
|
||||
CommandKamkeelBase command = getCommand(args);
|
||||
if(command == null)
|
||||
if (command == null)
|
||||
return null;
|
||||
if(args.length == 2 && command.runSubCommands())
|
||||
if (args.length == 2 && command.runSubCommands())
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, command.subcommands.keySet().toArray(new String[command.subcommands.keySet().size()]));
|
||||
String[] useArgs = command.getUsage().split(" ");
|
||||
if(command.runSubCommands()) {
|
||||
if (command.runSubCommands()) {
|
||||
Method m = command.subcommands.get(args[1].toLowerCase());
|
||||
if(m != null) {
|
||||
if (m != null) {
|
||||
useArgs = m.getAnnotation(CommandKamkeelBase.SubCommand.class).usage().split(" ");
|
||||
}
|
||||
}
|
||||
if(args.length <= useArgs.length + 2) {
|
||||
if(args.length - 3 >= 0){
|
||||
if (args.length <= useArgs.length + 2) {
|
||||
if (args.length - 3 >= 0) {
|
||||
String usage = useArgs[args.length - 3];
|
||||
if(usage.equals("<player>") || usage.equals("[player]")) {
|
||||
if (usage.equals("<player>") || usage.equals("[player]")) {
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames());
|
||||
}
|
||||
else if(usage.equals("<attribute>")) {
|
||||
} else if (usage.equals("<attribute>")) {
|
||||
List<String> keys = new ArrayList<>();
|
||||
for (AttributeDefinition def : AttributeController.getAllAttributes()) {
|
||||
keys.add(def.getKey());
|
||||
@@ -125,7 +123,7 @@ public class CommandKamkeel extends CommandBase{
|
||||
} else if (usage.equals("<requirement>")) {
|
||||
List<String> keys = new ArrayList<>(RequirementCheckerRegistry.getAllKeys());
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, keys.toArray(new String[keys.size()]));
|
||||
} else if(usage.equals("<effectName>")){
|
||||
} else if (usage.equals("<effectName>")) {
|
||||
List<String> keys = getSortedEffectNames();
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, keys.toArray(new String[keys.size()]));
|
||||
}
|
||||
@@ -134,35 +132,35 @@ public class CommandKamkeel extends CommandBase{
|
||||
return command.addTabCompletionOptions(sender, Arrays.copyOfRange(args, 1, args.length));
|
||||
}
|
||||
|
||||
public CommandKamkeelBase getCommand(String[] args){
|
||||
if(args.length == 0)
|
||||
public CommandKamkeelBase getCommand(String[] args) {
|
||||
if (args.length == 0)
|
||||
return null;
|
||||
return map.get(args[0].toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel(){
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public static String getCommandPermission(String command){
|
||||
public static String getCommandPermission(String command) {
|
||||
return "cnpc.kamkeel." + command.toLowerCase();
|
||||
}
|
||||
|
||||
public static String getUniversalPermission(){
|
||||
public static String getUniversalPermission() {
|
||||
return "cnpc.kamkeel.*";
|
||||
}
|
||||
|
||||
public static boolean canSendCommand(ICommandSender sender, CommandKamkeelBase command){
|
||||
if(sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), getUniversalPermission())){
|
||||
public static boolean canSendCommand(ICommandSender sender, CommandKamkeelBase command) {
|
||||
if (sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), getUniversalPermission())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), getCommandPermission(command.getCommandName()))){
|
||||
if (sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), getCommandPermission(command.getCommandName()))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(sender instanceof EntityPlayer){
|
||||
if (sender instanceof EntityPlayer) {
|
||||
return CustomNpcsPermissions.hasCustomPermission((EntityPlayer) sender, getCommandPermission(command.getCommandName()));
|
||||
}
|
||||
|
||||
|
||||
@@ -16,10 +16,10 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class CommandKamkeelBase extends CommandBase{
|
||||
public Map<String, Method> subcommands = new HashMap<String, Method>();
|
||||
public abstract class CommandKamkeelBase extends CommandBase {
|
||||
public Map<String, Method> subcommands = new HashMap<String, Method>();
|
||||
|
||||
public CommandKamkeelBase(){
|
||||
public CommandKamkeelBase() {
|
||||
for (Method m : this.getClass().getDeclaredMethods()) {
|
||||
SubCommand sc = m.getAnnotation(SubCommand.class);
|
||||
if (sc != null) {
|
||||
@@ -29,107 +29,107 @@ public abstract class CommandKamkeelBase extends CommandBase{
|
||||
subcommands.put(name.toLowerCase(), m);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender sender) {
|
||||
return getDescription();
|
||||
}
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender sender) {
|
||||
return getDescription();
|
||||
}
|
||||
|
||||
public abstract String getDescription();
|
||||
public abstract String getDescription();
|
||||
|
||||
/**
|
||||
* @return Should return a string in the format of <arg> <arg2> <arg3> [arg4] where <> is a required parameter and [] optional
|
||||
*/
|
||||
public String getUsage(){
|
||||
return "";
|
||||
}
|
||||
/**
|
||||
* @return Should return a string in the format of <arg> <arg2> <arg3> [arg4] where <> is a required parameter and [] optional
|
||||
*/
|
||||
public String getUsage() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public boolean runSubCommands(){
|
||||
return !subcommands.isEmpty();
|
||||
}
|
||||
public boolean runSubCommands() {
|
||||
return !subcommands.isEmpty();
|
||||
}
|
||||
|
||||
@Retention(value = RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface SubCommand {
|
||||
@Retention(value = RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface SubCommand {
|
||||
|
||||
String name() default "";
|
||||
String name() default "";
|
||||
|
||||
/**
|
||||
* @return Should return a string in the format of <arg> <arg2> <arg3> [arg4] where <> is a required parameter and [] optional
|
||||
*/
|
||||
String usage() default "";
|
||||
/**
|
||||
* @return Should return a string in the format of <arg> <arg2> <arg3> [arg4] where <> is a required parameter and [] optional
|
||||
*/
|
||||
String usage() default "";
|
||||
|
||||
String desc();
|
||||
String desc();
|
||||
|
||||
int permission() default 2;
|
||||
}
|
||||
int permission() default 2;
|
||||
}
|
||||
|
||||
public void processSubCommand(ICommandSender sender, String command, String[] args) throws CommandException {
|
||||
Method m = subcommands.get(command.toLowerCase());
|
||||
if(m == null)
|
||||
throw new CommandException("Unknown subcommand " + command);
|
||||
public void processSubCommand(ICommandSender sender, String command, String[] args) throws CommandException {
|
||||
Method m = subcommands.get(command.toLowerCase());
|
||||
if (m == null)
|
||||
throw new CommandException("Unknown subcommand " + command);
|
||||
|
||||
SubCommand sc = m.getAnnotation(SubCommand.class);
|
||||
if(!canSendCommand(sender, sc, command))
|
||||
throw new CommandException("You are not allowed to use this command: " + command);
|
||||
SubCommand sc = m.getAnnotation(SubCommand.class);
|
||||
if (!canSendCommand(sender, sc, command))
|
||||
throw new CommandException("You are not allowed to use this command: " + command);
|
||||
|
||||
canRun(sender, sc.usage(), args);
|
||||
try {
|
||||
m.invoke(this, sender, args);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
canRun(sender, sc.usage(), args);
|
||||
try {
|
||||
m.invoke(this, sender, args);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void canRun(ICommandSender sender, String usage, String[] args) throws CommandException{
|
||||
String[] np = usage.split(" ");
|
||||
List<String> required = new ArrayList<String>();
|
||||
for(int i = 0; i < np.length; i++){
|
||||
String command = np[i];
|
||||
if(command.startsWith("<")){
|
||||
required.add(command);
|
||||
}
|
||||
if(command.equals("<player>") && args.length > i){
|
||||
CommandBase.getPlayer(sender, args[i]); //throws PlayerNotFoundException if no player is found
|
||||
}
|
||||
public void canRun(ICommandSender sender, String usage, String[] args) throws CommandException {
|
||||
String[] np = usage.split(" ");
|
||||
List<String> required = new ArrayList<String>();
|
||||
for (int i = 0; i < np.length; i++) {
|
||||
String command = np[i];
|
||||
if (command.startsWith("<")) {
|
||||
required.add(command);
|
||||
}
|
||||
if (command.equals("<player>") && args.length > i) {
|
||||
CommandBase.getPlayer(sender, args[i]); //throws PlayerNotFoundException if no player is found
|
||||
}
|
||||
|
||||
}
|
||||
if (args.length < required.size()) {
|
||||
throw new CommandException("Missing parameter: " + required.get(args.length));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (args.length < required.size()) {
|
||||
throw new CommandException("Missing parameter: " + required.get(args.length));
|
||||
}
|
||||
}
|
||||
|
||||
public int getRequiredPermissionLevel(){
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public String getSubCommandPermission(String subCommand){
|
||||
return "cnpc.kamkeel." + getCommandName().toLowerCase() + "." + subCommand.toLowerCase();
|
||||
}
|
||||
public String getSubCommandPermission(String subCommand) {
|
||||
return "cnpc.kamkeel." + getCommandName().toLowerCase() + "." + subCommand.toLowerCase();
|
||||
}
|
||||
|
||||
public String getSubUniversalPermission(){
|
||||
return "cnpc.kamkeel." + getCommandName().toLowerCase() + "*";
|
||||
}
|
||||
public String getSubUniversalPermission() {
|
||||
return "cnpc.kamkeel." + getCommandName().toLowerCase() + "*";
|
||||
}
|
||||
|
||||
public boolean canSendCommand(ICommandSender sender, SubCommand command, String subCommand){
|
||||
if(sender.canCommandSenderUseCommand(command.permission(), getSubUniversalPermission())){
|
||||
return true;
|
||||
}
|
||||
public boolean canSendCommand(ICommandSender sender, SubCommand command, String subCommand) {
|
||||
if (sender.canCommandSenderUseCommand(command.permission(), getSubUniversalPermission())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(sender.canCommandSenderUseCommand(command.permission(), getSubCommandPermission(subCommand))){
|
||||
return true;
|
||||
}
|
||||
if (sender.canCommandSenderUseCommand(command.permission(), getSubCommandPermission(subCommand))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(sender instanceof EntityPlayer){
|
||||
return CustomNpcsPermissions.hasCustomPermission((EntityPlayer) sender, getSubCommandPermission(subCommand));
|
||||
}
|
||||
if (sender instanceof EntityPlayer) {
|
||||
return CustomNpcsPermissions.hasCustomPermission((EntityPlayer) sender, getSubCommandPermission(subCommand));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -27,245 +27,232 @@ import static kamkeel.npcs.util.ColorUtil.sendResult;
|
||||
public class ConfigCommand extends CommandKamkeelBase {
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "config";
|
||||
}
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "config";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Some config things you can set";
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Some config things you can set";
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Disable/Enable the natural leaves decay",
|
||||
usage = "[true/false]",
|
||||
permission = 4
|
||||
desc = "Disable/Enable the natural leaves decay",
|
||||
usage = "[true/false]",
|
||||
permission = 4
|
||||
)
|
||||
public void leavesdecay(ICommandSender sender, String[] args){
|
||||
if(args.length == 0){
|
||||
sendResult(sender, "LeavesDecay: \u00A7c" + ConfigMain.LeavesDecayEnabled);
|
||||
}
|
||||
else{
|
||||
ConfigMain.LeavesDecayEnabled = Boolean.parseBoolean(args[0]);
|
||||
ConfigMain.LeavesDecayEnabledProperty.set(ConfigMain.LeavesDecayEnabled);
|
||||
if(ConfigMain.config.hasChanged()){
|
||||
ConfigMain.config.save();
|
||||
}
|
||||
public void leavesdecay(ICommandSender sender, String[] args) {
|
||||
if (args.length == 0) {
|
||||
sendResult(sender, "LeavesDecay: \u00A7c" + ConfigMain.LeavesDecayEnabled);
|
||||
} else {
|
||||
ConfigMain.LeavesDecayEnabled = Boolean.parseBoolean(args[0]);
|
||||
ConfigMain.LeavesDecayEnabledProperty.set(ConfigMain.LeavesDecayEnabled);
|
||||
if (ConfigMain.config.hasChanged()) {
|
||||
ConfigMain.config.save();
|
||||
}
|
||||
Set<ResourceLocation> names = Block.blockRegistry.getKeys();
|
||||
for(ResourceLocation name : names){
|
||||
Block block = (Block) Block.blockRegistry.getObject(name);
|
||||
if(block instanceof BlockLeavesBase){
|
||||
block.setTickRandomly(ConfigMain.LeavesDecayEnabled);
|
||||
}
|
||||
for (ResourceLocation name : names) {
|
||||
Block block = (Block) Block.blockRegistry.getObject(name);
|
||||
if (block instanceof BlockLeavesBase) {
|
||||
block.setTickRandomly(ConfigMain.LeavesDecayEnabled);
|
||||
}
|
||||
}
|
||||
sendResult(sender, "LeavesDecay is now \u00A7c" + ConfigMain.LeavesDecayEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Disable/Enable the vines growing",
|
||||
usage = "[true/false]",
|
||||
permission = 4
|
||||
desc = "Disable/Enable the vines growing",
|
||||
usage = "[true/false]",
|
||||
permission = 4
|
||||
)
|
||||
public void vinegrowth(ICommandSender sender, String[] args){
|
||||
if(args.length == 0){
|
||||
sendResult(sender, "VineGrowth: \u00A7c" + ConfigMain.VineGrowthEnabled);
|
||||
}
|
||||
else{
|
||||
ConfigMain.VineGrowthEnabled = Boolean.parseBoolean(args[0]);
|
||||
ConfigMain.VineGrowthEnabledProperty.set(ConfigMain.VineGrowthEnabled);
|
||||
if(ConfigMain.config.hasChanged()){
|
||||
ConfigMain.config.save();
|
||||
}
|
||||
public void vinegrowth(ICommandSender sender, String[] args) {
|
||||
if (args.length == 0) {
|
||||
sendResult(sender, "VineGrowth: \u00A7c" + ConfigMain.VineGrowthEnabled);
|
||||
} else {
|
||||
ConfigMain.VineGrowthEnabled = Boolean.parseBoolean(args[0]);
|
||||
ConfigMain.VineGrowthEnabledProperty.set(ConfigMain.VineGrowthEnabled);
|
||||
if (ConfigMain.config.hasChanged()) {
|
||||
ConfigMain.config.save();
|
||||
}
|
||||
Set<ResourceLocation> names = Block.blockRegistry.getKeys();
|
||||
for(ResourceLocation name : names){
|
||||
Block block = (Block) Block.blockRegistry.getObject(name);
|
||||
if(block instanceof BlockVine){
|
||||
block.setTickRandomly(ConfigMain.VineGrowthEnabled);
|
||||
}
|
||||
for (ResourceLocation name : names) {
|
||||
Block block = (Block) Block.blockRegistry.getObject(name);
|
||||
if (block instanceof BlockVine) {
|
||||
block.setTickRandomly(ConfigMain.VineGrowthEnabled);
|
||||
}
|
||||
}
|
||||
sendResult(sender, "VineGrowth is now \u00A7c" + ConfigMain.VineGrowthEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Disable/Enable the ice melting",
|
||||
usage = "[true/false]",
|
||||
permission = 4
|
||||
desc = "Disable/Enable the ice melting",
|
||||
usage = "[true/false]",
|
||||
permission = 4
|
||||
)
|
||||
public void icemelts(ICommandSender sender, String[] args){
|
||||
if(args.length == 0){
|
||||
sendResult(sender, "IceMelts: \u00A7c" + ConfigMain.IceMeltsEnabled);
|
||||
}
|
||||
else{
|
||||
ConfigMain.IceMeltsEnabled = Boolean.parseBoolean(args[0]);
|
||||
ConfigMain.IceMeltsEnabledProperty.set(ConfigMain.IceMeltsEnabled);
|
||||
if(ConfigMain.config.hasChanged()){
|
||||
ConfigMain.config.save();
|
||||
}
|
||||
public void icemelts(ICommandSender sender, String[] args) {
|
||||
if (args.length == 0) {
|
||||
sendResult(sender, "IceMelts: \u00A7c" + ConfigMain.IceMeltsEnabled);
|
||||
} else {
|
||||
ConfigMain.IceMeltsEnabled = Boolean.parseBoolean(args[0]);
|
||||
ConfigMain.IceMeltsEnabledProperty.set(ConfigMain.IceMeltsEnabled);
|
||||
if (ConfigMain.config.hasChanged()) {
|
||||
ConfigMain.config.save();
|
||||
}
|
||||
Set<ResourceLocation> names = Block.blockRegistry.getKeys();
|
||||
for(ResourceLocation name : names){
|
||||
Block block = (Block) Block.blockRegistry.getObject(name);
|
||||
if(block instanceof BlockIce){
|
||||
block.setTickRandomly(ConfigMain.IceMeltsEnabled);
|
||||
}
|
||||
for (ResourceLocation name : names) {
|
||||
Block block = (Block) Block.blockRegistry.getObject(name);
|
||||
if (block instanceof BlockIce) {
|
||||
block.setTickRandomly(ConfigMain.IceMeltsEnabled);
|
||||
}
|
||||
}
|
||||
sendResult(sender, "IceMelts is now \u00A7c" + ConfigMain.IceMeltsEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Disable/Enable guns shooting",
|
||||
usage = "[true/false]",
|
||||
permission = 4
|
||||
desc = "Disable/Enable guns shooting",
|
||||
usage = "[true/false]",
|
||||
permission = 4
|
||||
)
|
||||
public void guns(ICommandSender sender, String[] args){
|
||||
if(args.length == 0){
|
||||
sendResult(sender, "GunsEnabled: \u00A7c" + ConfigItem.GunsEnabled);
|
||||
}
|
||||
else{
|
||||
ConfigItem.GunsEnabled = Boolean.parseBoolean(args[0]);
|
||||
ConfigItem.GunsEnabledProperty.set(ConfigItem.GunsEnabled);
|
||||
if(ConfigMain.config.hasChanged()){
|
||||
ConfigMain.config.save();
|
||||
}
|
||||
public void guns(ICommandSender sender, String[] args) {
|
||||
if (args.length == 0) {
|
||||
sendResult(sender, "GunsEnabled: \u00A7c" + ConfigItem.GunsEnabled);
|
||||
} else {
|
||||
ConfigItem.GunsEnabled = Boolean.parseBoolean(args[0]);
|
||||
ConfigItem.GunsEnabledProperty.set(ConfigItem.GunsEnabled);
|
||||
if (ConfigMain.config.hasChanged()) {
|
||||
ConfigMain.config.save();
|
||||
}
|
||||
sendResult(sender, "GunsEnabled is now \u00A7c" + ConfigItem.GunsEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Freezes/Unfreezes npcs",
|
||||
usage = "[true/false]",
|
||||
permission = 4
|
||||
desc = "Freezes/Unfreezes npcs",
|
||||
usage = "[true/false]",
|
||||
permission = 4
|
||||
)
|
||||
public void freezenpcs(ICommandSender sender, String[] args){
|
||||
if(args.length == 0){
|
||||
sendResult(sender, "Frozen NPCs: \u00A7c" + CustomNpcs.FreezeNPCs);
|
||||
}
|
||||
else{
|
||||
CustomNpcs.FreezeNPCs = Boolean.parseBoolean(args[0]);
|
||||
public void freezenpcs(ICommandSender sender, String[] args) {
|
||||
if (args.length == 0) {
|
||||
sendResult(sender, "Frozen NPCs: \u00A7c" + CustomNpcs.FreezeNPCs);
|
||||
} else {
|
||||
CustomNpcs.FreezeNPCs = Boolean.parseBoolean(args[0]);
|
||||
sendResult(sender, "FrozenNPCs is now \u00A7c" + CustomNpcs.FreezeNPCs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Set number of active chunkloaders",
|
||||
usage = "<number>",
|
||||
permission = 4
|
||||
desc = "Set number of active chunkloaders",
|
||||
usage = "<number>",
|
||||
permission = 4
|
||||
)
|
||||
public void chunkloaders(ICommandSender sender, String[] args) throws CommandException{
|
||||
if(args.length == 0){
|
||||
sendResult(sender, "ChunkLoaders: \u00A7c" + ChunkController.Instance.size() + "\u00A77/\u00A7c" + ConfigMain.ChunkLoaders);
|
||||
}
|
||||
else{
|
||||
try{
|
||||
ConfigMain.ChunkLoaders = Integer.parseInt(args[0]);
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
sendError(sender, "Did not get a number: " + args[0]);
|
||||
return;
|
||||
}
|
||||
ConfigMain.ChunkLoadersProperty.set(ConfigMain.ChunkLoaders);
|
||||
if(ConfigMain.config.hasChanged()){
|
||||
ConfigMain.config.save();
|
||||
}
|
||||
public void chunkloaders(ICommandSender sender, String[] args) throws CommandException {
|
||||
if (args.length == 0) {
|
||||
sendResult(sender, "ChunkLoaders: \u00A7c" + ChunkController.Instance.size() + "\u00A77/\u00A7c" + ConfigMain.ChunkLoaders);
|
||||
} else {
|
||||
try {
|
||||
ConfigMain.ChunkLoaders = Integer.parseInt(args[0]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, "Did not get a number: " + args[0]);
|
||||
return;
|
||||
}
|
||||
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);
|
||||
sendResult(sender, size - ConfigMain.ChunkLoaders + " chunksloaders unloaded");
|
||||
}
|
||||
sendResult(sender, "ChunkLoaders: \u00A7c" + ChunkController.Instance.size() + "\u00A77/\u00A7c" + ConfigMain.ChunkLoaders);
|
||||
}
|
||||
int size = ChunkController.Instance.size();
|
||||
if (size > ConfigMain.ChunkLoaders) {
|
||||
ChunkController.Instance.unload(size - ConfigMain.ChunkLoaders);
|
||||
sendResult(sender, size - ConfigMain.ChunkLoaders + " chunksloaders unloaded");
|
||||
}
|
||||
sendResult(sender, "ChunkLoaders: \u00A7c" + ChunkController.Instance.size() + "\u00A77/\u00A7c" + ConfigMain.ChunkLoaders);
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Generate PlayerData to JSON/DAT",
|
||||
usage = "[fileType] [convert]",
|
||||
permission = 4
|
||||
)
|
||||
public void playerdata(ICommandSender sender, String[] args) throws CommandException{
|
||||
String fileType;
|
||||
if(ConfigMain.DatFormat){
|
||||
fileType = "DAT";
|
||||
}
|
||||
else {
|
||||
fileType = "JSON";
|
||||
}
|
||||
if(args.length == 0){
|
||||
sendResult(sender, "PlayerData Filetype: \u00A7c" + fileType);
|
||||
}
|
||||
else if(args.length == 1){
|
||||
sendResult(sender, "Please write the word 'convert' at the end to confirm. \u00A7c<dat/json> convert");
|
||||
}
|
||||
else{
|
||||
if(args.length != 2){
|
||||
sendError(sender, "Two many arguments");
|
||||
return;
|
||||
}
|
||||
String formatType = args[0].toLowerCase();
|
||||
if(!formatType.equals("dat") && !formatType.equals("json")){
|
||||
sendError(sender, "Invalid Format Type - Please use dat or json");
|
||||
return;
|
||||
}
|
||||
|
||||
String convert = args[1].toLowerCase();
|
||||
if(!convert.equals("convert")){
|
||||
sendError(sender, "Please enter the word 'convert' at the end");
|
||||
return;
|
||||
}
|
||||
|
||||
boolean convertToDat = formatType.equals("dat");
|
||||
EntityPlayerMP send = null;
|
||||
if(sender instanceof EntityPlayerMP){
|
||||
send = (EntityPlayerMP) sender;
|
||||
}
|
||||
|
||||
sendResult(sender, "Started Conversion Process for PlayerData");
|
||||
PlayerDataController.Instance.convertPlayerFiles(send, convertToDat);
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Generate Market to JSON/DAT",
|
||||
desc = "Generate PlayerData to JSON/DAT",
|
||||
usage = "[fileType] [convert]",
|
||||
permission = 4
|
||||
)
|
||||
public void market(ICommandSender sender, String[] args) throws CommandException{
|
||||
public void playerdata(ICommandSender sender, String[] args) throws CommandException {
|
||||
String fileType;
|
||||
if(ConfigMain.MarketDatFormat){
|
||||
if (ConfigMain.DatFormat) {
|
||||
fileType = "DAT";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
fileType = "JSON";
|
||||
}
|
||||
if(args.length == 0){
|
||||
sendResult(sender, "Market Filetype: \u00A7c" + fileType);
|
||||
}
|
||||
else if(args.length == 1){
|
||||
if (args.length == 0) {
|
||||
sendResult(sender, "PlayerData Filetype: \u00A7c" + fileType);
|
||||
} else if (args.length == 1) {
|
||||
sendResult(sender, "Please write the word 'convert' at the end to confirm. \u00A7c<dat/json> convert");
|
||||
}
|
||||
else{
|
||||
if(args.length != 2){
|
||||
} else {
|
||||
if (args.length != 2) {
|
||||
sendError(sender, "Two many arguments");
|
||||
return;
|
||||
}
|
||||
String formatType = args[0].toLowerCase();
|
||||
if(!formatType.equals("dat") && !formatType.equals("json")){
|
||||
if (!formatType.equals("dat") && !formatType.equals("json")) {
|
||||
sendError(sender, "Invalid Format Type - Please use dat or json");
|
||||
return;
|
||||
}
|
||||
|
||||
String convert = args[1].toLowerCase();
|
||||
if(!convert.equals("convert")){
|
||||
if (!convert.equals("convert")) {
|
||||
sendError(sender, "Please enter the word 'convert' at the end");
|
||||
return;
|
||||
}
|
||||
|
||||
boolean convertToDat = formatType.equals("dat");
|
||||
EntityPlayerMP send = null;
|
||||
if(sender instanceof EntityPlayerMP){
|
||||
if (sender instanceof EntityPlayerMP) {
|
||||
send = (EntityPlayerMP) sender;
|
||||
}
|
||||
|
||||
sendResult(sender, "Started Conversion Process for PlayerData");
|
||||
PlayerDataController.Instance.convertPlayerFiles(send, convertToDat);
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Generate Market to JSON/DAT",
|
||||
usage = "[fileType] [convert]",
|
||||
permission = 4
|
||||
)
|
||||
public void market(ICommandSender sender, String[] args) throws CommandException {
|
||||
String fileType;
|
||||
if (ConfigMain.MarketDatFormat) {
|
||||
fileType = "DAT";
|
||||
} else {
|
||||
fileType = "JSON";
|
||||
}
|
||||
if (args.length == 0) {
|
||||
sendResult(sender, "Market Filetype: \u00A7c" + fileType);
|
||||
} else if (args.length == 1) {
|
||||
sendResult(sender, "Please write the word 'convert' at the end to confirm. \u00A7c<dat/json> convert");
|
||||
} else {
|
||||
if (args.length != 2) {
|
||||
sendError(sender, "Two many arguments");
|
||||
return;
|
||||
}
|
||||
String formatType = args[0].toLowerCase();
|
||||
if (!formatType.equals("dat") && !formatType.equals("json")) {
|
||||
sendError(sender, "Invalid Format Type - Please use dat or json");
|
||||
return;
|
||||
}
|
||||
|
||||
String convert = args[1].toLowerCase();
|
||||
if (!convert.equals("convert")) {
|
||||
sendError(sender, "Please enter the word 'convert' at the end");
|
||||
return;
|
||||
}
|
||||
|
||||
boolean convertToDat = formatType.equals("dat");
|
||||
EntityPlayerMP send = null;
|
||||
if (sender instanceof EntityPlayerMP) {
|
||||
send = (EntityPlayerMP) sender;
|
||||
}
|
||||
|
||||
@@ -275,28 +262,27 @@ public class ConfigCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Get/Set font",
|
||||
usage = "[type] [size]",
|
||||
permission = 4
|
||||
desc = "Get/Set font",
|
||||
usage = "[type] [size]",
|
||||
permission = 4
|
||||
)
|
||||
public void font(ICommandSender sender, String[] args){
|
||||
if(!(sender instanceof EntityPlayerMP))
|
||||
return;
|
||||
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(ICommandSender sender, String[] args) {
|
||||
if (!(sender instanceof EntityPlayerMP))
|
||||
return;
|
||||
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)sender);
|
||||
}
|
||||
}
|
||||
String font = "";
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
font += " " + args[i];
|
||||
}
|
||||
PacketHandler.Instance.sendToPlayer(new ConfigCommandPacket(EnumConfigOperation.FONT, font.trim(), size), (EntityPlayerMP) sender);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,22 +16,22 @@ import static kamkeel.npcs.util.ColorUtil.sendResult;
|
||||
|
||||
public class DialogCategoryCommand extends CommandKamkeelBase {
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "dialogcat";
|
||||
}
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "dialogcat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Dialog Category operations";
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Dialog Category operations";
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Find dialog category id number by its name",
|
||||
usage = "<dialog cat name>"
|
||||
desc = "Find dialog category id number by its name",
|
||||
usage = "<dialog cat name>"
|
||||
)
|
||||
public void id(ICommandSender sender, String args[]) throws CommandException {
|
||||
if(args.length == 0){
|
||||
if (args.length == 0) {
|
||||
sendError(sender, "Please provide a name for the dialog category");
|
||||
return;
|
||||
}
|
||||
@@ -39,48 +39,47 @@ public class DialogCategoryCommand extends CommandKamkeelBase {
|
||||
String catName = String.join(" ", args).toLowerCase();
|
||||
final Collection<DialogCategory> dialogCats = DialogController.Instance.categories.values();
|
||||
int count = 0;
|
||||
for(DialogCategory cat : dialogCats){
|
||||
if(cat.getName().toLowerCase().contains(catName)){
|
||||
for (DialogCategory cat : dialogCats) {
|
||||
if (cat.getName().toLowerCase().contains(catName)) {
|
||||
sendResult(sender, String.format("Dialog Cat \u00A7e%d\u00A77 - \u00A7c'%s'", cat.id, cat.getName()));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if(count == 0){
|
||||
if (count == 0) {
|
||||
sendResult(sender, String.format("No Dialog Cat found with name: \u00A7c'%s'", catName));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SubCommand(
|
||||
desc = "Read a dialog category for a player",
|
||||
usage = "<player> <dialogcatid>"
|
||||
desc = "Read a dialog category for a player",
|
||||
usage = "<player> <dialogcatid>"
|
||||
)
|
||||
public void read(ICommandSender sender, String args[]) throws CommandException{
|
||||
String playername=args[0];
|
||||
public void read(ICommandSender sender, String args[]) throws CommandException {
|
||||
String playername = args[0];
|
||||
int dialogCatId;
|
||||
try {
|
||||
dialogCatId = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch (NumberFormatException ex) {
|
||||
sendError(sender, "DialogCatID must be an integer: " + args[1]);
|
||||
dialogCatId = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, "DialogCatID must be an integer: " + args[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
List<PlayerData> data = PlayerDataController.Instance.getPlayersData(sender, playername);
|
||||
if (data.isEmpty()) {
|
||||
sendError(sender, String.format("Unknown player '%s'", playername));
|
||||
sendError(sender, String.format("Unknown player '%s'", playername));
|
||||
return;
|
||||
}
|
||||
|
||||
DialogCategory dialogCategory = DialogController.Instance.categories.get(dialogCatId);
|
||||
if (dialogCategory == null){
|
||||
sendError(sender, "Unknown DialogCatID: " + dialogCatId);
|
||||
if (dialogCategory == null) {
|
||||
sendError(sender, "Unknown DialogCatID: " + dialogCatId);
|
||||
return;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for(PlayerData playerdata : data){
|
||||
for(Dialog dialog : dialogCategory.dialogs.values()){
|
||||
for (PlayerData playerdata : data) {
|
||||
for (Dialog dialog : dialogCategory.dialogs.values()) {
|
||||
playerdata.dialogData.dialogsRead.add(dialog.id);
|
||||
count++;
|
||||
}
|
||||
@@ -94,16 +93,15 @@ public class DialogCategoryCommand extends CommandKamkeelBase {
|
||||
|
||||
|
||||
@SubCommand(
|
||||
desc = "Unread a dialog category for a player",
|
||||
usage = "<player> <dialogcatid>"
|
||||
desc = "Unread a dialog category for a player",
|
||||
usage = "<player> <dialogcatid>"
|
||||
)
|
||||
public void unread(ICommandSender sender, String args[]) throws CommandException{
|
||||
String playername=args[0];
|
||||
public void unread(ICommandSender sender, String args[]) throws CommandException {
|
||||
String playername = args[0];
|
||||
int dialogCatId;
|
||||
try {
|
||||
dialogCatId = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch (NumberFormatException ex) {
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, "DialogCatID must be an integer: " + args[1]);
|
||||
return;
|
||||
}
|
||||
@@ -115,14 +113,14 @@ public class DialogCategoryCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
DialogCategory dialogCategory = DialogController.Instance.categories.get(dialogCatId);
|
||||
if (dialogCategory == null){
|
||||
if (dialogCategory == null) {
|
||||
sendError(sender, "Unknown DialogCatID: " + dialogCatId);
|
||||
return;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for(PlayerData playerdata : data){
|
||||
for(Dialog dialog : dialogCategory.dialogs.values()){
|
||||
for (PlayerData playerdata : data) {
|
||||
for (Dialog dialog : dialogCategory.dialogs.values()) {
|
||||
playerdata.dialogData.dialogsRead.remove(dialog.id);
|
||||
count++;
|
||||
}
|
||||
|
||||
@@ -25,25 +25,25 @@ import static kamkeel.npcs.util.ColorUtil.sendResult;
|
||||
|
||||
public class DialogCommand extends CommandKamkeelBase {
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "dialog";
|
||||
}
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "dialog";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Dialog operations";
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Dialog operations";
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "force read",
|
||||
usage = "<player> <dialog>"
|
||||
desc = "force read",
|
||||
usage = "<player> <dialog>"
|
||||
)
|
||||
public void read(ICommandSender sender, String args[]) throws CommandException{
|
||||
String playername=args[0];
|
||||
public void read(ICommandSender sender, String args[]) throws CommandException {
|
||||
String playername = args[0];
|
||||
int diagid;
|
||||
try {
|
||||
diagid = Integer.parseInt(args[1]);
|
||||
diagid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, "DialogID must be an integer: " + args[1]);
|
||||
return;
|
||||
@@ -53,8 +53,8 @@ public class DialogCommand extends CommandKamkeelBase {
|
||||
sendError(sender, "Unknown player: " + playername);
|
||||
return;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.dialogData.dialogsRead.add(diagid);
|
||||
for (PlayerData playerdata : data) {
|
||||
playerdata.dialogData.dialogsRead.add(diagid);
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Forced Read for Dialog \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", diagid, playerdata.playername));
|
||||
@@ -62,14 +62,14 @@ public class DialogCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "force unread dialog",
|
||||
usage = "<player> <dialog>"
|
||||
desc = "force unread dialog",
|
||||
usage = "<player> <dialog>"
|
||||
)
|
||||
public void unread(ICommandSender sender, String args[]) throws CommandException{
|
||||
String playername=args[0];
|
||||
public void unread(ICommandSender sender, String args[]) throws CommandException {
|
||||
String playername = args[0];
|
||||
int diagid;
|
||||
try {
|
||||
diagid = Integer.parseInt(args[1]);
|
||||
diagid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, "DialogID must be an integer: " + args[1]);
|
||||
return;
|
||||
@@ -79,64 +79,65 @@ public class DialogCommand extends CommandKamkeelBase {
|
||||
sendError(sender, "Unknown player: " + playername);
|
||||
return;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.dialogData.dialogsRead.remove(diagid);
|
||||
for (PlayerData playerdata : data) {
|
||||
playerdata.dialogData.dialogsRead.remove(diagid);
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Forced Unread for Dialog \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", diagid, playerdata.playername));
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="reload dialogs from disk",
|
||||
permission = 4
|
||||
desc = "reload dialogs from disk",
|
||||
permission = 4
|
||||
)
|
||||
public void reload(ICommandSender sender, String args[]){
|
||||
new DialogController().load();
|
||||
public void reload(ICommandSender sender, String args[]) {
|
||||
new DialogController().load();
|
||||
SyncController.syncAllDialogs();
|
||||
sendResult(sender, "Dialogs Reloaded");
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="show dialog",
|
||||
usage="<player> <dialog> <name>"
|
||||
desc = "show dialog",
|
||||
usage = "<player> <dialog> <name>"
|
||||
)
|
||||
public void show(ICommandSender sender, String args[]) throws CommandException{
|
||||
EntityPlayer player = CommandBase.getPlayer(sender, args[0]);
|
||||
if(player == null){
|
||||
public void show(ICommandSender sender, String args[]) throws CommandException {
|
||||
EntityPlayer player = CommandBase.getPlayer(sender, args[0]);
|
||||
if (player == null) {
|
||||
sendError(sender, "Unknown player: " + args[0]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int diagid;
|
||||
try {
|
||||
diagid = Integer.parseInt(args[1]);
|
||||
diagid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, "DialogID must be an integer: " + args[1]);
|
||||
return;
|
||||
}
|
||||
Dialog dialog = DialogController.Instance.dialogs.get(diagid);
|
||||
if(dialog == null){
|
||||
if (dialog == null) {
|
||||
sendError(sender, "Unknown dialog id: " + args[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
EntityDialogNpc npc = new EntityDialogNpc(sender.getEntityWorld());
|
||||
npc.display.setName(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(sender.getEntityWorld());
|
||||
npc.display.setName(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);
|
||||
sendResult(sender, String.format("Displayed Dialog \u00A7e%d\u00A77 to Player '\u00A7b%s\u00A77'", diagid, player.getCommandSenderName()));
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Find dialog id number by its name",
|
||||
usage = "<dialogName>"
|
||||
desc = "Find dialog id number by its name",
|
||||
usage = "<dialogName>"
|
||||
)
|
||||
public void id(ICommandSender sender, String args[]) throws CommandException {
|
||||
if(args.length == 0){
|
||||
if (args.length == 0) {
|
||||
sendError(sender, "Please provide a name for the dialog");
|
||||
return;
|
||||
}
|
||||
@@ -144,23 +145,23 @@ public class DialogCommand extends CommandKamkeelBase {
|
||||
String dialogName = String.join(" ", args).toLowerCase();
|
||||
final Collection<Dialog> quests = DialogController.Instance.dialogs.values();
|
||||
int count = 0;
|
||||
for(Dialog dialog : quests){
|
||||
if(dialog.getName().toLowerCase().contains(dialogName)){
|
||||
for (Dialog dialog : quests) {
|
||||
if (dialog.getName().toLowerCase().contains(dialogName)) {
|
||||
sendResult(sender, String.format("Dialog \u00A7e%d\u00A77 - \u00A7c'%s'", dialog.id, dialog.getName()));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if(count == 0){
|
||||
if (count == 0) {
|
||||
sendResult(sender, String.format("No Dialog found with name: \u00A7c'%s'", dialogName));
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "List a dialogs availability options",
|
||||
usage = "<dialogId>"
|
||||
desc = "List a dialogs availability options",
|
||||
usage = "<dialogId>"
|
||||
)
|
||||
public void availability(ICommandSender sender, String args[]) throws CommandException {
|
||||
if(args.length == 0){
|
||||
if (args.length == 0) {
|
||||
sendError(sender, "Please provide an id for the dialog");
|
||||
return;
|
||||
}
|
||||
@@ -173,56 +174,56 @@ public class DialogCommand extends CommandKamkeelBase {
|
||||
return;
|
||||
}
|
||||
Dialog dialog = DialogController.Instance.dialogs.get(diagid);
|
||||
if(dialog == null){
|
||||
if (dialog == null) {
|
||||
sendError(sender, "Unknown dialog id: " + args[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
Availability avail = dialog.availability;
|
||||
if(avail != null){
|
||||
if (avail != null) {
|
||||
sendResult(sender, String.format("Availability Options for Dialog: \u00A7c%d", dialog.id));
|
||||
sendResult(sender, "--------------------");
|
||||
boolean diagFound = false;
|
||||
if(avail.dialogId != -1 && avail.dialogAvailable != EnumAvailabilityDialog.Always){
|
||||
if (avail.dialogId != -1 && avail.dialogAvailable != EnumAvailabilityDialog.Always) {
|
||||
sendResult(sender, String.format("%s Dialog: \u00A7c%d", avail.dialogAvailable.toString(), avail.dialogId));
|
||||
diagFound = true;
|
||||
}
|
||||
if(avail.dialog2Id != -1 && avail.dialog2Available != EnumAvailabilityDialog.Always){
|
||||
if (avail.dialog2Id != -1 && avail.dialog2Available != EnumAvailabilityDialog.Always) {
|
||||
sendResult(sender, String.format("%s Dialog: \u00A7c%d", avail.dialog2Available.toString(), avail.dialog2Id));
|
||||
diagFound = true;
|
||||
}
|
||||
if(avail.dialog3Id != -1 && avail.dialog3Available != EnumAvailabilityDialog.Always){
|
||||
if (avail.dialog3Id != -1 && avail.dialog3Available != EnumAvailabilityDialog.Always) {
|
||||
sendResult(sender, String.format("%s Dialog: \u00A7c%d", avail.dialog3Available.toString(), avail.dialog3Id));
|
||||
diagFound = true;
|
||||
}
|
||||
if(avail.dialog4Id != -1 && avail.dialog4Available != EnumAvailabilityDialog.Always){
|
||||
if (avail.dialog4Id != -1 && avail.dialog4Available != EnumAvailabilityDialog.Always) {
|
||||
sendResult(sender, String.format("%s Dialog: \u00A7c%d", avail.dialog4Available.toString(), avail.dialog4Id));
|
||||
diagFound = true;
|
||||
}
|
||||
|
||||
if(!diagFound){
|
||||
if (!diagFound) {
|
||||
sendResult(sender, "No Dialog Availability Options");
|
||||
}
|
||||
sendResult(sender, "--------------------");
|
||||
|
||||
boolean questFound = false;
|
||||
if(avail.questId != -1 && avail.questAvailable != EnumAvailabilityQuest.Always){
|
||||
if (avail.questId != -1 && avail.questAvailable != EnumAvailabilityQuest.Always) {
|
||||
sendResult(sender, String.format("%s Quest: \u00A7c%d", avail.questAvailable.toString(), avail.questId));
|
||||
questFound = true;
|
||||
}
|
||||
if(avail.quest2Id != -1 && avail.quest2Available != EnumAvailabilityQuest.Always){
|
||||
if (avail.quest2Id != -1 && avail.quest2Available != EnumAvailabilityQuest.Always) {
|
||||
sendResult(sender, String.format("%s Quest: \u00A7c%d", avail.quest2Available.toString(), avail.quest2Id));
|
||||
questFound = true;
|
||||
}
|
||||
if(avail.quest3Id != -1 && avail.quest3Available != EnumAvailabilityQuest.Always){
|
||||
if (avail.quest3Id != -1 && avail.quest3Available != EnumAvailabilityQuest.Always) {
|
||||
sendResult(sender, String.format("%s Quest: \u00A7c%d", avail.quest3Available.toString(), avail.quest3Id));
|
||||
questFound = true;
|
||||
}
|
||||
if(avail.quest4Id != -1 && avail.quest4Available != EnumAvailabilityQuest.Always){
|
||||
if (avail.quest4Id != -1 && avail.quest4Available != EnumAvailabilityQuest.Always) {
|
||||
sendResult(sender, String.format("%s Quest: \u00A7c%d", avail.quest4Available.toString(), avail.quest4Id));
|
||||
questFound = true;
|
||||
}
|
||||
if(!questFound){
|
||||
if (!questFound) {
|
||||
sendResult(sender, "No Quest Availability Options");
|
||||
}
|
||||
sendResult(sender, "--------------------");
|
||||
@@ -230,11 +231,11 @@ public class DialogCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Quick info on a dialog",
|
||||
usage = "<dialogId>"
|
||||
desc = "Quick info on a dialog",
|
||||
usage = "<dialogId>"
|
||||
)
|
||||
public void info(ICommandSender sender, String args[]) throws CommandException {
|
||||
if(args.length == 0){
|
||||
if (args.length == 0) {
|
||||
sendError(sender, "Please provide an id for the quest");
|
||||
return;
|
||||
}
|
||||
@@ -247,7 +248,7 @@ public class DialogCommand extends CommandKamkeelBase {
|
||||
return;
|
||||
}
|
||||
Dialog dialog = DialogController.Instance.dialogs.get(diagid);
|
||||
if(dialog == null){
|
||||
if (dialog == null) {
|
||||
sendError(sender, "Unknown dialog id: " + args[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public class EffectCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
for (PlayerData pdata : players) {
|
||||
if(pdata.player != null){
|
||||
if (pdata.player != null) {
|
||||
CustomEffectController.getInstance().applyEffect(pdata.player, match.id, time, (byte) 1, match.index);
|
||||
sendResult(sender, String.format("%s §agiven to §7'§b%s§7'", match.effect.getName(), pdata.playername));
|
||||
}
|
||||
@@ -182,7 +182,7 @@ public class EffectCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
for (PlayerData pdata : players) {
|
||||
if(pdata.player != null){
|
||||
if (pdata.player != null) {
|
||||
CustomEffectController.getInstance().removeEffect(pdata.player, match.id, match.index, ExpirationType.REMOVED);
|
||||
sendResult(sender, String.format("Effect %s removed from %s", match.effect.getName(), pdata.playername));
|
||||
}
|
||||
@@ -236,7 +236,7 @@ public class EffectCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
for (PlayerData pdata : players) {
|
||||
if(pdata.player != null){
|
||||
if (pdata.player != null) {
|
||||
CustomEffectController.getInstance().applyEffect(pdata.player, effect.id, time, (byte) 1, effect.index);
|
||||
sendResult(sender, String.format("%s §agiven to §7'§b%s§7'", effect.getName(), pdata.playername));
|
||||
}
|
||||
@@ -282,7 +282,7 @@ public class EffectCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
for (PlayerData pdata : players) {
|
||||
if(pdata.player != null){
|
||||
if (pdata.player != null) {
|
||||
CustomEffectController.getInstance().removeEffect(pdata.player, effect.id, effect.index, ExpirationType.REMOVED);
|
||||
sendResult(sender, String.format("Effect %s removed from %s", effect.getName(), pdata.playername));
|
||||
}
|
||||
|
||||
@@ -20,28 +20,28 @@ public class FactionCommand extends CommandKamkeelBase {
|
||||
public List<PlayerData> data;
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "faction";
|
||||
}
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "faction";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Faction operations";
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Faction operations";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage() {
|
||||
return "<player> <faction> <command>";
|
||||
}
|
||||
@Override
|
||||
public String getUsage() {
|
||||
return "<player> <faction> <command>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean runSubCommands(){
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean runSubCommands() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
String playername = args[0];
|
||||
String factionname = args[1];
|
||||
|
||||
@@ -51,10 +51,9 @@ public class FactionCommand extends CommandKamkeelBase {
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
try {
|
||||
selectedFaction = FactionController.getInstance().getFaction(Integer.parseInt(factionname));
|
||||
}
|
||||
catch(NumberFormatException e){
|
||||
} catch (NumberFormatException e) {
|
||||
selectedFaction = FactionController.getInstance().getFactionFromName(factionname);
|
||||
}
|
||||
|
||||
@@ -65,15 +64,15 @@ public class FactionCommand extends CommandKamkeelBase {
|
||||
|
||||
processSubCommand(sender, args[2], Arrays.copyOfRange(args, 3, args.length));
|
||||
|
||||
for(PlayerData playerdata : data){
|
||||
for (PlayerData playerdata : data) {
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Add points",
|
||||
usage = "<points>"
|
||||
desc = "Add points",
|
||||
usage = "<points>"
|
||||
)
|
||||
public void add(ICommandSender sender, String[] args) throws CommandException {
|
||||
int points;
|
||||
@@ -85,17 +84,17 @@ public class FactionCommand extends CommandKamkeelBase {
|
||||
}
|
||||
int factionid = this.selectedFaction.id;
|
||||
|
||||
for(PlayerData playerdata : data){
|
||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||
playerfactiondata.increasePoints(factionid, points, playerdata.player);
|
||||
for (PlayerData playerdata : data) {
|
||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||
playerfactiondata.increasePoints(factionid, points, playerdata.player);
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Added Points \u00A7a%d\u00A77, Faction \u00A7e%s (%d)\u00A77 for Player \u00A7b%s\u00A77", points, this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername));
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Substract points",
|
||||
usage = "<points>"
|
||||
desc = "Substract points",
|
||||
usage = "<points>"
|
||||
)
|
||||
public void subtract(ICommandSender sender, String[] args) throws CommandException {
|
||||
int points;
|
||||
@@ -106,9 +105,9 @@ public class FactionCommand extends CommandKamkeelBase {
|
||||
return;
|
||||
}
|
||||
int factionid = this.selectedFaction.id;
|
||||
for(PlayerData playerdata : data){
|
||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||
playerfactiondata.increasePoints(factionid, -points, playerdata.player);
|
||||
for (PlayerData playerdata : data) {
|
||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||
playerfactiondata.increasePoints(factionid, -points, playerdata.player);
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Subtracted Points \u00A7a%d\u00A77, Faction \u00A7e%s (%d)\u00A77 for Player \u00A7b%s\u00A77", points, this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername));
|
||||
}
|
||||
@@ -116,16 +115,16 @@ public class FactionCommand extends CommandKamkeelBase {
|
||||
|
||||
@SubCommand(desc = "Reset points to default")
|
||||
public void reset(ICommandSender sender, 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;
|
||||
sendResult(sender, String.format("Reset Faction \u00A7e%s (%d)\u00A77 for Player \u00A7b%s\u00A77", this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername));
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Set points",
|
||||
usage = "<points>"
|
||||
desc = "Set points",
|
||||
usage = "<points>"
|
||||
)
|
||||
public void set(ICommandSender sender, String[] args) throws CommandException {
|
||||
int points;
|
||||
@@ -135,28 +134,28 @@ public class FactionCommand extends CommandKamkeelBase {
|
||||
sendError(sender, "Must be an integer: " + args[0]);
|
||||
return;
|
||||
}
|
||||
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;
|
||||
sendResult(sender, String.format("Set Points \u00A7a%d\u00A77, Faction \u00A7e%s (%d)\u00A77 for Player \u00A7b%s\u00A77", points, this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername));
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(desc = "Drop relationship")
|
||||
public void drop(ICommandSender sender, String[] args){
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.factionData.factionData.remove(this.selectedFaction.id);
|
||||
public void drop(ICommandSender sender, String[] args) {
|
||||
for (PlayerData playerdata : data) {
|
||||
playerdata.factionData.factionData.remove(this.selectedFaction.id);
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Dropped Faction \u00A7e%s (%d)\u00A77 from Player \u00A7b%s\u00A77", this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List addTabCompletionOptions(ICommandSender par1, String[] args) {
|
||||
if(args.length == 3){
|
||||
return getListOfStringsMatchingLastWord(args, new String[]{"add", "subtract", "set", "reset", "drop", "create"});
|
||||
}
|
||||
return null;
|
||||
public List addTabCompletionOptions(ICommandSender par1, String[] args) {
|
||||
if (args.length == 3) {
|
||||
return getListOfStringsMatchingLastWord(args, new String[]{"add", "subtract", "set", "reset", "drop", "create"});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package kamkeel.npcs.command;
|
||||
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map.Entry;
|
||||
@@ -10,64 +9,63 @@ import java.util.Map.Entry;
|
||||
import static kamkeel.npcs.util.ColorUtil.sendError;
|
||||
import static kamkeel.npcs.util.ColorUtil.sendMessage;
|
||||
|
||||
public class HelpCommand extends CommandKamkeelBase{
|
||||
private CommandKamkeel parent;
|
||||
public class HelpCommand extends CommandKamkeelBase {
|
||||
private CommandKamkeel parent;
|
||||
|
||||
public HelpCommand(CommandKamkeel parent){
|
||||
this.parent = parent;
|
||||
}
|
||||
public HelpCommand(CommandKamkeel parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "help";
|
||||
}
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "help";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "help [command]";
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "help [command]";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
if(args.length == 0){
|
||||
sendMessage(sender, "\u00A78------ \u00A7cKamkeel Commands \u00A78------");
|
||||
for(Entry<String, CommandKamkeelBase> entry : parent.map.entrySet()){
|
||||
sendMessage(sender, "\u00A77> " + "\u00A7e" + entry.getKey() + "\u00A78: \u00A77" + entry.getValue().getCommandUsage(sender));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
if (args.length == 0) {
|
||||
sendMessage(sender, "\u00A78------ \u00A7cKamkeel Commands \u00A78------");
|
||||
for (Entry<String, CommandKamkeelBase> entry : parent.map.entrySet()) {
|
||||
sendMessage(sender, "\u00A77> " + "\u00A7e" + entry.getKey() + "\u00A78: \u00A77" + entry.getValue().getCommandUsage(sender));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
CommandKamkeelBase command = parent.getCommand(args);
|
||||
if(command == null){
|
||||
sendError(sender, "Unknown command " + args[0]);
|
||||
return;
|
||||
}
|
||||
CommandKamkeelBase command = parent.getCommand(args);
|
||||
if (command == null) {
|
||||
sendError(sender, "Unknown command " + args[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
if(command.subcommands.isEmpty()){
|
||||
sendMessage(sender, (command.getCommandUsage(sender)));
|
||||
return;
|
||||
}
|
||||
if (command.subcommands.isEmpty()) {
|
||||
sendMessage(sender, (command.getCommandUsage(sender)));
|
||||
return;
|
||||
}
|
||||
|
||||
Method m = null;
|
||||
if(args.length > 1){
|
||||
m = command.subcommands.get(args[1].toLowerCase());
|
||||
}
|
||||
if(m == null){
|
||||
sendMessage(sender, "\u00A78------ \u00A7a" + command.getCommandName().toUpperCase() + " SubCommands \u00A78------");
|
||||
sendMessage(sender, "\u00A77Usage: \u00A76" + command.getUsage());
|
||||
for(Entry<String, Method> entry : command.subcommands.entrySet()){
|
||||
sendMessage(sender, ("\u00A77> " + "\u00A7e" + entry.getKey() + "\u00A78: \u00A77" + entry.getValue().getAnnotation(SubCommand.class).desc()));
|
||||
}
|
||||
sendMessage(sender, ("\u00A78Permission:\u00A77 " + CommandKamkeel.getCommandPermission(command.getCommandName())));
|
||||
}
|
||||
else{
|
||||
sendMessage(sender, "\u00A78------ \u00A7b" + command.getCommandName().toUpperCase() + "." + args[1].toUpperCase() + " Command \u00A78------");
|
||||
SubCommand sc = m.getAnnotation(SubCommand.class);
|
||||
sendMessage(sender, ("\u00A77" + sc.desc()));
|
||||
if(!sc.usage().isEmpty())
|
||||
sendMessage(sender, ("\u00A77Usage: \u00A76" + sc.usage()));
|
||||
sendMessage(sender, ("\u00A78Permission:\u00A77 " + getSubCommandPermission(args[1])));
|
||||
}
|
||||
}
|
||||
Method m = null;
|
||||
if (args.length > 1) {
|
||||
m = command.subcommands.get(args[1].toLowerCase());
|
||||
}
|
||||
if (m == null) {
|
||||
sendMessage(sender, "\u00A78------ \u00A7a" + command.getCommandName().toUpperCase() + " SubCommands \u00A78------");
|
||||
sendMessage(sender, "\u00A77Usage: \u00A76" + command.getUsage());
|
||||
for (Entry<String, Method> entry : command.subcommands.entrySet()) {
|
||||
sendMessage(sender, ("\u00A77> " + "\u00A7e" + entry.getKey() + "\u00A78: \u00A77" + entry.getValue().getAnnotation(SubCommand.class).desc()));
|
||||
}
|
||||
sendMessage(sender, ("\u00A78Permission:\u00A77 " + CommandKamkeel.getCommandPermission(command.getCommandName())));
|
||||
} else {
|
||||
sendMessage(sender, "\u00A78------ \u00A7b" + command.getCommandName().toUpperCase() + "." + args[1].toUpperCase() + " Command \u00A78------");
|
||||
SubCommand sc = m.getAnnotation(SubCommand.class);
|
||||
sendMessage(sender, ("\u00A77" + sc.desc()));
|
||||
if (!sc.usage().isEmpty())
|
||||
sendMessage(sender, ("\u00A77Usage: \u00A76" + sc.usage()));
|
||||
sendMessage(sender, ("\u00A78Permission:\u00A77 " + getSubCommandPermission(args[1])));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,207 +27,206 @@ import static kamkeel.npcs.util.ColorUtil.sendResult;
|
||||
|
||||
public class NpcCommand extends CommandKamkeelBase {
|
||||
|
||||
public EntityNPCInterface selectedNpc;
|
||||
public EntityNPCInterface selectedNpc;
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "npc";
|
||||
}
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "npc";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "NPC operation";
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "NPC operation";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage() {
|
||||
return "<name> <command>";
|
||||
}
|
||||
@Override
|
||||
public String getUsage() {
|
||||
return "<name> <command>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean runSubCommands(){
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean runSubCommands() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
String npcname = args[0].replace("%", " ");
|
||||
String command = args[1];
|
||||
args = Arrays.copyOfRange(args, 2, args.length);
|
||||
if(command.equalsIgnoreCase("create")){
|
||||
args = ArrayUtils.add(args, 0, npcname);
|
||||
processSubCommand(sender, command, args);
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
String npcname = args[0].replace("%", " ");
|
||||
String command = args[1];
|
||||
args = Arrays.copyOfRange(args, 2, args.length);
|
||||
if (command.equalsIgnoreCase("create")) {
|
||||
args = ArrayUtils.add(args, 0, npcname);
|
||||
processSubCommand(sender, command, args);
|
||||
return;
|
||||
}
|
||||
|
||||
int x = sender.getPlayerCoordinates().posX;
|
||||
int y = sender.getPlayerCoordinates().posY;
|
||||
int z = sender.getPlayerCoordinates().posZ;
|
||||
List<EntityNPCInterface> list = getEntities(EntityNPCInterface.class, sender.getEntityWorld(), x, y, z, 80);
|
||||
for (EntityNPCInterface npc : list) {
|
||||
String name = npc.display.getName().replace(" ", "_");
|
||||
if (name.equalsIgnoreCase(npcname)){
|
||||
if(selectedNpc == null || selectedNpc.getDistanceSq(x, y, z) > npc.getDistanceSq(x, y, z))
|
||||
selectedNpc = npc;
|
||||
}
|
||||
}
|
||||
if(selectedNpc == null){
|
||||
sendError(sender, "Npc " + npcname + " was not found");
|
||||
return;
|
||||
}
|
||||
int x = sender.getPlayerCoordinates().posX;
|
||||
int y = sender.getPlayerCoordinates().posY;
|
||||
int z = sender.getPlayerCoordinates().posZ;
|
||||
List<EntityNPCInterface> list = getEntities(EntityNPCInterface.class, sender.getEntityWorld(), x, y, z, 80);
|
||||
for (EntityNPCInterface npc : list) {
|
||||
String name = npc.display.getName().replace(" ", "_");
|
||||
if (name.equalsIgnoreCase(npcname)) {
|
||||
if (selectedNpc == null || selectedNpc.getDistanceSq(x, y, z) > npc.getDistanceSq(x, y, z))
|
||||
selectedNpc = npc;
|
||||
}
|
||||
}
|
||||
if (selectedNpc == null) {
|
||||
sendError(sender, "Npc " + npcname + " was not found");
|
||||
return;
|
||||
}
|
||||
|
||||
processSubCommand(sender, command, args);
|
||||
selectedNpc = null;
|
||||
}
|
||||
processSubCommand(sender, command, args);
|
||||
selectedNpc = null;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Set Home (respawn place)",
|
||||
usage = "[x] [y] [z]"
|
||||
)
|
||||
public void home(ICommandSender sender, String[] args) {
|
||||
double posX = sender.getPlayerCoordinates().posX;
|
||||
double posY = sender.getPlayerCoordinates().posY;
|
||||
double posZ = sender.getPlayerCoordinates().posZ;
|
||||
@SubCommand(
|
||||
desc = "Set Home (respawn place)",
|
||||
usage = "[x] [y] [z]"
|
||||
)
|
||||
public void home(ICommandSender sender, String[] args) {
|
||||
double posX = sender.getPlayerCoordinates().posX;
|
||||
double posY = sender.getPlayerCoordinates().posY;
|
||||
double posZ = sender.getPlayerCoordinates().posZ;
|
||||
|
||||
if(args.length == 3){
|
||||
posX = CommandBase.func_110666_a(sender, selectedNpc.posX, args[0]);
|
||||
posY = CommandBase.func_110665_a(sender, selectedNpc.posY, args[1].trim(), 0, 0);
|
||||
posZ = CommandBase.func_110666_a(sender, selectedNpc.posZ, args[2]);
|
||||
}
|
||||
if (args.length == 3) {
|
||||
posX = CommandBase.func_110666_a(sender, selectedNpc.posX, args[0]);
|
||||
posY = CommandBase.func_110665_a(sender, selectedNpc.posY, args[1].trim(), 0, 0);
|
||||
posZ = CommandBase.func_110666_a(sender, selectedNpc.posZ, args[2]);
|
||||
}
|
||||
|
||||
selectedNpc.ais.startPos = new int[]{MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)};
|
||||
sendResult(sender, String.format("Set NPC \u00A7e%s\u00A77 Home to \u00A7b[%.1f] [%.1f] [%.1f]\u00A77", selectedNpc.display.name, posX, posY, posZ));
|
||||
}
|
||||
selectedNpc.ais.startPos = new int[]{MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)};
|
||||
sendResult(sender, String.format("Set NPC \u00A7e%s\u00A77 Home to \u00A7b[%.1f] [%.1f] [%.1f]\u00A77", selectedNpc.display.name, posX, posY, posZ));
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Set NPC visibility",
|
||||
usage = "[true/false/semi]"
|
||||
)
|
||||
public void visible(ICommandSender sender, String[] args){
|
||||
if(args.length < 1)
|
||||
return;
|
||||
boolean bo = args[0].equalsIgnoreCase("true");
|
||||
boolean semi = args[0].equalsIgnoreCase("semi");
|
||||
@SubCommand(
|
||||
desc = "Set NPC visibility",
|
||||
usage = "[true/false/semi]"
|
||||
)
|
||||
public void visible(ICommandSender sender, 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;
|
||||
|
||||
String[] list = new String[]{"True", "False", "Semi"};
|
||||
String[] list = new String[]{"True", "False", "Semi"};
|
||||
|
||||
if(current != selectedNpc.display.visible)
|
||||
selectedNpc.updateClient = true;
|
||||
if (current != selectedNpc.display.visible)
|
||||
selectedNpc.updateClient = true;
|
||||
|
||||
sendResult(sender, String.format("Set NPC \u00A7e%s\u00A77 Visibility to \u00A7b%s\u00A77", selectedNpc.display.name, list[selectedNpc.display.visible]));
|
||||
}
|
||||
sendResult(sender, String.format("Set NPC \u00A7e%s\u00A77 Visibility to \u00A7b%s\u00A77", selectedNpc.display.name, list[selectedNpc.display.visible]));
|
||||
}
|
||||
|
||||
@SubCommand(desc = "Delete an NPC")
|
||||
public void delete(ICommandSender sender, String[] args){
|
||||
selectedNpc.delete();
|
||||
}
|
||||
@SubCommand(desc = "Delete an NPC")
|
||||
public void delete(ICommandSender sender, String[] args) {
|
||||
selectedNpc.delete();
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Sets the owner of an follower/companion",
|
||||
usage = "[player]"
|
||||
)
|
||||
public void owner(ICommandSender sender, String[] args){
|
||||
if(args.length < 1){
|
||||
EntityPlayer player = null;
|
||||
if(selectedNpc.roleInterface instanceof RoleFollower)
|
||||
player = ((RoleFollower)selectedNpc.roleInterface).owner;
|
||||
@SubCommand(
|
||||
desc = "Sets the owner of an follower/companion",
|
||||
usage = "[player]"
|
||||
)
|
||||
public void owner(ICommandSender sender, 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)
|
||||
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, "NULL"));
|
||||
else
|
||||
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, player.getDisplayName()));
|
||||
}
|
||||
else{
|
||||
EntityPlayerMP player = null;
|
||||
try {
|
||||
player = CommandBase.getPlayer(sender, args[0]);
|
||||
} catch (PlayerNotFoundException e) {
|
||||
if (player == null)
|
||||
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, "NULL"));
|
||||
else
|
||||
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, player.getDisplayName()));
|
||||
} else {
|
||||
EntityPlayerMP player = null;
|
||||
try {
|
||||
player = CommandBase.getPlayer(sender, args[0]);
|
||||
} catch (PlayerNotFoundException e) {
|
||||
|
||||
}
|
||||
if(selectedNpc.roleInterface instanceof RoleFollower)
|
||||
((RoleFollower)selectedNpc.roleInterface).setOwner(player);
|
||||
}
|
||||
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);
|
||||
|
||||
if(player == null)
|
||||
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, "NULL"));
|
||||
else
|
||||
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, player.getDisplayName()));
|
||||
}
|
||||
}
|
||||
if (player == null)
|
||||
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, "NULL"));
|
||||
else
|
||||
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, player.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SubCommand(
|
||||
desc = "Set NPC name",
|
||||
usage = "[name]"
|
||||
)
|
||||
public void name(ICommandSender sender, String[] args){
|
||||
if(args.length < 1)
|
||||
return;
|
||||
@SubCommand(
|
||||
desc = "Set NPC name",
|
||||
usage = "[name]"
|
||||
)
|
||||
public void name(ICommandSender sender, 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];
|
||||
}
|
||||
|
||||
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Name set to \u00A7b%s\u00A77", selectedNpc.display.name, name));
|
||||
sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Name set to \u00A7b%s\u00A77", selectedNpc.display.name, name));
|
||||
|
||||
if(!selectedNpc.display.getName().equals(name)){
|
||||
selectedNpc.display.setName(name);
|
||||
selectedNpc.updateClient = true;
|
||||
}
|
||||
}
|
||||
if (!selectedNpc.display.getName().equals(name)) {
|
||||
selectedNpc.display.setName(name);
|
||||
selectedNpc.updateClient = true;
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Creates an NPC",
|
||||
usage = "[name]"
|
||||
)
|
||||
public void create(ICommandSender sender, String[] args) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) sender;
|
||||
World pw = player.getEntityWorld();
|
||||
EntityCustomNpc npc = new EntityCustomNpc(pw);
|
||||
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)};
|
||||
pw.spawnEntityInWorld(npc);
|
||||
npc.setHealth(npc.getMaxHealth());
|
||||
NoppesUtilServer.sendOpenGui(player, EnumGuiType.MainMenuDisplay, npc);
|
||||
}
|
||||
@SubCommand(
|
||||
desc = "Creates an NPC",
|
||||
usage = "[name]"
|
||||
)
|
||||
public void create(ICommandSender sender, String[] args) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) sender;
|
||||
World pw = player.getEntityWorld();
|
||||
EntityCustomNpc npc = new EntityCustomNpc(pw);
|
||||
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)};
|
||||
pw.spawnEntityInWorld(npc);
|
||||
npc.setHealth(npc.getMaxHealth());
|
||||
NoppesUtilServer.sendOpenGui(player, EnumGuiType.MainMenuDisplay, npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List addTabCompletionOptions(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());
|
||||
}
|
||||
@Override
|
||||
public List addTabCompletionOptions(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 null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel(){
|
||||
return 4;
|
||||
}
|
||||
@Override
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
public <T extends Entity> List<T> getEntities(Class<? extends T> cls, World world, int x, int y, int z, int range) {
|
||||
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1).expand(range, range, range);
|
||||
List<T> list = world.getEntitiesWithinAABB(cls, bb);
|
||||
return list;
|
||||
}
|
||||
public <T extends Entity> List<T> getEntities(Class<? extends T> cls, World world, int x, int y, int z, int range) {
|
||||
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1).expand(range, range, range);
|
||||
List<T> list = world.getEntitiesWithinAABB(cls, bb);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -14,22 +14,22 @@ import static kamkeel.npcs.util.ColorUtil.sendResult;
|
||||
|
||||
public class OverlayCommand extends CommandKamkeelBase {
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "overlay";
|
||||
}
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "overlay";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Overlay operations";
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Overlay operations";
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "set an overlay to a player",
|
||||
usage = "<player> <num> <texture>"
|
||||
desc = "set an overlay to a player",
|
||||
usage = "<player> <num> <texture>"
|
||||
)
|
||||
public void set(ICommandSender sender, String args[]) throws CommandException{
|
||||
String playername=args[0];
|
||||
public void set(ICommandSender sender, String args[]) throws CommandException {
|
||||
String playername = args[0];
|
||||
int overlayID;
|
||||
try {
|
||||
overlayID = Integer.parseInt(args[1]);
|
||||
@@ -42,7 +42,7 @@ public class OverlayCommand extends CommandKamkeelBase {
|
||||
sendError(sender, "Unknown player: " + playername);
|
||||
return;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
for (PlayerData playerdata : data) {
|
||||
SkinOverlay skinOverlay = new SkinOverlay(args[2]);
|
||||
playerdata.skinOverlays.add(overlayID, skinOverlay);
|
||||
playerdata.save();
|
||||
@@ -52,11 +52,11 @@ public class OverlayCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "remove an overlay from a player",
|
||||
usage = "<player> <num>"
|
||||
desc = "remove an overlay from a player",
|
||||
usage = "<player> <num>"
|
||||
)
|
||||
public void remove(ICommandSender sender, String args[]) throws CommandException{
|
||||
String playername=args[0];
|
||||
public void remove(ICommandSender sender, String args[]) throws CommandException {
|
||||
String playername = args[0];
|
||||
int overlayID;
|
||||
try {
|
||||
overlayID = Integer.parseInt(args[1]);
|
||||
@@ -69,13 +69,12 @@ public class OverlayCommand extends CommandKamkeelBase {
|
||||
sendError(sender, "Unknown player: " + playername);
|
||||
return;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
if(playerdata.skinOverlays.has(overlayID)){
|
||||
for (PlayerData playerdata : data) {
|
||||
if (playerdata.skinOverlays.has(overlayID)) {
|
||||
playerdata.skinOverlays.remove(overlayID);
|
||||
playerdata.save();
|
||||
sendResult(sender, String.format("Overlay removed to Player '\u00A7b%s\u00A77' on ID \u00A7d%d", playerdata.playername, overlayID));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sendError(sender, String.format("No overlay found for Player '\u00A7b%s\u00A74' on ID \u00A7d%d", playerdata.playername, overlayID));
|
||||
}
|
||||
return;
|
||||
@@ -83,11 +82,11 @@ public class OverlayCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "modify an overlay for a player",
|
||||
usage = "<player> <num> <blend/glow> <true/false>"
|
||||
desc = "modify an overlay for a player",
|
||||
usage = "<player> <num> <blend/glow> <true/false>"
|
||||
)
|
||||
public void modify(ICommandSender sender, String args[]) throws CommandException{
|
||||
String playername=args[0];
|
||||
public void modify(ICommandSender sender, String args[]) throws CommandException {
|
||||
String playername = args[0];
|
||||
int overlayID;
|
||||
try {
|
||||
overlayID = Integer.parseInt(args[1]);
|
||||
@@ -101,35 +100,34 @@ public class OverlayCommand extends CommandKamkeelBase {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!args[2].equalsIgnoreCase("blend") && !args[2].equalsIgnoreCase("glow")){
|
||||
if (!args[2].equalsIgnoreCase("blend") && !args[2].equalsIgnoreCase("glow")) {
|
||||
sendError(sender, "Unknown Entry: " + args[2]);
|
||||
return;
|
||||
}
|
||||
boolean isBlend = args[2].equalsIgnoreCase("blend");
|
||||
|
||||
if(!args[3].equalsIgnoreCase("true") && !args[3].equalsIgnoreCase("false")){
|
||||
if (!args[3].equalsIgnoreCase("true") && !args[3].equalsIgnoreCase("false")) {
|
||||
sendError(sender, "Unknown Bool: " + args[3]);
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isTrue = args[3].equalsIgnoreCase("true");
|
||||
|
||||
for(PlayerData playerdata : data){
|
||||
if(!playerdata.skinOverlays.has(overlayID)){
|
||||
for (PlayerData playerdata : data) {
|
||||
if (!playerdata.skinOverlays.has(overlayID)) {
|
||||
sendError(sender, String.format("Player '\u00A7b%s\u00A7c' does not have Overlay ID \u00A7d%d", playerdata.playername, overlayID));
|
||||
return;
|
||||
}
|
||||
|
||||
ISkinOverlay skinOverlay = playerdata.skinOverlays.get(overlayID);
|
||||
if(skinOverlay == null){
|
||||
if (skinOverlay == null) {
|
||||
sendError(sender, String.format("Player '\u00A7b%s\u00A7c' does not have Overlay ID \u00A7d%d", playerdata.playername, overlayID));
|
||||
return;
|
||||
}
|
||||
|
||||
if(isBlend){
|
||||
if (isBlend) {
|
||||
skinOverlay.setBlend(isTrue);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
skinOverlay.setGlow(isTrue);
|
||||
}
|
||||
playerdata.skinOverlays.add(overlayID, skinOverlay);
|
||||
@@ -140,17 +138,17 @@ public class OverlayCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "clears all overlays from a player",
|
||||
usage = "<player>"
|
||||
desc = "clears all overlays from a player",
|
||||
usage = "<player>"
|
||||
)
|
||||
public void clear(ICommandSender sender, String args[]) throws CommandException{
|
||||
String playername=args[0];
|
||||
public void clear(ICommandSender sender, String args[]) throws CommandException {
|
||||
String playername = args[0];
|
||||
List<PlayerData> data = PlayerDataController.Instance.getPlayersData(sender, playername);
|
||||
if (data.isEmpty()) {
|
||||
sendError(sender, "Unknown player: " + playername);
|
||||
return;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
for (PlayerData playerdata : data) {
|
||||
playerdata.skinOverlays.clear();
|
||||
playerdata.save();
|
||||
sendResult(sender, String.format("Overlays cleared from Player '\u00A7b%s\u00A77'", playerdata.playername));
|
||||
@@ -159,25 +157,24 @@ public class OverlayCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "List all overlays on a player",
|
||||
usage = "<player>"
|
||||
desc = "List all overlays on a player",
|
||||
usage = "<player>"
|
||||
)
|
||||
public void info(ICommandSender sender, String args[]) throws CommandException {
|
||||
String playername=args[0];
|
||||
String playername = args[0];
|
||||
|
||||
List<PlayerData> data = PlayerDataController.Instance.getPlayersData(sender, playername);
|
||||
if (data.isEmpty()) {
|
||||
sendError(sender, "Unknown player: " + playername);
|
||||
return;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
for (PlayerData playerdata : data) {
|
||||
sendResult(sender, "--------------------");
|
||||
if(playerdata.skinOverlays.size() == 0){
|
||||
if (playerdata.skinOverlays.size() == 0) {
|
||||
sendResult(sender, String.format("No Overlays found for Player '\u00A7b%s\u00A77'", playerdata.playername));
|
||||
}
|
||||
else {
|
||||
for(ISkinOverlay overlay : playerdata.skinOverlays.overlayList.values()){
|
||||
if(overlay != null){
|
||||
} else {
|
||||
for (ISkinOverlay overlay : playerdata.skinOverlays.overlayList.values()) {
|
||||
if (overlay != null) {
|
||||
sendResult(sender, String.format("%s", overlay.getTexture()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.constants.EnumProfileSync;
|
||||
import noppes.npcs.constants.EnumQuestRepeat;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.PlayerQuestController;
|
||||
import noppes.npcs.controllers.QuestController;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.controllers.data.Quest;
|
||||
@@ -25,22 +24,22 @@ import static kamkeel.npcs.util.ColorUtil.sendResult;
|
||||
|
||||
public class QuestCategoryCommand extends CommandKamkeelBase {
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "questcat";
|
||||
}
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "questcat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Quest Category operations";
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Quest Category operations";
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Find quest category id number by its name",
|
||||
usage = "<quest cat name>"
|
||||
desc = "Find quest category id number by its name",
|
||||
usage = "<quest cat name>"
|
||||
)
|
||||
public void id(ICommandSender sender, String args[]) throws CommandException {
|
||||
if(args.length == 0){
|
||||
if (args.length == 0) {
|
||||
sendError(sender, "Please provide a name for the quest category");
|
||||
return;
|
||||
}
|
||||
@@ -48,52 +47,51 @@ public class QuestCategoryCommand extends CommandKamkeelBase {
|
||||
String catName = String.join(" ", args).toLowerCase();
|
||||
final Collection<QuestCategory> questCats = QuestController.Instance.categories.values();
|
||||
int count = 0;
|
||||
for(QuestCategory cat : questCats){
|
||||
if(cat.getName().toLowerCase().contains(catName)){
|
||||
for (QuestCategory cat : questCats) {
|
||||
if (cat.getName().toLowerCase().contains(catName)) {
|
||||
sendResult(sender, String.format("Quest Cat \u00A7e%d\u00A77 - \u00A7c'%s'", cat.id, cat.getName()));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if(count == 0){
|
||||
if (count == 0) {
|
||||
sendResult(sender, String.format("No Quest Cat found with name: \u00A7c'%s'", catName));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SubCommand(
|
||||
desc = "Finish a quest category for a player",
|
||||
usage = "<player> <questcatid>"
|
||||
desc = "Finish a quest category for a player",
|
||||
usage = "<player> <questcatid>"
|
||||
)
|
||||
public void finish(ICommandSender sender, String args[]) throws CommandException{
|
||||
String playername=args[0];
|
||||
public void finish(ICommandSender sender, String args[]) throws CommandException {
|
||||
String playername = args[0];
|
||||
int questcatid;
|
||||
try {
|
||||
questcatid = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch (NumberFormatException ex) {
|
||||
sendError(sender, "QuestCatID must be an integer: " + args[1]);
|
||||
questcatid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, "QuestCatID must be an integer: " + args[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
List<PlayerData> data = PlayerDataController.Instance.getPlayersData(sender, playername);
|
||||
if (data.isEmpty()) {
|
||||
sendError(sender, String.format("Unknown player '%s'", playername));
|
||||
sendError(sender, String.format("Unknown player '%s'", playername));
|
||||
return;
|
||||
}
|
||||
|
||||
QuestCategory questCategory = QuestController.Instance.categories.get(questcatid);
|
||||
if (questCategory == null){
|
||||
sendError(sender, "Unknown QuestCatID: " + questcatid);
|
||||
if (questCategory == null) {
|
||||
sendError(sender, "Unknown QuestCatID: " + questcatid);
|
||||
return;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for(PlayerData playerdata : data){
|
||||
for (PlayerData playerdata : data) {
|
||||
count = 0;
|
||||
for(Quest quest : questCategory.quests.values()){
|
||||
for (Quest quest : questCategory.quests.values()) {
|
||||
playerdata.questData.activeQuests.remove(quest.id);
|
||||
long completeTime;
|
||||
if(quest.repeat == EnumQuestRepeat.RLDAILY || quest.repeat == EnumQuestRepeat.RLWEEKLY || quest.repeat == EnumQuestRepeat.RLCUSTOM){
|
||||
if (quest.repeat == EnumQuestRepeat.RLDAILY || quest.repeat == EnumQuestRepeat.RLWEEKLY || quest.repeat == EnumQuestRepeat.RLCUSTOM) {
|
||||
completeTime = System.currentTimeMillis();
|
||||
playerdata.questData.finishedQuests.put(quest.id, completeTime);
|
||||
} else {
|
||||
@@ -101,10 +99,11 @@ public class QuestCategoryCommand extends CommandKamkeelBase {
|
||||
playerdata.questData.finishedQuests.put(quest.id, completeTime);
|
||||
}
|
||||
|
||||
if(ConfigMain.ProfilesEnabled && playerdata.player != null && quest.profileOptions.enableOptions && quest.profileOptions.completeControl == EnumProfileSync.Shared)
|
||||
ProfileController.Instance.shareQuestCompletion(playerdata.player, quest.id, completeTime);;
|
||||
if (ConfigMain.ProfilesEnabled && playerdata.player != null && quest.profileOptions.enableOptions && quest.profileOptions.completeControl == EnumProfileSync.Shared)
|
||||
ProfileController.Instance.shareQuestCompletion(playerdata.player, quest.id, completeTime);
|
||||
;
|
||||
|
||||
if(playerdata.player != null){
|
||||
if (playerdata.player != null) {
|
||||
AchievementPacket.sendAchievement((EntityPlayerMP) playerdata.player, false, "quest.completed", quest.title);
|
||||
ChatAlertPacket.sendChatAlert((EntityPlayerMP) playerdata.player, "quest.completed", ": ", quest.title);
|
||||
}
|
||||
@@ -119,16 +118,15 @@ public class QuestCategoryCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Stop a quest category for a players active quests",
|
||||
usage = "<player> <questcatid>"
|
||||
desc = "Stop a quest category for a players active quests",
|
||||
usage = "<player> <questcatid>"
|
||||
)
|
||||
public void stop(ICommandSender sender, String args[]) throws CommandException{
|
||||
String playername=args[0];
|
||||
public void stop(ICommandSender sender, String args[]) throws CommandException {
|
||||
String playername = args[0];
|
||||
int questcatid;
|
||||
try {
|
||||
questcatid = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch (NumberFormatException ex) {
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, "QuestCatID must be an integer: " + args[1]);
|
||||
return;
|
||||
}
|
||||
@@ -140,15 +138,15 @@ public class QuestCategoryCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
QuestCategory questCategory = QuestController.Instance.categories.get(questcatid);
|
||||
if (questCategory == null){
|
||||
if (questCategory == null) {
|
||||
sendError(sender, "Unknown QuestCatID: " + questcatid);
|
||||
return;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for(PlayerData playerdata : data){
|
||||
for(Quest quest : questCategory.quests.values()){
|
||||
if(playerdata.questData.activeQuests.containsKey(quest.id)){
|
||||
for (PlayerData playerdata : data) {
|
||||
for (Quest quest : questCategory.quests.values()) {
|
||||
if (playerdata.questData.activeQuests.containsKey(quest.id)) {
|
||||
playerdata.questData.activeQuests.remove(quest.id);
|
||||
count++;
|
||||
}
|
||||
@@ -162,16 +160,15 @@ public class QuestCategoryCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Start a quest category for a player",
|
||||
usage = "<player> <questcatid>"
|
||||
desc = "Start a quest category for a player",
|
||||
usage = "<player> <questcatid>"
|
||||
)
|
||||
public void start(ICommandSender sender, String args[]) throws CommandException{
|
||||
String playername=args[0];
|
||||
public void start(ICommandSender sender, String args[]) throws CommandException {
|
||||
String playername = args[0];
|
||||
int questcatid;
|
||||
try {
|
||||
questcatid = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch (NumberFormatException ex) {
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, "QuestCatID must be an integer: " + args[1]);
|
||||
return;
|
||||
}
|
||||
@@ -183,20 +180,20 @@ public class QuestCategoryCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
QuestCategory questCategory = QuestController.Instance.categories.get(questcatid);
|
||||
if (questCategory == null){
|
||||
if (questCategory == null) {
|
||||
sendError(sender, "Unknown QuestCatID: " + questcatid);
|
||||
return;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for(PlayerData playerdata : data){
|
||||
for(Quest quest : questCategory.quests.values()){
|
||||
if(!playerdata.questData.activeQuests.containsKey(quest.id)){
|
||||
for (PlayerData playerdata : data) {
|
||||
for (Quest quest : questCategory.quests.values()) {
|
||||
if (!playerdata.questData.activeQuests.containsKey(quest.id)) {
|
||||
QuestData questData = new QuestData(quest);
|
||||
playerdata.questData.activeQuests.put(quest.id, questData);
|
||||
count++;
|
||||
|
||||
if(playerdata.player != null && questData.sendAlerts){
|
||||
if (playerdata.player != null && questData.sendAlerts) {
|
||||
AchievementPacket.sendAchievement((EntityPlayerMP) playerdata.player, false, "quest.newquest", quest.title);
|
||||
ChatAlertPacket.sendChatAlert((EntityPlayerMP) playerdata.player, "quest.newquest", ": ", quest.title);
|
||||
}
|
||||
@@ -212,16 +209,15 @@ public class QuestCategoryCommand extends CommandKamkeelBase {
|
||||
|
||||
|
||||
@SubCommand(
|
||||
desc = "Remove a quest cat from active/finished",
|
||||
usage = "<player> <questcatid>"
|
||||
desc = "Remove a quest cat from active/finished",
|
||||
usage = "<player> <questcatid>"
|
||||
)
|
||||
public void remove(ICommandSender sender, String args[]) throws CommandException{
|
||||
String playername=args[0];
|
||||
public void remove(ICommandSender sender, String args[]) throws CommandException {
|
||||
String playername = args[0];
|
||||
int questcatid;
|
||||
try {
|
||||
questcatid = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch (NumberFormatException ex) {
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, "QuestCatID must be an integer: " + args[1]);
|
||||
return;
|
||||
}
|
||||
@@ -233,14 +229,14 @@ public class QuestCategoryCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
QuestCategory questCategory = QuestController.Instance.categories.get(questcatid);
|
||||
if (questCategory == null){
|
||||
if (questCategory == null) {
|
||||
sendError(sender, "Unknown QuestCatID: " + questcatid);
|
||||
return;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for(PlayerData playerdata : data){
|
||||
for(Quest quest : questCategory.quests.values()){
|
||||
for (PlayerData playerdata : data) {
|
||||
for (Quest quest : questCategory.quests.values()) {
|
||||
playerdata.questData.activeQuests.remove(quest.id);
|
||||
playerdata.questData.finishedQuests.remove(quest.id);
|
||||
count++;
|
||||
|
||||
@@ -29,25 +29,25 @@ import static kamkeel.npcs.util.ColorUtil.sendResult;
|
||||
|
||||
public class QuestCommand extends CommandKamkeelBase {
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "quest";
|
||||
}
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "quest";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Quest operations";
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Quest operations";
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Start a quest",
|
||||
usage = "<player> <quest>"
|
||||
desc = "Start a quest",
|
||||
usage = "<player> <quest>"
|
||||
)
|
||||
public void start(ICommandSender sender, String[] args) throws CommandException {
|
||||
String playername = args[0];
|
||||
int questid;
|
||||
try {
|
||||
questid = Integer.parseInt(args[1]);
|
||||
questid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, "QuestID must be an integer: " + args[1]);
|
||||
return;
|
||||
@@ -61,16 +61,16 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
Quest quest = QuestController.Instance.quests.get(questid);
|
||||
if (quest == null){
|
||||
sendError(sender, "Unknown QuestID: " + questid);
|
||||
if (quest == null) {
|
||||
sendError(sender, "Unknown QuestID: " + questid);
|
||||
return;
|
||||
}
|
||||
|
||||
for(PlayerData playerdata : data){
|
||||
QuestData questdata = new QuestData(quest);
|
||||
playerdata.questData.activeQuests.put(questid, questdata);
|
||||
for (PlayerData playerdata : data) {
|
||||
QuestData questdata = new QuestData(quest);
|
||||
playerdata.questData.activeQuests.put(questid, questdata);
|
||||
playerdata.save();
|
||||
if(playerdata.player != null && questdata.sendAlerts){
|
||||
if (playerdata.player != null && questdata.sendAlerts) {
|
||||
AchievementPacket.sendAchievement((EntityPlayerMP) playerdata.player, false, "quest.newquest", quest.title);
|
||||
ChatAlertPacket.sendChatAlert((EntityPlayerMP) playerdata.player, "quest.newquest", ": ", quest.title);
|
||||
}
|
||||
@@ -80,95 +80,14 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Finish a quest",
|
||||
usage = "<player> <quest>"
|
||||
desc = "Finish a quest",
|
||||
usage = "<player> <quest>"
|
||||
)
|
||||
public void finish(ICommandSender sender, String args[]) throws CommandException{
|
||||
String playername=args[0];
|
||||
public void finish(ICommandSender sender, String args[]) throws CommandException {
|
||||
String playername = args[0];
|
||||
int questid;
|
||||
try {
|
||||
questid = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch (NumberFormatException ex) {
|
||||
sendError(sender, "QuestID must be an integer: " + args[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
List<PlayerData> data = PlayerDataController.Instance.getPlayersData(sender, playername);
|
||||
if (data.isEmpty()) {
|
||||
sendError(sender, String.format("Unknown player '%s'", playername));
|
||||
return;
|
||||
}
|
||||
|
||||
Quest quest = QuestController.Instance.quests.get(questid);
|
||||
if (quest == null){
|
||||
sendError(sender, "Unknown QuestID: " + questid);
|
||||
return;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.questData.activeQuests.remove(questid);
|
||||
long completeTime;
|
||||
if(quest.repeat == EnumQuestRepeat.RLDAILY || quest.repeat == EnumQuestRepeat.RLWEEKLY || quest.repeat == EnumQuestRepeat.RLCUSTOM){
|
||||
completeTime = System.currentTimeMillis();
|
||||
playerdata.questData.finishedQuests.put(quest.id, completeTime);
|
||||
} else {
|
||||
completeTime = sender.getEntityWorld().getTotalWorldTime();
|
||||
playerdata.questData.finishedQuests.put(quest.id, completeTime);
|
||||
}
|
||||
|
||||
if(ConfigMain.ProfilesEnabled && playerdata.player != null && quest.profileOptions.enableOptions && quest.profileOptions.completeControl == EnumProfileSync.Shared)
|
||||
ProfileController.Instance.shareQuestCompletion(playerdata.player, quest.id, completeTime);
|
||||
|
||||
playerdata.save();
|
||||
if(playerdata.player != null){
|
||||
AchievementPacket.sendAchievement((EntityPlayerMP) playerdata.player, false, "quest.completed", quest.title);
|
||||
ChatAlertPacket.sendChatAlert((EntityPlayerMP) playerdata.player, "quest.completed", ": ", quest.title);
|
||||
}
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Finished Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername));
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Stop a started quest",
|
||||
usage = "<player> <quest>"
|
||||
)
|
||||
public void stop(ICommandSender sender, String[] args) throws CommandException {
|
||||
String playername=args[0];
|
||||
int questid;
|
||||
try {
|
||||
questid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, "QuestID must be an integer: " + args[1]);
|
||||
return;
|
||||
}
|
||||
List<PlayerData> data = PlayerDataController.Instance.getPlayersData(sender, playername);
|
||||
if (data.isEmpty()) {
|
||||
sendError(sender, String.format("Unknown player '%s'", playername));
|
||||
return;
|
||||
}
|
||||
Quest quest = QuestController.Instance.quests.get(questid);
|
||||
if (quest == null){
|
||||
sendError(sender, "Unknown QuestID: " + questid);
|
||||
return;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.questData.activeQuests.remove(questid);
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Stopped Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername));
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Removes a quest from finished and active quests",
|
||||
usage = "<player> <quest>"
|
||||
)
|
||||
public void remove(ICommandSender sender, String[] args) throws CommandException {
|
||||
String playername=args[0];
|
||||
int questid;
|
||||
try {
|
||||
questid = Integer.parseInt(args[1]);
|
||||
questid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, "QuestID must be an integer: " + args[1]);
|
||||
return;
|
||||
@@ -181,14 +100,94 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
Quest quest = QuestController.Instance.quests.get(questid);
|
||||
if (quest == null){
|
||||
sendError(sender, "Unknown QuestID");
|
||||
if (quest == null) {
|
||||
sendError(sender, "Unknown QuestID: " + questid);
|
||||
return;
|
||||
}
|
||||
for (PlayerData playerdata : data) {
|
||||
playerdata.questData.activeQuests.remove(questid);
|
||||
long completeTime;
|
||||
if (quest.repeat == EnumQuestRepeat.RLDAILY || quest.repeat == EnumQuestRepeat.RLWEEKLY || quest.repeat == EnumQuestRepeat.RLCUSTOM) {
|
||||
completeTime = System.currentTimeMillis();
|
||||
playerdata.questData.finishedQuests.put(quest.id, completeTime);
|
||||
} else {
|
||||
completeTime = sender.getEntityWorld().getTotalWorldTime();
|
||||
playerdata.questData.finishedQuests.put(quest.id, completeTime);
|
||||
}
|
||||
|
||||
if (ConfigMain.ProfilesEnabled && playerdata.player != null && quest.profileOptions.enableOptions && quest.profileOptions.completeControl == EnumProfileSync.Shared)
|
||||
ProfileController.Instance.shareQuestCompletion(playerdata.player, quest.id, completeTime);
|
||||
|
||||
playerdata.save();
|
||||
if (playerdata.player != null) {
|
||||
AchievementPacket.sendAchievement((EntityPlayerMP) playerdata.player, false, "quest.completed", quest.title);
|
||||
ChatAlertPacket.sendChatAlert((EntityPlayerMP) playerdata.player, "quest.completed", ": ", quest.title);
|
||||
}
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Finished Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername));
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Stop a started quest",
|
||||
usage = "<player> <quest>"
|
||||
)
|
||||
public void stop(ICommandSender sender, String[] args) throws CommandException {
|
||||
String playername = args[0];
|
||||
int questid;
|
||||
try {
|
||||
questid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, "QuestID must be an integer: " + args[1]);
|
||||
return;
|
||||
}
|
||||
List<PlayerData> data = PlayerDataController.Instance.getPlayersData(sender, playername);
|
||||
if (data.isEmpty()) {
|
||||
sendError(sender, String.format("Unknown player '%s'", playername));
|
||||
return;
|
||||
}
|
||||
Quest quest = QuestController.Instance.quests.get(questid);
|
||||
if (quest == null) {
|
||||
sendError(sender, "Unknown QuestID: " + questid);
|
||||
return;
|
||||
}
|
||||
for (PlayerData playerdata : data) {
|
||||
playerdata.questData.activeQuests.remove(questid);
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Stopped Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername));
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Removes a quest from finished and active quests",
|
||||
usage = "<player> <quest>"
|
||||
)
|
||||
public void remove(ICommandSender sender, String[] args) throws CommandException {
|
||||
String playername = args[0];
|
||||
int questid;
|
||||
try {
|
||||
questid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, "QuestID must be an integer: " + args[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.questData.activeQuests.remove(questid);
|
||||
playerdata.questData.finishedQuests.remove(questid);
|
||||
List<PlayerData> data = PlayerDataController.Instance.getPlayersData(sender, playername);
|
||||
if (data.isEmpty()) {
|
||||
sendError(sender, String.format("Unknown player '%s'", playername));
|
||||
return;
|
||||
}
|
||||
|
||||
Quest quest = QuestController.Instance.quests.get(questid);
|
||||
if (quest == null) {
|
||||
sendError(sender, "Unknown QuestID");
|
||||
return;
|
||||
}
|
||||
|
||||
for (PlayerData playerdata : data) {
|
||||
playerdata.questData.activeQuests.remove(questid);
|
||||
playerdata.questData.finishedQuests.remove(questid);
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Removed Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername));
|
||||
@@ -196,7 +195,7 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc= "Get/Set objectives for quests progress",
|
||||
desc = "Get/Set objectives for quests progress",
|
||||
usage = "<player> <quest> [objective] [value]"
|
||||
)
|
||||
public void objective(ICommandSender sender, String[] args) throws CommandException {
|
||||
@@ -210,13 +209,13 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
Quest quest = QuestController.Instance.quests.get(questid);
|
||||
if (quest == null){
|
||||
if (quest == null) {
|
||||
sendError(sender, "Unknown QuestID");
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
if (data == null){
|
||||
if (data == null) {
|
||||
sendError(sender, "No PlayerData found for:" + player);
|
||||
return;
|
||||
}
|
||||
@@ -224,21 +223,21 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
Party party = data.getPlayerParty();
|
||||
boolean partyValid = party != null && party.getQuest() != null && party.getQuest().getId() == quest.id;
|
||||
|
||||
if(!partyValid && !data.questData.activeQuests.containsKey(quest.id)) {
|
||||
if (!partyValid && !data.questData.activeQuests.containsKey(quest.id)) {
|
||||
sendError(sender, "Player does not have quest active");
|
||||
return;
|
||||
}
|
||||
|
||||
IQuestObjective[] objectives;
|
||||
if(partyValid)
|
||||
if (partyValid)
|
||||
objectives = quest.questInterface.getPartyObjectives(party);
|
||||
else
|
||||
objectives = quest.questInterface.getObjectives(player);
|
||||
|
||||
if(args.length <= 2) {
|
||||
if(partyValid)
|
||||
if (args.length <= 2) {
|
||||
if (partyValid)
|
||||
sendResult(sender, "For Party: ");
|
||||
for(IQuestObjective ob : objectives) {
|
||||
for (IQuestObjective ob : objectives) {
|
||||
sendResult(sender, ob.getText());
|
||||
}
|
||||
return;
|
||||
@@ -252,12 +251,12 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
return;
|
||||
}
|
||||
|
||||
if(objective < 0 || objective >= objectives.length) {
|
||||
if (objective < 0 || objective >= objectives.length) {
|
||||
sendError(sender, "Invalid objective number was given");
|
||||
return;
|
||||
}
|
||||
|
||||
if(args.length <= 3) {
|
||||
if (args.length <= 3) {
|
||||
sendResult(sender, objectives[objective].getText());
|
||||
return;
|
||||
}
|
||||
@@ -272,11 +271,11 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
return;
|
||||
}
|
||||
|
||||
if(s.startsWith("-") || s.startsWith("+")) {
|
||||
if (s.startsWith("-") || s.startsWith("+")) {
|
||||
value = ValueUtil.CorrectInt(object.getProgress() + value, 0, object.getMaxProgress());
|
||||
}
|
||||
|
||||
if(partyValid)
|
||||
if (partyValid)
|
||||
object.setPlayerProgress(player.getCommandSenderName(), value);
|
||||
else
|
||||
object.setProgress(value);
|
||||
@@ -284,11 +283,11 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Find quest id number by its name",
|
||||
usage = "<questName>"
|
||||
desc = "Find quest id number by its name",
|
||||
usage = "<questName>"
|
||||
)
|
||||
public void id(ICommandSender sender, String args[]) throws CommandException {
|
||||
if(args.length == 0){
|
||||
if (args.length == 0) {
|
||||
sendError(sender, "Please provide a name for the quest");
|
||||
return;
|
||||
}
|
||||
@@ -296,23 +295,23 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
String catName = String.join(" ", args).toLowerCase();
|
||||
final Collection<Quest> quests = QuestController.Instance.quests.values();
|
||||
int count = 0;
|
||||
for(Quest quest : quests){
|
||||
if(quest.getName().toLowerCase().contains(catName)){
|
||||
for (Quest quest : quests) {
|
||||
if (quest.getName().toLowerCase().contains(catName)) {
|
||||
sendResult(sender, String.format("Quest \u00A7e%d\u00A77 - \u00A7c'%s'", quest.id, quest.getName()));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if(count == 0){
|
||||
if (count == 0) {
|
||||
sendResult(sender, String.format("No Quest found with name: \u00A7c'%s'", catName));
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Find prerequisite quests for an id",
|
||||
usage = "<questId>"
|
||||
desc = "Find prerequisite quests for an id",
|
||||
usage = "<questId>"
|
||||
)
|
||||
public void prereq(ICommandSender sender, String args[]) throws CommandException {
|
||||
if(args.length == 0){
|
||||
if (args.length == 0) {
|
||||
sendError(sender, "Please provide an id for the quest");
|
||||
return;
|
||||
}
|
||||
@@ -326,7 +325,7 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
Quest quest = QuestController.Instance.quests.get(questid);
|
||||
if (quest == null){
|
||||
if (quest == null) {
|
||||
sendError(sender, "Unknown QuestID");
|
||||
return;
|
||||
}
|
||||
@@ -334,25 +333,25 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
sendResult(sender, "Prerequisites:");
|
||||
sendResult(sender, "--------------------");
|
||||
boolean foundOne = false;
|
||||
for(Quest allQuest : quests){
|
||||
if(allQuest.nextQuestid == questid){
|
||||
for (Quest allQuest : quests) {
|
||||
if (allQuest.nextQuestid == questid) {
|
||||
foundOne = true;
|
||||
sendResult(sender, String.format("Quest %d: \u00A7a'%s'", allQuest.id, allQuest.title));
|
||||
}
|
||||
}
|
||||
|
||||
if(!foundOne){
|
||||
if (!foundOne) {
|
||||
sendResult(sender, String.format("No Prerequisites found for Quest \u00A7c%d", questid));
|
||||
}
|
||||
sendResult(sender, "--------------------");
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Quick info on a quest",
|
||||
usage = "<questId>"
|
||||
desc = "Quick info on a quest",
|
||||
usage = "<questId>"
|
||||
)
|
||||
public void info(ICommandSender sender, String args[]) throws CommandException {
|
||||
if(args.length == 0){
|
||||
if (args.length == 0) {
|
||||
sendError(sender, "Please provide an id for the quest");
|
||||
return;
|
||||
}
|
||||
@@ -366,7 +365,7 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
Quest quest = QuestController.Instance.quests.get(questid);
|
||||
if (quest == null){
|
||||
if (quest == null) {
|
||||
sendError(sender, "Unknown QuestID");
|
||||
return;
|
||||
}
|
||||
@@ -377,21 +376,21 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
sendResult(sender, String.format("Type: \u00A76%s", quest.type.toString()));
|
||||
sendResult(sender, String.format("Repeatable: \u00A76%s", quest.repeat.toString()));
|
||||
sendResult(sender, String.format("Complete: \u00A76%s", quest.completion.toString()));
|
||||
if(quest.completion == EnumQuestCompletion.Npc){
|
||||
if (quest.completion == EnumQuestCompletion.Npc) {
|
||||
sendResult(sender, String.format("NPC: \u00A76%s", quest.completerNpc));
|
||||
}
|
||||
if(quest.nextQuestid != -1){
|
||||
if (quest.nextQuestid != -1) {
|
||||
sendResult(sender, String.format("Next Quest ID: \u00A7c%d", quest.nextQuestid));
|
||||
}
|
||||
sendResult(sender, "--------------------");
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="reload quests from disk",
|
||||
permission = 4
|
||||
desc = "reload quests from disk",
|
||||
permission = 4
|
||||
)
|
||||
public void reload(ICommandSender sender, String args[]){
|
||||
new QuestController().load();
|
||||
public void reload(ICommandSender sender, String args[]) {
|
||||
new QuestController().load();
|
||||
SyncController.syncAllQuests();
|
||||
sendResult(sender, "Quests Reloaded");
|
||||
}
|
||||
|
||||
@@ -11,33 +11,33 @@ public class ScriptCommand extends CommandKamkeelBase {
|
||||
|
||||
@SubCommand(desc = "Reload scripts data and folders.")
|
||||
public Boolean reload(ICommandSender sender, String args[]) {
|
||||
ScriptController.Instance.loadCategories();
|
||||
ScriptController.Instance.loadCategories();
|
||||
|
||||
if(ScriptController.Instance.loadPlayerScripts())
|
||||
sendResult(sender, "Reload player scripts successfully");
|
||||
else
|
||||
sendError(sender, "Failed reloading player scripts");
|
||||
if (ScriptController.Instance.loadPlayerScripts())
|
||||
sendResult(sender, "Reload player scripts successfully");
|
||||
else
|
||||
sendError(sender, "Failed reloading player scripts");
|
||||
|
||||
if(ScriptController.Instance.loadForgeScripts())
|
||||
sendResult(sender, "Reload forge scripts successfully");
|
||||
else
|
||||
sendError(sender, "Failed reloading forge scripts");
|
||||
if (ScriptController.Instance.loadForgeScripts())
|
||||
sendResult(sender, "Reload forge scripts successfully");
|
||||
else
|
||||
sendError(sender, "Failed reloading forge scripts");
|
||||
|
||||
if(ScriptController.Instance.loadStoredData())
|
||||
sendResult(sender, "Reload stored data successfully");
|
||||
else
|
||||
sendError(sender, "Failed reloading stored data");
|
||||
return true;
|
||||
if (ScriptController.Instance.loadStoredData())
|
||||
sendResult(sender, "Reload stored data successfully");
|
||||
else
|
||||
sendError(sender, "Failed reloading stored data");
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "script";
|
||||
}
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "script";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Commands for scripts";
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Commands for scripts";
|
||||
}
|
||||
}
|
||||
@@ -23,118 +23,117 @@ import java.util.*;
|
||||
import static kamkeel.npcs.util.ColorUtil.sendResult;
|
||||
|
||||
public class SlayCommand extends CommandKamkeelBase {
|
||||
public Map<String, Class<?>> SlayMap = new LinkedHashMap<String, Class<?>>();
|
||||
public Map<String, Class<?>> SlayMap = new LinkedHashMap<String, Class<?>>();
|
||||
|
||||
public SlayCommand(){
|
||||
public SlayCommand() {
|
||||
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");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "slay";
|
||||
}
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "slay";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Kills given entity within range. Tab to see options.";
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Kills given entity within range. Tab to see options.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage(){
|
||||
return "<type>.. [range]";
|
||||
}
|
||||
@Override
|
||||
public String getUsage() {
|
||||
return "<type>.. [range]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
EntityPlayerMP player = (EntityPlayerMP) sender;
|
||||
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){
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
EntityPlayerMP player = (EntityPlayerMP) sender;
|
||||
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<? extends Entity> list = sender.getEntityWorld().getEntitiesWithinAABB(EntityLivingBase.class, box);
|
||||
}
|
||||
AxisAlignedBB box = player.boundingBox.expand(range, range, range);
|
||||
List<? extends Entity> list = sender.getEntityWorld().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 = sender.getEntityWorld().getEntitiesWithinAABB(EntityXPOrb.class, box);
|
||||
for(Entity entity : list){
|
||||
entity.isDead = true;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if(toDelete.contains(EntityItem.class)){
|
||||
list = sender.getEntityWorld().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 = sender.getEntityWorld().getEntitiesWithinAABB(EntityXPOrb.class, box);
|
||||
for (Entity entity : list) {
|
||||
entity.isDead = true;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (toDelete.contains(EntityItem.class)) {
|
||||
list = sender.getEntityWorld().getEntitiesWithinAABB(EntityItem.class, box);
|
||||
for (Entity entity : list) {
|
||||
entity.isDead = true;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
sendResult(sender, count + " entities deleted");
|
||||
}
|
||||
sendResult(sender, count + " entities deleted");
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
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 addTabCompletionOptions(ICommandSender sender, String[] args){
|
||||
return getListOfStringsMatchingLastWord(args, SlayMap.keySet().toArray(new String[SlayMap.size()]));
|
||||
}
|
||||
@Override
|
||||
public List addTabCompletionOptions(ICommandSender sender, String[] args) {
|
||||
return getListOfStringsMatchingLastWord(args, SlayMap.keySet().toArray(new String[SlayMap.size()]));
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ import static kamkeel.npcs.util.ColorUtil.sendMessage;
|
||||
public class CommandHelpProfile extends CommandProfileBase {
|
||||
private CommandProfile parent;
|
||||
|
||||
public CommandHelpProfile(CommandProfile parent){
|
||||
public CommandHelpProfile(CommandProfile parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@@ -31,9 +31,9 @@ public class CommandHelpProfile extends CommandProfileBase {
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
if(args.length == 0){
|
||||
if (args.length == 0) {
|
||||
sendMessage(sender, "\u00A78------ \u00A7aProfile Commands \u00A78------");
|
||||
for(Entry<String, CommandProfileBase> entry : parent.map.entrySet()){
|
||||
for (Entry<String, CommandProfileBase> entry : parent.map.entrySet()) {
|
||||
sendMessage(sender, "\u00A77> " + "\u00A7e" + entry.getKey() + "\u00A78: \u00A77"
|
||||
+ entry.getValue().getCommandUsage(sender));
|
||||
}
|
||||
@@ -41,50 +41,49 @@ public class CommandHelpProfile extends CommandProfileBase {
|
||||
}
|
||||
|
||||
CommandProfileBase command = parent.getCommand(args);
|
||||
if(command == null){
|
||||
if (command == null) {
|
||||
sendError(sender, "Unknown command " + args[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
if(command.subcommands.isEmpty()){
|
||||
if (command.subcommands.isEmpty()) {
|
||||
sendMessage(sender, (command.getCommandUsage(sender)));
|
||||
return;
|
||||
}
|
||||
|
||||
Method m = null;
|
||||
if(args.length > 1){
|
||||
if (args.length > 1) {
|
||||
m = command.subcommands.get(args[1].toLowerCase());
|
||||
}
|
||||
if(m == null){
|
||||
if (m == null) {
|
||||
sendMessage(sender, "\u00A78------ \u00A7a" + command.getCommandName().toUpperCase()
|
||||
+ " SubCommands \u00A78------");
|
||||
sendMessage(sender, "\u00A77Usage: \u00A76" + command.getUsage());
|
||||
for(Entry<String, Method> entry : command.subcommands.entrySet()){
|
||||
for (Entry<String, Method> entry : command.subcommands.entrySet()) {
|
||||
SubCommand sc = entry.getValue().getAnnotation(SubCommand.class);
|
||||
// For players, only list subcommands if they have permission; for console, show all.
|
||||
if(!(sender instanceof EntityPlayer) || command.canSendCommand(sender, sc, entry.getKey())){
|
||||
if (!(sender instanceof EntityPlayer) || command.canSendCommand(sender, sc, entry.getKey())) {
|
||||
sendMessage(sender, ("\u00A77> "
|
||||
+ "\u00A7e" + entry.getKey()
|
||||
+ "\u00A78: \u00A77" + sc.desc()));
|
||||
}
|
||||
}
|
||||
// Show permission node only if sender is console or has permission.
|
||||
if(!(sender instanceof EntityPlayer) ||
|
||||
CustomNpcsPermissions.hasPermission((EntityPlayer)sender, CustomNpcsPermissions.PROFILE_ADMIN)){
|
||||
if (!(sender instanceof EntityPlayer) ||
|
||||
CustomNpcsPermissions.hasPermission((EntityPlayer) sender, CustomNpcsPermissions.PROFILE_ADMIN)) {
|
||||
sendMessage(sender, ("\u00A78Permission:\u00A77 "
|
||||
+ CommandProfile.getCommandPermission(command.getCommandName())));
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
sendMessage(sender, "\u00A78------ \u00A7b" + command.getCommandName().toUpperCase()
|
||||
+ "." + args[1].toUpperCase() + " Command \u00A78------");
|
||||
SubCommand sc = m.getAnnotation(SubCommand.class);
|
||||
sendMessage(sender, ("\u00A77" + sc.desc()));
|
||||
if(!sc.usage().isEmpty()){
|
||||
if (!sc.usage().isEmpty()) {
|
||||
sendMessage(sender, ("\u00A77Usage: \u00A76" + sc.usage()));
|
||||
}
|
||||
if(!(sender instanceof EntityPlayer) ||
|
||||
CustomNpcsPermissions.hasPermission((EntityPlayer)sender, CustomNpcsPermissions.PROFILE_ADMIN)){
|
||||
if (!(sender instanceof EntityPlayer) ||
|
||||
CustomNpcsPermissions.hasPermission((EntityPlayer) sender, CustomNpcsPermissions.PROFILE_ADMIN)) {
|
||||
sendMessage(sender, ("\u00A78Permission:\u00A77 "
|
||||
+ getSubCommandPermission(args[1])));
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@ import java.util.Map;
|
||||
|
||||
public class CommandProfile extends CommandBase {
|
||||
|
||||
public Map<String, CommandProfileBase> map = new HashMap<String, CommandProfileBase>();
|
||||
public CommandHelpProfile help = new CommandHelpProfile(this);
|
||||
public String[] alias = {"profile"};
|
||||
public Map<String, CommandProfileBase> map = new HashMap<String, CommandProfileBase>();
|
||||
public CommandHelpProfile help = new CommandHelpProfile(this);
|
||||
public String[] alias = {"profile"};
|
||||
|
||||
public CommandProfile(){
|
||||
registerCommand(help);
|
||||
public CommandProfile() {
|
||||
registerCommand(help);
|
||||
registerCommand(new CommandProfileChange());
|
||||
registerCommand(new CommandProfileCreate());
|
||||
registerCommand(new CommandProfileRemove());
|
||||
@@ -29,120 +29,119 @@ public class CommandProfile extends CommandBase {
|
||||
registerCommand(new CommandProfileRegion());
|
||||
registerCommand(new CommandProfileList());
|
||||
registerCommand(new CommandProfileRename());
|
||||
}
|
||||
|
||||
public void registerCommand(CommandProfileBase command){
|
||||
String name = command.getCommandName().toLowerCase();
|
||||
if(map.containsKey(name))
|
||||
throw new CustomNPCsException("Already a subcommand with the name: " + name);
|
||||
map.put(name, command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "profile";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getCommandAliases()
|
||||
{
|
||||
return Arrays.asList(alias);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender sender) {
|
||||
return "Use as /profile subcommand";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
if(args.length == 0){
|
||||
help.processCommand(sender, args);
|
||||
return;
|
||||
}
|
||||
|
||||
CommandProfileBase command = getCommand(args);
|
||||
if(command == null)
|
||||
throw new CommandException("Unknown command " + args[0]);
|
||||
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
if(command.subcommands.isEmpty() || !command.runSubCommands()){
|
||||
if(!canSendCommand(sender, command))
|
||||
throw new CommandException("You are not allowed to use this command: " + command);
|
||||
command.canRun(sender, command.getUsage(), args);
|
||||
command.processCommand(sender, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if(args.length == 0){
|
||||
help.processCommand(sender, new String[]{command.getCommandName()});
|
||||
return;
|
||||
}
|
||||
|
||||
command.processSubCommand(sender, args[0], Arrays.copyOfRange(args, 1, args.length));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List addTabCompletionOptions(ICommandSender sender, String[] args){
|
||||
if(args.length == 1)
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, map.keySet().toArray(new String[map.size()]));
|
||||
CommandProfileBase command = getCommand(args);
|
||||
if(command == null)
|
||||
return null;
|
||||
if(args.length == 2 && command.runSubCommands())
|
||||
return getListOfStringsMatchingLastWord(args, command.subcommands.keySet().toArray(new String[command.subcommands.keySet().size()]));
|
||||
String[] useArgs = command.getUsage().split(" ");
|
||||
if(command.runSubCommands()) {
|
||||
Method m = command.subcommands.get(args[1].toLowerCase());
|
||||
if(m != null) {
|
||||
useArgs = m.getAnnotation(CommandProfileBase.SubCommand.class).usage().split(" ");
|
||||
}
|
||||
}
|
||||
if(args.length <= useArgs.length + 2) {
|
||||
if(args.length - 3 >= 0){
|
||||
String usage = useArgs[args.length - 3];
|
||||
if(usage.equals("<player>") || usage.equals("[player]") || usage.equals("<targetPlayer>")
|
||||
|| usage.equals("<sourcePlayer>") || usage.equals("<destinationPlayer>")) {
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames());
|
||||
}
|
||||
}
|
||||
}
|
||||
return command.addTabCompletionOptions(sender, Arrays.copyOfRange(args, 1, args.length));
|
||||
}
|
||||
|
||||
public CommandProfileBase getCommand(String[] args){
|
||||
if(args.length == 0)
|
||||
return null;
|
||||
return map.get(args[0].toLowerCase());
|
||||
public void registerCommand(CommandProfileBase command) {
|
||||
String name = command.getCommandName().toLowerCase();
|
||||
if (map.containsKey(name))
|
||||
throw new CustomNPCsException("Already a subcommand with the name: " + name);
|
||||
map.put(name, command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel(){
|
||||
public String getCommandName() {
|
||||
return "profile";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getCommandAliases() {
|
||||
return Arrays.asList(alias);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender sender) {
|
||||
return "Use as /profile subcommand";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
if (args.length == 0) {
|
||||
help.processCommand(sender, args);
|
||||
return;
|
||||
}
|
||||
|
||||
CommandProfileBase command = getCommand(args);
|
||||
if (command == null)
|
||||
throw new CommandException("Unknown command " + args[0]);
|
||||
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
if (command.subcommands.isEmpty() || !command.runSubCommands()) {
|
||||
if (!canSendCommand(sender, command))
|
||||
throw new CommandException("You are not allowed to use this command: " + command);
|
||||
command.canRun(sender, command.getUsage(), args);
|
||||
command.processCommand(sender, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
help.processCommand(sender, new String[]{command.getCommandName()});
|
||||
return;
|
||||
}
|
||||
|
||||
command.processSubCommand(sender, args[0], Arrays.copyOfRange(args, 1, args.length));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List addTabCompletionOptions(ICommandSender sender, String[] args) {
|
||||
if (args.length == 1)
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, map.keySet().toArray(new String[map.size()]));
|
||||
CommandProfileBase command = getCommand(args);
|
||||
if (command == null)
|
||||
return null;
|
||||
if (args.length == 2 && command.runSubCommands())
|
||||
return getListOfStringsMatchingLastWord(args, command.subcommands.keySet().toArray(new String[command.subcommands.keySet().size()]));
|
||||
String[] useArgs = command.getUsage().split(" ");
|
||||
if (command.runSubCommands()) {
|
||||
Method m = command.subcommands.get(args[1].toLowerCase());
|
||||
if (m != null) {
|
||||
useArgs = m.getAnnotation(CommandProfileBase.SubCommand.class).usage().split(" ");
|
||||
}
|
||||
}
|
||||
if (args.length <= useArgs.length + 2) {
|
||||
if (args.length - 3 >= 0) {
|
||||
String usage = useArgs[args.length - 3];
|
||||
if (usage.equals("<player>") || usage.equals("[player]") || usage.equals("<targetPlayer>")
|
||||
|| usage.equals("<sourcePlayer>") || usage.equals("<destinationPlayer>")) {
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames());
|
||||
}
|
||||
}
|
||||
}
|
||||
return command.addTabCompletionOptions(sender, Arrays.copyOfRange(args, 1, args.length));
|
||||
}
|
||||
|
||||
public CommandProfileBase getCommand(String[] args) {
|
||||
if (args.length == 0)
|
||||
return null;
|
||||
return map.get(args[0].toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
public static String getCommandPermission(String command){
|
||||
return "profile.kamkeel." + command.toLowerCase();
|
||||
}
|
||||
public static String getCommandPermission(String command) {
|
||||
return "profile.kamkeel." + command.toLowerCase();
|
||||
}
|
||||
|
||||
public static String getUniversalPermission(){
|
||||
return "profile.kamkeel.*";
|
||||
}
|
||||
public static String getUniversalPermission() {
|
||||
return "profile.kamkeel.*";
|
||||
}
|
||||
|
||||
public static boolean canSendCommand(ICommandSender sender, CommandProfileBase command){
|
||||
if(sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), getUniversalPermission())){
|
||||
return true;
|
||||
}
|
||||
public static boolean canSendCommand(ICommandSender sender, CommandProfileBase command) {
|
||||
if (sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), getUniversalPermission())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), getCommandPermission(command.getCommandName()))){
|
||||
return true;
|
||||
}
|
||||
if (sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), getCommandPermission(command.getCommandName()))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(sender instanceof EntityPlayer){
|
||||
return CustomNpcsPermissions.hasCustomPermission((EntityPlayer) sender, getCommandPermission(command.getCommandName()));
|
||||
}
|
||||
if (sender instanceof EntityPlayer) {
|
||||
return CustomNpcsPermissions.hasCustomPermission((EntityPlayer) sender, getCommandPermission(command.getCommandName()));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@ package kamkeel.npcs.command.profile;
|
||||
|
||||
import kamkeel.npcs.controllers.ProfileController;
|
||||
import kamkeel.npcs.controllers.data.profile.EnumProfileOperation;
|
||||
import noppes.npcs.api.handler.data.ISlot;
|
||||
import kamkeel.npcs.controllers.data.profile.Profile;
|
||||
import kamkeel.npcs.controllers.data.profile.ProfileOperation;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import noppes.npcs.api.handler.data.ISlot;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
@@ -36,7 +36,7 @@ public class CommandProfileAdmin extends CommandProfileBase {
|
||||
usage = "<sourcePlayer> <destinationPlayer> <sourceSlot> <destinationSlot> [temp]"
|
||||
)
|
||||
public void clone(ICommandSender sender, String[] args) throws CommandException {
|
||||
if(args.length < 4) {
|
||||
if (args.length < 4) {
|
||||
sendError(sender, "Usage: /profile admin clone <sourcePlayer> <destinationPlayer> <sourceSlot> <destinationSlot> [temp]");
|
||||
return;
|
||||
}
|
||||
@@ -52,12 +52,12 @@ public class CommandProfileAdmin extends CommandProfileBase {
|
||||
}
|
||||
boolean temporary = (args.length >= 5 && args[4].equalsIgnoreCase("temp"));
|
||||
ProfileOperation result = ProfileController.Instance.cloneSlot(sourcePlayer, sourceSlot, destinationSlot, temporary);
|
||||
if(result.getResult() == EnumProfileOperation.SUCCESS) {
|
||||
if (result.getResult() == EnumProfileOperation.SUCCESS) {
|
||||
sendResult(sender, "Successfully cloned slot %d from %s to slot %d for %s.", sourceSlot, sourcePlayer, destinationSlot, destinationPlayer);
|
||||
} else if(result.getResult() == EnumProfileOperation.LOCKED) {
|
||||
} else if (result.getResult() == EnumProfileOperation.LOCKED) {
|
||||
// Detail message for admins – note: using result.getMessage() for further details.
|
||||
sendError(sender, "Clone failed for %s: Profile is locked. Details: %s", sourcePlayer, result.getMessage());
|
||||
} else if(result.getResult() == EnumProfileOperation.ERROR) {
|
||||
} else if (result.getResult() == EnumProfileOperation.ERROR) {
|
||||
sendError(sender, "Error cloning slot for %s: %s", sourcePlayer, result.getMessage());
|
||||
} else {
|
||||
sendError(sender, "Unexpected error cloning slot: %s", result.getMessage());
|
||||
@@ -69,7 +69,7 @@ public class CommandProfileAdmin extends CommandProfileBase {
|
||||
usage = "<targetPlayer> <slotId>"
|
||||
)
|
||||
public void remove(ICommandSender sender, String[] args) throws CommandException {
|
||||
if(args.length < 2) {
|
||||
if (args.length < 2) {
|
||||
sendError(sender, "Usage: /profile admin remove <targetPlayer> <slotId>");
|
||||
return;
|
||||
}
|
||||
@@ -77,16 +77,16 @@ public class CommandProfileAdmin extends CommandProfileBase {
|
||||
int slotId;
|
||||
try {
|
||||
slotId = Integer.parseInt(args[1]);
|
||||
} catch(NumberFormatException ex) {
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, "Slot ID must be a number.");
|
||||
return;
|
||||
}
|
||||
ProfileOperation result = ProfileController.Instance.removeSlot(targetPlayer, slotId);
|
||||
if(result.getResult() == EnumProfileOperation.SUCCESS) {
|
||||
if (result.getResult() == EnumProfileOperation.SUCCESS) {
|
||||
sendResult(sender, "Successfully removed slot %d from %s.", slotId, targetPlayer);
|
||||
} else if(result.getResult() == EnumProfileOperation.LOCKED) {
|
||||
} else if (result.getResult() == EnumProfileOperation.LOCKED) {
|
||||
sendError(sender, "Remove failed for %s: Profile is locked. Details: %s", targetPlayer, result.getMessage());
|
||||
} else if(result.getResult() == EnumProfileOperation.ERROR) {
|
||||
} else if (result.getResult() == EnumProfileOperation.ERROR) {
|
||||
sendError(sender, "Error removing slot %d from %s: %s", slotId, targetPlayer, result.getMessage());
|
||||
} else {
|
||||
sendError(sender, "Unexpected error during removal: %s", result.getMessage());
|
||||
@@ -98,7 +98,7 @@ public class CommandProfileAdmin extends CommandProfileBase {
|
||||
usage = "<targetPlayer> <newSlotId>"
|
||||
)
|
||||
public void change(ICommandSender sender, String[] args) throws CommandException {
|
||||
if(args.length < 2) {
|
||||
if (args.length < 2) {
|
||||
sendError(sender, "Usage: /profile admin change <targetPlayer> <newSlotId>");
|
||||
return;
|
||||
}
|
||||
@@ -106,16 +106,16 @@ public class CommandProfileAdmin extends CommandProfileBase {
|
||||
int newSlotId;
|
||||
try {
|
||||
newSlotId = Integer.parseInt(args[1]);
|
||||
} catch(NumberFormatException ex) {
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, "Slot ID must be a number.");
|
||||
return;
|
||||
}
|
||||
ProfileOperation result = ProfileController.Instance.changeSlot(targetPlayer, newSlotId);
|
||||
if(result.getResult() == EnumProfileOperation.SUCCESS) {
|
||||
if (result.getResult() == EnumProfileOperation.SUCCESS) {
|
||||
sendResult(sender, "Successfully changed %s's active slot to %d.", targetPlayer, newSlotId);
|
||||
} else if(result.getResult() == EnumProfileOperation.LOCKED) {
|
||||
} else if (result.getResult() == EnumProfileOperation.LOCKED) {
|
||||
sendError(sender, "Change failed for %s: Profile is locked. Details: %s", targetPlayer, result.getMessage());
|
||||
} else if(result.getResult() == EnumProfileOperation.ERROR) {
|
||||
} else if (result.getResult() == EnumProfileOperation.ERROR) {
|
||||
sendError(sender, "Error changing active slot for %s: %s", targetPlayer, result.getMessage());
|
||||
} else {
|
||||
sendError(sender, "Unexpected error during change: %s", result.getMessage());
|
||||
@@ -127,22 +127,22 @@ public class CommandProfileAdmin extends CommandProfileBase {
|
||||
usage = "<targetPlayer>"
|
||||
)
|
||||
public void create(ICommandSender sender, String[] args) throws CommandException {
|
||||
if(args.length < 1) {
|
||||
if (args.length < 1) {
|
||||
sendError(sender, "Usage: /profile admin create <targetPlayer>");
|
||||
return;
|
||||
}
|
||||
String targetPlayer = args[0];
|
||||
Profile profile = ProfileController.Instance.getProfile(targetPlayer);
|
||||
if(profile == null) {
|
||||
if (profile == null) {
|
||||
sendError(sender, "Profile not found for player: %s", targetPlayer);
|
||||
return;
|
||||
}
|
||||
ProfileOperation result = ProfileController.Instance.createSlotInternal(profile);
|
||||
if(result.getResult() == EnumProfileOperation.SUCCESS) {
|
||||
if (result.getResult() == EnumProfileOperation.SUCCESS) {
|
||||
sendResult(sender, "New slot created successfully for %s.", targetPlayer);
|
||||
} else if(result.getResult() == EnumProfileOperation.LOCKED) {
|
||||
} else if (result.getResult() == EnumProfileOperation.LOCKED) {
|
||||
sendError(sender, "Create failed for %s: Profile is locked. Details: %s", targetPlayer, result.getMessage());
|
||||
} else if(result.getResult() == EnumProfileOperation.ERROR) {
|
||||
} else if (result.getResult() == EnumProfileOperation.ERROR) {
|
||||
sendError(sender, "Error creating new slot for %s: %s", targetPlayer, result.getMessage());
|
||||
} else {
|
||||
sendError(sender, "Unexpected error during slot creation: %s", result.getMessage());
|
||||
@@ -154,18 +154,18 @@ public class CommandProfileAdmin extends CommandProfileBase {
|
||||
usage = "<targetPlayer>"
|
||||
)
|
||||
public void list(ICommandSender sender, String[] args) throws CommandException {
|
||||
if(args.length < 1) {
|
||||
if (args.length < 1) {
|
||||
sendError(sender, "Usage: /profile admin list <targetPlayer>");
|
||||
return;
|
||||
}
|
||||
String targetPlayer = args[0];
|
||||
Profile profile = ProfileController.Instance.getProfile(targetPlayer);
|
||||
if(profile == null) {
|
||||
if (profile == null) {
|
||||
sendError(sender, "Profile not found for player: %s", targetPlayer);
|
||||
return;
|
||||
}
|
||||
sendMessage(sender, "Profile Slots for %s:", targetPlayer);
|
||||
for(Map.Entry<Integer, ISlot> entry : profile.getSlots().entrySet()) {
|
||||
for (Map.Entry<Integer, ISlot> entry : profile.getSlots().entrySet()) {
|
||||
int id = entry.getKey();
|
||||
String name = entry.getValue().getName();
|
||||
String prefix = (id == profile.currentSlotId) ? "* " : "- ";
|
||||
@@ -178,7 +178,7 @@ public class CommandProfileAdmin extends CommandProfileBase {
|
||||
usage = "<targetPlayer> <slotId> <newName>"
|
||||
)
|
||||
public void rename(ICommandSender sender, String[] args) throws CommandException {
|
||||
if(args.length < 3) {
|
||||
if (args.length < 3) {
|
||||
sendError(sender, "Usage: /profile admin rename <targetPlayer> <slotId> <newName>");
|
||||
return;
|
||||
}
|
||||
@@ -186,42 +186,42 @@ public class CommandProfileAdmin extends CommandProfileBase {
|
||||
int slotId;
|
||||
try {
|
||||
slotId = Integer.parseInt(args[1]);
|
||||
} catch(NumberFormatException ex) {
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, "Slot ID must be a number.");
|
||||
return;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int i = 2; i < args.length; i++){
|
||||
if(i > 2) sb.append(" ");
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
if (i > 2) sb.append(" ");
|
||||
sb.append(args[i]);
|
||||
}
|
||||
String newName = sb.toString().trim();
|
||||
if(newName.length() > 20) {
|
||||
if (newName.length() > 20) {
|
||||
newName = newName.substring(0, 20);
|
||||
}
|
||||
if(!newName.matches("[A-Za-z ]+")){
|
||||
if (!newName.matches("[A-Za-z ]+")) {
|
||||
sendError(sender, "Invalid name. Only alphabetic characters and spaces are allowed.");
|
||||
return;
|
||||
}
|
||||
Profile profile = ProfileController.Instance.getProfile(targetPlayer);
|
||||
if(profile == null) {
|
||||
if (profile == null) {
|
||||
sendError(sender, "Profile not found for player: %s", targetPlayer);
|
||||
return;
|
||||
}
|
||||
if(profile.isLocked()) {
|
||||
if (profile.isLocked()) {
|
||||
sendError(sender, "Profile for %s is locked. Please try again later.", targetPlayer);
|
||||
return;
|
||||
}
|
||||
if(!profile.getSlots().containsKey(slotId)) {
|
||||
if (!profile.getSlots().containsKey(slotId)) {
|
||||
sendError(sender, "Slot %d not found in %s's profile.", slotId, targetPlayer);
|
||||
return;
|
||||
}
|
||||
profile.getSlots().get(slotId).setName(newName);
|
||||
if(profile.getPlayer() != null) {
|
||||
if (profile.getPlayer() != null) {
|
||||
ProfileController.Instance.save(profile.player, profile);
|
||||
} else {
|
||||
UUID uuid = ProfileController.Instance.getUUIDFromUsername(targetPlayer);
|
||||
if(uuid != null)
|
||||
if (uuid != null)
|
||||
ProfileController.Instance.saveOffline(profile, uuid);
|
||||
}
|
||||
sendResult(sender, "Successfully renamed slot %d for %s to '%s'.", slotId, targetPlayer, newName);
|
||||
@@ -232,7 +232,7 @@ public class CommandProfileAdmin extends CommandProfileBase {
|
||||
usage = "<targetPlayer> <backupFileName>"
|
||||
)
|
||||
public void rollback(ICommandSender sender, String[] args) throws CommandException {
|
||||
if(args.length < 2) {
|
||||
if (args.length < 2) {
|
||||
sendError(sender, "Usage: /profile admin rollback <targetPlayer> <backupFileName>");
|
||||
return;
|
||||
}
|
||||
@@ -240,17 +240,17 @@ public class CommandProfileAdmin extends CommandProfileBase {
|
||||
String backupFileName = args[1] + ".dat";
|
||||
|
||||
Profile profile = ProfileController.Instance.getProfile(targetPlayer);
|
||||
if(profile == null || profile.player == null)
|
||||
if (profile == null || profile.player == null)
|
||||
return;
|
||||
|
||||
File backupDir = new File(ProfileController.getBackupDir(), profile.getPlayer().getUniqueID().toString());
|
||||
File backupFile = new File(backupDir, backupFileName);
|
||||
if(!backupFile.exists()){
|
||||
if (!backupFile.exists()) {
|
||||
sendError(sender, "Backup file %s not found for player %s.", backupFileName, targetPlayer);
|
||||
return;
|
||||
}
|
||||
boolean success = ProfileController.Instance.rollbackProfile(targetPlayer, backupFile);
|
||||
if(success) {
|
||||
if (success) {
|
||||
sendResult(sender, "Successfully rolled back %s's profile to backup %s.", targetPlayer, backupFileName);
|
||||
} else {
|
||||
sendError(sender, "Failed to rollback %s's profile.", targetPlayer);
|
||||
|
||||
@@ -16,10 +16,10 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class CommandProfileBase extends CommandBase{
|
||||
public Map<String, Method> subcommands = new HashMap<String, Method>();
|
||||
public abstract class CommandProfileBase extends CommandBase {
|
||||
public Map<String, Method> subcommands = new HashMap<String, Method>();
|
||||
|
||||
public CommandProfileBase(){
|
||||
public CommandProfileBase() {
|
||||
for (Method m : this.getClass().getDeclaredMethods()) {
|
||||
SubCommand sc = m.getAnnotation(SubCommand.class);
|
||||
if (sc != null) {
|
||||
@@ -29,107 +29,107 @@ public abstract class CommandProfileBase extends CommandBase{
|
||||
subcommands.put(name.toLowerCase(), m);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender sender) {
|
||||
return getDescription();
|
||||
}
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender sender) {
|
||||
return getDescription();
|
||||
}
|
||||
|
||||
public abstract String getDescription();
|
||||
public abstract String getDescription();
|
||||
|
||||
/**
|
||||
* @return Should return a string in the format of <arg> <arg2> <arg3> [arg4] where <> is a required parameter and [] optional
|
||||
*/
|
||||
public String getUsage(){
|
||||
return "";
|
||||
}
|
||||
/**
|
||||
* @return Should return a string in the format of <arg> <arg2> <arg3> [arg4] where <> is a required parameter and [] optional
|
||||
*/
|
||||
public String getUsage() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public boolean runSubCommands(){
|
||||
return !subcommands.isEmpty();
|
||||
}
|
||||
public boolean runSubCommands() {
|
||||
return !subcommands.isEmpty();
|
||||
}
|
||||
|
||||
@Retention(value = RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface SubCommand {
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface SubCommand {
|
||||
|
||||
String name() default "";
|
||||
String name() default "";
|
||||
|
||||
/**
|
||||
* @return Should return a string in the format of <arg> <arg2> <arg3> [arg4] where <> is a required parameter and [] optional
|
||||
*/
|
||||
String usage() default "";
|
||||
/**
|
||||
* @return Should return a string in the format of <arg> <arg2> <arg3> [arg4] where <> is a required parameter and [] optional
|
||||
*/
|
||||
String usage() default "";
|
||||
|
||||
String desc();
|
||||
String desc();
|
||||
|
||||
int permission() default 2;
|
||||
}
|
||||
int permission() default 2;
|
||||
}
|
||||
|
||||
public void processSubCommand(ICommandSender sender, String command, String[] args) throws CommandException {
|
||||
Method m = subcommands.get(command.toLowerCase());
|
||||
if(m == null)
|
||||
throw new CommandException("Unknown subcommand " + command);
|
||||
public void processSubCommand(ICommandSender sender, String command, String[] args) throws CommandException {
|
||||
Method m = subcommands.get(command.toLowerCase());
|
||||
if (m == null)
|
||||
throw new CommandException("Unknown subcommand " + command);
|
||||
|
||||
SubCommand sc = m.getAnnotation(SubCommand.class);
|
||||
if(!canSendCommand(sender, sc, command))
|
||||
throw new CommandException("You are not allowed to use this command: " + command);
|
||||
SubCommand sc = m.getAnnotation(SubCommand.class);
|
||||
if (!canSendCommand(sender, sc, command))
|
||||
throw new CommandException("You are not allowed to use this command: " + command);
|
||||
|
||||
canRun(sender, sc.usage(), args);
|
||||
try {
|
||||
m.invoke(this, sender, args);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
canRun(sender, sc.usage(), args);
|
||||
try {
|
||||
m.invoke(this, sender, args);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void canRun(ICommandSender sender, String usage, String[] args) throws CommandException{
|
||||
String[] np = usage.split(" ");
|
||||
List<String> required = new ArrayList<String>();
|
||||
for(int i = 0; i < np.length; i++){
|
||||
String command = np[i];
|
||||
if(command.startsWith("<")){
|
||||
required.add(command);
|
||||
}
|
||||
if(command.equals("<player>") && args.length > i){
|
||||
CommandBase.getPlayer(sender, args[i]); //throws PlayerNotFoundException if no player is found
|
||||
}
|
||||
public void canRun(ICommandSender sender, String usage, String[] args) throws CommandException {
|
||||
String[] np = usage.split(" ");
|
||||
List<String> required = new ArrayList<String>();
|
||||
for (int i = 0; i < np.length; i++) {
|
||||
String command = np[i];
|
||||
if (command.startsWith("<")) {
|
||||
required.add(command);
|
||||
}
|
||||
if (command.equals("<player>") && args.length > i) {
|
||||
CommandBase.getPlayer(sender, args[i]); //throws PlayerNotFoundException if no player is found
|
||||
}
|
||||
|
||||
}
|
||||
if (args.length < required.size()) {
|
||||
throw new CommandException("Missing parameter: " + required.get(args.length));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (args.length < required.size()) {
|
||||
throw new CommandException("Missing parameter: " + required.get(args.length));
|
||||
}
|
||||
}
|
||||
|
||||
public int getRequiredPermissionLevel(){
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public String getSubCommandPermission(String subCommand){
|
||||
return "profile.kamkeel." + getCommandName().toLowerCase() + "." + subCommand.toLowerCase();
|
||||
}
|
||||
public String getSubCommandPermission(String subCommand) {
|
||||
return "profile.kamkeel." + getCommandName().toLowerCase() + "." + subCommand.toLowerCase();
|
||||
}
|
||||
|
||||
public String getSubUniversalPermission(){
|
||||
return "profile.kamkeel." + getCommandName().toLowerCase() + "*";
|
||||
}
|
||||
public String getSubUniversalPermission() {
|
||||
return "profile.kamkeel." + getCommandName().toLowerCase() + "*";
|
||||
}
|
||||
|
||||
public boolean canSendCommand(ICommandSender sender, SubCommand command, String subCommand){
|
||||
if(sender.canCommandSenderUseCommand(command.permission(), getSubUniversalPermission())){
|
||||
return true;
|
||||
}
|
||||
public boolean canSendCommand(ICommandSender sender, SubCommand command, String subCommand) {
|
||||
if (sender.canCommandSenderUseCommand(command.permission(), getSubUniversalPermission())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(sender.canCommandSenderUseCommand(command.permission(), getSubCommandPermission(subCommand))){
|
||||
return true;
|
||||
}
|
||||
if (sender.canCommandSenderUseCommand(command.permission(), getSubCommandPermission(subCommand))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(sender instanceof EntityPlayer){
|
||||
return CustomNpcsPermissions.hasCustomPermission((EntityPlayer) sender, getSubCommandPermission(subCommand));
|
||||
}
|
||||
if (sender instanceof EntityPlayer) {
|
||||
return CustomNpcsPermissions.hasCustomPermission((EntityPlayer) sender, getSubCommandPermission(subCommand));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -34,28 +34,28 @@ public class CommandProfileChange extends CommandProfileBase {
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
if(!(sender instanceof EntityPlayer)) {
|
||||
if (!(sender instanceof EntityPlayer)) {
|
||||
sendError(sender, "This command can only be used by a player.");
|
||||
return;
|
||||
}
|
||||
if(args.length < 1) {
|
||||
if (args.length < 1) {
|
||||
sendError(sender, "Usage: " + getUsage());
|
||||
return;
|
||||
}
|
||||
int slotId;
|
||||
try {
|
||||
slotId = Integer.parseInt(args[0]);
|
||||
} catch(NumberFormatException ex) {
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, "Slot ID must be a number: " + args[0]);
|
||||
return;
|
||||
}
|
||||
EntityPlayer player = (EntityPlayer)sender;
|
||||
EntityPlayer player = (EntityPlayer) sender;
|
||||
ProfileOperation result = ProfileController.Instance.changeSlot(player, slotId);
|
||||
if(result.getResult() == EnumProfileOperation.SUCCESS) {
|
||||
if (result.getResult() == EnumProfileOperation.SUCCESS) {
|
||||
sendResult(sender, "Successfully changed profile slot to %d.", slotId);
|
||||
} else if(result.getResult() == EnumProfileOperation.LOCKED) {
|
||||
} else if (result.getResult() == EnumProfileOperation.LOCKED) {
|
||||
sendError(sender, "Profile is locked. Details: %s", result.getMessage());
|
||||
} else if(result.getResult() == EnumProfileOperation.ERROR) {
|
||||
} else if (result.getResult() == EnumProfileOperation.ERROR) {
|
||||
sendError(sender, "Error changing your profile slot: %s", result.getMessage());
|
||||
} else {
|
||||
sendError(sender, "Unexpected error: %s", result.getMessage());
|
||||
|
||||
@@ -34,21 +34,21 @@ public class CommandProfileCreate extends CommandProfileBase {
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
if(!(sender instanceof EntityPlayer)) {
|
||||
if (!(sender instanceof EntityPlayer)) {
|
||||
sendError(sender, "This command can only be used by a player.");
|
||||
return;
|
||||
}
|
||||
EntityPlayer player = (EntityPlayer)sender;
|
||||
if(ProfileController.Instance.getProfile(player) == null) {
|
||||
EntityPlayer player = (EntityPlayer) sender;
|
||||
if (ProfileController.Instance.getProfile(player) == null) {
|
||||
sendError(sender, "Profile not found.");
|
||||
return;
|
||||
}
|
||||
ProfileOperation result = ProfileController.Instance.createSlotInternal(ProfileController.Instance.getProfile(player));
|
||||
if(result.getResult() == EnumProfileOperation.SUCCESS) {
|
||||
if (result.getResult() == EnumProfileOperation.SUCCESS) {
|
||||
sendResult(sender, "New profile slot created successfully.");
|
||||
} else if(result.getResult() == EnumProfileOperation.LOCKED) {
|
||||
} else if (result.getResult() == EnumProfileOperation.LOCKED) {
|
||||
sendError(sender, "Profile is locked. Details: %s", result.getMessage());
|
||||
} else if(result.getResult() == EnumProfileOperation.ERROR) {
|
||||
} else if (result.getResult() == EnumProfileOperation.ERROR) {
|
||||
sendError(sender, "Error creating new profile slot: %s", result.getMessage());
|
||||
} else {
|
||||
sendError(sender, "Unexpected error: %s", result.getMessage());
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package kamkeel.npcs.command.profile;
|
||||
|
||||
import kamkeel.npcs.controllers.ProfileController;
|
||||
import noppes.npcs.api.handler.data.ISlot;
|
||||
import kamkeel.npcs.controllers.data.profile.Profile;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import noppes.npcs.api.handler.data.ISlot;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -31,21 +31,21 @@ public class CommandProfileList extends CommandProfileBase {
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
if(!(sender instanceof EntityPlayer)) {
|
||||
if (!(sender instanceof EntityPlayer)) {
|
||||
sendError(sender, "This command can only be used by a player.");
|
||||
return;
|
||||
}
|
||||
EntityPlayer player = (EntityPlayer)sender;
|
||||
EntityPlayer player = (EntityPlayer) sender;
|
||||
Profile profile = ProfileController.Instance.getProfile(player);
|
||||
if(profile == null) {
|
||||
if (profile == null) {
|
||||
sendError(sender, "Profile not found.");
|
||||
return;
|
||||
}
|
||||
if(profile.getSlots().isEmpty()){
|
||||
if (profile.getSlots().isEmpty()) {
|
||||
sendMessage(sender, "No slots found. Using default slot 0.");
|
||||
}
|
||||
sendMessage(sender, "Your Profile Slots:");
|
||||
for(Map.Entry<Integer, ISlot> entry : profile.getSlots().entrySet()) {
|
||||
for (Map.Entry<Integer, ISlot> entry : profile.getSlots().entrySet()) {
|
||||
int id = entry.getKey();
|
||||
String name = entry.getValue().getName();
|
||||
String prefix = (id == profile.currentSlotId) ? "* " : "- ";
|
||||
|
||||
@@ -33,7 +33,7 @@ public class CommandProfileRegion extends CommandProfileBase {
|
||||
public void enable(ICommandSender sender, String[] args) throws CommandException {
|
||||
ConfigMain.RegionProfileSwitching = true;
|
||||
ConfigMain.RegionProfileSwitchingProperty.set(true);
|
||||
if(ConfigMain.config.hasChanged()){
|
||||
if (ConfigMain.config.hasChanged()) {
|
||||
ConfigMain.config.save();
|
||||
}
|
||||
sendResult(sender, "Profile region switching enabled.");
|
||||
@@ -46,7 +46,7 @@ public class CommandProfileRegion extends CommandProfileBase {
|
||||
public void disable(ICommandSender sender, String[] args) throws CommandException {
|
||||
ConfigMain.RegionProfileSwitching = false;
|
||||
ConfigMain.RegionProfileSwitchingProperty.set(false);
|
||||
if(ConfigMain.config.hasChanged()){
|
||||
if (ConfigMain.config.hasChanged()) {
|
||||
ConfigMain.config.save();
|
||||
}
|
||||
sendResult(sender, "Profile region switching disabled.");
|
||||
@@ -57,32 +57,32 @@ public class CommandProfileRegion extends CommandProfileBase {
|
||||
usage = "<dim> <x1> <y1> <z1> <x2> <y2> <z2>"
|
||||
)
|
||||
public void add(ICommandSender sender, String[] args) throws CommandException {
|
||||
if(args.length != 7){
|
||||
if (args.length != 7) {
|
||||
sendError(sender, "Usage: /profile region add <dim> <x1> <y1> <z1> <x2> <y2> <z2>");
|
||||
return;
|
||||
}
|
||||
List<Integer> regionList = new ArrayList<>();
|
||||
try {
|
||||
for(String arg : args){
|
||||
for (String arg : args) {
|
||||
regionList.add(Integer.parseInt(arg));
|
||||
}
|
||||
} catch(NumberFormatException e){
|
||||
} catch (NumberFormatException e) {
|
||||
sendError(sender, "Invalid number format in region data.");
|
||||
return;
|
||||
}
|
||||
ConfigMain.RestrictedProfileRegions.add(regionList);
|
||||
// Update config property value
|
||||
List<String> regionStrings = new ArrayList<>();
|
||||
for(List<Integer> region : ConfigMain.RestrictedProfileRegions) {
|
||||
for (List<Integer> region : ConfigMain.RestrictedProfileRegions) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < region.size(); i++) {
|
||||
if(i > 0) sb.append(" ");
|
||||
if (i > 0) sb.append(" ");
|
||||
sb.append(region.get(i));
|
||||
}
|
||||
regionStrings.add(sb.toString());
|
||||
}
|
||||
ConfigMain.RestrictedProfileRegionsProperty.set(regionStrings.toArray(new String[0]));
|
||||
if(ConfigMain.config.hasChanged()){
|
||||
if (ConfigMain.config.hasChanged()) {
|
||||
ConfigMain.config.save();
|
||||
}
|
||||
sendResult(sender, "Region added successfully.");
|
||||
@@ -93,35 +93,35 @@ public class CommandProfileRegion extends CommandProfileBase {
|
||||
usage = "<index>"
|
||||
)
|
||||
public void remove(ICommandSender sender, String[] args) throws CommandException {
|
||||
if(args.length < 1){
|
||||
if (args.length < 1) {
|
||||
sendError(sender, "Usage: /profile region remove <index>");
|
||||
return;
|
||||
}
|
||||
int index;
|
||||
try {
|
||||
index = Integer.parseInt(args[0]);
|
||||
} catch(NumberFormatException e){
|
||||
} catch (NumberFormatException e) {
|
||||
sendError(sender, "Index must be a number.");
|
||||
return;
|
||||
}
|
||||
index = index - 1; // Convert to 0-based index
|
||||
if(index < 0 || index >= ConfigMain.RestrictedProfileRegions.size()){
|
||||
if (index < 0 || index >= ConfigMain.RestrictedProfileRegions.size()) {
|
||||
sendError(sender, "Invalid index. Must be between 1 and " + ConfigMain.RestrictedProfileRegions.size());
|
||||
return;
|
||||
}
|
||||
ConfigMain.RestrictedProfileRegions.remove(index);
|
||||
// Update config property value
|
||||
List<String> regionStrings = new ArrayList<>();
|
||||
for(List<Integer> region : ConfigMain.RestrictedProfileRegions) {
|
||||
for (List<Integer> region : ConfigMain.RestrictedProfileRegions) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < region.size(); i++) {
|
||||
if(i > 0) sb.append(", ");
|
||||
if (i > 0) sb.append(", ");
|
||||
sb.append(region.get(i));
|
||||
}
|
||||
regionStrings.add(sb.toString());
|
||||
}
|
||||
ConfigMain.RestrictedProfileRegionsProperty.set(regionStrings.toArray(new String[0]));
|
||||
if(ConfigMain.config.hasChanged()){
|
||||
if (ConfigMain.config.hasChanged()) {
|
||||
ConfigMain.config.save();
|
||||
}
|
||||
sendResult(sender, "Region removed successfully.");
|
||||
@@ -132,17 +132,17 @@ public class CommandProfileRegion extends CommandProfileBase {
|
||||
usage = ""
|
||||
)
|
||||
public void list(ICommandSender sender, String[] args) throws CommandException {
|
||||
if(ConfigMain.RestrictedProfileRegions.isEmpty()){
|
||||
if (ConfigMain.RestrictedProfileRegions.isEmpty()) {
|
||||
sendMessage(sender, "No restricted profile regions configured.");
|
||||
return;
|
||||
}
|
||||
sendMessage(sender, "Restricted Profile Regions:");
|
||||
int i = 1;
|
||||
for(List<Integer> region : ConfigMain.RestrictedProfileRegions) {
|
||||
for (List<Integer> region : ConfigMain.RestrictedProfileRegions) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(i).append(": ");
|
||||
for (int j = 0; j < region.size(); j++) {
|
||||
if(j > 0) sb.append(", ");
|
||||
if (j > 0) sb.append(", ");
|
||||
sb.append(region.get(j));
|
||||
}
|
||||
sendMessage(sender, sb.toString());
|
||||
|
||||
@@ -34,28 +34,28 @@ public class CommandProfileRemove extends CommandProfileBase {
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
if(!(sender instanceof EntityPlayer)) {
|
||||
if (!(sender instanceof EntityPlayer)) {
|
||||
sendError(sender, "This command can only be used by a player.");
|
||||
return;
|
||||
}
|
||||
if(args.length < 1) {
|
||||
if (args.length < 1) {
|
||||
sendError(sender, "Usage: " + getUsage());
|
||||
return;
|
||||
}
|
||||
int slotId;
|
||||
try {
|
||||
slotId = Integer.parseInt(args[0]);
|
||||
} catch(NumberFormatException ex) {
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, "Slot ID must be a number: " + args[0]);
|
||||
return;
|
||||
}
|
||||
EntityPlayer player = (EntityPlayer)sender;
|
||||
EntityPlayer player = (EntityPlayer) sender;
|
||||
ProfileOperation result = ProfileController.Instance.removeSlot(player, slotId);
|
||||
if(result.getResult() == EnumProfileOperation.SUCCESS) {
|
||||
if (result.getResult() == EnumProfileOperation.SUCCESS) {
|
||||
sendResult(sender, "Successfully removed slot %d from your profile.", slotId);
|
||||
} else if(result.getResult() == EnumProfileOperation.LOCKED) {
|
||||
} else if (result.getResult() == EnumProfileOperation.LOCKED) {
|
||||
sendError(sender, "Profile is locked. Details: %s", result.getMessage());
|
||||
} else if(result.getResult() == EnumProfileOperation.ERROR) {
|
||||
} else if (result.getResult() == EnumProfileOperation.ERROR) {
|
||||
sendError(sender, "Error removing slot: %s", result.getMessage());
|
||||
} else {
|
||||
sendError(sender, "Unexpected error: %s", result.getMessage());
|
||||
|
||||
@@ -27,40 +27,40 @@ public class CommandProfileRename extends CommandProfileBase {
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
if(!(sender instanceof EntityPlayer)) {
|
||||
if (!(sender instanceof EntityPlayer)) {
|
||||
sendError(sender, "This command can only be used by a player.");
|
||||
return;
|
||||
}
|
||||
if(args.length < 2) {
|
||||
if (args.length < 2) {
|
||||
sendError(sender, "Usage: " + getUsage());
|
||||
return;
|
||||
}
|
||||
int slotId;
|
||||
try {
|
||||
slotId = Integer.parseInt(args[0]);
|
||||
} catch(NumberFormatException ex) {
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, "Slot ID must be a number.");
|
||||
return;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int i = 1; i < args.length; i++){
|
||||
if(i > 1) sb.append(" ");
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
if (i > 1) sb.append(" ");
|
||||
sb.append(args[i]);
|
||||
}
|
||||
String newName = sb.toString().trim();
|
||||
if(newName.length() > 20) {
|
||||
if (newName.length() > 20) {
|
||||
newName = newName.substring(0, 20);
|
||||
}
|
||||
if(!newName.matches("[A-Za-z ]+")){
|
||||
if (!newName.matches("[A-Za-z ]+")) {
|
||||
sendError(sender, "Invalid name. Only alphabetic characters and spaces are allowed.");
|
||||
return;
|
||||
}
|
||||
EntityPlayer player = (EntityPlayer)sender;
|
||||
if(ProfileController.Instance.getProfile(player) == null) {
|
||||
EntityPlayer player = (EntityPlayer) sender;
|
||||
if (ProfileController.Instance.getProfile(player) == null) {
|
||||
sendError(sender, "Profile not found.");
|
||||
return;
|
||||
}
|
||||
if(!ProfileController.Instance.getProfile(player).getSlots().containsKey(slotId)) {
|
||||
if (!ProfileController.Instance.getProfile(player).getSlots().containsKey(slotId)) {
|
||||
sendError(sender, "Slot %d not found in your profile.", slotId);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package kamkeel.npcs.controllers;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import kamkeel.npcs.CustomAttributes;
|
||||
import kamkeel.npcs.controllers.data.attribute.AttributeDefinition;
|
||||
import kamkeel.npcs.controllers.data.attribute.AttributeValueType;
|
||||
import kamkeel.npcs.CustomAttributes;
|
||||
import kamkeel.npcs.controllers.data.attribute.tracker.PlayerAttributeTracker;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@@ -24,7 +24,7 @@ public class AttributeController {
|
||||
private static final Map<UUID, PlayerAttributeTracker> trackers = new HashMap<>();
|
||||
private static final Map<String, AttributeDefinition> definitions = new HashMap<>();
|
||||
|
||||
public AttributeController(){
|
||||
public AttributeController() {
|
||||
this.Instance = this;
|
||||
definitions.clear();
|
||||
trackers.clear();
|
||||
|
||||
@@ -7,8 +7,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.*;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.api.handler.IPlayerData;
|
||||
import noppes.npcs.api.handler.data.IProfile;
|
||||
import noppes.npcs.api.handler.IProfileHandler;
|
||||
import noppes.npcs.api.handler.data.IProfile;
|
||||
import noppes.npcs.api.handler.data.ISlot;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.controllers.QuestController;
|
||||
@@ -31,24 +31,24 @@ import static noppes.npcs.CustomNpcsPermissions.*;
|
||||
public class ProfileController implements IProfileHandler {
|
||||
|
||||
// Message constants
|
||||
private static final String MSG_PLAYER_NOT_FOUND = "Player not found.";
|
||||
private static final String MSG_PROFILE_LOCKED_CLONE = "Profile is locked; cannot clone slot.";
|
||||
private static final String MSG_SOURCE_SLOT_NOT_EXIST = "Source slot does not exist.";
|
||||
private static final String MSG_CANNOT_CLONE_CURRENT = "Cannot clone to the current active slot.";
|
||||
private static final String MSG_INVALID_DEST_SLOT = "Invalid destination slot id.";
|
||||
private static final String MSG_CLONE_SUCCESS = "Slot cloned successfully.";
|
||||
private static final String MSG_PROFILE_LOCKED_REMOVE = "Profile is locked; cannot remove slot.";
|
||||
private static final String MSG_CANNOT_REMOVE_ACTIVE = "Cannot remove the currently active slot.";
|
||||
private static final String MSG_SLOT_NOT_EXIST = "Slot does not exist.";
|
||||
private static final String MSG_REMOVE_SUCCESS = "Slot removed successfully.";
|
||||
private static final String MSG_PROFILE_LOCKED_CREATE = "Profile is locked; cannot create slot.";
|
||||
private static final String MSG_MAX_SLOTS_REACHED = "Maximum allowed slots reached.";
|
||||
private static final String MSG_NEW_SLOT_CREATED = "New slot created successfully.";
|
||||
private static final String MSG_PROFILE_LOCKED_CHANGE = "Profile is locked; cannot change slot.";
|
||||
private static final String MSG_SLOT_ALREADY_ACTIVE = "Slot is already active.";
|
||||
private static final String MSG_REGION_NOT_ALLOWED = "Profile switching not allowed from your current location.";
|
||||
private static final String MSG_CHANGE_SUCCESS = "Slot changed successfully.";
|
||||
private static final String MSG_CANCELLED = "Operation cancelled.";
|
||||
private static final String MSG_PLAYER_NOT_FOUND = "Player not found.";
|
||||
private static final String MSG_PROFILE_LOCKED_CLONE = "Profile is locked; cannot clone slot.";
|
||||
private static final String MSG_SOURCE_SLOT_NOT_EXIST = "Source slot does not exist.";
|
||||
private static final String MSG_CANNOT_CLONE_CURRENT = "Cannot clone to the current active slot.";
|
||||
private static final String MSG_INVALID_DEST_SLOT = "Invalid destination slot id.";
|
||||
private static final String MSG_CLONE_SUCCESS = "Slot cloned successfully.";
|
||||
private static final String MSG_PROFILE_LOCKED_REMOVE = "Profile is locked; cannot remove slot.";
|
||||
private static final String MSG_CANNOT_REMOVE_ACTIVE = "Cannot remove the currently active slot.";
|
||||
private static final String MSG_SLOT_NOT_EXIST = "Slot does not exist.";
|
||||
private static final String MSG_REMOVE_SUCCESS = "Slot removed successfully.";
|
||||
private static final String MSG_PROFILE_LOCKED_CREATE = "Profile is locked; cannot create slot.";
|
||||
private static final String MSG_MAX_SLOTS_REACHED = "Maximum allowed slots reached.";
|
||||
private static final String MSG_NEW_SLOT_CREATED = "New slot created successfully.";
|
||||
private static final String MSG_PROFILE_LOCKED_CHANGE = "Profile is locked; cannot change slot.";
|
||||
private static final String MSG_SLOT_ALREADY_ACTIVE = "Slot is already active.";
|
||||
private static final String MSG_REGION_NOT_ALLOWED = "Profile switching not allowed from your current location.";
|
||||
private static final String MSG_CHANGE_SUCCESS = "Slot changed successfully.";
|
||||
private static final String MSG_CANCELLED = "Operation cancelled.";
|
||||
|
||||
public static Map<String, IProfileData> profileTypes = new HashMap<>();
|
||||
public static Map<UUID, Profile> activeProfiles = new HashMap<>();
|
||||
@@ -91,7 +91,7 @@ public class ProfileController implements IProfileHandler {
|
||||
}
|
||||
|
||||
public synchronized void login(EntityPlayer player) {
|
||||
if(!ConfigMain.ProfilesEnabled)
|
||||
if (!ConfigMain.ProfilesEnabled)
|
||||
return;
|
||||
|
||||
if (player == null)
|
||||
@@ -162,7 +162,7 @@ public class ProfileController implements IProfileHandler {
|
||||
backupProfile(uuid, compound);
|
||||
} catch (Exception e) {
|
||||
LogWriter.except(e);
|
||||
} finally {
|
||||
} finally {
|
||||
profile.setLocked(false);
|
||||
}
|
||||
});
|
||||
@@ -365,17 +365,17 @@ public class ProfileController implements IProfileHandler {
|
||||
}
|
||||
|
||||
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||
if(profile.player != null){
|
||||
if (profile.player != null) {
|
||||
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(profile.player);
|
||||
if(EventHooks.onProfileRemove(handler, scriptPlayer, profile, slotId, false))
|
||||
if (EventHooks.onProfileRemove(handler, scriptPlayer, profile, slotId, false))
|
||||
return ProfileOperation.error(MSG_CANCELLED);
|
||||
}
|
||||
|
||||
profile.getSlots().remove(slotId);
|
||||
|
||||
if(profile.player != null){
|
||||
if (profile.player != null) {
|
||||
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(profile.player);
|
||||
EventHooks.onProfileRemove(handler, scriptPlayer, profile, slotId, true);
|
||||
EventHooks.onProfileRemove(handler, scriptPlayer, profile, slotId, true);
|
||||
}
|
||||
|
||||
return ProfileOperation.success(MSG_REMOVE_SUCCESS);
|
||||
@@ -403,21 +403,21 @@ public class ProfileController implements IProfileHandler {
|
||||
}
|
||||
|
||||
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||
if(profile.player != null){
|
||||
if (profile.player != null) {
|
||||
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(profile.player);
|
||||
if(EventHooks.onProfileCreate(handler, scriptPlayer, profile, newSlotId, false))
|
||||
if (EventHooks.onProfileCreate(handler, scriptPlayer, profile, newSlotId, false))
|
||||
return ProfileOperation.error(MSG_CANCELLED);
|
||||
}
|
||||
|
||||
Slot newSlot = new Slot(newSlotId, "Slot " + newSlotId);
|
||||
newSlot.setLastLoaded(System.currentTimeMillis());
|
||||
profile.getSlots().put(newSlotId, newSlot);
|
||||
if(profile.player != null){
|
||||
if (profile.player != null) {
|
||||
verifySlotQuests(profile.player);
|
||||
save(profile.player, profile);
|
||||
|
||||
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(profile.player);
|
||||
EventHooks.onProfileCreate(handler, scriptPlayer, profile, newSlotId, true);
|
||||
EventHooks.onProfileCreate(handler, scriptPlayer, profile, newSlotId, true);
|
||||
}
|
||||
return ProfileOperation.success(MSG_NEW_SLOT_CREATED);
|
||||
}
|
||||
@@ -476,7 +476,7 @@ public class ProfileController implements IProfileHandler {
|
||||
|
||||
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(profile.player);
|
||||
if(EventHooks.onProfileChange(handler, scriptPlayer, profile, newSlotId, prevSlot, false))
|
||||
if (EventHooks.onProfileChange(handler, scriptPlayer, profile, newSlotId, prevSlot, false))
|
||||
return ProfileOperation.error(MSG_CANCELLED);
|
||||
|
||||
|
||||
@@ -484,7 +484,7 @@ public class ProfileController implements IProfileHandler {
|
||||
profile.currentSlotId = newSlotId;
|
||||
loadSlotData(profile.player);
|
||||
|
||||
EventHooks.onProfileChange(handler, scriptPlayer, profile, newSlotId, prevSlot, true);
|
||||
EventHooks.onProfileChange(handler, scriptPlayer, profile, newSlotId, prevSlot, true);
|
||||
} else {
|
||||
return ProfileOperation.error(MSG_PLAYER_NOT_FOUND);
|
||||
}
|
||||
@@ -630,7 +630,7 @@ public class ProfileController implements IProfileHandler {
|
||||
pdata.profileSlot = profile.getCurrentSlotId();
|
||||
pdata.save();
|
||||
|
||||
if(ConfigMain.AttributesEnabled)
|
||||
if (ConfigMain.AttributesEnabled)
|
||||
AttributeController.getTracker(player).recalcAttributes(player);
|
||||
}
|
||||
|
||||
@@ -684,14 +684,14 @@ public class ProfileController implements IProfileHandler {
|
||||
|
||||
@Override
|
||||
public IProfile getProfile(IPlayer player) {
|
||||
if(player == null || player.getMCEntity() == null)
|
||||
if (player == null || player.getMCEntity() == null)
|
||||
return null;
|
||||
return getProfile((EntityPlayer) player.getMCEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean changeSlot(IPlayer player, int slotID) {
|
||||
if(player == null || player.getMCEntity() == null)
|
||||
if (player == null || player.getMCEntity() == null)
|
||||
return false;
|
||||
|
||||
EntityPlayer entityPlayer = (EntityPlayer) player.getMCEntity();
|
||||
@@ -701,19 +701,19 @@ public class ProfileController implements IProfileHandler {
|
||||
|
||||
@Override
|
||||
public boolean hasSlot(IPlayer player, int slotID) {
|
||||
if(player == null || player.getMCEntity() == null)
|
||||
if (player == null || player.getMCEntity() == null)
|
||||
return false;
|
||||
|
||||
EntityPlayer entityPlayer = (EntityPlayer) player.getMCEntity();
|
||||
Profile profile = getProfile(entityPlayer);
|
||||
if(profile == null)
|
||||
if (profile == null)
|
||||
return false;
|
||||
return profile.getSlots().containsKey(slotID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeSlot(IPlayer player, int slotID) {
|
||||
if(player == null || player.getMCEntity() == null)
|
||||
if (player == null || player.getMCEntity() == null)
|
||||
return false;
|
||||
|
||||
EntityPlayer entityPlayer = (EntityPlayer) player.getMCEntity();
|
||||
@@ -724,19 +724,19 @@ public class ProfileController implements IProfileHandler {
|
||||
@Override
|
||||
public IPlayerData getSlotPlayerData(IPlayer player, int slotID) {
|
||||
PlayerData playerData;
|
||||
if(player == null || player.getMCEntity() == null)
|
||||
if (player == null || player.getMCEntity() == null)
|
||||
return null;
|
||||
|
||||
EntityPlayer entityPlayer = (EntityPlayer) player.getMCEntity();
|
||||
Profile profile = getProfile(entityPlayer);
|
||||
if(profile == null)
|
||||
if (profile == null)
|
||||
return null;
|
||||
return getSlotPlayerData(entityPlayer, slotID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveSlotData(IPlayer player) {
|
||||
if(player == null || player.getMCEntity() == null)
|
||||
if (player == null || player.getMCEntity() == null)
|
||||
return;
|
||||
|
||||
EntityPlayer entityPlayer = (EntityPlayer) player.getMCEntity();
|
||||
@@ -746,10 +746,10 @@ public class ProfileController implements IProfileHandler {
|
||||
public IPlayerData getSlotPlayerData(EntityPlayer player, int slotID) {
|
||||
PlayerData playerData;
|
||||
Profile profile = getProfile(player);
|
||||
if(profile == null)
|
||||
if (profile == null)
|
||||
return null;
|
||||
|
||||
if(profile.currentSlotId == slotID){
|
||||
if (profile.currentSlotId == slotID) {
|
||||
playerData = PlayerData.get(player);
|
||||
} else {
|
||||
Slot slot = (Slot) profile.getSlots().get(slotID);
|
||||
@@ -759,14 +759,14 @@ public class ProfileController implements IProfileHandler {
|
||||
}
|
||||
|
||||
public PlayerData getSlotPlayerData(EntityPlayer player, Slot slot) {
|
||||
if(slot == null)
|
||||
if (slot == null)
|
||||
return null;
|
||||
|
||||
PlayerData playerData = new PlayerData();
|
||||
playerData.player = player;
|
||||
|
||||
NBTTagCompound compound = slot.getComponentData(new CNPCData().getTagName());
|
||||
if(compound == null)
|
||||
if (compound == null)
|
||||
compound = new NBTTagCompound();
|
||||
playerData.setNBT(compound);
|
||||
return playerData;
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class SyncController {
|
||||
|
||||
public static void syncPlayer(EntityPlayerMP player){
|
||||
public static void syncPlayer(EntityPlayerMP player) {
|
||||
|
||||
// Login Packet
|
||||
PacketHandler.Instance.sendToPlayer(new LoginPacket(), player);
|
||||
@@ -99,43 +99,43 @@ public class SyncController {
|
||||
syncPlayerData(player, false);
|
||||
}
|
||||
|
||||
public static NBTTagCompound workbenchNBT(){
|
||||
public static NBTTagCompound workbenchNBT() {
|
||||
RecipeController controller = RecipeController.Instance;
|
||||
NBTTagList list = new NBTTagList();
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
for(RecipeCarpentry recipe : controller.globalRecipes.values()){
|
||||
for (RecipeCarpentry recipe : controller.globalRecipes.values()) {
|
||||
list.appendTag(recipe.writeNBT());
|
||||
}
|
||||
compound.setTag("recipes", list);
|
||||
return compound;
|
||||
}
|
||||
|
||||
public static NBTTagCompound carpentryNBT(){
|
||||
public static NBTTagCompound carpentryNBT() {
|
||||
RecipeController controller = RecipeController.Instance;
|
||||
NBTTagList list = new NBTTagList();
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
for(RecipeCarpentry recipe : controller.carpentryRecipes.values()){
|
||||
for (RecipeCarpentry recipe : controller.carpentryRecipes.values()) {
|
||||
list.appendTag(recipe.writeNBT());
|
||||
}
|
||||
compound.setTag("recipes", list);
|
||||
return compound;
|
||||
}
|
||||
|
||||
public static NBTTagCompound anvilNBT(){
|
||||
public static NBTTagCompound anvilNBT() {
|
||||
RecipeController controller = RecipeController.Instance;
|
||||
NBTTagList list = new NBTTagList();
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
for(RecipeAnvil recipe : controller.anvilRecipes.values()){
|
||||
for (RecipeAnvil recipe : controller.anvilRecipes.values()) {
|
||||
list.appendTag(recipe.writeNBT());
|
||||
}
|
||||
compound.setTag("recipes", list);
|
||||
return compound;
|
||||
}
|
||||
|
||||
public static NBTTagCompound factionsNBT(){
|
||||
public static NBTTagCompound factionsNBT() {
|
||||
NBTTagList list = new NBTTagList();
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
for(Faction faction : FactionController.getInstance().factions.values()){
|
||||
for (Faction faction : FactionController.getInstance().factions.values()) {
|
||||
NBTTagCompound factioNBT = new NBTTagCompound();
|
||||
faction.writeNBT(factioNBT);
|
||||
list.appendTag(factioNBT);
|
||||
@@ -144,13 +144,13 @@ public class SyncController {
|
||||
return compound;
|
||||
}
|
||||
|
||||
public static NBTTagCompound dialogCategoriesNBT(){
|
||||
public static NBTTagCompound dialogCategoriesNBT() {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
NBTTagList categoryList = new NBTTagList();
|
||||
for(DialogCategory category : DialogController.Instance.categories.values()){
|
||||
for (DialogCategory category : DialogController.Instance.categories.values()) {
|
||||
NBTTagCompound questCompound = new NBTTagCompound();
|
||||
NBTTagList dialogList = new NBTTagList();
|
||||
for(int dialogID : category.dialogs.keySet()){
|
||||
for (int dialogID : category.dialogs.keySet()) {
|
||||
Dialog quest = category.dialogs.get(dialogID);
|
||||
dialogList.appendTag(quest.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
@@ -162,13 +162,14 @@ public class SyncController {
|
||||
return compound;
|
||||
}
|
||||
|
||||
public static NBTTagCompound questCategoriesNBT(){
|
||||
public static NBTTagCompound questCategoriesNBT() {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
NBTTagList categoryList = new NBTTagList();
|
||||
for(QuestCategory category : QuestController.Instance.categories.values()){
|
||||
NBTTagCompound questCompound = new NBTTagCompound();;
|
||||
for (QuestCategory category : QuestController.Instance.categories.values()) {
|
||||
NBTTagCompound questCompound = new NBTTagCompound();
|
||||
;
|
||||
NBTTagList questList = new NBTTagList();
|
||||
for(int questID : category.quests.keySet()){
|
||||
for (int questID : category.quests.keySet()) {
|
||||
Quest quest = category.quests.get(questID);
|
||||
questList.appendTag(quest.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
@@ -180,7 +181,7 @@ public class SyncController {
|
||||
return compound;
|
||||
}
|
||||
|
||||
public static NBTTagCompound customEffectsNBT(){
|
||||
public static NBTTagCompound customEffectsNBT() {
|
||||
NBTTagList list = new NBTTagList();
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
for (CustomEffect effect : CustomEffectController.getInstance().getCustomEffects().values()) {
|
||||
@@ -190,7 +191,7 @@ public class SyncController {
|
||||
return compound;
|
||||
}
|
||||
|
||||
public static NBTTagCompound magicsNBT(){
|
||||
public static NBTTagCompound magicsNBT() {
|
||||
NBTTagList list = new NBTTagList();
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
for (Magic magic : MagicController.getInstance().magics.values()) {
|
||||
@@ -202,7 +203,7 @@ public class SyncController {
|
||||
return compound;
|
||||
}
|
||||
|
||||
public static NBTTagCompound magicCyclesNBT(){
|
||||
public static NBTTagCompound magicCyclesNBT() {
|
||||
NBTTagList list = new NBTTagList();
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
for (MagicCycle cycle : MagicController.getInstance().cycles.values()) {
|
||||
@@ -214,10 +215,10 @@ public class SyncController {
|
||||
return compound;
|
||||
}
|
||||
|
||||
public static void syncPlayerData(EntityPlayerMP player, boolean update){
|
||||
public static void syncPlayerData(EntityPlayerMP player, boolean update) {
|
||||
PlayerData data = PlayerData.get(player);
|
||||
if(data != null){
|
||||
if(update){
|
||||
if (data != null) {
|
||||
if (update) {
|
||||
PacketHandler.Instance.sendToPlayer(new SyncPacket(
|
||||
EnumSyncType.PLAYERDATA,
|
||||
EnumSyncAction.UPDATE,
|
||||
@@ -234,7 +235,7 @@ public class SyncController {
|
||||
}
|
||||
}
|
||||
|
||||
public static void syncRemove(EnumSyncType enumSyncType, int id){
|
||||
public static void syncRemove(EnumSyncType enumSyncType, int id) {
|
||||
PacketHandler.Instance.sendToAll(new SyncPacket(
|
||||
enumSyncType,
|
||||
EnumSyncAction.REMOVE,
|
||||
@@ -299,7 +300,7 @@ public class SyncController {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void clientSync(EnumSyncType enumSyncType, NBTTagCompound fullCompound) {
|
||||
switch (enumSyncType){
|
||||
switch (enumSyncType) {
|
||||
case FACTION: {
|
||||
NBTTagList list = fullCompound.getTagList("Factions", 10);
|
||||
for (int i = 0; i < list.tagCount(); i++) {
|
||||
@@ -312,22 +313,21 @@ public class SyncController {
|
||||
break;
|
||||
}
|
||||
case DIALOG_CATEGORY: {
|
||||
if(!fullCompound.hasNoTags()){
|
||||
if (!fullCompound.hasNoTags()) {
|
||||
NBTTagList categories = fullCompound.getTagList("DialogCategories", 10);
|
||||
for(int j = 0; j < fullCompound.getTagList("DialogCategories", 10).tagCount(); j++) {
|
||||
for (int j = 0; j < fullCompound.getTagList("DialogCategories", 10).tagCount(); j++) {
|
||||
NBTTagCompound categoryCompound = categories.getCompoundTagAt(j);
|
||||
if(categoryCompound.hasNoTags())
|
||||
if (categoryCompound.hasNoTags())
|
||||
continue;
|
||||
|
||||
DialogCategory category = new DialogCategory();
|
||||
category.readSmallNBT(categoryCompound.getCompoundTag("CatNBT"));
|
||||
NBTTagList dialogList = categoryCompound.getTagList("Data", 10);
|
||||
if(DialogController.Instance.categoriesSync.containsKey(category.id)){
|
||||
if (DialogController.Instance.categoriesSync.containsKey(category.id)) {
|
||||
category = DialogController.Instance.categoriesSync.get(category.id);
|
||||
category.readSmallNBT(categoryCompound.getCompoundTag("CatNBT"));
|
||||
}
|
||||
for(int i = 0; i < dialogList.tagCount(); i++)
|
||||
{
|
||||
for (int i = 0; i < dialogList.tagCount(); i++) {
|
||||
Dialog dialog = new Dialog();
|
||||
dialog.readNBT(dialogList.getCompoundTagAt(i));
|
||||
dialog.category = category;
|
||||
@@ -338,8 +338,8 @@ public class SyncController {
|
||||
}
|
||||
|
||||
HashMap<Integer, Dialog> dialogs = new HashMap<Integer, Dialog>();
|
||||
for(DialogCategory category : DialogController.Instance.categoriesSync.values()){
|
||||
for(Dialog dialog : category.dialogs.values()){
|
||||
for (DialogCategory category : DialogController.Instance.categoriesSync.values()) {
|
||||
for (Dialog dialog : category.dialogs.values()) {
|
||||
dialogs.put(dialog.id, dialog);
|
||||
}
|
||||
}
|
||||
@@ -350,22 +350,21 @@ public class SyncController {
|
||||
break;
|
||||
}
|
||||
case QUEST_CATEGORY: {
|
||||
if(!fullCompound.hasNoTags()){
|
||||
if (!fullCompound.hasNoTags()) {
|
||||
NBTTagList categories = fullCompound.getTagList("QuestCategories", 10);
|
||||
for(int j = 0; j < fullCompound.getTagList("QuestCategories", 10).tagCount(); j++) {
|
||||
for (int j = 0; j < fullCompound.getTagList("QuestCategories", 10).tagCount(); j++) {
|
||||
NBTTagCompound categoryCompound = categories.getCompoundTagAt(j);
|
||||
if(categoryCompound.hasNoTags())
|
||||
if (categoryCompound.hasNoTags())
|
||||
continue;
|
||||
|
||||
QuestCategory category = new QuestCategory();
|
||||
category.readSmallNBT(categoryCompound.getCompoundTag("CatNBT"));
|
||||
NBTTagList questList = categoryCompound.getTagList("Data", 10);
|
||||
if(QuestController.Instance.categoriesSync.containsKey(category.id)){
|
||||
if (QuestController.Instance.categoriesSync.containsKey(category.id)) {
|
||||
category = QuestController.Instance.categoriesSync.get(category.id);
|
||||
category.readSmallNBT(categoryCompound.getCompoundTag("CatNBT"));
|
||||
}
|
||||
for(int i = 0; i < questList.tagCount(); i++)
|
||||
{
|
||||
for (int i = 0; i < questList.tagCount(); i++) {
|
||||
Quest quest = new Quest();
|
||||
quest.readNBT(questList.getCompoundTagAt(i));
|
||||
quest.category = category;
|
||||
@@ -375,9 +374,9 @@ public class SyncController {
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<Integer,Quest> quests = new HashMap<Integer, Quest>();
|
||||
for(QuestCategory category : QuestController.Instance.categoriesSync.values()){
|
||||
for(Quest quest : category.quests.values()){
|
||||
HashMap<Integer, Quest> quests = new HashMap<Integer, Quest>();
|
||||
for (QuestCategory category : QuestController.Instance.categoriesSync.values()) {
|
||||
for (Quest quest : category.quests.values()) {
|
||||
quests.put(quest.id, quest);
|
||||
}
|
||||
}
|
||||
@@ -423,13 +422,12 @@ public class SyncController {
|
||||
}
|
||||
case WORKBENCH_RECIPES: {
|
||||
NBTTagList list = fullCompound.getTagList("recipes", 10);
|
||||
if(list == null)
|
||||
if (list == null)
|
||||
return;
|
||||
|
||||
for(int i = 0; i < list.tagCount(); i++)
|
||||
{
|
||||
for (int i = 0; i < list.tagCount(); i++) {
|
||||
RecipeCarpentry recipe = RecipeCarpentry.read(list.getCompoundTagAt(i));
|
||||
RecipeController.syncRecipes.put(recipe.id,recipe);
|
||||
RecipeController.syncRecipes.put(recipe.id, recipe);
|
||||
}
|
||||
|
||||
RecipeController.reloadGlobalRecipes(RecipeController.syncRecipes);
|
||||
@@ -438,13 +436,12 @@ public class SyncController {
|
||||
}
|
||||
case CARPENTRY_RECIPES: {
|
||||
NBTTagList list = fullCompound.getTagList("recipes", 10);
|
||||
if(list == null)
|
||||
if (list == null)
|
||||
return;
|
||||
|
||||
for(int i = 0; i < list.tagCount(); i++)
|
||||
{
|
||||
for (int i = 0; i < list.tagCount(); i++) {
|
||||
RecipeCarpentry recipe = RecipeCarpentry.read(list.getCompoundTagAt(i));
|
||||
RecipeController.syncRecipes.put(recipe.id,recipe);
|
||||
RecipeController.syncRecipes.put(recipe.id, recipe);
|
||||
}
|
||||
|
||||
RecipeController.Instance.carpentryRecipes = RecipeController.syncRecipes;
|
||||
@@ -453,11 +450,10 @@ public class SyncController {
|
||||
}
|
||||
case ANVIL_RECIPES: {
|
||||
NBTTagList list = fullCompound.getTagList("recipes", 10);
|
||||
if(list == null)
|
||||
if (list == null)
|
||||
return;
|
||||
|
||||
for(int i = 0; i < list.tagCount(); i++)
|
||||
{
|
||||
for (int i = 0; i < list.tagCount(); i++) {
|
||||
RecipeAnvil recipe = RecipeAnvil.read(list.getCompoundTagAt(i));
|
||||
RecipeController.syncAnvilRecipes.put(recipe.id, recipe);
|
||||
}
|
||||
@@ -490,7 +486,7 @@ public class SyncController {
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void clientUpdate(EnumSyncType enumSyncType, int category_id, NBTTagCompound compound) {
|
||||
switch (enumSyncType){
|
||||
switch (enumSyncType) {
|
||||
case FACTION: {
|
||||
Faction faction = new Faction();
|
||||
faction.readNBT(compound);
|
||||
@@ -519,12 +515,11 @@ public class SyncController {
|
||||
QuestCategory category = new QuestCategory();
|
||||
category.readSmallNBT(compound.getCompoundTag("CatNBT"));
|
||||
NBTTagList list = compound.getTagList("Data", 10);
|
||||
if(QuestController.Instance.categoriesSync.containsKey(category.id)){
|
||||
if (QuestController.Instance.categoriesSync.containsKey(category.id)) {
|
||||
category = QuestController.Instance.categoriesSync.get(category.id);
|
||||
category.readSmallNBT(compound.getCompoundTag("CatNBT"));
|
||||
}
|
||||
for(int i = 0; i < list.tagCount(); i++)
|
||||
{
|
||||
for (int i = 0; i < list.tagCount(); i++) {
|
||||
Quest quest = new Quest();
|
||||
quest.readNBT(list.getCompoundTagAt(i));
|
||||
quest.category = category;
|
||||
@@ -537,12 +532,11 @@ public class SyncController {
|
||||
DialogCategory category = new DialogCategory();
|
||||
category.readSmallNBT(compound.getCompoundTag("CatNBT"));
|
||||
NBTTagList list = compound.getTagList("Data", 10);
|
||||
if(DialogController.Instance.categoriesSync.containsKey(category.id)){
|
||||
if (DialogController.Instance.categoriesSync.containsKey(category.id)) {
|
||||
category = DialogController.Instance.categoriesSync.get(category.id);
|
||||
category.readSmallNBT(compound.getCompoundTag("CatNBT"));
|
||||
}
|
||||
for(int i = 0; i < list.tagCount(); i++)
|
||||
{
|
||||
for (int i = 0; i < list.tagCount(); i++) {
|
||||
Dialog dialog = new Dialog();
|
||||
dialog.readNBT(list.getCompoundTagAt(i));
|
||||
dialog.category = category;
|
||||
@@ -591,7 +585,7 @@ public class SyncController {
|
||||
public static NBTTagCompound updateQuestCat(QuestCategory questCategory) {
|
||||
NBTTagCompound questCompound = new NBTTagCompound();
|
||||
NBTTagList questList = new NBTTagList();
|
||||
for(int questID : questCategory.quests.keySet()){
|
||||
for (int questID : questCategory.quests.keySet()) {
|
||||
Quest quest = questCategory.quests.get(questID);
|
||||
questList.appendTag(quest.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
@@ -603,7 +597,7 @@ public class SyncController {
|
||||
public static NBTTagCompound updateDialogCat(DialogCategory dialogCategory) {
|
||||
NBTTagCompound dialogCompound = new NBTTagCompound();
|
||||
NBTTagList dialogList = new NBTTagList();
|
||||
for(int questID : dialogCategory.dialogs.keySet()){
|
||||
for (int questID : dialogCategory.dialogs.keySet()) {
|
||||
Dialog dialog = dialogCategory.dialogs.get(questID);
|
||||
dialogList.appendTag(dialog.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
@@ -614,36 +608,36 @@ public class SyncController {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void clientSyncRemove(EnumSyncType enumSyncType, int id) {
|
||||
switch (enumSyncType){
|
||||
switch (enumSyncType) {
|
||||
case FACTION:
|
||||
FactionController.getInstance().factions.remove(id);
|
||||
break;
|
||||
case DIALOG:
|
||||
Dialog dialog = DialogController.Instance.dialogs.remove(id);
|
||||
if(dialog != null) {
|
||||
if (dialog != null) {
|
||||
dialog.category.dialogs.remove(id);
|
||||
}
|
||||
break;
|
||||
case DIALOG_CATEGORY:
|
||||
DialogCategory dialogCategory = DialogController.Instance.categories.remove(id);
|
||||
if(dialogCategory != null) {
|
||||
if (dialogCategory != null) {
|
||||
DialogController.Instance.dialogs.keySet().removeAll(dialogCategory.dialogs.keySet());
|
||||
}
|
||||
break;
|
||||
case QUEST:
|
||||
Quest quest = QuestController.Instance.quests.remove(id);
|
||||
if(quest != null) {
|
||||
if (quest != null) {
|
||||
quest.category.quests.remove(id);
|
||||
}
|
||||
break;
|
||||
case QUEST_CATEGORY:
|
||||
QuestCategory questCategory = QuestController.Instance.categories.remove(id);
|
||||
if(questCategory != null) {
|
||||
if (questCategory != null) {
|
||||
QuestController.Instance.quests.keySet().removeAll(questCategory.quests.keySet());
|
||||
}
|
||||
break;
|
||||
case MAGIC:
|
||||
for(MagicCycle cycle : MagicController.getInstance().cycles.values()){
|
||||
for (MagicCycle cycle : MagicController.getInstance().cycles.values()) {
|
||||
cycle.associations.remove(id);
|
||||
}
|
||||
MagicController.getInstance().cycles.remove(id);
|
||||
@@ -657,7 +651,7 @@ public class SyncController {
|
||||
}
|
||||
}
|
||||
|
||||
public static void syncEffects(EntityPlayerMP playerMP){
|
||||
public static void syncEffects(EntityPlayerMP playerMP) {
|
||||
ConcurrentHashMap<EffectKey, PlayerEffect> playerEffects = CustomEffectController.getInstance().getPlayerEffects(playerMP);
|
||||
PlayerData playerData = PlayerData.get(playerMP);
|
||||
playerData.effectData.setEffects(playerEffects);
|
||||
@@ -669,7 +663,7 @@ public class SyncController {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void clientSyncEffects(NBTTagCompound compound) {
|
||||
PlayerData playerData = PlayerData.get(Minecraft.getMinecraft().thePlayer);
|
||||
if(playerData != null){
|
||||
if (playerData != null) {
|
||||
playerData.setPlayerEffects(compound);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ package kamkeel.npcs.controllers.data.attribute;
|
||||
*/
|
||||
public interface ICustomAttribute {
|
||||
AttributeDefinition getAttribute();
|
||||
|
||||
float getValue();
|
||||
|
||||
void setValue(float value);
|
||||
}
|
||||
+1
@@ -2,6 +2,7 @@ package kamkeel.npcs.controllers.data.attribute.requirement;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
+4
-4
@@ -20,9 +20,9 @@ public class QuestActiveRequirement implements IRequirementChecker {
|
||||
|
||||
@Override
|
||||
public String getTooltipValue(NBTTagCompound nbt) {
|
||||
if(nbt.hasKey(getKey())) {
|
||||
if (nbt.hasKey(getKey())) {
|
||||
int questID = nbt.getInteger(getKey());
|
||||
if(QuestController.Instance.get(questID) != null) {
|
||||
if (QuestController.Instance.get(questID) != null) {
|
||||
return QuestController.Instance.get(questID).getName();
|
||||
}
|
||||
}
|
||||
@@ -31,14 +31,14 @@ public class QuestActiveRequirement implements IRequirementChecker {
|
||||
|
||||
@Override
|
||||
public void apply(NBTTagCompound nbt, Object value) {
|
||||
if(value instanceof Integer) {
|
||||
if (value instanceof Integer) {
|
||||
nbt.setInteger(getKey(), (Integer) value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check(EntityPlayer player, NBTTagCompound nbt) {
|
||||
if(nbt.hasKey(getKey())) {
|
||||
if (nbt.hasKey(getKey())) {
|
||||
int questID = nbt.getInteger(getKey());
|
||||
return PlayerData.get(player).questData.hasActiveQuest(questID);
|
||||
}
|
||||
|
||||
+4
-4
@@ -20,9 +20,9 @@ public class QuestCompletedRequirement implements IRequirementChecker {
|
||||
|
||||
@Override
|
||||
public String getTooltipValue(NBTTagCompound nbt) {
|
||||
if(nbt.hasKey(getKey())) {
|
||||
if (nbt.hasKey(getKey())) {
|
||||
int questID = nbt.getInteger(getKey());
|
||||
if(QuestController.Instance.get(questID) != null) {
|
||||
if (QuestController.Instance.get(questID) != null) {
|
||||
return QuestController.Instance.get(questID).getName();
|
||||
}
|
||||
}
|
||||
@@ -31,14 +31,14 @@ public class QuestCompletedRequirement implements IRequirementChecker {
|
||||
|
||||
@Override
|
||||
public void apply(NBTTagCompound nbt, Object value) {
|
||||
if(value instanceof Integer) {
|
||||
if (value instanceof Integer) {
|
||||
nbt.setInteger(getKey(), (Integer) value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check(EntityPlayer player, NBTTagCompound nbt) {
|
||||
if(nbt.hasKey(getKey())) {
|
||||
if (nbt.hasKey(getKey())) {
|
||||
int questID = nbt.getInteger(getKey());
|
||||
return PlayerData.get(player).questData.hasFinishedQuest(questID);
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
package kamkeel.npcs.controllers.data.attribute.tracker;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public class AttributeRecalcEvent {
|
||||
private static final List<IAttributeRecalcListener> listeners = new ArrayList<>();
|
||||
|
||||
+9
-8
@@ -1,10 +1,5 @@
|
||||
package kamkeel.npcs.controllers.data.attribute.tracker;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import kamkeel.npcs.CustomAttributes;
|
||||
import kamkeel.npcs.controllers.AttributeController;
|
||||
import kamkeel.npcs.controllers.data.attribute.AttributeDefinition;
|
||||
@@ -20,9 +15,14 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerAttributeTracker {
|
||||
|
||||
public static UUID healthUUID = UUID.fromString("48a0ad75-2cf8-4838-ad2f-9a0aadc57dfe");
|
||||
public static UUID healthUUID = UUID.fromString("48a0ad75-2cf8-4838-ad2f-9a0aadc57dfe");
|
||||
|
||||
|
||||
private final UUID playerId;
|
||||
@@ -59,7 +59,7 @@ public class PlayerAttributeTracker {
|
||||
// Update equipment tracker.
|
||||
PlayerEquipmentTracker currentEquip = new PlayerEquipmentTracker();
|
||||
currentEquip.updateFrom(player);
|
||||
ItemStack[] equipment = new ItemStack[] { currentEquip.heldItem, currentEquip.boots, currentEquip.leggings, currentEquip.chestplate, currentEquip.helmet };
|
||||
ItemStack[] equipment = new ItemStack[]{currentEquip.heldItem, currentEquip.boots, currentEquip.leggings, currentEquip.chestplate, currentEquip.helmet};
|
||||
for (ItemStack piece : equipment) {
|
||||
if (piece != null) {
|
||||
if (piece.stackTagCompound != null && piece.stackTagCompound.hasKey(AttributeItemUtil.TAG_RPGCORE)) {
|
||||
@@ -140,7 +140,8 @@ public class PlayerAttributeTracker {
|
||||
if (old != null) {
|
||||
maxHealthAttr.removeModifier(old);
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
if (bonusHealth != 0) {
|
||||
maxHealthAttr.applyModifier(new AttributeModifier(healthUUID, "RPGCoreHealthBonus", bonusHealth, 0));
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,9 +1,9 @@
|
||||
package kamkeel.npcs.controllers.data.attribute.tracker;
|
||||
|
||||
import kamkeel.npcs.util.AttributeItemUtil;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import kamkeel.npcs.util.AttributeItemUtil;
|
||||
|
||||
public class PlayerEquipmentTracker {
|
||||
public ItemStack heldItem;
|
||||
|
||||
@@ -32,12 +32,11 @@ public class CNPCData implements IProfileData {
|
||||
@Override
|
||||
public void setNBT(EntityPlayer player, NBTTagCompound replace) {
|
||||
PlayerData customNPCData = PlayerData.get(player);
|
||||
if(replace.hasNoTags()){
|
||||
if (replace.hasNoTags()) {
|
||||
PlayerData newData = new PlayerData();
|
||||
newData.player = player;
|
||||
customNPCData.setNBT((NBTTagCompound) newData.getNBT().copy());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
customNPCData.setNBT(replace);
|
||||
}
|
||||
customNPCData.updateClient = true;
|
||||
@@ -51,7 +50,7 @@ public class CNPCData implements IProfileData {
|
||||
@Override
|
||||
public ProfileOperation verifySwitch(EntityPlayer player) {
|
||||
PlayerData playerData = PlayerData.get(player);
|
||||
if(playerData.partyUUID != null)
|
||||
if (playerData.partyUUID != null)
|
||||
return ProfileOperation.error("Cannot switch while in Party");
|
||||
|
||||
return ProfileOperation.success("");
|
||||
|
||||
@@ -9,6 +9,7 @@ public interface IProfileData {
|
||||
|
||||
/**
|
||||
* Do not use the tags: Name, lastLoaded, ID.
|
||||
*
|
||||
* @return The save tag utilized in the Profile.
|
||||
*/
|
||||
public String getTagName();
|
||||
@@ -36,6 +37,7 @@ public interface IProfileData {
|
||||
|
||||
/**
|
||||
* Called before a profile switch occurs.
|
||||
*
|
||||
* @param player The player switching profiles.
|
||||
* @return true if allowed, false if not.
|
||||
*/
|
||||
@@ -44,7 +46,8 @@ public interface IProfileData {
|
||||
/**
|
||||
* NEW: Builds and returns a list of informational strings about this profile data,
|
||||
* based on the provided NBTTagCompound from the slot.
|
||||
* @param player The player in question.
|
||||
*
|
||||
* @param player The player in question.
|
||||
* @param compound The NBT data from the slot under this profile data's tag.
|
||||
* @return A list of InfoEntry with information
|
||||
*/
|
||||
|
||||
@@ -19,16 +19,16 @@ public class Profile implements IProfile {
|
||||
|
||||
public Profile(EntityPlayer player, NBTTagCompound compound) {
|
||||
this.player = player;
|
||||
if(compound.hasKey("CurrentSlotId")){
|
||||
if (compound.hasKey("CurrentSlotId")) {
|
||||
this.currentSlotId = compound.getInteger("CurrentSlotId");
|
||||
} else {
|
||||
this.currentSlotId = 0;
|
||||
}
|
||||
|
||||
if(compound.hasKey("Slots")){
|
||||
if (compound.hasKey("Slots")) {
|
||||
NBTTagCompound slotsCompound = compound.getCompoundTag("Slots");
|
||||
Set<String> keys = slotsCompound.func_150296_c();
|
||||
for(String key : keys) {
|
||||
for (String key : keys) {
|
||||
try {
|
||||
int slotId = Integer.parseInt(key);
|
||||
NBTTagCompound slotNBT = slotsCompound.getCompoundTag(key);
|
||||
@@ -76,13 +76,13 @@ public class Profile implements IProfile {
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT() {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
if(player != null)
|
||||
if (player != null)
|
||||
compound.setString("Name", player.getCommandSenderName());
|
||||
compound.setInteger("CurrentSlotId", currentSlotId);
|
||||
NBTTagCompound slotsCompound = new NBTTagCompound();
|
||||
for(Map.Entry<Integer, ISlot> entry : slots.entrySet()) {
|
||||
for (Map.Entry<Integer, ISlot> entry : slots.entrySet()) {
|
||||
// Save only non-temporary slots.
|
||||
if(entry.getValue().isTemporary())
|
||||
if (entry.getValue().isTemporary())
|
||||
continue;
|
||||
slotsCompound.setTag(String.valueOf(entry.getKey()), entry.getValue().toNBT());
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ public class ProfileInfoEntry {
|
||||
private int labelColor;
|
||||
private int resultColor;
|
||||
|
||||
public ProfileInfoEntry() {}
|
||||
public ProfileInfoEntry() {
|
||||
}
|
||||
|
||||
public ProfileInfoEntry(String label, int labelColor, String result, int resultColor) {
|
||||
this.label = label;
|
||||
@@ -43,8 +44,19 @@ public class ProfileInfoEntry {
|
||||
);
|
||||
}
|
||||
|
||||
public String getLabel() { return label; }
|
||||
public String getResult() { return result; }
|
||||
public int getLabelColor() { return labelColor; }
|
||||
public int getResultColor() { return resultColor; }
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public String getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public int getLabelColor() {
|
||||
return labelColor;
|
||||
}
|
||||
|
||||
public int getResultColor() {
|
||||
return resultColor;
|
||||
}
|
||||
}
|
||||
@@ -11,31 +11,31 @@ public class Developer {
|
||||
public static HashSet<UUID> QuestMaker = new HashSet<>();
|
||||
public static Developer Instance;
|
||||
|
||||
public Developer(){
|
||||
public Developer() {
|
||||
Instance = this;
|
||||
// Temp for testing
|
||||
Universal.add(UUID.fromString("29cc52dd-2c50-4e8f-a388-be6c497cf0b4"));
|
||||
}
|
||||
|
||||
public boolean hasUniversal(UUID uuid){
|
||||
if(Universal == null){
|
||||
public boolean hasUniversal(UUID uuid) {
|
||||
if (Universal == null) {
|
||||
Universal = new HashSet<>();
|
||||
}
|
||||
return Universal.contains(uuid);
|
||||
}
|
||||
|
||||
public boolean hasScriptUser(UUID uuid){
|
||||
if(ScriptUser == null){
|
||||
public boolean hasScriptUser(UUID uuid) {
|
||||
if (ScriptUser == null) {
|
||||
ScriptUser = new HashSet<>();
|
||||
}
|
||||
return ScriptUser.contains(uuid);
|
||||
}
|
||||
|
||||
public boolean hasWandUser(UUID uuid){
|
||||
public boolean hasWandUser(UUID uuid) {
|
||||
return WandUser.contains(uuid);
|
||||
}
|
||||
|
||||
public boolean hasQuestMaker(UUID uuid){
|
||||
public boolean hasQuestMaker(UUID uuid) {
|
||||
return QuestMaker.contains(uuid);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,17 +39,18 @@ public abstract class AbstractPacket {
|
||||
}
|
||||
|
||||
public abstract Enum getType();
|
||||
|
||||
public abstract PacketChannel getChannel();
|
||||
|
||||
public CustomNpcsPermissions.Permission getPermission(){
|
||||
public CustomNpcsPermissions.Permission getPermission() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean needsNPC(){
|
||||
public boolean needsNPC() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setNPC(EntityNPCInterface npc){
|
||||
public void setNPC(EntityNPCInterface npc) {
|
||||
this.npc = npc;
|
||||
}
|
||||
|
||||
|
||||
@@ -139,10 +139,13 @@ public abstract class LargeAbstractPacket extends AbstractPacket {
|
||||
protected abstract void handleCompleteData(ByteBuf data, EntityPlayer player) throws IOException;
|
||||
|
||||
@Override
|
||||
public final FMLProxyPacket generatePacket() {return null;}
|
||||
public final FMLProxyPacket generatePacket() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {}
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple storage class to keep track of partial data and how many bytes we've received so far.
|
||||
|
||||
@@ -34,7 +34,7 @@ public class PacketChannel {
|
||||
}
|
||||
|
||||
public void registerPacket(AbstractPacket packet) {
|
||||
if(packets.containsKey(packet.getType().ordinal())){
|
||||
if (packets.containsKey(packet.getType().ordinal())) {
|
||||
System.out.println("Packet ID: " + packet.getType().ordinal() + " is already registered in " + this.channelName);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package kamkeel.npcs.network;
|
||||
|
||||
public class PacketClient extends PacketHandler {
|
||||
|
||||
public static void sendClient(AbstractPacket packet){
|
||||
public static void sendClient(AbstractPacket packet) {
|
||||
PacketHandler.Instance.sendToServer(packet);
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,10 @@ import kamkeel.npcs.network.packets.data.script.ScriptOverlayClosePacket;
|
||||
import kamkeel.npcs.network.packets.data.script.ScriptOverlayDataPacket;
|
||||
import kamkeel.npcs.network.packets.data.script.ScriptedParticlePacket;
|
||||
import kamkeel.npcs.network.packets.player.*;
|
||||
import kamkeel.npcs.network.packets.player.customgui.CustomGuiButtonPacket;
|
||||
import kamkeel.npcs.network.packets.player.customgui.CustomGuiClosePacket;
|
||||
import kamkeel.npcs.network.packets.player.customgui.CustomGuiUnfocusedPacket;
|
||||
import kamkeel.npcs.network.packets.player.customgui.CustomScrollClickPacket;
|
||||
import kamkeel.npcs.network.packets.player.profile.*;
|
||||
import kamkeel.npcs.network.packets.request.*;
|
||||
import kamkeel.npcs.network.packets.request.animation.AnimationGetPacket;
|
||||
@@ -27,10 +31,6 @@ import kamkeel.npcs.network.packets.request.bank.BankRemovePacket;
|
||||
import kamkeel.npcs.network.packets.request.bank.BankSavePacket;
|
||||
import kamkeel.npcs.network.packets.request.bank.BanksGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.clone.*;
|
||||
import kamkeel.npcs.network.packets.player.customgui.CustomGuiButtonPacket;
|
||||
import kamkeel.npcs.network.packets.player.customgui.CustomGuiClosePacket;
|
||||
import kamkeel.npcs.network.packets.player.customgui.CustomGuiUnfocusedPacket;
|
||||
import kamkeel.npcs.network.packets.player.customgui.CustomScrollClickPacket;
|
||||
import kamkeel.npcs.network.packets.request.dialog.*;
|
||||
import kamkeel.npcs.network.packets.request.effects.EffectGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.effects.EffectRemovePacket;
|
||||
@@ -97,10 +97,10 @@ public class PacketHandler {
|
||||
public Map<EnumChannelType, FMLEventChannel> channels = new Hashtable<>();
|
||||
|
||||
// Client to Server
|
||||
public static final PacketChannel REQUEST_PACKET = new PacketChannel("CNPC+|Req", EnumChannelType.REQUEST);
|
||||
public static final PacketChannel REQUEST_PACKET = new PacketChannel("CNPC+|Req", EnumChannelType.REQUEST);
|
||||
|
||||
// Client to Server - Typically information
|
||||
public static final PacketChannel PLAYER_PACKET = new PacketChannel("CNPC+|Player", EnumChannelType.PLAYER);
|
||||
public static final PacketChannel PLAYER_PACKET = new PacketChannel("CNPC+|Player", EnumChannelType.PLAYER);
|
||||
|
||||
// Server to Client
|
||||
public static final PacketChannel DATA_PACKET = new PacketChannel("CNPC+|Data", EnumChannelType.DATA);
|
||||
@@ -118,7 +118,7 @@ public class PacketHandler {
|
||||
this.registerPlayerPackets();
|
||||
}
|
||||
|
||||
public void registerRequestPackets(){
|
||||
public void registerRequestPackets() {
|
||||
// NPC Packets
|
||||
REQUEST_PACKET.registerPacket(new NpcClosePacket());
|
||||
REQUEST_PACKET.registerPacket(new NpcDeletePacket());
|
||||
@@ -345,7 +345,7 @@ public class PacketHandler {
|
||||
REQUEST_PACKET.registerPacket(new DimensionTeleportPacket());
|
||||
}
|
||||
|
||||
public void registerDataPackets(){
|
||||
public void registerDataPackets() {
|
||||
// Data Packets
|
||||
DATA_PACKET.registerPacket(new LoginPacket());
|
||||
DATA_PACKET.registerPacket(new AchievementPacket());
|
||||
@@ -454,7 +454,7 @@ public class PacketHandler {
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
public FMLEventChannel getEventChannel(AbstractPacket abstractPacket){
|
||||
public FMLEventChannel getEventChannel(AbstractPacket abstractPacket) {
|
||||
PacketChannel packetChannel = getPacketChannel(abstractPacket.getChannel().getChannelType());
|
||||
if (packetChannel == null) {
|
||||
return null;
|
||||
@@ -491,20 +491,20 @@ public class PacketHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if(side == Side.SERVER){
|
||||
if(abstractPacket.getChannel() == REQUEST_PACKET && ConfigMain.OpsOnly && !NoppesUtilServer.isOp(player)){
|
||||
if (side == Side.SERVER) {
|
||||
if (abstractPacket.getChannel() == REQUEST_PACKET && ConfigMain.OpsOnly && !NoppesUtilServer.isOp(player)) {
|
||||
LogWriter.error(String.format("%s tried to use CNPC+ without being an op", player.getCommandSenderName()));
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if permission is allowed
|
||||
if(abstractPacket.getPermission() != null && !CustomNpcsPermissions.hasPermission(player, abstractPacket.getPermission())){
|
||||
if (abstractPacket.getPermission() != null && !CustomNpcsPermissions.hasPermission(player, abstractPacket.getPermission())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for required NPC
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(abstractPacket.needsNPC() && npc == null){
|
||||
if (abstractPacket.needsNPC() && npc == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ public class PacketUtil {
|
||||
}
|
||||
|
||||
private static boolean isValidItemForType(ItemStack item, EnumItemPacketType type) {
|
||||
if(item == null || item.getItem() == null)
|
||||
if (item == null || item.getItem() == null)
|
||||
return false;
|
||||
|
||||
switch (type) {
|
||||
@@ -213,9 +213,9 @@ public class PacketUtil {
|
||||
for (int i = 0; i < containers.size(); i++) {
|
||||
ScriptContainer container = containers.get(i);
|
||||
NBTTagCompound tabCompound = new NBTTagCompound();
|
||||
tabCompound.setInteger("Tab",i);
|
||||
tabCompound.setTag("Script",container.writeToNBT(new NBTTagCompound()));
|
||||
tabCompound.setInteger("TotalScripts",containers.size());
|
||||
tabCompound.setInteger("Tab", i);
|
||||
tabCompound.setTag("Script", container.writeToNBT(new NBTTagCompound()));
|
||||
tabCompound.setInteger("TotalScripts", containers.size());
|
||||
GuiDataPacket.sendGuiData(player, tabCompound);
|
||||
}
|
||||
}
|
||||
@@ -229,14 +229,14 @@ public class PacketUtil {
|
||||
|
||||
if (tab >= 0) {
|
||||
if (data.getScripts().size() > totalScripts) {
|
||||
data.setScripts(data.getScripts().subList(0,totalScripts));
|
||||
data.setScripts(data.getScripts().subList(0, totalScripts));
|
||||
} else while (data.getScripts().size() < totalScripts) {
|
||||
data.getScripts().add(new ScriptContainer(data));
|
||||
}
|
||||
NBTTagCompound tabCompound = ByteBufUtils.readNBT(buffer);
|
||||
ScriptContainer script = new ScriptContainer(data);
|
||||
script.readFromNBT(tabCompound);
|
||||
data.getScripts().set(tab,script);
|
||||
data.getScripts().set(tab, script);
|
||||
} else {
|
||||
NBTTagCompound compound = ByteBufUtils.readNBT(buffer);
|
||||
data.setLanguage(compound.getString("ScriptLanguage"));
|
||||
|
||||
@@ -53,7 +53,7 @@ public final class ConfigCommandPacket extends AbstractPacket {
|
||||
EnumConfigOperation configType = EnumConfigOperation.values()[in.readInt()];
|
||||
if (configType == EnumConfigOperation.FONT) { // Font Configuration
|
||||
String font = ByteBufUtils.readString(in);
|
||||
if(font == null)
|
||||
if (font == null)
|
||||
return;
|
||||
|
||||
int size = in.readInt();
|
||||
|
||||
@@ -15,7 +15,9 @@ import java.io.IOException;
|
||||
|
||||
public final class LoginPacket extends AbstractPacket {
|
||||
public static final String packetName = "CNPC+|Login";
|
||||
public LoginPacket() {}
|
||||
|
||||
public LoginPacket() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
|
||||
@@ -8,10 +8,8 @@ import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumDataPacket;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.ClientCacheHandler;
|
||||
import noppes.npcs.client.gui.hud.ClientHudManager;
|
||||
import noppes.npcs.client.gui.hud.EnumHudComponent;
|
||||
import noppes.npcs.client.gui.hud.HudComponent;
|
||||
@@ -52,7 +50,7 @@ public final class OverlayQuestTrackingPacket extends AbstractPacket {
|
||||
try {
|
||||
NBTTagCompound nbt = ByteBufUtils.readNBT(in);
|
||||
component.loadData(nbt);
|
||||
if(nbt.hasNoTags())
|
||||
if (nbt.hasNoTags())
|
||||
component.hasData = false;
|
||||
} catch (IOException e) {
|
||||
component.hasData = false;
|
||||
|
||||
@@ -80,7 +80,7 @@ public final class ParticlePacket extends AbstractPacket {
|
||||
float yOffset = buffer.readFloat();
|
||||
|
||||
String particle = ByteBufUtils.readString(buffer);
|
||||
if(particle != null){
|
||||
if (particle != null) {
|
||||
World worldObj = Minecraft.getMinecraft().theWorld;
|
||||
|
||||
Random rand = worldObj.rand;
|
||||
|
||||
@@ -10,7 +10,6 @@ import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.controllers.data.Magic;
|
||||
import noppes.npcs.controllers.data.MagicData;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -35,7 +34,8 @@ public final class PlayerDataInfoPacket extends LargeAbstractPacket {
|
||||
|
||||
private MagicData playerMagicData;
|
||||
|
||||
public PlayerDataInfoPacket() {}
|
||||
public PlayerDataInfoPacket() {
|
||||
}
|
||||
|
||||
public PlayerDataInfoPacket(String playerName,
|
||||
Map<String, Integer> questCategories, Map<String, Integer> questActive, Map<String, Integer> questFinished,
|
||||
|
||||
@@ -61,7 +61,7 @@ public final class GuiOpenBookPacket extends AbstractPacket {
|
||||
int z = in.readInt();
|
||||
NBTTagCompound nbt = ByteBufUtils.readNBT(in);
|
||||
ItemStack book = ItemStack.loadItemStackFromNBT(nbt);
|
||||
if(book != null)
|
||||
if (book != null)
|
||||
NoppesUtil.openGUI(player, new GuiBook(player, book, x, y, z));
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public final class ScrollListPacket extends LargeAbstractPacket {
|
||||
public ScrollListPacket() {
|
||||
}
|
||||
|
||||
public ScrollListPacket(List<String> data, EnumScrollData enumScrollData) {
|
||||
public ScrollListPacket(List<String> data, EnumScrollData enumScrollData) {
|
||||
this.data = data;
|
||||
this.enumScrollData = enumScrollData;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@ public final class SyncEffectPacket extends LargeAbstractPacket {
|
||||
|
||||
private NBTTagCompound syncData;
|
||||
|
||||
public SyncEffectPacket() {}
|
||||
public SyncEffectPacket() {
|
||||
}
|
||||
|
||||
public SyncEffectPacket(NBTTagCompound syncData) {
|
||||
this.syncData = syncData;
|
||||
@@ -54,8 +55,7 @@ public final class SyncEffectPacket extends LargeAbstractPacket {
|
||||
try {
|
||||
NBTTagCompound tag = ByteBufUtils.readBigNBT(data);
|
||||
SyncController.clientSyncEffects(tag);
|
||||
}
|
||||
catch (RuntimeException e){
|
||||
} catch (RuntimeException e) {
|
||||
LogWriter.error(String.format("Attempted to Sync Effects but it was too big"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,8 +86,7 @@ public final class SyncPacket extends LargeAbstractPacket {
|
||||
NBTTagCompound tag = ByteBufUtils.readBigNBT(data);
|
||||
// Now do your client-side logic (similar to your old clientSync() or clientSyncUpdate() approach)
|
||||
handleSyncPacketClient(type, action, categoryID, tag);
|
||||
}
|
||||
catch (RuntimeException e){
|
||||
} catch (RuntimeException e) {
|
||||
LogWriter.error(String.format("Attempted to Sync %s but it was too big", type.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,9 +42,11 @@ public class BankActionPacket extends AbstractPacket {
|
||||
public static void Open(int bankID, int slotID) {
|
||||
PacketClient.sendClient(new BankActionPacket(Action.OpenSlot, bankID, slotID));
|
||||
}
|
||||
|
||||
public static void Upgrade() {
|
||||
PacketClient.sendClient(new BankActionPacket(Action.Upgrade, -1, -1));
|
||||
}
|
||||
|
||||
public static void Unlock() {
|
||||
PacketClient.sendClient(new BankActionPacket(Action.Unlock, -1, -1));
|
||||
}
|
||||
@@ -79,7 +81,7 @@ public class BankActionPacket extends AbstractPacket {
|
||||
|
||||
EntityPlayerMP playerMP = (EntityPlayerMP) player;
|
||||
|
||||
if(npc.advanced.role != EnumRoleType.Bank)
|
||||
if (npc.advanced.role != EnumRoleType.Bank)
|
||||
return;
|
||||
|
||||
switch (requestedAction) {
|
||||
@@ -92,7 +94,7 @@ public class BankActionPacket extends AbstractPacket {
|
||||
case OpenSlot:
|
||||
int bankID = in.readInt();
|
||||
int slotID = in.readInt();
|
||||
BankData data = PlayerDataController.Instance.getBankData(playerMP,bankID).getBankOrDefault(bankID);
|
||||
BankData data = PlayerDataController.Instance.getBankData(playerMP, bankID).getBankOrDefault(bankID);
|
||||
data.openBankGui(playerMP, npc, bankID, slotID);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class CheckPlayerValue extends AbstractPacket {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(playerMP);
|
||||
PlayerQuestData questData = PlayerDataController.Instance.getPlayerData(playerMP).questData;
|
||||
Party playerParty = playerData.getPlayerParty();
|
||||
if(playerParty != null)
|
||||
if (playerParty != null)
|
||||
PartyController.Instance().checkQuestCompletion(playerParty, null);
|
||||
|
||||
questData.checkQuestCompletion(playerData, null);
|
||||
|
||||
@@ -69,7 +69,7 @@ public class CompanionActionPacket extends AbstractPacket {
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
Type type = Type.values()[in.readInt()];
|
||||
|
||||
if(npc.advanced.role != EnumRoleType.Companion || player != npc.getOwner())
|
||||
if (npc.advanced.role != EnumRoleType.Companion || player != npc.getOwner())
|
||||
return;
|
||||
|
||||
if (type == Type.OpenInventory) {
|
||||
@@ -79,7 +79,7 @@ public class CompanionActionPacket extends AbstractPacket {
|
||||
int id = in.readInt();
|
||||
int exp = in.readInt();
|
||||
RoleCompanion role = (RoleCompanion) npc.roleInterface;
|
||||
if(exp <= 0 || !role.canAddExp(-exp) || id < 0 || id >= EnumCompanionTalent.values().length) //should never happen unless hacking
|
||||
if (exp <= 0 || !role.canAddExp(-exp) || id < 0 || id >= EnumCompanionTalent.values().length) //should never happen unless hacking
|
||||
return;
|
||||
EnumCompanionTalent talent = EnumCompanionTalent.values()[id];
|
||||
role.addExp(-exp);
|
||||
|
||||
@@ -16,8 +16,9 @@ public class DialogSelectPacket extends AbstractPacket {
|
||||
|
||||
private int dialogID, optionID;
|
||||
|
||||
public DialogSelectPacket(){
|
||||
public DialogSelectPacket() {
|
||||
}
|
||||
|
||||
public DialogSelectPacket(int dialogID, int optionID) {
|
||||
this.dialogID = dialogID;
|
||||
this.optionID = optionID;
|
||||
|
||||
@@ -38,7 +38,7 @@ public class GetNPCRole extends AbstractPacket {
|
||||
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
if(!(player instanceof EntityPlayerMP))
|
||||
if (!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
if (npc.advanced.role == EnumRoleType.None)
|
||||
return;
|
||||
|
||||
@@ -34,6 +34,7 @@ public class InputDevicePacket extends AbstractPacket {
|
||||
this.key = key;
|
||||
this.isKeyPressed = isDown;
|
||||
}
|
||||
|
||||
public static void sendMouse(int mouseButton, int scroll, boolean isDown) {
|
||||
InputDevicePacket packet = new InputDevicePacket(Type.MOUSE, mouseButton, isDown);
|
||||
packet.scroll = scroll;
|
||||
@@ -121,20 +122,19 @@ public class InputDevicePacket extends AbstractPacket {
|
||||
}
|
||||
|
||||
private static int[] getPressedArray(String pressedKeys) {
|
||||
if(pressedKeys == null)
|
||||
if (pressedKeys == null)
|
||||
return new int[0];
|
||||
|
||||
String[] split = pressedKeys.split(",");
|
||||
int[] keysDown;
|
||||
|
||||
if(pressedKeys.length() > 0) {
|
||||
if (pressedKeys.length() > 0) {
|
||||
keysDown = new int[split.length];
|
||||
try {
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
keysDown[i] = Integer.parseInt(split[i]);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ignored){
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
} else {
|
||||
keysDown = new int[0];
|
||||
|
||||
@@ -45,15 +45,19 @@ public class MailActionPacket extends AbstractPacket {
|
||||
packet.action = Action.GET;
|
||||
PacketClient.sendClient(packet);
|
||||
}
|
||||
|
||||
public static void OpenMail(long time, String sender) {
|
||||
PacketClient.sendClient(new MailActionPacket(Action.OPEN, time, sender));
|
||||
}
|
||||
|
||||
public static void DeleteMail(long time, String sender) {
|
||||
PacketClient.sendClient(new MailActionPacket(Action.DELETE, time, sender));
|
||||
}
|
||||
|
||||
public static void ReadMail(long time, String sender) {
|
||||
PacketClient.sendClient(new MailActionPacket(Action.READ, time, sender));
|
||||
}
|
||||
|
||||
public static void SendMail(String receiver, NBTTagCompound mailData) {
|
||||
PacketClient.sendClient(new MailSendPacket(receiver, mailData));
|
||||
}
|
||||
@@ -90,7 +94,7 @@ public class MailActionPacket extends AbstractPacket {
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
Action type = Action.values()[in.readInt()];
|
||||
|
||||
if(!(player instanceof EntityPlayerMP))
|
||||
if (!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
EntityPlayerMP playerMP = (EntityPlayerMP) player;
|
||||
PlayerMailData data = PlayerDataController.Instance.getPlayerData(playerMP).mailData;
|
||||
@@ -107,9 +111,9 @@ public class MailActionPacket extends AbstractPacket {
|
||||
case OPEN:
|
||||
playerMP.closeContainer();
|
||||
|
||||
while(it.hasNext()){
|
||||
while (it.hasNext()) {
|
||||
PlayerMail mail = it.next();
|
||||
if(mail.time == time && mail.sender.equals(user)){
|
||||
if (mail.time == time && mail.sender.equals(user)) {
|
||||
ContainerMail.staticmail = mail;
|
||||
playerMP.openGui(CustomNpcs.instance, EnumGuiType.PlayerMailman.ordinal(), playerMP.worldObj, 0, 0, 0);
|
||||
break;
|
||||
@@ -118,9 +122,9 @@ public class MailActionPacket extends AbstractPacket {
|
||||
break;
|
||||
|
||||
case DELETE:
|
||||
while(it.hasNext()){
|
||||
while (it.hasNext()) {
|
||||
PlayerMail mail = it.next();
|
||||
if(mail.time == time && mail.sender.equals(user)){
|
||||
if (mail.time == time && mail.sender.equals(user)) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
@@ -128,11 +132,11 @@ public class MailActionPacket extends AbstractPacket {
|
||||
break;
|
||||
|
||||
case READ:
|
||||
while(it.hasNext()){
|
||||
while (it.hasNext()) {
|
||||
PlayerMail mail = it.next();
|
||||
if(mail.time == time && mail.sender.equals(user)){
|
||||
if (mail.time == time && mail.sender.equals(user)) {
|
||||
mail.beenRead = true;
|
||||
if(mail.hasQuest())
|
||||
if (mail.hasQuest())
|
||||
PlayerQuestController.addActiveQuest(new QuestData(mail.getQuest()), playerMP);
|
||||
}
|
||||
}
|
||||
@@ -148,6 +152,7 @@ public class MailActionPacket extends AbstractPacket {
|
||||
public MailSendPacket() {
|
||||
|
||||
}
|
||||
|
||||
private MailSendPacket(String username, NBTTagCompound mailContent) {
|
||||
this.username = username;
|
||||
this.mailContent = mailContent;
|
||||
@@ -164,10 +169,10 @@ public class MailActionPacket extends AbstractPacket {
|
||||
@Override
|
||||
@SideOnly(Side.SERVER)
|
||||
protected void handleCompleteData(ByteBuf data, EntityPlayer player) throws IOException {
|
||||
if(!(player instanceof EntityPlayerMP))
|
||||
if (!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
EntityPlayerMP playerMP = (EntityPlayerMP) player;
|
||||
if(!(playerMP.openContainer instanceof ContainerMail))
|
||||
if (!(playerMP.openContainer instanceof ContainerMail))
|
||||
return;
|
||||
|
||||
String mailReceiver = PlayerDataController.Instance.hasPlayer(ByteBufUtils.readString(data));
|
||||
@@ -179,7 +184,7 @@ public class MailActionPacket extends AbstractPacket {
|
||||
PlayerMail mail = new PlayerMail();
|
||||
String s = playerMP.getDisplayName();
|
||||
if (!s.equals(playerMP.getCommandSenderName()))
|
||||
s += " (" +playerMP.getCommandSenderName() + ")";
|
||||
s += " (" + playerMP.getCommandSenderName() + ")";
|
||||
mail.readNBT(ByteBufUtils.readBigNBT(data));
|
||||
mail.sender = s;
|
||||
mail.items = ((ContainerMail) playerMP.openContainer).mail.items;
|
||||
@@ -192,7 +197,7 @@ public class MailActionPacket extends AbstractPacket {
|
||||
|
||||
NBTTagCompound comp = new NBTTagCompound();
|
||||
comp.setString("username", mailReceiver);
|
||||
NoppesUtilServer.sendGuiClose(playerMP, 1,comp);
|
||||
NoppesUtilServer.sendGuiClose(playerMP, 1, comp);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -44,7 +44,7 @@ public class SaveSignPacket extends LargeAbstractPacket {
|
||||
int x = data.readInt(), y = data.readInt(), z = data.readInt();
|
||||
if (player.worldObj.blockExists(x, y, z)) {
|
||||
TileEntity tile = player.worldObj.getTileEntity(x, y, z);
|
||||
if(!(tile instanceof TileBigSign))
|
||||
if (!(tile instanceof TileBigSign))
|
||||
return;
|
||||
TileBigSign sign = (TileBigSign) tile;
|
||||
if (sign.canEdit) {
|
||||
|
||||
@@ -19,7 +19,7 @@ public class ScreenSizePacket extends AbstractPacket {
|
||||
public ScreenSizePacket() {
|
||||
}
|
||||
|
||||
public ScreenSizePacket(int width, int height){
|
||||
public ScreenSizePacket(int width, int height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
@@ -44,6 +44,6 @@ public class ScreenSizePacket extends AbstractPacket {
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
int width = in.readInt(), height = in.readInt();
|
||||
PlayerDataController.Instance.getPlayerData(player).screenSize.setSize(width,height);
|
||||
PlayerDataController.Instance.getPlayerData(player).screenSize.setSize(width, height);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumPlayerPacket;
|
||||
import kamkeel.npcs.network.enums.EnumRequestPacket;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@@ -7,7 +7,6 @@ import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumPlayerPacket;
|
||||
import kamkeel.npcs.network.enums.EnumRequestPacket;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
+2
-2
@@ -7,7 +7,6 @@ import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumPlayerPacket;
|
||||
import kamkeel.npcs.network.enums.EnumRequestPacket;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -24,7 +23,8 @@ public final class CustomGuiUnfocusedPacket extends AbstractPacket {
|
||||
private NBTTagCompound compound;
|
||||
private int id;
|
||||
|
||||
public CustomGuiUnfocusedPacket() {}
|
||||
public CustomGuiUnfocusedPacket() {
|
||||
}
|
||||
|
||||
public CustomGuiUnfocusedPacket(int id, NBTTagCompound comp) {
|
||||
this.compound = comp;
|
||||
|
||||
+2
-2
@@ -7,7 +7,6 @@ import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumPlayerPacket;
|
||||
import kamkeel.npcs.network.enums.EnumRequestPacket;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -28,7 +27,8 @@ public final class CustomScrollClickPacket extends AbstractPacket {
|
||||
private boolean doubleClick;
|
||||
private NBTTagCompound compound;
|
||||
|
||||
public CustomScrollClickPacket() {}
|
||||
public CustomScrollClickPacket() {
|
||||
}
|
||||
|
||||
public CustomScrollClickPacket(NBTTagCompound compound, int scrollId, int scrollIndex, NBTTagCompound selection, boolean doubleClick) {
|
||||
this.compound = compound;
|
||||
|
||||
@@ -22,7 +22,8 @@ public final class ProfileChangePacket extends AbstractPacket {
|
||||
|
||||
private int slotID;
|
||||
|
||||
public ProfileChangePacket() {}
|
||||
public ProfileChangePacket() {
|
||||
}
|
||||
|
||||
public ProfileChangePacket(int slotID) {
|
||||
this.slotID = slotID;
|
||||
@@ -54,7 +55,7 @@ public final class ProfileChangePacket extends AbstractPacket {
|
||||
if (!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
|
||||
if(!ConfigMain.ProfilesEnabled)
|
||||
if (!ConfigMain.ProfilesEnabled)
|
||||
return;
|
||||
|
||||
int slot = in.readInt();
|
||||
|
||||
@@ -21,7 +21,8 @@ import java.io.IOException;
|
||||
public final class ProfileCreatePacket extends AbstractPacket {
|
||||
public static String packetName = "Request|ProfileCreate";
|
||||
|
||||
public ProfileCreatePacket() {}
|
||||
public ProfileCreatePacket() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
@@ -40,14 +41,15 @@ public final class ProfileCreatePacket extends AbstractPacket {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {}
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
if (!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
|
||||
if(!ConfigMain.ProfilesEnabled)
|
||||
if (!ConfigMain.ProfilesEnabled)
|
||||
return;
|
||||
|
||||
Profile profile = ProfileController.Instance.getProfile(player);
|
||||
|
||||
+12
-10
@@ -4,19 +4,19 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.controllers.ProfileController;
|
||||
import kamkeel.npcs.network.enums.EnumPlayerPacket;
|
||||
import noppes.npcs.api.handler.data.ISlot;
|
||||
import kamkeel.npcs.controllers.data.profile.ProfileInfoEntry;
|
||||
import kamkeel.npcs.controllers.data.profile.Profile;
|
||||
import kamkeel.npcs.controllers.data.profile.ProfileInfoEntry;
|
||||
import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumPlayerPacket;
|
||||
import kamkeel.npcs.network.packets.data.large.GuiDataPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import noppes.npcs.api.handler.data.ISlot;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -27,7 +27,8 @@ import java.util.List;
|
||||
public final class ProfileGetInfoPacket extends AbstractPacket {
|
||||
public static String packetName = "Request|ProfileGetInfo";
|
||||
|
||||
public ProfileGetInfoPacket() {}
|
||||
public ProfileGetInfoPacket() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
@@ -41,31 +42,32 @@ public final class ProfileGetInfoPacket extends AbstractPacket {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {}
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
if (!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
|
||||
if(!ConfigMain.ProfilesEnabled)
|
||||
if (!ConfigMain.ProfilesEnabled)
|
||||
return;
|
||||
|
||||
sendProfileInfo(player);
|
||||
}
|
||||
|
||||
public static void sendProfileInfo(EntityPlayer player){
|
||||
public static void sendProfileInfo(EntityPlayer player) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setBoolean("PROFILE_INFO", true);
|
||||
NBTTagList slotList = new NBTTagList();
|
||||
Profile profile = ProfileController.Instance.getProfile(player);
|
||||
if(profile != null){
|
||||
for(ISlot slot : profile.getSlots().values()){
|
||||
if (profile != null) {
|
||||
for (ISlot slot : profile.getSlots().values()) {
|
||||
NBTTagCompound slotCompound = new NBTTagCompound();
|
||||
NBTTagList infoList = new NBTTagList();
|
||||
slotCompound.setInteger("ID", slot.getId());
|
||||
List<ProfileInfoEntry> profileInfo = ProfileController.Instance.getProfileInfo(player, slot.getId());
|
||||
for(ProfileInfoEntry profileInfoEntry : profileInfo){
|
||||
for (ProfileInfoEntry profileInfoEntry : profileInfo) {
|
||||
infoList.appendTag(profileInfoEntry.writeToNBT());
|
||||
}
|
||||
slotCompound.setTag("INFO", infoList);
|
||||
|
||||
@@ -20,7 +20,8 @@ import java.io.IOException;
|
||||
public final class ProfileGetPacket extends AbstractPacket {
|
||||
public static String packetName = "Request|ProfileGet";
|
||||
|
||||
public ProfileGetPacket() {}
|
||||
public ProfileGetPacket() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
@@ -34,20 +35,21 @@ public final class ProfileGetPacket extends AbstractPacket {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {}
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
if (!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
|
||||
if(!ConfigMain.ProfilesEnabled)
|
||||
if (!ConfigMain.ProfilesEnabled)
|
||||
return;
|
||||
|
||||
sendProfileNBT(player);
|
||||
}
|
||||
|
||||
public static void sendProfileNBT(EntityPlayer player){
|
||||
public static void sendProfileNBT(EntityPlayer player) {
|
||||
Profile profile = ProfileController.Instance.getProfile(player);
|
||||
NBTTagCompound compound = profile.writeToNBT();
|
||||
compound.setBoolean("PROFILE", true);
|
||||
|
||||
@@ -22,7 +22,8 @@ public final class ProfileRemovePacket extends AbstractPacket {
|
||||
|
||||
private int slotID;
|
||||
|
||||
public ProfileRemovePacket() {}
|
||||
public ProfileRemovePacket() {
|
||||
}
|
||||
|
||||
public ProfileRemovePacket(int slotID) {
|
||||
this.slotID = slotID;
|
||||
@@ -54,7 +55,7 @@ public final class ProfileRemovePacket extends AbstractPacket {
|
||||
if (!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
|
||||
if(!ConfigMain.ProfilesEnabled)
|
||||
if (!ConfigMain.ProfilesEnabled)
|
||||
return;
|
||||
|
||||
int slot = in.readInt();
|
||||
|
||||
@@ -24,7 +24,8 @@ public final class ProfileRenamePacket extends AbstractPacket {
|
||||
private int slotID;
|
||||
private String name;
|
||||
|
||||
public ProfileRenamePacket() {}
|
||||
public ProfileRenamePacket() {
|
||||
}
|
||||
|
||||
public ProfileRenamePacket(int slotID, String name) {
|
||||
this.slotID = slotID;
|
||||
@@ -58,14 +59,14 @@ public final class ProfileRenamePacket extends AbstractPacket {
|
||||
if (!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
|
||||
if(!ConfigMain.ProfilesEnabled)
|
||||
if (!ConfigMain.ProfilesEnabled)
|
||||
return;
|
||||
|
||||
int slot = in.readInt();
|
||||
String newName = ByteBufUtils.readString(in);
|
||||
|
||||
Profile profile = ProfileController.Instance.getProfile(player);
|
||||
if(!profile.getSlots().containsKey(slot)) {
|
||||
if (!profile.getSlots().containsKey(slot)) {
|
||||
ChatAlertPacket.sendChatAlert((EntityPlayerMP) player, "No slot found");
|
||||
return;
|
||||
}
|
||||
|
||||
Loaded 100 of 1179 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user