public static boolean removePresetPath(Player p, String npcName, NPCHandler handle) { if (!FileLocator.doesNPCNameExist(npcName)) { if (p != null) { QuestX.logChat(p, ChatColor.RED + LocaleBundle.getString("no_npc_name")); } return false; } else { if (!fixedSpawns.containsKey(npcName)) { if (p != null) { QuestX.logChat(p, LocaleBundle.getString("no_fixed_spawn")); } return false; } else { if (!presetNPCs.contains(npcName)) { QuestX.logChat(p, LocaleBundle.getString("no_preset_path")); return false; } else { io.read(); io.clearWriteArray(); io.clearReadArray(); for (SyncWrapper wrap : loader.getReadableData()) { // copy all the data read, except the npc to remove if (!wrap.getTag().equalsIgnoreCase(npcName)) { io.add(wrap); } } io.write(); presetNPCs.remove(npcName); SimpleNPC rem = handle.getSimpleNPCByName(npcName); if (rem != null) { rem.destroyNPCObject(); } LoadNPCTemplate tmp = new LoadNPCTemplate(npcName); tmp.loadProperties(); SimpleNPC npc = tmp.getLoadedNPCTemplate() .registerSimpleNPCFixedSpawn(handle, fixedSpawns.get(npcName)); npc.setAllowedToMove(true); PresetPathsDisplay.updateSoftReference(); QuestX.logChat(p, ChatColor.GREEN + "Preset path for NPC " + npcName + " was removed."); return true; } } } }
public void setupSpawn(Player p) { String npcName = setupGuide.get(currentNode + 1).getNpcName(); QuestX.logDebug("Current NPC setup name = " + npcName); if (this.currentNode == this.nodes - 1) { QuestX.logChat(p, LocaleBundle.getString("q_setup_complete")); } else { QuestX.logChat(p, LocaleBundle.getString("setup_progress") + currentNode + "/" + nodes + ")"); QuestX.logChat(p, LocaleBundle.getString("q_choose_spawn") + npcName + "'."); } FixedLoadingTable.addFixedNPCSpawn(p, npcName, p.getLocation(), handle); this.currentNode++; }
public QuestSetup(String name, NPCHandler handle) { this.name = name; this.handle = handle; if (!QuestManager.hasQuestBeenSetup(name)) { if (!settingUp.contains(name)) { this.setup = true; settingUp.add(name); this.load(); } else { failSetupReason = LocaleBundle.getString("q_currently_being_setup"); this.setup = false; } } else { failSetupReason = LocaleBundle.getString("q_already_setup"); this.setup = false; } }
public static boolean addFixedNPCSpawn(Player p, String npcName, Location l, NPCHandler handle) { if (!FileLocator.doesNPCNameExist(npcName)) { if (p != null) { QuestX.logChat(p, ChatColor.RED + LocaleBundle.getString("no_npc_name")); } return false; } else { if (fixedSpawns.containsKey(npcName)) { if (p != null) { QuestX.logChat(p, LocaleBundle.getString("yes_fixed_spawn")); } return false; } SimpleNPC remove = handle.getSimpleNPCByName(npcName); if (remove != null) { remove.destroyNPCObject(); } LoadNPCTemplate tmp = new LoadNPCTemplate(npcName); tmp.loadProperties(); tmp.getLoadedNPCTemplate().registerSimpleNPCFixedSpawn(handle, l); loader.read(); for (SyncWrapper wrap : loader.getReadableData()) { loader.add(wrap.getTag(), wrap.getObject()); } loader.add(npcName, new SyncLocation(l)); loader.write(); loader.clearReadArray(); loader.clearWriteArray(); fixedSpawns.put(npcName, l); FixedSpawnsDisplay.updateSoftReference(); if (p != null) { QuestX.logChat(p, LocaleBundle.getString("fixed_spawn_success") + npcName + "'."); } return true; } }
public static final void deleteAllFixedSpawns(Player p, NPCHandler handle) { File spawn = FileLocator.getNPCFixedSpawnsFile(), pres = FileLocator.getNPCPresetPathingFile(); if (spawn.canRead() && spawn.canWrite()) { if (spawn.exists()) { loader.read(); for (SyncWrapper wrap : loader.getReadableData()) { SimpleNPC rem = handle.getSimpleNPCByName(wrap.getTag()); if (rem != null) { rem.destroyNPCObject(); } } spawn.delete(); try { spawn.createNewFile(); loader.add("NPC_COUNT", 0); loader.write(); QuestX.logChat(p, LocaleBundle.getString("all_fxied_spawns_del")); } catch (IOException e) { QuestX.logChat(p, LocaleBundle.getString("error_del_fs_file")); e.printStackTrace(); } } else { QuestX.logChat(p, LocaleBundle.getString("no_fs_file")); } } else { QuestX.logChat(p, LocaleBundle.getString("fs_file_locked")); } presetNPCs.clear(); if (pres.canRead() && pres.canWrite()) { if (pres.exists()) { pres.delete(); try { pres.createNewFile(); io.clearWriteArray(); io.add("NULL", 0); io.write(); QuestX.logChat(p, LocaleBundle.getString("all_preset_del")); } catch (IOException e) { QuestX.logChat(p, LocaleBundle.getString("error_del_pp_file")); e.printStackTrace(); } } else { QuestX.logChat(p, LocaleBundle.getString("no_pp_file")); } } else { QuestX.logChat(p, LocaleBundle.getString("pp_file_locked")); } FixedSpawnsDisplay.updateSoftReference(); PresetPathsDisplay.updateSoftReference(); }
public static boolean removeFixedNPCSpawn(Player p, String npcName, NPCHandler handle) { if (!FileLocator.doesNPCNameExist(npcName)) { if (p != null) { QuestX.logChat(p, ChatColor.RED + LocaleBundle.getString("no_npc_name")); } return false; } else { if (!fixedSpawns.containsKey(npcName)) { if (p != null) { QuestX.logChat(p, LocaleBundle.getString("no_fixed_spawn")); } return false; } else { SimpleNPC rem = handle.getSimpleNPCByName(npcName); if (rem != null) { rem.destroyNPCObject(); } loader.read(); loader.clearWriteArray(); for (SyncWrapper wrap : loader.getReadableData()) { // copy all the data read, except the npc to remove if (!wrap.getTag().equalsIgnoreCase(npcName)) { loader.add(wrap); } } loader.write(); loader.clearReadArray(); loader.clearWriteArray(); fixedSpawns.remove(npcName); io.read(); io.clearWriteArray(); io.clearReadArray(); for (SyncWrapper wrap : loader.getReadableData()) { // copy all the data read, except the npc to remove if (!wrap.getTag().equalsIgnoreCase(npcName)) { io.add(wrap); } } io.write(); if (p != null) { QuestX.logChat( p, LocaleBundle.getString("t_fs") + npcName + LocaleBundle.getString("was_rem")); if (presetNPCs.contains(npcName)) { QuestX.logChat( p, LocaleBundle.getString("t_pp") + npcName + LocaleBundle.getString("was_rem")); presetNPCs.remove(npcName); } } FixedSpawnsDisplay.updateSoftReference(); PresetPathsDisplay.updateSoftReference(); return true; } } }
public void sendInitialMessage(Player p) { String npcName = setupGuide.get(currentNode + 1).getNpcName(); QuestX.logChat(p, LocaleBundle.getString("setup_progress") + currentNode + "/" + nodes + ")"); QuestX.logChat(p, LocaleBundle.getString("q_choose_spawn") + npcName + "'."); }
public static boolean editFixedNPCSpawn(Player p, String npcName, NPCHandler handle) { if (!FileLocator.doesNPCNameExist(npcName)) { if (p != null) { QuestX.logChat(p, ChatColor.RED + "There is no NPC created with this name!"); } return false; } else { if (!fixedSpawns.containsKey(npcName)) { if (p != null) { QuestX.logChat(p, LocaleBundle.getString("no_fixed_spawn")); } return false; } else { SimpleNPC rem = handle.getSimpleNPCByName(npcName); if (rem != null) { rem.destroyNPCObject(); } loader.read(); io.read(); loader.clearWriteArray(); for (SyncWrapper wrap : loader.getReadableData()) { // copy all the data read, except the npc to remove, set // this to be edited if (!wrap.getTag().equalsIgnoreCase(npcName)) { loader.add(wrap); } else { if (p != null) { loader.add(wrap.getTag(), new SyncLocation(p.getLocation())); } } } loader.write(); loader.clearReadArray(); loader.clearWriteArray(); io.read(); io.clearWriteArray(); io.clearReadArray(); for (SyncWrapper wrap : loader.getReadableData()) { // copy all the data read, except the npc to remove if (!wrap.getTag().equalsIgnoreCase(npcName)) { io.add(wrap); } } io.write(); if (presetNPCs.contains(npcName)) { QuestX.logChat(p, "The preset path for NPC '" + npcName + "' was removed."); presetNPCs.remove(npcName); } LoadNPCTemplate tmp = new LoadNPCTemplate(npcName); tmp.loadProperties(); SimpleNPC npc = tmp.getLoadedNPCTemplate().registerSimpleNPCFixedSpawn(handle, p.getLocation()); npc.setAllowedToMove(true); if (p != null) { QuestX.logChat( p, "The fixed spawn for NPC '" + npcName + "' was changed to your current location."); } PresetPathsDisplay.updateSoftReference(); return true; } } }