Skip to content

Commit 47bdcce

Browse files
committed
Update to Rocket 4.6
1 parent 18395f2 commit 47bdcce

12 files changed

+62
-54
lines changed

CommandHome.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Zamirathe_HomeCommand
1111
{
1212
public class CommandHome : IRocketCommand
1313
{
14-
public bool RunFromConsole
14+
public bool AllowFromConsole
1515
{
1616
get
1717
{
@@ -43,8 +43,13 @@ public List<string> Aliases
4343
{
4444
get { return new List<string>(); }
4545
}
46-
public void Execute(RocketPlayer playerid, string[] bed)
46+
public List<string> Permissions
4747
{
48+
get { return new List<string>() { }; }
49+
}
50+
public void Execute(IRocketPlayer caller, string[] bed)
51+
{
52+
UnturnedPlayer playerid = (UnturnedPlayer)caller;
4853
HomePlayer homeplayer = playerid.Player.transform.GetComponent<HomePlayer>();
4954
object[] cont = HomeCommand.CheckConfig(playerid);
5055
if (!(bool)cont[0]) return;

HomePlayer.cs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
using Rocket.API;
1+
using System;
2+
using System.Collections.Generic;
3+
4+
using Rocket.API;
5+
using Rocket.Core;
6+
using Rocket.Core.Logging;
7+
using Rocket.Core.Serialisation;
28
using Rocket.Unturned;
3-
using Rocket.Unturned.Logging;
9+
using Rocket.Unturned.Chat;
410
using Rocket.Unturned.Player;
511
using SDG.Unturned;
612
using Steamworks;
713
using UnityEngine;
8-
using System;
9-
using System.Collections.Generic;
1014

1115
namespace Zamirathe_HomeCommand
1216
{
13-
public class HomePlayer : RocketPlayerComponent
17+
public class HomePlayer : UnturnedPlayerComponent
1418
{
1519
private bool GoingHome;
1620
private DateTime LastCalledHomeCommand;
@@ -21,17 +25,17 @@ public class HomePlayer : RocketPlayerComponent
2125
private bool cangohome;
2226
private Vector3 bedPos;
2327
private byte bedRot;
24-
private RocketPlayer p;
28+
private UnturnedPlayer p;
2529

2630
private void Load()
2731
{
2832
this.GoingHome = false;
2933
this.cangohome = false;
3034
}
31-
public void GoHome(Vector3 bedPos, byte bedRot, RocketPlayer player)
35+
public void GoHome(Vector3 bedPos, byte bedRot, UnturnedPlayer player)
3236
{
33-
this.waitrestricted = HomeCommand.Instance.Configuration.TeleportWait;
34-
this.movementrestricted = HomeCommand.Instance.Configuration.MovementRestriction;
37+
this.waitrestricted = HomeCommand.Instance.Configuration.Instance.TeleportWait;
38+
this.movementrestricted = HomeCommand.Instance.Configuration.Instance.MovementRestriction;
3539
this.p = player;
3640
this.bedPos = Vector3.up + bedPos;
3741
this.bedRot = bedRot;
@@ -53,15 +57,16 @@ public void GoHome(Vector3 bedPos, byte bedRot, RocketPlayer player)
5357
else
5458
{
5559
// Either not an admin or they don't get special wait restrictions.
56-
List<Rocket.Core.Permissions.Group> hg = player.GetGroups(true);
60+
List<RocketPermissionsGroup> hg = R.Permissions.GetGroups(player, true);
5761
if (hg.Count <= 0)
5862
{
5963
Logger.Log("There was an error as a player has no groups!");
6064
}
6165
byte[] time2 = new byte[hg.Count];
6266
for (byte g=0;g<hg.Count;g++)
6367
{
64-
Rocket.Core.Permissions.Group hgr = hg[g];
68+
69+
RocketPermissionsGroup hgr = hg[g];
6570
HomeCommand.Instance.WaitGroups.TryGetValue(hgr.Id, out time2[g]);
6671
if (time2[g] <= 0)
6772
{
@@ -76,11 +81,11 @@ public void GoHome(Vector3 bedPos, byte bedRot, RocketPlayer player)
7681
if (this.movementrestricted)
7782
{
7883
this.LastCalledHomePos = this.transform.position;
79-
RocketChat.Say(player, String.Format(HomeCommand.Instance.Configuration.FoundBedWaitNoMoveMsg, player.CharacterName, this.waittime));
84+
UnturnedChat.Say(player, String.Format(HomeCommand.Instance.Configuration.Instance.FoundBedWaitNoMoveMsg, player.CharacterName, this.waittime));
8085
}
8186
else
8287
{
83-
RocketChat.Say(player, String.Format(HomeCommand.Instance.Configuration.FoundBedNowWaitMsg, player.CharacterName, this.waittime));
88+
UnturnedChat.Say(player, String.Format(HomeCommand.Instance.Configuration.Instance.FoundBedNowWaitMsg, player.CharacterName, this.waittime));
8489
}
8590
}
8691
else
@@ -93,7 +98,7 @@ public void GoHome(Vector3 bedPos, byte bedRot, RocketPlayer player)
9398
private void DoGoHome()
9499
{
95100
if (!this.cangohome) return;
96-
RocketChat.Say(this.p, String.Format(HomeCommand.Instance.Configuration.TeleportMsg, this.p.CharacterName));
101+
UnturnedChat.Say(this.p, String.Format(HomeCommand.Instance.Configuration.Instance.TeleportMsg, this.p.CharacterName));
97102
this.p.Teleport(this.bedPos, this.bedRot);
98103
this.cangohome = false;
99104
this.GoingHome = false;
@@ -104,7 +109,7 @@ public void FixedUpdate()
104109
if (this.p.Dead)
105110
{
106111
// Abort teleport, they died.
107-
RocketChat.Say(this.p, String.Format(HomeCommand.Instance.Configuration.NoTeleportDiedMsg, this.p.CharacterName));
112+
UnturnedChat.Say(this.p, String.Format(HomeCommand.Instance.Configuration.Instance.NoTeleportDiedMsg, this.p.CharacterName));
108113
this.GoingHome = false;
109114
this.cangohome = false;
110115
return;
@@ -114,7 +119,7 @@ public void FixedUpdate()
114119
if (Vector3.Distance(this.p.Position, this.LastCalledHomePos) > 0.1)
115120
{
116121
// Abort teleport, they moved.
117-
RocketChat.Say(this.p, String.Format(HomeCommand.Instance.Configuration.UnableMoveSinceMoveMsg, this.p.CharacterName));
122+
UnturnedChat.Say(this.p, String.Format(HomeCommand.Instance.Configuration.Instance.UnableMoveSinceMoveMsg, this.p.CharacterName));
118123
this.GoingHome = false;
119124
this.cangohome = false;
120125
return;

Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.1.1.3")]
36-
[assembly: AssemblyFileVersion("2.1.1.2")]
35+
[assembly: AssemblyVersion("2.2.0.0")]
36+
[assembly: AssemblyFileVersion("2.2.0.0")]

ZaupHomeCommand.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
using System;
22
using System.Collections.Generic;
3+
34
using Rocket.API;
5+
using Rocket.Core.Plugins;
46
using Rocket.Unturned;
7+
using Rocket.Unturned.Chat;
58
using Rocket.Unturned.Plugins;
69
using Rocket.Unturned.Player;
710
using SDG.Unturned;
@@ -20,31 +23,31 @@ public class HomeCommand : RocketPlugin<HomeCommandConfiguration>
2023
protected override void Load()
2124
{
2225
HomeCommand.Instance = this;
23-
if (Loaded)
26+
if (this.State == PluginState.Loaded)
2427
{
25-
foreach (HomeGroup hg in this.Configuration.WaitGroups)
28+
foreach (HomeGroup hg in this.Configuration.Instance.WaitGroups)
2629
{
2730
WaitGroups.Add(hg.Id, hg.Wait);
2831
}
2932
}
3033
}
3134
// All we are doing here is checking the config to see if anything like restricted movement or time restriction is enforced.
32-
public static object[] CheckConfig(RocketPlayer player)
35+
public static object[] CheckConfig(UnturnedPlayer player)
3336
{
3437

3538
object[] returnv = { false, null, null };
3639
// First check if command is enabled.
37-
if (!HomeCommand.Instance.Configuration.Enabled)
40+
if (!HomeCommand.Instance.Configuration.Instance.Enabled)
3841
{
3942
// Command disabled.
40-
RocketChat.Say(player, String.Format(HomeCommand.Instance.Configuration.DisabledMsg, player.CharacterName));
43+
UnturnedChat.Say(player, String.Format(HomeCommand.Instance.Configuration.Instance.DisabledMsg, player.CharacterName));
4144
return returnv;
4245
}
4346
// It is enabled, but are they in a vehicle?
4447
if (player.Stance == EPlayerStance.DRIVING || player.Stance == EPlayerStance.SITTING)
4548
{
4649
// They are in a vehicle.
47-
RocketChat.Say(player, String.Format(HomeCommand.Instance.Configuration.NoVehicleMsg, player.CharacterName));
50+
UnturnedChat.Say(player, String.Format(HomeCommand.Instance.Configuration.Instance.NoVehicleMsg, player.CharacterName));
4851
return returnv;
4952
}
5053
// They aren't in a vehicle, so check if they have a bed.
@@ -53,7 +56,7 @@ public static object[] CheckConfig(RocketPlayer player)
5356
if (!BarricadeManager.tryGetBed(player.CSteamID, out bedPos, out bedRot))
5457
{
5558
// Bed not found.
56-
RocketChat.Say(player, String.Format(HomeCommand.Instance.Configuration.NoBedMsg, player.CharacterName));
59+
UnturnedChat.Say(player, String.Format(HomeCommand.Instance.Configuration.Instance.NoBedMsg, player.CharacterName));
5760
return returnv;
5861
}
5962
object[] returnv2 = { true, bedPos, bedRot };

ZaupHomeCommandConfiguration.cs

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
using Rocket.API;
2-
using Rocket.Core;
3-
using System;
1+
using System;
42
using System.Collections.Generic;
53

4+
using Rocket.API;
5+
using Rocket.Core;
6+
67
namespace Zamirathe_HomeCommand
78
{
89
public class HomeCommandConfiguration : IRocketPluginConfiguration
@@ -20,31 +21,25 @@ public class HomeCommandConfiguration : IRocketPluginConfiguration
2021
public string UnableMoveSinceMoveMsg;
2122
public string NoTeleportDiedMsg;
2223

23-
public IRocketPluginConfiguration DefaultConfiguration
24+
public HomeCommandConfiguration()
2425
{
25-
get
26-
{
27-
return new HomeCommandConfiguration()
28-
{
29-
Enabled = true,
30-
DisabledMsg = "I'm sorry {0}, but the home command has been disabled.",
31-
NoBedMsg = "I'm sorry {0}, but I could not find your bed.",
32-
NoVehicleMsg = "I'm sorry {0}, but you can't be teleported while inside a vehicle.",
33-
TeleportWait = false,
34-
WaitGroups = new List<HomeGroup>() {
35-
new HomeGroup{Id = "all", Wait = 5},
36-
new HomeGroup{Id = "admin", Wait = 0},
37-
new HomeGroup{Id = "moderator", Wait = 3},
38-
new HomeGroup{Id = "default", Wait = 5}
39-
},
40-
TeleportMsg = "You were sent back to your bed.",
41-
FoundBedNowWaitMsg = "I have located your bed {0}, please wait for {1} seconds to be teleported.",
42-
MovementRestriction = false,
43-
FoundBedWaitNoMoveMsg = "I have located your bed {0}, now don't move for {1} seconds while I prepare you for teleport.",
44-
UnableMoveSinceMoveMsg = "I'm sorry {0}, but you moved. I am unable to teleport you.",
45-
NoTeleportDiedMsg = "Sorry {0}, unable to finish home teleport as you died."
46-
};
47-
}
26+
Enabled = true;
27+
DisabledMsg = "I'm sorry {0}, but the home command has been disabled.";
28+
NoBedMsg = "I'm sorry {0}, but I could not find your bed.";
29+
NoVehicleMsg = "I'm sorry {0}, but you can't be teleported while inside a vehicle.";
30+
TeleportWait = false;
31+
WaitGroups = new List<HomeGroup>() {
32+
new HomeGroup{Id = "all", Wait = 5},
33+
new HomeGroup{Id = "admin", Wait = 0},
34+
new HomeGroup{Id = "moderator", Wait = 3},
35+
new HomeGroup{Id = "default", Wait = 5}
36+
};
37+
TeleportMsg = "You were sent back to your bed.";
38+
FoundBedNowWaitMsg = "I have located your bed {0}, please wait for {1} seconds to be teleported.";
39+
MovementRestriction = false;
40+
FoundBedWaitNoMoveMsg = "I have located your bed {0}, now don't move for {1} seconds while I prepare you for teleport.";
41+
UnableMoveSinceMoveMsg = "I'm sorry {0}, but you moved. I am unable to teleport you.";
42+
NoTeleportDiedMsg = "Sorry {0}, unable to finish home teleport as you died.";
4843
}
4944
}
5045
}

lib/Assembly-CSharp-firstpass.dll

0 Bytes
Binary file not shown.

lib/Assembly-CSharp.dll

62.5 KB
Binary file not shown.

lib/Rocket.API.dll

5 KB
Binary file not shown.

lib/Rocket.Core.dll

-6.5 KB
Binary file not shown.

lib/Rocket.Unturned.dll

-2 KB
Binary file not shown.

0 commit comments

Comments
 (0)