diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..0be1c0c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "java.configuration.updateBuildConfiguration": "automatic", + "java.compile.nullAnalysis.mode": "automatic" +} \ No newline at end of file diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml new file mode 100644 index 0000000..ccde445 --- /dev/null +++ b/dependency-reduced-pom.xml @@ -0,0 +1,83 @@ + + + 4.0.0 + com.softwarerat + mlgrush + mlgrush + 1.0.24-SNAPSHOT + + + + maven-compiler-plugin + 3.13.0 + + ${java.version} + ${java.version} + + + + maven-shade-plugin + 3.5.3 + + + package + + shade + + + + + com.softwarerat.MLGRush.MLGRush + + + META-INF/spring.handlers + + + META-INF/spring.schemas + + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + + + + + + papermc-repo + https://repo.papermc.io/repository/maven-public/ + + + sonatype + https://oss.sonatype.org/content/groups/public/ + + + + + io.papermc.paper + paper-api + 1.21.1-R0.1-SNAPSHOT + provided + + + org.projectlombok + lombok + 1.18.42 + provided + + + + 21 + UTF-8 + + diff --git a/pom.xml b/pom.xml index f3770fc..d8a196d 100644 --- a/pom.xml +++ b/pom.xml @@ -1,37 +1,23 @@ - - 4.0.0 - de.softwarerat + 4.0.0 + com.softwarerat mlgrush 1.0.24-SNAPSHOT jar mlgrush - - - - gitlab-maven - https://gitlab.softwarerat.com/api/v4/projects/25/packages/maven - - - gitlab-maven - https://gitlab.softwarerat.com/api/v4/projects/25/packages/maven - - - - - 18 + 21 UTF-8 - clean package + org.apache.maven.plugins maven-compiler-plugin @@ -41,6 +27,8 @@ ${java.version} + + org.apache.maven.plugins maven-shade-plugin @@ -51,29 +39,43 @@ shade + + + + + com.softwarerat.MLGRush.MLGRush + + + META-INF/spring.handlers + + + META-INF/spring.schemas + + + + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + - - - src/main/resources - true - - - papermc-repo https://repo.papermc.io/repository/maven-public/ - - gitlab-maven - https://Gitlab.Softwarerat.com/api/v4/projects/16/packages/maven - - sonatype https://oss.sonatype.org/content/groups/public/ @@ -90,7 +92,7 @@ org.projectlombok lombok - 1.18.28 + 1.18.42 provided @@ -99,4 +101,5 @@ 1.6.4-SNAPSHOT - + + \ No newline at end of file diff --git a/src/main/java/com/softwarerat/MLGRush/MLGRush/GameState/IngameState.java b/src/main/java/com/softwarerat/MLGRush/MLGRush/GameState/IngameState.java new file mode 100644 index 0000000..83bcc3b --- /dev/null +++ b/src/main/java/com/softwarerat/MLGRush/MLGRush/GameState/IngameState.java @@ -0,0 +1,106 @@ +package com.softwarerat.MLGRush.MLGRush.GameState; + +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; + +import com.softwarerat.API.builder.SpigotInventory; +import com.softwarerat.API.builder.SpigotItem; +import com.softwarerat.API.gameState.IGameState; +import com.softwarerat.MLGRush.MLGRush.MLGRush; +import com.softwarerat.MLGRush.MLGRush.data.Scores; + +import lombok.Getter; + +public class IngameState implements IGameState { + + private final Scores scores; + private final MLGRush plugin; + + @Getter + private Player player1; + + @Getter + private Player player2; + + public IngameState(MLGRush plugin, Scores scores) { + this.plugin = plugin; + this.scores = scores; + } + + @Override + public void Start() { + + Location redSpawn = getLocation("spawn.red"); + Location blueSpawn = getLocation("spawn.blue"); + + scores.getScoreBlue().set(0); + scores.getScoreRed().set(0); + + int index = 0; + + for (Player player : Bukkit.getOnlinePlayers()) { + + preparePlayer(player); + + if (index == 0) { + player1 = player; + player.teleport(redSpawn); + player.setRespawnLocation(redSpawn); + } else if (index == 1) { + player2 = player; + player.teleport(blueSpawn); + player.setRespawnLocation(blueSpawn); + } + + index++; + } + } + + @Override + public void Stop() { + Bukkit.shutdown(); + } + + private void preparePlayer(Player player) { + + SpigotInventory inventory = new SpigotInventory(player, plugin); + inventory.clear(); + + inventory.addItem(new SpigotItem(Material.SANDSTONE, 64).build()); + inventory.addItem(new SpigotItem(Material.STICK, 1) + .addUnsafeEnchantment(Enchantment.KNOCKBACK, 1) + .build()); + inventory.addItem(new SpigotItem(Material.WOODEN_PICKAXE, 1) + .addEnchant(Enchantment.EFFICIENCY, 5) + .setUnbreakable(true) + .build()); + + player.setGameMode(GameMode.SURVIVAL); + } + + private Location getLocation(String path) { + + FileConfiguration config = plugin.getConfig(); + + String worldName = config.getString(path + ".world"); + double x = config.getDouble(path + ".x"); + double y = config.getDouble(path + ".y"); + double z = config.getDouble(path + ".z"); + float yaw = (float) config.getDouble(path + ".yaw"); + float pitch = (float) config.getDouble(path + ".pitch"); + + World world = Bukkit.getWorld(worldName); + + if (world == null) { + throw new IllegalArgumentException("World '" + worldName + "' not found in config!"); + } + + return new Location(world, x, y, z, yaw, pitch); + } +} \ No newline at end of file diff --git a/src/main/java/de/softwarerat/MLGRush/GameState/LobbyState.java b/src/main/java/com/softwarerat/MLGRush/MLGRush/GameState/LobbyState.java similarity index 83% rename from src/main/java/de/softwarerat/MLGRush/GameState/LobbyState.java rename to src/main/java/com/softwarerat/MLGRush/MLGRush/GameState/LobbyState.java index b28ed08..ef70ded 100644 --- a/src/main/java/de/softwarerat/MLGRush/GameState/LobbyState.java +++ b/src/main/java/com/softwarerat/MLGRush/MLGRush/GameState/LobbyState.java @@ -1,4 +1,4 @@ -package de.softwarerat.MLGRush.GameState; +package com.softwarerat.MLGRush.MLGRush.GameState; import com.softwarerat.API.gameState.IGameState; import com.softwarerat.API.world.WorldAPI; @@ -14,12 +14,12 @@ public class LobbyState implements IGameState { @Override public void Start() { - + worldAPI.loadWorld("ingame"); } @Override public void Stop() { - worldAPI.loadWorld("ingame"); + ingameState.Start(); } } diff --git a/src/main/java/de/softwarerat/MLGRush/IPrefix.java b/src/main/java/com/softwarerat/MLGRush/MLGRush/IPrefix.java similarity index 98% rename from src/main/java/de/softwarerat/MLGRush/IPrefix.java rename to src/main/java/com/softwarerat/MLGRush/MLGRush/IPrefix.java index 42cef39..d7755e8 100644 --- a/src/main/java/de/softwarerat/MLGRush/IPrefix.java +++ b/src/main/java/com/softwarerat/MLGRush/MLGRush/IPrefix.java @@ -1,9 +1,10 @@ -package de.softwarerat.MLGRush; +package com.softwarerat.MLGRush.MLGRush; -import com.softwarerat.API.prefix.PrefixAPI; import org.bukkit.ChatColor; import org.bukkit.entity.Player; +import com.softwarerat.API.prefix.PrefixAPI; + public class IPrefix { PrefixAPI prefixAPI; diff --git a/src/main/java/de/softwarerat/MLGRush/MLGRush.java b/src/main/java/com/softwarerat/MLGRush/MLGRush/MLGRush.java similarity index 76% rename from src/main/java/de/softwarerat/MLGRush/MLGRush.java rename to src/main/java/com/softwarerat/MLGRush/MLGRush/MLGRush.java index 61718e4..3e6cdbb 100644 --- a/src/main/java/de/softwarerat/MLGRush/MLGRush.java +++ b/src/main/java/com/softwarerat/MLGRush/MLGRush/MLGRush.java @@ -1,16 +1,5 @@ -package de.softwarerat.MLGRush; +package com.softwarerat.MLGRush.MLGRush; -import com.softwarerat.API.data.GameData; -import com.softwarerat.API.prefix.PrefixAPI; -import com.softwarerat.API.world.WorldAPI; -import com.softwarerat.GameAPI; -import de.softwarerat.MLGRush.GameState.IngameState; -import de.softwarerat.MLGRush.GameState.LobbyState; -import de.softwarerat.MLGRush.data.Scores; -import de.softwarerat.MLGRush.listener.BlockBreakListener; -import de.softwarerat.MLGRush.listener.JoinListener; -import de.softwarerat.MLGRush.listener.OutOfAreaListener; -import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -18,6 +7,18 @@ import org.bukkit.World; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scoreboard.Scoreboard; +import com.softwarerat.API.data.GameData; +import com.softwarerat.API.prefix.PrefixAPI; +import com.softwarerat.API.world.WorldAPI; +import com.softwarerat.GameAPI; +import com.softwarerat.MLGRush.MLGRush.GameState.IngameState; +import com.softwarerat.MLGRush.MLGRush.GameState.LobbyState; +import com.softwarerat.MLGRush.MLGRush.data.Scores; +import com.softwarerat.MLGRush.MLGRush.listener.BlockBreakListener; +import com.softwarerat.MLGRush.MLGRush.listener.JoinListener; + +import lombok.Getter; + public final class MLGRush extends JavaPlugin { GameAPI gameAPI; GameData gameData; @@ -29,8 +30,29 @@ public final class MLGRush extends JavaPlugin { IngameState ingameState; @Override public void onEnable() { - + saveDefaultConfig(); + setupAPIs(); + setupGame(); + setupListener(); + // Plugin startup logic + + + } + + @Override + public void onDisable() { + // Plugin shutdown logic + } + + + public void setupListener() { + Bukkit.getPluginManager().registerEvents(new JoinListener(lobbyState,iPrefix),this); + Bukkit.getPluginManager().registerEvents(new BlockBreakListener(this,scores, ingameState),this); + // Bukkit.getPluginManager().registerEvents(new OutOfAreaListener(ingameState, this),this); + } + + public void setupAPIs() { gameAPI = new GameAPI(); gameAPI.enableAPI(this); gameAPI.setJavaPlugin(this); @@ -42,6 +64,9 @@ public final class MLGRush extends JavaPlugin { scoreboard = Bukkit.getScoreboardManager().getMainScoreboard(); gameData.setScoreboard(scoreboard); prefixAPI = new PrefixAPI(scoreboard); + } + + public void setupGame() { if (Bukkit.getScoreboardManager().getMainScoreboard().getTeam("1Admin") == null){ prefixAPI.createPrefix("Admin", 01, ChatColor.RED + "Admin " + ChatColor.GRAY + "| "); @@ -69,16 +94,8 @@ public final class MLGRush extends JavaPlugin { // Plugin startup logic iPrefix = new IPrefix(prefixAPI); scores = new Scores(); - ingameState = new IngameState(scores); + ingameState = new IngameState(this,scores); lobbyState = new LobbyState(ingameState,new WorldAPI()); - - Bukkit.getPluginManager().registerEvents(new JoinListener(lobbyState,iPrefix),this); - Bukkit.getPluginManager().registerEvents(new BlockBreakListener(scores, ingameState),this); - Bukkit.getPluginManager().registerEvents(new OutOfAreaListener(ingameState),this); - } - - @Override - public void onDisable() { - // Plugin shutdown logic + lobbyState.Start(); } } diff --git a/src/main/java/de/softwarerat/MLGRush/data/Scores.java b/src/main/java/com/softwarerat/MLGRush/MLGRush/data/Scores.java similarity index 83% rename from src/main/java/de/softwarerat/MLGRush/data/Scores.java rename to src/main/java/com/softwarerat/MLGRush/MLGRush/data/Scores.java index e36106e..6c87d0f 100644 --- a/src/main/java/de/softwarerat/MLGRush/data/Scores.java +++ b/src/main/java/com/softwarerat/MLGRush/MLGRush/data/Scores.java @@ -1,10 +1,10 @@ -package de.softwarerat.MLGRush.data; +package com.softwarerat.MLGRush.MLGRush.data; + +import java.util.concurrent.atomic.AtomicInteger; import lombok.Getter; import lombok.Setter; -import java.util.concurrent.atomic.AtomicInteger; - @Setter @Getter public class Scores { diff --git a/src/main/java/com/softwarerat/MLGRush/MLGRush/data/Yaml.java b/src/main/java/com/softwarerat/MLGRush/MLGRush/data/Yaml.java new file mode 100644 index 0000000..d92b1aa --- /dev/null +++ b/src/main/java/com/softwarerat/MLGRush/MLGRush/data/Yaml.java @@ -0,0 +1,62 @@ +package com.softwarerat.MLGRush.MLGRush.data; + + +import java.io.File; +import java.io.IOException; + +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; + +public class Yaml { + + private final File file; + private FileConfiguration config; + + public Yaml(String path, String fileName) { + this.file = new File(path, fileName); // FIX HERE + load(); + } + + + + public void load() { + this.config = YamlConfiguration.loadConfiguration(file); + } + + public void save() { + try { + config.save(file); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public void reload() { + load(); + } + + public FileConfiguration getConfig() { + return config; + } + + public void set(String path, Object value) { + config.set(path, value); + save(); + } + + public Object get(String path) { + return config.get(path); + } + + public String getString(String path) { + return config.getString(path); + } + + public int getInt(String path) { + return config.getInt(path); + } + + public boolean getBoolean(String path) { + return config.getBoolean(path); + } +} diff --git a/src/main/java/com/softwarerat/MLGRush/MLGRush/listener/BlockBreakListener.java b/src/main/java/com/softwarerat/MLGRush/MLGRush/listener/BlockBreakListener.java new file mode 100644 index 0000000..d323aa2 --- /dev/null +++ b/src/main/java/com/softwarerat/MLGRush/MLGRush/listener/BlockBreakListener.java @@ -0,0 +1,118 @@ +package com.softwarerat.MLGRush.MLGRush.listener; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; + +import com.softwarerat.API.builder.SpigotInventory; +import com.softwarerat.API.builder.SpigotItem; +import com.softwarerat.MLGRush.MLGRush.GameState.IngameState; +import com.softwarerat.MLGRush.MLGRush.MLGRush; +import com.softwarerat.MLGRush.MLGRush.data.Scores; + +public class BlockBreakListener implements Listener { + + private final Scores scores; + private final IngameState ingameState; + private final MLGRush plugin; + + public BlockBreakListener(MLGRush plugin, Scores scores, IngameState ingameState) { + this.plugin = plugin; + this.scores = scores; + this.ingameState = ingameState; + } + + @EventHandler + public void onBlockBreak(BlockBreakEvent event) { + + Player player1 = ingameState.getPlayer1(); + Player player2 = ingameState.getPlayer2(); + + if (player1 == null || player2 == null) return; + + if (event.getBlock().getType() != Material.SANDSTONE) { + event.setCancelled(true); + + // BLUE BED -> RED SCORES + if (event.getBlock().getType() == Material.BLUE_BED) { + if (event.getPlayer().equals(player1)) { + scores.getScoreRed().incrementAndGet(); + handleRoundWin("Rot +1", true, player1, player2); + } + } + + // RED BED -> BLUE SCORES + else if (event.getBlock().getType() == Material.RED_BED) { + if (event.getPlayer().equals(player2)) { + scores.getScoreBlue().incrementAndGet(); + handleRoundWin("Blau +1", false, player1, player2); + } + } + + checkWinCondition(); + } + } + + private void handleRoundWin(String message, boolean redScored, Player player1, Player player2) { + + resetInventory(player1); + resetInventory(player2); + + Location redSpawn = getLocation("spawn.red"); + Location blueSpawn = getLocation("spawn.blue"); + + player1.teleport(redSpawn); + player2.teleport(blueSpawn); + + Bukkit.getOnlinePlayers().forEach(player -> player.sendMessage(message)); + } + + private void resetInventory(Player player) { + SpigotInventory inv = new SpigotInventory(player, plugin); + inv.clear(); + inv.addItem(new SpigotItem(Material.SANDSTONE, 64).build()); + inv.addItem(new SpigotItem(Material.STICK, 1) + .addUnsafeEnchantment(Enchantment.KNOCKBACK, 1) + .build()); + inv.addItem(new SpigotItem(Material.WOODEN_PICKAXE, 1) + .addEnchant(Enchantment.EFFICIENCY, 5) + .setUnbreakable(true) + .build()); + } + + private void checkWinCondition() { + if (scores.getScoreRed().get() >= 10) { + ingameState.Stop(); + Bukkit.getOnlinePlayers().forEach(player -> + player.sendTitle("Rot hat gewonnen", "Server startet nun neu")); + } else if (scores.getScoreBlue().get() >= 10) { + ingameState.Stop(); + Bukkit.getOnlinePlayers().forEach(player -> + player.sendTitle("Blau hat gewonnen", "Server startet nun neu")); + } + } + + private Location getLocation(String path) { + FileConfiguration config = plugin.getConfig(); + + String worldName = config.getString(path + ".world"); + double x = config.getDouble(path + ".x"); + double y = config.getDouble(path + ".y"); + double z = config.getDouble(path + ".z"); + float yaw = (float) config.getDouble(path + ".yaw"); + float pitch = (float) config.getDouble(path + ".pitch"); + World world = Bukkit.getWorld(worldName); + if (world == null) { + throw new IllegalArgumentException("World '" + worldName + "' not found in config!"); + } + + return new Location(world, x, y, z, yaw, pitch); + } +} \ No newline at end of file diff --git a/src/main/java/de/softwarerat/MLGRush/listener/JoinListener.java b/src/main/java/com/softwarerat/MLGRush/MLGRush/listener/JoinListener.java similarity index 83% rename from src/main/java/de/softwarerat/MLGRush/listener/JoinListener.java rename to src/main/java/com/softwarerat/MLGRush/MLGRush/listener/JoinListener.java index 4dddba1..9acc895 100644 --- a/src/main/java/de/softwarerat/MLGRush/listener/JoinListener.java +++ b/src/main/java/com/softwarerat/MLGRush/MLGRush/listener/JoinListener.java @@ -1,14 +1,19 @@ -package de.softwarerat.MLGRush.listener; +package com.softwarerat.MLGRush.MLGRush.listener; -import de.softwarerat.MLGRush.GameState.LobbyState; -import de.softwarerat.MLGRush.IPrefix; -import org.bukkit.*; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; +import com.softwarerat.MLGRush.MLGRush.GameState.LobbyState; +import com.softwarerat.MLGRush.MLGRush.IPrefix; + public class JoinListener implements Listener { LobbyState lobbyState; diff --git a/src/main/java/com/softwarerat/MLGRush/MLGRush/listener/OutOfAreaListener.java b/src/main/java/com/softwarerat/MLGRush/MLGRush/listener/OutOfAreaListener.java new file mode 100644 index 0000000..a8a6428 --- /dev/null +++ b/src/main/java/com/softwarerat/MLGRush/MLGRush/listener/OutOfAreaListener.java @@ -0,0 +1,73 @@ +package com.softwarerat.MLGRush.MLGRush.listener; + + + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerMoveEvent; + +import com.softwarerat.MLGRush.MLGRush.GameState.IngameState; +import com.softwarerat.MLGRush.MLGRush.MLGRush; + +public class OutOfAreaListener implements Listener { + IngameState ingameState; + Player player2; + Player player1; + Location location; + Location location2; + private final MLGRush plugin; + + public OutOfAreaListener(IngameState ingameState, MLGRush plugin) { + this.ingameState = ingameState; + this.plugin = plugin; + } + +@EventHandler +public void onPlayerMove(PlayerMoveEvent event) { + Player player = event.getPlayer(); + Location redSpawn = getLocation("spawn.red"); + Location blueSpawn = getLocation("spawn.blue"); + + player1 = ingameState.getPlayer1(); + player2 = ingameState.getPlayer2(); + + if (player1 == null || player2 == null) return; + + int fallLimitRed = redSpawn.getBlockY() - 5; + int fallLimitBlue = blueSpawn.getBlockY() - 5; + + int playerY = player.getLocation().getBlockY(); + + if (player.getUniqueId().equals(player1.getUniqueId()) && playerY <= fallLimitRed) { + player.teleport(redSpawn); + } else if (player.getUniqueId().equals(player2.getUniqueId()) && playerY <= fallLimitBlue) { + player.teleport(blueSpawn); + } +} + + + + + private Location getLocation(String path) { + FileConfiguration config = plugin.getConfig(); + + String worldName = config.getString(path + ".world"); + double x = config.getDouble(path + ".x"); + double y = config.getDouble(path + ".y"); + double z = config.getDouble(path + ".z"); + float yaw = (float) config.getDouble(path + ".yaw"); + float pitch = (float) config.getDouble(path + ".pitch"); + + World world = Bukkit.getWorld(worldName); + if (world == null) { + throw new IllegalArgumentException("World '" + worldName + "' not found in config!"); + } + + return new Location(world, x, y, z, yaw, pitch); + } +} diff --git a/src/main/java/de/softwarerat/MLGRush/GameState/IngameState.java b/src/main/java/de/softwarerat/MLGRush/GameState/IngameState.java deleted file mode 100644 index 8c5d589..0000000 --- a/src/main/java/de/softwarerat/MLGRush/GameState/IngameState.java +++ /dev/null @@ -1,67 +0,0 @@ -package de.softwarerat.MLGRush.GameState; - - -import com.softwarerat.API.builder.SpigotInventory; -import com.softwarerat.API.builder.SpigotItem; -import com.softwarerat.API.gameState.IGameState; -import de.softwarerat.MLGRush.MLGRush; -import de.softwarerat.MLGRush.data.Scores; -import lombok.Getter; -import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; - -import java.util.concurrent.atomic.AtomicReference; - -public class IngameState implements IGameState { - - public IngameState(Scores scores) { - this.scores = scores; - } - - Scores scores; - Location location; - Location location2; - @Getter - Player player1; - @Getter - Player player2; - @Override - public void Start() { - location = new Location(Bukkit.getWorld("ingame"),19,53,0); - location2 = new Location(Bukkit.getWorld("ingame"),-19,53,0); - AtomicReference teleported = new AtomicReference<>(false); - Bukkit.getOnlinePlayers().forEach(player -> - { - SpigotInventory spigotInventory = new SpigotInventory(player, MLGRush.getPlugin(MLGRush.class)); - spigotInventory.addItem(new SpigotItem(Material.SANDSTONE,64).build()); - spigotInventory.addItem(new SpigotItem(Material.STICK,1).addUnsafeEnchantment(Enchantment.KNOCKBACK,1).build()); - spigotInventory.addItem(new SpigotItem(Material.WOODEN_PICKAXE,1).addEnchant(Enchantment.EFFICIENCY,5).setUnbreakable(true).build()); - player.setGameMode(GameMode.SURVIVAL); - scores.getScoreBlue().set(0); - scores.getScoreRed().set(0); - if (!teleported.get()){ - teleported.set(true); - player1 = player; - player1.teleport(location); - player1.setRespawnLocation(location); - } else { - player2 = player; - player2.teleport(location2); - player2.setRespawnLocation(location2); - } - - - }); - - - } - - @Override - public void Stop() { - Bukkit.getServer().shutdown(); - } -} diff --git a/src/main/java/de/softwarerat/MLGRush/listener/BlockBreakListener.java b/src/main/java/de/softwarerat/MLGRush/listener/BlockBreakListener.java deleted file mode 100644 index 48a6337..0000000 --- a/src/main/java/de/softwarerat/MLGRush/listener/BlockBreakListener.java +++ /dev/null @@ -1,94 +0,0 @@ -package de.softwarerat.MLGRush.listener; - -import com.softwarerat.API.builder.SpigotInventory; -import com.softwarerat.API.builder.SpigotItem; -import de.softwarerat.MLGRush.GameState.IngameState; -import de.softwarerat.MLGRush.MLGRush; -import de.softwarerat.MLGRush.data.Scores; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockBreakEvent; - -import java.util.concurrent.atomic.AtomicReference; - -public class BlockBreakListener implements Listener { - Scores scores; - IngameState ingameState; - Player player1; - Player player2; - - public BlockBreakListener(Scores scores, IngameState ingameState) { - this.scores = scores; - this.ingameState = ingameState; - - } - Location location; - Location location2; - @EventHandler - public void onBlockBreak(BlockBreakEvent event) { - player2 = ingameState.getPlayer2(); - player1 = ingameState.getPlayer1(); - if (!(event.getBlock().getBlockData().getMaterial() == Material.SANDSTONE)) { - event.setCancelled(true); - if (event.getBlock().getBlockData().getMaterial() == Material.BLUE_BED) { - if (event.getPlayer().equals(player1)){ - scores.getScoreRed().getAndIncrement(); - location = new Location(Bukkit.getWorld("ingame"),19,53,0); - location2 = new Location(Bukkit.getWorld("ingame"),-19,53,0); - AtomicReference teleported = new AtomicReference<>(false); - SpigotInventory spigotInventory = new SpigotInventory(player1, MLGRush.getPlugin(MLGRush.class)); - spigotInventory.clear(); - spigotInventory.addItem(new SpigotItem(Material.SANDSTONE,64).build()); - spigotInventory.addItem(new SpigotItem(Material.STICK,1).addUnsafeEnchantment(Enchantment.KNOCKBACK,1).build()); - spigotInventory.addItem(new SpigotItem(Material.WOODEN_PICKAXE,1).addEnchant(Enchantment.EFFICIENCY,5).setUnbreakable(true).build()); - SpigotInventory spigotInventory1 = new SpigotInventory(player2, MLGRush.getPlugin(MLGRush.class)); - spigotInventory1.clear(); - spigotInventory1.addItem(new SpigotItem(Material.SANDSTONE,64).build()); - spigotInventory1.addItem(new SpigotItem(Material.STICK,1).addUnsafeEnchantment(Enchantment.KNOCKBACK,1).build()); - spigotInventory1.addItem(new SpigotItem(Material.WOODEN_PICKAXE,1).addEnchant(Enchantment.EFFICIENCY,5).setUnbreakable(true).build()); - player1.teleport(location); - player2.teleport(location2); - Bukkit.getOnlinePlayers().forEach(player -> player.sendMessage("Rot +1")); - } - - } else if (event.getBlock().getBlockData().getMaterial() == Material.RED_BED) { - if (event.getPlayer().equals(player2)) { - SpigotInventory spigotInventory = new SpigotInventory(player1, MLGRush.getPlugin(MLGRush.class)); - spigotInventory.clear(); - spigotInventory.addItem(new SpigotItem(Material.SANDSTONE,64).build()); - spigotInventory.addItem(new SpigotItem(Material.STICK,1).addUnsafeEnchantment(Enchantment.KNOCKBACK,1).build()); - spigotInventory.addItem(new SpigotItem(Material.WOODEN_PICKAXE,1).addEnchant(Enchantment.EFFICIENCY,5).setUnbreakable(true).build()); - SpigotInventory spigotInventory1 = new SpigotInventory(player2, MLGRush.getPlugin(MLGRush.class)); - spigotInventory1.clear(); - spigotInventory1.addItem(new SpigotItem(Material.SANDSTONE,64).build()); - spigotInventory1.addItem(new SpigotItem(Material.STICK,1).addUnsafeEnchantment(Enchantment.KNOCKBACK,1).build()); - spigotInventory1.addItem(new SpigotItem(Material.WOODEN_PICKAXE,1).addEnchant(Enchantment.EFFICIENCY,5).setUnbreakable(true).build()); - location = new Location(Bukkit.getWorld("ingame"), 19, 53, 0); - location2 = new Location(Bukkit.getWorld("ingame"), -19, 53, 0); - scores.getScoreBlue().getAndIncrement(); - player1.teleport(location); - player2.teleport(location2); - Bukkit.getOnlinePlayers().forEach(player -> player.sendMessage("Blau +1")); - } - } - - if (scores.getScoreRed().get() == 10) { - ingameState.Stop(); - Bukkit.getOnlinePlayers().forEach(player -> { - player.sendTitle("Rot hat gewonnen", "server startet nun neu"); - }); - } else if (scores.getScoreBlue().get() == 10) { - ingameState.Stop(); - Bukkit.getOnlinePlayers().forEach(player -> { - player.sendTitle("Blau hat gewonnen", "server startet nun neu"); - }); - } - } - } - -} diff --git a/src/main/java/de/softwarerat/MLGRush/listener/OutOfAreaListener.java b/src/main/java/de/softwarerat/MLGRush/listener/OutOfAreaListener.java deleted file mode 100644 index c1c3269..0000000 --- a/src/main/java/de/softwarerat/MLGRush/listener/OutOfAreaListener.java +++ /dev/null @@ -1,39 +0,0 @@ -package de.softwarerat.MLGRush.listener; - -import de.softwarerat.MLGRush.GameState.IngameState; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerMoveEvent; - -public class OutOfAreaListener implements Listener { - IngameState ingameState; - Player player2; - Player player1; - Location location; - Location location2; - - public OutOfAreaListener(IngameState ingameState) { - this.ingameState = ingameState; - } - - @EventHandler - public void onPlayerMove(PlayerMoveEvent event) { - location = new Location(Bukkit.getWorld("ingame"),19,53,0); - location2 = new Location(Bukkit.getWorld("ingame"),-19,53,0); - player2 = ingameState.getPlayer2(); - player1 = ingameState.getPlayer1(); - if (event.getPlayer().getLocation().getBlockY() <= 39){ - if (event.getPlayer().getName().equals(player1.getName())){ - player1.teleport(location); - - }else { - player2.teleport(location2); - } - } - - } - -} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml new file mode 100644 index 0000000..f70d1e0 --- /dev/null +++ b/src/main/resources/config.yml @@ -0,0 +1,30 @@ +spawn: + red: + world: ingame + x: 19 + y: 53 + z: 0 + yaw: 0 + pitch: 0 + blue: + world: ingame + x: -19 + y: 53 + z: 0 + yaw: 180 + pitch: 0 +bed: + red: + world: ingame + x: 19 + y: 53 + z: 0 + yaw: 0 + pitch: 0 + blue: + world: ingame + x: -19 + y: 53 + z: 0 + yaw: 180 + pitch: 0 \ No newline at end of file diff --git a/src/main/resources/paper-plugin.yml b/src/main/resources/paper-plugin.yml index c60d9d9..2e75163 100644 --- a/src/main/resources/paper-plugin.yml +++ b/src/main/resources/paper-plugin.yml @@ -1,4 +1,6 @@ name: MLGRush version: '1.0-SNAPSHOT' -main: de.softwarerat.MLGRush.MLGRush +main: com.softwarerat.MLGRush.MLGRush.MLGRush +author: Softwarerat +description: A MLGRush plugin for Minecraft 1.21.1 api-version: '1.21' diff --git a/target/classes/com/softwarerat/MLGRush/MLGRush/GameState/IngameState.class b/target/classes/com/softwarerat/MLGRush/MLGRush/GameState/IngameState.class new file mode 100644 index 0000000..6447e38 Binary files /dev/null and b/target/classes/com/softwarerat/MLGRush/MLGRush/GameState/IngameState.class differ diff --git a/target/classes/com/softwarerat/MLGRush/MLGRush/GameState/LobbyState.class b/target/classes/com/softwarerat/MLGRush/MLGRush/GameState/LobbyState.class new file mode 100644 index 0000000..8d1f47a Binary files /dev/null and b/target/classes/com/softwarerat/MLGRush/MLGRush/GameState/LobbyState.class differ diff --git a/target/classes/com/softwarerat/MLGRush/MLGRush/IPrefix.class b/target/classes/com/softwarerat/MLGRush/MLGRush/IPrefix.class new file mode 100644 index 0000000..9af5bc6 Binary files /dev/null and b/target/classes/com/softwarerat/MLGRush/MLGRush/IPrefix.class differ diff --git a/target/classes/com/softwarerat/MLGRush/MLGRush/MLGRush.class b/target/classes/com/softwarerat/MLGRush/MLGRush/MLGRush.class new file mode 100644 index 0000000..ccdb268 Binary files /dev/null and b/target/classes/com/softwarerat/MLGRush/MLGRush/MLGRush.class differ diff --git a/target/classes/de/softwarerat/MLGRush/data/Scores.class b/target/classes/com/softwarerat/MLGRush/MLGRush/data/Scores.class similarity index 57% rename from target/classes/de/softwarerat/MLGRush/data/Scores.class rename to target/classes/com/softwarerat/MLGRush/MLGRush/data/Scores.class index 9db626f..996af88 100644 Binary files a/target/classes/de/softwarerat/MLGRush/data/Scores.class and b/target/classes/com/softwarerat/MLGRush/MLGRush/data/Scores.class differ diff --git a/target/classes/com/softwarerat/MLGRush/MLGRush/data/Yaml.class b/target/classes/com/softwarerat/MLGRush/MLGRush/data/Yaml.class new file mode 100644 index 0000000..cc6b023 Binary files /dev/null and b/target/classes/com/softwarerat/MLGRush/MLGRush/data/Yaml.class differ diff --git a/target/classes/com/softwarerat/MLGRush/MLGRush/listener/BlockBreakListener.class b/target/classes/com/softwarerat/MLGRush/MLGRush/listener/BlockBreakListener.class new file mode 100644 index 0000000..802cd6b Binary files /dev/null and b/target/classes/com/softwarerat/MLGRush/MLGRush/listener/BlockBreakListener.class differ diff --git a/target/classes/de/softwarerat/MLGRush/listener/JoinListener.class b/target/classes/com/softwarerat/MLGRush/MLGRush/listener/JoinListener.class similarity index 61% rename from target/classes/de/softwarerat/MLGRush/listener/JoinListener.class rename to target/classes/com/softwarerat/MLGRush/MLGRush/listener/JoinListener.class index 37eead3..b092f42 100644 Binary files a/target/classes/de/softwarerat/MLGRush/listener/JoinListener.class and b/target/classes/com/softwarerat/MLGRush/MLGRush/listener/JoinListener.class differ diff --git a/target/classes/com/softwarerat/MLGRush/MLGRush/listener/OutOfAreaListener.class b/target/classes/com/softwarerat/MLGRush/MLGRush/listener/OutOfAreaListener.class new file mode 100644 index 0000000..153362d Binary files /dev/null and b/target/classes/com/softwarerat/MLGRush/MLGRush/listener/OutOfAreaListener.class differ diff --git a/target/classes/config.yml b/target/classes/config.yml new file mode 100644 index 0000000..f70d1e0 --- /dev/null +++ b/target/classes/config.yml @@ -0,0 +1,30 @@ +spawn: + red: + world: ingame + x: 19 + y: 53 + z: 0 + yaw: 0 + pitch: 0 + blue: + world: ingame + x: -19 + y: 53 + z: 0 + yaw: 180 + pitch: 0 +bed: + red: + world: ingame + x: 19 + y: 53 + z: 0 + yaw: 0 + pitch: 0 + blue: + world: ingame + x: -19 + y: 53 + z: 0 + yaw: 180 + pitch: 0 \ No newline at end of file diff --git a/target/classes/de/softwarerat/MLGRush/GameState/IngameState.class b/target/classes/de/softwarerat/MLGRush/GameState/IngameState.class deleted file mode 100644 index 395b179..0000000 Binary files a/target/classes/de/softwarerat/MLGRush/GameState/IngameState.class and /dev/null differ diff --git a/target/classes/de/softwarerat/MLGRush/GameState/LobbyState.class b/target/classes/de/softwarerat/MLGRush/GameState/LobbyState.class deleted file mode 100644 index 21e4bad..0000000 Binary files a/target/classes/de/softwarerat/MLGRush/GameState/LobbyState.class and /dev/null differ diff --git a/target/classes/de/softwarerat/MLGRush/IPrefix.class b/target/classes/de/softwarerat/MLGRush/IPrefix.class deleted file mode 100644 index bdcf50c..0000000 Binary files a/target/classes/de/softwarerat/MLGRush/IPrefix.class and /dev/null differ diff --git a/target/classes/de/softwarerat/MLGRush/MLGRush.class b/target/classes/de/softwarerat/MLGRush/MLGRush.class deleted file mode 100644 index 8d89e26..0000000 Binary files a/target/classes/de/softwarerat/MLGRush/MLGRush.class and /dev/null differ diff --git a/target/classes/de/softwarerat/MLGRush/listener/BlockBreakListener.class b/target/classes/de/softwarerat/MLGRush/listener/BlockBreakListener.class deleted file mode 100644 index 475497e..0000000 Binary files a/target/classes/de/softwarerat/MLGRush/listener/BlockBreakListener.class and /dev/null differ diff --git a/target/classes/de/softwarerat/MLGRush/listener/OutOfAreaListener.class b/target/classes/de/softwarerat/MLGRush/listener/OutOfAreaListener.class deleted file mode 100644 index be5ddd3..0000000 Binary files a/target/classes/de/softwarerat/MLGRush/listener/OutOfAreaListener.class and /dev/null differ diff --git a/target/classes/paper-plugin.yml b/target/classes/paper-plugin.yml index c60d9d9..2e75163 100644 --- a/target/classes/paper-plugin.yml +++ b/target/classes/paper-plugin.yml @@ -1,4 +1,6 @@ name: MLGRush version: '1.0-SNAPSHOT' -main: de.softwarerat.MLGRush.MLGRush +main: com.softwarerat.MLGRush.MLGRush.MLGRush +author: Softwarerat +description: A MLGRush plugin for Minecraft 1.21.1 api-version: '1.21' diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties new file mode 100644 index 0000000..99dcbc9 --- /dev/null +++ b/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=mlgrush +groupId=com.softwarerat +version=1.0.24-SNAPSHOT diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst index 7d2c70e..392b3c3 100644 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -1,8 +1,9 @@ -/Users/zlavra/code/MLGRush/src/main/java/de/softwarerat/MLGRush/GameState/IngameState.java -/Users/zlavra/code/MLGRush/src/main/java/de/softwarerat/MLGRush/GameState/LobbyState.java -/Users/zlavra/code/MLGRush/src/main/java/de/softwarerat/MLGRush/IPrefix.java -/Users/zlavra/code/MLGRush/src/main/java/de/softwarerat/MLGRush/MLGRush.java -/Users/zlavra/code/MLGRush/src/main/java/de/softwarerat/MLGRush/data/Scores.java -/Users/zlavra/code/MLGRush/src/main/java/de/softwarerat/MLGRush/listener/BlockBreakListener.java -/Users/zlavra/code/MLGRush/src/main/java/de/softwarerat/MLGRush/listener/JoinListener.java -/Users/zlavra/code/MLGRush/src/main/java/de/softwarerat/MLGRush/listener/OutOfAreaListener.java +F:\Devel\mc\mlgrush-main\src\main\java\com\softwarerat\MLGRush\MLGRush\data\Scores.java +F:\Devel\mc\mlgrush-main\src\main\java\com\softwarerat\MLGRush\MLGRush\data\Yaml.java +F:\Devel\mc\mlgrush-main\src\main\java\com\softwarerat\MLGRush\MLGRush\GameState\IngameState.java +F:\Devel\mc\mlgrush-main\src\main\java\com\softwarerat\MLGRush\MLGRush\GameState\LobbyState.java +F:\Devel\mc\mlgrush-main\src\main\java\com\softwarerat\MLGRush\MLGRush\IPrefix.java +F:\Devel\mc\mlgrush-main\src\main\java\com\softwarerat\MLGRush\MLGRush\listener\BlockBreakListener.java +F:\Devel\mc\mlgrush-main\src\main\java\com\softwarerat\MLGRush\MLGRush\listener\JoinListener.java +F:\Devel\mc\mlgrush-main\src\main\java\com\softwarerat\MLGRush\MLGRush\listener\OutOfAreaListener.java +F:\Devel\mc\mlgrush-main\src\main\java\com\softwarerat\MLGRush\MLGRush\MLGRush.java diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/target/mlgrush-1.0.24-SNAPSHOT.jar b/target/mlgrush-1.0.24-SNAPSHOT.jar new file mode 100644 index 0000000..949aa9f Binary files /dev/null and b/target/mlgrush-1.0.24-SNAPSHOT.jar differ diff --git a/target/original-mlgrush-1.0.24-SNAPSHOT.jar b/target/original-mlgrush-1.0.24-SNAPSHOT.jar new file mode 100644 index 0000000..85c4f20 Binary files /dev/null and b/target/original-mlgrush-1.0.24-SNAPSHOT.jar differ