Jump to content

Recommended Posts

Posted

With this command the players from your server can vote for the server restart.

 

If there are 25 (config) votes the server will restart by him self.

 

And here is the code:

Index: D:/Games/Server/WorkSpace/GameServer/java/config/Mods.properties
===================================================================
--- D:/Games/Server/WorkSpace/GameServer/java/config/Mods.properties	(revision 194)
+++ D:/Games/Server/WorkSpace/GameServer/java/config/Mods.properties	(working copy)
@@ -227,3 +227,12 @@
# Announce Level Settings
MinLevelToAnnounce = 1
MaxLevelToAnnounce = 80
+
+# ========================== #
+#   Server Restart Voting    #
+# ========================== #
+# Enable Server Restart Command
+AllowServerRestartCommand = False
+
+# Votes For Restart
+VotesNeededForRestart = 20
Index: D:/Games/Server/WorkSpace/GameServer/java/net/sf/l2j/Config.java
===================================================================
--- D:/Games/Server/WorkSpace/GameServer/java/net/sf/l2j/Config.java	(revision 194)
+++ D:/Games/Server/WorkSpace/GameServer/java/net/sf/l2j/Config.java	(working copy)
@@ -960,6 +960,10 @@
     public static int NPC_ANNOUNCER_MIN_LVL_TO_ANNOUNCE;
     public static int NPC_ANNOUNCER_MAX_LVL_TO_ANNOUNCE;
     public static boolean NPC_ANNOUNCER_DONATOR_ONLY;
+    
+    /** Server Restart */
+    public static boolean ALLOW_SERVER_RESTART_COMMAND;
+    public static int     VOTES_NEEDED_FOR_RESTART;

	/** Event Automation */
	public static int TIME_BETWEEN_EVENTS;
@@ -2091,6 +2095,9 @@
         		NPC_ANNOUNCER_MAX_ANNOUNCES_PER_DAY = Integer.parseInt(Mods.getProperty("AnnouncesPerDay", "20"));
         		NPC_ANNOUNCER_MIN_LVL_TO_ANNOUNCE = Integer.parseInt(Mods.getProperty("MinLevelToAnnounce", "0"));
         		NPC_ANNOUNCER_MAX_LVL_TO_ANNOUNCE = Integer.parseInt(Mods.getProperty("MaxLevelToAnnounce", "80"));
