Jump to content

[Share]Auto Voting for Restart.


Recommended Posts

Thanks *NeverMore* gia tin idea....

Perigrafi:

Kathe 12 ores ginete announce automata an oi players

theloun o server na ginei rr, etsi tous dinete to dikeoma

na patisoun .yes . no(san vote).

Auto krataei gia 3 lepta....molis teliosoun ta 3 lepta

ginonte announce ta apotelesmata.

Analoga me ta nai kai ta oxi, o server kanei restart i

sinexizei ti litourgia.

 

### Eclipse Workspace Patch 1.0
#P TEST_GS2
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(revision 4767)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -452,6 +452,7 @@

	private boolean _noble = false;
	private boolean _hero = false;
+	public boolean _vote = false;

	/** The L2FolkInstance corresponding to the last Folk wich one the player talked. */
	private L2FolkInstance _lastFolkNpc = null;
Index: java/net/sf/l2j/gameserver/GameServer.java
===================================================================
--- java/net/sf/l2j/gameserver/GameServer.java	(revision 4767)
+++ java/net/sf/l2j/gameserver/GameServer.java	(working copy)
@@ -197,6 +197,7 @@
import net.sf.l2j.gameserver.handler.usercommandhandlers.PartyInfo;
import net.sf.l2j.gameserver.handler.usercommandhandlers.Time;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.Wedding;
+import net.sf.l2j.gameserver.handler.voicedcommandhandlers.autorestart;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.stats;
import net.sf.l2j.gameserver.idfactory.IdFactory;
import net.sf.l2j.gameserver.instancemanager.AuctionManager;
@@ -219,6 +220,7 @@
import net.sf.l2j.gameserver.model.L2Manor;
import net.sf.l2j.gameserver.model.L2PetDataTable;
import net.sf.l2j.gameserver.model.L2World;
+import net.sf.l2j.gameserver.model.entity.AutoRestart;
import net.sf.l2j.gameserver.model.entity.Hero;
import net.sf.l2j.gameserver.model.entity.TvTManager;
import net.sf.l2j.gameserver.network.L2GameClient;
@@ -390,6 +392,8 @@
		CastleManager.getInstance();
		SiegeManager.getInstance();

+		AutoRestart.getInstance();
+		
		TeleportLocationTable.getInstance();
		LevelUpData.getInstance();
		L2World.getInstance();
@@ -589,6 +593,7 @@

		_voicedCommandHandler = VoicedCommandHandler.getInstance();
		_voicedCommandHandler.registerVoicedCommandHandler(new stats());
+		_voicedCommandHandler.registerVoicedCommandHandler(new autorestart());

		if(Config.L2JMOD_ALLOW_WEDDING)
			_voicedCommandHandler.registerVoicedCommandHandler(new Wedding());
Index: java/net/sf/l2j/gameserver/model/entity/AutoRestart.java
===================================================================
--- java/net/sf/l2j/gameserver/model/entity/AutoRestart.java	(revision 0)
+++ java/net/sf/l2j/gameserver/model/entity/AutoRestart.java	(revision 0)
@@ -0,0 +1,139 @@
+/* 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 net.sf.l2j.gameserver.Announcements;
+import net.sf.l2j.gameserver.Shutdown;
+import net.sf.l2j.gameserver.ThreadPoolManager;
+import net.sf.l2j.gameserver.model.L2World;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ *
+ * @author  Codex
+ */
+public class AutoRestart 
+{
+	static boolean canVote = false;
+	public static int yes = 0;
+	public static int no = 0;
+	
+	class Task implements Runnable{
+		public void run()
+		{
+			handle();
+		}	
+	}
+
+	void handle(){
+		globalMessage("Want a server restart? Vote now by pressing .yes or .no");
+		setCanVote(true);
+		globalMessage("In 3 minutes, votes are closed...please press .yes or .no");
+		waitMinutes(2);
+		globalMessage("In 1 minutes, votes are closed...please press .yes or .no");
+		waitMinutes(1);
+		setCanVote(false);
+		globalMessage("Votes closed, results will be shown in 30 seconds");
+		waitSeconds(30);
+		checkTheVotes();
+		clear();
+		
+	}
+	void globalMessage(String s){
+		Announcements.getInstance().announceToAll(s);
+	}
+	
+	void setCanVote(boolean z){
+		canVote = z;
+	}
+	
+	public static boolean getCanVote(){
+		return canVote;
+	}
+	
+	void waitMinutes(int i){
+		try{
+			Thread.sleep(i * 60000);
+		}
+		catch(Exception ie){
+			ie.printStackTrace();
+		}
+	}
+	
+	void waitSeconds(int i){
+		try{
+			Thread.sleep(i * 1000);
+		}
+		catch(Exception ie){
+			ie.printStackTrace();
+		}
+	}
+	
+	public static void increaseYes(boolean n){
+		if(n){
+			yes = yes + 1;
+		}
+		else{
+			no = no + 1 ;
+		}	
+	}
+	
+	int takeYes(){
+		return yes;
+	}
+	
+	int takeNo(){
+		return no;
+	}
+	
+	void checkTheVotes(){
+		globalMessage("Results: Yes: "+takeYes()+", No: "+takeNo());
+		if(takeYes() > takeNo()){
+			globalMessage("Server will restart...");
+			for(L2PcInstance p: L2World.getInstance().getAllPlayers()){
+			Shutdown.getInstance().startShutdown(p, 30, true);}
+		}
+		else if(takeYes() < takeNo()){
+			globalMessage("Server will not restart...");
+			globalMessage("Server is continuing normally");
+		}
+	}
+	
+	void clear(){
+		yes = 0;
+		no = 0;
+		for(L2PcInstance p: L2World.getInstance().getAllPlayers())
+			p._vote = false;
+	}
+	
+	private AutoRestart()
+	{
+	ThreadPoolManager.getInstance().scheduleGeneral(new Task(), 43200000);
+	}
+	
+	 public static AutoRestart getInstance()
+	 {
+	return SingletonHolder._instance;
+	 }
+	      
+	 private static class SingletonHolder
+	 {
+	 @SuppressWarnings("synthetic-access")
+	protected static final AutoRestart _instance = new AutoRestart();
+	}
+}
Index: java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/autorestart.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/autorestart.java	(revision 0)
+++ java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/autorestart.java	(revision 0)
@@ -0,0 +1,76 @@
+/* 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.handler.voicedcommandhandlers;
+
+import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.entity.AutoRestart;
+
+/**
+ *
+ * @author  Codex
+ */
+public class autorestart implements IVoicedCommandHandler
+{
+
+	private static final String[] VOICED_COMMANDS = { "yes", "no"};
+	
+	public boolean useVoicedCommand(String command, L2PcInstance activeChar,String target)
+	{
+		if(command.startsWith("yes")){
+		if(!AutoRestart.getCanVote()){
+		   return false;
+		}
+		else if(activeChar._vote = true){
+			activeChar.sendMessage("You have already voted.");
+			return false;
+		}
+		else if(activeChar == null) return false;
+		
+		else {
+			activeChar.sendMessage("You voted successfully.");
+			AutoRestart.increaseYes(true);
+			activeChar._vote = true;
+		}
+	}
+		else if(command.startsWith("no")){
+			if(!AutoRestart.getCanVote()){
+				   return false;
+				}
+			else if(activeChar._vote = true){
+				activeChar.sendMessage("You have already voted.");
+				return false;
+			}
+				else if(activeChar == null) return false;
+			
+			activeChar.sendMessage("You voted successfully.");
+			AutoRestart.increaseYes(false);
+			activeChar._vote = true;
+		}
+		return true;
+}
+
+	/**
+	 * @see net.sf.l2j.gameserver.handler.IVoicedCommandHandler#getVoicedCommandList()
+	 */
+	public String[] getVoicedCommandList()
+	{
+		return VOICED_COMMANDS;
+	}
+
+}

Credits:Me

Einai kalo se servers me polla atoma pisteuw, isos an kolisei o server kamia fora, oi an oi gm den einai mesa.

Link to comment
Share on other sites

akomi ena kalo share apo esena .... Aksizei karma i douleia s tis teleutaies meres nomizw alla krima pou dn mporw na sto dosw ... Otan exo xrono 8a to kanw test na dw ama doulevei

 

 

Thanks For share ...

Link to comment
Share on other sites

poly kalo alla na rotiso ekei pou exeis bali auto:

### Eclipse Workspace Patch 1.0
#P TEST_GS2
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(revision 4767)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -452,6 +452,7 @@

	private boolean _noble = false;
	private boolean _hero = false;
+	public boolean _vote = false;

simeni oti den ta boroun na psifizoun oi hero kai oi nobless?

Link to comment
Share on other sites

poly kalo alla na rotiso ekei pou exeis bali auto:

### Eclipse Workspace Patch 1.0
#P TEST_GS2
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(revision 4767)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -452,6 +452,7 @@

	private boolean _noble = false;
	private boolean _hero = false;
+	public boolean _vote = false;

simeni oti den ta boroun na psifizoun oi hero kai oi nobless?

oxi vevea.....
Link to comment
Share on other sites

  • 8 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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.



  • Posts

    • yen, yuan, franc, pound / / Canadian dollar, Australian dollar, Singapore dollar, Hong Kong dollar and other currencies for sale Buy Super Notes /[kennroger77@gmail.com] USD dollar, Pounds, euro @  Text /Call / Whatsapp:   +27833928661. We are reliable, quality and Unique producer of excellent grade of Undetectable counterfeit Banknotes. With over a billion of our products circulating around the world. We offer only original high-quality counterfeit currency NOTES. We ship worldwide. We also print and sell Grade A banknotes of over 150 currencies in the world. (((kennroger77@gmail.com )))USD, EURO, POUNDS, CANADIAN DOLLARS, AUSTRALIAN, DOLLARS, FRANC, SWISS FRANC, INDIAN RUPEE, NEW ZEALAND DOLLARS, BRAZILIAN REAL, BAHRAINI DINAR, ISRAELI NEW SHEKEL, QATARI RIYAL, UAE DIRHAM, NORWEGIAN KRONE, OMANI RIAL, MEXICAN PESO, JAMAICAN DOLLAR,((( ))) SOUTH AFRICAN RAND, HUNGARIAN FORINT, Bolivian boliviano BOB, Chilean peso CLP, Colombian peso COP, Falkland Islands pound FKP, Guyanese dollar GYD, Paraguayan guarani PYG, Peruvian sol PEN, Surinamese dollar SRD, Uruguayan peso UYU, Venezuelan bolivar. We offer high quality counterfeit NOTES for all currencies. Contact us for more information+27833928661
    • Undetectable counterfeit money for sale , we have a tendency to area unit the most effective and distinctive producer of prime quality Undetectable counterfeit money.Passes in ATM %100+27833928661 Contact me On +27833928661 #counterfeitmoney #fakenotes #counterfeit #fakenotesalready #fakemoney #fakenotestatus #money #dollars #fakenotesforsale #fakebanknotes #counterfeitmoneyforsale #germany #fakenotesgoingaround +27833928661 #counterfeitnotes #fakepoundsmoney #counterfeitmoneymachine #counterfeitmoneyonline #banknotesforsale #moneyforsale #buycounterfeitmoney #cash #counterfeitcurrency #counterfetmoney #fakedollarsforsale #fakenotestilyatakenotes #fakenotesstatus #makemoney #fakedollars+27833928661
    • Buy Fake Canadian Dollars WhatsApp+27833928661 ,Buy Fake USD Online ($) buy fake canadian money online,Buy fake euros | Buy fake pounds+27833928661 Buy Fake Canadian Dollars WhatsApp+27833928661 ,Buy Fake USD Online ($) buy fake canadian money online,Buy fake euros | Buy fake pounds | Buy fake dollars | Buy fake Canadian dollars | Buy fake AUD Buy Fake USD Online ($) WhatsApp+27833928661 Euros online Buy Fake USD Online ($) Buy Fake Euros Online (EUR) ,Buy Fake Canadian Dollars ( CAD) Buy Fake Chinese ) Buy fake Australian dollars ,WhatsApp+27833928661 Buy fake money / Buy counterfeit banknotes , Buy prop money , Buy Fake USD $100 Banknotes, HOW TO BUY COUNTERFEIT MONEY ONLINE. Buy a Real Passport Online , Buy US Passport online , Buy Visa Online , Buy Drivers License Online , buy driving license online , Renew your driving license online , +27833928661 Buy registered drivers license online , Buy Visa online , Buy Canadian Visa online , Buy real Visa online , buy social security number online, Buy SSN Online , Buy ID cards , Buy Permanent Resident , Buy IELTS certificate without exam , Apply for citizenship online , Buy Covid Vaccine Card online , Buy a real Australian passport , Buy a diplomatic passport , Buy TOEFL+27833928661 certificate online , Buy Spanish passport Buy Spanish ID Card , Buy Birth Certificate online , Buy Krimea Birth Certificate WhatsApp+27833928661 Email ::: Kennroger77@gmail.com It is partitioned into 100 pence (solitary: penny). Before you proceed with us , you search kindly remember this is the best spot where you will buy or exchange counterfeit euro bills+27833928661 where to buy fake dollar bills where to buy counterfeit bills where to buy fake bills buy counterfeit bank notes where to buy fake bank notes where can i buy fake dollar bills where to buy counterfeit bank notes Buy counterfeit euro bills Purchase euro fake bills online Where to buy fake British pounds fake banknotes for sale uk fake bank notes for sale counterfeit euro banknotes for sale counterfeit bank notes for sale Where to buy fake euro bills Where to british pounds Fake bank notes for sale Germany Counterfeit bank notes for sale China Buy currency bills Japan Where to buy euro bills online fake money for sale prop money for sale counterfeit money for sale money for sale money tree for sale undetectable fake money for sale real money for sale confederate money for sale legit counterfeit money for sale confederate currency for sale high quality counterfeit money for sale quality counterfeit money for sale high quality undetectable counterfeit banknotes for sale currency for sale
    • Whatsapp This Number +27833928661   General Support: Kennroger77@gmail.com   +27833928661 With the COVID-19 pandemic possibly triggering a global recession, +27833928661 we produce genuine banknotes in USD Dollars, British Pounds £ and Euro€s with different serial numbers on each banknote. We have in stock semi-finished banknote substrates already engraved and designed front and back of the various currencies of each denomination. +27833928661 We need a partner to work with unobtrusively to complete the production of our semi-finished banknote substrates and make them legal tender on a percentage which we will discuss in a personal meeting should you agree to work with us. We will schedule a meeting to show you everything and discuss all the details and produce samples so you can have a test run to confirm authenticity. All notes will pass important tests such as ultraviolet light, pencil test,+27833928661    +27833928661 Get a second chance in life with a new identity, protect your privacy, build a new credit history, take back your freedom.+27833928661  We offer real driver's licenses, passports, visas, ID cards, residence permits, postage stamps, school diplomas, work permits, marriage certificates, death certificates, green cards, credit cards, bank statements and other documents for a number of countries such as: United States, Australia, Belgium, Brazil, Canada, Italy, Finland, France, Germany, Israel, Mexico, Netherlands, South Africa, Spain, United Kingdom, Japan, China! +27833928661 Our team produces high quality products, +27833928661 authentic database passports, database or citizenship documents and other ID cards. We use high quality equipment and materials to create documents.+27833928661    WhatsApp: +27833928661   General Support: Kennroger77@gmail.com   -Scan ID - yes... -HOLOGRAM: IDENTICAL - BARCODES: IDS SCAN -UV: YES   buy undetectable counterfeit money buy real and fake passport online buy undetectable counterfeit money, buy real and fake driving licenses Buy counterfeit banknotes where to buy fake dollar bills where to buy counterfeit banknotes where to buy counterfeit banknotes buy counterfeit banknotes where to buy counterfeit banknotes where can i buy fake dollar bills where to buy counterfeit banknotes Buy counterfeit euro banknotes Buy counterfeit euro banknotes online Where to buy fake British pounds counterfeit banknotes for sale in the UK counterfeit banknotes for sale sale of counterfeit euro banknotes sale of counterfeit banknotes Where to buy counterfeit euro banknotes Where do British pounds go Fake banknotes for sale Germany Counterfeit banknotes for sale China Buy Japan banknotes Where to buy euro banknotes online counterfeit money for sale prop money for sale counterfeit money for sale money for sale money tree for sale undetectable counterfeit money for sale real money for sale Confederate money for sale legit fake money for sale Confederate currency for sale high quality counterfeit money for sale quality counterfeit money for sale High quality undetectable counterfeit banknotes for sale+27833928661  currency for sale banknotes for sale best counterfeit money for sale For sale printer for counterfeit banknotes+27833928661  fake money that look real for sale currency traders near me undetectable counterfeit money for sale high quality undetectable counterfeit money for sale foreign currency for sale real fake money for sale world banknotes for sale +27833928661 
    • PermalinkWe are involved in the productions of more than 150 currencies. We print original money of all types Euro, US Dollar, Pound and many more. We print UNDETECTABLE COUNTERFEIT BANKNOTES of all currencies. We have 1 BILLION in stock. Here is your chance to be a MILLIONAIRE. Contact us now. This bills are not home made but industrial and professionally manufactured from High Quality IT technicians from US, Russia, Korea and China. We offer HIGH QUALITY COUNTERFEIT NOTES for the following currencies; EUR - Euro+27833928661 USD - US Dollar DNR - DINAR GBP - British Pound INR - Indian Rupee AUD - Australian Dollar CAD - Canadian Dollar AED - Emirati Dirham ZAR - Rand CHF - Swiss France CNY - Chinese Yuan Renminbi MYR - Malaysian Ringgit THB - Thai Baht NZD - New Zealand Dollar SAR - Saudi Arabian Riyal QAR - Qatari Riya+27833928661
  • 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