Jump to content

Recommended Posts

Posted (edited)

missing 
net.sf.l2j.gameserver.handler.admincommandhandlers.AdminEventEngine;

 

and some imports are wrong. example ....events. must be "event" and ...impl.. must be imp or vice versa.

Edited by wongerlt
  • Upvote 1
Posted (edited)
7 hours ago, StinkyMadness said:

  

Eu não acho que os jogadores se importem com o ID de itens de recompensa, mas pelo Nome : D

 

already changed for

 

for (IntIntHolder reward: Config.TVT_REWARDS)
            World.announceToOnlinePlayers("TvT Event: Reward "+ ItemTable.getInstance().getTemplate(reward.getId()).getName() +","+ reward.getValue(), true);
        

4 hours ago, edusz93 said:

 

Tem um pequeno erro no código que faz com que o tempo todo seja apenas teleportado de volta e removido do evento. 

 

Correção:



		 
		
		  
		
			
			  
				 
			   
			 
			
			  
				
			
			
				  
				
					  
						
					
					
					  
					
						    
					
				
			
			
			  
			
				 
				
			
		
	  
	

 

 

already fixed

 

Edited by Williams
  • Like 1
Posted
On 8/6/2019 at 9:30 PM, Williams said:

about threadpool execution i don't know how i will do i will do more research on.

 

ThreadPool.schedule(new Runnable()
{
	@Override
	public void run()
	{
		"ACTION"
	}
}, "TIME ACTION IN SECONDS"*1000);

 

Posted (edited)
ThreadPool.schedule(() -> finishChamp(), _endDate - System.currentTimeMillis());

In case you got a method to call, otherwise use following if you got some actions to do.

		_earthQuakeTask = ThreadPool.schedule(() ->
		{
			for (Player member : getAvailablePlayers(_party))
				member.sendPacket(new Earthquake(member.getX(), member.getY(), member.getZ(), 65, 9));
		}, jumpTime - 7000);

As shown in last exemple, you can retain the task on a variable, in order to stop it when you want (notably used to delay a scheduled action, to avoid to get it twice).

 

		if (_earthQuakeTask != null)
		{
			_earthQuakeTask.cancel(false);
			_earthQuakeTask = null;
		}

There's a huge amount of tasks here and there, simply read.

 

Edited by Tryskell
  • Like 1
Posted

Estou tentando e tendo dificuldades em fazer com que o TVT fique com horário fixo. 


Exemplo na "events.properties":
# Times TvT will occur (24h format).
TvTEventInterval = 00:00,02:00,04:00,06:00,08:00,10:00,13:34,14:00,16:00,18:00,20:00,22:00

Posted
On 8/12/2019 at 10:25 AM, edusz93 said:

Estou tentando e tendo dificuldades em fazer com que o TVT fique com horário fixo. 


Exemplo na "events.properties":
# Times TvT will occur (24h format).
TvTEventInterval = 00:00,02:00,04:00,06:00,08:00,10:00,13:34,14:00,16:00,18:00,20:00,22:00

 

2.jpg?1565823032

 

3.jpg?1565823007

 

Consegui!

  • Thanks 1
Posted
1 hour ago, Williams said:

 

Estou sem tempo, quando estiver posto as alterações feitas.

 


Se quiser, te mando essa minha alteração e depois você posta tudo junto.

Posted (edited)
12 hours ago, edusz93 said:


Se quiser, te mando essa minha alteração e depois você posta tudo junto.

manda em mp que faco o pacth, amanha ja posto

Edited by Williams
  • 2 weeks later...
Posted (edited)
On 8/6/2019 at 5:50 PM, Tryskell said:

 

To name few, after some look :

 

* eventTimer(int time) should be handled with a Future<?> task and ThreadPool.

* _originalCoordinates is (probably) redundant with _savedLocation, and the use of it is wrong (see _savedLocation usage to see correct)

* CopyOnWriteArrayList container should be avoid for performance reason, use ConcurrentHashMap.newKeySet instead.


+                   if (reward == null)
+                       continue;

can never be null, since you manipulate it from A TO Z.

* TVT_DOOR_LIST doesn't seem to be used and can use getProperty(final String name, final int[] defaultValue, final String delimiter) instead of self coded array manipulation.

 

 

* CopyOnWriteArrayList container should be avoid for performance reason, use ConcurrentHashMap.newKeySet instead.

 

Hello Master, I'm studying and improving TVT, I'm tending to change the player lists. I changed to ConcurrentHashMap.newKeySet ()

 

in 

private List<Player> _registered = new CopyOnWriteArrayList<>();

 

for 

 

private Set<Player> _registered = ConcurrentHashMap.newKeySet();

 

I have this error

 

JBoTJgC.png

 

I don't know if it's the correct one but I did it like this

 

in Player player = _registered.get(Rnd.get(_registered.size()));

 

for Player player = World.getInstance().getPlayer(Rnd.get(_registered.size()));

Edited by Williams
Posted

A Set got no .get() method, and a Map would give you the key related value if you .get() it. I would use a ConcurrentHashMap (cause keys are probably useful anyway elsewhere), then generate a List based on values() with

List<Player>registeredPlayers = new ArrayList(_registered.values())

then

Collections.shuffle(registeredPlayers);

 

Why shuffle instead of Rnd.get ? Simply because to avoid multiple Rnd.get.

 

And in the end, .clear() the _registered, once all players are allocated (or even in the beginning, just after registeredPlayers creation). That would avoid to .remove everytime a loop is done. You .clear() only once.

 

That would also avoid you that dangerous (while) loop (I'm not a big fan of loops). You only for loop, for the given shuffled internal List.

 

It basically depends about what you do with leftover Players, if any. But your current writting means there is no leftover, otherwise you would end with infinite loop.

  • Thanks 1
Posted
5 hours ago, Tryskell said:

A Set got no .get() method, and a Map would give you the key related value if you .get() it. I would use a ConcurrentHashMap (cause keys are probably useful anyway elsewhere), then generate a List based on values() with


List<Player>registeredPlayers = new ArrayList(_registered.values())

then


Collections.shuffle(registeredPlayers);

 

Why shuffle instead of Rnd.get ? Simply because to avoid multiple Rnd.get.

 

And in the end, .clear() the _registered, once all players are allocated (or even in the beginning, just after registeredPlayers creation). That would avoid to .remove everytime a loop is done. You .clear() only once.

 

That would also avoid you that dangerous (while) loop (I'm not a big fan of loops). You only for loop, for the given shuffled internal List.

 

It basically depends about what you do with leftover Players, if any. But your current writting means there is no leftover, otherwise you would end with infinite loop.

 

which would be better to list the players?

 

private Map<Integer, Player> _registered = new ConcurrentHashMap<>();

 

or 

 

    private Set<Player> _registered = ConcurrentHashMap.newKeySet();

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
Reply to this topic...

×   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...