public override void Use(Player p, string message, CommandData data) { if (message.Length == 0) { if (!hooked) // not thread-safe but meh { OnSentMapEvent.Register(HandleOnSentMap, Priority.High); OnGettingMotdEvent.Register(HandleGettingMotd, Priority.High); hooked = true; } if (LevelInfo.IsRealmOwner(p.name, p.level.MapName) || CheckExtraPerm(p, data, 1)) { EnableHacksBypass(p); } else { p.Message("&cYou can only bypass hacks on your own realms."); } } else if (message.CaselessEq("stop")) { DisableHacksBypass(p); } else { Help(p); } }
bool SendRawMapCore(Level prev, Level level) { bool success = true; try { if (level.blocks == null) { throw new InvalidOperationException("Tried to join unloaded level"); } useCheckpointSpawn = false; lastCheckpointIndex = -1; AFKCooldown = DateTime.UtcNow.AddSeconds(2); ZoneIn = null; AllowBuild = level.BuildAccess.CheckAllowed(this); SendMapMotd(); Session.SendLevel(prev, level); Loading = false; OnSentMapEvent.Call(this, prev, level); } catch (Exception ex) { success = false; PlayerActions.ChangeMap(this, Server.mainLevel); Message("&WThere was an error sending the map, you have been sent to the main level."); Logger.LogError(ex); } finally { Server.DoGC(); } return(success); }
protected override void UnhookEventHandlers() { OnPlayerChatEvent.Unregister(HandlePlayerChat); OnPlayerSpawningEvent.Unregister(HandlePlayerSpawning); OnSentMapEvent.Unregister(HandleSentMap); OnJoinedLevelEvent.Unregister(HandleJoinedLevel); OnTabListEntryAddedEvent.Unregister(HandleTabListEntryAdded); base.UnhookEventHandlers(); }
protected override void HookEventHandlers() { OnPlayerChatEvent.Register(HandlePlayerChat, Priority.High); OnPlayerSpawningEvent.Register(HandlePlayerSpawning, Priority.High); OnSentMapEvent.Register(HandleSentMap, Priority.High); OnJoinedLevelEvent.Register(HandleJoinedLevel, Priority.High); OnTabListEntryAddedEvent.Register(HandleTabListEntryAdded, Priority.High); base.HookEventHandlers(); }
public override void Unload(bool shutdown) { OnPlayerConnectEvent.Unregister(ConnectHandler.HandleConnect); OnPlayerCommandEvent.Unregister(ChatHandler.HandleCommand); OnChatEvent.Unregister(ChatHandler.HandleOnChat); OnPlayerStartConnectingEvent.Unregister(ConnectingHandler.HandleConnecting); OnSentMapEvent.Unregister(MiscHandlers.HandleOnMapSent); OnPlayerMoveEvent.Unregister(MiscHandlers.HandlePlayerMove); OnPlayerClickEvent.Unregister(MiscHandlers.HandlePlayerClick); OnEcoTransactionEvent.Unregister(EcoHandlers.HandleEcoTransaction); OnModActionEvent.Unregister(ModActionHandler.HandleModAction); Server.Background.Cancel(clearTask); }
public override void Load(bool startup) { OnPlayerConnectEvent.Register(ConnectHandler.HandleConnect, Priority.Critical); OnPlayerCommandEvent.Register(ChatHandler.HandleCommand, Priority.Critical); OnChatEvent.Register(ChatHandler.HandleOnChat, Priority.Critical); OnPlayerStartConnectingEvent.Register(ConnectingHandler.HandleConnecting, Priority.Critical); OnSentMapEvent.Register(MiscHandlers.HandleOnMapSent, Priority.Critical); OnPlayerMoveEvent.Register(MiscHandlers.HandlePlayerMove, Priority.Critical); OnPlayerClickEvent.Register(MiscHandlers.HandlePlayerClick, Priority.Critical); OnEcoTransactionEvent.Register(EcoHandlers.HandleEcoTransaction, Priority.Critical); OnModActionEvent.Register(ModActionHandler.HandleModAction, Priority.Critical); clearTask = Server.Background.QueueRepeat(IPThrottler.CleanupTask, null, TimeSpan.FromMinutes(10)); }
public override void Unload(bool shutdown) { OnPlayerConnectEvent.Unregister(ConnectHandler.HandleConnect); OnPlayerCommandEvent.Unregister(ChatHandler.HandleCommand); OnChatEvent.Unregister(ChatHandler.HandleOnChat); OnPlayerStartConnectingEvent.Unregister(ConnectingHandler.HandleConnecting); OnSentMapEvent.Unregister(MiscHandlers.HandleSentMap); OnPlayerMoveEvent.Unregister(MiscHandlers.HandlePlayerMove); OnPlayerClickEvent.Unregister(MiscHandlers.HandlePlayerClick); OnChangedZoneEvent.Unregister(MiscHandlers.HandleChangedZone); OnEcoTransactionEvent.Unregister(EcoHandlers.HandleEcoTransaction); OnModActionEvent.Unregister(ModActionHandler.HandleModAction); }
public override void Load(bool startup) { OnPlayerConnectEvent.Register(ConnectHandler.HandleConnect, Priority.Critical); OnPlayerCommandEvent.Register(ChatHandler.HandleCommand, Priority.Critical); OnChatEvent.Register(ChatHandler.HandleOnChat, Priority.Critical); OnPlayerStartConnectingEvent.Register(ConnectingHandler.HandleConnecting, Priority.Critical); OnSentMapEvent.Register(MiscHandlers.HandleSentMap, Priority.Critical); OnPlayerMoveEvent.Register(MiscHandlers.HandlePlayerMove, Priority.Critical); OnPlayerClickEvent.Register(MiscHandlers.HandlePlayerClick, Priority.Critical); OnChangedZoneEvent.Register(MiscHandlers.HandleChangedZone, Priority.Critical); OnEcoTransactionEvent.Register(EcoHandlers.HandleEcoTransaction, Priority.Critical); OnModActionEvent.Register(ModActionHandler.HandleModAction, Priority.Critical); }
void InitServerTask(SchedulerTask task) { Server.Start(); // The first check for updates is run after 10 seconds, subsequent ones every two hours Server.Background.QueueRepeat(Updater.UpdaterTask, null, TimeSpan.FromSeconds(10)); OnPlayerConnectEvent.Register(Player_PlayerConnect, Priority.Low); OnPlayerDisconnectEvent.Register(Player_PlayerDisconnect, Priority.Low); OnSentMapEvent.Register(Player_OnJoinedLevel, Priority.Low); OnLevelAddedEvent.Register(Level_LevelAdded, Priority.Low); OnLevelRemovedEvent.Register(Level_LevelRemoved, Priority.Low); OnPhysicsLevelChangedEvent.Register(Level_PhysicsLevelChanged, Priority.Low); RunOnUI_Async(() => main_btnProps.Enabled = true); }
public override void Use(Player p, string message, CommandData data) { if (!hooked) // not thread-safe but meh { OnSentMapEvent.Register(HandleOnSentMap, Priority.High); OnGettingMotdEvent.Register(HandleGettingMotd, Priority.High); hooked = true; } if (LevelInfo.IsRealmOwner(p.name, p.level.MapName) || CheckExtraPerm(p, data, 1)) { p.Extras[ext_allowed_key] = true; p.SendMapMotd(); p.Message("&aYou are now bypassing hacks restrictions on this map"); } else { p.Message("&cYou can only bypass hacks on your own realms."); } }
bool SendRawMapCore(Level prev, Level level) { bool success = true; try { if (level.blocks == null) { throw new InvalidOperationException("Tried to join unloaded level"); } useCheckpointSpawn = false; lastCheckpointIndex = -1; AFKCooldown = DateTime.UtcNow.AddSeconds(2); ZoneIn = null; SendMapMotd(); AllowBuild = level.BuildAccess.CheckAllowed(this); int volume = level.blocks.Length; if (Supports(CpeExt.FastMap)) { Send(Packet.LevelInitaliseExt(volume)); } else { Send(Packet.LevelInitalise()); } if (hasBlockDefs) { if (prev != null && prev != level) { RemoveOldLevelCustomBlocks(prev); } BlockDefinition.SendLevelCustomBlocks(this); if (Supports(CpeExt.InventoryOrder)) { BlockDefinition.SendLevelInventoryOrder(this); } } using (LevelChunkStream dst = new LevelChunkStream(this)) using (Stream stream = LevelChunkStream.CompressMapHeader(this, volume, dst)) { if (level.MightHaveCustomBlocks()) { LevelChunkStream.CompressMap(this, stream, dst); } else { LevelChunkStream.CompressMapSimple(this, stream, dst); } } // Force players to read the MOTD (clamped to 3 seconds at most) if (level.Config.LoadDelay > 0) { System.Threading.Thread.Sleep(level.Config.LoadDelay); } byte[] buffer = Packet.LevelFinalise(level.Width, level.Height, level.Length); Send(buffer); Loading = false; OnSentMapEvent.Call(this, prev, level); } catch (Exception ex) { success = false; PlayerActions.ChangeMap(this, Server.mainLevel); Message("&WThere was an error sending the map, you have been sent to the main level."); Logger.LogError(ex); } finally { Server.DoGC(); } return(success); }