use of com.solinia.solinia.Interfaces.ISoliniaQuest 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.Interfaces.ISoliniaQuest in project solinia3-core by mixxit.
the class SoliniaNPCEventHandler method editTriggerEventSetting.
@Override
public void editTriggerEventSetting(String setting, String value) throws InvalidNPCEventSettingException {
switch(setting.toLowerCase()) {
case "randomisedgearsuffix":
setRandomisedGearSuffix(value);
break;
case "title":
setTitle(value);
break;
case "awardstitle":
setAwardsTitle(Boolean.parseBoolean(value));
break;
case "triggerdata":
if (value.equals(""))
throw new InvalidNPCEventSettingException("Triggerdata is empty");
if (value.contains(" "))
throw new InvalidNPCEventSettingException("Triggerdata can only be one value");
setTriggerdata(value.toUpperCase());
break;
case "chatresponse":
if (value.equals(""))
throw new InvalidNPCEventSettingException("Chatresponse is empty");
setChatresponse(value);
break;
case "requiresquest":
int questid = Integer.parseInt(value);
if (questid < 1)
throw new InvalidNPCEventSettingException("Invalid quest id");
try {
ISoliniaQuest quest = StateManager.getInstance().getConfigurationManager().getQuest(questid);
if (quest == null)
throw new InvalidNPCEventSettingException("Invalid quest id");
} catch (CoreStateInitException e) {
throw new InvalidNPCEventSettingException("State not initialised");
}
setRequiresQuest(questid);
break;
case "awardsquest":
int aquestid = Integer.parseInt(value);
if (aquestid < 1)
throw new InvalidNPCEventSettingException("Invalid quest id");
try {
ISoliniaQuest quest = StateManager.getInstance().getConfigurationManager().getQuest(aquestid);
if (quest == null)
throw new InvalidNPCEventSettingException("Invalid quest id");
} catch (CoreStateInitException e) {
throw new InvalidNPCEventSettingException("State not initialised");
}
setAwardsQuest(aquestid);
break;
case "requiresquestflag":
setRequiresQuestFlag(value);
break;
case "awardsquestflag":
setAwardsQuestFlag(value);
break;
case "teleportresponse":
try {
String[] zonedata = value.split(",");
// Dissasemble the value to ensure it is correct
String world = zonedata[0];
double x = Double.parseDouble(zonedata[1]);
double y = Double.parseDouble(zonedata[2]);
double z = Double.parseDouble(zonedata[3]);
setTeleportResponse(world + "," + x + "," + y + "," + z);
break;
} catch (Exception e) {
throw new InvalidNPCEventSettingException("Teleport zone value must be in format: world,x,y,z");
}
case "awardsrandomisedgear":
setAwardsRandomisedGear(Boolean.parseBoolean(value));
break;
case "awardsitem":
int itemId = Integer.parseInt(value);
if (itemId < 1)
throw new InvalidNPCEventSettingException("Invalid item ID");
if (getAwardsQuestFlag() == null || getAwardsQuestFlag().equals(""))
throw new InvalidNPCEventSettingException("You cannot set an awardsitem to a npc event handler unless the npc awards a quest flag - this is to prevent duplicated awards");
try {
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(itemId);
if (item == null)
throw new InvalidNPCEventSettingException("Invalid item id");
} catch (CoreStateInitException e) {
throw new InvalidNPCEventSettingException("State not initialised");
}
setAwardsItem(itemId);
break;
default:
throw new InvalidNPCEventSettingException("Invalid NPC Event setting. Valid Options are: triggerdata,chatresponse,interactiontype,requiresquest,awardsquest,requiresquestflag,awardsquestflag,awardsitem");
}
}
use of com.solinia.solinia.Interfaces.ISoliniaQuest in project solinia3-core by mixxit.
the class JsonQuestRepository method reload.
@Override
public void reload() {
List<ISoliniaQuest> file = new ArrayList<ISoliniaQuest>();
try {
Gson gson = new Gson();
BufferedReader br = new BufferedReader(new FileReader(filePath));
file = gson.fromJson(br, new TypeToken<List<SoliniaQuest>>() {
}.getType());
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Quests.clear();
for (ISoliniaQuest i : file) {
Quests.put(i.getId(), i);
}
System.out.println("Reloaded " + Quests.size() + " Quests");
}
Aggregations