SteamWar/FightSystem
Archiviert
13
1

Adding piston movement listener

Dieser Commit ist enthalten in:
Lixfel 2019-06-08 12:57:08 +02:00
Ursprung c2da2498f7
Commit 9377db47e5
7 geänderte Dateien mit 63 neuen und 13 gelöschten Zeilen

10
pom.xml
Datei anzeigen

@ -19,10 +19,6 @@
<id>maven</id>
<url>https://steamwar.de:81/maven/</url>
</repository>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<build>
@ -51,9 +47,9 @@
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>

Datei anzeigen

@ -57,6 +57,7 @@ public class FightSystem extends JavaPlugin {
scoreboard = new Scoreboard();
waterRemover = new WaterRemover();
entern = false;
loadConfig();
@ -78,6 +79,7 @@ public class FightSystem extends JavaPlugin {
pm.registerEvents(new EntityExplodeListener(), plugin);
pm.registerEvents(new PlayerTeleportListener(), plugin);
pm.registerEvents(new ProjectileLaunchListener(), plugin);
pm.registerEvents(new PistonListener(), plugin);
//WinConditions
if(Config.AllDead) pm.registerEvents(new WinconditionAllDead(), plugin);
@ -227,7 +229,7 @@ public class FightSystem extends JavaPlugin {
return fightTime;
}
public boolean isEntern() {
public static boolean isEntern() {
return entern;
}

Datei anzeigen

@ -10,17 +10,15 @@ import org.bukkit.event.block.BlockBreakEvent;
public class BlockBreakListener implements Listener {
private final FightSystem instance = FightSystem.getPlugin();
@EventHandler
public void handleBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
if(Fight.getPlayerTeam(player) == null)
event.setCancelled(true);
else if(FightSystem.getPlugin().getFightState() != FightState.RUNNING) {
else if(FightSystem.getFightState() != FightState.RUNNING) {
event.setCancelled(true);
if(instance.getFightState() == FightState.SETUP || instance.getFightState() == FightState.PRE_RUNNING) {
if(FightSystem.getFightState() == FightState.SETUP || FightSystem.getFightState() == FightState.PRE_RUNNING) {
player.sendMessage(FightSystem.PREFIX + "§cDu darfst erst nach Fightbeginn Blöcke abbauen!");
} else
player.sendMessage(FightSystem.PREFIX + "§cDu darfst keine Blöcke mehr abbauen!");

Datei anzeigen

@ -0,0 +1,49 @@
package me.yaruma.fightsystem.listener;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.FightState;
import me.yaruma.fightsystem.utils.Config;
import me.yaruma.fightsystem.utils.Region;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;
public class PistonListener implements Listener {
@EventHandler
public void handlePistonExtend(BlockPistonExtendEvent e){
if(Config.Entern && FightSystem.getFightState() != FightState.SETUP)
return;
BlockFace b = e.getDirection();
for(Block block : e.getBlocks()){
if(
!Region.isIn2DRange(block.getLocation(), Config.TeamBlueCornerX + b.getModX(), Config.TeamBlueCornerZ + b.getModZ(), Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic) &&
!Region.isIn2DRange(block.getLocation(), Config.TeamRedCornerX + b.getModX(), Config.TeamRedCornerZ + b.getModZ(), Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic)
){
e.setCancelled(true);
return;
}
}
}
@EventHandler
public void handlePistonRetract(BlockPistonRetractEvent e){
if(Config.Entern && FightSystem.getFightState() != FightState.SETUP)
return;
BlockFace b = e.getDirection();
for(Block block : e.getBlocks()){
if(
!Region.isIn2DRange(block.getLocation(), Config.TeamBlueCornerX + b.getModX(), Config.TeamBlueCornerZ + b.getModZ(), Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic) &&
!Region.isIn2DRange(block.getLocation(), Config.TeamRedCornerX + b.getModX(), Config.TeamRedCornerZ + b.getModZ(), Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic)
){
e.setCancelled(true);
return;
}
}
}
}

Datei anzeigen

@ -27,6 +27,9 @@ public class PlayerInteractListener implements Listener {
String displayName = itemMeta.getDisplayName();
event.setCancelled(true);
if(displayName == null)
return;
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(displayName.equals("§e" + Config.GameName + " wählen")){
GUI.preSchemDialog(player);

Datei anzeigen

@ -4,6 +4,8 @@ import org.bukkit.Location;
public class Region {
private Region(){}
public static boolean isInRange(Location location, int minX, int minY, int minZ, int xRange, int yRange, int zRange, int margin) {
return isInRegion(location, minX, minY, minZ, minX + xRange, minY + yRange, minZ + zRange, margin);
}

Datei anzeigen

@ -12,7 +12,7 @@ public class FinishNoneEntern implements CountdownCallback {
@Override
public void countdownFinished() {
FightSystem.getPlugin().setEntern(true);
FightSystem.setEntern(true);
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aEntern ist nun erlaubt!");
}