public string PlotSetBiome(Player player, int biomeId = 1) { PlotCoordinates coords = (PlotCoordinates)player.KnownPosition; if (!_plotManager.HasClaim(coords, player)) { return("You don't own this plot."); } if (!_plotManager.TryGetPlot(coords, out Plot plot)) { return("No plot found."); } var bbox = PlotManager.GetBoundingBoxForPlot(plot.Coordinates); PlotWorldGenerator.SetBiome(player.Level, bbox, (byte)biomeId); Task.Run(() => { player.CleanCache(); player.ForcedSendChunks(() => { player.SendMessage($"Resent chunks."); }); }); return($"Set biome on plot {plot.Coordinates} to {biomeId}"); }
public VanillaCommands.SimpleResponse PlotClaim(Player player) { PlotCoordinates coords = PlotManager.ConvertToPlotCoordinates(player.KnownPosition); if (coords == null) { return new VanillaCommands.SimpleResponse() { Body = "Not able to claim plot at this position." } } ; Plot plot; if (!_plotManager.TryClaim(coords, player, out plot)) { return new VanillaCommands.SimpleResponse() { Body = "Not able to claim plot at this position." } } ; return(new VanillaCommands.SimpleResponse($"Claimed plot {plot.Coordinates.X}:{plot.Coordinates.Z} at {coords}")); }
protected override void OnEnable() { var server = Context.Server; PlotManager plotManager = new PlotManager(); Context.PluginManager.LoadCommands(new PlotCommands(plotManager)); }
private string ClaimPlot(Player player, PlotCoordinates coords) { var bbox = PlotManager.GetBoundingBoxForPlot(coords); var center = bbox.Max - (bbox.Max - bbox.Min) / 2; int height = player.Level.GetHeight(center); player.Teleport(new PlayerLocation(center.X, height + 3, center.Z)); return($"Claimed plot {coords.X},{coords.Z}"); }
protected override void OnEnable() { var server = Context.Server; _plotManager = new PlotManager(); Context.PluginManager.LoadCommands(new VanillaCommands()); Context.PluginManager.LoadCommands(new PlotCommands(_plotManager)); server.PlayerFactory.PlayerCreated += (sender, e) => { Player player = e.Player; player.PlayerJoining += OnPlayerJoin; player.PlayerLeave += OnPlayerLeave; player.Ticking += OnTicking; }; }
public string PlotVisit(Player player, int x, int z) { PlotCoordinates coords = new PlotCoordinates(x, z); if (x == 0 || z == 0) { return($"No plot at this location {coords.X},{coords.Z}."); } var bbox = PlotManager.GetBoundingBoxForPlot(coords); var center = bbox.Max - (bbox.Max - bbox.Min) / 2; int height = player.Level.GetHeight(center); player.Teleport(new PlayerLocation(center.X, height + 3, center.Z)); return($"Moved you to plot {coords.X},{coords.Z}."); }
public string PlotDelete(Player player, bool force = false) { PlotCoordinates coords = (PlotCoordinates)player.KnownPosition; if (!force && !_plotManager.HasClaim(coords, player)) { return("Not able to reset plot at this position."); } if (!_plotManager.TryGetPlot(coords, out Plot plot) && !force) { return("Not able to delete plot at this position."); } if (plot != null && !_plotManager.Delete(plot)) { return("Not able to delete plot at this position."); } PlotWorldGenerator.ResetBlocks(player.Level, PlotManager.GetBoundingBoxForPlot(coords), true); return($"Deleted plot {coords.X},{coords.Z}."); }
public string PlotClear(Player player) { PlotCoordinates coords = (PlotCoordinates)player.KnownPosition; if (coords == null) { return("Not able to reset plot at this position."); } if (!_plotManager.HasClaim(coords, player)) { return("Not able to reset plot at this position."); } if (!_plotManager.TryGetPlot(coords, out Plot plot)) { return("Not able to reset plot at this position."); } PlotWorldGenerator.ResetBlocks(player.Level, PlotManager.GetBoundingBoxForPlot(plot.Coordinates)); return($"Reset plot {plot.Coordinates.X},{plot.Coordinates.Z}."); }
public PlotCommands(PlotManager plotManager) { _plotManager = plotManager; }