@Test public void canUpdateAddressAfterItExists() { writeServerAddress(address); assertEquals(handler.readServerAddress(), address); writeServerAddress("http://einiinboss.fi"); assertEquals(handler.readServerAddress(), "http://einiinboss.fi"); }
@Test public void correctPortGetsWritten() { try { handler.writePort(12355); assertEquals(12355, handler.readPort()); } catch (IOException ex) { fail("Failed to read or write port"); } }
public static void notify(Player player, String message) { if (player.isOnline()) { player.sendMessage(ChatColor.BLUE + message); } else { List<String> messages = messagingConfig.getConfig().getStringList(player.getName()); messages.add(message); messagingConfig.getConfig().set(player.getName(), messages); messagingConfig.saveConfig(); } }
@Test public void canReadAddressFromConfig() { try { handler.writeServerAddress(address); } catch (IOException ex) { fail("Failed writing to file"); } String readAddress = handler.readServerAddress(); assertEquals(readAddress, address); }
private void writeServerAddress(String address) { try { handler.writeServerAddress(address); } catch (IOException ex) { fail("Something went wrong"); } }
@Test public void canWritePortAddress() { try { handler.writePort(1234); } catch (IOException ex) { fail("failed to write port"); } }
@Test public void canWriteAddressToConfig() { try { handler.writeServerAddress(address); } catch (IOException ex) { fail("Something went wrong"); } }
public void onEnable() { saveDefaultConfig(); loadValues(); vote_handler = new ConfigHandler(this, "votepoints.yml"); vote_handler.load(); getServer().getPluginManager().registerEvents(new VoteListener(this), this); loadCommands(); for (String command : commands) { getCommand(command).setExecutor(new CommandManager(this)); } }
/** Clean all marks of test in config files. */ @After public void tearstuff() { try { handler.writeServerAddress(""); File file = new File("test.properties"); if (file.exists()) { file.delete(); } } catch (IOException ex) { fail("something went wrong"); } }
public void preInit(FMLPreInitializationEvent event) { ConfigHandler.init(event.getSuggestedConfigurationFile()); registerEventListeners(event.getSide()); ModBlocks.init(); ModItems.init(); ContributorHandler.init(); registerTileEntities(); initializeNetwork(); registerOres(); DraconicEvolution.reaperEnchant = new EnchantmentReaper(ConfigHandler.reaperEnchantID); // // Potion[] potionTypes = null; // LogHelper.info("Expanding Potion array size to 256"); // // for (Field f : Potion.class.getDeclaredFields()) { // f.setAccessible(true); // // try { // if (f.getName().equals("potionTypes") || f.getName().equals("field_76425_a")) { // Field modfield = Field.class.getDeclaredField("modifiers"); // modfield.setAccessible(true); // modfield.setInt(f, f.getModifiers() & ~Modifier.FINAL); // potionTypes = (Potion[]) f.get(null); // final Potion[] newPotionTypes = new Potion[256]; // System.arraycopy(potionTypes, 0, newPotionTypes, 0, potionTypes.length); // f.set(null, newPotionTypes); // } // } // catch (Exception e) { // LogHelper.error("Severe error, please report this to the mod author:"); // e.printStackTrace(); // } // } Achievements.addModAchievements(); LogHelper.info("Finished PreInitialization"); }
@EventHandler public void preInit(FMLPreInitializationEvent event) { ConfigHandler.init(event); FMLCommonHandler.instance().bus().register(new EventHooks()); MinecraftForge.EVENT_BUS.register(new EventHooks()); }
@Test public void configPathIsSetCorrectly() { assertEquals("test.properties", handler.getConfigFilePath()); new File("test.properties").delete(); }
@Test public void dontCrashWhenLastUpdateDoesntExist() throws ParseException, IOException { Date lastUpdate = handler.readLastUpdate(); assertNotNull(lastUpdate); }
@Test(expected = IllegalStateException.class) public void exceptionIsThrownIfNoAddressFound() { handler.readServerAddress(); }
// This is used by src/main/bin/config-doc.sh which is used by // src/main/bin/traffic_monitor_config.pl which must be run after rpm install of traffic monitor @SuppressWarnings("PMD") public static void main(final String[] args) throws JSONException { final JSONObject doc = ConfigHandler.getConfig().getConfigDoc(); System.out.println(doc.toString(2)); }