Update CodeStyle
Dieser Commit ist enthalten in:
Ursprung
7e0be0a412
Commit
8b2c67d8f3
@ -29,7 +29,10 @@ import java.io.File;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
private Config(){}
|
|
||||||
|
private Config() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static final int ArenaMinX;
|
public static final int ArenaMinX;
|
||||||
public static final int ArenaMaxX;
|
public static final int ArenaMaxX;
|
||||||
|
@ -32,7 +32,9 @@ import java.util.Objects;
|
|||||||
*/
|
*/
|
||||||
class FightScoreboard {
|
class FightScoreboard {
|
||||||
|
|
||||||
private FightScoreboard(){}
|
private FightScoreboard() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private static final Scoreboard scoreboard = Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard();
|
private static final Scoreboard scoreboard = Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard();
|
||||||
private static final Objective objective;
|
private static final Objective objective;
|
||||||
|
@ -61,7 +61,6 @@ public class MissileWars extends JavaPlugin {
|
|||||||
new WaitingListener();
|
new WaitingListener();
|
||||||
new FightListener();
|
new FightListener();
|
||||||
new ChatListener();
|
new ChatListener();
|
||||||
new GamemodeListener();
|
|
||||||
getCommand("spectate").setExecutor(new CommandSpectate());
|
getCommand("spectate").setExecutor(new CommandSpectate());
|
||||||
|
|
||||||
new WaitingCountdown();
|
new WaitingCountdown();
|
||||||
|
@ -52,7 +52,6 @@ public class EndCountdown extends StateDependent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disable() {
|
public void disable() {
|
||||||
if(task != null && !task.isCancelled())
|
if (task != null && !task.isCancelled()) task.cancel();
|
||||||
task.cancel();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ public class ItemCountdown extends StateDependent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disable() {
|
public void disable() {
|
||||||
if(task != null && !task.isCancelled())
|
if (task != null && !task.isCancelled()) task.cancel();
|
||||||
task.cancel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,4 +36,5 @@ public class Arrows extends SpecialItem {
|
|||||||
public boolean handleUse(Player p) {
|
public boolean handleUse(Player p) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -44,4 +44,5 @@ public class Fireball extends SpecialItem {
|
|||||||
fb.setYield(3f);
|
fb.setYield(3f);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -76,4 +76,5 @@ public class LandingPad extends SpecialItem {
|
|||||||
editSession.flushSession();
|
editSession.flushSession();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,4 +36,5 @@ public class Mine extends SpecialItem {
|
|||||||
public boolean handleUse(Player p) {
|
public boolean handleUse(Player p) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -92,24 +92,24 @@ public class Missile extends SpecialItem {
|
|||||||
private void lore(List<String> lore, String[] args, int index, String tag) {
|
private void lore(List<String> lore, String[] args, int index, String tag) {
|
||||||
if (args.length > index) {
|
if (args.length > index) {
|
||||||
try {
|
try {
|
||||||
lore.add(graph(Integer.parseInt(args[index]), GRAPH_SIZE) + tag);
|
lore.add(graph(Integer.parseInt(args[index])) + tag);
|
||||||
return;
|
return;
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
// Ignored
|
// Ignored
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lore.add(graph(0, GRAPH_SIZE) + tag);
|
lore.add(graph(0) + tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String graph(int index, int size) {
|
private String graph(int index) {
|
||||||
if (index > size) index = size;
|
if (index > Missile.GRAPH_SIZE) index = Missile.GRAPH_SIZE;
|
||||||
StringBuilder st = new StringBuilder();
|
StringBuilder st = new StringBuilder();
|
||||||
st.append("§8[§e");
|
st.append("§8[§e");
|
||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
st.append(repeat(index));
|
st.append(repeat(index));
|
||||||
}
|
}
|
||||||
st.append("§7");
|
st.append("§7");
|
||||||
st.append(repeat(size - index));
|
st.append(repeat(Missile.GRAPH_SIZE - index));
|
||||||
st.append("§8]");
|
st.append("§8]");
|
||||||
return st.toString();
|
return st.toString();
|
||||||
}
|
}
|
||||||
|
@ -36,4 +36,5 @@ public class Shield extends SpecialItem {
|
|||||||
public boolean handleUse(Player p) {
|
public boolean handleUse(Player p) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -55,11 +55,7 @@ public class ArenaListener extends BasicListener {
|
|||||||
p.teleport(Objects.requireNonNull(MissileWars.getTeam(p)).getSpawn());
|
p.teleport(Objects.requireNonNull(MissileWars.getTeam(p)).getSpawn());
|
||||||
else
|
else
|
||||||
p.damage(20.0f);
|
p.damage(20.0f);
|
||||||
}else if(
|
} else if (location.getX() < Config.ArenaMinX || location.getX() > Config.ArenaMaxX || location.getZ() < Config.ArenaMinZ || location.getZ() > Config.ArenaMaxZ) {
|
||||||
location.getX() < Config.ArenaMinX ||
|
|
||||||
location.getX() > Config.ArenaMaxX ||
|
|
||||||
location.getZ() < Config.ArenaMinZ ||
|
|
||||||
location.getZ() > Config.ArenaMaxZ){
|
|
||||||
p.teleport(e.getFrom());
|
p.teleport(e.getFrom());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,9 +77,8 @@ public class ArenaListener extends BasicListener {
|
|||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onInventoryOpen(InventoryOpenEvent event) {
|
public void onInventoryOpen(InventoryOpenEvent event) {
|
||||||
if(event.getView().getType() != InventoryType.PLAYER &&
|
if(event.getView().getType() != InventoryType.PLAYER && event.getView().getType() != InventoryType.CRAFTING && event.getView().getType() != InventoryType.CREATIVE) {
|
||||||
event.getView().getType() != InventoryType.CRAFTING &&
|
|
||||||
event.getView().getType() != InventoryType.CREATIVE)
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -44,4 +44,5 @@ public abstract class BasicListener extends StateDependent implements Listener {
|
|||||||
public void disable() {
|
public void disable() {
|
||||||
HandlerList.unregisterAll(this);
|
HandlerList.unregisterAll(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,4 +37,5 @@ public class ChatListener extends BasicListener {
|
|||||||
Bukkit.broadcastMessage(e.getPlayer().getDisplayName() + "§8» §7" + e.getMessage());
|
Bukkit.broadcastMessage(e.getPlayer().getDisplayName() + "§8» §7" + e.getMessage());
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -48,10 +48,10 @@ public class DeathListener extends BasicListener {
|
|||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
p.setFireTicks(0);
|
p.setFireTicks(0);
|
||||||
MWTeam team = MissileWars.getTeam(p);
|
MWTeam team = MissileWars.getTeam(p);
|
||||||
if(team == null)
|
if(team == null) return;
|
||||||
return;
|
|
||||||
|
|
||||||
e.setRespawnLocation(team.getSpawn());
|
e.setRespawnLocation(team.getSpawn());
|
||||||
new SpawnPlatformCreator(p);
|
new SpawnPlatformCreator(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,4 +37,5 @@ public class EndListener extends BasicListener {
|
|||||||
e.setJoinMessage(null);
|
e.setJoinMessage(null);
|
||||||
e.getPlayer().setGameMode(GameMode.SPECTATOR);
|
e.getPlayer().setGameMode(GameMode.SPECTATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -35,13 +35,12 @@ public class FightListener extends BasicListener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDamage(EntityDamageByEntityEvent e) {
|
public void onDamage(EntityDamageByEntityEvent e) {
|
||||||
if(!(e.getDamager() instanceof Player && e.getEntity() instanceof Player))
|
if (!(e.getDamager() instanceof Player && e.getEntity() instanceof Player)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
Player damager = (Player)e.getDamager();
|
Player damager = (Player)e.getDamager();
|
||||||
Player reciever = (Player)e.getEntity();
|
Player reciever = (Player)e.getEntity();
|
||||||
|
|
||||||
if(MissileWars.getTeam(damager) == MissileWars.getTeam(reciever))
|
if (MissileWars.getTeam(damager) == MissileWars.getTeam(reciever)) e.setCancelled(true);
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -84,11 +84,8 @@ public class ItemListener extends BasicListener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onItemClick(PlayerInteractEvent e) {
|
public void onItemClick(PlayerInteractEvent e) {
|
||||||
ItemStack item = e.getItem();
|
ItemStack item = e.getItem();
|
||||||
if (item == null)
|
if (item == null) return;
|
||||||
return;
|
if (e.getAction() != Action.RIGHT_CLICK_BLOCK && e.getAction() != Action.RIGHT_CLICK_AIR) return;
|
||||||
|
|
||||||
if(e.getAction() != Action.RIGHT_CLICK_BLOCK && e.getAction() != Action.RIGHT_CLICK_AIR)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (SpecialItem.handleUse(item, e.getPlayer())) {
|
if (SpecialItem.handleUse(item, e.getPlayer())) {
|
||||||
item.setAmount(item.getAmount()-1);
|
item.setAmount(item.getAmount()-1);
|
||||||
|
@ -39,8 +39,8 @@ public class PortalDestructListener extends BasicListener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockupdate(BlockPhysicsEvent e) {
|
public void onBlockupdate(BlockPhysicsEvent e) {
|
||||||
if (e.getBlock().getType() != Material.NETHER_PORTAL)
|
if (e.getBlock().getType() != Material.NETHER_PORTAL) return;
|
||||||
return;
|
|
||||||
int z = e.getBlock().getZ();
|
int z = e.getBlock().getZ();
|
||||||
if (z == MissileWars.getRedTeam().getPortalZ())
|
if (z == MissileWars.getRedTeam().getPortalZ())
|
||||||
MissileWars.end(WinReasons.PORTAL_DESTROYED, MissileWars.getBlueTeam());
|
MissileWars.end(WinReasons.PORTAL_DESTROYED, MissileWars.getBlueTeam());
|
||||||
@ -50,13 +50,12 @@ public class PortalDestructListener extends BasicListener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onExplosion(EntityExplodeEvent e) {
|
public void onExplosion(EntityExplodeEvent e) {
|
||||||
if(e.getEntityType() != EntityType.FIREBALL)
|
if(e.getEntityType() != EntityType.FIREBALL) return;
|
||||||
return;
|
|
||||||
|
|
||||||
double z = e.getLocation().getZ();
|
double z = e.getLocation().getZ();
|
||||||
double distRed = Math.abs(Config.RedPortalZ + 0.5 - z);
|
double distRed = Math.abs(Config.RedPortalZ + 0.5 - z);
|
||||||
double distBlue = Math.abs(Config.BluePortalZ + 0.5 - z);
|
double distBlue = Math.abs(Config.BluePortalZ + 0.5 - z);
|
||||||
if(distRed < 2 || distBlue < 2)
|
if(distRed < 2 || distBlue < 2) e.setCancelled(true);
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,19 +28,18 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
|
||||||
public class WaitingListener extends BasicListener {
|
public class WaitingListener extends BasicListener {
|
||||||
|
|
||||||
public WaitingListener() {
|
public WaitingListener() {
|
||||||
super(EnumSet.of(FightState.WAITING));
|
super(EnumSet.of(FightState.WAITING));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDisconnect(PlayerQuitEvent e) {
|
public void onDisconnect(PlayerQuitEvent e) {
|
||||||
if(Bukkit.getOnlinePlayers().isEmpty())
|
if(Bukkit.getOnlinePlayers().isEmpty()) Bukkit.shutdown();
|
||||||
Bukkit.shutdown();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDamage(EntityDamageEvent e) {
|
public void onDamage(EntityDamageEvent e) {
|
||||||
if(e.getCause() != EntityDamageEvent.DamageCause.VOID)
|
if(e.getCause() != EntityDamageEvent.DamageCause.VOID) e.setCancelled(true);
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren