Jump to content

Question

Posted (edited)

Hello guys i have one problem with the vote manager at l2network, when the votes are until 999 the vote manager work

but when goes 1000 and up i got error because the website write the votes 1,000 with a comma.

maybe someone can help me to work this ?

ERROR RequestByPassToServer.runImpl : invalid number format
java.lang.NumberFormatException: For input string: "19,474"

the code is this 

public static int getL2NetworkVotes()
	{
		int votes = 0;
		boolean lineFound = false;
		try
		{
			URL url = new URL(Config.VOTES_SITE_L2NETWORK_URL);
			InputStream is = url.openStream();
			try (
				BufferedReader br = new BufferedReader(new InputStreamReader(is)))
			{
				String line;
				while ((line = br.readLine()) != null)
				{
					if (line.contains("color:#e7ebf2"))
						votes = Integer.parseInt(line.split(">")[2].split("<")[0]);
					lineFound = true;
				}
			}
		}
		catch (IOException e)
		{
			e.printStackTrace();
			System.out.println("NetWork is offline. We will check reward as it will be online again.");
		}
		if (!lineFound)
			System.out.println("The line wasn't found in Network, check site in case they updated.");
		return votes;
	}

 

Edited by cyta5

4 answers to this question

Recommended Posts

  • 0
Posted

Like @TGSLineage2 mentioned, you should replace "," with nothing. ""...

also, you have to add the lineFound inside of the line check. so it should be

while ((line = br.readLine()) != null)
{
	if (line.contains("color:#e7ebf2"))
	{
		votes = Integer.parseInt(line.split(">")[2].split("<")[0].replace(",",""));
		lineFound = true;
	}
}

 

  • 0
Posted

  

4 hours ago, TGSLineage2 said:

line.split(">")[2].split("<")[0].replace(",","");

 

9 minutes ago, melron said:

Like @TGSLineage2 mentioned, you should replace "," with nothing. ""...

also, you have to add the lineFound inside of the line check. so it should be


while ((line = br.readLine()) != null)
{
	if (line.contains("color:#e7ebf2"))
	{
		votes = Integer.parseInt(line.split(">")[2].split("<")[0].replace(",",""));
		lineFound = true;
	}
}

 

 

but does not want and one check ...if the votes is <=999 or >999 ?

because the votes until the 999 its ok but when goes 1000 and over the website write it 1,000

  • 0
Posted
43 minutes ago, cyta5 said:

  

 

 

but does not want and one check ...if the votes is <=999 or >999 ?

because the votes until the 999 its ok but when goes 1000 and over the website write it 1,000

You dont need any check. you replacing comma at every case and you are done

  • Upvote 1

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

    • Hey guys, I came up with this idea while needing to write down multiple locations. When you use the /loc command, a text file is created (only the first time) and stores all the locations you debug.   Output:   --- a/aCis_gameserver/java/net/sf/l2j/gameserver/handler/usercommandhandlers/Loc.java +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/handler/usercommandhandlers/Loc.java @@ -1,5 +1,10 @@ package net.sf.l2j.gameserver.handler.usercommandhandlers; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + import net.sf.l2j.gameserver.data.xml.MapRegionData; import net.sf.l2j.gameserver.handler.IUserCommandHandler; import net.sf.l2j.gameserver.model.actor.Player; @@ -13,6 +18,7 @@ 0 }; + @SuppressWarnings("resource") @Override public void useUserCommand(int id, Player player) { @@ -100,6 +106,26 @@ } player.sendPacket(SystemMessage.getSystemMessage(msg).addNumber(player.getX()).addNumber(player.getY()).addNumber(player.getZ())); + + if (player.isGM()) + { + try + { + String fileLoc = "./data/locations.txt"; + final File file = new File(fileLoc); + file.createNewFile(); + + FileWriter fw = new FileWriter(fileLoc, true); + BufferedWriter bw = new BufferedWriter(fw); + bw.write(player.getX() + ", " + player.getY() + ", " + player.getZ()); + bw.newLine(); + bw.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } + } } @Override  
    • Not any training model, i should fix that, just a very well done bot engine. As we use it on a local Internet Cafe spot and people join to test server, they don't seem to understand they are bots. Their behaviour is really well done. Many actions that other bots can't do are possible and the are complicated patterns that can be done due to structure of the engine such as Pick items of dead party pk member and later on trade them back to owner. So i'll fix later the title to Bot Engine rather than A.I. 
    • its old ver ))   this is new https://gamerip.ru/index.php?/topic/3308-lineage2-chronicle3-rise-of-darkness-new-version-172-030225/
  • Topics

×
×
  • Create New...