Merge remote-tracking branch 'origin/master'
Dieser Commit ist enthalten in:
Commit
a31b69d838
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
||||||
|
|
||||||
|
public class DenyWorldInteraction_10 implements Listener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onSwapItems(PlayerSwapHandItemsEvent event) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
@ -19,12 +19,10 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
import java.util.function.ObjIntConsumer;
|
import java.util.function.ObjIntConsumer;
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
public class Region {
|
public class Region {
|
||||||
|
|
||||||
@ -41,7 +39,6 @@ public class Region {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Region(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ) {
|
public Region(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ) {
|
||||||
Bukkit.getLogger().log(Level.INFO, minX + " " + minY + " " + minZ + " " + sizeX + " " + sizeY + " " + sizeZ);
|
|
||||||
this.minX = minX;
|
this.minX = minX;
|
||||||
this.minY = minY;
|
this.minY = minY;
|
||||||
this.minZ = minZ;
|
this.minZ = minZ;
|
||||||
|
@ -30,5 +30,6 @@ public enum Winconditions {
|
|||||||
POINTS,
|
POINTS,
|
||||||
TIME_TECH_KO,
|
TIME_TECH_KO,
|
||||||
WATER_TECH_KO,
|
WATER_TECH_KO,
|
||||||
PUMPKIN_TECH_KO
|
PUMPKIN_TECH_KO,
|
||||||
|
HELLS_BELLS
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import de.steamwar.core.CommandRemover;
|
|||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.fightsystem.commands.*;
|
import de.steamwar.fightsystem.commands.*;
|
||||||
import de.steamwar.fightsystem.countdown.*;
|
import de.steamwar.fightsystem.countdown.*;
|
||||||
|
import de.steamwar.fightsystem.event.HellsBells;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.fight.FightWorld;
|
import de.steamwar.fightsystem.fight.FightWorld;
|
||||||
@ -106,6 +107,9 @@ public class FightSystem extends JavaPlugin {
|
|||||||
new RankedPlayerLeftWincondition();
|
new RankedPlayerLeftWincondition();
|
||||||
new WinconditionPercentTimeout();
|
new WinconditionPercentTimeout();
|
||||||
|
|
||||||
|
//noinspection InstantiationOfUtilityClass
|
||||||
|
new HellsBells();
|
||||||
|
|
||||||
new NoPlayersOnlineCountdown();
|
new NoPlayersOnlineCountdown();
|
||||||
new PreSchemCountdown();
|
new PreSchemCountdown();
|
||||||
new PostSchemCountdown();
|
new PostSchemCountdown();
|
||||||
|
265
FightSystem_Main/src/de/steamwar/fightsystem/event/HellsBells.java
Normale Datei
265
FightSystem_Main/src/de/steamwar/fightsystem/event/HellsBells.java
Normale Datei
@ -0,0 +1,265 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.fightsystem.event;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import de.steamwar.fightsystem.countdown.Countdown;
|
||||||
|
import de.steamwar.fightsystem.countdown.SWSound;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
|
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
|
||||||
|
public class HellsBells {
|
||||||
|
|
||||||
|
public static final Random random = new Random();
|
||||||
|
|
||||||
|
private final World world = Bukkit.getWorlds().get(0);
|
||||||
|
private final int xLength = Config.RedPasteRegion.getMaxX() - Config.RedPasteRegion.getMinX();
|
||||||
|
private final int zLength = Config.RedPasteRegion.getMaxZ() - Config.RedPasteRegion.getMinZ();
|
||||||
|
private State current = State.PRE;
|
||||||
|
private int currentDrops = 0;
|
||||||
|
private HellsBellsCountdown currentCountdown;
|
||||||
|
private BukkitTask currentDropping;
|
||||||
|
private final List<String> startMessages = Arrays.asList("§c!!Achtung!! Bomber im Anflug, noch ca. eine Minute bis zur Ankunft.",
|
||||||
|
"§cBomber im Anflug, ca. eine Minute bis zur Ankunft.",
|
||||||
|
"§cBomber auf dem Radar gesichtet, geschätzte Ankunftszeit: eine Minute.",
|
||||||
|
"§cUnbekanntes Flugobjekt gesichtet, trifft in ca. einer Minute ein.",
|
||||||
|
"§cFlugobjekt gesichtet. Ankunft in ca. einer Minute.",
|
||||||
|
"§cBomber erschienen, Ankunft ca. eine Minute.");
|
||||||
|
private final List<String> stateSwapMessages = Arrays.asList("§aDie Bomben fallen nun schneller.",
|
||||||
|
"§aMehr Bomber im Anflug.",
|
||||||
|
"§aZusätzliche Bomber gesichtet.",
|
||||||
|
"§aDas Bombardement scheint sich zu erhöhen.");
|
||||||
|
|
||||||
|
public void startCountdown() {
|
||||||
|
if (current == State.PRE) {
|
||||||
|
Bukkit.broadcastMessage(FightSystem.PREFIX + (startMessages.get(random.nextInt(startMessages.size()))));
|
||||||
|
current = current.getNext();
|
||||||
|
} else if (current != State.LAST && currentDrops >= current.SWITCH_AFTER) {
|
||||||
|
Bukkit.broadcastMessage(FightSystem.PREFIX + (stateSwapMessages.get(random.nextInt(stateSwapMessages.size()))));
|
||||||
|
currentDrops = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentDrops++;
|
||||||
|
currentCountdown = new HellsBellsCountdown(current.MIN_TIME + random.nextInt(current.MAX_TIME - current.MIN_TIME));
|
||||||
|
currentCountdown.enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drop() {
|
||||||
|
Direction direction = Direction.getRandom();
|
||||||
|
|
||||||
|
AtomicInteger length = new AtomicInteger(10 + random.nextInt(direction.getLength(zLength, xLength) - 10));
|
||||||
|
int width = 5 + random.nextInt(5);
|
||||||
|
int xOffset = getWidthStart(direction.getLength(xLength, zLength), direction.getLength(length.get(), width));
|
||||||
|
int zOffset = getLengthStart(direction.getLength(zLength, xLength), direction.getLength(width, length.get()));
|
||||||
|
int yOffset = getHeightStart();
|
||||||
|
|
||||||
|
Point redStart;
|
||||||
|
Point blueStart;
|
||||||
|
|
||||||
|
if (direction.isNorthOrWest()) {
|
||||||
|
redStart = new Point(Config.RedPasteRegion.getMaxX() - xOffset, Config.RedExtendRegion.getMaxY() + yOffset, Config.RedPasteRegion.getMaxZ() - zOffset);
|
||||||
|
blueStart = new Point(Config.BluePasteRegion.getMinX() + xOffset, Config.BlueExtendRegion.getMaxY() + yOffset, Config.BluePasteRegion.getMinZ() + zOffset);
|
||||||
|
} else {
|
||||||
|
redStart = new Point(Config.RedPasteRegion.getMinX() + xOffset, Config.RedExtendRegion.getMaxY() + yOffset, Config.RedPasteRegion.getMinZ() + zOffset);
|
||||||
|
blueStart = new Point(Config.BluePasteRegion.getMaxX() - xOffset, Config.BlueExtendRegion.getMaxY() + yOffset, Config.BluePasteRegion.getMaxZ() - zOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
currentDropping = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), () -> {
|
||||||
|
for (int w = 0; w < width; w++) {
|
||||||
|
if (direction.isNorthOrWest()) {
|
||||||
|
world.spawnEntity(redStart.addAndToLocation(world, -1 * (direction.dx * length.get() + w * direction.other().dx), 0, -1 * (direction.dz * length.get() + w * direction.other().dz)), EntityType.PRIMED_TNT);
|
||||||
|
|
||||||
|
world.spawnEntity(blueStart.addAndToLocation(world, direction.dx * length.get() + w * direction.other().dx, 0, direction.dz * length.get() + w * direction.other().dz), EntityType.PRIMED_TNT);
|
||||||
|
} else {
|
||||||
|
world.spawnEntity(redStart.addAndToLocation(world, direction.dx * length.get() + w * direction.other().dx, 0, direction.dz * length.get() + w * direction.other().dz), EntityType.PRIMED_TNT);
|
||||||
|
|
||||||
|
world.spawnEntity(blueStart.addAndToLocation(world, -1 * (direction.dx * length.get() + w * direction.other().dx), 0, -1 * (direction.dz * length.get() + w * direction.other().dz)), EntityType.PRIMED_TNT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (length.addAndGet(-2) <= 0) {
|
||||||
|
currentDropping.cancel();
|
||||||
|
}
|
||||||
|
}, 0L, 4L);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getLengthStart(int regionSize, int length) {
|
||||||
|
return random.nextInt(regionSize - length);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getWidthStart(int regionSize, int length) {
|
||||||
|
return random.nextInt(regionSize - length);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getHeightStart() {
|
||||||
|
return 5 + random.nextInt(15);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HellsBells() {
|
||||||
|
new StateDependent(Winconditions.HELLS_BELLS, FightState.Running) {
|
||||||
|
@Override
|
||||||
|
public void enable() {
|
||||||
|
startCountdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
|
currentCountdown.disable();
|
||||||
|
}
|
||||||
|
}.register();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class HellsBellsCountdown extends Countdown {
|
||||||
|
|
||||||
|
public HellsBellsCountdown(int time) {
|
||||||
|
super(time, SWSound.BLOCK_NOTE_BASS, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String countdownCounting() {
|
||||||
|
return "bis die Bomben fallen";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void countdownFinished() {
|
||||||
|
drop();
|
||||||
|
|
||||||
|
startCountdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Point {
|
||||||
|
|
||||||
|
private final int x;
|
||||||
|
private final int y;
|
||||||
|
private final int z;
|
||||||
|
|
||||||
|
public Point(int x, int y, int z) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location addAndToLocation(World world, int x, int y, int z) {
|
||||||
|
return new Location(world, this.x + x, this.y + y, this.z + z); //NOSONAR
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum State {
|
||||||
|
|
||||||
|
PRE(60, 80, 1),
|
||||||
|
FIRST(40, 60, 5),
|
||||||
|
SECOND(30, 40, 6),
|
||||||
|
THIRD(20, 30, 6),
|
||||||
|
FOURTH(10, 20, 7),
|
||||||
|
LAST(5, 10, 0);
|
||||||
|
|
||||||
|
|
||||||
|
State(int minTime, int maxTime, int switchAfter) {
|
||||||
|
this.MIN_TIME = minTime;
|
||||||
|
this.MAX_TIME = maxTime;
|
||||||
|
this.SWITCH_AFTER = switchAfter;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final int MIN_TIME; //NOSONAR
|
||||||
|
private final int MAX_TIME; //NOSONAR
|
||||||
|
private final int SWITCH_AFTER; //NOSONAR
|
||||||
|
|
||||||
|
|
||||||
|
public State getNext() {
|
||||||
|
switch (this) {
|
||||||
|
case PRE:
|
||||||
|
return FIRST;
|
||||||
|
case FIRST:
|
||||||
|
return SECOND;
|
||||||
|
case SECOND:
|
||||||
|
return THIRD;
|
||||||
|
case THIRD:
|
||||||
|
return FOURTH;
|
||||||
|
case FOURTH:
|
||||||
|
case LAST:
|
||||||
|
return LAST;
|
||||||
|
default:
|
||||||
|
return PRE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum Direction {
|
||||||
|
NORTH(0, 0, 1),
|
||||||
|
SOUTH(0, 0, -1),
|
||||||
|
EAST(1, 0, 0),
|
||||||
|
WEST(-1, 0, 0);
|
||||||
|
|
||||||
|
|
||||||
|
int dx;
|
||||||
|
int dy;
|
||||||
|
int dz;
|
||||||
|
|
||||||
|
Direction(int dx, int dy, int dz) {
|
||||||
|
this.dx = dx;
|
||||||
|
this.dy = dy;
|
||||||
|
this.dz = dz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Direction getRandom() {
|
||||||
|
return Direction.values()[random.nextInt(Direction.values().length)];
|
||||||
|
}
|
||||||
|
|
||||||
|
Direction other() {
|
||||||
|
switch (this) {
|
||||||
|
case NORTH:
|
||||||
|
return EAST;
|
||||||
|
case SOUTH:
|
||||||
|
return WEST;
|
||||||
|
case EAST:
|
||||||
|
return NORTH;
|
||||||
|
case WEST:
|
||||||
|
return SOUTH;
|
||||||
|
default:
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLength(int length1, int length2) {
|
||||||
|
return isNorthOrSouth() ? length1 : length2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNorthOrSouth() {
|
||||||
|
return this == NORTH || this == SOUTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNorthOrWest() {
|
||||||
|
return this == NORTH || this == WEST;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -118,7 +118,7 @@ public class FightSchematic extends StateDependent {
|
|||||||
|
|
||||||
private void paste(){
|
private void paste(){
|
||||||
FreezeWorld freezer = new FreezeWorld();
|
FreezeWorld freezer = new FreezeWorld();
|
||||||
DyeColor c = ColorConverter.chat2dye(team.getColor());
|
DyeColor c = ArenaMode.AntiPrepare.contains(Config.mode) ? ColorConverter.chat2dye(team.getColor()) : DyeColor.PINK;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
VersionedRunnable.call(new VersionedRunnable(() -> {
|
VersionedRunnable.call(new VersionedRunnable(() -> {
|
||||||
@ -126,25 +126,26 @@ public class FightSchematic extends StateDependent {
|
|||||||
FightTeam_8.replaceTeamColor(clipboard, c);
|
FightTeam_8.replaceTeamColor(clipboard, c);
|
||||||
FightTeam_8.pasteSchematic(clipboard, region, rotate);
|
FightTeam_8.pasteSchematic(clipboard, region, rotate);
|
||||||
} catch (NoClipboardException | WorldEditException ex) {
|
} catch (NoClipboardException | WorldEditException ex) {
|
||||||
throw new SecurityException("Error pasting arena in schematic", ex);
|
throw new SecurityException("Error pasting schematic", ex);
|
||||||
}
|
}
|
||||||
}, 8), new VersionedRunnable(() -> {
|
}, 8), new VersionedRunnable(() -> {
|
||||||
try {
|
try {
|
||||||
FightTeam_12.replaceTeamColor(clipboard, c);
|
FightTeam_12.replaceTeamColor(clipboard, c);
|
||||||
FightTeam_8.pasteSchematic(clipboard, region, rotate);
|
FightTeam_8.pasteSchematic(clipboard, region, rotate);
|
||||||
} catch (NoClipboardException | WorldEditException ex) {
|
} catch (NoClipboardException | WorldEditException ex) {
|
||||||
throw new SecurityException("Error pasting arena in schematic", ex);
|
throw new SecurityException("Error pasting schematic", ex);
|
||||||
}
|
}
|
||||||
}, 12), new VersionedRunnable(() -> {
|
}, 12), new VersionedRunnable(() -> {
|
||||||
try {
|
try {
|
||||||
FightTeam_14.replaceTeamColor(clipboard, c);
|
FightTeam_14.replaceTeamColor(clipboard, c);
|
||||||
FightTeam_14.pasteSchematic(clipboard, region, rotate);
|
FightTeam_14.pasteSchematic(clipboard, region, rotate);
|
||||||
} catch (NoClipboardException | WorldEditException ex) {
|
} catch (NoClipboardException | WorldEditException ex) {
|
||||||
throw new SecurityException("Error pasting arena in schematic", ex);
|
throw new SecurityException("Error pasting schematic", ex);
|
||||||
}
|
}
|
||||||
}, 14));
|
}, 14));
|
||||||
} catch (SecurityException securityException) {
|
} catch (SecurityException securityException) {
|
||||||
team.broadcast(FightSystem.PREFIX + "§cFehler beim Pasten der Schematic");
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cFehler beim Pasten der Schematic");
|
||||||
|
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), FightSystem::setPreSchemState);
|
||||||
throw securityException;
|
throw securityException;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +94,10 @@ public class FightTeam implements IFightTeam{
|
|||||||
team.setAllowFriendlyFire(false);
|
team.setAllowFriendlyFire(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UUID getDesignatedLeader(){
|
||||||
|
return designatedLeader;
|
||||||
|
}
|
||||||
|
|
||||||
public Region getSchemRegion() {
|
public Region getSchemRegion() {
|
||||||
return schemRegion;
|
return schemRegion;
|
||||||
}
|
}
|
||||||
|
@ -51,8 +51,11 @@ public class ArenaBorder implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FightTeam team = Fight.getPlayerTeam(player);
|
FightTeam team = Fight.getPlayerTeam(player);
|
||||||
if(team == null || player.getGameMode() == GameMode.SPECTATOR)
|
if(team == null || player.getGameMode() == GameMode.SPECTATOR){
|
||||||
|
if(to.getY() <= Config.ArenaRegion.getMinY())
|
||||||
|
reset(event);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(to.getY() <= Config.ArenaRegion.getMinY()) {
|
if(to.getY() <= Config.ArenaRegion.getMinY()) {
|
||||||
if(FightState.infight())
|
if(FightState.infight())
|
||||||
|
@ -21,7 +21,6 @@ package de.steamwar.fightsystem.listener;
|
|||||||
|
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
|
||||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -29,17 +28,15 @@ import org.bukkit.block.Block;
|
|||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.projectiles.ProjectileSource;
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public class ArrowStopper implements Listener {
|
public class ArrowStopper {
|
||||||
|
|
||||||
private static final Vector NULL_VECTOR = new Vector(0, 0, 0);
|
private static final Vector NULL_VECTOR = new Vector(0, 0, 0);
|
||||||
private static final BlockFace[] BLOCK_FACES = {BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH};
|
private static final BlockFace[] BLOCK_FACES = {BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH};
|
||||||
|
|
||||||
public ArrowStopper() {
|
public ArrowStopper() {
|
||||||
new StateDependentListener(Config.TechhiderActive, FightState.Running, this);
|
|
||||||
new StateDependentTask(Config.TechhiderActive, FightState.Running, this::run, 1, 1);
|
new StateDependentTask(Config.TechhiderActive, FightState.Running, this::run, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +82,7 @@ public class ArrowStopper implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkBlock(Block block) {
|
private boolean checkBlock(Block block) {
|
||||||
return Config.HiddenBlocks.contains(block.getType().name());
|
return Config.HiddenBlocks.contains(block.getType().name().toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean invalidEntity(Arrow entity) {
|
private boolean invalidEntity(Arrow entity) {
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
@ -39,6 +40,11 @@ public class DenyWorldInteraction implements Listener {
|
|||||||
public DenyWorldInteraction() {
|
public DenyWorldInteraction() {
|
||||||
new StateDependentListener(ArenaMode.Test, FightState.PreRunning, this);
|
new StateDependentListener(ArenaMode.Test, FightState.PreRunning, this);
|
||||||
new StateDependentListener(ArenaMode.AntiTest, FightState.AntiRunning, this);
|
new StateDependentListener(ArenaMode.AntiTest, FightState.AntiRunning, this);
|
||||||
|
if(Core.getVersion() > 9){
|
||||||
|
Listener listener = new DenyWorldInteraction_10();
|
||||||
|
new StateDependentListener(ArenaMode.Test, FightState.PreRunning, listener);
|
||||||
|
new StateDependentListener(ArenaMode.AntiTest, FightState.AntiRunning, listener);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -68,13 +74,13 @@ public class DenyWorldInteraction implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClick(InventoryClickEvent event) {
|
public void onInventoryClick(InventoryClickEvent event) {
|
||||||
if(PersonalKitCreator.notInKitCreator(event.getWhoClicked()))
|
if(!PersonalKitCreator.inKitCreator(event.getWhoClicked()))
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryDrag(InventoryDragEvent event) {
|
public void onInventoryDrag(InventoryDragEvent event) {
|
||||||
if(PersonalKitCreator.notInKitCreator(event.getWhoClicked()))
|
if(!PersonalKitCreator.inKitCreator(event.getWhoClicked()))
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,17 +42,17 @@ public class HotbarGUI implements Listener {
|
|||||||
public void handlePlayerInteract(PlayerInteractEvent event) {
|
public void handlePlayerInteract(PlayerInteractEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if(!PersonalKitCreator.notInKitCreator(player))
|
if(PersonalKitCreator.inKitCreator(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(event.getItem() == null)
|
if(event.getItem() == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||||
if(fightTeam == null)
|
if(fightTeam == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
ItemMeta itemMeta = event.getItem().getItemMeta();
|
ItemMeta itemMeta = event.getItem().getItemMeta();
|
||||||
String displayName = itemMeta.getDisplayName();
|
String displayName = itemMeta.getDisplayName();
|
||||||
|
|
||||||
|
@ -61,8 +61,8 @@ public class PersonalKitCreator implements Listener {
|
|||||||
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§eInventar zum Anpassen des Kits öffnen§8!"));
|
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§eInventar zum Anpassen des Kits öffnen§8!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean notInKitCreator(HumanEntity player){
|
public static boolean inKitCreator(HumanEntity player){
|
||||||
return !openKitCreators.containsKey(player);
|
return openKitCreators.containsKey(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void closeIfInKitCreator(HumanEntity player){
|
public static void closeIfInKitCreator(HumanEntity player){
|
||||||
|
@ -82,7 +82,7 @@ public class TeamArea implements Listener {
|
|||||||
private void checkInInnerArea(Player player, Location to, FightTeam team){
|
private void checkInInnerArea(Player player, Location to, FightTeam team){
|
||||||
if(team.getSchemRegion().playerInRegion(to) && Config.PreperationArea >= 5){ // Preventing false positives due to small extension
|
if(team.getSchemRegion().playerInRegion(to) && Config.PreperationArea >= 5){ // Preventing false positives due to small extension
|
||||||
player.kickPlayer(null);
|
player.kickPlayer(null);
|
||||||
Bukkit.getLogger().log(Level.SEVERE, player.getName() + " ist in einen Teambereich eingedrungen.");
|
Bukkit.getLogger().log(Level.INFO, player.getName() + " ist in einen Teambereich eingedrungen.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,12 +50,8 @@ public class FightStatistics {
|
|||||||
public static void saveStats(FightTeam winner, String windescription){
|
public static void saveStats(FightTeam winner, String windescription){
|
||||||
String gameMode = Config.SchematicType.toDB();
|
String gameMode = Config.SchematicType.toDB();
|
||||||
|
|
||||||
int blueLeader = 0;
|
int blueLeader = getLeader(Fight.getBlueTeam());
|
||||||
int redLeader = 0;
|
int redLeader = getLeader(Fight.getRedTeam());
|
||||||
if(Fight.getBlueTeam().getLeader() != null)
|
|
||||||
blueLeader = SteamwarUser.get(Fight.getBlueTeam().getLeader().getPlayer().getUniqueId()).getId();
|
|
||||||
if(Fight.getRedTeam().getLeader() != null)
|
|
||||||
redLeader = SteamwarUser.get(Fight.getRedTeam().getLeader().getPlayer().getUniqueId()).getId();
|
|
||||||
|
|
||||||
int win = 0;
|
int win = 0;
|
||||||
double blueResult;
|
double blueResult;
|
||||||
@ -109,11 +105,19 @@ public class FightStatistics {
|
|||||||
int newRedElo = (int) Math.round(redElo + K * (1 - blueResult - redWinExpectation));
|
int newRedElo = (int) Math.round(redElo + K * (1 - blueResult - redWinExpectation));
|
||||||
Elo.setElo(blueLeader, gameMode, newBlueElo);
|
Elo.setElo(blueLeader, gameMode, newBlueElo);
|
||||||
Elo.setElo(redLeader, gameMode, newRedElo);
|
Elo.setElo(redLeader, gameMode, newRedElo);
|
||||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§7ELO von " + Fight.getBlueTeam().getPrefix() + Fight.getBlueTeam().getLeader().getPlayer().getName() + "§8: §7" + blueElo + "§8»§e" + newBlueElo);
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§7ELO von " + Fight.getBlueTeam().getPrefix() + SteamwarUser.get(blueLeader).getUserName() + "§8: §7" + blueElo + "§8»§e" + newBlueElo);
|
||||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§7ELO von " + Fight.getRedTeam().getPrefix() + Fight.getRedTeam().getLeader().getPlayer().getName() + "§8: §7" + redElo + "§8»§e" + newRedElo);
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§7ELO von " + Fight.getRedTeam().getPrefix() + SteamwarUser.get(redLeader).getUserName() + "§8: §7" + redElo + "§8»§e" + newRedElo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int getLeader(FightTeam team){
|
||||||
|
if(team.getLeader() != null)
|
||||||
|
return SteamwarUser.get(team.getLeader().getPlayer().getUniqueId()).getId();
|
||||||
|
else if(team.getDesignatedLeader() != null)
|
||||||
|
return SteamwarUser.get(team.getDesignatedLeader()).getId();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
private static void savePlayerStats(FightPlayer fp, int fightId){
|
private static void savePlayerStats(FightPlayer fp, int fightId){
|
||||||
SteamwarUser user = SteamwarUser.get(fp.getPlayer().getUniqueId());
|
SteamwarUser user = SteamwarUser.get(fp.getPlayer().getUniqueId());
|
||||||
de.steamwar.sql.FightPlayer.create(fightId, user.getId(), fp.getTeam().isBlue(), fp.getKit().getName(), fp.getKills(), !fp.isLiving());
|
de.steamwar.sql.FightPlayer.create(fightId, user.getId(), fp.getTeam().isBlue(), fp.getKit().getName(), fp.getKills(), !fp.isLiving());
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren