-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix randomjoin not being random * Fix lobby world not loading non-default worlds This commit will address the issue sending a player to a world that was not loaded/created before. * Append -bugfixes suffix to version * Fix empty messages being shown * Replace outdated links with new ones * Add commit patch to version * Fix improper island positioning Due to island position being inaccurate, it caused some islands to clash together. This commit solves #31 issue. * Add debug commands for islands
- Loading branch information
Showing
18 changed files
with
386 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...-plugin/src/main/java/io/tofpu/speedbridge2/command/subcommand/debug/DestroyableLand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package io.tofpu.speedbridge2.command.subcommand.debug; | ||
|
||
import com.sk89q.worldedit.EditSession; | ||
import com.sk89q.worldedit.MaxChangedBlocksException; | ||
import com.sk89q.worldedit.WorldEditException; | ||
import com.sk89q.worldedit.bukkit.BukkitWorld; | ||
import com.sk89q.worldedit.extent.clipboard.Clipboard; | ||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy; | ||
import com.sk89q.worldedit.function.operation.Operation; | ||
import com.sk89q.worldedit.function.operation.Operations; | ||
import io.tofpu.multiworldedit.EditSessionWrapper; | ||
import io.tofpu.multiworldedit.MultiWorldEditAPI; | ||
import io.tofpu.speedbridge2.model.common.util.BridgeUtil; | ||
import io.tofpu.speedbridge2.model.island.object.land.IslandLand; | ||
|
||
import java.io.IOException; | ||
|
||
public class DestroyableLand extends IslandLand { | ||
private EditSession editSession; | ||
|
||
public DestroyableLand(IslandLand islandLand) { | ||
super(islandLand.getIsland(), islandLand.getWorld(), islandLand.getPositions()); | ||
} | ||
|
||
@Override | ||
public void generatePlot() throws WorldEditException { | ||
// TODO: Make this generation operation async | ||
BridgeUtil.debug("Generating plot at " + getPlotLocation().toString() + " for " + | ||
"island " + getIsland().getSlot()); | ||
|
||
final BukkitWorld bukkitWorld = new BukkitWorld(getWorld()); | ||
|
||
try (final EditSessionWrapper editSessionWrapper = MultiWorldEditAPI.getMultiWorldEdit() | ||
.create(bukkitWorld, -1)) { | ||
final Clipboard schematicClipboard = getIsland().getSchematicClipboard(); | ||
this.editSession = editSessionWrapper.to(); | ||
|
||
final Operation operation = MultiWorldEditAPI.getMultiWorldEdit() | ||
.create(schematicClipboard, editSession, bukkitWorld) | ||
.to((int) getX(), (int) getY(), (int) getZ()) | ||
.ignoreAirBlocks(true) | ||
.build(); | ||
|
||
Operations.completeLegacy(operation); | ||
} catch (IOException e) { | ||
throw new IllegalStateException(e); | ||
} | ||
} | ||
|
||
public void destroy() { | ||
// TODO: Make this generation operation async | ||
BridgeUtil.debug("Generating plot at " + getPlotLocation().toString() + " for " + | ||
"island " + getIsland().getSlot()); | ||
|
||
final BukkitWorld bukkitWorld = new BukkitWorld(getWorld()); | ||
|
||
try (final EditSessionWrapper editSessionWrapper = MultiWorldEditAPI.getMultiWorldEdit() | ||
.create(bukkitWorld, -1)) { | ||
EditSession session = editSessionWrapper.to(); | ||
this.editSession.undo(session); | ||
// session.undo(this.editSession); | ||
} catch (IOException e) { | ||
throw new IllegalStateException(e); | ||
} | ||
this.free(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...lugin/src/main/java/io/tofpu/speedbridge2/command/subcommand/debug/EmptyBridgePlayer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.tofpu.speedbridge2.command.subcommand.debug; | ||
|
||
import io.tofpu.speedbridge2.model.player.object.BridgePlayer; | ||
|
||
import java.util.UUID; | ||
|
||
public class EmptyBridgePlayer extends BridgePlayer { | ||
protected EmptyBridgePlayer(UUID id) { | ||
super(null, null, id); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...igot-plugin/src/main/java/io/tofpu/speedbridge2/command/subcommand/debug/GameIsland2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.tofpu.speedbridge2.command.subcommand.debug; | ||
|
||
import io.tofpu.speedbridge2.model.island.arena.ArenaManager; | ||
import io.tofpu.speedbridge2.model.island.object.GameIsland; | ||
import io.tofpu.speedbridge2.model.island.object.land.IslandLand; | ||
|
||
public class GameIsland2 extends GameIsland { | ||
private IslandLand islandLand; | ||
|
||
public GameIsland2(final ArenaManager arenaManager, GameIsland gameIsland) { | ||
super(arenaManager, gameIsland.getIsland(), gameIsland.getGamePlayer()); | ||
} | ||
|
||
public void setIslandPlot(final IslandLand islandLand) { | ||
this.islandLand = islandLand; | ||
} | ||
|
||
@Override | ||
public IslandLand getIslandPlot() { | ||
return this.islandLand; | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
...src/main/java/io/tofpu/speedbridge2/command/subcommand/debug/SpeedBridgeDebugCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package io.tofpu.speedbridge2.command.subcommand.debug; | ||
|
||
import com.sk89q.worldedit.WorldEditException; | ||
import io.tofpu.speedbridge2.model.island.IslandFactory; | ||
import io.tofpu.speedbridge2.model.island.arena.ArenaManager; | ||
import io.tofpu.speedbridge2.model.island.object.GameIsland; | ||
import io.tofpu.speedbridge2.model.island.object.Island; | ||
import io.tofpu.speedbridge2.model.island.object.land.IslandLand; | ||
import io.tofpu.speedbridge2.model.player.object.GamePlayer; | ||
import org.bukkit.Location; | ||
import org.bukkit.entity.Player; | ||
import revxrsal.commands.annotation.Command; | ||
import revxrsal.commands.annotation.Default; | ||
import revxrsal.commands.annotation.Subcommand; | ||
import revxrsal.commands.annotation.Usage; | ||
import revxrsal.commands.bukkit.annotation.CommandPermission; | ||
|
||
import java.util.*; | ||
|
||
@Command("speedbridge debug") | ||
@CommandPermission("speedbridge.debug") | ||
public class SpeedBridgeDebugCommand { | ||
private final Map<Island, List<GameIsland>> generatedGames = new HashMap<>(); | ||
private final ArenaManager arenaManager; | ||
|
||
public SpeedBridgeDebugCommand(ArenaManager arenaManager) { | ||
this.arenaManager = arenaManager; | ||
} | ||
|
||
@Subcommand("arena teleport") | ||
public String islandTeleport(final Player player) { | ||
double[] positions = arenaManager.getPositions(); | ||
player.teleport(new Location(this.arenaManager.getWorld(), positions[0], positions[1], positions[2])); | ||
return String.format("Teleported you to world %s with %s coordinates", arenaManager.getWorld().getName(), positions); | ||
} | ||
|
||
@Subcommand("island generate") | ||
@Usage("island generate <island> [amount]") | ||
public String generateGame(final Island island, final @Default("1") int amount) { | ||
for (int i = 0; i < amount; i++) { | ||
generateGame(island); | ||
} | ||
return String.format("Generated %s games of island type %s", amount, island.getSlot()); | ||
} | ||
|
||
@Subcommand("island destroy") | ||
@Usage("island destroy") | ||
public String islandClear(final Island island) { | ||
int gameAmountDestroyed = destroyGames(island); | ||
int islandType = island.getSlot(); | ||
return String.format("Destroyed %s games of island type %s!", gameAmountDestroyed, islandType); | ||
} | ||
|
||
private int destroyGames(final Island island) { | ||
List<GameIsland> games = this.generatedGames.get(island); | ||
games.forEach(game -> { | ||
DestroyableLand islandPlot = (DestroyableLand) game.getIslandPlot(); | ||
islandPlot.destroy(); | ||
}); | ||
return games.size(); | ||
} | ||
|
||
public void generateGame(final Island island) { | ||
final GamePlayer gamePlayer = GamePlayer.of(new EmptyBridgePlayer(UUID.randomUUID())); | ||
final GameIsland2 gameIsland = new GameIsland2(arenaManager, IslandFactory.createGame(island, gamePlayer)); | ||
|
||
DestroyableLand islandLand = new DestroyableLand(arenaManager.justReservePlot(gameIsland)); | ||
try { | ||
islandLand.generatePlot(); | ||
} catch (WorldEditException e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
||
gameIsland.setIslandPlot(islandLand); | ||
|
||
this.generatedGames.compute(island, (island1, gameIslands) -> { | ||
if (gameIslands == null) { | ||
gameIslands = new ArrayList<>(); | ||
} | ||
gameIslands.add(gameIsland); | ||
return gameIslands; | ||
}); | ||
} | ||
} |
Oops, something went wrong.