Skip to content

Commit c486176

Browse files
author
Zack Piispanen
committed
Update to 1,14
1 parent cfb55b4 commit c486176

12 files changed

Lines changed: 48 additions & 58 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.suo
2+
_ReSharper.Twitchys-C3Mod
3+
bin
4+
obj

C3Commands.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Text;
4-
using System.Linq;
5-
using System.Threading;
64
using Terraria;
7-
using Hooks;
85
using TShockAPI;
96
using TShockAPI.DB;
107
using C3Mod.GameTypes;

C3Mod.cs

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Xml;
43
using System.Reflection;
5-
using System.Data;
64
using Terraria;
7-
using Hooks;
85
using MySql.Data.MySqlClient;
9-
using System.Threading;
106
using System.ComponentModel;
117
using C3Mod.GameTypes;
128
using System.IO;
9+
using TerrariaApi.Server;
1310
using TShockAPI;
1411
using TShockAPI.DB;
1512

1613
namespace C3Mod
1714
{
18-
[APIVersion(1, 12)]
15+
[ApiVersion(1, 14)]
1916
public class C3Mod : TerrariaPlugin
2017
{
2118
public static C3ConfigFile C3Config { get; set; }
@@ -48,23 +45,23 @@ public override void Initialize()
4845
C3Tools.SetupConfig();
4946

5047
if (C3Config.CTFEnabled)
51-
GameHooks.Update += CTF.OnUpdate;
48+
ServerApi.Hooks.GameUpdate.Register(this, CTF.OnUpdate);
5249
if (C3Config.DuelsEnabled)
53-
GameHooks.Update += Duel.OnUpdate;
50+
ServerApi.Hooks.GameUpdate.Register(this, Duel.OnUpdate);
5451
if (C3Config.OneFlagEnabled)
55-
GameHooks.Update += OneFlagCTF.OnUpdate;
52+
ServerApi.Hooks.GameUpdate.Register(this, OneFlagCTF.OnUpdate);
5653
if (C3Config.TeamDeathmatchEnabled)
57-
GameHooks.Update += TDM.OnUpdate;
54+
ServerApi.Hooks.GameUpdate.Register(this, TDM.OnUpdate);
5855
if (C3Config.MonsterApocalypseEnabled)
59-
GameHooks.Update += Apocalypse.OnUpdate;
56+
ServerApi.Hooks.GameUpdate.Register(this, Apocalypse.OnUpdate);
6057
if (C3Config.FreeForAllEnabled)
61-
GameHooks.Update += FFA.OnUpdate;
58+
ServerApi.Hooks.GameUpdate.Register(this, FFA.OnUpdate);
6259

63-
GameHooks.Update += OnUpdate;
64-
GameHooks.Initialize += OnInitialize;
65-
NetHooks.GreetPlayer += OnGreetPlayer;
66-
ServerHooks.Leave += OnLeave;
67-
NetHooks.GetData += GetData;
60+
ServerApi.Hooks.GameUpdate.Register(this, OnUpdate);
61+
ServerApi.Hooks.GameInitialize.Register(this, OnInitialize);
62+
ServerApi.Hooks.NetGreetPlayer.Register(this, OnGreetPlayer);
63+
ServerApi.Hooks.ServerLeave.Register(this, OnLeave);
64+
ServerApi.Hooks.NetGetData.Register(this, GetData);
6865

6966
GetDataHandlers.InitGetDataHandler();
7067
}
@@ -73,23 +70,24 @@ protected override void Dispose(bool disposing)
7370
{
7471
if (disposing)
7572
{
76-
if (C3Config.CTFEnabled)
77-
GameHooks.Update -= CTF.OnUpdate;
78-
if (C3Config.DuelsEnabled)
79-
GameHooks.Update -= Duel.OnUpdate;
80-
if (C3Config.OneFlagEnabled)
81-
GameHooks.Update -= OneFlagCTF.OnUpdate;
82-
if (C3Config.TeamDeathmatchEnabled)
83-
GameHooks.Update -= TDM.OnUpdate;
84-
if (C3Config.MonsterApocalypseEnabled)
85-
GameHooks.Update -= Apocalypse.OnUpdate;
86-
if (C3Config.FreeForAllEnabled)
87-
GameHooks.Update -= FFA.OnUpdate;
88-
GameHooks.Update -= OnUpdate;
89-
GameHooks.Initialize -= OnInitialize;
90-
NetHooks.GreetPlayer -= OnGreetPlayer;
91-
ServerHooks.Leave -= OnLeave;
92-
NetHooks.GetData -= GetData;
73+
if (C3Config.CTFEnabled)
74+
ServerApi.Hooks.GameUpdate.Deregister(this, CTF.OnUpdate);
75+
if (C3Config.DuelsEnabled)
76+
ServerApi.Hooks.GameUpdate.Deregister(this, Duel.OnUpdate);
77+
if (C3Config.OneFlagEnabled)
78+
ServerApi.Hooks.GameUpdate.Deregister(this, OneFlagCTF.OnUpdate);
79+
if (C3Config.TeamDeathmatchEnabled)
80+
ServerApi.Hooks.GameUpdate.Deregister(this, TDM.OnUpdate);
81+
if (C3Config.MonsterApocalypseEnabled)
82+
ServerApi.Hooks.GameUpdate.Deregister(this, Apocalypse.OnUpdate);
83+
if (C3Config.FreeForAllEnabled)
84+
ServerApi.Hooks.GameUpdate.Deregister(this, FFA.OnUpdate);
85+
86+
ServerApi.Hooks.GameUpdate.Deregister(this, OnUpdate);
87+
ServerApi.Hooks.GameInitialize.Deregister(this, OnInitialize);
88+
ServerApi.Hooks.NetGreetPlayer.Deregister(this, OnGreetPlayer);
89+
ServerApi.Hooks.ServerLeave.Deregister(this, OnLeave);
90+
ServerApi.Hooks.NetGetData.Deregister(this, GetData);
9391
}
9492
base.Dispose(disposing);
9593
}
@@ -101,7 +99,7 @@ public C3Mod(Main game)
10199
Order = -1;
102100
}
103101

104-
internal void OnInitialize()
102+
internal void OnInitialize(EventArgs args)
105103
{
106104
if (C3Config.TeamColor1 < 1 || C3Config.TeamColor1 > 4 || C3Config.TeamColor1 == C3Config.TeamColor2 || C3Config.TeamColor2 > 4 || C3Config.TeamColor2 < 1)
107105
throw new Exception("Team Colours are inccorectly set up. Check c3config.json");
@@ -443,16 +441,16 @@ internal void OnInitialize()
443441
#endregion
444442
}
445443

446-
internal void OnGreetPlayer(int who, HandledEventArgs e)
444+
internal void OnGreetPlayer(GreetPlayerEventArgs args)
447445
{
448446
lock (C3Players)
449-
C3Players.Add(new C3Player(who));
447+
C3Players.Add(new C3Player(args.Who));
450448

451449
if(C3Config.ShowWelcomeMessage)
452-
TShock.Players[who].SendMessage("This server is running C3Mod, created by Twitchy. C3Mod is now open source.", Color.Cyan);
450+
TShock.Players[args.Who].SendMessage("This server is running C3Mod, created by Twitchy. C3Mod is now open source.", Color.Cyan);
453451
}
454452
//Converted v2.2
455-
internal void OnUpdate()
453+
internal void OnUpdate(EventArgs args)
456454
{
457455
if (C3Config.C3TeamsLocked)
458456
{
@@ -475,13 +473,13 @@ internal void OnUpdate()
475473
}
476474
}
477475

478-
internal void OnLeave(int ply)
476+
internal void OnLeave(LeaveEventArgs args)
479477
{
480478
lock (C3Mod.C3Players)
481479
{
482480
for (int i = 0; i < C3Mod.C3Players.Count; i++)
483481
{
484-
if (C3Mod.C3Players[i].Index.ToString() == ply.ToString())
482+
if (C3Mod.C3Players[i].Index == args.Who)
485483
{
486484
C3Mod.C3Players.RemoveAt(i);
487485
break;

DLL/TShockAPI.dll

69.5 KB
Binary file not shown.

DLL/TerrariaServer.exe

1 MB
Binary file not shown.

DataHandler.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,9 @@ You should have received a copy of the GNU General Public License
1717
*/
1818
using System;
1919
using System.Collections.Generic;
20-
using System.Xml;
21-
using System.Reflection;
2220
using Terraria;
23-
using Hooks;
24-
using MySql.Data.MySqlClient;
25-
using System.Threading;
26-
using System.ComponentModel;
27-
using C3Mod.GameTypes;
2821
using System.IO;
2922
using TShockAPI;
30-
using TShockAPI.DB;
31-
using TShockAPI.Net;
3223
using System.IO.Streams;
3324

3425
namespace C3Mod

GameTypes/Apocalypse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ internal class Apocalypse
2626
public static int LastMonster = 0;
2727
public static int playersdead = 0;
2828

29-
public static void OnUpdate()
29+
public static void OnUpdate(EventArgs args)
3030
{
3131
if (C3Mod.VoteRunning && C3Mod.VoteType == "apoc")
3232
{

GameTypes/CTF.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal class CTF
2525
public static int StartCount = 5;
2626
public static int VoteCount = 0;
2727

28-
public static void OnUpdate()
28+
public static void OnUpdate(EventArgs args)
2929
{
3030
lock (C3Mod.C3Players)
3131
{

GameTypes/Duel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ internal class Duel
2020
public static C3Player Team1Player;
2121
public static C3Player Team2Player;
2222

23-
public static void OnUpdate()
23+
public static void OnUpdate(EventArgs args)
2424
{
2525
lock (C3Mod.C3Players)
2626
{

GameTypes/FFA.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ internal class FFA
1717
public static DateTime voteCountDown = DateTime.UtcNow;
1818
public static DateTime scoreNotify = DateTime.UtcNow;
1919

20-
public static void OnUpdate()
20+
public static void OnUpdate(EventArgs args)
2121
{
2222
lock (C3Mod.C3Players)
2323
{

0 commit comments

Comments
 (0)