RedstoneWincondition #274
@ -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;
|
||||||
|
@ -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