Jump to content
  • 0

An4Rchy's .dressme For L2Jfrozen


Question

Posted (edited)

So i saw this code posted from An4rchy and because i had some free time i decided to try the adaptation of the code to l2jfrozen since it was posted for acis.
 I'm terrible in this so i got stuck somewhere as expected.
 
Original Code :

 

package net.sf.l2j.gameserver.handler.bypasshandlers;

import java.util.StringTokenizer;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.custom.DressMeData;
import net.sf.l2j.gameserver.datatables.ItemTable;
import net.sf.l2j.gameserver.handler.IBypassHandler;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.DressMe;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.itemcontainer.Inventory;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;

/**
* @author Anarchy
*
*/
public class DressMeBypasses implements IBypassHandler
{
private static final String[] BYPASSES = { "bp_changedressmestatus", "bp_editWindow", "bp_setpart", "bp_gettarget", "bp_main" };

@Override
public boolean handleBypass(String bypass, L2PcInstance activeChar)
{
if (bypass.equals("bp_changedressmestatus"))
{
if (activeChar.isDressMeEnabled())
{
activeChar.setDressMeEnabled(false);
activeChar.broadcastUserInfo();
}
else
{
activeChar.setDressMeEnabled(true);
activeChar.broadcastUserInfo();
}

DressMe.sendMainWindow(activeChar);
}

if (bypass.startsWith("bp_editWindow"))
{
String bp = bypass.substring(14);
StringTokenizer st = new StringTokenizer(bp);

sendEditWindow(activeChar, st.nextToken());
}

if (bypass.startsWith("bp_setpart"))
{
String bp = bypass.substring(11);
StringTokenizer st = new StringTokenizer(bp);

String part = st.nextToken();
String type = st.nextToken();

setPart(activeChar, part, type);
}

if (bypass.startsWith("bp_gettarget"))
{
String bp = bypass.substring(13);
StringTokenizer st = new StringTokenizer(bp);

String part = st.nextToken();

stealTarget(activeChar, part);
}

if (bypass.equals("bp_main"))
{
DressMe.sendMainWindow(activeChar);
}

return true;
}

public void stealTarget(L2PcInstance p, String part)
{
if (p.getTarget() == null || !(p.getTarget() instanceof L2PcInstance))
{
p.sendMessage("Invalid target.");
return;
}

L2PcInstance t = (L2PcInstance)p.getTarget();

if (p.getDressMeData() == null)
{
DressMeData dmd = new DressMeData();
p.setDressMeData(dmd);
}

boolean returnMain = false;

switch (part)
{
case "chest":
{
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST) == null)
{
p.getDressMeData().setChestId(0);
}
else
{
p.getDressMeData().setChestId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItemId());
}
break;
}
case "legs":
{
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS) == null)
{
p.getDressMeData().setLegsId(0);
}
else
{
p.getDressMeData().setLegsId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS).getItemId());
}
break;
}
case "gloves":
{
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES) == null)
{
p.getDressMeData().setGlovesId(0);
}
else
{
p.getDressMeData().setGlovesId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES).getItemId());
}
break;
}
case "boots":
{
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET) == null)
{
p.getDressMeData().setBootsId(0);
}
else
{
p.getDressMeData().setBootsId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET).getItemId());
}
break;
}
case "weap":
{
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND) == null)
{
p.getDressMeData().setWeapId(0);
}
else
{
p.getDressMeData().setWeapId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).getItemId());
}
break;
}
case "all":
{
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST) == null)
{
p.getDressMeData().setChestId(0);
}
else
{
p.getDressMeData().setChestId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItemId());
}
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS) == null)
{
p.getDressMeData().setLegsId(0);
}
else
{
p.getDressMeData().setLegsId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS).getItemId());
}
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES) == null)
{
p.getDressMeData().setGlovesId(0);
}
else
{
p.getDressMeData().setGlovesId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES).getItemId());
}
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET) == null)
{
p.getDressMeData().setBootsId(0);
}
else
{
p.getDressMeData().setBootsId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET).getItemId());
}
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND) == null)
{
p.getDressMeData().setWeapId(0);
}
else
{
p.getDressMeData().setWeapId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).getItemId());
}
returnMain = true;
break;
}
}

p.broadcastUserInfo();
if (!returnMain)
sendEditWindow(p, part);
else
DressMe.sendMainWindow(p);
}

public void setPart(L2PcInstance p, String part, String type)
{
if (p.getDressMeData() == null)
{
DressMeData dmd = new DressMeData();
p.setDressMeData(dmd);
}

switch (part)
{
case "chest":
{
if (Config.DRESS_ME_CHESTS.keySet().contains(type))
{
p.getDressMeData().setChestId(Config.DRESS_ME_CHESTS.get(type));
}

break;
}
case "legs":
{
if (Config.DRESS_ME_LEGS.keySet().contains(type))
{
p.getDressMeData().setLegsId(Config.DRESS_ME_LEGS.get(type));
}

break;
}
case "gloves":
{
if (Config.DRESS_ME_GLOVES.keySet().contains(type))
{
p.getDressMeData().setGlovesId(Config.DRESS_ME_GLOVES.get(type));
}

break;
}
case "boots":
{
if (Config.DRESS_ME_BOOTS.keySet().contains(type))
{
p.getDressMeData().setBootsId(Config.DRESS_ME_BOOTS.get(type));
}

break;
}
case "weap":
{
if (Config.DRESS_ME_WEAPONS.keySet().contains(type))
{
p.getDressMeData().setWeapId(Config.DRESS_ME_WEAPONS.get(type));
}

break;
}
}

p.broadcastUserInfo();
sendEditWindow(p, part);
}

public void sendEditWindow(L2PcInstance p, String part)
{
NpcHtmlMessage htm = new NpcHtmlMessage(0);
htm.setFile("./data/html/custom/dressme/edit.htm");
htm.replace("%part%", part);
switch (part)
{
case "chest":
{
if (p.getDressMeData() == null)
{
htm.replace("%partinfo%", "You have no custom chest.");
}
else
{
htm.replace("%partinfo%", p.getDressMeData().getChestId() == 0 ? "You have no custom chest." : ItemTable.getInstance().getTemplate(p.getDressMeData().getChestId()).getName());
}
String temp = "";
for (String s : Config.DRESS_ME_CHESTS.keySet())
{
temp += s+";";
}
htm.replace("%dropboxdata%", temp);
break;
}
case "legs":
{
if (p.getDressMeData() == null)
{
htm.replace("%partinfo%", "You have no custom legs.");
}
else
{
htm.replace("%partinfo%", p.getDressMeData().getLegsId() == 0 ? "You have no custom legs." : ItemTable.getInstance().getTemplate(p.getDressMeData().getLegsId()).getName());
}
String temp = "";
for (String s : Config.DRESS_ME_LEGS.keySet())
{
temp += s+";";
}
htm.replace("%dropboxdata%", temp);
break;
}
case "gloves":
{
if (p.getDressMeData() == null)
{
htm.replace("%partinfo%", "You have no custom gloves.");
}
else
{
htm.replace("%partinfo%", p.getDressMeData().getGlovesId() == 0 ? "You have no custom gloves." : ItemTable.getInstance().getTemplate(p.getDressMeData().getGlovesId()).getName());
}
String temp = "";
for (String s : Config.DRESS_ME_GLOVES.keySet())
{
temp += s+";";
}
htm.replace("%dropboxdata%", temp);
break;
}
case "boots":
{
if (p.getDressMeData() == null)
{
htm.replace("%partinfo%", "You have no custom boots.");
}
else
{
htm.replace("%partinfo%", p.getDressMeData().getBootsId() == 0 ? "You have no custom boots." : ItemTable.getInstance().getTemplate(p.getDressMeData().getBootsId()).getName());
}
String temp = "";
for (String s : Config.DRESS_ME_BOOTS.keySet())
{
temp += s+";";
}
htm.replace("%dropboxdata%", temp);
break;
}
case "weap":
{
if (p.getDressMeData() == null)
{
htm.replace("%partinfo%", "You have no custom weapon.");
}
else
{
htm.replace("%partinfo%", p.getDressMeData().getWeapId() == 0 ? "You have no custom weapon." : ItemTable.getInstance().getTemplate(p.getDressMeData().getWeapId()).getName());
}
String temp = "";
for (String s : Config.DRESS_ME_WEAPONS.keySet())
{
temp += s+";";
}
htm.replace("%dropboxdata%", temp);
break;
}
}

p.sendPacket(htm);
}

@Override
public String[] getBypassHandlersList()
{
return BYPASSES;
}
}

 

 

 

Since i use l2jfrozen and there is not a file named bypasshandlers.java i decided to add the code in : package com.l2jfrozen.gameserver.network.clientpackets; --> RequestBypassToServer (Don't know if it's the right thing to do)

 

This is what i added there :

private static final String[] RequestBypassToServer = { "bp_changedressmestatus", "bp_editWindow", "bp_setpart", "bp_gettarget", "bp_main" };

@Override
public boolean handleBypass(String bypass, L2PcInstance activeChar)
{
if (bypass.equals("bp_changedressmestatus"))
{
if (activeChar.isDressMeEnabled())
{
activeChar.setDressMeEnabled(false);
activeChar.broadcastUserInfo();
}
else
{
activeChar.setDressMeEnabled(true);
activeChar.broadcastUserInfo();
}

DressMe.sendMainWindow(activeChar);
}

if (bypass.startsWith("bp_editWindow"))
{
String bp = bypass.substring(14);
StringTokenizer st = new StringTokenizer(bp);

sendEditWindow(activeChar, st.nextToken());
}

if (bypass.startsWith("bp_setpart"))
{
String bp = bypass.substring(11);
StringTokenizer st = new StringTokenizer(bp);

String part = st.nextToken();
String type = st.nextToken();

setPart(activeChar, part, type);
}

if (bypass.startsWith("bp_gettarget"))
{
String bp = bypass.substring(13);
StringTokenizer st = new StringTokenizer(bp);

String part = st.nextToken();

stealTarget(activeChar, part);
}

if (bypass.equals("bp_main"))
{
DressMe.sendMainWindow(activeChar);
}

return true;
}

public void stealTarget(L2PcInstance p, String part)
{
if (p.getTarget() == null || !(p.getTarget() instanceof L2PcInstance))
{
p.sendMessage("Invalid target.");
return;
}

L2PcInstance t = (L2PcInstance)p.getTarget();

if (p.getDressMeData() == null)
{
DressMeData dmd = new DressMeData();
p.setDressMeData(dmd);
}

boolean returnMain = false;

switch (part)
{
case "chest":
{
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST) == null)
{
p.getDressMeData().setChestId(0);
}
else
{
p.getDressMeData().setChestId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItemId());
}
break;
}
case "legs":
{
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS) == null)
{
p.getDressMeData().setLegsId(0);
}
else
{
p.getDressMeData().setLegsId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS).getItemId());
}
break;
}
case "gloves":
{
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES) == null)
{
p.getDressMeData().setGlovesId(0);
}
else
{
p.getDressMeData().setGlovesId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES).getItemId());
}
break;
}
case "boots":
{
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET) == null)
{
p.getDressMeData().setBootsId(0);
}
else
{
p.getDressMeData().setBootsId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET).getItemId());
}
break;
}
case "weap":
{
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND) == null)
{
p.getDressMeData().setWeapId(0);
}
else
{
p.getDressMeData().setWeapId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).getItemId());
}
break;
}
case "all":
{
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST) == null)
{
p.getDressMeData().setChestId(0);
}
else
{
p.getDressMeData().setChestId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItemId());
}
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS) == null)
{
p.getDressMeData().setLegsId(0);
}
else
{
p.getDressMeData().setLegsId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS).getItemId());
}
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES) == null)
{
p.getDressMeData().setGlovesId(0);
}
else
{
p.getDressMeData().setGlovesId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES).getItemId());
}
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET) == null)
{
p.getDressMeData().setBootsId(0);
}
else
{
p.getDressMeData().setBootsId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET).getItemId());
}
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND) == null)
{
p.getDressMeData().setWeapId(0);
}
else
{
p.getDressMeData().setWeapId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).getItemId());
}
returnMain = true;
break;
}
}

p.broadcastUserInfo();
if (!returnMain)
sendEditWindow(p, part);
else
DressMe.sendMainWindow(p);
}

public void setPart(L2PcInstance p, String part, String type)
{
if (p.getDressMeData() == null)
{
DressMeData dmd = new DressMeData();
p.setDressMeData(dmd);
}

switch (part)
{
case "chest":
{
if (Config.DRESS_ME_CHESTS.keySet().contains(type))
{
p.getDressMeData().setChestId(Config.DRESS_ME_CHESTS.get(type));
}

break;
}
case "legs":
{
if (Config.DRESS_ME_LEGS.keySet().contains(type))
{
p.getDressMeData().setLegsId(Config.DRESS_ME_LEGS.get(type));
}

break;
}
case "gloves":
{
if (Config.DRESS_ME_GLOVES.keySet().contains(type))
{
p.getDressMeData().setGlovesId(Config.DRESS_ME_GLOVES.get(type));
}

break;
}
case "boots":
{
if (Config.DRESS_ME_BOOTS.keySet().contains(type))
{
p.getDressMeData().setBootsId(Config.DRESS_ME_BOOTS.get(type));
}

break;
}
case "weap":
{
if (Config.DRESS_ME_WEAPONS.keySet().contains(type))
{
p.getDressMeData().setWeapId(Config.DRESS_ME_WEAPONS.get(type));
}

break;
}
}

p.broadcastUserInfo();
sendEditWindow(p, part);
}

