mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-28 11:16:02 +00:00
Proper Reformating
This commit is contained in:
1 parent
ce75880aba
commit
180d257024
1179 files changed
+59847
-61583
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user