Compare commits

...

3 Commits
1.19.4 ... main

Author SHA1 Message Date
6dbd755055
fix: Update version 2024-03-22 22:11:29 +01:00
9bbbdd42f7
fix: Create and load extra worlds only on server startup
This saves time having to wait for the entire world being generated on every swap.
2024-03-22 22:09:10 +01:00
91e3a43dc4
Update to Minecraft 1.20 2023-06-10 10:26:45 +02:00
4 changed files with 34 additions and 27 deletions

View File

@ -1,6 +1,6 @@
# death-swap
DeathSwap plugin for 1.19 Minecraft Java servers (Spigot/Paper)
DeathSwap plugin for 1.20 Minecraft Java servers (Spigot/Paper)
## WARNING

View File

@ -4,7 +4,7 @@
<groupId>eu.cloudapio.deathswap</groupId>
<artifactId>deathswap</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<version>1.2-SNAPSHOT</version>
<name>deathswap</name>
<url>http://maven.apache.org</url>
<properties>
@ -22,7 +22,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.4-R0.1-SNAPSHOT</version>
<version>1.20.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>

View File

@ -20,10 +20,9 @@ import org.bukkit.entity.Player;
public class DeathSwapGame {
ArrayList<Player> players;
WorldCreator wc;
World world;
World world_nether;
Random randomizer;
String worldName;
boolean isPlayingGame = false;
@ -34,12 +33,34 @@ public class DeathSwapGame {
long lastSwapTime;
private World createWorld(String name, boolean isNether)
{
World world = Bukkit.getWorld(name);
Bukkit.getServer().unloadWorld(world, false);
deleteWorld(name);
WorldCreator wc = new WorldCreator(name);
wc.copy(Bukkit.getServer().getWorlds().get(0));
wc.seed(randomizer.nextLong());
if(isNether) wc.environment(Environment.NETHER);
world = wc.createWorld();
world.setKeepSpawnInMemory(false);
world.setDifficulty(Difficulty.NORMAL);
world.setPVP(false);
world.setGameRule(GameRule.DO_IMMEDIATE_RESPAWN, true);
return world;
}
public DeathSwapGame()
{
randomizer = new Random(System.currentTimeMillis());
players = new ArrayList<Player>();
worldName = "death-swap";
wc = new WorldCreator(worldName);
world = createWorld("death-swap", false);
world_nether = createWorld("death-swap-nether", true);
getMainWorld().setPVP(false);
}
@ -132,26 +153,12 @@ public class DeathSwapGame {
isPlayingGame = true;
Bukkit.getServer().unloadWorld(world, false);
deleteWorld(worldName);
wc.copy(Bukkit.getServer().getWorlds().get(0));
wc.seed(randomizer.nextLong());
if(isNether)
{
wc.environment(Environment.NETHER);
}
world = wc.createWorld();
world.setKeepSpawnInMemory(false);
world.setDifficulty(Difficulty.NORMAL);
world.setPVP(false);
world.setGameRule(GameRule.DO_IMMEDIATE_RESPAWN, true);
ArrayList<Location> spawnLocations = new ArrayList<Location>(players.size());
for(int i = 0; i < players.size(); i++)
{
spawnLocations.add(randomSpawnLocation(world, isNether));
if(isNether)
spawnLocations.add(randomSpawnLocation(world_nether, true));
else spawnLocations.add(randomSpawnLocation(world, false));
}
for(int i = 0; i < players.size(); i++)

View File

@ -1,7 +1,7 @@
main: eu.cloudapio.deathswap.DeathSwap
name: death-swap
version: 0.1
api-version: 1.19
api-version: 1.20
commands:
dswap:
description: Death Swap