public void sendEditWindow(L2PcInstance p, String part)
{
NpcHtmlMessage htm = new NpcHtmlMessage(0);
htm.setFile("./data/html/custom/dressme/edit.htm");
htm.replace("%part%", part);
switch (part)
{
case "chest":
{
if (p.getDressMeData() == null)
{
htm.replace("%partinfo%", "You have no custom chest.");
}
else
{
htm.replace("%partinfo%", p.getDressMeData().getChestId() == 0 ? "You have no custom chest." : ItemTable.getInstance().getTemplate(p.getDressMeData().getChestId()).getName());
}
String temp = "";
for (Integer s : Config.DRESS_ME_CHESTS.keySet())
{
temp += s+";";
}
htm.replace("%dropboxdata%", temp);
break;
}
case "legs":
{
if (p.getDressMeData() == null)
{
htm.replace("%partinfo%", "You have no custom legs.");
}
else
{
htm.replace("%partinfo%", p.getDressMeData().getLegsId() == 0 ? "You have no custom legs." : ItemTable.getInstance().getTemplate(p.getDressMeData().getLegsId()).getName());
}
String temp = "";
for (Integer s : Config.DRESS_ME_LEGS.keySet())
{
temp += s+";";
}
htm.replace("%dropboxdata%", temp);
break;
}
case "gloves":
{
if (p.getDressMeData() == null)
{
htm.replace("%partinfo%", "You have no custom gloves.");
}
else
{
htm.replace("%partinfo%", p.getDressMeData().getGlovesId() == 0 ? "You have no custom gloves." : ItemTable.getInstance().getTemplate(p.getDressMeData().getGlovesId()).getName());
}
String temp = "";
for (Integer s : Config.DRESS_ME_GLOVES.keySet())
{
temp += s+";";
}
htm.replace("%dropboxdata%", temp);
break;
}
case "boots":
{
if (p.getDressMeData() == null)
{
htm.replace("%partinfo%", "You have no custom boots.");
}
else
{
htm.replace("%partinfo%", p.getDressMeData().getBootsId() == 0 ? "You have no custom boots." : ItemTable.getInstance().getTemplate(p.getDressMeData().getBootsId()).getName());
}
String temp = "";
for (Integer s : Config.DRESS_ME_BOOTS.keySet())
{
temp += s+";";
}
htm.replace("%dropboxdata%", temp);
break;
}
case "weap":
{
if (p.getDressMeData() == null)
{
htm.replace("%partinfo%", "You have no custom weapon.");
}
else
{
htm.replace("%partinfo%", p.getDressMeData().getWeapId() == 0 ? "You have no custom weapon." : ItemTable.getInstance().getTemplate(p.getDressMeData().getWeapId()).getName());
}
String temp = "";
for (Integer s : Config.DRESS_ME_WEAPONS.keySet())
{
temp += s+";";
}
htm.replace("%dropboxdata%", temp);
break;
}
}

 

 

Errors/Warnings: 

 

Description Resource Path Location Type
The method handleBypass(String, L2PcInstance) of type RequestBypassToServer must override or implement a supertype method RequestBypassToServer.java /L2jFrozen_GameServer/head-src/com/l2jfrozen/gameserver/network/clientpackets line 428 Java Problem

Description Resource Path Location Type
Cannot switch on a value of type String for source level below 1.7. Only convertible int values or enum variables are permitted RequestBypassToServer.java /L2jFrozen_GameServer/head-src/com/l2jfrozen/gameserver/network/clientpackets line 501 Java Problem

Description Resource Path Location Type
The value of the field RequestBypassToServer.BYPASSES is not used RequestBypassToServer.java /L2jFrozen_GameServer/head-src/com/l2jfrozen/gameserver/network/clientpackets line 425 Java Problem

 

 

I post my problem here not cause i want someone to give me a ready fix and that's it , i made this post in order to learn something out of it
P.S i hope i don't burn your eyes too much with the crap i did to the code

Edited by MiReEn

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • ⭐⭐⭐⭐⭐L2Lusty 50x [Essence - High Five] Start 08 February⭐⭐⭐⭐⭐  L2Lusty Essence - High Five 50x Website: https://l2lusty.online/ Starts on 08/02/2025 16:00 London Time Rates: XP 50X, Adena 20X, Spoil 20X, Drop 20X, Max enchant +16 with 50% normal and 60% blessed, Chaos Event whit 3x Lcoins Drop 24h Website:  https://l2lusty.online/
    • Hi, I inviting you to join L2Einhovant server, lets give them chanse. It's x1 Classic with some bonus futures, no duals box, no wipes, buffs stores and etc. Grow up by litle steps together with the server population.   🔥 Why L2Einhovant? ✅ Authentic Classic Gameplay – No dual box, all classes inportant, no auto farm. ✅ Hardcore x1 Rates – A true test of your gameplay skill, level up stages. ✅ Active Community & Fair Administration – A server built for passionate players. ✅ Long-Term Stability – Grow your character in a world that lasts.   Gather your allies, sharpen your weapons, and prepare for an unforgettable journey. Join to our comunity now and prepare for start.   Open beta: 1th February. Grand opening: 7th February, 20:00 UTC+2.   🔗 Discord: https://discord.gg/zfKd4tU9N2
    • ElmoreLab Harbor - Eternal C1 x1: ✅ https://harbor.elmorelab.com ElmoreLab Harbor - Eternal C1 x1 - is an exclusive server of the Eternal C1 chronicles from the top project ElmoreLab Harbor.   A unique server of its kind, on which everyone will have maximum pleasure, such as oldschool players who dream of nostalgia and to feel the warmest and classic C1 chronicles, as well as experienced players who are tired of thousands unbalanced servers of late chronicles. Due to the professional corrections of the balance system and the HONEST gameplay system - on this server, EVERY player will feel like in their own, warm and cozy Harbor C1. Let's return to the origins of L2 - back to 2004 in C1! ❤️   ⭐ Server characteristics:   STRICTLY 1 window, NO BOXES Bans for RMT and bots/cheats No donations with benefits Unique and high-quality PTS-build from Master Toma Professional corrections and full class-balance Reworked economy and closed all abuses Improved animations and all aspects of the game Exclusive HD-client with high-quality textures Experienced administration and management Fixed all bugs, geodata, exploits and holes Maximum sociality due to the 1-box system Discovering, exploring and researching Big online International server Nostalgia and oldschool-feelings   Rates: x1 Server start: 14.02.2025   The server is at the final stages of development and preparation for release. Information on the server will be updated, soon the patchnotes and changes/edits will be posted. Don't miss the legendary and epic experience on the best server in the last 20 years! ❤️ Join our C1-forum with a lot of information about server and active discussions.   ⭐ Website: https://harbor.elmorelab.com   ✅ Forum: https://forum-harbor.elmorelab.com   💥 Telegram: https://t.me/l2harbor https://t.me/l2harbor_chat   ⚡ Discord: https://discord.gg/harborelmorelab
    • yeah ok, if you say what is fuctional 100% i can't say something different 😛  but if someone find hard to compile it or get vs and all that things i have here one more simple way here to put overlay in your own server or to change your window name with few money.
  • Topics

×
×
  • Create New...