Merge branch 'master' into recordSystem
# Conflicts: # FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java # FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java
Dieser Commit ist enthalten in:
Commit
06960ffda7
@ -37,4 +37,24 @@ class WaterRemover_14 {
|
||||
|
||||
return ((Waterlogged) data).isWaterlogged();
|
||||
}
|
||||
|
||||
static boolean removeWater(Block block){
|
||||
if(block.getType() == Material.WATER){
|
||||
block.setType(Material.AIR);
|
||||
return true;
|
||||
}
|
||||
|
||||
BlockData data = block.getBlockData();
|
||||
if(!(data instanceof Waterlogged))
|
||||
return false;
|
||||
|
||||
Waterlogged waterlogged = (Waterlogged) data;
|
||||
if(waterlogged.isWaterlogged()){
|
||||
waterlogged.setWaterlogged(false);
|
||||
block.setBlockData(waterlogged);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -29,4 +29,12 @@ public class WaterRemover_8 {
|
||||
Material type = block.getType();
|
||||
return type == Material.WATER || type == Material.STATIONARY_WATER;
|
||||
}
|
||||
|
||||
static boolean removeWater(Block block){
|
||||
if(isWater(block)){
|
||||
block.setType(Material.AIR);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -140,6 +140,7 @@ public class Config {
|
||||
public static final int EventTeamRedID;
|
||||
public static final boolean BothTeamsPublic;
|
||||
public static final int MaximumTeamMembers;
|
||||
public static final boolean SpectateSystem;
|
||||
|
||||
//check parameter
|
||||
public static final int CheckSchemID;
|
||||
@ -374,6 +375,7 @@ public class Config {
|
||||
OnlyPublicSchematics = event.publicSchemsOnly();
|
||||
MaximumTeamMembers = event.getMaximumTeamMembers();
|
||||
}
|
||||
SpectateSystem = event.spectateSystem();
|
||||
}else{
|
||||
//No event
|
||||
TeamRedName = config.getString("Output.TeamRedName");
|
||||
@ -383,6 +385,7 @@ public class Config {
|
||||
EventTeamRedID = 0;
|
||||
BothTeamsPublic = true;
|
||||
MaximumTeamMembers = Integer.MAX_VALUE;
|
||||
SpectateSystem = false;
|
||||
}
|
||||
|
||||
String blueLeader = System.getProperty("blueLeader", null);
|
||||
|
@ -19,13 +19,24 @@
|
||||
|
||||
package de.steamwar.fightsystem.fight;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||
import com.comphenix.protocol.wrappers.PlayerInfoData;
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.record.RecordSystem;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.sql.Schematic;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Fight {
|
||||
private Fight(){}
|
||||
@ -114,17 +125,31 @@ public class Fight {
|
||||
if(gameMode == GameMode.SPECTATOR) {
|
||||
for(Player currentPlayer : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if(currentPlayer.getUniqueId() != player.getUniqueId() && currentPlayer.getGameMode() == GameMode.SPECTATOR) {
|
||||
currentPlayer.hidePlayer(player);
|
||||
player.hidePlayer(currentPlayer);
|
||||
}
|
||||
currentPlayer.hidePlayer(FightSystem.getPlugin(), player);
|
||||
player.hidePlayer(FightSystem.getPlugin(), currentPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
if(gameMode == GameMode.SURVIVAL) {
|
||||
if(FightSystem.getEventLeiter() == player || Config.test())
|
||||
return;
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
||||
PacketContainer gm1packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
|
||||
gm1packet.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE);
|
||||
List<PlayerInfoData> playerInfoActions = new ArrayList<>();
|
||||
playerInfoActions.add(new PlayerInfoData(WrappedGameProfile.fromPlayer(player), 1, EnumWrappers.NativeGameMode.CREATIVE, WrappedChatComponent.fromText(player.getDisplayName())));
|
||||
gm1packet.getPlayerInfoDataLists().write(0, playerInfoActions);
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, gm1packet);
|
||||
} catch (InvocationTargetException e) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Invocation target exception", e);
|
||||
}
|
||||
}, 2);
|
||||
}else if(gameMode == GameMode.SURVIVAL) {
|
||||
for(Player currentPlayer : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if(currentPlayer.getUniqueId() != player.getUniqueId() && currentPlayer.getGameMode() == GameMode.SPECTATOR) {
|
||||
currentPlayer.showPlayer(player);
|
||||
player.showPlayer(currentPlayer);
|
||||
currentPlayer.showPlayer(FightSystem.getPlugin(), player);
|
||||
player.showPlayer(FightSystem.getPlugin(), currentPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,14 +20,19 @@
|
||||
package de.steamwar.fightsystem.fight;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import de.steamwar.comms.packets.TablistNamePacket;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.IFightSystem;
|
||||
import de.steamwar.fightsystem.kit.KitManager;
|
||||
import de.steamwar.fightsystem.listener.PersonalKitCreator;
|
||||
import de.steamwar.fightsystem.record.RecordSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.utils.*;
|
||||
import de.steamwar.fightsystem.utils.ColorConverter;
|
||||
import de.steamwar.fightsystem.utils.FightScoreboard;
|
||||
import de.steamwar.fightsystem.utils.ItemBuilder;
|
||||
import de.steamwar.fightsystem.utils.TechHider;
|
||||
import de.steamwar.fightsystem.winconditions.RankedPlayerLeftWincondition;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.sql.NoClipboardException;
|
||||
@ -178,6 +183,8 @@ public class FightTeam implements IFightTeam{
|
||||
if(KitManager.getKits(false).size() > 1 || Config.PersonalKits)
|
||||
player.getInventory().setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build());
|
||||
player.getInventory().setItem(7, new ItemBuilder(Material.BEACON).removeAllAttributs().setDisplayName("§eRespawn").build());
|
||||
if(!Config.test())
|
||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), prefix + player.getName()).send(player), 5);
|
||||
TechHider.reloadChunks(player, chunksToReload);
|
||||
return fightPlayer;
|
||||
}
|
||||
@ -195,6 +202,8 @@ public class FightTeam implements IFightTeam{
|
||||
|
||||
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
||||
player.teleport(Config.SpecSpawn);
|
||||
if(!Config.test())
|
||||
new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), "§7§o" + player.getName()).send(player);
|
||||
TechHider.reloadChunks(player, chunksToReload);
|
||||
}
|
||||
|
||||
@ -223,6 +232,9 @@ public class FightTeam implements IFightTeam{
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!PersonalKitCreator.notInKitCreator(leader.getPlayer()))
|
||||
leader.getPlayer().closeInventory();
|
||||
|
||||
this.leader = leader;
|
||||
if(ready)
|
||||
setReady(false);
|
||||
|
@ -29,6 +29,7 @@ import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
@ -39,6 +40,21 @@ public class EventJoinListener extends BasicListener {
|
||||
super(Config.event() ? EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP, FightState.POST_SCHEM_SETUP) : EnumSet.noneOf(FightState.class));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerLogin(PlayerLoginEvent event) {
|
||||
if(!Config.SpectateSystem)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
if(user.getTeam() == Config.EventTeamBlueID ||
|
||||
user.getTeam() == Config.EventTeamRedID ||
|
||||
user.getId() == FightSystem.getEventFight().getKampfleiter())
|
||||
return;
|
||||
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "§cDu bist kein Kampfteilnehmer");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
@ -78,7 +78,7 @@ public class PersonalKitCreator extends BasicListener {
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
}
|
||||
|
||||
static boolean notInKitCreator(HumanEntity player){
|
||||
public static boolean notInKitCreator(HumanEntity player){
|
||||
return !openKitCreators.containsKey(player);
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.utils.Region;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -33,6 +34,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class PlayerMoveListener extends BasicListener {
|
||||
|
||||
@ -64,15 +66,30 @@ public class PlayerMoveListener extends BasicListener {
|
||||
reset(event, DENY_TEAM);
|
||||
else if(fightTeam == Fight.getRedTeam() && player.getGameMode() == GameMode.SPECTATOR)
|
||||
reset(event, DENY_ENTERN);
|
||||
else
|
||||
return; // Is allowed in area
|
||||
checkInInnerArea(event.getPlayer(), to, Config.TeamBlueCornerX, Config.TeamBlueCornerZ);
|
||||
}else if(inRedArea){
|
||||
if(fightTeam == null)
|
||||
reset(event, DENY_TEAM);
|
||||
else if(fightTeam == Fight.getBlueTeam() && player.getGameMode() == GameMode.SPECTATOR)
|
||||
reset(event, DENY_ENTERN);
|
||||
else
|
||||
return; // Is allowed in area
|
||||
checkInInnerArea(event.getPlayer(), to, Config.TeamRedCornerX, Config.TeamRedCornerZ);
|
||||
}else if(fightTeam != null && player.getGameMode() != GameMode.SPECTATOR && !fightTeam.canPlayerEntern(player))
|
||||
reset(event, DENY_ENTERN);
|
||||
}
|
||||
|
||||
private void checkInInnerArea(Player player, Location to, int teamCornerX, int teamCornerZ){
|
||||
boolean inArenaY = to.getY() + 1.8 <= Config.TeamBlueCornerY + Config.SchemsizeY;
|
||||
boolean inArea = inArenaY && Region.isIn2DRange(to, teamCornerX, teamCornerZ, Config.SchemsizeX, Config.SchemsizeZ, 0);
|
||||
if(inArea){
|
||||
player.kickPlayer(null);
|
||||
Bukkit.getLogger().log(Level.SEVERE, player.getName() + " ist in einen Teambereich eingedrungen.");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void arenaBorder(PlayerMoveEvent event){
|
||||
Player player = event.getPlayer();
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.comms.packets.TablistNamePacket;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.countdown.Countdown;
|
||||
@ -27,6 +28,7 @@ import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
@ -61,6 +63,8 @@ public class PlayerStateListener extends BasicListener{
|
||||
if (fightTeam == null) {
|
||||
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
|
||||
player.teleport(Config.SpecSpawn);
|
||||
if(!Config.test())
|
||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> new TablistNamePacket(SteamwarUser.get(player.getUniqueId()).getId(), "§7" + player.getName()).send(player), 5);
|
||||
} else {
|
||||
player.teleport(fightTeam.getSpawn());
|
||||
if(FightSystem.getFightState().setup())
|
||||
|
@ -49,14 +49,15 @@ public class WaterRemover {
|
||||
}
|
||||
|
||||
private static void checkBlock(Block b, int startX, int startY, int startZ) throws IsAnOcean {
|
||||
if(!isWater(b))
|
||||
if(!removeWater(b))
|
||||
return;
|
||||
|
||||
// If distance to original block is greater than 20
|
||||
if(Math.abs(startX - b.getX()) + Math.abs(startY - b.getY() + Math.abs(startZ - b.getZ())) >= 20)
|
||||
if(Math.abs(startX - b.getX()) + Math.abs(startY - b.getY() + Math.abs(startZ - b.getZ())) >= 20){
|
||||
b.setType(Material.WATER);
|
||||
throw new IsAnOcean();
|
||||
}
|
||||
|
||||
b.setType(Material.AIR);
|
||||
try{
|
||||
checkBlock(b.getRelative(BlockFace.EAST), startX, startY, startZ);
|
||||
checkBlock(b.getRelative(BlockFace.WEST), startX, startY, startZ);
|
||||
@ -84,4 +85,19 @@ public class WaterRemover {
|
||||
return WaterRemover_14.isWater(block);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean removeWater(Block block){
|
||||
//checks for water and removes it, if present
|
||||
switch(Core.getVersion()){
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 12:
|
||||
return WaterRemover_8.removeWater(block);
|
||||
case 14:
|
||||
case 15:
|
||||
default:
|
||||
return WaterRemover_14.removeWater(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren