Jump to content
  • 0

Fastlist -> Arraylist Acis


L2shaken

Question

http://imgur.com/a/1oYgm

protected int getWinnerTeam()
	{
		ArrayList<EventTeam> t = new ArrayList<>();
		
		for (EventTeam team : teams.values())
		{
			if (t.size() == 0)
			{
				t.add(team);
				continue;
			}
			
			if (team.getScore() > t.getFirst().getScore())
			{
				t.clear();
				t.add(team);
				continue;
			}
			
			if (team.getScore() == t.getFirst().getScore())
				t.add(team);
		}
		
		if (t.size() > 1)
			return 0;
		
		return t.getFirst().getId();
	}

getFirst () must be replaced by what?

Edited by L2shaken
Link to comment
Share on other sites

Recommended Posts

  • 0
protected int getWinnerTeam()
{
	final EventTeam team = teams.values().stream().sorted(Comparator.comparing(EventTeam::getScore).reversed()).findFirst().orElse(null);
	return team == null ? 0 : team.getId();
}

Exact same broken getWinnerTeam logic to java.

 

 

So much overhead for few calculations

Link to comment
Share on other sites

  • 0

So much overhead for few calculations

You use reconnect system for your events?

public boolean onReconnect(final L2PcInstance player)

Btw what "list" you use to store id of the disconnected player and the set that you store teamId, Kills e.t.c ?

 

treemap ? 

Edited by AccessDenied
Link to comment
Share on other sites

  • 0

You use reconnect system for your events?

public boolean onReconnect(final L2PcInstance player)

Btw what "list" you use to store id of the disconnected player and the set that you store teamId, Kills e.t.c ?

 

treemap ? 

 

None, my custom instance world manages it 

	@Override
	public boolean onReconnect(final L2PcInstance player)
	{
		final PlayerDriver playerDriver = getPlayerDriver(player);
		if (playerDriver == null || playerDriver.getEventAFKSeconds() > 200)
		{
			player.sendMessage("You have been kicked from this event for being inactive for more than 3 minutes.");
			IWorld.resetKnown(player);
			return false;
		}
		playerInject(player);
		return true;
	}
Link to comment
Share on other sites

  • 0

 

None, my custom instance world manages it 

	@Override
	public boolean onReconnect(final L2PcInstance player)
	{
		final PlayerDriver playerDriver = getPlayerDriver(player);
		if (playerDriver == null || playerDriver.getEventAFKSeconds() > 200)
		{
			player.sendMessage("You have been kicked from this event for being inactive for more than 3 minutes.");
			IWorld.resetKnown(player);
			return false;
		}
		playerInject(player);
		return true;
	}

 

 

EventWorld.java

Link to comment
Share on other sites

  • 0

What you mean more tricky ?

 

If team 1 and team 2 has same score it will return 0 anyway 

u have 5 teams and 2 of them have the highest same score... Both have to get rewards-claim the winner title.

 

so,based in what he wants to do(get the ID),he might need 2 ids (e.g stored in array and return it instead of int and thats a simple solution or "check for more than 1" -> more code).I m pretty sure that there is something better in l2j but IDC  :dat:

Easy stuff without "l2j" knowledge.

Sry no l2j here ,i m jealous ... no i m not YDB Kappa

Edited by bravetobe
Link to comment
Share on other sites

  • 0
IWorld.resetKnown(player);

AHAHHAHAHAHAAHAHAHAHAHAHAHAHAAHAHAHAHAHAAHAHAHAHAAHAHAHAAHAHAHAAHAHAHAHAHAHAAHAHAHAAHAHAHAHAAHAAHHAHAHHA

 

 

you dont even know what that is :D

Link to comment
Share on other sites

  • 0

This is a static method in an interface. One of the most non necessary features of Java 8.

 

Shows you never wrote unit tests ever in your life and you have no idea what DI is.

 

:D

 

You're a joke I give you that. I've been using static methods in interfaces since default methods came. IWorld is a hybrid interface consisted of default methods and a few static methods for caching on a global access. This hybrid interface is a "hack" that allows me to make an illusion of a virtuallu multiple inheritance which is not possible in Java (I have strong c++ background).

 

This way I can implement IWorld while extending another important class.

 

 

I am not here to teach you elfo, crawl back to your virgin nasty fatass C# mentor that told you that C# is the best

Edited by xxdem
Link to comment
Share on other sites

  • 0

I never said it was the best way to do it :D

Even if you show him the finest code in the universe he will find something to disagree with.

Link to comment
Share on other sites

  • 0

default methods became a thing in java 8 too.

 

"Hybrid interface" HAHAHAHHAHAHAHAHA

Writing default methods for a class that already is part of your source is so lame. 

 

"This way I can implement IWorld while extending another important class."

I won't even get into the trouble of explaining you why this is so wrong.

 

I'm pretty sure that if you have to do shit like this you don't even know what SOLID are.

 

Get out of my way incompetent developer. Go make some shitty google drive sync file system.

 

 

PS: I got news for you. I equally use C# and Java in a day to day basic in both Android, Spring, ASP.NET MVC and other scenarios. So what you are saying has no point.

I'm not judging Java. Java is amazing. I am judging you. You are a overrated piece of shit :D

 

Your but-hurt-ness level is paranoid.

 

Did I singed an agreement with myself that I will follow strict policies for my own free-time project that is mostly coded for fun and myself?Did I say anywhere that the above snippet is a tryhard piece of software that respects ALL GLOBAL STANDARDS that any retard is gonna bring on the table or anything? s

 

Well I didn't :D . So violations are made. Can't get it why it hurts you so much.

 

 

 

Retard.

Edited by xxdem
Link to comment
Share on other sites

  • 0

Your but-hurt-ness level is paranoid.

 

Did I singed an agreement with myself that I will follow strict policies for my own free-time project that is mostly coded for fun? I didn't say anywhere that its coded tryhard mode or anything, so violations are made. Can't get it why it hurts you so much.

 

Well I didn't :D .

 

 

 

Retard.

It doesn't hurt me. It hurts you because you are poping out of nowhere to show off you "cool little ae event shit" and when someone trashes you to the ground you get all defensive and say it's coded for fun.

 

We are developers. We code for fun anyway. This doesn't mean we have to use it as an excuse.

 

Fuck it I'm out.

Link to comment
Share on other sites

  • 0

It doesn't hurt me. It hurts you because you are poping out of nowhere to show off you "cool little ae event shit" and when someone trashes you to the ground you get all defensive and say it's coded for fun.

 

We are developers. We code for fun anyway. This doesn't mean we have to use it as an excuse.

 

Fuck it I'm out.

 

I've edited read again. Fun was a wrong word to say.

 

Showing off or helping? Get your shit straight mate.

Edited by xxdem
Link to comment
Share on other sites

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.




×
×
  • Create New...