Reset attendance rewards every day at 6:30 am.
Contributed by nasseka.
This commit is contained in:
		| @@ -70,6 +70,7 @@ public class DailyTaskManager extends AbstractEventManager<AbstractEvent<?>> | ||||
| 		resetWorldChatPoints(); | ||||
| 		resetTrainingCamp(); | ||||
| 		onResetTimedHuntingZones(); | ||||
| 		onResetAttendanceRewards(); | ||||
| 	} | ||||
| 	 | ||||
| 	@ScheduleTarget | ||||
| @@ -325,6 +326,32 @@ public class DailyTaskManager extends AbstractEventManager<AbstractEvent<?>> | ||||
| 		LOGGER.info("Weekly Special Hunting Zones has been resetted."); | ||||
| 	} | ||||
| 	 | ||||
| 	public void onResetAttendanceRewards() | ||||
| 	{ | ||||
| 		// Update data for offline players. | ||||
| 		try (Connection con = DatabaseFactory.getConnection()) | ||||
| 		{ | ||||
| 			try (PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var=?")) | ||||
| 			{ | ||||
| 				ps.setString(1, "ATTENDANCE_DATE"); | ||||
| 				ps.execute(); | ||||
| 			} | ||||
| 		} | ||||
| 		catch (Exception e) | ||||
| 		{ | ||||
| 			LOGGER.log(Level.SEVERE, getClass().getSimpleName() + ": Could not reset Attendance Rewards: " + e); | ||||
| 		} | ||||
| 		 | ||||
| 		// Update data for online players. | ||||
| 		for (PlayerInstance player : World.getInstance().getPlayers()) | ||||
| 		{ | ||||
| 			player.getVariables().remove("ATTENDANCE_DATE"); | ||||
| 			player.getVariables().storeMe(); | ||||
| 		} | ||||
| 		 | ||||
| 		LOGGER.info("Attendance Rewards has been resetted."); | ||||
| 	} | ||||
| 	 | ||||
| 	public static DailyTaskManager getInstance() | ||||
| 	{ | ||||
| 		return SingletonHolder.INSTANCE; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 MobiusDevelopment
					MobiusDevelopment