Jump to content
  • 0

[HELP]ONE CODE I MADE DOESN'T WORK-JAVA


Question

Posted

I WANT TO HAPPEN EVERY 1 HOUR FOR EXAMPLE, IT DOES NOT WORK :sssss HOW CAN I MAKE IT TO WORK? CAN ANYONE HELP ME :/


### Eclipse Workspace Patch 1.0
#P testGameserver
Index: java/net/sf/l2j/gameserver/GameServer.java
===================================================================
--- java/net/sf/l2j/gameserver/GameServer.java	(revision 5117)
+++ java/net/sf/l2j/gameserver/GameServer.java	(working copy)
@@ -217,6 +217,7 @@
import net.sf.l2j.gameserver.instancemanager.RaidBossSpawnManager;
import net.sf.l2j.gameserver.instancemanager.SiegeManager;
import net.sf.l2j.gameserver.model.AutoChatHandler;
+import net.sf.l2j.gameserver.model.entity.AutoRewardLords;
import net.sf.l2j.gameserver.model.AutoSpawnHandler;
import net.sf.l2j.gameserver.model.L2Manor;
import net.sf.l2j.gameserver.model.L2PetDataTable;
@@ -343,6 +344,7 @@

		RecipeController.getInstance();

+		AutoRewardLords.getInstance();
		SkillTreeTable.getInstance();
		ArmorSetsTable.getInstance();
		FishTable.getInstance();
Index: java/net/sf/l2j/gameserver/model/entity/AutoRewardLords.java
===================================================================
--- java/net/sf/l2j/gameserver/model/entity/AutoRewardLords.java	(revision 0)
+++ java/net/sf/l2j/gameserver/model/entity/AutoRewardLords.java	(revision 0)
@@ -0,0 +1,69 @@
+/* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package net.sf.l2j.gameserver.model.entity;
+
+import java.util.Collection;
+
+import net.sf.l2j.gameserver.Announcements;
+import net.sf.l2j.gameserver.ThreadPoolManager;
+import net.sf.l2j.gameserver.model.L2World;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ *
+ * @author  Cafr
+ */
+public class AutoRewardLords
+{
+	Collection<L2PcInstance> players = L2World.getInstance().getAllPlayers();
+	
+	 class AutoRewardTask implements Runnable
+	{
+		public void run()
+		{
+			for(L2PcInstance player : players)
+			{
+			   if(player != null) if(player.getClan() != null)
+					   if(player.getClan().getHasCastle() > 0 && player.isClanLeader())
+					   {
+						   player.getInventory().addAdena(null, 25000000, player, null);
+						   player.sendMessage("Auto rewarding castle lords activated,look your inventory.");
+					   }	  
+			   }
+			Announcements.getInstance().announceToAll("All online castle lords rewarded.");
+			System.out.println("Auto Castle Lords Reward Activated");
+		 }
+	}
+	
+	private AutoRewardLords()
+		{
+		 ThreadPoolManager.getInstance().scheduleGeneral(new AutoRewardTask(), 60000);
+		}
+   
+	
+	public static AutoRewardLords getInstance()
+		{
+			return SingletonHolder._instance;
+		}
+		
+		private static class SingletonHolder
+		{
+			@SuppressWarnings("synthetic-access")
+			protected static final AutoRewardLords _instance = new AutoRewardLords();
+		}
+}
\ No newline at end of file

Recommended Posts

  • 0
Posted

Thats what i thought at the beggining too.  :(

 

But:

 

You need to update it, it's a copy of current state of the map, not a reference, LOL, imagine the damage that could cause...

 

Actually its a ref and not a new collection referencing the player objects. Taken from the latest revision:

 

227         public L2TIntObjectHashMap<L2PcInstance> getAllPlayers()

228         {

229                 return _allPlayers;

230         }

  • 0
Posted

Yes, I mixed with getAllPlayersArray() which returns a copy into an array of L2PcI.

 

Also L2TIntObjectHashMap should be thread safe...

 

--Edit:

I knew I wasn't that wrong.

With L2World.getInstance().getAllPlayers() you get a map, to get an (iterable) array you need to use getAllPlayersArray(), which isn't a collection.

 

In Freya and older High Five versions L2World.getInstance().getAllPlayers() returned a collection...

 

Be careful depends on the core you try to run the script, obviously the script in first post is for Freya.

  • 0
Posted

+ Collection<L2PcInstance> players = L2World.getInstance().getAllPlayers();

 

I think he has to update his collection each time the method runs.. I agree with Leluche, because a player might exit and get deleted from _allPlayers L2TIntObjectHashMap, so he needs to get deleted from his collection too. Or am i wrong?

  • 0
Posted

+ Collection<L2PcInstance> players = L2World.getInstance().getAllPlayers();

 

I think he has to update his collection each time the method runs.. I agree with Leluche, because a player might exit and get deleted from _allPlayers L2TIntObjectHashMap, so he needs to get deleted from his collection too. Or am i wrong?

 

Read the thread again: http://maxcheaters.com/forum/index.php?topic=227009.msg2000014#msg2000014

I say there why it has to be updated and here (previous post): http://maxcheaters.com/forum/index.php?topic=227009.msg1999371#msg1999371

I included the update in the run method...

 

Actually Leluche and adenaman said that update is not required.

http://maxcheaters.com/forum/index.php?topic=227009.msg1999711#msg1999711

http://maxcheaters.com/forum/index.php?topic=227009.msg2000281#msg2000281

  • 0
Posted

problem solved , actually update was required finally , but and i have to change the scheduleGeneral.

Thanks you :)

 

Good that you got it working, sometimes we go offtopic trying to prove who is right :D

  • 0
Posted

Oh i see. That's what i wanted to say, but thinking Leluche said the opposite :P

 

sometimes we go offtopic trying to prove who is right :D

Yeah this happens quite often here :D

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

    • My official facebook profile!: https://www.facebook.com/spectrumL2 Specifications: Revamped L2JACIS revision FROM the core Private project!!! Revision that has been receiving corrections for over 3 years!!! Events already installed in the revision: TVT CTF KTB PARTY FARM SPOIL EVENT CRAZY RATES TOURNAMENT TIME ZONE (INSTANCE) All working correctly!!! SIEGE ESSENTIAL FEATURES: Walls fix Gates fix Flags fix 100% functional: OLYMPIADS: Implemented settings Hero receives enchanted Weapons with equal status PvP Weapons Optional /true/false Hero can acquire all Hero Weapons Optional true/false OTHER IMPLEMENTATIONS: Teleport fixed (directly to Giran) Teleport effect classic Vip skins vip collor name Pack NPCs with effect already configured BOSES already configured Mobs already configured CLASS BALANCE SPECIAL SYSTEM We have a SPECIAL system developed for Class Balance with only 1 digit in XML %tage of configurable debuffs Player limitation system in BOSES or PvP zones BS blocking system in FLEG zones or events Among others dozens of improvements made in the review... price: 390 USD !  OBS: WE CAN CHANGE THE BANNER AND NAME OF THE SERVICE TO THE ONE OF YOUR PREFERENCE BUT THE SETTINGS MUST BE KEPT ANY CHANGES REQUIRE ADDITION        
    • Server is Online – 1,000+ Active Players! We’re excited to announce the addition of a Europe Proxy to improve connectivity for our EU players! Clans can now benefit from VIP Access to help you catch up faster. 🎯 If you're a clan leader with at least 9 active members, join our Discord and open a ticket to claim your VIP rewards!  
    • The Telegram team is rolling out a new batch of Stars-only gifts you’ll be able to mint as NFTs. Don’t miss your chance to join the next Telegram trend and earn from it! Buy Telegram Stars cheap and KYC-free 1 Star from $0.0149 (min. 50 Stars, bulk discounts available) Promo code STARS5 — 5 % off Pay any way you like: bank cards · crypto · other popular methods How to purchase: ➡Online Store — Click ➡ Telegram bot — Click Other services: ➡ SMM panel — Click Regular buyers get extra discounts and promo codes. Support: ➡ Telegram: https://t.me/solomon_bog ➡ Telegram channel: https://t.me/accsforyou_shop ➡ Discord: https://discord.gg/y9AStFFsrh ➡ WhatsApp: https://wa.me/79051904467 ➡ Email: solomonbog@socnet.store Use these contacts to discuss wholesale orders, partnerships (current list: https://socnet.bgng.io/partners) or to become a supplier. SocNet — your shop for digital goods and premium subscriptions
  • Topics

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