public void Search(IPlayer player, List <AssetLocation> missing, List <AssetLocation> notmissing, string type = "Block", bool DL = false) { for (int i = 0; i < missing.Count; i++) { List <int> distance = new List <int>(); for (int j = 0; j < notmissing.Count; j++) { if (missing[i] == null || notmissing[j] == null) { distance.Add(999999999); continue; } if (DL) { distance.Add(missing[i].ToString().Replace(missing[i].Domain + ":", "").ComputeDLDistance(notmissing[j].ToString().Replace(notmissing[j].Domain + ":", ""))); } else { distance.Add(missing[i].ToString().Replace(missing[i].Domain + ":", "").ComputeDistance(notmissing[j].ToString().Replace(notmissing[j].Domain + ":", ""))); } } int index = distance.IndexOfMin(); if (!MostLikely.ContainsValue(notmissing[index])) { MostLikely.Add(missing[i], notmissing[index]); notmissing.RemoveAt(index); } sapi.SendMessage(player, GlobalConstants.InfoLogChatGroup, "Finding Closest " + type + " Matches... " + Math.Round(i / (float)missing.Count * 100, 2) + "%", EnumChatType.Notification); } sapi.SendMessage(player, GlobalConstants.InfoLogChatGroup, "Finding Closest " + type + " Matches... 100%", EnumChatType.Notification); }
public override void CallHandler(IPlayer player, int groupId, CmdArgs args) { foreach (var mod in _api.ModLoader.Mods) { var systems = args.PopWord() == "systems" ? $" Systems:\n {string.Join(" \n", mod.Systems)}" : string.Empty; var message = $"{mod.FileName}:{mod.SourcePath} ({mod.SourceType}) {systems}"; _api.SendMessage(player, GlobalConstants.InfoLogChatGroup, message, EnumChatType.OwnMessage); } }
public override void CallHandler(IPlayer player, int groupId, CmdArgs args) { var setAmount = args.PopFloat( ); var hungerBehavior = player.Entity.GetBehavior <EntityBehaviorHunger>(); if (setAmount.HasValue) { hungerBehavior.Saturation = setAmount.Value; } else { _api.SendMessage(player, 0, $"Saturation:{hungerBehavior?.Saturation}", EnumChatType.Notification); } }
public void MeCommand(IServerPlayer player, int groupId, CmdArgs args) { if (args == null || args.Length < 1) { api.SendMessage(player, GlobalConstants.CurrentChatGroup, Lang.Get("Syntax: /me msg"), EnumChatType.OwnMessage); return; } string msg = ""; for (int i = 0; i < args.Length; i++) { msg += args[i] + " "; } api.SendMessage(player, GlobalConstants.GeneralChatGroup, player.PlayerName + " " + msg, EnumChatType.OthersMessage); }
public override bool OnBlockInteractStart(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel) { BlockPos blockPos = blockSel.Position; BEOmokTableTop beOmok = (BEOmokTableTop)api.World.BlockAccessor.GetBlockEntity(blockPos); // Continue if the clicked spot is an available space if (beOmok == null || !IsViableSpace(beOmok, blockSel, out int pieceX, out int pieceZ)) { return(true); } // Determine next piece to be placed bool whitesTurn = beOmok.WhitesTurn; int piecesPlayed = beOmok.PiecesPlayed(); // If two player, determine who's playing and whose turn it is before placing a piece if (beOmok.IsTwoPlayer) { // Assign ID if it's a player's first turn if (piecesPlayed == 0) // Assign first player { beOmok.FirstPlayerID = byPlayer.PlayerUID; } else if (piecesPlayed == 1) // Assign second player // If second player is a new player, assign second player, otherwise return { if (byPlayer.PlayerUID != beOmok.FirstPlayerID) { beOmok.SecondPlayerID = byPlayer.PlayerUID; } else { return(true); } } // Return if it's not the player's turn if (!whitesTurn && byPlayer.PlayerUID != beOmok.FirstPlayerID) { return(true); } if (whitesTurn && byPlayer.PlayerUID != beOmok.SecondPlayerID) { return(true); } } if (whitesTurn) { beOmok.PlaceWhitePiece(pieceX, pieceZ); } else { beOmok.PlaceBlackPiece(pieceX, pieceZ); } // Victory Condition Check string victoryText = ""; if (!beOmok.GameIsOver) { victoryText = beOmok.CheckVictoryConditions(); } // Play piece setting sound int random = new Random().Next(1, 3); AssetLocation placeSound = new AssetLocation("game:sounds/block/loosestone" + random); world.PlaySoundAt(placeSound, blockPos.X, blockPos.Y, blockPos.Z, byPlayer, true, 10, 1); if (world.Side == EnumAppSide.Server) { ICoreServerAPI sAPI = (ICoreServerAPI)api; if (victoryText != "") { foreach (IPlayer nearbyPlayer in api.World.GetPlayersAround(blockSel.Position.ToVec3d(), 10, 10)) { sAPI.SendMessage(nearbyPlayer, 0, victoryText, EnumChatType.OwnMessage); } } } beOmok.MarkDirty(true); beOmok.UpdateClients(); return(true); }