SteamWar/MissileWars
Archiviert
13
0

First fightable version

Dieser Commit ist enthalten in:
Lixfel 2020-06-24 18:24:00 +02:00
Ursprung 3e75eeacfb
Commit e99470fec5
17 geänderte Dateien mit 93 neuen und 54 gelöschten Zeilen

Datei anzeigen

@ -1,7 +1,7 @@
WaitingTime: 600 WaitingTime: 600
ItemTime: 300 ItemTime: 300
ShieldFlyTime: 100 ShieldFlyTime: 100
EndTime: 100 EndTime: 600
Arena: Arena:
MinX: 0 MinX: 0

Datei anzeigen

@ -51,11 +51,11 @@ public class Config {
ConfigurationSection red = config.getConfigurationSection("Red"); ConfigurationSection red = config.getConfigurationSection("Red");
assert red != null; assert red != null;
RedPortalZ = red.getInt("PortalZ"); RedPortalZ = red.getInt("PortalZ");
RedSpawn = new Location(Bukkit.getWorlds().get(0), red.getDouble("SpawnX"), red.getDouble("SpawnY"), red.getDouble("SpawnZ")); RedSpawn = new Location(Bukkit.getWorlds().get(0), red.getDouble("SpawnX"), red.getDouble("SpawnY"), red.getDouble("SpawnZ"), (float)red.getDouble("SpawnYaw"), (float)red.getDouble("SpawnPitch"));
ConfigurationSection blue = config.getConfigurationSection("Blue"); ConfigurationSection blue = config.getConfigurationSection("Blue");
assert blue != null; assert blue != null;
BluePortalZ = blue.getInt("PortalZ"); BluePortalZ = blue.getInt("PortalZ");
BlueSpawn = new Location(Bukkit.getWorlds().get(0), blue.getDouble("SpawnX"), blue.getDouble("SpawnY"), blue.getDouble("SpawnZ")); BlueSpawn = new Location(Bukkit.getWorlds().get(0), blue.getDouble("SpawnX"), blue.getDouble("SpawnY"), blue.getDouble("SpawnZ"), (float)blue.getDouble("SpawnYaw"), (float)blue.getDouble("SpawnPitch"));
} }
} }

Datei anzeigen

@ -32,16 +32,14 @@ public class FightScoreboard {
objective.setDisplaySlot(DisplaySlot.SIDEBAR); objective.setDisplaySlot(DisplaySlot.SIDEBAR);
MWTeam fightTeam = getIndexDisplay(); MWTeam fightTeam = getIndexDisplay();
if(fightTeam != null) teamScoreboard(fightTeam);
teamScoreboard(fightTeam);
else
generalScoreboard();
Bukkit.getOnlinePlayers().forEach(player -> player.setScoreboard(scoreboard)); Bukkit.getOnlinePlayers().forEach(player -> player.setScoreboard(scoreboard));
}, 0, 200); }, 0, 200);
} }
public static Scoreboard getScoreboard() { static Scoreboard getScoreboard() {
return scoreboard; return scoreboard;
} }
@ -52,23 +50,14 @@ public class FightScoreboard {
}); });
} }
private static void generalScoreboard(){
objective.setDisplayName("§6Kampf");
int fightTime = MissileWars.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() { private static MWTeam getIndexDisplay() {
index++; if(index == 0) {
if(index == 1) index = 1;
return MissileWars.getRedTeam(); return MissileWars.getRedTeam();
if(index == 2) }else{
index = 0;
return MissileWars.getBlueTeam(); return MissileWars.getBlueTeam();
index = 0; }
return null;
} }
} }

Datei anzeigen

@ -1,8 +1,6 @@
package de.steamwar.misslewars; package de.steamwar.misslewars;
import org.bukkit.ChatColor; import org.bukkit.*;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -60,9 +58,10 @@ public class MWTeam {
public void join (Player p) { public void join (Player p) {
players.add(p); players.add(p);
p.teleport(spawn); p.teleport(spawn);
Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), () -> p.setGameMode(GameMode.SURVIVAL), 1);
p.getInventory().setItem(0, bow); p.getInventory().setItem(0, bow);
sbteam.addPlayer(p); sbteam.addPlayer(p);
p.setDisplayName(color + teamName + " " + p.getName()); p.setDisplayName(color + " " + p.getName());
if (MissileWars.getFightState() == FightState.WAITING && !enemy().getPlayers().isEmpty()) if (MissileWars.getFightState() == FightState.WAITING && !enemy().getPlayers().isEmpty())
MissileWars.startRound(); MissileWars.startRound();
} }

Datei anzeigen

@ -10,6 +10,8 @@ import de.steamwar.misslewars.items.Snowball;
import de.steamwar.misslewars.listener.*; import de.steamwar.misslewars.listener.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -28,13 +30,12 @@ public class MissileWars extends JavaPlugin {
plugin = this; plugin = this;
fightState = FightState.WAITING; fightState = FightState.WAITING;
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
redTeam = new MWTeam(ChatColor.RED, Config.RedSpawn, "Rot", Config.RedPortalZ);
blueTeam = new MWTeam(ChatColor.BLUE, Config.BlueSpawn, "Blau", Config.BluePortalZ);
} }
@Override @Override
public void onEnable() { public void onEnable() {
redTeam = new MWTeam(ChatColor.RED, Config.RedSpawn, "Rot", Config.RedPortalZ);
blueTeam = new MWTeam(ChatColor.BLUE, Config.BlueSpawn, "Blau", Config.BluePortalZ);
new DeathListener(); new DeathListener();
new ItemListener(); new ItemListener();
new ArenaListener(); new ArenaListener();
@ -44,6 +45,7 @@ public class MissileWars extends JavaPlugin {
new PortalDestructListener(); new PortalDestructListener();
new WaitingListener(); new WaitingListener();
new FightListener(); new FightListener();
new ChatListener();
new WaitingCountdown(); new WaitingCountdown();
new ItemCountdown(); new ItemCountdown();
@ -82,13 +84,18 @@ public class MissileWars extends JavaPlugin {
fightState = FightState.END; fightState = FightState.END;
StateDependent.setupState(fightState); StateDependent.setupState(fightState);
for(Player player : Bukkit.getOnlinePlayers()){
player.playSound(player.getLocation(), Sound.ENTITY_ENDER_DRAGON_DEATH, 100f, 1f);
player.setGameMode(GameMode.SPECTATOR);
}
switch (reason) { switch (reason) {
case PORTAL_DESTROYED: case PORTAL_DESTROYED:
Bukkit.getServer().broadcastMessage(winner.getColoredName() + ChatColor.RESET + " hat das gegnerische Portal zerstört."); Bukkit.getServer().broadcastMessage(winner.getColoredName() + ChatColor.RESET + " §7hat das gegnerische Portal zerstört");
break; break;
case NO_ENEMY: case NO_ENEMY:
default: default:
Bukkit.getServer().broadcastMessage("Ohne Gegner kein Kampf - Team " + winner.getColoredName() + ChatColor.RESET + " hat gewonnen."); Bukkit.getServer().broadcastMessage("§7Team " + winner.getColoredName() + ChatColor.RESET + " §7hat aufgrund fehlenden Gegners gewonnen");
break; break;
} }
} }

Datei anzeigen

@ -21,10 +21,10 @@ public abstract class StateDependent {
static void setupState(FightState state){ static void setupState(FightState state){
for(StateDependent listener : listeners){ for(StateDependent listener : listeners){
if(listener.running && !listener.active.contains(state)){ if(listener.running && !listener.active.contains(state)){
listener.enable(); listener.disable();
listener.running = false; listener.running = false;
}else if(!listener.running && listener.active.contains(state)){ }else if(!listener.running && listener.active.contains(state)){
listener.disable(); listener.enable();
listener.running = true; listener.running = true;
} }
} }

Datei anzeigen

@ -29,7 +29,7 @@ public class EndCountdown extends StateDependent {
@Override @Override
public void disable() { public void disable() {
if(!task.isCancelled()) if(task != null && !task.isCancelled())
task.cancel(); task.cancel();
} }
} }

Datei anzeigen

@ -55,12 +55,12 @@ public class ItemCountdown extends StateDependent {
@Override @Override
public void enable() { public void enable() {
task = Bukkit.getScheduler().runTaskTimer(MissileWars.getPlugin(), this::run, Config.ItemTime, 0); task = Bukkit.getScheduler().runTaskTimer(MissileWars.getPlugin(), this::run, 0, Config.ItemTime);
} }
@Override @Override
public void disable() { public void disable() {
if(!task.isCancelled()) if(task != null && !task.isCancelled())
task.cancel(); task.cancel();
} }
} }

Datei anzeigen

@ -27,7 +27,7 @@ public class WaitingCountdown extends StateDependent {
@Override @Override
public void disable() { public void disable() {
if(!task.isCancelled()) if(task != null && !task.isCancelled())
task.cancel(); task.cancel();
} }
} }

Datei anzeigen

@ -1,6 +1,7 @@
package de.steamwar.misslewars.items; package de.steamwar.misslewars.items;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -16,6 +17,8 @@ public class Fireball extends SpecialItem {
@Override @Override
public boolean handleUse(Player p) { public boolean handleUse(Player p) {
org.bukkit.entity.Fireball fb = p.launchProjectile(org.bukkit.entity.Fireball.class); org.bukkit.entity.Fireball fb = p.launchProjectile(org.bukkit.entity.Fireball.class);
fb.setVelocity(fb.getVelocity().multiply(2));
p.playSound(p.getLocation(), Sound.ITEM_FIRECHARGE_USE, 100, 1);
fb.setIsIncendiary(true); fb.setIsIncendiary(true);
return true; return true;
} }

Datei anzeigen

@ -32,8 +32,8 @@ public class Missile extends SpecialItem {
private final ItemStack item; private final ItemStack item;
private Missile(File missileFile){ private Missile(File missileFile){
String name = missileFile.getName().split(".")[0]; String name = missileFile.getName().split("\\.")[0];
Material itemType = Material.valueOf(missileFile.getName().split(".")[1]); Material itemType = Material.valueOf(missileFile.getName().split("\\.")[1]);
ClipboardFormat format = ClipboardFormats.findByFile(missileFile); ClipboardFormat format = ClipboardFormats.findByFile(missileFile);
@ -60,24 +60,27 @@ public class Missile extends SpecialItem {
public boolean handleUse(Player p){ public boolean handleUse(Player p){
BlockVector3 dimensions = clipboard.getDimensions(); BlockVector3 dimensions = clipboard.getDimensions();
Location location = p.getLocation(); Location location = p.getLocation();
BlockVector3 v = BlockVector3.at(location.getBlockX(), location.getBlockY(), location.getBlockZ()); BlockVector3 v = BlockVector3.ZERO;
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()); BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
AffineTransform aT = new AffineTransform(); AffineTransform aT = new AffineTransform();
double yaw = p.getLocation().getYaw(); double yaw = (p.getLocation().getYaw() + 360f) % 360;
if(yaw > 45 && yaw <= 135) if(yaw > 45 && yaw <= 135) {
aT = aT.rotateY(90); aT = aT.rotateY(90);
else if(yaw > 135 && yaw <= 225) }else if(yaw > 135 && yaw <= 225) {
aT = aT.rotateY(180); aT = aT.rotateY(180);
else if(yaw > 225 && yaw <= 315) }else if(yaw > 225 && yaw <= 315) {
aT = aT.rotateY(270); aT = aT.rotateY(270);
}
v = v.subtract(dimensions.getX()/2, dimensions.getY(), dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset); v = v.subtract(dimensions.getX()/2, dimensions.getY() + 2, -2).subtract(offset);
v = aT.apply(v.toVector3()).toBlockPoint();
v = v.add(location.getBlockX(), location.getBlockY(), location.getBlockZ());
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1); EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1);
ClipboardHolder ch = new ClipboardHolder(clipboard); ClipboardHolder ch = new ClipboardHolder(clipboard);
ch.setTransform(aT); ch.setTransform(aT);
Operations.completeBlindly(ch.createPaste(e).to(v).build()); Operations.completeBlindly(ch.createPaste(e).to(v).ignoreAirBlocks(true).build());
e.flushSession(); e.flushSession();
return true; return true;
} }

Datei anzeigen

@ -6,7 +6,9 @@ import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerPickupArrowEvent;
import java.util.EnumSet; import java.util.EnumSet;
@ -26,7 +28,7 @@ public class ArenaListener extends BasicListener {
if(p.getGameMode() == GameMode.SPECTATOR) if(p.getGameMode() == GameMode.SPECTATOR)
p.teleport(e.getFrom()); p.teleport(e.getFrom());
else else
p.damage(Double.MAX_VALUE); p.damage(20.0f);
}else if( }else if(
location.getX() < Config.ArenaMinX || location.getX() < Config.ArenaMinX ||
location.getX() > Config.ArenaMaxX || location.getX() > Config.ArenaMaxX ||
@ -35,4 +37,14 @@ public class ArenaListener extends BasicListener {
p.teleport(e.getFrom()); p.teleport(e.getFrom());
} }
} }
@EventHandler
public void onArrowPickup(PlayerPickupArrowEvent e){
e.setCancelled(true);
}
@EventHandler
public void onItemDrop(PlayerDropItemEvent e){
e.setCancelled(true);
}
} }

