asusoda / Corundum

This is a new plugin-based server-side modding A.P.I. for Minecraft. [WIP]
MIT License
7 stars 1 forks source link

Some interfaces still use Java 8 code/Project not completely Java 7 #3

Closed Niadevv closed 9 years ago

Niadevv commented 9 years ago

While there has been a commit claiming to back Corundum down to Java 7 (A good move in my opinion, although I myself would have liked my personal project to be Java 8, Mac users apparently can't use Java 8 stuff because Apple), the utils.messaging.Messenger interface uses default methods, a feature introduced in Java 8 but not existing earlier. This is also present in the Commander, CorundumListener and Matchable interfaces, possibly more.

A possible solution would be to have a default abstract base class with the implemented methods and the "implement it yourself" methods declared abstract in said base class. Could be some work, however.

Variadicism-zz commented 9 years ago

I finished integration into Java 7. Sorry about that; I must have mislabeled that commit. I'll be sure to make more accurate labels in the future.

Niadevv commented 9 years ago

Don't worry, sometimes my commits are mislabeled due to some commit issues. I have done some work on the conversion to Java 7, though. I made an interface an abstract class (CorundumListener), as it was only used once in the corundum source code. Latest commit also seems to have the interfaces backported. Closing.

Variadicism-zz commented 9 years ago

My commits actually got rid of the CorundumListener class. Unfortunately, because Java (stupidly) still doesn't support multiple inheritance, I try to avoid making abstract classes as much as possible to allow plugin authors to make their listener classes extend whatever they want. That way, they don't have to have one central listener class or more than one central listener classes; instead, they can implement interfaces for the listeners they want. The plan for interfaces right now is this: each listener method (e.g. "onPluginEnable(CorundumPlugin)") will be associated with a single plain old-fashioned Java 7 interface (e.g. "PluginEnableListener"). To use a listener method, plugin authors simply make their class implement the appropriate listener interface. Also, for added convenience, there are some extra listener interfaces that extend multiple listener interfaces that have a similar function (e.g. "PluginListener" extends all listener interfaces that have to do with plugin handling, i.e. "PluginLoadListener", "PluginEnableListener", "PluginDisableListener", and "PluginUnloadListener"). If you have a simpler idea, please let me know because I realize that this idea isn't perfect. I would have MUCH preferred using Java 8 default interface methods to make the CorundumListener like before, but that won't work. So, I'm open to ideas, but I think that this is currently the best plan we have.

Niadevv commented 9 years ago

I too would have loved to use Java 8 as well (even for my own stuff). Some of Java 8's features are awesome, and I'd love to use them. The issue is that as far as I can tell, Mac users can't seem to use Java 8 (unless I'm missing something, I might be, I'm a Windows user myself), and a large amount of the Minecraft community are Mac users. Another thing is that Minecraft itself is stupidly on Java 6. Java 7 allows for more performance optimisations and cool features on Mojang's end. Furthermore, Java 6 is outdated, and has been for quite a while. IMO Minecraft should be Java 7 MINIMUM.

The interface plan is good in my opinion. It means you can implement specific listeners, and, if you use them all, you can just implement PluginListener and be done with it.

The background for Java not supporting multiple inheritance is because simplicity. One of the reasons for Java's existence is a simple alternative to C++. The Java devs decided that multiple inheritance was too complicated to add, so they didn't. If that's still the case with things like annotations, generics, etc. nowadays, I don't know.

Variadicism-zz commented 9 years ago

Minecraft absolutely should be at least Java 7. I don't know why in the world they're not. That reminds me, I forgot aoub the step in the building from source instructions I added to the README; you need to go into the MCP config and change its Java commands.

I didn't know that Java 8 wasn't available for Mac. I forgot that Mac has to use that special Apple Java bullshit. I actually tried really hard to make Java 8 to work, but I couldn't get it to work with MCP. They have to use ASM to modify the compiled bytecode for reobfuscation. It took me a while, but I actually got so far as making it be able to compile and reobfuscate without displaying any errors, but unfortunately, there was a bug that wouldn't obfuscate fields or methods; only classes were reobfuscated properly. I could never find that bug and had to give up on it. I e-mailed Ocean Labs about my progress and the bugs, but they never replied.

I suppose it might be for the better; just about everyone uses Java 7 now, but Java 8 would require quite a few people to upgrade.

I know they decided against multiple inheritance for simplicity, but it was for the creators' simplicity, not the users. Multiple inheritance, in my opinion, is simpler to use than all this interface crap. Oh well... wishful thinking...