Exemple #1
0
        public static void Removediamonds(User user)
        {
            int      count      = 0;
            int      debugcount = 0;
            Vector3i startpos   = user.Position.XYZi - new Vector3i(4, 4, 4);


            foreach (Vector3i posoffset in Vector3i.XYZIter(9))
            {
                debugcount++;
                Vector3i pos = startpos + posoffset;
                if (World.GetBlock(pos).GetType() == typeof(DiamondBlock))
                {
                    World.DeleteBlock(pos);
                    count++;
                }
            }
            ChatUtils.SendMessage(user, "Debug(totalblocks): " + debugcount);
            if (count > 0)
            {
                ChatUtils.SendMessage(user, "Deleted " + count + " Diamondblocks");
            }
            else
            {
                ChatUtils.SendMessage(user, "No Diamonds found!");
            }
        }
Exemple #2
0
        public static void LinkHidden(User user, string item)
        {
            Item x = Item.GetItemByString(user, item);

            if (x != null)
            {
                ChatUtils.SendMessage(user, x.UILink());
            }
        }
        public static void ClearAllergy(User user, string username = "")
        {
            User target = UserManager.FindUserByName(username);

            target = target ?? user;
            target.SetState("allergy", string.Empty);
            ChatUtils.SendMessage(user, "You cleared the allergies of " + target.UILink());
            ChatUtils.SendMessage(target, "Your allergies have been cleared");
        }
Exemple #4
0
 public static void MFly(User user)
 {
     if (!user.IsAdmin && !user.GetState <bool>("Moderator"))//admin/mod only
     {
         ChatUtils.SendMessage(user, "Not Authorized to use this command!");
         return;
     }
     IOUtils.WriteCommandLog(user, "mFly");
     user.Player.RPC("ToggleFly");
 }
Exemple #5
0
        public static void MBan(User user, string banUserIDOrName, string reason = "")
        {
            if (!user.IsAdmin && !user.GetState <bool>("Moderator"))//admin/mod only
            {
                ChatUtils.SendMessage(user, "Not Authorized to use this command!");
                return;
            }

            UserManager.Ban(user, banUserIDOrName, reason);
            IOUtils.WriteCommandLog(user, "mBan", "Banned " + banUserIDOrName);
        }
        public static void SetAllergy(User user, string item, string username = "")
        {
            User target = UserManager.FindUserByName(username);

            target = target ?? user;
            Item x = Item.GetItemByString(user, item);

            if (x != null)
            {
                target.SetState("allergy", x.Type.Name);
                ChatUtils.SendMessage(user, "You made " + target.UILink() + " allergic to " + x.UILink());
                ChatUtils.SendMessage(target, "You are now allergic to " + x.UILink());
            }
        }
Exemple #7
0
 public static void SpawnCustomOres(User user, string force = null)
 {
     if (CustomWorldGen.newworld || (force == "force"))
     {
         DateTime start = DateTime.Now;
         CustomWorldGen.Generate();
         TimeSpan used = DateTime.Now - start;
         ChatUtils.SendMessage(user, "Worldgen finalized. Time spent: " + used.Minutes + ":" + used.Seconds + ":" + used.Milliseconds);
     }
     else
     {
         ChatUtils.SendMessage(user, "This is not a newly generated world. This command should only be run once. You can however force it by entering \"force\" as parameter");
     }
 }
Exemple #8
0
    public override InteractResult OnActRight(InteractionContext context)
    {
        User owner;
        User creator;
        var  currentBlock = context.Player.User.Inventory.Carried.Stacks.First().Item as BlockItem;

        if (currentBlock != null && context.HasBlock && context.Normal != Vector3i.Zero)
        {
            var result = currentBlock.OnActRight(context);
            if (result == InteractResult.Success)
            {
                context.Player.User.Inventory.AddItem(currentBlock);
                return(result);
            }
        }
        else if (context.HasTarget)
        {
            if (context.Target != null)
            {
                if (context.Target is WorldObject)
                {
                    owner = (context.Target as WorldObject).OwnerUser;
                    if (owner != null)
                    {
                        ChatUtils.SendMessage(context.Player, "Owner: " + owner.Name);
                    }
                    else
                    {
                        ChatUtils.SendMessage(context.Player, "Object is unowned");
                    }
                    creator = (context.Target as WorldObject).Creator.User;
                    if (creator != null)
                    {
                        ChatUtils.SendMessage(context.Player, "Creator: " + creator.Name);
                    }
                    else
                    {
                        ChatUtils.SendMessage(context.Player, "No creator");
                    }
                }
            }
            return(InteractResult.Success);
        }

        return(InteractResult.NoOp);
    }
Exemple #9
0
        public static void GlobalRoomFix(User user)
        {
            if (!user.IsAdmin && !user.GetState <bool>("Moderator"))//admin/mod only
            {
                ChatUtils.SendMessage(user, "Not Authorized to use this command!");
                return;
            }

            IOUtils.WriteCommandLog(user, "Roomfix");
            foreach (WorldObject obj in WorldObjectManager.All)
            {
                RoomData.QueueRoomTest(obj.Position3i);
                //Console.WriteLine("Checked " + obj.Name + " at " + obj.Position3i.ToStringLabelled("pos"));
            }
            RoomData.Obj.UpdateRooms();
            ChatUtils.SendMessage(user, "Rooms should be fixed now");
        }
Exemple #10
0
        public static void OpenAuth(User user)
        {
            if (!user.IsAdmin && !user.GetState <bool>("Moderator"))//admin/mod only
            {
                ChatUtils.SendMessage(user, "Not Authorized to use this command!");
                return;
            }
            Deed deed = PropertyManager.GetDeed(user.Position.XZi);

            if (deed != null)
            {
                deed.OpenAuthorizationMenuOn(user.Player);
            }
            else
            {
                ChatUtils.SendMessage(user, "Plot is not claimed!", true);
            }
        }
Exemple #11
0
        public static void testdebug(User user)
        {
            ChatUtils.SendMessage(user, World.ChunksCount.ToString());
            ChatUtils.SendMessage(user, World.GetDepth(user.Position.Round).ToString());
            ChatUtils.SendMessage(user, ("asdf").Color("green"));
            ChatUtils.SendMessage(user, Text.Color("00FF00", "bla"));
            Legislation.Laws.AllNonFailedLaws.ForEach(x => { ChatUtils.SendMessage(user, x.Title); });

            string teststring = "Hello World!";

            ChatUtils.SendMessage(user, Text.Bold(teststring));
            ChatUtils.SendMessage(user, teststring.Bold());

            Timer timer = new Timer(10000);

            timer.Disposed += (sender, e) => ChatUtils.SendMessage(user, "Timer disposed");
            timer.AutoReset = false;
            timer.Elapsed  += (sender, e) => Timer_Elapsed(sender, e, user);
            timer.Start();
        }
Exemple #12
0
        public static void SetOwner(User user, string newowner)
        {
            User newowneruser = UserManager.FindUserByName(newowner);
            Deed deed         = PropertyManager.GetDeed(user.Position.XZi);

            if (deed == null)
            {
                ChatUtils.SendMessage(user, "Plot is not claimed!");
                return;
            }
            if (newowneruser != null)
            {
                deed.SetOwner(newowneruser);
                ChatUtils.SendMessage(user, newowneruser + " is now the owner of " + deed.Name);
            }
            else
            {
                ChatUtils.SendMessage(user, "User not found!", true);
            }
        }
Exemple #13
0
        public static void MKick(User user, User kickUser, string reason = "")
        {
            if (!user.IsAdmin && !user.GetState <bool>("Moderator"))//admin/mod only
            {
                ChatUtils.SendMessage(user, "Not Authorized to use this command!");
                return;
            }
            IOUtils.WriteCommandLog(user, "mKick", "Kicked " + kickUser.Name);
            var player = kickUser.Player;

            if (player != null)
            {
                player.Client.Disconnect("Moderator " + Text.Bold(user.Name) + " has kicked you.", reason);
                ChatUtils.SendMessage(user, "You have kicked " + kickUser.Name);
            }
            else
            {
                ChatUtils.SendMessage(user, kickUser.Name + " is not online");
            }
        }
Exemple #14
0
        public static void Testcontains(User user, string itemstr, string ingredientstr)
        {
            Item item       = Item.Get(itemstr);
            Item ingredient = Item.Get(ingredientstr);

            if (item != null && ingredient != null)
            {
                if (item.HasIngredient(ingredient.Type))
                {
                    ChatUtils.SendMessage(user, item.DisplayName + " contains " + ingredient.DisplayName);
                }
                else
                {
                    ChatUtils.SendMessage(user, item.DisplayName + " does not contain " + ingredient.DisplayName);
                }
            }
            else
            {
                ChatUtils.SendMessage(user, "ERROR");
            }
        }
Exemple #15
0
        public static void Tp(User user, string username = "")
        {
            if (!user.IsAdmin && !user.GetState <bool>("Moderator"))//admin/mod only
            {
                ChatUtils.SendMessage(user, "Not Authorized to use this command!");
                return;
            }
            User usertoteleport = UserManager.FindUserByName(username);

            if (usertoteleport == null)
            {
                usertoteleport = user;
            }

            string panelcontent = "Select Player: <br><br>";

            foreach (User onlineuser in UserManager.OnlineUsers)
            {
                panelcontent += new Button(player => { usertoteleport.Player.SetPosition(onlineuser.Player.Position); IOUtils.WriteCommandLog(user, "Tp", usertoteleport.Name + " -> " + onlineuser.Name); }, text: onlineuser.Name, singleuse: true, clickdesc: "Click to teleport " + usertoteleport.Name + " to " + onlineuser.Name).UILink();
                panelcontent += "<br>";
            }
            user.Player.OpenInfoPanel("Teleporting " + usertoteleport.Name, panelcontent);
        }
Exemple #16
0
        public static void SetMaxSuperSkills(User user, int maxallowed = int.MinValue)
        {
            if (maxallowed == -1)
            {
                maxallowed = int.MaxValue;
            }
            string currentallowedstr = (REYmodSettings.Obj.Config.Maxsuperskills != int.MaxValue) ? REYmodSettings.Obj.Config.Maxsuperskills.ToString() : "Infinite";

            if (maxallowed == int.MinValue || maxallowed == REYmodSettings.Obj.Config.Maxsuperskills)
            {
                ChatUtils.SendMessage(user, "Max allowed Superskills: " + currentallowedstr);
                return;
            }
            else
            {
                string newallowedstr = (maxallowed != int.MaxValue) ? maxallowed.ToString() : "Infinite";
                REYmodSettings.Obj.Config.Maxsuperskills = maxallowed;
                REYmodSettings.Obj.SaveConfig();
                ChatUtils.SendMessage(user, "Changed the amount of allowed Superskills from " + currentallowedstr + " to " + newallowedstr);
                ChatUtils.SendMessageToAll(user.UILink() + "changed the amount of allowed Superskills from " + currentallowedstr + " to " + newallowedstr);
                // ConfigHandler.UpdateConfigFile();
            }
        }
Exemple #17
0
        public static void LeaderPassLaw(User user)
        {
            if (user != Legislation.Government.LeaderUser)//leader only
            {
                ChatUtils.SendMessage(user, "Not Authorized to use this command!");
                return;
            }

            string panelcontent = "Click on the law you want to pass: <br><br>";

            if (Legislation.Laws.AllNonFailedLaws.Where(x => !x.InEffect).Count() != 0)
            {
                Legislation.Laws.AllNonFailedLaws.Where(x => !x.InEffect).ToList().ForEach(x =>
                {
                    panelcontent += new Button(player => { MiscUtils.SoftPassLaw(x, user); }, tooltip: x.Tooltip(), text: x.Title, singleuse: true, clickdesc: "Click to try to enact this law").UILink();
                    panelcontent += "<br>";
                });
            }
            else
            {
                panelcontent = "No pending laws!";
            }
            user.Player.OpenInfoPanel("Passlaw Menu", panelcontent);
        }
Exemple #18
0
 public static void SetTitle(User user, User target, string title)
 {
     target.SetState("CustomTitle", title);
     ChatUtils.SendMessage(user, "Set " + target.Name + "'s title to: \"" + title + "\"");
 }
Exemple #19
0
        public static void UnclaimConfirm(User user, int confirmcode = 0)
        {
            User target = null;
            Tuple <User, int> targetandcode;
            int totalplotcount = 0, deedcount = 0, plotcountdeed = 0, vehiclecount = 0, destroyedvehicles = 0;
            IEnumerable <Vector2i> positions;
            string                 tmp     = string.Empty;
            WorldObject            vehicle = null;
            ItemStack              sourcestack;
            ItemStack              targetstack;
            Func <ItemStack, bool> findDeed = i =>
            {
                if (i.Item as DeedItem != null)
                {
                    return((i.Item as DeedItem).AuthID == vehicle.GetComponent <StandaloneAuthComponent>().AuthGuid);
                }
                return(false);
            };

            if (!UtilsClipboard.UnclaimSelector.TryGetValue(user, out targetandcode))
            {
                user.Player.SendTemporaryErrorAlreadyLocalized("no User selected");
                return;
            }
            target = targetandcode.Item1;
            if (confirmcode != targetandcode.Item2)
            {
                ChatUtils.SendMessage(user, "Confirmationcode not correct");
                return;
            }
            IEnumerable <AuthorizationController> authorizationControllers = PropertyManager.GetAuthBelongingTo(target);

            foreach (AuthorizationController auth in authorizationControllers)
            {
                plotcountdeed = 0;
                if (auth.Type == "Property")
                {
                    deedcount++;
                    positions = PropertyManager.PositionsForId(auth.Id);
                    foreach (Vector2i pos in positions)
                    {
                        plotcountdeed++;
                        totalplotcount++;
                        //ChatUtils.SendMessage(user, TextLinkManager.MarkUpText("Try unclaiming: (" + pos.X + "," + pos.Y + ")"));
                        PropertyManager.UnclaimProperty(pos);
                    }
                    ChatUtils.SendMessage(user, "Unclaimed: " + auth.Name + " (" + plotcountdeed.ToString() + " Plots)");
                }
                else if (auth.Type == "Vehicle")
                {
                    if (auth.AttachedWorldObjects[0].Object != null)
                    {
                        vehiclecount++;
                        vehicle = auth.AttachedWorldObjects[0].Object;
                        ChatUtils.SendMessage(user, "Found Vehicle: " + auth.Name);
                        //vehicle.Destroy();
                        sourcestack = null;
                        sourcestack = target.Inventory.NonEmptyStacks.FirstOrDefault(findDeed);
                        targetstack = vehicle.GetComponent <PublicStorageComponent>().Inventory.Stacks.FirstOrDefault(i => i.Empty);
                        if (targetstack == null)
                        {
                            targetstack = vehicle.GetComponent <PublicStorageComponent>().Inventory.Stacks.First();
                            vehicle.GetComponent <PublicStorageComponent>().Inventory.ClearItemStack(targetstack);
                        }

                        if (sourcestack != null)
                        {
                            vehicle.GetComponent <PublicStorageComponent>().Inventory.AddItem(sourcestack.Item);
                            auth.SetOwner(user.Name);
                            vehicle.GetComponent <StandaloneAuthComponent>().SetLocked(user.Player, false);
                            auth.SetOwner(target.Name);
                            //target.Inventory.MoveItems(sourcestack, targetstack, target.Player);
                        }
                        else
                        {
                            destroyedvehicles++;
                            vehicle.Destroy();
                        }
                    }
                }
            }

            ChatUtils.SendMessage(user, totalplotcount + " Plots on " + deedcount + " Deeds unclaimed. Also found " + vehiclecount + " Vehicles. " + (vehiclecount - destroyedvehicles) + " have been unlocked and got their deed added to inventory. " + destroyedvehicles + " were destroyed as the deed couldn't be found");
        }
Exemple #20
0
        public static async void UnclaimPlayerAsync(User user, User owner = null)
        {
            bool   inactive  = true;
            bool   confirmed = false;
            double inactivetime;

            if (!user.IsAdmin && !user.GetState <bool>("Moderator"))//admin/mod only
            {
                ChatUtils.SendMessage(user, "Not Authorized to use this command!");
                return;
            }

            if (owner == null)
            {
                if (PropertyManager.GetPlot(user.Position.XZi) != null)
                {
                    owner = PropertyManager.GetPlot(user.Position.XZi).Owner;
                }
            }

            if (owner == null)
            {
                user.Player.SendTemporaryMessageAlreadyLocalized("Plot not owned");
                return;
            }

            inactivetime = (WorldTime.Seconds - owner.LogoutTime);
            if (inactivetime < REYmodSettings.Obj.Config.Maxinactivetime * 3600)
            {
                inactive = false;
            }
            if (owner.LoggedIn)
            {
                inactivetime = 0;
            }

            IEnumerable <Deed> allDeeds    = PropertyManager.GetAllDeeds();
            IEnumerable <Deed> targetDeeds = allDeeds.Where(x => x.OwnerUser == owner);
            int ownedplots    = PropertyManager.PropertyForUser(owner).Count();
            int ownedvehicles = targetDeeds.Sum(x => x.OwnedObjects.Count) - ownedplots;

            string textbox = "";

            textbox += "You are going to unclaim all property of " + owner.UILink() + "<br>";
            textbox += "Owned Plots: " + ownedplots + "<br>";
            textbox += "Owned Vehicles: " + ownedvehicles + "<br>";
            textbox += "<br>Player offline for " + TimeFormatter.FormatSpan(inactivetime);
            if (!inactive)
            {
                textbox += "<br>WARNING! Player not inactive!".Color("red");
            }
            textbox += "<br><br>";
            if (!inactive && !user.IsAdmin)
            {
                textbox += "<b><color=red>You can't unclaim this player! Not inactive for long enough.</color></b>";
                user.Player.PopupOKBoxLoc(Localizer.DoStr(textbox));
                return;
            }
            else
            {
                //  textbox += new Button(x => { MiscUtils.UnclaimUser(owner, user); IOUtils.WriteCommandLog(user, "UnclaimUser", "Unclaimed " + owner.Name + " (" + ownedplots + " plots/" + ownedvehicles + " vehicles)" + "Inactive for " + TimeFormatter.FormatSpan(inactivetime)); }, "", "Click here to unclaim all property of " + owner.UILink(), "Confirm Unclaiming".Color("green")).UILink();
                FormattableString textboxformattable = FormattableStringFactory.Create(textbox);
                confirmed = await user.Player.PopupConfirmBoxLoc(textboxformattable);
            }

            if (confirmed)
            {
                MiscUtils.UnclaimUser(owner, user);
                IOUtils.WriteCommandLog(user, "UnclaimUser", "Unclaimed " + owner.Name + " (" + ownedplots + " plots/" + ownedvehicles + " vehicles)" + "Inactive for " + TimeFormatter.FormatSpan(inactivetime));
            }


            //user.Player.OpenInfoPanel("Unclaim Player", textbox);
        }
Exemple #21
0
 private static void Timer_Elapsed(object sender, ElapsedEventArgs e, User user)
 {
     ChatUtils.SendMessage(user, "Timer elapsed!");
     (sender as Timer).Dispose();
 }