Giter Site home page Giter Site logo

yamler's People

Contributors

bibo38 avatar intangir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

yamler's Issues

An API shouldnt break terribly on a single update

I've been using your Yamler config API in most of my plugins.
Now I understand that your rapid dev can sometimes a bit rough but I've spent WAY too many hours tonight trying to fix things:

http://pastebin.com/Mq04gKC0

I've given you the link to my config on irc.

And this is just after trying to regen 50 times, removing parts of my plugin just to be a bit more convinient. There's NOTHING weird in the config

Nope, still not going for it.

Please, if something used to work, keep it working. 1.5.2 configs were fine. I had to regen ALL of my configs, on ALL on my servers, and that didnt mean it succeeded every time.

A very annoyed and sleepy frenchman.

Waterfall 1.20 – yamler error

It seems like 1.20 has finally broken the support of Yamler and Bungeecord RCON.

[14:23:39 WARN]: Exception encountered when loading plugin: BungeeRcon
java.lang.NoSuchMethodError: org.yaml.snakeyaml.representer.Representer: method 'void <init>()' not found
        at net.cubespace.Yamler.Config.BaseConfigMapper.<init>(BaseConfigMapper.java:27) ~[?:?]
        at net.cubespace.Yamler.Config.ConfigMapper.<init>(ConfigMapper.java:13) ~[?:?]
        at net.cubespace.Yamler.Config.YamlConfig.<init>(YamlConfig.java:12) ~[?:?]
        at net.cubespace.Yamler.Config.Config.<init>(Config.java:4) ~[?:?]
        at net.borlcand.rcon.config.MainConfig.<init>(MainConfig.java:10) ~[?:?]
        at net.borlcand.rcon.config.ConfigManager.<clinit>(ConfigManager.java:7) ~[?:?]
        at net.borlcand.rcon.Rcon.startListener(Rcon.java:38) ~[?:?]
        at net.borlcand.rcon.Rcon.onEnable(Rcon.java:34) ~[?:?]
        at net.md_5.bungee.api.plugin.PluginManager.enablePlugins(PluginManager.java:316) ~[waterfall-1.20-536.jar:git:Waterfall-Bootstrap:1.20-R0.1-SNAPSHOT:ec41547:536]
        at net.md_5.bungee.BungeeCord.start(BungeeCord.java:299) ~[waterfall-1.20-536.jar:git:Waterfall-Bootstrap:1.20-R0.1-SNAPSHOT:ec41547:536]
        at net.md_5.bungee.BungeeCordLauncher.main(BungeeCordLauncher.java:67) ~[waterfall-1.20-536.jar:git:Waterfall-Bootstrap:1.20-R0.1-SNAPSHOT:ec41547:536]
        at net.md_5.bungee.Bootstrap.main(Bootstrap.java:15) ~[waterfall-1.20-536.jar:git:Waterfall-Bootstrap:1.20-R0.1-SNAPSHOT:ec41547:536]

InvalidConfigurationException: Could not get field

Hallo,
ich versuche Locations in eine UserFile abzuspeichern.

Leider wird die Config nicht korrekt generiert:

So sieht mein Code aus:

@Comment("Das ist die letzte Position wo ein Port durchgeführt wurde!")
    private GlobalLocation backpos = null;

    @Comment("Das ist das Home Bed")
    private GlobalLocation homebed = null;

    @Comment("Die Homes vom Spieler xy ohne homebed")
    private Map<String, GlobalLocation> homes = new HashMap<String, GlobalLocation>();

    public UserConfig(File userfolder) {
        CONFIG_HEADER = new String[] { "Porty" };
        CONFIG_FILE = new File(userfolder, "porty.yml");
        try {
            init();
        } catch(InvalidConfigurationException ex) {
            Porty.log.info("Your Config YML was wrong");
            ex.printStackTrace();
        }
    }

Die GlobalLocation.java sieht so aus: http://pastebin.com/01UegrGj

Diesen Fehler bekomme ich:

25.05.2014 10:59 [Information] Your Config YML was wrong
�[m>
25.05.2014 10:59 [Schwerwiegend] net.cubespace.Yamler.Config.InvalidConfigurationException: Could not get field
�[m>
25.05.2014 10:59 [Schwerwiegend]     at net.cubespace.Yamler.Config.Config.internalLoad(Config.java:178)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at net.cubespace.Yamler.Config.Config.load(Config.java:141)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at net.cubespace.Yamler.Config.Config.init(Config.java:113)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at me.moehritz.porty.api.UserConfig.<init>(UserConfig.java:28)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at me.moehritz.porty.io.TeleportHandler$3.done(TeleportHandler.java:90)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at me.moehritz.porty.io.PositionRequest.setPosition(PositionRequest.java:48)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at me.moehritz.porty.io.PluginMessageHandler.onPluginMessageReceived(PluginMessageHandler.java:102)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at java.lang.reflect.Method.invoke(Method.java:606)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at net.md_5.bungee.event.EventHandlerMethod.invoke(EventHandlerMethod.java:19)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at net.md_5.bungee.event.EventBus.post(EventBus.java:47)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at net.md_5.bungee.api.plugin.PluginManager.callEvent(PluginManager.java:353)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at net.md_5.bungee.connection.DownstreamBridge.handle(DownstreamBridge.java:204)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at net.md_5.bungee.protocol.packet.PluginMessage.handle(PluginMessage.java:43)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at net.md_5.bungee.netty.HandlerBoss.channelRead(HandlerBoss.java:75)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:340)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:326)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:155)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:340)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:326)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:155)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:340)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:326)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at io.netty.handler.timeout.ReadTimeoutHandler.channelRead(ReadTimeoutHandler.java:149)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:340)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:326)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:116)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:494)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:461)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:378)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:350)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at java.lang.Thread.run(Thread.java:744)
�[m>
25.05.2014 10:59 [Schwerwiegend] Caused by: java.lang.NullPointerException
�[m>
25.05.2014 10:59 [Schwerwiegend]     at net.cubespace.Yamler.Config.Converter.Config.fromConfig(Config.java:28)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at net.cubespace.Yamler.Config.InternalConverter.fromConfig(InternalConverter.java:82)
�[m>
25.05.2014 10:59 [Schwerwiegend]     at net.cubespace.Yamler.Config.Config.internalLoad(Config.java:173)
�[m>
25.05.2014 10:59 [Schwerwiegend]     ... 35 more

using underscores in inner configs

Here is the config class:

public class UnderscoreInnerConfig extends Config{

    public class InnerConfig extends Config {
        public int lucky_number = 5;
        public String sample_text = "Hello World";
    }

    public InnerConfig config = new InnerConfig();
}

and here's what happens when calling init(...):

net.cubespace.Yamler.Config.InvalidConfigurationException: Could not save the Field
    at net.cubespace.Yamler.Config.Config.internalSave(Config.java:84)
    at net.cubespace.Yamler.Config.Config.save(Config.java:36)
    at net.cubespace.Yamler.Config.Config.init(Config.java:108)
    at net.cubespace.Yamler.Config.Config.init(Config.java:124)
    at UnderscoreInnerConfigTest.initNull(UnderscoreInnerConfigTest.java:33)
Caused by: java.lang.IllegalArgumentException: Can not set int field UnderscoreInnerConfig$InnerConfig.lucky_number to null value
    at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
    at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
    at sun.reflect.UnsafeIntegerFieldAccessorImpl.set(UnsafeIntegerFieldAccessorImpl.java:80)
    at java.lang.reflect.Field.set(Field.java:758)
    at net.cubespace.Yamler.Config.InternalConverter.fromConfig(InternalConverter.java:77)
    at net.cubespace.Yamler.Config.MapConfigMapper.loadFromMap(MapConfigMapper.java:66)
    at net.cubespace.Yamler.Config.Converter.Config.fromConfig(Config.java:33)
    at net.cubespace.Yamler.Config.InternalConverter.fromConfig(InternalConverter.java:72)
    at net.cubespace.Yamler.Config.Config.internalSave(Config.java:81)
    ... 38 more

Doesn't seem to work w/ Spigot 1.10.2

Hello,
I have been using your plugin for several projects fine.
For my first use of your plugin in 1.10, I have a problem: the bukkit converters doesn't seem to work.
new net.cubespace.Yamler.Converter.Location(null).supports(Location.class) returns true!

Thank you.
Problem (this is just a location):
lobby: &id001 !!org.bukkit.Location
pitch: 0.0
world: !!org.bukkit.craftbukkit.v1_10_R1.CraftWorld
PVP: true
ambientSpawnLimit: 15
animalSpawnLimit: 15
autoSave: true
difficulty: EASY
environment: NORMAL
fullTime: 126000
keepSpawnInMemory: true
monsterSpawnLimit: 70
thunderDuration: 68990
thundering: false
time: 6000
waterAnimalSpawnLimit: 5
weatherDuration: 9005
x: 0.0
y: 64.0
yaw: 0.0
z: 0.0

Struggling with Yamler - Please Help!

Getting this error (Which i don't find very helpful at all):
error
May not have stuff set up quite correctly.
i have my main class:
main
ConfigManager:
configmanager
and two config files(MainConfig and Messages):
messages
mainconfig

It's not creating a folder with the configs in it. I'm rather stumped as to what I've done wrong. Please Help!

Saving an ItemStack results in an NullPointerException

import java.io.File;

import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;

import net.cubespace.Yamler.Config.Config;

public class TestConfig extends Config
{
    public ItemStack is = new ItemStack(Material.COOKIE);

    public TestConfig()
    {
        CONFIG_FILE = new File("test.yml");
        try
        {
            addConverter(net.cubespace.Yamler.Converter.ItemStack.class);
            init();
        } catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    public static void main(String args[])
    {
        new TestConfig();
    }
}

This produces the following NullPointerException:

net.cubespace.Yamler.Config.InvalidConfigurationException: Could not save the Field
    at net.cubespace.Yamler.Config.Config.internalSave(Config.java:84)
    at net.cubespace.Yamler.Config.Config.save(Config.java:36)
    at net.cubespace.Yamler.Config.Config.init(Config.java:108)
    at TestConfig.<init>(TestConfig.java:18)
    at TestConfig.main(TestConfig.java:27)
Caused by: java.lang.NullPointerException
    at org.bukkit.Bukkit.getItemFactory(Bukkit.java:1038)
    at org.bukkit.inventory.ItemStack.getItemMeta(ItemStack.java:568)
    at net.cubespace.Yamler.Converter.ItemStack.toConfig(ItemStack.java:34)
    at net.cubespace.Yamler.Config.InternalConverter.toConfig(InternalConverter.java:102)
    at net.cubespace.Yamler.Config.Config.internalSave(Config.java:80)
    ... 4 more

Convert Number formats

Hi

I am using Yamler for my configurations and I added my own Location-class extending the YamlConfig (so you can save it without certain converters). The problem with such YamlConfig as Converters is that there will be errors, if you do something with numbers and der YamlConfig cannot parse them. I am using nearly the same location class as in the example and I am getting errors if I restart the server after saving one Location. The problem is, that he can't set for example the field 'yaw' (Float) because he thinks its a double, however, I saved it as a float. So it would be cool, if there were extra opportunities for the right converting of numbers...

Yours sincerely
Schmidtchen

Saving an Array of Config objects results in a wrong configuration

import java.io.File;

import net.cubespace.Yamler.Config.Config;
import net.cubespace.Yamler.Config.InvalidConfigurationException;

public class TestConfig extends Config
{
    public class InnerConfig extends Config
    {
        public int x = 7;
    }

    public InnerConfig configs[] = { new InnerConfig(), 
            new InnerConfig(),
            new InnerConfig()
            };

    public TestConfig()
    {
        CONFIG_FILE = new File("test.yml");
    }

    public static void main(String args[])
    {
        TestConfig test = new TestConfig();
        try
        {
            test.init();
        } catch (InvalidConfigurationException e)
        {
            e.printStackTrace();
        }
    }
}

This creates the following test.yml, which is wrong and cannot be loaded again:

configs:
- !!TestConfig$InnerConfig
  x: 7
- !!TestConfig$InnerConfig
  x: 7
- !!TestConfig$InnerConfig
  x: 7

StackOverflowError when a config class with an inner class initializes itself on startup

import java.io.File;

import net.cubespace.Yamler.Config.Config;
import net.cubespace.Yamler.Config.InvalidConfigurationException;

public class TestConfig extends Config
{
    public class InnerConfig extends Config {}

    public InnerConfig inner = new InnerConfig();

    public TestConfig()
    {
        CONFIG_FILE = new File("test.yml");
        try
        {
            init();
        } catch (InvalidConfigurationException e)
        {
            e.printStackTrace();
        }
    }

    public static void main(String args[])
    {
        new TestConfig();
    }
}

This example produces a StackOverflowError with this repeating stacktrace:

    at TestConfig.<init>(TestConfig.java:17)
    at sun.reflect.GeneratedConstructorAccessor7.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at java.lang.Class.newInstance(Class.java:383)
    at net.cubespace.Yamler.Config.Converter.Config.newInstance(Config.java:44)
    at net.cubespace.Yamler.Config.Converter.Config.newInstance(Config.java:41)
    at net.cubespace.Yamler.Config.Converter.Config.fromConfig(Config.java:26)
    at net.cubespace.Yamler.Config.InternalConverter.fromConfig(InternalConverter.java:72)
    at net.cubespace.Yamler.Config.Config.internalLoad(Config.java:166)
    at net.cubespace.Yamler.Config.Config.load(Config.java:141)
    at net.cubespace.Yamler.Config.Config.init(Config.java:113)
    at TestConfig.<init>(TestConfig.java:17)
    at sun.reflect.GeneratedConstructorAccessor7.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at java.lang.Class.newInstance(Class.java:383)

Loading of Arrays results in a ArrayStoreException

import java.io.File;

import net.cubespace.Yamler.Config.Config;
import net.cubespace.Yamler.Config.InvalidConfigurationException;

public class TestConfig extends Config
{
    public int[] data = { 1, 2, 3 };

    public TestConfig()
    {
        CONFIG_FILE = new File("test.yml");
        try
        {
            init();
            load();
        } catch (InvalidConfigurationException e)
        {
            e.printStackTrace();
        }
    }

    public static void main(String args[])
    {
        new TestConfig();
    }
}

This program creates the right YAML file, but is not able to parse it again.
It creates an ArrayStoreException:

net.cubespace.Yamler.Config.InvalidConfigurationException: Could not set field
    at net.cubespace.Yamler.Config.Config.internalLoad(Config.java:168)
    at net.cubespace.Yamler.Config.Config.load(Config.java:141)
    at TestConfig.<init>(TestConfig.java:16)
    at TestConfig.main(TestConfig.java:25)
Caused by: java.lang.ArrayStoreException
    at java.lang.System.arraycopy(Native Method)
    at java.util.ArrayList.toArray(ArrayList.java:408)
    at net.cubespace.Yamler.Config.Converter.Array.getArray(Array.java:34)
    at net.cubespace.Yamler.Config.Converter.Array.fromConfig(Array.java:29)
    at net.cubespace.Yamler.Config.InternalConverter.fromConfig(InternalConverter.java:72)
    at net.cubespace.Yamler.Config.Config.internalLoad(Config.java:166)
    ... 3 more

java.security.AccessControlException: Plugin violation: Illegal thread group access

I update to last update of the plugin and the bungee proxy.

15:04:35 [WARNING] Plugin performed restricted action, please inform them to use proper API methods: Illegal thread group access
java.security.AccessControlException: Plugin violation: Illegal thread group access
    at net.md_5.bungee.BungeeSecurityManager.checkRestricted(BungeeSecurityManager.java:39)
    at net.md_5.bungee.BungeeSecurityManager.checkAccess(BungeeSecurityManager.java:62)
    at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:315)
    at java.lang.Thread.init(Thread.java:389)
    at java.lang.Thread.init(Thread.java:349)
    at java.lang.Thread.<init>(Thread.java:547)
    at net.cubespace.Yamler.Metrics.start(Metrics.java:212)
    at net.cubespace.Yamler.YamlerPlugin.onEnable(YamlerPlugin.java:14)
    at net.md_5.bungee.api.plugin.PluginManager.enablePlugins(PluginManager.java:207)
    at net.md_5.bungee.BungeeCord.start(BungeeCord.java:230)
    at net.md_5.bungee.Bootstrap.main(Bootstrap.java:65)

I think it to update a bit on codes for new update of the bungee.

New ConfigMode (DEFAULT or PATH_BY_UNDERSCORE) only works when creating a new config file. Not if it already exists.

Hello!

Yamler 2.4.0 is really cool! However, there seems to be a bug in the new ConfigMode feature.

The plugin having issues is BungeeAdminTools. What happens is that on initial run of the plugin (the part where it creates the new, clean config) it works perfectly. But if the file already exists, it ignores ConfigMode.DEFAULT (set by not defining anything else) and acts as though it's using ConfigMode.PATH_BY_UNDERSCORE.

The config file for BAT can be seen here.

I'm working on a fix that uses @Path, but an official patch would be nice 😄.

Let me know if you need more info, or if I'm being a derp and BAT is actually the culprit.

Thanks.

ItemMeta of ItemStacks is not properly set

In the ItemStack.java converter the ItemMeta is not properly set.
The getItemMeta() method only returns a clone of the actual ItemMeta, so that the ItemMeta must be set again after change like this:

ItemMeta meta = itemStack.getItemMeta();
meta.set...
itemStack.setItemMeta(meta);

Not initialized fields create a NullPointerException on save

import java.io.File;
import java.util.HashSet;

import net.cubespace.Yamler.Config.Config;

public class TestConfig extends Config
{
    public HashSet<String> data;

    public TestConfig()
    {
        CONFIG_FILE = new File("test.yml");
        try
        {
            init();
        } catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    public static void main(String args[])
    {
        new TestConfig();
    }
}

This creates the following NullPointerException:

net.cubespace.Yamler.Config.InvalidConfigurationException: Could not save the Field
    at net.cubespace.Yamler.Config.Config.internalSave(Config.java:84)
    at net.cubespace.Yamler.Config.Config.save(Config.java:36)
    at net.cubespace.Yamler.Config.Config.init(Config.java:108)
    at TestConfig.<init>(TestConfig.java:15)
    at TestConfig.main(TestConfig.java:24)
Caused by: java.lang.NullPointerException
    at java.util.AbstractCollection.addAll(AbstractCollection.java:343)
    at net.cubespace.Yamler.Config.Converter.Set.fromConfig(Set.java:54)
    at net.cubespace.Yamler.Config.InternalConverter.fromConfig(InternalConverter.java:85)
    at net.cubespace.Yamler.Config.Config.internalSave(Config.java:81)
    ... 4 more

Underscores in inner configs don't produce the expected configuration

import java.io.File;

import net.cubespace.Yamler.Config.Config;

public class TestConfig extends Config
{
    public class InnerConfig extends Config
    {
        public String a_x = "Hello, World!";
    }

    public InnerConfig inner = new InnerConfig();

    public TestConfig()
    {
        CONFIG_FILE = new File("test.yml");
    }

    public static void main(String args[])
    {
        TestConfig test = new TestConfig();
        try
        {
            test.init();
        } catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}

This produces the following configuration, which includes a dot(Should be a new Map instead...):

inner:
  a.x: Hello, World!

Frage zu API

Hallo,
ist es irgendwie möglich eine ArrayList mit dem Objekt "Channel" abzuspeichern ohne diese "Classpfad Angaben" abzuspeichern ?
Die Classe Channel enthält
private String name;
private String shortcut;
private String prefix;
private ChatColor color;

So siehts derzeit aus:

channels:
- !!at.Nosxxx.Chat.Channel.Channel
  color: WHITE
  name: default
  prefix: '[default]'
  shortcut: d

So hätte ich es gerne:

channels:
  - color: WHITE
    name: default
    prefix: '[default]'
    shortcut: d

Ist das irgendwie möglich ?

Comments doesn't work for other Config objects inside a Config

import java.io.File;

import net.cubespace.Yamler.Config.Comment;
import net.cubespace.Yamler.Config.Config;
import net.cubespace.Yamler.Config.InvalidConfigurationException;

public class TestConfig extends Config
{
    public class InnerConfig extends Config {
        @Comment("This is another important field")
        public int x = 0;
    }

    @Comment("A field")
    public int a = 7;

    public InnerConfig inner = new InnerConfig();

    public TestConfig()
    {
        CONFIG_FILE = new File("test.yml");
    }

    public static void main(String args[])
    {
        Config test = new TestConfig();
        try
        {
            test.init();
        } catch (InvalidConfigurationException e)
        {
            e.printStackTrace();
        }
    }
}

This example produces the following test.yml:

# A field
a: 7
inner:
  x: 0

But the comment of the inner config field won't get printed to the file, as expected:

# A field
a: 7
inner:
  # This is another important field
  x: 0

Extending configs (What am I doing wrong?)

I am converting a couple of plugins over to using Yamler to "clean" up my config mess :-)
The config structure of my plugin is quite "big", with lists and hasmaps, and whatnot. Most seems to work fine by itself, but extending the config classes I ran into trouble.

In my code I have a concept of an Action which is what to do when an element is triggered. What triggers the action is in the subclass TriggerableAction. Below I have tried to write code that illustrates what im trying to do (read: doing), my expectation and the actual outcome in which I am missing the Field from the extended class...

What am I doing wrong?

Cheers,
Citaborg

// ActionConfig.java
import net.cubespace.Yamler.Config.Config;

public class ActionConfig extends Config
{
    public ActionConfig()
    {
    }

    public ActionConfig(String action)
    {
        this.action = action;
    }

    public String action = "default action";
}
// TriggerableActionConfig.java
public class TriggerableActionConfig extends ActionConfig
{
    public TriggerableActionConfig()
    {
    }

    public TriggerableActionConfig(String trigger, String action)
    {
        super(action);
        this.trigger = trigger;
    }

    public String trigger = "default trigger";
}
//MyConfig.java
public class MyConfig extends Config
{
    public MyConfig(Plugin plugin)
    {
        CONFIG_HEADER = new String[] { "Configuration" };
        CONFIG_FILE = new File(plugin.getDataFolder(), "config.yml");
    }

    public ActionConfig action = new ActionConfig();
    public TriggerableActionConfig trigAct = new TriggerableActionConfig();
    public ActionConfig actionCtor = new ActionConfig("another action (2)");
    public TriggerableActionConfig trigActCtor = new TriggerableActionConfig("another trigger (3)", "yet another action (3)");

}
// in onEnable in myTestPlugin.java
...
if (this.cfg == null){
    this.cfg = new MyConfig(this);
    try { this.cfg.init(); } 
    catch (InvalidConfigurationException e) {
        System.out.println("Error i config.yml");
        ...
    }
}
...
// expected config.yml

action:
  action: default action
trigAct:
  trigger: default trigger
actionCtor:
  action: another action (2)
trigActCtor:
 action: yet another action (3)
 trigger: another trigger (3)
// produced config.yml 
# Configuration 

action:
  action: default action
trigAct:
  trigger: default trigger
actionCtor:
  action: another action (2)
trigActCtor:
  trigger: another trigger (3)

Following the inner class config example fails

the example shows you can have an inner class in your config
https://github.com/Cube-Space/Yamler/blob/master/Yamler-Core/examples/CustomConfigClasses.java#L28

but when i tried it, it fails on this line:

https://github.com/Cube-Space/Yamler/blob/master/Yamler-Core/src/main/java/net/cubespace/Yamler/Config/Converter/Config.java#L27

it tries to instantiate the inner class without any args which fails

i THINK it needs a object of the outer class to work, but i haven't tested that far

Error using latest for geSuite

The only version that works for me is 1.5.2 - the rest seem to have the below error. I have tried wiping all configs and still no change.

I have verified for 100% that the config.yml has the proper configurations.

23:24:01 [SEVERE] net.cubespace.Yamler.Config.InvalidConfigurationException: Could not set field
23:24:01 [SEVERE] at net.cubespace.Yamler.Config.Config.internalLoad(Config.java:168)
23:24:01 [SEVERE] at net.cubespace.Yamler.Config.Config.load(Config.java:141)
23:24:01 [SEVERE] at net.cubespace.Yamler.Config.Config.init(Config.java:113)
23:24:01 [SEVERE] at net.cubespace.geSuit.managers.ConfigManager.(ConfigManager.java:25)
23:24:01 [SEVERE] at net.cubespace.geSuit.managers.DatabaseManager.(DatabaseManager.java:38)
23:24:01 [SEVERE] at net.cubespace.geSuit.geSuit.onEnable(geSuit.java:39)
23:24:01 [SEVERE] at net.md_5.bungee.api.plugin.PluginManager.enablePlugins(PluginManager.java:217)
23:24:01 [SEVERE] at net.md_5.bungee.BungeeCord.start(BungeeCord.java:233)
23:24:01 [SEVERE] at net.md_5.bungee.Bootstrap.main(Bootstrap.java:68)
23:24:01 [SEVERE] Caused by: java.lang.ClassCastException: net.cubespace.geSuit.configs.SubConfig.AnnouncementEntry cannot be cast to net.cubespace.Yamler.Config.ConfigSection
23:24:01 [SEVERE] at net.cubespace.Yamler.Config.Converter.Config.fromConfig(Config.java:27)
23:24:01 [SEVERE] at net.cubespace.Yamler.Config.Converter.Map.fromConfig(Map.java:76)
23:24:01 [SEVERE] at net.cubespace.Yamler.Config.InternalConverter.fromConfig(InternalConverter.java:69)
23:24:01 [SEVERE] at net.cubespace.Yamler.Config.Config.internalLoad(Config.java:166)
23:24:01 [SEVERE] ... 8 more
23:24:01 [INFO] SQL is unable to conect
23:24:01 [SEVERE] java.sql.SQLException: Access denied for user 'username'@'localhost' (using password: YES)
23:24:01 [SEVERE] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1084)
23:24:01 [SEVERE] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4232)
23:24:01 [SEVERE] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4164)
23:24:01 [SEVERE] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:926)
23:24:01 [SEVERE] at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1748)
23:24:01 [SEVERE] at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1288)
23:24:01 [SEVERE] at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2506)
23:24:01 [SEVERE] at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2539)
23:24:01 [SEVERE] at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2321)
23:24:01 [SEVERE] at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:832)
23:24:01 [SEVERE] at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:46)
23:24:01 [SEVERE] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
23:24:01 [SEVERE] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
23:24:01 [SEVERE] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
23:24:01 [SEVERE] at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
23:24:01 [SEVERE] at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
23:24:01 [SEVERE] at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:417)
23:24:01 [SEVERE] at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:344)
23:24:01 [SEVERE] at java.sql.DriverManager.getConnection(DriverManager.java:571)
23:24:01 [SEVERE] at java.sql.DriverManager.getConnection(DriverManager.java:215)
23:24:01 [SEVERE] at net.cubespace.geSuit.database.ConnectionPool.initialiseConnections(ConnectionPool.java:37)
23:24:01 [SEVERE] at net.cubespace.geSuit.managers.DatabaseManager.(DatabaseManager.java:38)
23:24:01 [SEVERE] at net.cubespace.geSuit.geSuit.onEnable(geSuit.java:39)
23:24:01 [SEVERE] at net.md_5.bungee.api.plugin.PluginManager.enablePlugins(PluginManager.java:217)
23:24:01 [SEVERE] at net.md_5.bungee.BungeeCord.start(BungeeCord.java:233)
23:24:01 [SEVERE] at net.md_5.bungee.Bootstrap.main(Bootstrap.java:68)
23:24:01 [WARNING] Exception encountered when loading plugin: geSuit

String Lists, and Arrays cannot be modified

Whenever I create a String array or a list of strings yamler correctly converts it but appears to be unable to read it and does not allow someone to change it like it would with other variables.

I have a class named YAMLConfig:
https://www.dropbox.com/s/op4rxt1blz3feue/Screenshot%202016-06-07%2017.43.45.png?dl=0

Then I have a PlayerJoinEvent listener that broadcasts everything in the YAMLConfig class for testing.
https://www.dropbox.com/s/wyzr7t657vlc00h/Screenshot%202016-06-07%2017.45.53.png?dl=0

Then my test.yml class looks like this and is successfully generated when I restart my server.

Localization:
  # Lets try it with comments!
  TEST:
- '&AOooh test #1'
- '&bTest #2'
- Change us!
  # more
  # more
  # and even more comments!
  INT: 300```

When I modify test.yml to be something like this
```yaml
Localization:
  # Lets try it with comments!
  TEST:
- '&AOooh test #1'
- '&bTest #2'
- '&cOkay, I''ll change you!'
  # more
  # more
  # and even more comments!
  INT: 300```

Then restart the server, test.yml turns in to this.
```yaml
Localization:
  # Lets try it with comments!
  TEST:
- '&AOooh test #1'
- '&bTest #2'
- Change us!
  # more
  # more
  # and even more comments!
  INT: 300
  Localization_TEST:
  - '&AOooh test #1'
  - '&bTest #2'
  - Change `us!```

It is also worth noting that I get this both times when I join the server.
https://www.dropbox.com/s/07kswot5v3qltzn/Screenshot%202016-06-07%2017.49.38.png?dl=0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.