Jump to content

Recommended Posts

Guest Elfocrash
Posted

Hey guys, i was checking my archive and i found this buffer from my server L2Cydonius.

 

Here is a video of how it looks:

 

 

Here is the code:

### Eclipse Workspace Patch 1.0
#P aCis_gameserver
Index: java/net/sf/l2j/util/DDSConverter.java
===================================================================
--- java/net/sf/l2j/util/DDSConverter.java	(revision 0)
+++ java/net/sf/l2j/util/DDSConverter.java	(working copy)
@@ -0,0 +1,348 @@
+package net.sf.l2j.util;
+
+
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.logging.Logger;
+
+import javax.imageio.ImageIO;
+
+public class DDSConverter
+{
+    public static final Logger _log = Logger.getLogger(DDSConverter.class.getName());
+
+    protected static class Color
+    {
+
+        @Override
+        public boolean equals(Object obj)
+        {
+            if (this == obj)
+            {
+                return true;
+            }
+            if ((obj == null) || (getClass() != obj.getClass()))
+            {
+                return false;
+            }
+            Color color = (Color) obj;
+            if (b != color.b)
+            {
+                return false;
+            }
+            if (g != color.g)
+            {
+                return false;
+            }
+            return r == color.r;
+        }
+
+        @Override
+        public int hashCode()
+        {
+            int i = r;
+            i = (29 * i) + g;
+            i = (29 * i) + b;
+            return i;
+        }
+
+        protected int r;
+        protected int g;
+        protected int b;
+
+        public Color()
+        {
+            r = g = b = 0;
+        }
+
+        public Color(int i, int j, int k)
+        {
+            r = i;
+            g = j;
+            b = k;
+        }
+    }
+
+    public static ByteBuffer convertToDDS(File file) throws IOException
+    {
+        if (file == null)
+        {
+            String s = "nullValue.FileIsNull";
+            _log.severe(s);
+            throw new IllegalArgumentException(s);
+        }
+        if (!file.exists() || !file.canRead())
+        {
+            String s1 = "DDSConverter.NoFileOrNoPermission";
+            _log.severe(s1);
+            throw new IllegalArgumentException(s1);
+        }
+        BufferedImage bufferedimage = ImageIO.read(file);
+        if (bufferedimage == null)
+        {
+            return null;
+        }
+        if (bufferedimage.getColorModel().hasAlpha())
+        {
+            return convertToDxt3(bufferedimage);
+        }
+        return convertToDxt1NoTransparency(bufferedimage);
+    }
+
+    public static ByteBuffer convertToDxt1NoTransparency(BufferedImage bufferedimage)
+    {
+        if (bufferedimage == null)
+        {
+            return null;
+        }
+        int ai[] = new int[16];
+        int i = 128 + ((bufferedimage.getWidth() * bufferedimage.getHeight()) / 2);
+        ByteBuffer bytebuffer = ByteBuffer.allocate(i);
+        bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
+        buildHeaderDxt1(bytebuffer, bufferedimage.getWidth(), bufferedimage.getHeight());
+        int j = bufferedimage.getWidth() / 4;
+        int k = bufferedimage.getHeight() / 4;
+        for (int l = 0; l < k; l++)
+        {
+            for (int i1 = 0; i1 < j; i1++)
+            {
+                BufferedImage bufferedimage1 = bufferedimage.getSubimage(i1 * 4, l * 4, 4, 4);
+                bufferedimage1.getRGB(0, 0, 4, 4, ai, 0, 4);
+                Color acolor[] = getColors888(ai);
+                for (int j1 = 0; j1 < ai.length; j1++)
+                {
+                    ai[j1] = getPixel565(acolor[j1]);
+                    acolor[j1] = getColor565(ai[j1]);
+                }
+
+                int ai1[] = determineExtremeColors(acolor);
+                if (ai[ai1[0]] < ai[ai1[1]])
+                {
+                    int k1 = ai1[0];
+                    ai1[0] = ai1[1];
+                    ai1[1] = k1;
+                }
+                bytebuffer.putShort((short) ai[ai1[0]]);
+                bytebuffer.putShort((short) ai[ai1[1]]);
+                long l1 = computeBitMask(acolor, ai1);
+                bytebuffer.putInt((int) l1);
+            }
+        }
+        return bytebuffer;
+    }
+
+    public static ByteBuffer convertToDxt3(BufferedImage bufferedimage)
+    {
+        if (bufferedimage == null)
+        {
+            return null;
+        }
+        if (!bufferedimage.getColorModel().hasAlpha())
+        {
+            return convertToDxt1NoTransparency(bufferedimage);
+        }
+        int ai[] = new int[16];
+        int i = 128 + (bufferedimage.getWidth() * bufferedimage.getHeight());
+        ByteBuffer bytebuffer = ByteBuffer.allocate(i);
+        bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
+        buildHeaderDxt3(bytebuffer, bufferedimage.getWidth(), bufferedimage.getHeight());
+        int j = bufferedimage.getWidth() / 4;
+        int k = bufferedimage.getHeight() / 4;
+        for (int l = 0; l < k; l++)
+        {
+            for (int i1 = 0; i1 < j; i1++)
+            {
+                BufferedImage bufferedimage1 = bufferedimage.getSubimage(i1 * 4, l * 4, 4, 4);
+                bufferedimage1.getRGB(0, 0, 4, 4, ai, 0, 4);
+                Color acolor[] = getColors888(ai);
+                for (int j1 = 0; j1 < ai.length; j1 += 2)
+                {
+                    bytebuffer.put((byte) ((ai[j1] >>> 28) | (ai[j1 + 1] >>> 24)));
+                }
+
+                for (int k1 = 0; k1 < ai.length; k1++)
+                {
+                    ai[k1] = getPixel565(acolor[k1]);
+                    acolor[k1] = getColor565(ai[k1]);
+                }
+
+                int ai1[] = determineExtremeColors(acolor);
+                if (ai[ai1[0]] < ai[ai1[1]])
+                {
+                    int l1 = ai1[0];
+                    ai1[0] = ai1[1];
+                    ai1[1] = l1;
+                }
+                bytebuffer.putShort((short) ai[ai1[0]]);
+                bytebuffer.putShort((short) ai[ai1[1]]);
+                long l2 = computeBitMask(acolor, ai1);
+                bytebuffer.putInt((int) l2);
+            }
+        }
+        return bytebuffer;
+    }
+
+    protected static void buildHeaderDxt1(ByteBuffer bytebuffer, int i, int j)
+    {
+        bytebuffer.rewind();
+        bytebuffer.put((byte) 68);
+        bytebuffer.put((byte) 68);
+        bytebuffer.put((byte) 83);
+        bytebuffer.put((byte) 32);
+        bytebuffer.putInt(124);
+        int k = 0xa1007;
+        bytebuffer.putInt(k);
+        bytebuffer.putInt(j);
+        bytebuffer.putInt(i);
+        bytebuffer.putInt((i * j) / 2);
+        bytebuffer.putInt(0);
+        bytebuffer.putInt(0);
+        bytebuffer.position(bytebuffer.position() + 44);
+        bytebuffer.putInt(32);
+        bytebuffer.putInt(4);
+        bytebuffer.put((byte) 68);
+        bytebuffer.put((byte) 88);
+        bytebuffer.put((byte) 84);
+        bytebuffer.put((byte) 49);
+        bytebuffer.putInt(0);
+        bytebuffer.putInt(0);
+        bytebuffer.putInt(0);
+        bytebuffer.putInt(0);
+        bytebuffer.putInt(0);
+        bytebuffer.putInt(4096);
+        bytebuffer.putInt(0);
+        bytebuffer.position(bytebuffer.position() + 12);
+    }
+
+    protected static void buildHeaderDxt3(ByteBuffer bytebuffer, int i, int j)
+    {
+        bytebuffer.rewind();
+        bytebuffer.put((byte) 68);
+        bytebuffer.put((byte) 68);
+        bytebuffer.put((byte) 83);
+        bytebuffer.put((byte) 32);
+        bytebuffer.putInt(124);
+        int k = 0xa1007;
+        bytebuffer.putInt(k);
+        bytebuffer.putInt(j);
+        bytebuffer.putInt(i);
+        bytebuffer.putInt(i * j);
+        bytebuffer.putInt(0);
+        bytebuffer.putInt(0);
+        bytebuffer.position(bytebuffer.position() + 44);
+        bytebuffer.putInt(32);
+        bytebuffer.putInt(4);
+        bytebuffer.put((byte) 68);
+        bytebuffer.put((byte) 88);
+        bytebuffer.put((byte) 84);
+        bytebuffer.put((byte) 51);
+        bytebuffer.putInt(0);
+        bytebuffer.putInt(0);
+        bytebuffer.putInt(0);
+        bytebuffer.putInt(0);
+        bytebuffer.putInt(0);
+        bytebuffer.putInt(4096);
+        bytebuffer.putInt(0);
+        bytebuffer.position(bytebuffer.position() + 12);
+    }
+
+    protected static int[] determineExtremeColors(Color acolor[])
+    {
+        int i = 0x80000000;
+        int ai[] = new int[2];
+        for (int j = 0; j < (acolor.length - 1); j++)
+        {
+            for (int k = j + 1; k < acolor.length; k++)
+            {
+                int l = distance(acolor[j], acolor[k]);
+                if (l > i)
+                {
+                    i = l;
+                    ai[0] = j;
+                    ai[1] = k;
+                }
+            }
+
+        }
+        return ai;
+    }
+
+    protected static long computeBitMask(Color acolor[], int ai[])
+    {
+        Color acolor1[] =
+        {
+            null,
+            null,
+            new Color(),
+            new Color()
+        };
+        acolor1[0] = acolor[ai[0]];
+        acolor1[1] = acolor[ai[1]];
+        if (acolor1[0].equals(acolor1[1]))
+        {
+            return 0L;
+        }
+        acolor1[2].r = ((2 * acolor1[0].r) + acolor1[1].r + 1) / 3;
+        acolor1[2].g = ((2 * acolor1[0].g) + acolor1[1].g + 1) / 3;
+        acolor1[2].b = ((2 * acolor1[0].b) + acolor1[1].b + 1) / 3;
+        acolor1[3].r = (acolor1[0].r + (2 * acolor1[1].r) + 1) / 3;
+        acolor1[3].g = (acolor1[0].g + (2 * acolor1[1].g) + 1) / 3;
+        acolor1[3].b = (acolor1[0].b + (2 * acolor1[1].b) + 1) / 3;
+        long l = 0L;
+        for (int i = 0; i < acolor.length; i++)
+        {
+            int j = 0x7fffffff;
+            int k = 0;
+            for (int i1 = 0; i1 < acolor1.length; i1++)
+            {
+                int j1 = distance(acolor[i], acolor1[i1]);
+                if (j1 < j)
+                {
+                    j = j1;
+                    k = i1;
+                }
+            }
+
+            l |= k << (i * 2);
+        }
+        return l;
+    }
+
+    protected static int getPixel565(Color color)
+    {
+        int i = color.r >> 3;
+        int j = color.g >> 2;
+        int k = color.b >> 3;
+        return (i << 11) | (j << 5) | k;
+    }
+
+    protected static Color getColor565(int i)
+    {
+        Color color = new Color();
+        color.r = (int) (i & 63488L) >> 11;
+        color.g = (int) (i & 2016L) >> 5;
+        color.b = (int) (i & 31L);
+        return color;
+    }
+
+    protected static Color[] getColors888(int ai[])
+    {
+        Color acolor[] = new Color[ai.length];
+        for (int i = 0; i < ai.length; i++)
+        {
+            acolor[i] = new Color();
+            acolor[i].r = (int) (ai[i] & 0xff0000L) >> 16;
+            acolor[i].g = (int) (ai[i] & 65280L) >> 8;
+            acolor[i].b = (int) (ai[i] & 255L);
+        }
+        return acolor;
+    }
+
+    protected static int distance(Color color, Color color1)
+    {
+        return ((color1.r - color.r) * (color1.r - color.r)) + ((color1.g - color.g) * (color1.g - color.g)) + ((color1.b - color.b) * (color1.b - color.b));
+    }
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2BufferArchiveInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2BufferArchiveInstance.java	(revision 0)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2BufferArchiveInstance.java	(working copy)
@@ -0,0 +1,339 @@
+ /*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package net.sf.l2j.gameserver.model.actor.instance;
+
+import java.io.File;
+import java.util.StringTokenizer;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.ai.CtrlIntention;
+import net.sf.l2j.gameserver.datatables.SkillTable;
+import net.sf.l2j.gameserver.model.L2Effect;
+import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
+import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
+import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected;
+import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
+import net.sf.l2j.gameserver.network.serverpackets.PledgeCrest;
+import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
+import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
+import net.sf.l2j.gameserver.templates.skills.L2SkillType;
+import net.sf.l2j.util.DDSConverter;
+import net.sf.l2j.util.StringUtil;
+
+/**
+ * @author Elfocrash
+ */
+public final class L2BufferArchiveInstance extends L2NpcInstance
+{
+    public L2BufferArchiveInstance(int objectId, NpcTemplate template)
+    {
+        super(objectId, template);
+    }
+
+    int state = 0;
+    @Override
+    public void onAction(L2PcInstance client)
+    {
+        if (this != client.getTarget())
+        {
+            client.setTarget(this);
+            client.sendPacket(new MyTargetSelected(getObjectId(), 0));
+            client.sendPacket(new ValidateLocation(this));
+        }
+        else
+        {
+            client.sendPacket(new MyTargetSelected(getObjectId(), 0));
+            client.getAI().setIntention(CtrlIntention.INTERACT, this);
+
+            if (!isInsideRadius(client, 150, false, false))
+                client.sendPacket(ActionFailed.STATIC_PACKET);
+            else
+                showMessageWindow(client);
+        }
+    }
+
+    @Override
+    public void onBypassFeedback(L2PcInstance client, String command)
+    {
+        if (!client.isDead())
+        {
+            StringTokenizer st = new StringTokenizer(command, " ");
+            String actualCommand = st.nextToken();
+
+            int buffid = 0;
+            int bufflevel = 1;
+            if (st.countTokens() == 2)
+            {
+                buffid = Integer.valueOf(st.nextToken());
+                bufflevel = Integer.valueOf(st.nextToken());
+            }
+            else if (st.countTokens() == 1)
+                buffid = Integer.valueOf(st.nextToken());
+
+            if (actualCommand.equalsIgnoreCase("getbuff"))
+            {
+                if (buffid != 0)
+                {
+                    MagicSkillUse mgc = new MagicSkillUse(this, client, buffid, bufflevel, 500, 0);
+                    SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, client);
+                    showMessageWindow(client);
+                    client.broadcastPacket(mgc);
+                }
+            }
+            else if (actualCommand.equalsIgnoreCase("restore"))
+            {
+                MagicSkillUse mgc = new MagicSkillUse(this, client, 1258, 4, 500, 0);
+                client.setCurrentHpMp(client.getMaxHp(), client.getMaxMp());
+                client.setCurrentCp(client.getMaxCp());
+                showMessageWindow(client);
+                client.broadcastPacket(mgc);
+            }
+            else if (actualCommand.equalsIgnoreCase("cancel"))
+            {
+                MagicSkillUse mgc = new MagicSkillUse(this, client, 1056, 12, 500, 0);
+                client.stopAllEffects();
+                showMessageWindow(client);
+                client.broadcastPacket(mgc);
+            }
+            else if (actualCommand.equalsIgnoreCase("setstate0"))
+            {
+               state = 0;
+               showMessageWindow(client);
+            }
+            else if (actualCommand.equalsIgnoreCase("setstate1"))
+            {
+               state = 1;
+               showMessageWindow(client);
+            }
+            else if (actualCommand.equalsIgnoreCase("setstate2"))
+            {
+               state = 2;
+               showMessageWindow(client);
+            }
+            else if (actualCommand.equalsIgnoreCase("setstate3"))
+            {
+               state = 3;
+               showMessageWindow(client);
+            }
+            else
+                super.onBypassFeedback(client, command);
+        }
+    }
+
+    private static int getCurrentBuffs(L2PcInstance activechar)
+    {
+        int i = 0;
+
+        for (L2Effect e : activechar.getAllEffects())
+        {
+            if (e.getSkill().getSkillType() == L2SkillType.BUFF)
+            i++;
+    }
+
+    return i;
+    }
+
+    private void showMessageWindow(L2PcInstance client)
+    {
+        NpcHtmlMessage html = new NpcHtmlMessage(1);
+        final StringBuilder sb = StringUtil.startAppend(3500, "<html><body>");
+        int imgId = 0;
+        
+        switch (getCurrentBuffs(client)) {
+        case 0:  imgId = 20010;
+                generateLogo(client, 20010);
+                 break;
+        case 1:  imgId = 20011;
+        generateLogo(client, 20011);
+                 break;
+        case 2:  imgId = 20012;
+        generateLogo(client, 20012);
+                 break;
+        case 3:  imgId = 20013;
+        generateLogo(client, 20013);
+                 break;
+        case 4:  imgId = 20014;
+        generateLogo(client, 20014);
+                 break;
+        case 5:  imgId = 20015;
+        generateLogo(client, 20015);
+                 break;
+        case 6:  imgId = 20016;
+        generateLogo(client, 20016);
+                 break;
+        case 7:  imgId = 20017;
+        generateLogo(client, 20017);
+                 break;
+        case 8:  imgId = 20018;
+        generateLogo(client, 20018);
+                 break;
+        case 9:  imgId = 20019;
+        generateLogo(client, 20019);
+                 break;
+        case 10: imgId = 20020;
+        generateLogo(client, 20020);
+                 break;
+        case 11: imgId = 20021;
+        generateLogo(client, 20021);
+                 break;
+        case 12: imgId = 20022;
+        generateLogo(client, 20022);
+                 break;
+        case 13:  imgId = 20023;
+        generateLogo(client, 20023);
+                break;
+        case 14:  imgId = 20024;
+        generateLogo(client, 20024);
+                break;
+        case 15:  imgId = 20025;
+        generateLogo(client, 20025);
+                break;
+        case 16:  imgId = 20026;
+        generateLogo(client, 20026);
+                break;
+        case 17:  imgId = 20027;
+        generateLogo(client, 20027);
+                break;
+        case 18:  imgId = 20028;
+        generateLogo(client, 20028);
+                break;
+        case 19:  imgId = 20029;
+        generateLogo(client, 20029);
+                break;
+        case 20:  imgId = 20030;
+        generateLogo(client, 20030);
+                break;
+        case 21:  imgId = 20031;
+        generateLogo(client, 20031);
+                break;
+        case 22: imgId = 20032;
+        generateLogo(client, 20032);
+                break;
+        case 23: imgId = 20033;
+        generateLogo(client, 20033);
+                break;
+        case 24: imgId = 20034;
+        generateLogo(client, 20034);
+                break;
+        default: imgId = 20034;
+        generateLogo(client, 20034);
+                 break;
+    }
+
+
+        sb.append("<center><font color=\"FF9900\">AIO Buffer Laena</font></center>");
+
+        sb.append("<table width=\"256\" cellpadding=\"5\" bgcolor=\"000000\"><tr><td><img src=\"Crest.crest_" + Config.SERVER_ID + "_" + imgId + "\" width=256 height=16></td></tr></table>");
+
+        if(state ==0)
+       {
+        sb.append("<br><center><font color=\"FF9900\">Buffs</font></center><table width=\"256\" cellpadding=\"5\">");
+        sb.append("<tr><td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1204 130\" width=32 height=32 back=\"icon.skill1204\" fore=\"icon.skill1204\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1040 130\" width=32 height=32 back=\"icon.skill1040\" fore=\"icon.skill1040\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1068 130\" width=32 height=32 back=\"icon.skill1068\" fore=\"icon.skill1068\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1036 130\" width=32 height=32 back=\"icon.skill1036\" fore=\"icon.skill1036\"></td><");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1035 130\" width=32 height=32 back=\"icon.skill1035\" fore=\"icon.skill1035\"></td></tr>");
+        sb.append("<tr><td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1045 130\" width=32 height=32 back=\"icon.skill1045\" fore=\"icon.skill1045\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1048 130\" width=32 height=32 back=\"icon.skill1048\" fore=\"icon.skill1048\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1062 130\" width=32 height=32 back=\"icon.skill1062\" fore=\"icon.skill1062\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1086 130\" width=32 height=32 back=\"icon.skill1086\" fore=\"icon.skill1086\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1240 130\" width=32 height=32 back=\"icon.skill1240\" fore=\"icon.skill1240\"></td></tr>");
+        sb.append("<tr><td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1242 130\" width=32 height=32 back=\"icon.skill1242\" fore=\"icon.skill1242\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1077 130\" width=32 height=32 back=\"icon.skill1077\" fore=\"icon.skill1077\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1268 130\" width=32 height=32 back=\"icon.skill1268\" fore=\"icon.skill1268\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1087 130\" width=32 height=32 back=\"icon.skill1087\" fore=\"icon.skill1087\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1085 130\" width=32 height=32 back=\"icon.skill1085\" fore=\"icon.skill1085\"></td></tr>");
+        sb.append("<tr><td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1059 130\" width=32 height=32 back=\"icon.skill1059\" fore=\"icon.skill1059\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1303 130\" width=32 height=32 back=\"icon.skill1303\" fore=\"icon.skill1303\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1078 130\" width=32 height=32 back=\"icon.skill1078\" fore=\"icon.skill1078\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1243 130\" width=32 height=32 back=\"icon.skill1243\" fore=\"icon.skill1243\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1259 130\" width=32 height=32 back=\"icon.skill1259\" fore=\"icon.skill1259\"></td></tr>"
+                + "<tr><td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1304 130\" width=32 height=32 back=\"icon.skill1304\" fore=\"icon.skill1304\"></td></tr></table>");
+       }
+       else
+           sb.append("<br><center><a action=\"bypass npc_%objectId%_setstate0\">Buffs [+]</a></center>");
+
+
+       if(state == 1)
+       {
+        sb.append("<center><font color=\"FF9900\">Dances</font></center><table width=\"200\" cellpadding=\"5\">");
+        sb.append("<tr><td><button action=\"bypass npc_" + getObjectId() + "_getbuff 271 130\" width=32 height=32 back=\"icon.skill0271\" fore=\"icon.skill0271\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 274 130\" width=32 height=32 back=\"icon.skill0274\" fore=\"icon.skill0274\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 275 130\" width=32 height=32 back=\"icon.skill0275\" fore=\"icon.skill0275\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 272 130\" width=32 height=32 back=\"icon.skill0272\" fore=\"icon.skill0272\"></td></tr>");
+        sb.append("<tr><td><button action=\"bypass npc_" + getObjectId() + "_getbuff 310 130\" width=32 height=32 back=\"icon.skill0310\" fore=\"icon.skill0310\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 273 130\" width=32 height=32 back=\"icon.skill0273\" fore=\"icon.skill0273\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 276 130\" width=32 height=32 back=\"icon.skill0276\" fore=\"icon.skill0276\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 277 130\" width=32 height=32 back=\"icon.skill0277\" fore=\"icon.skill0277\"></td></tr></table>");
+       }
+       else
+           sb.append("<br><center><a action=\"bypass npc_%objectId%_setstate1\">Dances [+]</a></center>");
+
+       if(state == 2)
+       {
+        sb.append("<center><font color=\"FF9900\">Songs</font></center><table width=\"200\" cellpadding=\"5\">");
+        sb.append("<tr><td><button action=\"bypass npc_" + getObjectId() + "_getbuff 264 130\" width=32 height=32 back=\"icon.skill0264\" fore=\"icon.skill0264\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 304 130\" width=32 height=32 back=\"icon.skill0304\" fore=\"icon.skill0304\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 268 130\" width=32 height=32 back=\"icon.skill0268\" fore=\"icon.skill0268\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 267 130\" width=32 height=32 back=\"icon.skill0267\" fore=\"icon.skill0267\"></td></tr>");
+        sb.append("<tr><td><button action=\"bypass npc_" + getObjectId() + "_getbuff 266 130\" width=32 height=32 back=\"icon.skill0266\" fore=\"icon.skill0266\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 269 130\" width=32 height=32 back=\"icon.skill0269\" fore=\"icon.skill0269\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 265 130\" width=32 height=32 back=\"icon.skill0265\" fore=\"icon.skill0265\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 270 130\" width=32 height=32 back=\"icon.skill0270\" fore=\"icon.skill0270\"></td></tr></table>");
+       }
+       else
+           sb.append("<br><center><a action=\"bypass npc_%objectId%_setstate2\">Song [+]</a></center>");
+
+       if(state == 3)
+       {
+        sb.append("<center><font color=\"FF9900\">Restore/Cancel</font></center><table width=\"100\" cellpadding=\"5\">");
+        sb.append("<tr><td><button action=\"bypass npc_" + getObjectId() + "_restore\" width=32 height=32 back=\"icon.skill0058\" fore=\"icon.skill0058\"></td>");
+        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_cancel\" width=32 height=32 back=\"icon.skill1056\" fore=\"icon.skill1056\"></td></tr>");
+       }
+       else
+           sb.append("<br><center><a action=\"bypass npc_%objectId%_setstate3\">Restore/Cancel [+]</a></center>");
+
+       // sb.append("</table>");
+
+
+        sb.append("</body></html>");
+
+        html.setHtml(sb.toString());
+        html.replace("%objectId%", String.valueOf(getObjectId()));
+        html.replace("%charname%", client.getName());
+        client.sendPacket(html);
+    }
+
+    public static void generateLogo(L2PcInstance activeChar, int imgId)
+    {
+            try
+            {
+                
+                	 File captcha = new File("data/images/"+imgId+".png");
+                     PledgeCrest packet = new PledgeCrest(imgId, DDSConverter.convertToDDS(captcha).array());
+                     activeChar.sendPacket(packet);
+        
+            }
+            catch (Exception e)
+            {
+            }
+
+    }
+  
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/network/serverpackets/PledgeCrest.java
===================================================================
--- java/net/sf/l2j/gameserver/network/serverpackets/PledgeCrest.java	(revision 65)
+++ java/net/sf/l2j/gameserver/network/serverpackets/PledgeCrest.java	(working copy)
@@ -3,42 +3,36 @@
  * the terms of the GNU General Public License as published by the Free Software
  * Foundation, either version 3 of the License, or (at your option) any later
  * version.
