Proper Reformating

This commit is contained in:
Kam committed 2025-03-13 17:14:45 -04:00
1 parent ce75880aba
commit 180d257024
1179 files changed
+59847 -61583

No files matched your search

+141 -147
View File
@@ -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);
}
+128 -136
View File
@@ -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);
}
}
+44 -43
View File
@@ -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);
}
}
+29 -29
View File
@@ -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;
+171 -171
View File
@@ -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);
}
}
+75 -76
View File
@@ -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);
}
}
+54 -54
View File
@@ -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;
}
}
+8 -8
View File
@@ -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 {
+47 -51
View File
@@ -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");
+9 -9
View File
@@ -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;