RECENT NEWS
📢 𝟑𝟎% Discount for all ads only this month ❄️

Calender Events

Romeo
power_settings_new
Seen 2 days ago
Rune Warrior (38/40)
Rune Warrior
0
0
0
38 Posts
Posts
0
Warning level
0
Likes
0
Dislikes
Joined: 2022-07-03
This is a custom system built to be ran to initate custom events. You can also set it up to be used for weekend boosts, or other events that are in rotation

CalenderEvents.java

Code:
package com.rs;

import java.util.Calendar;

import com.rs.game.World;
import com.rs.game.player.content.quantum.donations.DailyLimited;
import com.rs.game.player.content.quantum.event.EscapedWarriors;
import com.rs.game.player.content.quantum.events.GodWarsGlobal;
import com.rs.game.player.content.quantum.events.InvestEvent;
import com.rs.game.player.content.quantum.impl.UserPolls;
import com.rs.utils.Colors;

/**
 * A class used to store all event related settings
 * 
 * @author Quantum
 */
public final class CalenderEvents {
	
	
	private static Calendar cal = Calendar.getInstance();
	
	private static int dayOfWeek() {
		return cal.get(Calendar.DAY_OF_WEEK);
	}
	
	private static int dayOfMonth() {
		return cal.get(Calendar.DATE);
	}
	
	private static int month() {
		return cal.get(Calendar.MONTH);
	}
	
	private static int week() {
		return cal.get(Calendar.WEEK_OF_MONTH);
	}
	
	public static boolean isWeekend() {
		return dayOfWeek() == 1 ? true : dayOfWeek() == 6 ? true : dayOfWeek() == 7 ? true : false;
	}
	
	/*
	 * Events
	 */
	public static boolean investEvent = false;
	public static boolean investClaim = false;
	public static int investStart = 15, investEnd = 20, investClaimStart = 20, investClaimEnd = 24, investReset = 25;
	
	/*
	 * Boosts
	 */

	public static boolean slayerWeekend = false, dungeoneeringWeekend = false;
	public static boolean doubleXPWeekend = false, zealModifier = false;
	public static boolean doubleDrop = false, doubleReputation = false;
	
	
	public static void reinit() {
		if(dayOfMonth() >=12 && dayOfMonth() <= 15) {
			dungeoneeringWeekend = true;
		}
		if(dayOfMonth() >= 25 && dayOfMonth() <= 28) {
			slayerWeekend = true;
		}
		if(isWeekend()) {
			doubleXPWeekend = true;
			zealModifier = true;
		}
		if(dayOfWeek() == 6) {
			doubleDrop = true;
			doubleReputation = true;
		}
		if(dayOfMonth() >= investStart && dayOfMonth() <= investEnd) {
			investEvent = true;
			InvestEvent.reinit();
		} else {
			investEvent = false;
		}
		if(dayOfMonth() >= investClaimStart && dayOfMonth() <= investClaimEnd) {
			investClaim = true;
			InvestEvent.claimStart();
		}
	}
	
	
	public static void init() {
		if(dayOfMonth() >=12 && dayOfMonth() <= 15) {
			dungeoneeringWeekend = true;
		}
		if(dayOfMonth() >= 25 && dayOfMonth() <= 28) {
			slayerWeekend = true;
		}
		if(isWeekend()) {
			doubleXPWeekend = true;
			zealModifier = true;
		}
		if(dayOfWeek() == 6) {
			doubleDrop = true;
			doubleReputation = true;
		}
		if(dayOfMonth() >= investStart && dayOfMonth() <= investEnd) {
			investEvent = true;
			InvestEvent.init();
		} else {
			investEvent = false;
		}
		if(dayOfMonth() >= investClaimStart && dayOfMonth() <= investClaimEnd) {
			investClaim= true;
			InvestEvent.initClaim();
		} else {
			investClaim = false;
			
		}
	}
}

Inside your ServerLauncher (always renamed so whatever launches your server) :

Code:
/* Starts calender events */
		
CalenderEvents.init();
checkCalenderEvents();

Put this function inside the same file to run your reinit():

Code:
private static void checkCalenderEvents() {
		CoresManager.slowExecutor.scheduleWithFixedDelay(new Runnable() {
			@Override
			public void run() {
				try {
					CalenderEvents.reinit();
					World.sendWorldMessage("Calender Events have been refreshed!", false);
				} catch (Throwable e) {
					Logger.handle(e);
				}

			}
		}, 1, 6, TimeUnit.HOURS);
	}

 

There are two main functions, init() and reinit(). init() is thrown on server start, to initiate any events, the reinit() is thrown to be set up every 4-6 hours to recheck if events are going (if you dont update constantly, reninit() will recollect what day it is and start those events without a reset)
I also left in Invest Event triggers, in a way to show how you can set it up to be used for Events that are specified to a certain month, a certain week, or others. Hopefully someone can use this.
00
  • Like
Reactions: