Fix for issue #64 bad interaction with Essentials plugin

This commit is contained in:
walterhiggins 2013-02-22 15:49:42 +00:00
parent a684a0b333
commit 5b473d9c93
3 changed files with 16 additions and 7 deletions

View file

@ -15,8 +15,9 @@ import java.util.ArrayList;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.command.*; import org.bukkit.command.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.event.Listener;
public class ScriptCraftPlugin extends JavaPlugin public class ScriptCraftPlugin extends JavaPlugin implements Listener
{ {
// right now all ops share the same JS context/scope // right now all ops share the same JS context/scope
// need to look at possibly having context/scope per operator // need to look at possibly having context/scope per operator

View file

@ -94,10 +94,6 @@ var events = events || {
} }
var _event = org.bukkit.event; var _event = org.bukkit.event;
var _plugin = org.bukkit.plugin; var _plugin = org.bukkit.plugin;
//
// can't have objects that implement multiple interface in javax.scripts.*
//
var theListener = new _event.Listener(){};
var _on = function(eventType, handler, priority) var _on = function(eventType, handler, priority)
{ {
@ -121,7 +117,19 @@ var events = events || {
} }
}; };
listener.reg = new _plugin.RegisteredListener( listener.reg = new _plugin.RegisteredListener(
theListener,eventExecutor,priority,__plugin,true /*
wph 20130222 issue #64 bad interaction with Essentials plugin
if another plugin tries to unregister a Listener (not a Plugin or a RegisteredListener)
then BOOM! the other plugin will throw an error because Rhino can't coerce an
equals() method from an Interface.
The workaround is to make the ScriptCraftPlugin java class a Listener.
Should only unregister() registered plugins in ScriptCraft js code.
*/
__plugin
,eventExecutor
,priority
,__plugin
,true
) )
handlerList.register(listener.reg); handlerList.register(listener.reg);
return listener.reg; return listener.reg;

View file

@ -206,6 +206,7 @@ var signs = signs || plugin("signs", {
look up our list of menu signs. If there's a matching location and there's look up our list of menu signs. If there's a matching location and there's
a sign, then update it. a sign, then update it.
*/ */
if (! event.clickedBlock.state instanceof org.bukkit.block.Sign) if (! event.clickedBlock.state instanceof org.bukkit.block.Sign)
return; return;
var evtLocStr = utils.locationToString(event.clickedBlock.location); var evtLocStr = utils.locationToString(event.clickedBlock.location);
@ -213,7 +214,6 @@ var signs = signs || plugin("signs", {
if (signUpdater) if (signUpdater)
signUpdater(event.player, event.clickedBlock.state); signUpdater(event.player, event.clickedBlock.state);
}); });
}); });
}()); }());