use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class CommandCreateQuest method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player) && !(sender instanceof CommandSender))
return false;
if (sender instanceof Player) {
Player player = (Player) sender;
if (!player.isOp()) {
player.sendMessage("This is an operator only command");
return false;
}
}
if (args.length < 1) {
sender.sendMessage("Insufficient arguments: name");
return false;
}
String questname = args[0];
if (questname.equals("")) {
sender.sendMessage("Invalid quest name");
return false;
}
try {
for (ISoliniaQuest quest : StateManager.getInstance().getConfigurationManager().getQuests()) {
if (quest.getName().toUpperCase().equals(questname.toUpperCase())) {
sender.sendMessage("That quest already exists");
return false;
}
}
SoliniaQuest quest = new SoliniaQuest();
quest.setId(StateManager.getInstance().getConfigurationManager().getNextQuestId());
quest.setName(questname);
StateManager.getInstance().getConfigurationManager().addQuest(quest);
sender.sendMessage("Quest created! [" + quest.getId() + "]");
} catch (CoreStateInitException e) {
sender.sendMessage(e.getMessage());
}
return true;
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class CommandEditFaction method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player) && !(sender instanceof CommandSender))
return false;
if (sender instanceof Player) {
Player player = (Player) sender;
if (!player.isOp() && !player.hasPermission("solinia.editfaction")) {
player.sendMessage("You do not have permission to access this command");
return false;
}
}
if (args.length == 0) {
return false;
}
int factionid = Integer.parseInt(args[0]);
if (args.length == 1) {
try {
ISoliniaFaction solfaction = StateManager.getInstance().getConfigurationManager().getFaction(factionid);
if (solfaction != null) {
solfaction.sendFactionSettingsToSender(sender);
} else {
sender.sendMessage("FACTION ID doesnt exist");
}
return true;
} catch (CoreStateInitException e) {
sender.sendMessage(e.getMessage());
}
}
if (args.length < 3) {
sender.sendMessage("Insufficient arguments: factionid setting value");
return false;
}
String setting = args[1];
String value = args[2];
// a string
if (args.length > 3 && (setting.toLowerCase().contains("description") || setting.toLowerCase().contains("factionentry") || setting.toLowerCase().contains("allygrants") || setting.toLowerCase().contains("title"))) {
value = "";
int current = 0;
for (String entry : args) {
current++;
if (current <= 2)
continue;
value = value + entry + " ";
}
value = value.trim();
}
if (factionid < 1) {
sender.sendMessage("Invalid faction id");
return false;
}
try {
if (StateManager.getInstance().getConfigurationManager().getFaction(factionid) == null) {
sender.sendMessage("Cannot locate faction id: " + factionid);
return false;
}
if (StateManager.getInstance().getConfigurationManager().getFaction(factionid).isOperatorCreated() && !sender.isOp()) {
sender.sendMessage("This faction was op created and you are not an op. Only ops can faction op items");
return false;
}
StateManager.getInstance().getConfigurationManager().editFaction(factionid, setting, value);
sender.sendMessage("Updating setting on faction");
} catch (InvalidFactionSettingException ne) {
sender.sendMessage("Invalid faction setting: " + ne.getMessage());
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
sender.sendMessage(e.getMessage());
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
sender.sendMessage(e.getMessage());
} catch (IOException e) {
// TODO Auto-generated catch block
sender.sendMessage(e.getMessage());
}
return true;
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class CommandEditClass method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player) && !(sender instanceof CommandSender))
return false;
if (sender instanceof Player) {
Player player = (Player) sender;
if (!player.isOp()) {
player.sendMessage("This is an operator only command");
return false;
}
}
if (args.length == 0) {
return false;
}
int classid = Integer.parseInt(args[0]);
if (args.length == 1) {
try {
ISoliniaClass solclass = StateManager.getInstance().getConfigurationManager().getClassObj(classid);
if (solclass != null) {
solclass.sendClassSettingsToSender(sender);
} else {
sender.sendMessage("CLASS ID doesnt exist");
}
return true;
} catch (CoreStateInitException e) {
sender.sendMessage(e.getMessage());
}
}
if (args.length < 3) {
sender.sendMessage("Insufficient arguments: classid setting value");
return false;
}
String setting = args[1];
String value = args[2];
// a string
if (args.length > 3 && (setting.toLowerCase().contains("text") || setting.toLowerCase().contains("description") || setting.toLowerCase().contains("title"))) {
value = "";
int current = 0;
for (String entry : args) {
current++;
if (current <= 2)
continue;
value = value + entry + " ";
}
value = value.trim();
}
if (classid < 1) {
sender.sendMessage("Invalid class id");
return false;
}
try {
if (StateManager.getInstance().getConfigurationManager().getClassObj(classid) == null) {
sender.sendMessage("Cannot locate class id: " + classid);
return false;
}
StateManager.getInstance().getConfigurationManager().editClass(classid, setting, value);
sender.sendMessage("Updating setting on class");
} catch (InvalidClassSettingException ne) {
sender.sendMessage("Invalid class setting: " + ne.getMessage());
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
sender.sendMessage(e.getMessage());
}
return true;
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class CommandCreateLootDrop method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player) && !(sender instanceof CommandSender))
return false;
if (sender instanceof Player) {
Player player = (Player) sender;
if (!player.isOp() && !player.hasPermission("solinia.createlootdrop")) {
player.sendMessage("You do not have permission to access this command");
return false;
}
}
if (args.length < 1) {
sender.sendMessage("Insufficient arguments: name");
return false;
}
String lootdropname = "";
int count = 0;
for (String entry : args) {
lootdropname += entry;
count++;
}
if (lootdropname.equals("")) {
sender.sendMessage("Blank name not allowed when creating lootdrop");
return false;
}
lootdropname = lootdropname.replace(" ", "_").toUpperCase();
if (lootdropname.length() > 25) {
sender.sendMessage("Lootdrop name cannot be longer than 25 characters");
return true;
}
try {
if (StateManager.getInstance().getConfigurationManager().getLootDrop(lootdropname) != null) {
sender.sendMessage("LootDrop already exists with the same name");
return true;
}
SoliniaLootFactory.CreateLootDrop(lootdropname, sender.isOp());
sender.sendMessage("LootDrop created as " + StateManager.getInstance().getConfigurationManager().getLootDrop(lootdropname).getId());
} catch (CoreStateInitException e) {
sender.sendMessage(e.getMessage());
}
return true;
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class CommandCreateMerchantList method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player) && !(sender instanceof CommandSender))
return false;
if (sender instanceof Player) {
Player player = (Player) sender;
if (!player.isOp()) {
player.sendMessage("This is an operator only command");
return false;
}
}
if (args.length < 1) {
sender.sendMessage("Insufficient arguments: name");
return false;
}
String merchantlistname = "";
for (String entry : args) {
merchantlistname += entry;
}
if (merchantlistname.equals("")) {
sender.sendMessage("Blank name not allowed when creating merchant list");
return false;
}
merchantlistname.replace(" ", "_");
try {
if (StateManager.getInstance().getConfigurationManager().getNPCMerchant(merchantlistname.toUpperCase()) != null) {
sender.sendMessage("MerchantList already exists with the same name");
return true;
}
SoliniaNPCMerchantFactory.CreateNPCMerchant(merchantlistname);
sender.sendMessage("MerchantList created");
} catch (CoreStateInitException e) {
sender.sendMessage(e.getMessage());
}
return true;
}
Aggregations