Datei anzeigen

@ -0,0 +1,21 @@
package de.steamwar.misslewars.listener;
import de.steamwar.misslewars.FightState;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import java.util.EnumSet;
public class ChatListener extends BasicListener {
public ChatListener() {
super(EnumSet.allOf(FightState.class));
}
@EventHandler
public void onChat(AsyncPlayerChatEvent e){
Bukkit.broadcastMessage(e.getPlayer().getDisplayName() + "§8» §7" + e.getMessage());
e.setCancelled(true);
}
}

Datei anzeigen

@ -5,6 +5,7 @@ import de.steamwar.misslewars.MissileWars;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
@ -16,14 +17,13 @@ public class ConnectionListener extends BasicListener{
super(EnumSet.allOf(FightState.class)); super(EnumSet.allOf(FightState.class));
} }
@EventHandler @EventHandler(priority = EventPriority.HIGH)
public void onJoin(PlayerJoinEvent e) { public void onJoin(PlayerJoinEvent e) {
e.getPlayer().setGameMode(GameMode.SPECTATOR); e.getPlayer().setGameMode(GameMode.SPECTATOR);
} }
@EventHandler @EventHandler
public void onLeave(PlayerQuitEvent e) { public void onLeave(PlayerQuitEvent e) {
e.setQuitMessage(null);
Player p = e.getPlayer(); Player p = e.getPlayer();
MissileWars.getBlueTeam().leave(p); MissileWars.getBlueTeam().leave(p);

Datei anzeigen

@ -29,7 +29,7 @@ import java.util.Objects;
public class ItemListener extends BasicListener { public class ItemListener extends BasicListener {
private static final File shield = new File(de.steamwar.misslewars.MissileWars.getPlugin().getDataFolder(), "shield.schematic"); private static final File shield = new File(MissileWars.getPlugin().getDataFolder(), "shield.schematic");
private static final World world = new BukkitWorld(Bukkit.getWorlds().get(0)); private static final World world = new BukkitWorld(Bukkit.getWorlds().get(0));
private static final Clipboard clipboard; private static final Clipboard clipboard;
private static final BlockVector3 offset; private static final BlockVector3 offset;
@ -69,7 +69,7 @@ public class ItemListener extends BasicListener {
BlockVector3 paste = BlockVector3.at(l.getX(), l.getY(), l.getZ()).subtract(offset); BlockVector3 paste = BlockVector3.at(l.getX(), l.getY(), l.getZ()).subtract(offset);
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1); EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1);
Operations.completeBlindly(new ClipboardHolder(clipboard).createPaste(editSession).to(paste).build()); Operations.completeBlindly(new ClipboardHolder(clipboard).createPaste(editSession).ignoreAirBlocks(true).to(paste).build());
editSession.flushSession(); editSession.flushSession();
}, Config.ShieldFlyTime); }, Config.ShieldFlyTime);
} }

Datei anzeigen

@ -3,6 +3,7 @@ package de.steamwar.misslewars.listener;
import de.steamwar.misslewars.FightState; import de.steamwar.misslewars.FightState;
import de.steamwar.misslewars.MissileWars; import de.steamwar.misslewars.MissileWars;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import java.util.EnumSet; import java.util.EnumSet;
@ -13,11 +14,12 @@ public class JoinListener extends BasicListener {
super(EnumSet.of(FightState.WAITING, FightState.FIGHTING)); super(EnumSet.of(FightState.WAITING, FightState.FIGHTING));
} }
@EventHandler @EventHandler(priority = EventPriority.HIGHEST)
public void onJoin(PlayerJoinEvent e){ public void onJoin(PlayerJoinEvent e){
if(MissileWars.getRedTeam().getPlayers().size() < MissileWars.getBlueTeam().getPlayers().size()) if(MissileWars.getRedTeam().getPlayers().size() < MissileWars.getBlueTeam().getPlayers().size())
MissileWars.getRedTeam().join(e.getPlayer()); MissileWars.getRedTeam().join(e.getPlayer());
else else
MissileWars.getBlueTeam().join(e.getPlayer()); MissileWars.getBlueTeam().join(e.getPlayer());
e.setJoinMessage("§a» " + e.getPlayer().getDisplayName());
} }
} }

Datei anzeigen

@ -1,8 +1,11 @@
name: MissleWars name: MissileWars
prefix: MW prefix: MW
main: de.steamwar.misslewars.MissileWars main: de.steamwar.misslewars.MissileWars
authors: authors:
- Jan9103 - Jan9103
- Lixfel - Lixfel
version: "1.0" version: "1.0"
api-version: "1.13" api-version: "1.13"
depend:
- WorldEdit
- SpigotCore