Adding piston movement listener
Dieser Commit ist enthalten in:
Ursprung
c2da2498f7
Commit
9377db47e5
10
pom.xml
10
pom.xml
@ -19,10 +19,6 @@
|
|||||||
<id>maven</id>
|
<id>maven</id>
|
||||||
<url>https://steamwar.de:81/maven/</url>
|
<url>https://steamwar.de:81/maven/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
|
||||||
<id>spigotmc-repo</id>
|
|
||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -51,9 +47,9 @@
|
|||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>Spigot</artifactId>
|
||||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
<version>1.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -57,6 +57,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
|
|
||||||
scoreboard = new Scoreboard();
|
scoreboard = new Scoreboard();
|
||||||
waterRemover = new WaterRemover();
|
waterRemover = new WaterRemover();
|
||||||
|
entern = false;
|
||||||
|
|
||||||
loadConfig();
|
loadConfig();
|
||||||
|
|
||||||
@ -78,6 +79,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
pm.registerEvents(new EntityExplodeListener(), plugin);
|
pm.registerEvents(new EntityExplodeListener(), plugin);
|
||||||
pm.registerEvents(new PlayerTeleportListener(), plugin);
|
pm.registerEvents(new PlayerTeleportListener(), plugin);
|
||||||
pm.registerEvents(new ProjectileLaunchListener(), plugin);
|
pm.registerEvents(new ProjectileLaunchListener(), plugin);
|
||||||
|
pm.registerEvents(new PistonListener(), plugin);
|
||||||
|
|
||||||
//WinConditions
|
//WinConditions
|
||||||
if(Config.AllDead) pm.registerEvents(new WinconditionAllDead(), plugin);
|
if(Config.AllDead) pm.registerEvents(new WinconditionAllDead(), plugin);
|
||||||
@ -227,7 +229,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
return fightTime;
|
return fightTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEntern() {
|
public static boolean isEntern() {
|
||||||
return entern;
|
return entern;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,17 +10,15 @@ import org.bukkit.event.block.BlockBreakEvent;
|
|||||||
|
|
||||||
public class BlockBreakListener implements Listener {
|
public class BlockBreakListener implements Listener {
|
||||||
|
|
||||||
private final FightSystem instance = FightSystem.getPlugin();
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handleBlockBreak(BlockBreakEvent event) {
|
public void handleBlockBreak(BlockBreakEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if(Fight.getPlayerTeam(player) == null)
|
if(Fight.getPlayerTeam(player) == null)
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
else if(FightSystem.getPlugin().getFightState() != FightState.RUNNING) {
|
else if(FightSystem.getFightState() != FightState.RUNNING) {
|
||||||
event.setCancelled(true);
|
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!");
|
player.sendMessage(FightSystem.PREFIX + "§cDu darfst erst nach Fightbeginn Blöcke abbauen!");
|
||||||
} else
|
} else
|
||||||
player.sendMessage(FightSystem.PREFIX + "§cDu darfst keine Blöcke mehr abbauen!");
|
player.sendMessage(FightSystem.PREFIX + "§cDu darfst keine Blöcke mehr abbauen!");
|
||||||
|
49
src/me/yaruma/fightsystem/listener/PistonListener.java
Normale Datei
49
src/me/yaruma/fightsystem/listener/PistonListener.java
Normale Datei
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -27,6 +27,9 @@ public class PlayerInteractListener implements Listener {
|
|||||||
String displayName = itemMeta.getDisplayName();
|
String displayName = itemMeta.getDisplayName();
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
if(displayName == null)
|
||||||
|
return;
|
||||||
|
|
||||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||||
if(displayName.equals("§e" + Config.GameName + " wählen")){
|
if(displayName.equals("§e" + Config.GameName + " wählen")){
|
||||||
GUI.preSchemDialog(player);
|
GUI.preSchemDialog(player);
|
||||||
|
@ -4,6 +4,8 @@ import org.bukkit.Location;
|
|||||||
|
|
||||||
public class Region {
|
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) {
|
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);
|
return isInRegion(location, minX, minY, minZ, minX + xRange, minY + yRange, minZ + zRange, margin);
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ public class FinishNoneEntern implements CountdownCallback {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void countdownFinished() {
|
public void countdownFinished() {
|
||||||
FightSystem.getPlugin().setEntern(true);
|
FightSystem.setEntern(true);
|
||||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aEntern ist nun erlaubt!");
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aEntern ist nun erlaubt!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren