From 4947ede7dd8a0ac8d2b45d54c5871077091d0bb5 Mon Sep 17 00:00:00 2001 From: Jan9103 Date: Fri, 22 May 2020 16:36:52 +0200 Subject: [PATCH] init push --- src/Doku.txt | 4 + src/ToDo.txt | 19 +++ src/config.yml | 3 + src/de/steamwar/misslewars/EndTimer.java | 28 ++++ .../steamwar/misslewars/FightScoreboard.java | 78 ++++++++++ src/de/steamwar/misslewars/FightState.java | 7 + src/de/steamwar/misslewars/MWPlayer.java | 24 +++ src/de/steamwar/misslewars/MWTeam.java | 89 +++++++++++ .../misslewars/MissleSpawnSystem.java | 142 ++++++++++++++++++ src/de/steamwar/misslewars/MissleWars.java | 135 +++++++++++++++++ src/de/steamwar/misslewars/WinReasons.java | 7 + .../misslewars/commands/JoinCommand.java | 5 + .../misslewars/listener/DeathListener.java | 25 +++ .../misslewars/listener/EggClickListener.java | 21 +++ .../listener/FallOutOfWorldListener.java | 15 ++ .../misslewars/listener/JoinListener.java | 13 ++ .../listener/PortalDestructListener.java | 22 +++ src/plugin.yml | 8 + 18 files changed, 645 insertions(+) create mode 100644 src/Doku.txt create mode 100644 src/ToDo.txt create mode 100644 src/config.yml create mode 100644 src/de/steamwar/misslewars/EndTimer.java create mode 100644 src/de/steamwar/misslewars/FightScoreboard.java create mode 100644 src/de/steamwar/misslewars/FightState.java create mode 100644 src/de/steamwar/misslewars/MWPlayer.java create mode 100644 src/de/steamwar/misslewars/MWTeam.java create mode 100644 src/de/steamwar/misslewars/MissleSpawnSystem.java create mode 100644 src/de/steamwar/misslewars/MissleWars.java create mode 100644 src/de/steamwar/misslewars/WinReasons.java create mode 100644 src/de/steamwar/misslewars/commands/JoinCommand.java create mode 100644 src/de/steamwar/misslewars/listener/DeathListener.java create mode 100644 src/de/steamwar/misslewars/listener/EggClickListener.java create mode 100644 src/de/steamwar/misslewars/listener/FallOutOfWorldListener.java create mode 100644 src/de/steamwar/misslewars/listener/JoinListener.java create mode 100644 src/de/steamwar/misslewars/listener/PortalDestructListener.java create mode 100644 src/plugin.yml diff --git a/src/Doku.txt b/src/Doku.txt new file mode 100644 index 0000000..e48a346 --- /dev/null +++ b/src/Doku.txt @@ -0,0 +1,4 @@ +Rot ist im süden +SpawnEgg name == MissleName (Config) + incl Color-Tags, ect +Missle-Configs sind für Team Rot \ No newline at end of file diff --git a/src/ToDo.txt b/src/ToDo.txt new file mode 100644 index 0000000..ab1d365 --- /dev/null +++ b/src/ToDo.txt @@ -0,0 +1,19 @@ +Commands: + join + leave + forcestop +Config: + Timeout-Time + Runden max length + shield / platform / ect item on/off + give-speed (default: 11) +Features + Items: + shield + platform + fireball + pfeile + bridge + Item-giver + am anfang bogen geben + listener + commadns registrieren \ No newline at end of file diff --git a/src/config.yml b/src/config.yml new file mode 100644 index 0000000..d76b417 --- /dev/null +++ b/src/config.yml @@ -0,0 +1,3 @@ +portal: + red: -60 + blue: 60 \ No newline at end of file diff --git a/src/de/steamwar/misslewars/EndTimer.java b/src/de/steamwar/misslewars/EndTimer.java new file mode 100644 index 0000000..74fea99 --- /dev/null +++ b/src/de/steamwar/misslewars/EndTimer.java @@ -0,0 +1,28 @@ +package de.steamwar.misslewars; + +import java.util.TimerTask; + +import org.bukkit.Bukkit; + +public class EndTimer extends TimerTask{ + + private boolean endPrep; //if true it counts to end of preparing (after end server if not ingame); if false it counts to end of game -> win + + public EndTimer(boolean endPrep) { + this.endPrep = endPrep; + } + + @Override + public void run() { + if (endPrep) { + if (MissleWars.getFightState() != FightState.WAITING) return; + Bukkit.getServer().broadcastMessage("Da kein Gegner gefunden wurde schaltet der Server sich jetzt ab."); + Bukkit.getServer().shutdown(); + }else { + if (MissleWars.getFightState() == FightState.END) return; + //TODO end match - unentschieden + } + this.cancel(); + } + +} \ No newline at end of file diff --git a/src/de/steamwar/misslewars/FightScoreboard.java b/src/de/steamwar/misslewars/FightScoreboard.java new file mode 100644 index 0000000..21510bb --- /dev/null +++ b/src/de/steamwar/misslewars/FightScoreboard.java @@ -0,0 +1,78 @@ +package de.steamwar.misslewars; + +import de.steamwar.misslewars.MWTeam; + +import org.bukkit.Bukkit; +import org.bukkit.scoreboard.DisplaySlot; +import org.bukkit.scoreboard.Objective; +import org.bukkit.scoreboard.Scoreboard; + +import java.util.Objects; + +/** + * Modified Version of the Fight-System Scoreboard + */ +public class FightScoreboard { + + private FightScoreboard(){} + + private static final Scoreboard scoreboard = Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard(); + private static final Objective objective; + private static int index = 0; + + static{ + if(scoreboard.getObjective("AAA") == null) + //noinspection deprecation + objective = scoreboard.registerNewObjective("AAA", "BBB", "MissleWars"); + else + objective = scoreboard.getObjective("AAA"); + } + + public static void init(){ + Bukkit.getScheduler().scheduleSyncRepeatingTask(MissleWars.getPlugin(), () -> { + objective.unregister(); + //noinspection deprecation + scoreboard.registerNewObjective("AAA", "BBB", "MissleWars"); + objective.setDisplaySlot(DisplaySlot.SIDEBAR); + + MWTeam fightTeam = getIndexDisplay(); + if(fightTeam != null) + teamScoreboard(fightTeam); + else + generalScoreboard(); + + Bukkit.getOnlinePlayers().forEach(player -> player.setScoreboard(scoreboard)); + }, 0, 200); + } + + public static Scoreboard getScoreboard() { + return scoreboard; + } + + private static void teamScoreboard(MWTeam fightTeam){ + objective.setDisplayName(fightTeam.getColoredName()); + fightTeam.getPlayers().forEach(fp -> { + objective.getScore(fightTeam.getPrefix() + fp.getPlayer().getName()).setScore((int) fp.getKills()); + }); + } + + private static void generalScoreboard(){ + objective.setDisplayName("§6Kampf"); + int fightTime = MissleWars.getFightTime(); + if (fightTime >= 60) + objective.getScore("§7Zeit: §a" + fightTime / 60 + "m " + fightTime % 60 + "s").setScore(3); + else + objective.getScore("§7Zeit: §a" + fightTime + "s").setScore(3); + } + + private static MWTeam getIndexDisplay() { + index++; + if(index == 1) + return MissleWars.redTeam; + if(index == 2) + return MissleWars.blueTeam; + index = 0; + return null; + } + +} diff --git a/src/de/steamwar/misslewars/FightState.java b/src/de/steamwar/misslewars/FightState.java new file mode 100644 index 0000000..6787a9b --- /dev/null +++ b/src/de/steamwar/misslewars/FightState.java @@ -0,0 +1,7 @@ +package de.steamwar.misslewars; + +public enum FightState { +WAITING, //waiting for at least 2Players +FIGHTING, //no one has Won +END // fight ended for some reason +} diff --git a/src/de/steamwar/misslewars/MWPlayer.java b/src/de/steamwar/misslewars/MWPlayer.java new file mode 100644 index 0000000..1a5abbd --- /dev/null +++ b/src/de/steamwar/misslewars/MWPlayer.java @@ -0,0 +1,24 @@ +package de.steamwar.misslewars; + +import org.bukkit.entity.Player; + +public class MWPlayer { + private Player p; + private int kills = 0; + + public int getKills() { + return kills; + } + + public void addKill() { + kills++; + } + + public MWPlayer (Player p) { + this.p = p; + } + + public Player getPlayer() { + return p; + } +} diff --git a/src/de/steamwar/misslewars/MWTeam.java b/src/de/steamwar/misslewars/MWTeam.java new file mode 100644 index 0000000..d2e16f6 --- /dev/null +++ b/src/de/steamwar/misslewars/MWTeam.java @@ -0,0 +1,89 @@ +package de.steamwar.misslewars; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.scoreboard.Team; +import org.bukkit.scoreboard.Team.Option; +import org.bukkit.scoreboard.Team.OptionStatus; + +public class MWTeam { + private ChatColor color; + private String teamName; + private String prefix; + private Team sbteam; //scoreboard-Team + private ArrayList spieler = new ArrayList(); + private Location spawn; + + public List getPlayers(){ + return spieler; + } + + public MWTeam(ChatColor color, String teamName, String prefix) { + this.teamName = teamName; + this.prefix = prefix; + this.color = color; + if(FightScoreboard.getScoreboard().getTeam(teamName) == null) + sbteam = FightScoreboard.getScoreboard().registerNewTeam(teamName); + else + sbteam = FightScoreboard.getScoreboard().getTeam(teamName); + assert sbteam != null; + sbteam.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.FOR_OWN_TEAM); + sbteam.setAllowFriendlyFire(false); + } + + public void tpToSpawn(Player p) { + p.teleport(spawn); + } + + public void join (Player p) { + spieler.add(new MWPlayer(p)); + p.setDisplayName(color + "[" + teamName + "]" + p.getName()); + if (MissleWars.getFightState() == FightState.WAITING) { + if (!enemy().getPlayers().isEmpty()) + MissleWars.startRound(); + } + } + + public void leave (Player p) { + for (MWPlayer pl : spieler) { + if (p == pl.getPlayer()) { + spieler.remove(pl); + break; + } + p.setDisplayName(p.getName()); + } + if (spieler.isEmpty()) + MissleWars.end(WinReasons.NOENEMY, enemy()); + } + + public MWTeam enemy() { + if (this == MissleWars.redTeam) return MissleWars.blueTeam; + return MissleWars.redTeam; + } + + public String getPrefix(){ + return prefix; + } + + public boolean hasPlayer (Player p) { + for (MWPlayer pl : spieler) + if (p == pl.getPlayer()) + return true; + return false; + } + + public MWPlayer getPlayer (Player p) { + for (MWPlayer pl : spieler) + if (p == pl.getPlayer()) + return pl; + return null; + } + + public String getColoredName() { + return color.toString() + teamName; + } +} diff --git a/src/de/steamwar/misslewars/MissleSpawnSystem.java b/src/de/steamwar/misslewars/MissleSpawnSystem.java new file mode 100644 index 0000000..bae3c31 --- /dev/null +++ b/src/de/steamwar/misslewars/MissleSpawnSystem.java @@ -0,0 +1,142 @@ +package de.steamwar.misslewars; + +import java.io.File; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Piston; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.block.data.type.Observer; + +public class MissleSpawnSystem { + + public static Missle[] missles; + + /** + * load Config, ect + */ + @SuppressWarnings("unchecked") + public static void load() { + FileConfiguration c = YamlConfiguration.loadConfiguration(new File(MissleWars.path + "/missles.yml")); + missles = ((List) c.get("missles")).toArray(new Missle[0]); + } + + public static void paste(String missle, boolean red, Location l) { + for (Missle m : missles) { + if (m.name == missle) + m.paste(l, red, red); + } + } + + /** + * Missle-Schematic + */ + @SuppressWarnings("unused") + private class Missle{ + public String name; + private byte height; + private byte depth; + private byte width; + private MissleBlockTypes[] blocks; + + /** + * + * @param l Location of the spawning player + * @param redTeam for Block-color blue / red + * @param north facing north or south? + */ + public void paste(Location l, boolean redTeam, boolean north) { + byte a = 1; + if (!north) a = -1; + for (int x=0; x < width; x++) { + for (int y=height; y > 0; y--) { + for (int z=0; z < width; z++) { + int i = x+y*width+z*height*width; + if (i > blocks.length || i < 0) continue; + setBlock(blocks[i], MissleWars.world.getBlockAt(l.getBlockX() + x, l.getBlockY() + y, l.getBlockZ() + z * a), north, redTeam); + } + } + } + } + + //bewusst mit blockupdate, damit observer, ect beim pasten triggern + private void setBlock(MissleBlockTypes t, Block b, boolean n, boolean red) { + if (t == MissleBlockTypes.GLASS) { + if (red) + b.setType(Material.RED_STAINED_GLASS); + else + b.setType(Material.BLUE_STAINED_GLASS); + }else if (t == MissleBlockTypes.BLOCK) { + if (red) + b.setType(Material.RED_CONCRETE); + else + b.setType(Material.BLUE_CONCRETE); + }else if (t == MissleBlockTypes.HONEY_BLOCK) { + b.setType(Material.HONEY_BLOCK); + }else if (t == MissleBlockTypes.PANE) { + if (red) + b.setType(Material.RED_STAINED_GLASS_PANE); + else + b.setType(Material.BLUE_STAINED_GLASS_PANE); + }else if (t == MissleBlockTypes.TNT) { + b.setType(Material.TNT); + }else if (t == MissleBlockTypes.SLIME_BLOCK) { + b.setType(Material.SLIME_BLOCK); + }else if (t.toString().contains("STICKY_PISTON")) { + b.setType(Material.STICKY_PISTON); + ((Piston) b).setFacing(getFacing(t, n)); + }else if (t.toString().contains("PISTON")) { + b.setType(Material.PISTON); + ((Piston) b).setFacing(getFacing(t, n)); + }else if (t.toString().contains("OBSERVER")) { + b.setType(Material.OBSERVER); + ((Observer) b).setFacing(getFacing(t, n)); + } + } + } + + public BlockFace getFacing(MissleBlockTypes t, boolean north) { + String s = t.toString(); + if (s.contains("UP")) return BlockFace.UP; + if (s.contains("DOWN")) return BlockFace.DOWN; + if ((s.contains("NORTH") && north) || (s.contains("SOUTH") && !north)) return BlockFace.NORTH; + if ((s.contains("NORTH") && !north) || (s.contains("SOUTH") && north)) return BlockFace.SOUTH; + if ((s.contains("WEST") && north) || (s.contains("EAST") && !north)) return BlockFace.WEST; + return BlockFace.EAST; + } + + /** + * For Config & lowRAM save of missles + */ + private enum MissleBlockTypes { + PISTON_UP, + PISTON_DOWN, + PISTON_NORTH, + PISTON_SOUTH, + PISTON_EAST, + PISTON_WEST, + STICKY_PISTON_UP, + STICKY_PISTON_DOWN, + STICKY_PISTON_NORTH, + STICKY_PISTON_SOUTH, + STICKY_PISTON_WEST, + STICKY_PISTON_EAST, + GLASS, //teamcolored + BLOCK, //normal block, teamcolored + PANE, //teamcolored (glass-pane) + REDSTONE_BLOCK, + OBSERVER_UP, + OBSERVER_DOWN, + OBSERVER_NORTH, + OBSERVER_SOUTH, + OBSERVER_EAST, + OBSERVER_WEST, + SLIME_BLOCK, + HONEY_BLOCK, + TNT + } +} diff --git a/src/de/steamwar/misslewars/MissleWars.java b/src/de/steamwar/misslewars/MissleWars.java new file mode 100644 index 0000000..42d9479 --- /dev/null +++ b/src/de/steamwar/misslewars/MissleWars.java @@ -0,0 +1,135 @@ +package de.steamwar.misslewars; + +import java.io.File; +import java.util.Timer; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitRunnable; + +public class MissleWars extends JavaPlugin { + public static World world; + private static MissleWars plugin; + public static MWTeam redTeam; //red has South side -> spawns missles towards north + public static MWTeam blueTeam; + public static int redPortalZ; + public static int bluePortalZ; + private static FightState fightstate; + private static long fightend; //timestamp when the fight ends + private static int rundenLaenge = 108000; //millis (108000 = 30mins) + private static int timeOut = 36000; //millis (36000 = 10min) + private static EndTimer timerClass; + private static int inspectionTime = 3600; //gameticks (3600 = 3min) + public static File path; + + /** + * create teams, ect + */ + public void onLoad() { + path = getDataFolder(); + plugin = this; + redTeam = new MWTeam(ChatColor.RED, "Rot", "Rot"); + redTeam = new MWTeam(ChatColor.BLUE, "Blau", "Blau"); + fightstate = FightState.WAITING; + fightend = System.currentTimeMillis() + timeOut; + MissleSpawnSystem.load(); + } + + /** + * start waiting for players timeout-timer + */ + public void onEnable() { + world = Bukkit.getServer().getWorlds().get(0); + timerClass = new EndTimer(true); + (new Timer()).schedule(timerClass, timeOut); + fightend = System.currentTimeMillis() + timeOut; + } + + /** + * call to change fightstate from WAITING to INGAME + */ + public static void startRound() { + if (fightstate != FightState.WAITING) // anti dual-call + return; + if (timerClass != null) timerClass.cancel(); + timerClass = new EndTimer(false); + (new Timer()).schedule(timerClass, rundenLaenge); + fightend = System.currentTimeMillis() + rundenLaenge; + } + + /** + * @return how long did this round last so far + */ + public static long getRoundLength() { + return rundenLaenge - (fightend - System.currentTimeMillis()); + //pflicht-ende-zeit - zeit bis zum pflicht-ende (pflicht-ende-timestamp - current-timestamp) + } + + public static MissleWars getPlugin() { + return plugin; + } + + public static FightState getFightState() { + return fightstate; + } + + /** + * @return seconds left + */ + public static int getFightTime() { + return Math.floorDiv((int) (fightend - System.currentTimeMillis()), 60); + } + + /** + * get the corresponding MWPlayer Object for a Player (if Player is ingame, otherwise returns null) + */ + public static MWPlayer getPlayer(Player p) { + MWPlayer pe = redTeam.getPlayer(p); + if (pe != null) return pe; + return blueTeam.getPlayer(p); + } + + /** + * checks if a Bukkit-Player Object is in a team + */ + public static boolean playerInGame(Player p) { + return redTeam.hasPlayer(p) || blueTeam.hasPlayer(p); + } + + /** + * Fight beenden + * @param reason Grund fürs ende + * @param winner Gewinner (oder null) + */ + public static void end(WinReasons reason, MWTeam winner) { + if (fightstate == FightState.END) //verhindern dass es mehrfach gecallt wird + return; + fightstate = FightState.END; + timerClass.cancel(); + String winnerName = "Null"; + if (winner == redTeam) winnerName = redTeam.getColoredName(); + if (winner == blueTeam) winnerName = blueTeam.getColoredName(); + switch (reason) { + case NOENEMY: + Bukkit.getServer().broadcastMessage("Ohne Gegner kein Kampf - Team " + winnerName + ChatColor.RESET + " hat gewonnen."); + break; + case PORTALDESTROYED: + Bukkit.getServer().broadcastMessage(winnerName + ChatColor.RESET + " hat das gegnerische Portal zerstört."); + break; + case TIMEOUT: + Bukkit.getServer().broadcastMessage("Kampf beendet: Unentschieden (Zeit abgelaufen)."); + break; + default: + Bukkit.getServer().broadcastMessage("Kampf beendet."); + break; + } + new BukkitRunnable() { + public void run() { + Bukkit.getServer().shutdown(); + } + }.runTaskLater(plugin, inspectionTime); + } +} diff --git a/src/de/steamwar/misslewars/WinReasons.java b/src/de/steamwar/misslewars/WinReasons.java new file mode 100644 index 0000000..3c10adf --- /dev/null +++ b/src/de/steamwar/misslewars/WinReasons.java @@ -0,0 +1,7 @@ +package de.steamwar.misslewars; + +public enum WinReasons { + NOENEMY, + PORTALDESTROYED, + TIMEOUT +} diff --git a/src/de/steamwar/misslewars/commands/JoinCommand.java b/src/de/steamwar/misslewars/commands/JoinCommand.java new file mode 100644 index 0000000..2c05ee8 --- /dev/null +++ b/src/de/steamwar/misslewars/commands/JoinCommand.java @@ -0,0 +1,5 @@ +package de.steamwar.misslewars.commands; + +public class JoinCommand { + +} diff --git a/src/de/steamwar/misslewars/listener/DeathListener.java b/src/de/steamwar/misslewars/listener/DeathListener.java new file mode 100644 index 0000000..50bb25c --- /dev/null +++ b/src/de/steamwar/misslewars/listener/DeathListener.java @@ -0,0 +1,25 @@ +package de.steamwar.misslewars.listener; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +import de.steamwar.misslewars.MWPlayer; +import de.steamwar.misslewars.MissleWars; + +import org.bukkit.event.entity.PlayerDeathEvent; + +public class DeathListener implements Listener { + @EventHandler + public void onDeath(PlayerDeathEvent e) { + Player p = e.getEntity(); + if (!MissleWars.playerInGame(p)) { + e.setDeathMessage(""); + return; + } + Player killer = p.getKiller(); + if (killer == null) return; + MWPlayer mwKiller = MissleWars.getPlayer(killer); + if (mwKiller != null) mwKiller.addKill(); + } +} diff --git a/src/de/steamwar/misslewars/listener/EggClickListener.java b/src/de/steamwar/misslewars/listener/EggClickListener.java new file mode 100644 index 0000000..f479d4f --- /dev/null +++ b/src/de/steamwar/misslewars/listener/EggClickListener.java @@ -0,0 +1,21 @@ +package de.steamwar.misslewars.listener; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerInteractEvent; + +import de.steamwar.misslewars.FightState; +import de.steamwar.misslewars.MissleSpawnSystem; +import de.steamwar.misslewars.MissleWars; + +public class EggClickListener implements Listener { + @EventHandler + public void onItemClick(PlayerInteractEvent e) { + if (MissleWars.getFightState() != FightState.FIGHTING) return; + if (!MissleWars.playerInGame(e.getPlayer())) return; + if (!e.getItem().getType().toString().contains("SPAWN_EGG")) return; + MissleSpawnSystem.paste(e.getItem().getItemMeta().getDisplayName() , MissleWars.redTeam.hasPlayer(e.getPlayer()), e.getPlayer().getLocation()); + e.getItem().setAmount(e.getItem().getAmount()-1); + e.setCancelled(true); + } +} diff --git a/src/de/steamwar/misslewars/listener/FallOutOfWorldListener.java b/src/de/steamwar/misslewars/listener/FallOutOfWorldListener.java new file mode 100644 index 0000000..10f2452 --- /dev/null +++ b/src/de/steamwar/misslewars/listener/FallOutOfWorldListener.java @@ -0,0 +1,15 @@ +package de.steamwar.misslewars.listener; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerMoveEvent; + +import de.steamwar.misslewars.MissleWars; + +public class FallOutOfWorldListener implements Listener { + @EventHandler + public void onMove(PlayerMoveEvent e) { + if (!MissleWars.playerInGame(e.getPlayer())) return; + if (e.getPlayer().getEyeHeight() < 0) e.getPlayer().damage(Double.MAX_VALUE); + } +} diff --git a/src/de/steamwar/misslewars/listener/JoinListener.java b/src/de/steamwar/misslewars/listener/JoinListener.java new file mode 100644 index 0000000..20095b4 --- /dev/null +++ b/src/de/steamwar/misslewars/listener/JoinListener.java @@ -0,0 +1,13 @@ +package de.steamwar.misslewars.listener; + +import org.bukkit.GameMode; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; + +public class JoinListener implements Listener{ + @EventHandler + public void onJoin(PlayerJoinEvent e) { + e.getPlayer().setGameMode(GameMode.SPECTATOR); + } +} diff --git a/src/de/steamwar/misslewars/listener/PortalDestructListener.java b/src/de/steamwar/misslewars/listener/PortalDestructListener.java new file mode 100644 index 0000000..19822c1 --- /dev/null +++ b/src/de/steamwar/misslewars/listener/PortalDestructListener.java @@ -0,0 +1,22 @@ +package de.steamwar.misslewars.listener; + +import org.bukkit.Material; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockPhysicsEvent; + +import de.steamwar.misslewars.MissleWars; +import de.steamwar.misslewars.WinReasons; + +public class PortalDestructListener implements Listener { + @EventHandler + public void onBlockupdate(BlockPhysicsEvent e) { + if (e.getBlock().getType() != Material.NETHER_PORTAL) + return; + int z = e.getBlock().getZ(); + if (z == MissleWars.redPortalZ) + MissleWars.end(WinReasons.PORTALDESTROYED, MissleWars.blueTeam); + if (z == MissleWars.bluePortalZ) + MissleWars.end(WinReasons.PORTALDESTROYED, MissleWars.blueTeam); + } +} diff --git a/src/plugin.yml b/src/plugin.yml new file mode 100644 index 0000000..5ce4837 --- /dev/null +++ b/src/plugin.yml @@ -0,0 +1,8 @@ +name: MissleWars +prefix: MW +main: de.steamwar.misslewars +authors: [Jan9103] +version: 1.0 +commands: + join: + leave: \ No newline at end of file