public BlockTypeFilter(WebHook hook, ConfigurationNode config) { super(hook, config); try { types = config.getList(TypeToken.of(BlockType.class)); } catch (ObjectMappingException e) { e.printStackTrace(); } }
public PlayerFilter(WebHook hook, ConfigurationNode config) { super(hook, config); try { players = config.getList(TypeToken.of(String.class)); } catch (ObjectMappingException e) { e.printStackTrace(); } }
public ItemTypeFilter(WebHook hook, ConfigurationNode config) { super(hook, config); try { items = config.getList(TypeToken.of(ItemType.class)); } catch (ObjectMappingException e) { e.printStackTrace(); } }
@Override public void onDisable() { super.onDisable(); try { config.getNode("variables").setValue(new TypeToken<Map<String, Map<String, String>>>() {}, variableStore); } catch (ObjectMappingException e) { e.printStackTrace(); } if (variableCommandMapping != null) { Sponge.getCommandManager().removeMapping(variableCommandMapping); } }
public static <T extends BaseConfig> T load(Path path, T defaultConfig) { ConfigurationLoader<CommentedConfigurationNode> loader = HoconConfigurationLoader.builder() .setPath(path) .build(); CommentedConfigurationNode node; try { node = loader.load(); } catch (IOException e) { e.printStackTrace(); node = loader.createEmptyNode(); } T config = null; try { config = (T)node.getValue(TypeToken.of(defaultConfig.getClass())); } catch (ObjectMappingException e) { e.printStackTrace(); } if (config == null) { config = defaultConfig; } config.setLoader(loader); config.setNode(node); config.save(); return config; } }