Jump to content
  • 0

Another Error.


sotid

Question

My error:

 C:\Users\User\workspace - pvp - Copy\Stable_1004\gameserver\head-src\com\l2jfrozen\gameserver\model\actor\instance\L2DonateShopInstance.java:928: error: method replace in class NpcHtmlMessage cannot be applied to given types;
    [javac] 					html.replace("%level%", rhand.getAugmentation().getSkill().getLevel());
    [javac] 					    ^
    [javac]   required: String,String
    [javac]   found: String,int
    [javac]   reason: actual argument int cannot be converted to String by method invocation conversion
    

 

The actual lines:

case 11:
				String htmContent11 = HtmCache.getInstance().getHtm("data/html/mods/donate/augment/active/page4.htm");
				html.setHtml(htmContent11);
				html.replace("%objectId%", String.valueOf(this.getObjectId()));
				html.replace("%charname%", player.getName());
				if (rhand != null && rhand.isAugmented() && rhand.getAugmentation() != null && rhand.getAugmentation().getSkill() != null && rhand.getAugmentation().getSkill().getLevel() >= 1)
				{
					html.replace("%level%", rhand.getAugmentation().getSkill().getLevel());
				}
				html.replace("%level%", "None");
				player.sendPacket(html);
				break;
			

I know what the error is I see it but I dont know how to fix it. Any help?

Edited by sotid
Link to comment
Share on other sites

13 answers to this question

Recommended Posts

  • 0

Try this one:

ItemInstance item = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);

 

            if (item != null && item.isAugmented() && item.getAugmentation() != null && item.getAugmentation().getSkill() != null && item.getAugmentation().getSkill().getLevel() >= 1)
                html.replace("%level%", item.getAugmentation().getSkill().getLevel());
            html.replace("%level%", "None");

Link to comment
Share on other sites

  • 0

try to add .toString()

at 

 html.replace("%level%", item.getAugmentation().getSkill().getLevel());

 

final

 html.replace("%level%", item.getAugmentation().getSkill().getLevel().toString());

Link to comment
Share on other sites

  • 0
31 minutes ago, @IcathiaLord said:

Try this one:

ItemInstance item = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);

 

            if (item != null && item.isAugmented() && item.getAugmentation() != null && item.getAugmentation().getSkill() != null && item.getAugmentation().getSkill().getLevel() >= 1)
                html.replace("%level%", item.getAugmentation().getSkill().getLevel());
            html.replace("%level%", "None"); 

case 11:
				String htmContent11 = HtmCache.getInstance().getHtm("data/html/mods/donate/augment/active/page4.htm");
				html.setHtml(htmContent11);
				html.replace("%objectId%", String.valueOf(this.getObjectId()));
				html.replace("%charname%", player.getName());
				ItemInstance item = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
				if (item != null && item.isAugmented() && item.getAugmentation() != null && item.getAugmentation().getSkill() != null && item.getAugmentation().getSkill().getLevel() >= 1)
				{
					 html.replace("%level%", item.getAugmentation().getSkill().getLevel());
				}
				html.replace("%level%", "None");
				player.sendPacket(html);
				break;
			

like this?
I get error.

http://prntscr.com/mcj9v3

Link to comment
Share on other sites

  • 0

Integer.toString(int)

 

Explanation : replace only accepts Strings, not int. Therefore you have to cast your int into a String.

 

aCis NpcHtmlMessage allow to directly use int as parameter, because there are replace for the most used datatypes.

 

	public void replace(String pattern, String value)
	{
		_html = _html.replaceAll(pattern, value.replaceAll("\\$", "\\\\\\$"));
	}
	
	public void replace(String pattern, int value)
	{
		_html = _html.replaceAll(pattern, Integer.toString(value));
	}
	
	public void replace(String pattern, long value)
	{
		_html = _html.replaceAll(pattern, Long.toString(value));
	}
	
	public void replace(String pattern, double value)
	{
		_html = _html.replaceAll(pattern, Double.toString(value));
	}

If you haven't that, you are forced to do it whenever and wherever you need it. Which is extremely redundant, subject to make errors, and increase amount of code.

 

PS : you got your solution on your question, you already have an exemple :

 

html.replace("%objectId%", String.valueOf(this.getObjectId()));

On aCis or wherever clean pack, you would have :

html.replace("%objectId%", getObjectId());
Edited by Tryskell
Link to comment
Share on other sites

  • 0

ah tryskel is right i confuzed .net with java sorry String.valueOf is the fix :)

about the others just retype the code its encoding issue if you want send me private teamviewer i can retype the code for you and help you solve it 

Edited by DenArt Designs
Link to comment
Share on other sites

  • 0

Sorry, the code i posted was for aCis.

As tryskell said String.valueOf is the solution , so the code must be

html.replace("%level%", String.valueOf(rhand.getAugmentation().getSkill().getLevel()));

  • Like 1
Link to comment
Share on other sites

  • 0

Thank you all I used this and finally works.

 

html.replace("%level%", Integer.toString(rhand.getAugmentation().getSkill().getLevel()));

 

 

Please dont lock the topic , I will post another error later so I wont spam with topics.

Edited by sotid
Link to comment
Share on other sites

  • 0

Next error as promised. :D
 

Error:

[javac] Compiling 911 source files to C:\Users\User\workspace - pvp - Copy\Stable_1004\gameserver\build\classes
    [javac] C:\Users\User\workspace - pvp - Copy\Stable_1004\gameserver\head-src\com\l2jfrozen\gameserver\model\L2Party.java:681: error: cannot find symbol
    [javac] 			member.addItem("Party", itemid, count, player, true);
    [javac] 			                        ^
    [javac]   symbol:   variable itemid
    [javac]   location: class L2Party
    [javac] 1 error

 

Actual lines:

public void distributeAdena(L2PcInstance player, int itemId, long itemCount, L2Character target)
	{
		// Get all the party members
		List<L2PcInstance> membersList = getPartyMembers();

		// Check the number of party members that must be rewarded
		// (The party member must be in range to receive its reward)
		List<L2PcInstance> ToReward = FastList.newInstance();

		for(L2PcInstance member : membersList)
		{
			if(!Util.checkIfInRange(Config.ALT_PARTY_RANGE2, target, member, true))
			{
				continue;
			}
			ToReward.add(member);
		}

		// Avoid null exceptions, if any
		if (ToReward.isEmpty())
			return;

		// Now we can actually distribute the adena reward
		// (Total adena split by the number of party members that are in range and must be rewarded)
		long count = itemCount / ToReward.size();

		for(L2PcInstance member : ToReward)
		{
			member.addItem("Party", itemid, count, player, true);
		}
		FastList.recycle((FastList<?>) ToReward);
	}

 

I dont get why I get this error , other lines of the same java use itemid before I tried to edit anything.
Anyway the code I used:

 

Link to comment
Share on other sites

  • 0
1 hour ago, DenArt Designs said:

make it itemId not itemid

Thanks , of that was a big oof...

Now what? Do I have to add something in pcinstance?

 

[javac] C:\Users\User\workspace - pvp - Copy\Stable_1004\gameserver\head-src\com\l2jfrozen\gameserver\model\L2Party.java:680: error: no suitable method found for addItem(String,int,long,L2PcInstance,boolean)
    [javac] 			member.addItem("Party", itemId, count, player, true);
    [javac] 			      ^
    [javac]     method L2PcInstance.addItem(String,int,int,L2Object,boolean) is not applicable
    [javac]       (actual argument long cannot be converted to int by method invocation conversion)
    [javac]     method L2PcInstance.addItem(String,L2ItemInstance,L2Object,boolean) is not applicable
    [javac]       (actual and formal argument lists differ in length)
    [javac] 1 error

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock