I have a problem:
I wrote a lobby plugin for a Minecraft server and now it doesn't quite work anymore.
In what way:
As soon as I reinstall the plugin, everything works perfectly. But as soon as I change something in a config file, only one method of the plugin loads.
I have linked the plugin here:
Plugin
Source Code
Would be cool if you guys can help me.
The issue appear because of lines like this one:
new File("plugins//Lobysystem//preandsuffixes.yml");
1) Don't write your own folder
Spigot already has API to do it. In the onEnable method, you can do saveDefaultConfig() that will create the folder for the plugin's config.
2) Use Spigot's informations
Such as spigot have multiple way to make config file fastly, you can do something like this (already with the plugin instance):
new File(getDataFolder(), "preandsuffixes.yml");
3) The static method will no longer work
Yes, if you have to use the plugin instance, all of the static {} method will not work. If you really want to keep a static method to load everything, you can do something like that:
public static loadConfig(Main plugin) {
myconfig = new File(plugin.getDataFolder(), "preandsuffixes.yml");
}
#Override
public void onEnable() {
loadConfig(this);
}
4) Stackoverflow guidelines
It's off-topic for an answer, but few tips :
Try to don't include link to download unknow source
Add a minimal reproductible example instead of just giving all the code
Don't decompile plugin.
Take the time to identify problem and to be more clear than "it was working but now it's no longer working"
Related
Hey guys i'm working on a project with Google App Engine. To get Data from my devices we're using MQTT. The org.eclipse.paho.client.mqttv3.* library starts a Thread with "client.connect()".
After some researches i found that you cant just simply create Threads when working with GAE. Following error is shown:
java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "modifyThreadGroup")
So i continued searching and someone told to use following code instead of a "normal" Thread:
Thread monitoringThread = ThreadManager.createThreadForCurrentRequest( new Runnable() {..}
So i decompiled the paho library, looked up where the Thread is created and changed it.
I created a new class exported it as mymqttclient.jar
In eclipse i changed the order of my build at Properties -> Java Build Path -> Order and Export so mymqttclient.jar is loaded before the mqtt-client-0.4.0.jar So that it will use my created function with the monitoringThread.
But how can i change the order of the .jar's in the web-inf/lib ?
Thank you very much for your answers, i couldnt find something useful until now.
Firstly there is no need to decompile any of the Paho code it is all available from here.
Since you can now get the clean source, why not just modify the original class and rebuild the jar file, then you don't need to worry about messing with the Classpath to get your class to load first?
I'm very new to eclipse plugin development, and frankly to eclipse itself. I am trying to find a way to access a list of which files are currently being worked on by the user, and possibly even more specifically, what part of these files (which class, method, block of code, etc.).
I am thinking that I would like to have the plugin grab information on which files are currently open in the tabs, and then go from there, but I can't even figure out how to do this. I've been searching the eclipse documentation at help.eclipse.org, but I still haven't found anything useful for what I want to do. Does anyone have any ideas?
Try the following code:
IWorkbenchPage[] pages = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getPages();
for (IWorkbenchPage page : pages) {
IEditorReference[] references = page.getEditorReferences();
for (IEditorReference reference : references) {
IEditorInput input = reference.getEditorInput();
}
}
You should be able to walk your way from the workbench to a workbench page (IWorkbenchPage), which as a findEditors method.
I’m trying to create a backend for a homepage with GWT. I created a Google Web Application in Eclipse without sample code and now I would like to add the service, but the developer Google guide doesn’t help me. I’m not sure, where to add the interface and how it exactly works.
If I understand the google documentation correctly, I have to add a module and an entry point class, is that correct? It would be great if you could give me some tips and help how to create a rpc service.
If you create a new GWT project in the Eclipse "New Project" wizard, with "Generate project sample code" checked, it will include a fully functioning RPC service with a sample method, which you can then adapt or copy according to your needs.
Out of memory, don't have eclipse in front of me.
First do create a test project with generated testcode, you can delete it afterward.
Yes you will have to add a module.
Create in client the two interfaces for the async calls, inherit it on server side.
Hope I understood your question right.
I'm not sure what would help you the most. Google developer guide was enough for me (at least when I started using it on version 1.6) to create RPC services for my GWT application.
General APP
Module: is the .gwt.xml file. Yes, you'll need it. The GWT compiler will find it automagically and try to compile all the GWT code (the <source> element will tell which subpackage contains Java code that will be converted to JS). It will tell also which class implements the EntryPoint interface. The onModuleLoad will be the code executed when javascript runs in the client page.
RPC
Well, you should first try UI things and only then, when you're confident enough, try the server thing. Anyway the scheme is:
interface MyService extends RemoteService {
List<String> doSomething(String sample, int other);
}
#RemoteServiceRelativePath("../path/to/servlet") // see later
intercace MyServiceAsync {
void doSomething(String sample, int other, AsyncCallback<List<String>> callback);
}
These are the interfaces. Later is the async one. That's what you'll use from client side. Always calling and passing an implementation of AsyncCallback which will receive (sometime later, you don't know when) the result.
First interface is the syncrhonous one. That is what you need to implement on server. You must inherit from RemoteServiceServlet class (it is an implementation of servlet that already does all the values handling), and implement your interface. GWT code does the rest (almost).
public class ServiceImpl extends RemoteServiceServlet implements MyService
{
// implement the method normally
}
From client you'll need to create the service proxy:
private static MyServiceAsync MY_SERVICE = GWT.create(MyService.class);
Yes. I know it's weird how GWT knows MyserviceAsync and MyService work together. Don't worry about that. It works :)
Just use the service like this:
MY_SERVICE.doSomething("value", 111, new AsyncCallback<List<String>>() {
// note that this code executes some time in the future when response from server is back
public void onSuccess(List<String> result) {
Window.alert("Server answered with " + result.size() + " elements!");
}
public void onFailure(Throwable t) {
Window.alert("Server failed: " + t.getMessage());
}
}
Path to server
You'll have to configure your app to make that servlet implementation listen to URL indicated in #RemoteServiceRelativePath. That's the way client knows where to make the request, and the server knows which servlet attends that request. I'd suggest using:
../my-service.gwt as relative path (GWT module gets published in <ROOT>/module_name
and
configuring your web app to use the servlet for /my-service.gwt
But it's entirely upon your preferences :)
Anyway I think Google tutorials are the best. So please copy&paste. Try&modify until you get to understand the whole thing.
I mainly program Android, and one of the things I (and the rest of android programmers I'm sure) use with tenacity is android.util.Log. Every class I create has a
private static final String TAG = "ClassName";
tag that I write up as soon as I create the class, before I work on anything else. So, since I always create the tag I figured it would just save me on time (albeit a small amount) to just have it as part of the template for an empty class. My problem is, I don't know how or where to create code templates. Can anyone inform me on how to manage and create them?
What you're referring to are called "code templates" in Eclipse.
Go to Eclipse Preferences, search for "templates", you'll find them under Java -> Code Style -> Code Templates.
Where I can find wicketstuff-annotation.jar? It's used to be available at least in a Maven repo at http://wicketstuff.org/maven/repository but that doesn't exist anymore, and the Wicket Stuff homepage is not very helpful either.
Specifically, I need org.wicketstuff.annotation.mount.MountPath because I want readable URLs in my Wicket app and find annotations an elegant way to mount pages. (I wonder why this kind of stuff isn't included in core Wicket distribution...)
(Any place to download the jar from would be fine; I don't use Maven in current project.)
You can just mount your pages anywhere in your application, typically in your Application's init() method, like:
#Override
protected void init() {
mountBookmarkablePage("/users", UsersPage.class);
}
That said, if you want to use the annotations package, it is available from Maven Central
Update from Wicket 1.5:
You should use the method mountPage() instead of mountBookmarkablePage() as that method has been removed from Wicket 1.5.
#Override
protected void init() {
mountPage("/users", UsersPage.class);
}
https://cwiki.apache.org/WICKET/migration-to-wicket-15.html
This is the URL. You can click on Binary link to download the required jar.
A community user today contributed an upgrade of the library to Wicket 1.5, so it will be available for next release (1.5-RC6). Until then the users of 1.5 can use it from Github repo.