- * 
+ *
  * This program is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  * details.
- * 
+ *
  * You should have received a copy of the GNU General Public License along with
  * this program. If not, see <http://www.gnu.org/licenses/>.
  */
 package net.sf.l2j.gameserver.network.serverpackets;
 
-import net.sf.l2j.gameserver.cache.CrestCache;
-import net.sf.l2j.gameserver.cache.CrestCache.CrestType;
-
 public class PledgeCrest extends L2GameServerPacket
 {
-	private final int _crestId;
-	private final byte[] _data;
-	
-	public PledgeCrest(int crestId)
-	{
-		_crestId = crestId;
-		_data = CrestCache.getCrest(CrestType.PLEDGE, _crestId);
-	}
-	
-	@Override
-	protected final void writeImpl()
-	{
-		writeC(0x6c);
-		writeD(_crestId);
-		if (_data != null)
-		{
-			writeD(_data.length);
-			writeB(_data);
-		}
-		else
-			writeD(0);
-	}
+    private final int _crestId;
+    private final byte[] _data;
+    private final int _crestSize;
+
+     public PledgeCrest(int crestId, byte[] data)
+    {
+        _crestId = crestId;
+        _data = data;
+        _crestSize = _data.length;
+    }
+
+    @Override
+    protected final void writeImpl()
+    {
+        writeC(0x6c);
+        writeD(_crestId);
+        writeD(_crestSize);
+        writeB(_data);
+    }
 }
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestPledgeCrest.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/RequestPledgeCrest.java	(revision 65)
+++ java/net/sf/l2j/gameserver/network/clientpackets/RequestPledgeCrest.java	(working copy)
@@ -3,38 +3,66 @@
  * the terms of the GNU General Public License as published by the Free Software
  * Foundation, either version 3 of the License, or (at your option) any later
  * version.
