Esempio n. 1
0
		public override void onCommand(CommandEvent Event)
		{
			int player = ((Player)Event.GetSender()).whoAmi;
			string command = Event.GetMessage();
			string[] Params = command.Split(' ');
			Sender sender = Event.GetSender();
			Console.WriteLine(GetPlayerName(player) + " sent command " + command);
			if (Params[0].Substring(1) == "players"))
			{
				string players = Statics.ServerWorld.getPlayerList().Aggregate("", (current, ply) => current + (ply.name + " "));
				sender.SendMessage("Currently connected players:", 255f, 240f, 20f);
				sender.SendMessage(players, 255f, 240f, 20f);
			}
			if (Params[0] == "/pvpon")
			{
				Event.SetCancelled(true);
				if (!Permissions.HasPermission(GetPlayerName(player), "examplePlugin.setpvp"))
				{
					SendPlayerMessage(player, "You don't have enough permissions!", 255f, 0f, 0f);
					return;
				}
				int target = Params.Length > 1 ? FindPlayerByName(Params[1]) : player;
				TogglePvP(target,  true);
				SendAllMessage("PvP on " + GetPlayerName(target) + " has been turned on!", 0f, 255f, 0f);
				return;
			}
			if (Params[0] == "/pvpoff")
			{
				Event.SetCancelled(true);
				if (!Permissions.HasPermission(GetPlayerName(player), "examplePlugin.setpvp"))
				{
					SendPlayerMessage(player, "You don't have enough permissions!", 255f, 0f, 0f);
					return;
				}
				int target = Params.Length > 1 ? FindPlayerByName(Params[1]) : player;
				TogglePvP(target, false);
				SendAllMessage("PvP on " + GetPlayerName(target) + " has been turned off!", 255f, 0f, 0f);
				return;
			}
			if (Params[0] == "/settime" && Params.Length > 1)
			{
				Event.SetCancelled(true);
				if (!Permissions.HasPermission(GetPlayerName(player), "examplePlugin.settime"))
				{
					SendPlayerMessage(player, "You don't have enough permissions!", 255f, 0f, 0f);
					return;
				}
				SetWorldTime(Convert.ToDouble(Params[1]));
				SendAllMessage("The time has been set to " + Params[1], 0f, 0f, 0f);
				return;
			}
			if (Params[0] == "/bloodmoon")
			{
				Event.SetCancelled(true);
				if (!Permissions.HasPermission(GetPlayerName(player), "examplePlugin.bloodmoon"))
				{
					SendPlayerMessage(player, "You don't have enough permissions!", 255f, 0f, 0f);
					return;
				}
				ToggleBloodMoon(!Statics.ServerWorld.isBloodMoon());
				SendAllMessage("Blood Moon is now " + (Statics.ServerWorld.isBloodMoon() ? "on" : "off"), 0f, 255f, 0f);
				return;
			}
			if (Params[0] == "/npc" && Params.Length > 1)
			{
				Event.SetCancelled(true);
				if (!Permissions.HasPermission(GetPlayerName(player), "examplePlugin.npc"))
				{
					SendPlayerMessage(player, "You don't have enough permissions!", 255f, 0f, 0f);
					return;
				}
				NPC.NewNPC(Convert.ToInt32(Statics.ServerWorld.getPlayerList()[player].position.X) + 3,
				           Convert.ToInt32(Statics.ServerWorld.getPlayerList()[player].position.Y) + 2,
				           Statics.ServerWorld,
				           Convert.ToInt32(Params[1]));
				SendPlayerMessage(player, "Spawned NPC type " + Params[1], 0f, 255f, 255f);
				return;
			}
		}
Esempio n. 2
0
 public override void onCommand(CommandEvent Event)
 {
     int player = ((Player)Event.GetSender()).whoAmi;
     string command = Event.GetMessage();
     string[] Params = command.Split(' ');
     Sender sender = Event.GetSender();
     Console.WriteLine(GetPlayerName(player) + " sent command " + command);
     if (Params[0].Substring(1) == "players"))
     {
         string players = Statics.ServerWorld.getPlayerList().Aggregate("", (current, ply) => current + (ply.name + " "));
         sender.SendMessage("Currently connected players:", 255f, 240f, 20f);
         sender.SendMessage(players, 255f, 240f, 20f);
     }
     if (Params[0] == "/pvpon")
     {
         Event.SetCancelled(true);
         if (!Permissions.HasPermission(GetPlayerName(player), "examplePlugin.setpvp"))
         {
             SendPlayerMessage(player, "You don't have enough permissions!", 255f, 0f, 0f);
             return;
         }
         int target = Params.Length > 1 ? FindPlayerByName(Params[1]) : player;
         TogglePvP(target,  true);
         SendAllMessage("PvP on " + GetPlayerName(target) + " has been turned on!", 0f, 255f, 0f);
         return;
     }
     if (Params[0] == "/pvpoff")
     {
         Event.SetCancelled(true);
         if (!Permissions.HasPermission(GetPlayerName(player), "examplePlugin.setpvp"))
         {
             SendPlayerMessage(player, "You don't have enough permissions!", 255f, 0f, 0f);
             return;
         }
         int target = Params.Length > 1 ? FindPlayerByName(Params[1]) : player;
         TogglePvP(target, false);
         SendAllMessage("PvP on " + GetPlayerName(target) + " has been turned off!", 255f, 0f, 0f);
         return;
     }
     if (Params[0] == "/settime" && Params.Length > 1)
     {
         Event.SetCancelled(true);
         if (!Permissions.HasPermission(GetPlayerName(player), "examplePlugin.settime"))
         {
             SendPlayerMessage(player, "You don't have enough permissions!", 255f, 0f, 0f);
             return;
         }
         SetWorldTime(Convert.ToDouble(Params[1]));
         SendAllMessage("The time has been set to " + Params[1], 0f, 0f, 0f);
         return;
     }
     if (Params[0] == "/bloodmoon")
     {
         Event.SetCancelled(true);
         if (!Permissions.HasPermission(GetPlayerName(player), "examplePlugin.bloodmoon"))
         {
             SendPlayerMessage(player, "You don't have enough permissions!", 255f, 0f, 0f);
             return;
         }
         ToggleBloodMoon(!Statics.ServerWorld.isBloodMoon());
         SendAllMessage("Blood Moon is now " + (Statics.ServerWorld.isBloodMoon() ? "on" : "off"), 0f, 255f, 0f);
         return;
     }
     if (Params[0] == "/npc" && Params.Length > 1)
     {
         Event.SetCancelled(true);
         if (!Permissions.HasPermission(GetPlayerName(player), "examplePlugin.npc"))
         {
             SendPlayerMessage(player, "You don't have enough permissions!", 255f, 0f, 0f);
             return;
         }
         NPC.NewNPC(Convert.ToInt32(Statics.ServerWorld.getPlayerList()[player].position.X) + 3,
                    Convert.ToInt32(Statics.ServerWorld.getPlayerList()[player].position.Y) + 2,
                    Statics.ServerWorld,
                    Convert.ToInt32(Params[1]));
         SendPlayerMessage(player, "Spawned NPC type " + Params[1], 0f, 255f, 255f);
         return;
     }
 }