haus system auf core geändert
This commit is contained in:
@@ -2793,144 +2793,10 @@ namespace ReallifeGamemode.Server.Commands
|
||||
ChatService.SendMessage(player, "~b~[ADMIN]~s~ Die Türen wurden erfolgreich neugeladen.");
|
||||
}
|
||||
|
||||
[Command("house", "~m~Benutzung: ~s~/house [add / remove / price / type / reloadhouses]", GreedyArg = true)]
|
||||
public void CmdAdminHouse(Player player, string option1 = null, string option2 = null)
|
||||
{
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
option1 = option1?.ToLower();
|
||||
|
||||
if (option1 == "add")
|
||||
{
|
||||
House nearHouse = HouseManager.GetNearHouse(player.Position);
|
||||
if (nearHouse != null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "In der Nähe ist schon ein Haus");
|
||||
return;
|
||||
}
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
House house = new House()
|
||||
{
|
||||
Price = 0,
|
||||
Type = "Haus",
|
||||
X = player.Position.X,
|
||||
Y = player.Position.Y,
|
||||
Z = player.Position.Z
|
||||
};
|
||||
|
||||
dbContext.Houses.Add(house);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
HouseManager.LoadHouse(house);
|
||||
|
||||
player.SendNotification("Das Haus wurde erstellt");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else if (option1 == "remove")
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
House nearHouse = HouseManager.GetNearHouse(player.Position, dbContext);
|
||||
if (nearHouse == null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "In deiner Nähe befindet sich kein Haus");
|
||||
return;
|
||||
}
|
||||
|
||||
if (nearHouse.OwnerId != null)
|
||||
{
|
||||
dbContext.Users.Where(u => u.Id == nearHouse.OwnerId).First().HouseId = null;
|
||||
}
|
||||
|
||||
foreach (HouseRental rental in dbContext.HouseRentals.Include(r => r.User).Where(r => r.HouseId == nearHouse.Id))
|
||||
{
|
||||
rental.User.Player?.SendChatMessage("!{#81F7BE}* Dein Mietvertrag wurde administrativ aufgelöst!");
|
||||
dbContext.HouseRentals.Remove(rental);
|
||||
}
|
||||
|
||||
dbContext.Houses.Remove(nearHouse);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
HouseManager.RemoveHouse(nearHouse);
|
||||
|
||||
player.SendNotification("Das Haus wurde gelöscht");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else if (option1 == "price")
|
||||
{
|
||||
if (!int.TryParse(option2, out int price))
|
||||
{
|
||||
ChatService.SendMessage(player, "~m~Benutzung: ~s~/house price [Price]");
|
||||
return;
|
||||
}
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
House nearHouse = HouseManager.GetNearHouse(player.Position, dbContext);
|
||||
if (nearHouse == null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "In deiner Nähe befindet sich kein Haus");
|
||||
return;
|
||||
}
|
||||
|
||||
nearHouse.Price = price;
|
||||
dbContext.SaveChanges();
|
||||
|
||||
HouseManager.RemoveHouse(nearHouse);
|
||||
HouseManager.LoadHouse(nearHouse);
|
||||
|
||||
player.SendNotification("Der Hauspreis wurde gesetzt");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else if (option1 == "type")
|
||||
{
|
||||
if (option2 == null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "~m~Benutzung: ~s~/house type [Type]");
|
||||
return;
|
||||
}
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
House nearHouse = HouseManager.GetNearHouse(player.Position, dbContext);
|
||||
if (nearHouse == null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "In deiner Nähe befindet sich kein Haus");
|
||||
return;
|
||||
}
|
||||
|
||||
nearHouse.Type = option2;
|
||||
dbContext.SaveChanges();
|
||||
|
||||
HouseManager.RemoveHouse(nearHouse);
|
||||
HouseManager.LoadHouse(nearHouse);
|
||||
|
||||
player.SendNotification("Der Haustyp wurde gesetzt");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else if (option1 == "reloadhouses")
|
||||
{
|
||||
HouseManager.ReloadAllHouses();
|
||||
player.SendNotification("Alle Häuser wurden neu geladen");
|
||||
return;
|
||||
}
|
||||
|
||||
player.SendChatMessage("~m~Benutzung: ~s~/house [add / remove / price / type / reloadhouses]");
|
||||
}
|
||||
//[Command("house", "~m~Benutzung: ~s~/house [add / remove / price / type / reloadhouses]", GreedyArg = true)]
|
||||
//public void CmdAdminHouse(Player player, string option1 = null, string option2 = null)
|
||||
//{
|
||||
//}
|
||||
|
||||
[Command("paydaydrop", "~m~Benutzung: ~s~/paydaydrop")]
|
||||
public void CmdAdminPaydaydrop(Player player)
|
||||
|
||||
Reference in New Issue
Block a user