messed up applying but applying works
Some checks are pending
Build plugin / build (push) Waiting to run
Some checks are pending
Build plugin / build (push) Waiting to run
This commit is contained in:
parent
90b3a1922d
commit
62e3b4a4a2
|
@ -6,7 +6,9 @@ package xyz.twovb.sgm.games.impl.capturethebrick;
|
|||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
@ -22,10 +24,7 @@ import xyz.twovb.toolbox.utils.ChatUtils;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
public class CTB implements Minigame {
|
||||
final static String name = "CaptureTheBrick";
|
||||
|
@ -46,10 +45,12 @@ public class CTB implements Minigame {
|
|||
Bukkit.getPluginManager().registerEvents(this, SGM.getInstance());
|
||||
gameWorld = createGameWorld(world, uuid);
|
||||
gameWorld.setAutoSave(false);
|
||||
if (applyOptions()) {
|
||||
state = GameState.READY;
|
||||
owner.sendMessage("A new " + name + " instance with ID " + uuid + " has been created and is now ready!");
|
||||
} else {
|
||||
try {
|
||||
if (applyOptions()) {
|
||||
state = GameState.READY;
|
||||
owner.sendMessage("A new " + name + " instance with ID " + uuid + " has been created and is now ready!");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
owner.sendMessage(ChatUtils.translate(SGM.getInstance().getMessages().getString("sgm.game.cant-start")));
|
||||
}
|
||||
}
|
||||
|
@ -76,9 +77,18 @@ public class CTB implements Minigame {
|
|||
SGM.getInstance().getCLogger().log(teamName + " Player Spawn Area: " + playerSpawnArea);
|
||||
|
||||
// Log each team's brick spawns
|
||||
for (int i = 0; i < brickSpawns.size(); i++) {
|
||||
SGM.getInstance().getCLogger().log(teamName + " Brick Spawn " + (i + 1) + ": " + brickSpawns.get(i));
|
||||
// Process each brick spawn here if needed
|
||||
for (String brickSpawn : brickSpawns) {
|
||||
String[] coords = brickSpawn.split(",");
|
||||
if (coords.length == 3) {
|
||||
int x = Integer.parseInt(coords[0]);
|
||||
int y = Integer.parseInt(coords[1]);
|
||||
int z = Integer.parseInt(coords[2]);
|
||||
// Now you have x, y, z coordinates to work with
|
||||
placeBrick(new Location(gameWorld, x, y, z), teamName);
|
||||
} else {
|
||||
SGM.getInstance().getCLogger().error("Invalid brick spawn: " + coords[0]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -105,9 +115,15 @@ public class CTB implements Minigame {
|
|||
return true;
|
||||
}
|
||||
|
||||
// private void placeBrick(Integer integer) {
|
||||
//
|
||||
// }
|
||||
private void placeBrick(Location location, String team) {
|
||||
Block brick = location.getBlock();
|
||||
if (Objects.equals(team, "red")) {
|
||||
brick.setType(Material.RED_WOOL);
|
||||
}
|
||||
if (Objects.equals(team, "blue")) {
|
||||
brick.setType(Material.BLUE_WOOL);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
|
|
|
@ -167,26 +167,33 @@ public class LevelManager {
|
|||
}
|
||||
|
||||
public void loadLevels() {
|
||||
// Initialize enabledMaps for each registered game
|
||||
for (String game : SGM.getInstance().getGameManager().getRegisteredGames()) {
|
||||
enabledMaps.put(game, new ArrayList<>()); // Initialize an empty ArrayList for each game
|
||||
}
|
||||
// List all files (worlds) in the folder
|
||||
File folder = new File(mapPath);
|
||||
|
||||
// Load levels from levelPath
|
||||
loadWorldDir(levelPath, LevelType.LEVEL);
|
||||
}
|
||||
|
||||
private void loadWorldDir(String path, LevelType levelType) {
|
||||
File folder = new File(path);
|
||||
File[] files = folder.listFiles();
|
||||
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
if (file.isDirectory()) {
|
||||
// Check if sgm.yml exists in the world directory
|
||||
File configFile = new File(file, "sgm.yml");
|
||||
if (configFile.exists()) {
|
||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
|
||||
String game = config.getString("game");
|
||||
String name = config.getString("name");
|
||||
if (enabledMaps.containsKey(game)) {
|
||||
|
||||
if (enabledMaps.containsKey(game) && levelType == LevelType.MAP) {
|
||||
enabledMaps.get(game).add(name);
|
||||
// Load the world if sgm.yml exists
|
||||
loadWorld(file.getName(), LevelType.LEVEL);
|
||||
}
|
||||
// Load the world if sgm.yml exists
|
||||
loadWorld(file.getName(), levelType);
|
||||
} else {
|
||||
SGM.getInstance().getCLogger().log("Skipping directory " + file.getName() + ": sgm.yml not found.");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user