I have an interesting problem where I want to enable a specific Bukkit plugin first before any other plugins are enabled. This has proven a difficult task. I can't use the plugin.yml dependancy options because those assume I know what plugins are installed on any given server. I don't care if it doesn't load first, but I do need it to enable first.
I have tried several methods to accomplish this but with no luck:
Attempt 1:
static{
try {
Bukkit.getPluginManager().loadPlugin(plug);
Bukkit.getPluginManager().enablePlugin(plugin);
} catch (UnknownDependencyException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidPluginException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidDescriptionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Allow me to explain. The static seems to run before most anything, including plugin loadups. This means I also have to define when it loads as well. This normally wouldn't be a problem, except non static API like getDataFolder() for the file Path doesn't work.
public static File plug = new File("/plugins/Debugger");
So unless I'm doing my Paths wrong, I have no clue why this throws an Exception.
NOTE: Yes, I have tried multiple different paths such as "plugins/Debugger" or "Debugger.jar" and ECT.
Method 2:
public void onLoad(){
Bukkit.getPluginManager().enablePlugin(plugin);
console.info("[Debugger] loaded first!");
}
This seemed too good to be true and this method actually seemed to get me closer to solving my problem. This Method is called whenever the plugin loads, so by enabling the plugin within the onLoad Method, it actually caused the plugin to enable first; But there were issues when loading:
[00:15:08] [Server thread/ERROR]: null initializing Debugger v1.0.0 (Is it up to date?)
java.lang.NullPointerException
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:396) ~[craftbukkit.jar:git-Bukkit-0ebb9c7]
at me.doublehelix457.Debugger.Debugger.onLoad(Debugger.java:20) ~[?:?]
at org.bukkit.craftbukkit.v1_10_R1.CraftServer.loadPlugins(CraftServer.java:299) [craftbukkit.jar:git-Bukkit-0ebb9c7]
at org.bukkit.craftbukkit.v1_10_R1.CraftServer.reload(CraftServer.java:723) [craftbukkit.jar:git-Bukkit-0ebb9c7]
at org.bukkit.Bukkit.reload(Bukkit.java:548) [craftbukkit.jar:git-Bukkit-0ebb9c7]
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [craftbukkit.jar:git-Bukkit-0ebb9c7]
Somehow despite the weird null initializing Debugger (Debugger is the test plugin name) the plugin still managed to enable first?
So the line it is referring to is Bukkit.getPluginManager().enablePlugin(plugin);
Doing some research online I noticed certain API like getServer() was not working within that Method and I believe that maybe this means that Bukkit or PluginManager may not exist yet.
If that's the case, then is there a workaround to this?
That said, I'm willing to take improvements on my current attempts or even try new ones, whatever gets the job done. Please do not ask "Why do you need to enable the plugin first?" I should mention that this version of bukkit is on 1.10.
Any HELPFUL advice would be much appreciated.
So now I feel really stupid. Turns out all I had to do was make my
plugin variable non-static and define it. All that trouble just to change
public static Debugger plugin; to public Debugger plugin = this;
This change works with Method 2.
Well. I hope that this benefits someone as to how they can enable a plugin first.
Related
I am working on Android app and we are working as a team. I am facing a serious issue. And that is when ever I try to get the data from intent it gives me following exception
Parcel android.os.Parcel#355932a: Unmarshalling unknown type code
4784211 at offset 712
I know on SO there are a lot of helping material related to this issue, but my case is different and quiet mind boggling .....
Here is a quick code to see how I am getting my object
try {
if (data.hasExtra("KEY_MY_MODEL")) {
MyCustomModel newSelectedModel = data.getParcelableExtra("KEY_MY_MODEL");
//DO SOME THING WITH OBJECT
}
} catch (Exception e) {
e.printStackTrace();
}
Case1:
I am getting exception on first line if (data.hasExtra("KEY_MY_MODEL")) {
and this is quiet funny because when I inspect the intent object (data) while debugging and if I look into intent object using debugging I can see all my custom object.
The keys of getting object are same, if in any case the key is wrong I think the code inside the if condition must not get run. as it will return false.
But instead of returning false it is giving the above mentioned exception.
Case2: As I told you we are working in team, the same set of code is running perfectly on other system, but when I run app from my system and install app on device, it is giving the exception I mentioned above.
This is very much frustrating. I think there is something wrong with proguard, as I read on S.O but its still not helpful. Any Idea why this is happening? This looks like a big bug.
Note: I am using A.S 3.5 and on other system A.S 3.5 is in use, even we have same set of sdk, configurations and other things are quiet
identical on both sides...
It seems to be a ProGuard issue
Just add this line in proguard.rules.pro/txt
-keepclassmembers class * implements android.os.Parcelable {
static ** CREATOR;
}
i'm using the LibGdx framework to create a game and I'm using Eclipse 4.4 (Luna). Whilst i'm debugging my application this method is breaking.
#Override
public void run() {
setName("GLThread " + getId());
if (LOG_THREADS) {
Log.i("GLThread", "starting tid=" + getId());
}
try {
guardedRun();
} catch (InterruptedException e) {
// fall thru and exit normally
} finally {
sGLThreadManager.threadExiting(this);
}
}
inside the GLSurfaceView Android class, with the stack trace:
Thread [GLThread 232] (Suspended (exception NullPointerException))
GLSurfaceView$GLThread.run() line: 1243
I know what a NullPointerException is, I know somewhere is passing a null value, but what I would like to know is how can I find out where?
With these types of questions, I can only assume you'll need more code but I don't know where I should be looking, I'll post code from the Java classes on request if anyone has an idea of where I should be looking.
Note: I'm not using GLSurfaceView directly anywhere in my code, I'm assuming it's a library from Libgdx. Unless it's something i'm missing?
UPDATE: Found the issue in detail.
GLSurfaceView$GLThread.class [in android.opengl [in C:\Users\me\AppData\Local\Android\android-sdk\platforms\android-8\android.jar]] does not exist
Solution:
An AtlasRegion was being called from the renderer class without being assigned a value in the assets class hence the null Exception
What is a NullPointerException, and how do I fix it?
changing that to a field that is declared solved this problem for me on the code side.
For the solution to the backend issue:
GLSurfaceView$GLThread.class [in android.opengl [in C:\Users\me\AppData\Local\Android\android-sdk\platforms\android-8\android.jar]] does not exist
I downloaded source codes from Google, and assigned the source code inside the SDK folder, C:\Users\me\AppData\Local\Android\android-sdk\sources\, if you don't already have a source folder create one, put the sources in there and it should reload the class that was being handled. (in this case GLSurfaceView.class for API 2.2)
Another way In Eclipse 4.4 (Luna) or any other eclipse I do believe, go onto your project folder right click > properties > java build path and assign the source file for android.jar in your dependent libraries.
I am doing some debugging in an application (not applet) and have obtained the system's security manager via a call to System.getSecurityManager(). How can I print all configuration information that this SecurityManager was setup with? Looking at the Java 7 SE API it seems that all methods are interrogatory in nature and there is no way to get the permissions configuration. The toString() method also seems to inherit directly from Object and just prints the pointer.
Run the program with -Djava.security.debug=access,domain and you will see everything you need to see.
See it here. http://www.oracle.com/technetwork/java/javase/tech/index-jsp-136007.html
There also exists another method of checking the permissions. Use a try catch block.
try{
} catch (Exception e){
if (e instanceof SecurityException){
// It's a security violation.
// Look for another possibility
}
}
Hope this helps.
I'm running into the strangest error in this program, which is confirmed when debugging it. I have the following code (boiled down to highlight the problem, of course):
BHFrame.java
public class BHFrame
{
private boolean uSS;
private StateSaver stateSaver;
public BHFrame(boolean useInternalStateSaver)
{
//Init code
uSS = useInternalStateSaver;
//More init code
System.out.println(uSS);
if (uSS)
{System.out.println("Entered 1");
stateSaver = new StateSaver(title, false);
stateSaver.addSaveable(getThis());
}
//More init code
System.out.println(uSS);
if (uSS)
{System.out.println("Entered 2");
try
{
stateSaver.loadState();
stateSaver.putState(getThis());
}
catch (IOException ex)
{
alertUserOfException(ex);
}
}
}
}
GUI.java
public class GUI extends BHFrame
{
public GUI(boolean useInternalStateSaver)
{
super(useInternalStateSaver);
}
}
Main.java
public class Main
{
public static void main(String[] args)
{
GUI gui = new GUI(false);
}
}
Output
false
false
Entered 2
Exception in thread "main" java.lang.NullPointerException
at bht.tools.comps.BHFrame.<init>(BHFrame.java:26)
at bhms.GUI.<init>(GUI.java:5)
at bhms.Main.main(Main.java:5)
The class BHFrame is extended and run from a child class that calls this constructor, but that really shouldn't affect this behavior. The problem is that, when false is passed to the constructor as useInternalStateSaver, the first if (uSS) is skipped, but the second is entered. Upon debugging, I found that uSS is false throughout runtime, including on the line of the second if statement, here. Why would Java enter an if statement when the condition returns false? Before you ask, I did delete the .class files and recompile it just in case there was some residual code messing with it, but I got the same result. And rest assured, all the references to the uSS variable are displayed here.
Solution
As it turns out, this appears to be a bug in NetBeans 7.1 Build 201109252201, wherein the IDE doesn't properly insert new code into the compiled .class files. The problem was fixed by compiling the files externally. A bug report has been submitted.
Whatever's throwing that exception is probably not in your posted code.
It's not being caught by your catch statement, which only catches IOException.
It's a NullPointerException and can occur anywhere.
You have shown no indication that the code inside your if block is actually executing. In your screenshot, there is absolutely know way of knowing if your if block is entered or not. There are no logging statements.
Add debugging messages at various points to see exactly what is happening. Or, you know, look at line 26 (wayyyyy before your posted code) to see why you're getting a NullPointerException.
I've seen crazy stuff like this when there is bad RAM on the machine. You might want to run memtest86.
You might also consider deleting all of your project class files, and then doing a build. Maybe you changed Main.java, but it was never recompiled. I hate that when that happens.
This is just a guess, because I can't see the code you are mentioning, but I reckon you have defined a local variable uSS in the second //More init code segment.
Once you define a local variable named the same as an instance variable, it 'hides' the instance variable. Better to qualify all instance variables with this.
So, try qualifying all above accesses of uSS with this. ... (this.uSS)
Even if this isn't the issue, it might be better to post the full code anyway.
HTH
I am coding in GWT 2.3 using Eclipse. While I have had coding experience, it has been limited to client-side. My current project involves creating a mapping program, which takes a list of points from an Excel sheet and places them on a predefined image. Now, I have my servlet and my client code connected, and I already have some idea how to read the Excel file.
My current problem: I get the following error when I load my application on Firefox using Development Mode:
Something other than an int was returned from JSNI method '#com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader::readInt()': JS value of type undefined, expected int
Development Mode's console doesn't give me any errors when I run, those it does tell me there is a [WARN] with two things I'm not using (images which I misnamed, but do not load ever).
Currently, my code is as follows:
In my Floor.java client side code:
MyServiceAsync service = (MyServiceAsync) GWT.create(MyService.class);
AsyncCallback<String> callback = new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
printerModel.setText("FAILED");
String details = caught.getMessage();
printerModel.setText(details);
}
#Override
public void onSuccess(String result) {
//I purposefully have this as an empty method so I could figure out the error
}
};
service.readFile("PrinterList.xls", callback);
In my MyService.java:
>public String readFile(String s);
In `MyServiceImpl.java`:
>public String readFile(String s) {
// TODO Auto-generated method stub
try {
} catch (Exception e) {
}
return "foo";
}
My AsyncCallback type is String, which seems to be causing the error. The method my client code calls returns a single String at this point, "fubar" (for simplicity). I thought that Strings were automatically serializable, but I am not sure. So, how do I get this error to go away? And how do I make the server code serialized?
What the exception says is basically this:
Client was trying to read an object from the data stream. Based on the signature of called method (or some other hint) the stream reader was expecting an int but found undefined instead.
As for the serializability of String, your assumption is correct. They are serializable without any effort on your part.
Without looking at the code and/or exception trace, it's difficult to say anything more.
EDIT:
Your code seems fine to me. Is there a chance that you are mixing GWT versions? That is you compiled your GWT application with 2.3, but the server classpath contains an older GWT jar (or vice versa). Take a look at:
Project GWT version settings. Project-> Properties -> Google -> Web Toolkit. Which version of GWT is selected there?
Compare the GWT settings with Project -> Properties -> Java Build Path -> Libraries. How many GWT related jars do you see there? Which version? Are there more than one gwt-servlet-x.y.jar?