diff --git a/CHANGELOG.md b/CHANGELOG.md index ad0550f1..3d902451 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Added `GetDataHandlers.PlaceItemFrame` hook and related arguments. (@hakusaro) * Added `TSPlayer.IsBouncerThrottled()`. (@hakusaro) * Added `TSPlayer.CheckIgnores()` and removed `TShock.CheckIgnores(TSPlayer)`. (@hakusaro) +* Hooks inside TShock can now be registered with their `Register` method and can be prioritized according to the TShock HandlerList system. (@hakusaro) * Fix message requiring login not using the command specifier set in the config file. (@hakusaro) ## TShock 4.3.25 diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 959ec454..e5336967 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -108,7 +108,7 @@ namespace TShockAPI /// /// TileEdit - called when a tile is placed or destroyed /// - public static HandlerList TileEdit; + public static HandlerList TileEdit = new HandlerList(); private static bool OnTileEdit(TSPlayer ply, int x, int y, EditAction action, EditType editDetail, short editData, byte style) { if (TileEdit == null) @@ -144,7 +144,7 @@ namespace TShockAPI /// /// TogglePvp - called when a player toggles pvp /// - public static HandlerList TogglePvp; + public static HandlerList TogglePvp = new HandlerList(); private static bool OnPvpToggled(byte _id, bool _pvp) { if (TogglePvp == null) @@ -176,7 +176,7 @@ namespace TShockAPI /// /// TogglePvp - called when a player toggles pvp /// - public static HandlerList PlayerTeam; + public static HandlerList PlayerTeam = new HandlerList(); private static bool OnPlayerTeam(byte _id, byte _team) { if (PlayerTeam == null) @@ -220,7 +220,7 @@ namespace TShockAPI /// /// PlayerSlot - called at a PlayerSlot event /// - public static HandlerList PlayerSlot; + public static HandlerList PlayerSlot = new HandlerList(); private static bool OnPlayerSlot(byte _plr, byte _slot, short _stack, byte _prefix, short _type) { if (PlayerSlot == null) @@ -259,7 +259,7 @@ namespace TShockAPI /// /// PlayerHP - called at a PlayerHP event /// - public static HandlerList PlayerHP; + public static HandlerList PlayerHP = new HandlerList(); private static bool OnPlayerHP(byte _plr, short _cur, short _max) { @@ -288,7 +288,7 @@ namespace TShockAPI /// /// PlayerMana - called at a PlayerMana event /// - public static HandlerList PlayerMana; + public static HandlerList PlayerMana = new HandlerList(); private static bool OnPlayerMana(byte _plr, short _cur, short _max) { @@ -332,7 +332,7 @@ namespace TShockAPI /// PlayerInfo - called at a PlayerInfo event /// If this is cancelled, the server will ForceKick the player. If this should be changed in the future, let someone know. /// - public static HandlerList PlayerInfo; + public static HandlerList PlayerInfo = new HandlerList(); private static bool OnPlayerInfo(byte _plrid, byte _hair, int _style, byte _difficulty, string _name) { @@ -372,7 +372,7 @@ namespace TShockAPI /// /// When a chest is added or removed from the world. /// - public static HandlerList PlaceChest; + public static HandlerList PlaceChest = new HandlerList(); private static bool OnPlaceChest(TSPlayer player, int flag, int tilex, int tiley) { @@ -404,7 +404,7 @@ namespace TShockAPI } /// The event fired when a projectile kill packet is received. - public static HandlerList ProjectileKill; + public static HandlerList ProjectileKill = new HandlerList(); /// Fires the ProjectileKill event. /// The TSPlayer that caused the event. @@ -458,7 +458,7 @@ namespace TShockAPI /// /// KillMe - Terraria's crappy way of handling damage from players /// - public static HandlerList KillMe; + public static HandlerList KillMe = new HandlerList(); private static bool OnKillMe(TSPlayer player, byte plr, byte direction, short damage, bool pvp, PlayerDeathReason playerDeathReason) { @@ -511,7 +511,7 @@ namespace TShockAPI /// /// PlayerUpdate - When the player sends it's updated information to the server /// - public static HandlerList PlayerUpdate; + public static HandlerList PlayerUpdate = new HandlerList(); private static bool OnPlayerUpdate(TSPlayer player, byte plr, byte control, byte item, Vector2 position, Vector2 velocity, byte pulley) { @@ -600,7 +600,7 @@ namespace TShockAPI } /// When a player heals another player - public static HandlerList HealOtherPlayer; + public static HandlerList HealOtherPlayer = new HandlerList(); /// Fires the HealOtherPlayer event /// The TSPlayer that started the event @@ -652,7 +652,7 @@ namespace TShockAPI /// /// When the player sends a tile square /// - public static HandlerList SendTileSquare; + public static HandlerList SendTileSquare = new HandlerList(); private static bool OnSendTileSquare(TSPlayer player, MemoryStream data, short size, int tilex, int tiley) { @@ -698,7 +698,7 @@ namespace TShockAPI } /// Fired when an object is placed in the world. - public static HandlerList PlaceObject; + public static HandlerList PlaceObject = new HandlerList(); /// Fires the PlaceObject hook. To be called when an object is placed in the world. /// The originating player. @@ -773,7 +773,7 @@ namespace TShockAPI /// /// NewProjectile - Called when a client creates a new projectile /// - public static HandlerList NewProjectile; + public static HandlerList NewProjectile = new HandlerList(); private static bool OnNewProjectile(short ident, Vector2 pos, Vector2 vel, float knockback, short dmg, byte owner, short type, int index, TSPlayer player) { @@ -823,7 +823,7 @@ namespace TShockAPI /// /// LiquidSet - When ever a liquid is set /// - public static HandlerList LiquidSet; + public static HandlerList LiquidSet = new HandlerList(); private static bool OnLiquidSet(TSPlayer player, int tilex, int tiley, byte amount, byte type) { @@ -862,7 +862,7 @@ namespace TShockAPI /// /// PlayerSpawn - When a player spawns /// - public static HandlerList PlayerSpawn; + public static HandlerList PlayerSpawn = new HandlerList(); private static bool OnPlayerSpawn(byte player, int spawnX, int spawnY) { @@ -900,7 +900,7 @@ namespace TShockAPI /// /// ChestOpen - Called when any chest is opened /// - public static HandlerList ChestOpen; + public static HandlerList ChestOpen = new HandlerList(); private static bool OnChestOpen(int x, int y, TSPlayer player) { @@ -948,7 +948,7 @@ namespace TShockAPI /// /// ChestItemChange - Called when an item in a chest changes /// - public static HandlerList ChestItemChange; + public static HandlerList ChestItemChange = new HandlerList(); private static bool OnChestItemChange(TSPlayer player, short id, byte slot, short stacks, byte prefix, short type) { @@ -989,7 +989,7 @@ namespace TShockAPI /// /// Sign - Called when a sign is changed /// - public static HandlerList Sign; + public static HandlerList Sign = new HandlerList(); private static bool OnSignEvent(short id, int x, int y) { @@ -1033,7 +1033,7 @@ namespace TShockAPI /// /// NPCHome - Called when an NPC's home is changed /// - public static HandlerList NPCHome; + public static HandlerList NPCHome = new HandlerList(); private static bool OnUpdateNPCHome(TSPlayer player, short id, short x, short y, byte homeless) { @@ -1074,7 +1074,7 @@ namespace TShockAPI /// /// PlayerBuff - Called when a player is buffed /// - public static HandlerList PlayerBuff; + public static HandlerList PlayerBuff = new HandlerList(); private static bool OnPlayerBuff(TSPlayer player, byte id, byte type, int time) { @@ -1134,7 +1134,7 @@ namespace TShockAPI /// /// ItemDrop - Called when an item is dropped /// - public static HandlerList ItemDrop; + public static HandlerList ItemDrop = new HandlerList(); private static bool OnItemDrop(TSPlayer player, short id, Vector2 pos, Vector2 vel, short stacks, byte prefix, bool noDelay, short type) { @@ -1188,7 +1188,7 @@ namespace TShockAPI /// /// PlayerDamage - Called when a player is damaged /// - public static HandlerList PlayerDamage; + public static HandlerList PlayerDamage = new HandlerList(); private static bool OnPlayerDamage(TSPlayer player, byte id, byte dir, short dmg, bool pvp, bool crit, PlayerDeathReason playerDeathReason) { @@ -1240,7 +1240,7 @@ namespace TShockAPI /// /// NPCStrike - Called when an NPC is attacked /// - public static HandlerList NPCStrike; + public static HandlerList NPCStrike = new HandlerList(); private static bool OnNPCStrike(TSPlayer player, short id, byte dir, short dmg, float knockback, byte crit) { @@ -1283,7 +1283,7 @@ namespace TShockAPI } /// Fired on a mass wire edit operation. - public static HandlerList MassWireOperation; + public static HandlerList MassWireOperation = new HandlerList(); private static bool OnMassWireOperation(TSPlayer player, short startX, short startY, short endX, short endY, byte toolMode) { @@ -1321,7 +1321,7 @@ namespace TShockAPI } /// Fired when a PlaceTileEntity event occurs. - public static HandlerList PlaceTileEntity; + public static HandlerList PlaceTileEntity = new HandlerList(); private static bool OnPlaceTileEntity(TSPlayer player, short x, short y, byte type) { @@ -1357,7 +1357,7 @@ namespace TShockAPI /// /// NPCSpecial - Called at some point /// - public static HandlerList NPCSpecial; + public static HandlerList NPCSpecial = new HandlerList(); private static bool OnNPCSpecial(byte id, byte type) { @@ -1385,7 +1385,7 @@ namespace TShockAPI /// /// PlayerAnimation - Called when a player animates /// - public static HandlerList PlayerAnimation; + public static HandlerList PlayerAnimation = new HandlerList(); private static bool OnPlayerAnimation(TSPlayer player) { @@ -1413,7 +1413,7 @@ namespace TShockAPI /// /// PlayerBuffUpdate - Called when a player updates buffs /// - public static HandlerList PlayerBuffUpdate; + public static HandlerList PlayerBuffUpdate = new HandlerList(); private static bool OnPlayerBuffUpdate(byte id) { @@ -1457,7 +1457,7 @@ namespace TShockAPI /// /// NPCStrike - Called when an NPC is attacked /// - public static HandlerList Teleport; + public static HandlerList Teleport = new HandlerList(); private static bool OnTeleport(Int16 id, byte f, float x, float y) { @@ -2084,7 +2084,7 @@ namespace TShockAPI /// /// NPCStrike - Called when an NPC is attacked /// - public static HandlerList PaintTile; + public static HandlerList PaintTile = new HandlerList(); private static bool OnPaintTile(Int32 x, Int32 y, byte t) { @@ -2123,7 +2123,7 @@ namespace TShockAPI /// /// Called When a wall is painted /// - public static HandlerList PaintWall; + public static HandlerList PaintWall = new HandlerList(); private static bool OnPaintWall(Int32 x, Int32 y, byte t) { @@ -3101,7 +3101,7 @@ namespace TShockAPI } /// Fired when an ItemFrame is placed. - public static HandlerList PlaceItemFrame; + public static HandlerList PlaceItemFrame = new HandlerList(); private static bool OnPlaceItemFrame(TSPlayer player, short x, short y, short itemID, byte prefix, short stack, TEItemFrame itemFrame) { @@ -3147,7 +3147,7 @@ namespace TShockAPI /// /// GemLockToggle - Called when a gem lock is switched /// - public static HandlerList GemLockToggle; + public static HandlerList GemLockToggle = new HandlerList(); private static bool OnGemLockToggle(short x, short y, bool on) { diff --git a/TShockAPI/Rest/Rest.cs b/TShockAPI/Rest/Rest.cs index 0e3cdeeb..18be5080 100644 --- a/TShockAPI/Rest/Rest.cs +++ b/TShockAPI/Rest/Rest.cs @@ -258,7 +258,7 @@ namespace Rests } [Obsolete("This method will be removed in the next release")] - public static HandlerList RestRequestEvent; + public static HandlerList RestRequestEvent = new HandlerList(); private static bool OnRestRequestCall(RequestEventArgs request) {