Skip to content

Commit

Permalink
Fixed zombieignore patch file, i added a try and catch, because if pl…
Browse files Browse the repository at this point in the history
…ayer don't have the compontent, just set it in true

Added setattachment [id/name item]
Added fly [player] or empty (you)
  • Loading branch information
TH3AL3X committed Mar 31, 2024
1 parent f13fba6 commit 5898cad
Show file tree
Hide file tree
Showing 63 changed files with 493 additions and 67 deletions.
7 changes: 6 additions & 1 deletion default/lang_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -312,5 +312,10 @@
"CHECKOWNER": "Owner of this SteamID64: {0}",
"CHECKOWNER_LOOKING_NONE": "You're not looking to anything",
"IGNOREZOMBIES": "Now zombies are {0} you",
"IGNOREZOMBIES_TOPLAYER": "Now zombies are {0} player {1}"
"IGNOREZOMBIES_TOPLAYER": "Now zombies are {0} player {1}",
"FLY": "Now you {0} fly",
"FLY_TOPLAYER": "Now you {0} fly to player {1}",
"FLY_SPEED_CHANGED": "Your speed has been changed to {0}",
"SET_ATTACHMENT": "You added an attachment to the weapon",
"SET_ATTACHMENT_FAIL": "Impossible to add this attachment to the weaoon"
}
7 changes: 6 additions & 1 deletion default/lang_es.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,5 +279,10 @@
"CHECKOWNER": "Owner of this: {0}",
"CHECKOWNER_LOOKING_NONE": "You're not looking to anything",
"IGNOREZOMBIES": "Now zombies are {0} you",
"IGNOREZOMBIES_TOPLAYER": "Now zombies are {0} player {1}"
"IGNOREZOMBIES_TOPLAYER": "Now zombies are {0} player {1}",
"FLY": "Now you {0} fly",
"FLY_TOPLAYER": "Now you {0} fly to player {1}",
"FLY_SPEED_CHANGED": "Your speed has been changed to {0}",
"SET_ATTACHMENT": "You added an attachment to the weapon",
"SET_ATTACHMENT_FAIL": "Impossible to add this attachment to the weaoon"
}
7 changes: 6 additions & 1 deletion default/lang_pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,5 +278,10 @@
"CHECKOWNER": "Owner of this: {0}",
"CHECKOWNER_LOOKING_NONE": "You're not looking to anything",
"IGNOREZOMBIES": "Now zombies are {0} you",
"IGNOREZOMBIES_TOPLAYER": "Now zombies are {0} player {1}"
"IGNOREZOMBIES_TOPLAYER": "Now zombies are {0} player {1}",
"FLY": "Now you {0} fly",
"FLY_TOPLAYER": "Now you {0} fly to player {1}",
"FLY_SPEED_CHANGED": "Your speed has been changed to {0}",
"SET_ATTACHMENT": "You added an attachment to the weapon",
"SET_ATTACHMENT_FAIL": "Impossible to add this attachment to the weaoon"
}
7 changes: 6 additions & 1 deletion default/lang_ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,5 +281,10 @@
"CHECKOWNER": "Owner of this: {0}",
"CHECKOWNER_LOOKING_NONE": "You're not looking to anything",
"IGNOREZOMBIES": "Now zombies are {0} you",
"IGNOREZOMBIES_TOPLAYER": "Now zombies are {0} player {1}"
"IGNOREZOMBIES_TOPLAYER": "Now zombies are {0} player {1}",
"FLY": "Now you {0} fly",
"FLY_TOPLAYER": "Now you {0} fly to player {1}",
"FLY_SPEED_CHANGED": "Your speed has been changed to {0}",
"SET_ATTACHMENT": "You added an attachment to the weapon",
"SET_ATTACHMENT_FAIL": "Impossible to add this attachment to the weaoon"
}
1 change: 0 additions & 1 deletion src/Commands/CommandAmmo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Essentials.Api;
using Essentials.Api.Command;
using Essentials.Api.Command;
using Essentials.Api.Command.Source;
using Essentials.Api.Unturned;
using Essentials.I18n;
Expand Down
135 changes: 135 additions & 0 deletions src/Commands/CommandAttachment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#region License
/*
* This file is part of uEssentials project.
* https://uessentials.github.io/
*
* Copyright (C) 2015-2024 Terror
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#endregion

using System;
using System.Linq;
using System.Numerics;
using Essentials.Api;
using Essentials.Api.Command;
using Essentials.Api.Command.Source;
using Essentials.Api.Unturned;
using Essentials.Common;
using Essentials.Compatibility;
using Essentials.Components.Player;
using Essentials.Event.Handling;
using Essentials.I18n;
using HarmonyLib;
using Rocket.API;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Player;
using SDG.Framework.Utilities;
using SDG.Unturned;
using UnityEngine;

namespace Essentials.Commands
{
[CommandInfo(
Name = "setattachment",
Usage = "[attachment name/id]",
Description = "Add attachment to a weapon",
Aliases = new[] { "sments" },
AllowedSource = AllowedSource.PLAYER,
MinArgs = 1,
MaxArgs = 1
)]
// Another copy from shimmytools, i only changed the if else if... to a switch, idk what he doing
public class CommandAttachment : EssCommand
{
readonly static EItemType[] Types = new EItemType[] { EItemType.BARREL, EItemType.GRIP, EItemType.MAGAZINE, EItemType.SIGHT, EItemType.TACTICAL };
public override CommandResult OnExecute(ICommandSource src, ICommandArgs args)
{
var Player = src.ToPlayer();

if (args.Length > 0)
{
if (Player.Equipment.state == null || Player.Equipment.state.Length < 12 || Player.Equipment.asset == null || Player.Equipment.asset.type != EItemType.GUN)
return CommandResult.LangError("SET_ATTACHMENT_FAIL");

ItemAsset Item = null;

if (ushort.TryParse(args[0].ToString(), out ushort ItemID))
{
Asset SelectAsset = Assets.find(EAssetType.ITEM, ItemID);
if (SelectAsset != null && typeof(ItemAsset).IsAssignableFrom(SelectAsset.GetType()) && Types.Contains(((ItemAsset)SelectAsset).type))
{
Item = (ItemAsset)SelectAsset;
}
}

if (Item == null)
{
ItemAsset[] Ast = Assets.find(EAssetType.ITEM).Where(x => typeof(ItemAsset).IsAssignableFrom(x.GetType()) &&

Check warning on line 81 in src/Commands/CommandAttachment.cs

View workflow job for this annotation

GitHub Actions / build

'Assets.find(EAssetType)' is obsolete: 'Please use the method which takes a List instead.'
Types.Contains(((ItemAsset)x).type) &&
((ItemAsset)x).itemName.ToLower().Contains(args[0].ToString().ToLower()))
.Cast<ItemAsset>()
.ToArray();
if (Ast.Length != 0) Item = Ast[0];
}

if (Item != null)
{
byte pos = 255;

switch (Item.type)
{
case EItemType.SIGHT:
pos = 0;
break;
case EItemType.TACTICAL:
pos = 2;
break;
case EItemType.GRIP:
pos = 4;
break;
case EItemType.BARREL:
pos = 6;
break;
case EItemType.MAGAZINE:
pos = 8;
break;
}

if (pos == 255)
return CommandResult.LangError("SET_ATTACHMENT_FAIL");

byte[] ID = BitConverter.GetBytes(Item.id);

Array.Copy(ID, 0, Player.Equipment.state, pos, 2);

Player.Equipment.sendUpdateState();
EssLang.Send(src, "SET_ATTACHMENT");
}
else
{
return CommandResult.LangError("SET_ATTACHMENT_FAIL");
}
}
else
{
return CommandResult.ShowUsage();
}

return CommandResult.Success();
}
}
}
2 changes: 1 addition & 1 deletion src/Commands/CommandBack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* This file is part of uEssentials project.
* https://uessentials.github.io/
*
* Copyright (C) 2015-2018 leonardosnt
* Copyright (C) 2015-2024 Terror
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/CommandBoom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* This file is part of uEssentials project.
* https://uessentials.github.io/
*
* Copyright (C) 2015-2018 leonardosnt
* Copyright (C) 2015-2024 Terror
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/CommandCheckowner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* This file is part of uEssentials project.
* https://uessentials.github.io/
*
* Copyright (C) 2015-2018 leonardosnt
* Copyright (C) 2015-2024 Terror
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/CommandClearInventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This file is part of uEssentials project.
* https://uessentials.github.io/
*
* Copyright (C) 2015-2018 leonardosnt
* Copyright (C) 2015-2024 Terror
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/CommandDestroy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This file is part of uEssentials project.
* https://uessentials.github.io/
*
* Copyright (C) 2015-2018 leonardosnt
* Copyright (C) 2015-2024 Terror
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/CommandEssentials.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* This file is part of uEssentials project.
* https://uessentials.github.io/
*
* Copyright (C) 2015-2018 leonardosnt
* Copyright (C) 2015-2024 Terror
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/CommandExperience.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* This file is part of uEssentials project.
* https://uessentials.github.io/
*
* Copyright (C) 2015-2018 leonardosnt
* Copyright (C) 2015-2024 Terror
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
52 changes: 48 additions & 4 deletions src/Commands/CommandFly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* This file is part of uEssentials project.
* https://uessentials.github.io/
*
* Copyright (C) 2015-2018 leonardosnt
* Copyright (C) 2015-2024 Terror
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -23,6 +23,7 @@

using System;
using System.Linq;
using System.Numerics;
using Essentials.Api;
using Essentials.Api.Command;
using Essentials.Api.Command.Source;
Expand All @@ -47,16 +48,59 @@ namespace Essentials.Commands
Description = "Fly like a bird",
AllowedSource = AllowedSource.PLAYER,
MinArgs = 0,
MaxArgs = 0
MaxArgs = 1
)]
public class CommandFly : EssCommand
{

public override CommandResult OnExecute(ICommandSource src, ICommandArgs args)
{
var player = src.ToPlayer();
if (args.Length > 0)
{
if (!src.HasPermission($"{Permission}.other"))
{
return CommandResult.NoPermission($"{Permission}.other");
}

if (!UPlayer.TryGet(args[0].ToString(), out var player))
{
return CommandResult.LangError("PLAYER_NOT_FOUND", args[0]);
}

var component_to_player = player.GetComponent<FlyPlayer>() ?? player.AddComponent<FlyPlayer>();

if (component_to_player.session)
{
EssLang.Send(src, "FLY_TOPLAYER", "disabled", player.DisplayName);
player.RemoveComponent<FlyPlayer>();
}
else
{
component_to_player.session = true;
EssLang.Send(src, "FLY_TOPLAYER", "enabled", player.DisplayName);
component_to_player.SetReady(player);
}
}
else
{
var player = src.ToPlayer();

var component = player.GetComponent<FlyPlayer>() ?? player.AddComponent<FlyPlayer>();

if (component.session)
{
EssLang.Send(src, "FLY", "disabled");
player.RemoveComponent<FlyPlayer>();
}
else
{
component.session = true;
EssLang.Send(src, "FLY", "enabled");
component.SetReady(player);
}
}
return CommandResult.Success();
}
}


}
2 changes: 1 addition & 1 deletion src/Commands/CommandFreecam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* This file is part of uEssentials project.
* https://uessentials.github.io/
*
* Copyright (C) 2015-2018 leonardosnt
* Copyright (C) 2015-2024 Terror
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/CommandFreeze.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* This file is part of uEssentials project.
* https://uessentials.github.io/
*
* Copyright (C) 2015-2018 leonardosnt
* Copyright (C) 2015-2024 Terror
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/CommandGoToBed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* This file is part of uEssentials project.
* https://uessentials.github.io/
*
* Copyright (C) 2015-2018 leonardosnt
* Copyright (C) 2015-2024 Terror
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/CommandGravity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* This file is part of uEssentials project.
* https://uessentials.github.io/
*
* Copyright (C) 2015-2018 leonardosnt
* Copyright (C) 2015-2024 Terror
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/CommandHome.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* This file is part of uEssentials project.
* https://uessentials.github.io/
*
* Copyright (C) 2015-2018 leonardosnt
* Copyright (C) 2015-2024 Terror
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
Loading

0 comments on commit 5898cad

Please sign in to comment.