本文整理匯總了C#中TShockAPI.GetDataHandlerArgs類的典型用法代碼示例。如果您正苦於以下問題:C# GetDataHandlerArgs類的具體用法?C# GetDataHandlerArgs怎麽用?C# GetDataHandlerArgs使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
GetDataHandlerArgs類屬於TShockAPI命名空間,在下文中一共展示了GetDataHandlerArgs類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: HandlePlayerHp
public static bool HandlePlayerHp(GetDataHandlerArgs args)
{
var plr = args.Data.ReadInt8();
var cur = args.Data.ReadInt16();
var max = args.Data.ReadInt16();
if (OnPlayerHP(plr, cur, max) || cur <= 0 || max <= 0 || args.Player.IgnoreSSCPackets)
return true;
if (max > TShock.Config.MaxHP && !args.Player.Group.HasPermission(Permissions.ignorehp))
{
args.Player.Disable("Maximum HP beyond limit", DisableFlags.WriteToLogAndConsole);
return true;
}
if (args.Player.IsLoggedIn)
{
args.Player.TPlayer.statLife = cur;
args.Player.TPlayer.statLifeMax = max;
args.Player.PlayerData.maxHealth = max;
}
if (args.Player.GodMode && (cur < max))
{
args.Player.Heal(args.TPlayer.statLifeMax2);
}
return false;
}
示例2: HandleSync
private static bool HandleSync(GetDataHandlerArgs args)
{
return TShock.Config.EnableAntiLag;
}
示例3: HandleTileKill
private static bool HandleTileKill(GetDataHandlerArgs args)
{
int tilex = args.Data.ReadInt32();
int tiley = args.Data.ReadInt32();
if (tilex < 0 || tilex >= Main.maxTilesX || tiley < 0 || tiley >= Main.maxTilesY)
return false;
if (Main.tile[tilex, tiley].type != 0x15 && (!Tools.MaxChests() && Main.tile[tilex, tiley].type != 0)) //Chest
{
Log.Debug(string.Format("TileKill(TileXY:{0}_{1}, Type:{2})",
tilex, tiley, Main.tile[tilex, tiley].type));
Tools.ForceKick(args.Player, string.Format(TShock.Config.TileKillAbuseReason, Main.tile[tilex, tiley].type));
return true;
}
if (!args.Player.Group.HasPermission(Permissions.canbuild))
{
args.Player.SendMessage("You do not have permission to build!", Color.Red);
args.Player.SendTileSquare(tilex, tiley);
return true;
}
if (!args.Player.Group.HasPermission(Permissions.editspawn) && !TShock.Regions.CanBuild(tilex, tiley, args.Player) && TShock.Regions.InArea(tilex, tiley))
{
args.Player.SendMessage("Region protected from changes.", Color.Red);
args.Player.SendTileSquare(tilex, tiley);
return true;
}
if (TShock.Config.DisableBuild)
{
if (!args.Player.Group.HasPermission(Permissions.editspawn))
{
args.Player.SendMessage("World protected from changes.", Color.Red);
args.Player.SendTileSquare(tilex, tiley);
return true;
}
}
if (TShock.Config.SpawnProtection)
{
if (!args.Player.Group.HasPermission(Permissions.editspawn))
{
var flag = TShock.CheckSpawn(tilex, tiley);
if (flag)
{
args.Player.SendMessage("Spawn protected from changes.", Color.Red);
args.Player.SendTileSquare(tilex, tiley);
return true;
}
}
}
return false;
}
示例4: HandleSendSection
private static bool HandleSendSection(GetDataHandlerArgs args)
{
return Tools.HandleGriefer(args.Player, TShock.Config.SendSectionAbuseReason);
}
示例5: HandleSign
private static bool HandleSign(GetDataHandlerArgs args)
{
var id = args.Data.ReadInt16();
var x = args.Data.ReadInt32();
var y = args.Data.ReadInt32();
if (TShock.Config.RangeChecks && ((Math.Abs(args.Player.TileX - x) > 32) || (Math.Abs(args.Player.TileY - y) > 32)))
{
return Tools.HandleGriefer(args.Player, TShock.Config.RangeCheckBanReason);
}
return false;
}
示例6: HandlePlayerKillMe
private static bool HandlePlayerKillMe(GetDataHandlerArgs args)
{
byte id = args.Data.ReadInt8();
if (id != args.Player.Index)
{
return Tools.HandleGriefer(args.Player, TShock.Config.KillMeAbuseReason);
}
args.Player.LastDeath = DateTime.Now;
if (args.Player.Difficulty != 2)
args.Player.ForceSpawn = true;
return false;
}
示例7: HandlePlayerUpdate
private static bool HandlePlayerUpdate(GetDataHandlerArgs args)
{
byte plr = args.Data.ReadInt8();
byte control = args.Data.ReadInt8();
byte item = args.Data.ReadInt8();
float posx = args.Data.ReadSingle();
float posy = args.Data.ReadSingle();
float velx = args.Data.ReadSingle();
float vely = args.Data.ReadSingle();
if (Main.verboseNetplay)
Debug.WriteLine("Update: {{{0},{1}}} {{{2}, {3}}}", (int)posx, (int)posy, (int)velx, (int)vely);
if (plr != args.Player.Index)
{
return Tools.HandleGriefer(args.Player, TShock.Config.UpdatePlayerAbuseReason);
}
if (item < 0 || item >= args.TPlayer.inventory.Length)
{
Tools.HandleGriefer(args.Player, TShock.Config.UpdatePlayerAbuseReason);
return true;
}
return false;
}
示例8: HandleDoorUse
private static bool HandleDoorUse(GetDataHandlerArgs args)
{
byte type = (byte)args.Data.ReadByte();
short x = args.Data.ReadInt16();
short y = args.Data.ReadInt16();
args.Data.ReadByte(); //Ignore direction
if (x >= Main.maxTilesX || y >= Main.maxTilesY || x < 0 || y < 0) // Check for out of range
{
return true;
}
if (type < 0 || type > 5)
{
return true;
}
ushort tileType = Main.tile[x, y].type;
if (tileType != TileID.ClosedDoor && tileType != TileID.OpenDoor
&& tileType != TileID.TallGateClosed && tileType != TileID.TallGateOpen
&& tileType != TileID.TrapdoorClosed && tileType != TileID.TrapdoorOpen)
{
return true;
}
return false;
}
示例9: HandleGetSection
private static bool HandleGetSection(GetDataHandlerArgs args)
{
if (args.Player.RequestedSection)
return true;
args.Player.RequestedSection = true;
if (String.IsNullOrEmpty(args.Player.Name))
{
TShock.Utils.ForceKick(args.Player, "Blank name.", true);
return true;
}
if (!args.Player.Group.HasPermission(Permissions.ignorestackhackdetection))
{
TShock.HackedInventory(args.Player);
}
if (TShock.Utils.ActivePlayers() + 1 > TShock.Config.MaxSlots &&
!args.Player.Group.HasPermission(Permissions.reservedslot))
{
TShock.Utils.ForceKick(args.Player, TShock.Config.ServerFullReason, true);
return true;
}
NetMessage.SendData((int) PacketTypes.TimeSet, -1, -1, "", Main.dayTime ? 1 : 0, (int)Main.time, Main.sunModY, Main.moonModY);
return false;
}
示例10: HandleCompleteAnglerQuest
private static bool HandleCompleteAnglerQuest(GetDataHandlerArgs args)
{
// Since packet 76 is NEVER sent to us, we actually have to rely on this to get the true count
args.TPlayer.anglerQuestsFinished++;
return false;
}
示例11: HandleConnecting
private static bool HandleConnecting(GetDataHandlerArgs args)
{
var user = TShock.Users.GetUserByName(args.Player.Name);
if (user != null && !TShock.Config.DisableUUIDLogin)
{
if (user.UUID == args.Player.UUID)
{
if (args.Player.State == 1)
args.Player.State = 2;
NetMessage.SendData((int)PacketTypes.WorldInfo, args.Player.Index);
args.Player.PlayerData = TShock.CharacterDB.GetPlayerData(args.Player, user.ID);
var group = TShock.Utils.GetGroup(user.Group);
if (Main.ServerSideCharacter)
{
if (!group.HasPermission(Permissions.bypassssc))
{
args.Player.PlayerData.RestoreCharacter(args.Player);
}
}
args.Player.LoginFailsBySsi = false;
if (group.HasPermission(Permissions.ignorestackhackdetection))
args.Player.IgnoreActionsForCheating = "none";
if (group.HasPermission(Permissions.usebanneditem))
args.Player.IgnoreActionsForDisabledArmor = "none";
args.Player.Group = group;
args.Player.tempGroup = null;
args.Player.User = user;
args.Player.IsLoggedIn = true;
args.Player.IgnoreActionsForInventory = "none";
if (!args.Player.IgnoreActionsForClearingTrashCan && Main.ServerSideCharacter)
{
args.Player.PlayerData.CopyCharacter(args.Player);
TShock.CharacterDB.InsertPlayerData(args.Player);
}
args.Player.SendSuccessMessage("Authenticated as " + user.Name + " successfully.");
TShock.Log.ConsoleInfo(args.Player.Name + " authenticated successfully as user " + args.Player.Name + ".");
Hooks.PlayerHooks.OnPlayerPostLogin(args.Player);
return true;
}
}
else if (user != null && !TShock.Config.DisableLoginBeforeJoin)
{
args.Player.RequiresPassword = true;
NetMessage.SendData((int) PacketTypes.PasswordRequired, args.Player.Index);
return true;
}
else if (!string.IsNullOrEmpty(TShock.Config.ServerPassword))
{
args.Player.RequiresPassword = true;
NetMessage.SendData((int) PacketTypes.PasswordRequired, args.Player.Index);
return true;
}
if (args.Player.State == 1)
args.Player.State = 2;
NetMessage.SendData((int) PacketTypes.WorldInfo, args.Player.Index);
return true;
}
示例12: HandleChestOpen
private static bool HandleChestOpen(GetDataHandlerArgs args)
{
var x = args.Data.ReadInt16();
var y = args.Data.ReadInt16();
if (OnChestOpen(x, y, args.Player))
return true;
if (TShock.CheckIgnores(args.Player))
{
return true;
}
if (TShock.CheckRangePermission(args.Player, x, y))
{
return true;
}
if (TShock.CheckTilePermission(args.Player, x, y) && TShock.Config.RegionProtectChests)
{
return true;
}
int id = Chest.FindChest(x, y);
args.Player.ActiveChest = id;
return false;
}
示例13: HandleChestItem
private static bool HandleChestItem(GetDataHandlerArgs args)
{
var id = args.Data.ReadInt16();
var slot = args.Data.ReadInt8();
var stacks = args.Data.ReadInt16();
var prefix = args.Data.ReadInt8();
var type = args.Data.ReadInt16();
if (OnChestItemChange(id, slot, stacks, prefix, type))
return true;
if (args.TPlayer.chest != id)
{
return false;
}
if (TShock.CheckIgnores(args.Player))
{
args.Player.SendData(PacketTypes.ChestItem, "", id, slot);
return true;
}
Item item = new Item();
item.netDefaults(type);
if (stacks > item.maxStack || TShock.Itembans.ItemIsBanned(item.name, args.Player))
{
return false;
}
if (TShock.CheckTilePermission(args.Player, Main.chest[id].x, Main.chest[id].y) && TShock.Config.RegionProtectChests)
{
return false;
}
if (TShock.CheckRangePermission(args.Player, Main.chest[id].x, Main.chest[id].y))
{
return false;
}
return false;
}
示例14: HandleChestActive
private static bool HandleChestActive(GetDataHandlerArgs args)
{
//chest ID
var id = args.Data.ReadInt16();
//chest x
var x = args.Data.ReadInt16();
//chest y
var y = args.Data.ReadInt16();
//chest name length
var nameLen = args.Data.ReadInt8();
if (nameLen != 0 && nameLen <= 20)
args.Data.ReadString(); // Ignore the name
args.Player.ActiveChest = id;
if (TShock.CheckTilePermission(args.Player, x, y) && TShock.Config.RegionProtectChests)
{
args.Player.SendData(PacketTypes.ChestOpen, "", -1);
return true;
}
return false;
}
示例15: HandlePlayerDamage
private static bool HandlePlayerDamage(GetDataHandlerArgs args)
{
byte playerid = args.Data.ReadInt8();
if (TShock.Players[playerid] == null)
return true;
return !TShock.Players[playerid].TPlayer.hostile;
}