+        		
+        		ALLOW_SERVER_RESTART_COMMAND = Boolean.parseBoolean(Mods.getProperty("AllowServerRestartCommand", "False"));
+        		VOTES_NEEDED_FOR_RESTART     = Integer.parseInt(Mods.getProperty("VotesNeededForRestart", "20"));
             }
             catch (Exception e)
             {
Index: D:/Games/Server/WorkSpace/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- D:/Games/Server/WorkSpace/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(revision 196)
+++ D:/Games/Server/WorkSpace/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -617,6 +617,9 @@
     public boolean _inEventVIP = false;
     public boolean _isNotVIP = false, _isTheVIP = false;
     public int _originalNameColourVIP, _originalKarmaVIP;
+    
+    /** Server Restart Vote Parameters */
+    public boolean		_voteRestart		= false;

	/** new loto ticket **/
	private int _loto[] = new int[5];
Index: D:/Games/Server/WorkSpace/GameServer/java/net/sf/l2j/gameserver/GameServer.java
===================================================================
--- D:/Games/Server/WorkSpace/GameServer/java/net/sf/l2j/gameserver/GameServer.java	(revision 189)
+++ D:/Games/Server/WorkSpace/GameServer/java/net/sf/l2j/gameserver/GameServer.java	(working copy)
@@ -204,6 +204,7 @@
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.JoinVIP;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.OnlinePlayers;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.PmOff;
+import net.sf.l2j.gameserver.handler.voicedcommandhandlers.ServerRestartVote;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.TradeOff;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.VoiceInfo;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.Wedding;
@@ -620,6 +621,9 @@
			_voicedCommandHandler.registerVoicedCommandHandler(new BuyRec());

		_voicedCommandHandler.registerVoicedCommandHandler(new JoinVIP());
+		
+		if(Config.ALLOW_SERVER_RESTART_COMMAND)
+			_voicedCommandHandler.registerVoicedCommandHandler(new ServerRestartVote());

		_log.config("VoicedCommandHandler: Loaded " + _voicedCommandHandler.size() + " handlers.");

 

Now create new file named ServerRestartVote.java in net.sf.l2j.gameserver.commandhandler.voicedcommands and place this:

 

/*
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
*/
package net.sf.l2j.gameserver.handler.voicedcommandhandlers;

import net.sf.l2j.gameserver.Announcements;
import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.entity.RestartVoteVariable;

/**
* @author SkyLanceR
*/

public class ServerRestartVote implements IVoicedCommandHandler
{
private static final String[] VOICED_COMMANDS = {"vote_restart"};

/**
 * 
 * @see net.sf.l2j.gameserver.handler.IVoicedCommandHandler#useVoicedCommand(java.lang.String, net.sf.l2j.gameserver.model.actor.instance.L2PcInstance, java.lang.String)
 */

public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
{
	RestartVoteVariable e = new RestartVoteVariable();

	if(command.startsWith("vote_restart"))
	{
		if (activeChar._voteRestart == false)
		{
			e.increaseVoteCount("restart");
			activeChar._voteRestart = true;
			activeChar.sendMessage("You succesfully voted for the server restart. Votes For The Moment: " + e.getVoteCount("tvt") + ".");
			Announcements.getInstance().announceToAll("Player: "+activeChar.getName()+" has voted for server restart. If you whant to support him type .vote_restart !");
		}
		else
		{
			activeChar.sendMessage("You have already voted for an server restart.");
		}
	}
	return false;
}

public String[] getVoicedCommandList()
{
	return VOICED_COMMANDS;
}
}

 

Create new file named VoteVariable.java in net.sf.l2j.gameserver.model.actor.entity and place this:

 

/*
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
*/

package net.sf.l2j.gameserver.model.entity;

/**
*@author SkyLanceR
*/

public class RestartVoteVariable
{
public int				_voteCountRestart = 0;
private int				_voteCount = 0;

public int getVoteCount(String name)
{
	if (name == "restart")
	{
		_voteCount = _voteCountRestart;
	}
	return  _voteCount;
}

public void increaseVoteCount(String name)
{
	if (name == "restart")
	{
		_voteCountRestart = _voteCountRestart+1;
	}
}
}

 

Create new file named RestartTheServer.java in net.sf.l2j.gameserver.model.actor.entity and place this:

 

/*
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
*/
package net.sf.l2j.gameserver.model.entity;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.Shutdown;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;


/**
* @author SkyLanceR
*/

public class RestartTheServer
{

public static void playerRestart(L2PcInstance activeChar, boolean restart)
{
	RestartVoteVariable e = new RestartVoteVariable();

	if (e.getVoteCount("restart") > Config.VOTES_NEEDED_FOR_RESTART)
	{
		Shutdown.getInstance().startShutdown(activeChar, 60, restart);
	}
}
}

 

Tested in L2J Interlude & Working

Thats all.

Hope its useful and helpful.

Credits: SkyLancer & Me

Guest
This topic is now closed to further replies.


  • Posts

    • Auto Farm System  100% functional  Fully configurable (zones, skills, behavior)   Interesting, I'd like to see it.
    • 🔥 L2Ext Custom Interlude VANG – 2026 Release High-End Extender for Lineage 2 Interlude by L2Devs   🎯 About L2Devs L2Devs is a production-ready custom extender for Lineage 2 Interlude, designed for stable long-term servers that require performance, security, balance and flexibility. Developed and battle-tested for more than 6 years on live servers, the 2026 Release represents a major evolution, focusing not only on new features but also on stability, configurability and abuse prevention. This extender is aimed at serious server owners, not experimental or low-quality projects.   🚀 What’s New in 2026 Temporary Fake Hero System Fully configurable (duration, visuals, effects) Visual Weapons System Client-side visual weapons without stat impact Visual Armor by Zone System Fully configurable per zone Advanced Balance System Fully configurable per class, skill and scenario Armor Enchant Bonus System Extra bonuses at +7 / +8 / +9 (fully configurable) Enchant Stats System Full control of stats per enchant level Damage Cap System Fully configurable damage limits Champion System with Rewards Custom champions with configurable rewards Item Percentage Steal by Zone Fully configurable zone-based system Raid Boss HP Percentage Announce Last Hit Announce System (Raid / Boss) Pet Sales via Multisell Auto Farm System ✔️ 100% functional ✔️ Fully configurable (zones, skills, behavior) Auto Potion System Configurable by Item ID, HP/MP %, reuse delay New Captcha Mod v4 (2026) Improved bot detection & automation prevention New Event Modes TvT – Last Man Standing (LMS) KTB – Kill The Boss Fully configurable ⚙️ Core Features General Systems Cached Extended IOBuffer (8192kb) Hair2Slot Cache Item Bid Auctioner for Clan Halls Offline Shops & Buffers restore after restart (fixed location) Offline Buffer System ALT+B Augmentation House Shift+Click Drop/Spoil List Auto Learn Skills Scheme Buffer Global Trade Chat Global Vote Reward System Achievements System Custom Subclass (Accumulative) Change Name Color / Title Color Change Gender / Change Race (Skin) VIP Systems (chat, autoloot, features) Command .menu fully configurable Command .hero enable/disable aura PvP / PK / War PvP Auto Announce System (rebuilt, configurable) PvP Reward / PK Reward / War Reward Epic Items Rank Raid Boss Points Rank Global PvP Rankings Anti abuse validations Olympiad Olympiad Season Rank Pages Restore Stats on Fight Start Olympiad Second Time System Last 10 Minutes Entry Third Class Summons Control Castle / Siege Castle Announce Time Castle Standby Time Siege-related optimizations Disable SSQ System after Castle Siege Drops & Enchants Fully configurable drop system (min/max level, all mobs, RBs, individual mobs) Spellbook Drop enable/disable Custom Cancel Effects (min/max) Blessed Enchant Rates (armor & weapons) Enchant restrictions & protections Quality of Life Fix Spiritshot Delay Fast NPC loading fix Show Mob Level Show NPC Clan Flag Use Any Dyes No Drop on Death (configurable) No Sell / No Private Buy Items Min Level Trade Soulshot no system message Spawn Protection System 🎮 Events Engine Team vs Team Capture The Flag Death Match Last Man Standing Destroy The Base Korean Style Events Castle Siege Events Happy Hour Event (reworked) AFK Time Control Reset Reuse Skills Reset Buffs on Finish Firework Effects Win/Loss Rewards Custom Team Titles & Colors Kill Counter in Title Open Door / Wall System Balance Bishops Disconnect Recovery Validation 🔁 Reload Systems (Live Reload) EnterWorld HTML Donate Shop Offline Buffer Champion NPC AntiBot VIP System Auction System AutoLoot Castle Siege Manager Character Lock Clan PvP Status Auto Learn Clan Reputation Rank Clan Systems Skill Data Door Data Deco Data Multisell Drop List Custom Config Files 🛡️ Security & Stability Anti-Bot & Captcha v4 Anti-Exploit & Anti-Abuse protections Safe enchant & item handling Crash-safe routines Tested on live servers for 3+ years 📊 Performance Optimized thread usage Reduced database load Improved packet handling Designed for high concurrency environments 💼 License & Support Price: 450 USDT per IP / initial installation License: One server / one IP / 30 USDT monthly Payments: Crypto only Included Support Extender installation Extender configuration support Not Included Script configuration (consult separately) Custom MOD development (available on request) Source code not included, please inquire for pricing 📩 Contact Telegram: @L2Devs Discord: .unknownsoldier Website: https://l2devs.com
    • Prices added, sorry for the inconvenience.   Greetings!!
    • There is a big difference when somebody ''use some brand names'' with a role of his discord to ensure that people will trust him. Here is MXC and not  your friends discord. Read the rules before you post, and read the rules before you buy.
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..