- * 
+ *
  * This program is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  * details.
- * 
+ *
  * You should have received a copy of the GNU General Public License along with
  * this program. If not, see <http://www.gnu.org/licenses/>.
  */
 package net.sf.l2j.gameserver.network.clientpackets;
 
+import java.util.logging.Logger;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.cache.CrestCache;
+import net.sf.l2j.gameserver.cache.CrestCache.CrestType;
 import net.sf.l2j.gameserver.network.serverpackets.PledgeCrest;
 
 public final class RequestPledgeCrest extends L2GameClientPacket
 {
-	private int _crestId;
-	
-	@Override
-	protected void readImpl()
-	{
-		_crestId = readD();
-	}
-	
-	@Override
-	protected void runImpl()
-	{
-		sendPacket(new PledgeCrest(_crestId));
-	}
-	
-	@Override
-	protected boolean triggersOnActionRequest()
-	{
-		return false;
-	}
+    private static Logger _log = Logger.getLogger(RequestPledgeCrest.class.getName());
+    private int _crestId;
+
+    @Override
+    protected void readImpl()
+    {
+        _crestId = readD();
+    }
+
+    @Override
+    protected void runImpl()
+    {
+        if (_crestId == 0)
+            {
+                    return;
+            }
+            if (Config.DEBUG)
+            {
+                    _log.fine("crestid " + _crestId + " requested");
+            }
+
+            byte[] data = CrestCache.getCrest(CrestType.PLEDGE, _crestId);
+
+            if (data != null)
+            {
+                    PledgeCrest pc = new PledgeCrest(_crestId, data);
+                    sendPacket(pc);
+            }
+            else
+            {
+                    if (Config.DEBUG)
+                    {
+                            _log.fine("crest is missing:" + _crestId);
+                    }
+            }
+    }
+
+    @Override
+    protected boolean triggersOnActionRequest()
+    {
+        return false;
+    }
 }
\ No newline at end of file

Images can be found attached

 

 

Have fun.

images.zip

Posted (edited)

The only thing i cannot understand i how you made the window not disappear after a bypass.. Oh and why there are crest packets in the code :D

Edited by An4rchy
Guest Elfocrash
Posted

The only thing i cannot understand i how you made the window not disappear after a bypass.. Oh and why there are crest packets in the code :D

where do you think the bar comes from?
Posted

The only thing i cannot understand i how you made the window not disappear after a bypass.. Oh and why there are crest packets in the code :D

for the images from bar :O

Guest Elfocrash
Posted

efficient is not the word id use. easier to read yeah

Posted

efficient is not the word id use. easier to read yeah

 

with html u load the img from the client, on the other hand, the icon packet sends the raw icon data from the server. So its not efficient

Guest Elfocrash
Posted

with html u load the img from the client, on the other hand, the icon packet sends the raw icon data from the server. So its not efficient

It is html. I don't get your point. 

I guess you mean it is not an icom straigh from the client. But you are wrong.

The way this works is this:

The image gets generated and SAVED in the player's client. After the first intialization the image is getting picked by the client itself via te Crest.utx file.

Do some research and you will understand what i mean. It is only the first time where you need to load the image.

After that it is exactly like it is in the client but you don't have to physically send the image to the other guy's systextures folder.

Posted

It is html. I don't get your point. 

I guess you mean it is not an icom straigh from the client. But you are wrong.

The way this works is this:

The image gets generated and SAVED in the player's client. After the first intialization the image is getting picked by the client itself via te Crest.utx file.

Do some research and you will understand what i mean. It is only the first time where you need to load the image.

After that it is exactly like it is in the client but you don't have to physically send the image to the other guy's systextures folder.

 

 

I know how it works I know its saved since first request and then it uses it from the client, no reason for all these since it can be done with html... Its not bad, its unefficient since a better and cleaner method exists

Guest Elfocrash
Posted

I know how it works I know its saved since first request and then it uses it from the client, no reason for all these since it can be done with html... Its not bad, its unefficient since a better and cleaner method exists

But it is html. I still don't get your point. It is exactly the same as if it was in a .htm file.

Posted

But it is html. I still don't get your point. It is exactly the same as if it was in a .htm file.

 

But the client has to download it first 

 

and server side... +import net.sf.l2j.util.DDSConverter;

 

 

I think you get my point now

Guest Elfocrash
Posted

But the client has to download it first 

 

and server side... +import net.sf.l2j.util.DDSConverter;

 

 

I think you get my point now

Yeah which is EXACLY the same process if you get a player to download it from your site.

 

I think you get my point now

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



  • Posts

    • Added the protection module to the demo.   DDoS Guard Pro v2.0 is a system protection module for PlayMMO CMS designed to reduce the load on the website during HTTP floods, bot activity, suspicious frequent requests, and attacks on individual pages or API methods. Unlike simple global limiters, DDoS Guard Pro v2.0 supports flexible rules based on routes and HTTP methods. This allows you to block the entire site in a targeted manner, rather than blocking the entire site equally. You can set up protection for specific areas of the site, such as login, registration, APIs, administration, forms, and other sensitive areas. What is the purpose of the module? DDoS Guard Pro v2.0 helps protect your site from basic L7 attacks at the HTTP request level. The module is useful when your site receives: frequent requests from a single IP address; HTTP page floods; login or registration form flooding; automatic requests from bots; URL scanning; frequent API requests; suspicious activity spikes; load on individual CMS methods or pages. The module helps to reduce the load on PHP and CMS by limiting suspicious activity before it starts to create a serious load on the site. Main features Per-route and per-method Rate Limit In the new version, protection is configured not only globally, but also according to specific rules. You can set limits separately for: GET; POST; PUT; PATCH; DELETE; ALL. This allows you to flexibly protect different parts of your website. For example: for the login page, you can set a strict limit; for registration, you can set a separate limit; for the API, you can set a limit for reading and a limit for changing data; for regular website pages, you can set a soft limit or not set a limit at all. This approach reduces the risk of accidentally blocking regular users and makes the protection more accurate. Flexible rule system The module supports setting rules in the following format: METHODS|PATTERN|LIMIT|WINDOW|BURST_LIMIT|BURST_WINDOW|BLOCK_SECONDS|IDENTITY|NAME Example of rules: POST|*login*|10|60|5|10|600|ip|login_post POST|*register*|8|60|4|10|600|ip|register_post GET|*api*|300|60|80|10|120|ip|api_get PUT,PATCH,DELETE|*api*|80|60|20|10|300|ip|api_write This allows you to specify exactly: which HTTP methods to protect; which URLs or URL patterns to consider; how many requests are allowed; over what time period; what burst limit to use;  how many seconds to block the offender;  by which ID to count the limit;  what the rule is called. Burst protection against sharp spikes  In addition to the regular request limit, the module monitors sharp spikes of activity.  This is useful when a bot makes many requests in a few seconds. In this case, the protection can be activated faster, without waiting for the overall limit per minute.  Burst protection is especially useful for: authorization pages; registration; API; search; data submission forms; administrative sections. Support for different types of requests DDoS Guard Pro v2.0 works not only with POST requests. The module can control: GET — regular pages, API requests, search; POST — forms, login, registration, data submission; PUT — updating data via API; PATCH — partial data update; DELETE — data deletion; ALL — all methods at once. This makes the module suitable not only for regular sites, but also for CMS with API, personal accounts, game panels and administrative actions. Limit storage: Redis, APCu and file fallback In the new version, the module supports several options for storing temporary data. Available modes: Redis; APCu; file fallback. The auto mode tries to use the most suitable option: Redis; APCu; file storage as a fallback. Redis or APCu are suitable for more efficient operation, while the file storage is left as a fallback option for simple hosting environments that do not have additional extensions. JSONL logging The module records protection events in JSON Lines format. Logs are saved in the following file: storage/logs/ddos_guard.jsonl This format is more convenient than a regular text log, because each event is stored as a separate JSON record. The logs can record the following information: event time; IP address; HTTP method; URL; name of the triggered rule; reason for blocking; number of requests; action status; user-agent; protection mode. The JSONL format is convenient for analysis by external tools, log agents, and monitoring systems. Prometheus metrics DDoS Guard Pro v2.0 adds an endpoint for receiving metrics in Prometheus format. Endpoint: /?ddos_guard_metrics=TOKEN The token is set in the module settings. Metrics allow you to track: the number of processed requests; the number of rule activations; the number of blocks; activity by limits; protection events; module status. This allows you to connect monitoring and configure alerts so that the administrator can see when suspicious activity starts on the site. LOG ONLY mode The module has a LOG ONLY mode. In this mode, DDoS Guard Pro does not block users, but only records events and potential triggers in the log. This mode is recommended to be used after installation, in order to first see which rules are triggered, and only then to enable the real blocking.  This helps to avoid too strict limits and random blocking of regular users.  Support for Cloudflare and proxy  The module supports working behind Cloudflare or another reverse proxy.  With proper configuration, it is possible to take into account the real IP of the user, and not the IP of the proxy server.  This is important for sites that use:  Cloudflare; nginx reverse proxy; load balancers; CDN; hosting proxy protection. Nginx-recommendations DDoS Guard Pro v2.0 contains an example nginx-config: modules/ddos_guard/nginx-ddos-guard-example.conf This allows you to use the module as an additional application layer of protection, and to move the main coarse limits to the nginx level. Recommended protection scheme: Cloudflare / nginx / firewall → DDoS Guard Pro → PlayMMO CMS This approach is more correct than trying to solve all problems only at the PHP level.
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..