mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 06:28:49 +00:00
Ensure spawn.yml is properly deleted when overwritten, close #400
This commit is contained in:
1 parent
aeff866b48
commit
cb9d4808f2
3 files changed
+18
-3
No files matched your search
@@ -357,7 +357,12 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes, BukkitTask
|
|||||||
@Override
|
@Override
|
||||||
public void setServerSpawn(@NotNull Location location) {
|
public void setServerSpawn(@NotNull Location location) {
|
||||||
try {
|
try {
|
||||||
this.serverSpawn = Annotaml.create(new File(getDataFolder(), "spawn.yml"), new Spawn(location)).get();
|
// Create or update the spawn.yml file
|
||||||
|
final File spawnFile = new File(getDataFolder(), "spawn.yml");
|
||||||
|
if (spawnFile.exists() && !spawnFile.delete()) {
|
||||||
|
log(Level.WARNING, "Failed to delete the existing spawn.yml file");
|
||||||
|
}
|
||||||
|
this.serverSpawn = Annotaml.create(spawnFile, new Spawn(location)).get();
|
||||||
|
|
||||||
// Update the world spawn location, too
|
// Update the world spawn location, too
|
||||||
BukkitAdapter.adaptLocation(location).ifPresent(bukkitLocation -> {
|
BukkitAdapter.adaptLocation(location).ifPresent(bukkitLocation -> {
|
||||||
|
|||||||
@@ -327,7 +327,12 @@ public class FabricHuskHomes implements DedicatedServerModInitializer, HuskHomes
|
|||||||
@Override
|
@Override
|
||||||
public void setServerSpawn(@NotNull Location location) {
|
public void setServerSpawn(@NotNull Location location) {
|
||||||
try {
|
try {
|
||||||
this.serverSpawn = Annotaml.create(new File(getDataFolder(), "spawn.yml"), new Spawn(location)).get();
|
// Create or update the spawn.yml file
|
||||||
|
final File spawnFile = new File(getDataFolder(), "spawn.yml");
|
||||||
|
if (spawnFile.exists() && !spawnFile.delete()) {
|
||||||
|
log(Level.WARNING, "Failed to delete the existing spawn.yml file");
|
||||||
|
}
|
||||||
|
this.serverSpawn = Annotaml.create(spawnFile, new Spawn(location)).get();
|
||||||
|
|
||||||
// Update the world spawn location, too
|
// Update the world spawn location, too
|
||||||
minecraftServer.getWorlds().forEach(world -> {
|
minecraftServer.getWorlds().forEach(world -> {
|
||||||
|
|||||||
@@ -318,7 +318,12 @@ public class SpongeHuskHomes implements HuskHomes, SpongeTaskRunner, SpongeSafet
|
|||||||
@Override
|
@Override
|
||||||
public void setServerSpawn(@NotNull Location location) {
|
public void setServerSpawn(@NotNull Location location) {
|
||||||
try {
|
try {
|
||||||
this.serverSpawn = Annotaml.create(new File(getDataFolder(), "spawn.yml"), new Spawn(location)).get();
|
// Create or update the spawn.yml file
|
||||||
|
final File spawnFile = new File(getDataFolder(), "spawn.yml");
|
||||||
|
if (spawnFile.exists() && !spawnFile.delete()) {
|
||||||
|
log(Level.WARNING, "Failed to delete the existing spawn.yml file");
|
||||||
|
}
|
||||||
|
this.serverSpawn = Annotaml.create(spawnFile, new Spawn(location)).get();
|
||||||
|
|
||||||
// Update the world spawn location, too
|
// Update the world spawn location, too
|
||||||
game.server().worldManager().worlds().forEach(world -> {
|
game.server().worldManager().worlds().forEach(world -> {
|
||||||
|
|||||||
Reference in new issue
Block a user