formatted code

This commit is contained in:
Lennart Kampshoff
2019-05-05 17:59:11 +02:00
parent a34c03eae9
commit a88d5256a8
54 changed files with 290 additions and 210 deletions

View File

@@ -37,7 +37,7 @@ namespace ReallifeGamemode.Server.Commands
IItem iItem = InventoryManager.GetItemByName(item);
if(iItem == null)
if (iItem == null)
{
player.SendChatMessage("Dieses Essen existiert nicht.");
return;
@@ -46,15 +46,15 @@ namespace ReallifeGamemode.Server.Commands
List<UserItem> itemList = player.GetUser().GetItems();
UserItem eatItem = itemList.FirstOrDefault(i => i.ItemId == iItem.Id);
if(eatItem == null)
if (eatItem == null)
{
player.SendChatMessage("Du hast dieses Item nicht");
return;
}
if(iItem is IUsableItem usableItemObj)
if (iItem is IUsableItem usableItemObj)
{
usableItemObj.Use(eatItem);
usableItemObj.Use(eatItem);
}
}
@@ -227,7 +227,7 @@ namespace ReallifeGamemode.Server.Commands
return;
}
if (target == player)
if (target == player)
{
ChatService.Error(player, "Du kannst dir nicht selber zuflüstern.");
return;
@@ -339,7 +339,7 @@ namespace ReallifeGamemode.Server.Commands
return;
}
var gotoString = "";
using(var dbContext = new DatabaseContext())
using (var dbContext = new DatabaseContext())
{
foreach (GotoPoint point in dbContext.GotoPoints)
{
@@ -659,7 +659,7 @@ namespace ReallifeGamemode.Server.Commands
{
GotoPoint p = dbContext.GotoPoints.FirstOrDefault(x => x.Description == location);
if(p == null)
if (p == null)
{
ChatService.Error(player, "Dieser Goto-Punkt existiert nicht.");
return;
@@ -757,7 +757,7 @@ namespace ReallifeGamemode.Server.Commands
}
Vehicle v = VehicleManager.GetVehicleFromId(vehid);
if(v == null)
if (v == null)
{
ChatService.Error(player, "Dieses Fahrzeug existiert nicht.");
return;
@@ -864,7 +864,7 @@ namespace ReallifeGamemode.Server.Commands
public void CmdAdminVeh(Client player, string hash, int color1 = 111, int color2 = 111)
{
if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN3) ?? true)
//TODO: Bestimmte Autos nur ab Adminlevel 1337, "normale Fahrzeuge" schon ab Adminlevel 3.
//TODO: Bestimmte Autos nur ab Adminlevel 1337, "normale Fahrzeuge" schon ab Adminlevel 3.
{
ChatService.NotAuthorized(player);
return;
@@ -876,10 +876,10 @@ namespace ReallifeGamemode.Server.Commands
return;
}
if(!uint.TryParse(hash, out uint uHash))
if (!uint.TryParse(hash, out uint uHash))
uHash = NAPI.Util.GetHashKey(hash);
if(!VehicleManager.IsValidHash(uHash))
if (!VehicleManager.IsValidHash(uHash))
{
ChatService.Error(player, "Dieses Fahrzeug existiert nicht.");
return;
@@ -931,7 +931,7 @@ namespace ReallifeGamemode.Server.Commands
else
{
targetVeh = VehicleManager.GetVehicleFromId(vid);
if(targetVeh == null)
if (targetVeh == null)
{
ChatService.Error(player, "Dieses Fahrzeug existiert nicht.");
return;
@@ -939,7 +939,7 @@ namespace ReallifeGamemode.Server.Commands
}
ServerVehicle veh = VehicleManager.GetServerVehicleFromVehicle(targetVeh);
if(veh != null)
if (veh != null)
{
ChatService.Error(player, "Dieses Fahrzeug wird von einem Server-System benutzt: ~m~" + veh.GetType().Name);
return;
@@ -1120,7 +1120,7 @@ namespace ReallifeGamemode.Server.Commands
user.Handmoney += amount;
context.SaveChanges();
target.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
}
}
}
[Command("quicksavemode", "~m~Benutzung: ~s~/quicksavemode [Modus]\nModi (klein schreiben): ~g~blip, ~r~atm")]
@@ -1155,7 +1155,7 @@ namespace ReallifeGamemode.Server.Commands
using (var context = new DatabaseContext())
{
List<UserItem> userItems = context.UserItems.ToList().FindAll(i => i.UserId == target.GetUser().Id);
foreach(var uItem in userItems)
foreach (var uItem in userItems)
{
invWeight += uItem.Amount * InventoryManager.GetItemById(uItem.ItemId).Gewicht;
}
@@ -1169,7 +1169,7 @@ namespace ReallifeGamemode.Server.Commands
{
UserItem item = new UserItem() { ItemId = itemId, UserId = target.GetUser().Id, Amount = amount };
InventoryManager.AddItemToInventory(target, item);
}
}
}
[Command("inventory", "~m~Benutzung: ~s~/inventory [Spieler]")]
@@ -1192,7 +1192,7 @@ namespace ReallifeGamemode.Server.Commands
InventoryManager.GetUserItemsAsAdmin(player, user);
}
[Command("editmode", "~m~Benutzung: ~s~/editmode")]
public void CmdAdminToggleEditMode(Client player)
{
@@ -1201,8 +1201,8 @@ namespace ReallifeGamemode.Server.Commands
ChatService.NotAuthorized(player);
return;
}
if(player.GetData("editmode") == false)
if (player.GetData("editmode") == false)
{
player.SetData("editmode", true);
player.SendNotification("Edit-Mode ~g~aktiviert");
@@ -1433,13 +1433,13 @@ namespace ReallifeGamemode.Server.Commands
return;
}
if(hour > 23 || min > 59 || sec > 59)
if (hour > 23 || min > 59 || sec > 59)
{
ChatService.Error(player, "Es wurde eine ungültige Zeit eingegeben.");
return;
}
if(hour == -1)
if (hour == -1)
{
player.SendChatMessage("Es wird nun wieder die Echtzeit genutzt.");
TimeManager.StartTimeManager();
@@ -1618,26 +1618,26 @@ namespace ReallifeGamemode.Server.Commands
case "svehicle":
if (player.IsInVehicle)
{
if(option1 == null || option2 == null)
if (option1 == null || option2 == null)
{
player.SendChatMessage("~m~Benutzung: ~s~/save SVehicle [Carshop Business ID] [Preis]");
return;
}
if(!int.TryParse(option1, out int businessId) || !int.TryParse(option2, out int price))
if (!int.TryParse(option1, out int businessId) || !int.TryParse(option2, out int price))
{
player.SendChatMessage("~m~Benutzung: ~s~/save SVehicle [Carshop Business ID] [Preis]");
return;
}
BusinessBase business = BusinessManager.GetBusiness(businessId);
if(business == null)
if (business == null)
{
ChatService.Error(player, "Dieses Business existiert nicht.");
return;
}
if(!(business is CarDealerBusinessBase))
if (!(business is CarDealerBusinessBase))
{
ChatService.Error(player, "Dieses Business ist kein Fahrzeug-Business.");
return;
@@ -1666,23 +1666,23 @@ namespace ReallifeGamemode.Server.Commands
return;
}
switch(type.ToLower())
switch (type.ToLower())
{
case "vehicle":
if(!player.IsInVehicle)
if (!player.IsInVehicle)
{
player.SendChatMessage("~m~Du sitzt in keinem Fahrzeug!");
return;
}
ServerVehicle veh = player.Vehicle.GetServerVehicle();
if(veh == null)
if (veh == null)
{
ChatService.Error(player, "Dieses Fahrzeug wird nicht von einem Server-System genutzt.");
return;
}
if(option.ToLower() != "yes")
if (option.ToLower() != "yes")
{
player.SendChatMessage("Bist du sicher, dass du folgendes Fahrzeug löschen willst: ~m~" + veh.ToString() + " ~s~?");
player.SendChatMessage("Falls ~g~Ja~s~, nutze ~y~/remove vehicle yes");
@@ -1699,7 +1699,7 @@ namespace ReallifeGamemode.Server.Commands
break;
case "goto":
if(option == "")
if (option == "")
{
player.SendChatMessage("~m~Benutzung: ~s~/remove [Goto] [Punkt]");
return;
@@ -1712,7 +1712,7 @@ namespace ReallifeGamemode.Server.Commands
using (var dbContext = new DatabaseContext())
{
GotoPoint p = dbContext.GotoPoints.FirstOrDefault(x => x.Description == option);
if(p == null)
if (p == null)
{
ChatService.Error(player, "Dieser Goto-Punkt existiert nicht.");
return;
@@ -1953,7 +1953,7 @@ namespace ReallifeGamemode.Server.Commands
}
#endregion
//
[Command("managefactionranks", "~m~Benutzung: ~s~/managefactionranks [Fraktions-ID]")]
public void CmdFactionManageFactionRanks(Client player, int factionID)
@@ -2119,26 +2119,26 @@ namespace ReallifeGamemode.Server.Commands
return;
}
if(target.GetUser().BusinessId != null)
if (target.GetUser().BusinessId != null)
{
ChatService.Error(player, "Der Spieler besitzt momentan schon ein Business: ~o~" + BusinessManager.GetBusiness(target.GetUser().BusinessId).Name);
return;
}
BusinessBase business = BusinessManager.GetBusiness(businessid);
if(business == null)
if (business == null)
{
ChatService.Error(player, "Dieses Business existiert nicht. ~m~/businesslist");
return;
}
if(business.GetOwner() != null)
if (business.GetOwner() != null)
{
ChatService.Error(player, "Das Business hat momentan noch einen Besitzer: ~o~" + business.GetOwner().Name + "~s~. Entferne diesen Besitzer erst mit ~m~/clearbusiness");
return;
}
using(var dbContext = new DatabaseContext())
using (var dbContext = new DatabaseContext())
{
Entities.User targetUser = target.GetUser(dbContext);
targetUser.BusinessId = businessid;
@@ -2164,10 +2164,10 @@ namespace ReallifeGamemode.Server.Commands
return;
}
using(var dbContext = new DatabaseContext())
using (var dbContext = new DatabaseContext())
{
User owner = business.GetOwner(dbContext);
if(owner == null)
if (owner == null)
{
ChatService.Error(player, "Dieses Business hat momentan keinen Besitzer.");
return;
@@ -2226,16 +2226,16 @@ namespace ReallifeGamemode.Server.Commands
option1 = option1.ToString();
if(option1 != "add" && option1 != "remove" && option1 != "setenterposition" && option1 != "setexitposition")
if (option1 != "add" && option1 != "remove" && option1 != "setenterposition" && option1 != "setexitposition")
{
player.SendChatMessage("~m~Benutzung: ~s~/interior [Add / Remove / SetEnterPosition / SetExitPosition] [Name]");
return;
}
switch(option1)
switch (option1)
{
case "add":
using(var dbContext = new DatabaseContext())
using (var dbContext = new DatabaseContext())
{
Interior interiorAdd = new Interior
{
@@ -2249,13 +2249,13 @@ namespace ReallifeGamemode.Server.Commands
case "remove":
using (var dbContext = new DatabaseContext())
{
if(!int.TryParse(option2, out int intId))
if (!int.TryParse(option2, out int intId))
{
ChatService.Error(player, "Es muss eine Nummer angegeben werden.");
return;
}
Interior interiorRemove = InteriorManager.GetInteriorById(intId, dbContext);
if(interiorRemove == null)
if (interiorRemove == null)
{
ChatService.Error(player, "Dieses Interior existiert nicht.");
return;