<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Extending Java constructors with Nashorn?]]></title><description><![CDATA[<p dir="auto">Let's say that there's a listener that subscribes into PacketEvent and calls my WrappedPacketEvent:</p>
<pre><code class="language-javascript">var WrappedListener = Java.extend((Java.type('net.ccbluex.liquidbounce.event.Listenable')), (Java.type('java.util.function.Consumer')), {
    handleEvents: function() { return true },
    accept: function(e) {
        e instanceof PacketEvent &amp;&amp; LiquidBounce.INSTANCE.eventManager.callEvent(new WrappedPacketEvent(e.getPacket().wrapped)); 
    }
});
</code></pre>
<p dir="auto">But how can I extend Event and create my own constructor  that accepts <code>Packet&lt;?&gt;</code>? (Consumer?)</p>
]]></description><link>https://forum.liquidbounce.net/topic/3603/extending-java-constructors-with-nashorn</link><generator>RSS for Node</generator><lastBuildDate>Fri, 06 Mar 2026 03:02:45 GMT</lastBuildDate><atom:link href="https://forum.liquidbounce.net/topic/3603.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 06 Feb 2022 09:15:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Extending Java constructors with Nashorn? on Sun, 06 Feb 2022 09:49:38 GMT]]></title><description><![CDATA[<p dir="auto">There's how far I got:</p>
<pre><code class="language-js">var WrappedListener = Java.extend((Java.type('net.ccbluex.liquidbounce.event.Listenable')), (Java.type('java.util.function.Consumer')), {
    handleEvents: function() { return module[0].state },
    accept: function(e) {
        e instanceof PacketEvent &amp;&amp; LiquidBounce.INSTANCE.eventManager.callEvent(new WrappedPacketEvent(e.getPacket().wrapped)); 
    }
});

function WrappedPacketEvent(packet) {
    var isCancelled;

    this.isCancelled = function() isCancelled;
    this.cancelEvent = function() {
        isCancelled = true;
    }
    this.getPacket = function() packet;
}
</code></pre>
]]></description><link>https://forum.liquidbounce.net/post/28491</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28491</guid><dc:creator><![CDATA[idk my name]]></dc:creator><pubDate>Sun, 06 Feb 2022 09:49:38 GMT</pubDate></item><item><title><![CDATA[Reply to Extending Java constructors with Nashorn? on Sun, 06 Feb 2022 09:27:50 GMT]]></title><description><![CDATA[<p dir="auto">For understanding:<br />
<img src="/assets/uploads/files/1644139577522-9751f39d-9889-41ad-82d3-322fa8869705-image.png" alt="9751f39d-9889-41ad-82d3-322fa8869705-image.png" class=" img-fluid img-markdown" /><br />
The problem is in <code>IPacket</code>.<br />
I want to wrap <code>IPacket</code> into <code>Packet&lt;?&gt;</code>, so onPacket will accept <code>Packet&lt;?&gt;</code> instead of <code>IPacket</code> (xversion problem, I need to write e.getPacket().wrapped instead of just e.getPacket(), that's really annoying)</p>
]]></description><link>https://forum.liquidbounce.net/post/28490</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28490</guid><dc:creator><![CDATA[idk my name]]></dc:creator><pubDate>Sun, 06 Feb 2022 09:27:50 GMT</pubDate></item></channel></rss>