SteamWar/FightSystem
Archiviert
13
1

Adding 1.8 Version Support

Dieser Commit ist enthalten in:
Lixfel 2019-11-10 22:34:22 +01:00
Ursprung e068a72f49
Commit cc42c86549
77 geänderte Dateien mit 448 neuen und 104 gelöschten Zeilen

42
FightSystem_12/pom.xml Normale Datei
Datei anzeigen

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>steamwar</groupId>
<artifactId>FightSystem</artifactId>
<version>1.0</version>
</parent>
<artifactId>FightSystem_12</artifactId>
<version>1.0</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.kt</exclude>
</excludes>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FightSystem_8</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.12</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -0,0 +1,11 @@
package de.steamwar.fightsystem.countdown;
import org.bukkit.Sound;
class Countdown_12 {
private Countdown_12(){}
static Sound getSound(String sound){
return Sound.valueOf(sound);
}
}

Datei anzeigen

@ -0,0 +1,45 @@
package de.steamwar.fightsystem.fight;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.regions.CuboidRegion;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.scoreboard.Team;
import java.util.Collections;
import java.util.Set;
public class FightTeam_12 {
private FightTeam_12(){}
@SuppressWarnings("deprecation")
private static final int COLOR_TO_REPLACE = DyeColor.PINK.getWoolData();
@SuppressWarnings("deprecation")
private static final BaseBlock CONCRETE = new BaseBlock(Material.CONCRETE.getId(), COLOR_TO_REPLACE);
@SuppressWarnings("deprecation")
private static final BaseBlock CONCRETE_POWDER = new BaseBlock(Material.CONCRETE_POWDER.getId(), COLOR_TO_REPLACE);
private static final Set<BaseBlock> CONCRETE_SET = Collections.singleton(CONCRETE);
private static final Set<BaseBlock> CONCRETE_POWDER_SET = Collections.singleton(CONCRETE_POWDER);
static void setTeamColor(Team team, ChatColor color){
team.setColor(color);
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM);
}
@SuppressWarnings("deprecation")
static void replaceTeamColor(EditSession e, DyeColor c, CuboidRegion region){
FightTeam_8.replaceTeamColor(e, c, region);
try {
e.replaceBlocks(region, CONCRETE_SET, new BaseBlock(CONCRETE.getId(), c.getWoolData()));
e.replaceBlocks(region, CONCRETE_POWDER_SET, new BaseBlock(CONCRETE_POWDER.getId(), c.getWoolData()));
} catch (MaxChangedBlocksException ex) {
// ignore, will never occur
}
}
}

Datei anzeigen

@ -0,0 +1,20 @@
package de.steamwar.fightsystem.listener;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.BaseComponent;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.entity.Player;
class BasicListener_12 {
private BasicListener_12(){}
static void toActionbar(Player player, BaseComponent... components){
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, components);
}
static void setAttackSpeed(Player player){
AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED);
attribute.setBaseValue(16);
}
}

Datei anzeigen

@ -0,0 +1,15 @@
package de.steamwar.fightsystem.utils;
import javafx.util.Pair;
import net.minecraft.server.v1_12_R1.PacketPlayOutMapChunk;
import org.bukkit.craftbukkit.v1_12_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
class TechHider_v12 {
private TechHider_v12(){}
static void reloadChunk(Player p, Pair<Integer, Integer> chunk){
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.getKey(), chunk.getValue())).getHandle(), 65535));
}
}

37
FightSystem_8/pom.xml Normale Datei
Datei anzeigen

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>steamwar</groupId>
<artifactId>FightSystem</artifactId>
<version>1.0</version>
</parent>
<artifactId>FightSystem_8</artifactId>
<version>1.0</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.kt</exclude>
</excludes>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.8</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -0,0 +1,20 @@
package de.steamwar.fightsystem.countdown;
import org.bukkit.Sound;
class Countdown_8 {
private Countdown_8(){}
static Sound getSound(String sound){
switch(sound){
case "ENTITY_WITHER_DEATH":
return Sound.WITHER_DEATH;
case "BLOCK_NOTE_BASS":
return Sound.NOTE_BASS;
case "BLOCK_NOTE_PLING":
return Sound.NOTE_PLING;
default:
return Sound.valueOf(sound);
}
}
}

Datei anzeigen

@ -0,0 +1,52 @@
package de.steamwar.fightsystem.fight;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.regions.CuboidRegion;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.scoreboard.NameTagVisibility;
import org.bukkit.scoreboard.Team;
import java.util.Collections;
import java.util.Set;
class FightTeam_8 {
private FightTeam_8(){}
@SuppressWarnings("deprecation")
private static final int COLOR_TO_REPLACE = DyeColor.PINK.getWoolData();
@SuppressWarnings("deprecation")
private static final BaseBlock WOOL = new BaseBlock(Material.WOOL.getId(), COLOR_TO_REPLACE);
@SuppressWarnings("deprecation")
private static final BaseBlock GLASS = new BaseBlock(Material.STAINED_GLASS.getId(), COLOR_TO_REPLACE);
@SuppressWarnings("deprecation")
private static final BaseBlock CLAY = new BaseBlock(Material.CLAY.getId(), COLOR_TO_REPLACE);
@SuppressWarnings("deprecation")
private static final BaseBlock GLASS_PANE = new BaseBlock(Material.STAINED_GLASS_PANE.getId(), COLOR_TO_REPLACE);
private static final Set<BaseBlock> WOOL_SET = Collections.singleton(WOOL);
private static final Set<BaseBlock> CLAY_SET = Collections.singleton(CLAY);
private static final Set<BaseBlock> GLASS_SET = Collections.singleton(GLASS);
private static final Set<BaseBlock> GLASS_PANE_SET = Collections.singleton(GLASS_PANE);
static void setTeamColor(Team team, ChatColor color){
team.setPrefix("§" + color.getChar());
team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS);
}
@SuppressWarnings("deprecation")
static void replaceTeamColor(EditSession e, DyeColor c, CuboidRegion region){
try {
e.replaceBlocks(region, WOOL_SET, new BaseBlock(WOOL.getId(), c.getWoolData()));
e.replaceBlocks(region, CLAY_SET, new BaseBlock(CLAY.getId(), c.getWoolData()));
e.replaceBlocks(region, GLASS_SET, new BaseBlock(GLASS.getId(), c.getWoolData()));
e.replaceBlocks(region, GLASS_PANE_SET, new BaseBlock(GLASS_PANE.getId(), c.getWoolData()));
} catch (MaxChangedBlocksException ex) {
// ignore, will never occur
}
}
}

Datei anzeigen

@ -0,0 +1,12 @@
package de.steamwar.fightsystem.listener;
import net.md_5.bungee.api.chat.BaseComponent;
import org.bukkit.entity.Player;
class BasicListener_8 {
private BasicListener_8(){}
static void toActionbar(Player player, BaseComponent... components){
player.spigot().sendMessage(components);
}
}

Datei anzeigen

@ -0,0 +1,15 @@
package de.steamwar.fightsystem.utils;
import javafx.util.Pair;
import net.minecraft.server.v1_8_R3.PacketPlayOutMapChunk;
import org.bukkit.craftbukkit.v1_8_R3.CraftChunk;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
class TechHider_v8 {
private TechHider_v8(){}
static void reloadChunk(Player p, Pair<Integer, Integer> chunk){
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.getKey(), chunk.getValue())).getHandle(), true, 65535));
}
}

67
FightSystem_Main/pom.xml Normale Datei
Datei anzeigen

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>steamwar</groupId>
<artifactId>FightSystem</artifactId>
<version>1.0</version>
</parent>
<artifactId>FightSystem_Main</artifactId>
<version>1.0</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.kt</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FightSystem_8</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FightSystem_12</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -1,5 +1,6 @@
package de.steamwar.fightsystem.countdown; package de.steamwar.fightsystem.countdown;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.Fight;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -21,9 +22,9 @@ public abstract class Countdown {
abstract String countdownCounting(); abstract String countdownCounting();
abstract void countdownFinished(); abstract void countdownFinished();
Countdown(int time, Sound sound, boolean level) { Countdown(int time, String sound, boolean level) {
this.time = time; this.time = time;
this.sound = sound; this.sound = getSound(sound);
this.level = level; this.level = level;
countdowns.add(this); countdowns.add(this);
@ -31,6 +32,18 @@ public abstract class Countdown {
this.taskID = bukkitScheduler.scheduleSyncRepeatingTask(FightSystem.getPlugin(), this::count, 0, 20); this.taskID = bukkitScheduler.scheduleSyncRepeatingTask(FightSystem.getPlugin(), this::count, 0, 20);
} }
public static Sound getSound(String sound){
if(sound == null)
return null;
switch (Core.getVersion()){
case 8:
return Countdown_8.getSound(sound);
default:
return Countdown_12.getSound(sound);
}
}
public static void cancelAllTimers() { public static void cancelAllTimers() {
while (!countdowns.isEmpty()) { while (!countdowns.isEmpty()) {
countdowns.get(0).cancelTimer(); countdowns.get(0).cancelTimer();

Datei anzeigen

@ -3,12 +3,11 @@ package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.utils.Config; import de.steamwar.fightsystem.utils.Config;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Sound;
public class EnternCountdown extends Countdown { public class EnternCountdown extends Countdown {
public EnternCountdown() { public EnternCountdown() {
super(Config.EnterPhaseBegin, Sound.BLOCK_NOTE_PLING, false); super(Config.EnterPhaseBegin, "BLOCK_NOTE_PLING", false);
} }
@Override @Override

Datei anzeigen

@ -1,13 +1,12 @@
package de.steamwar.fightsystem.countdown; package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.utils.Config;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import org.bukkit.Sound; import de.steamwar.fightsystem.utils.Config;
public class EventStartCountdown extends Countdown { public class EventStartCountdown extends Countdown {
public EventStartCountdown() { public EventStartCountdown() {
super(Config.SetupDuration, Sound.BLOCK_NOTE_PLING, false); super(Config.SetupDuration, "BLOCK_NOTE_PLING", false);
} }
@Override @Override

Datei anzeigen

@ -2,12 +2,11 @@ package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.utils.Config; import de.steamwar.fightsystem.utils.Config;
import org.bukkit.Sound;
public class PreRunningCountdown extends Countdown { public class PreRunningCountdown extends Countdown {
public PreRunningCountdown() { public PreRunningCountdown() {
super(Config.PreFightDuration, Sound.BLOCK_NOTE_PLING, true); super(Config.PreFightDuration, "BLOCK_NOTE_PLING", true);
} }
@Override @Override

Datei anzeigen

@ -2,12 +2,11 @@ package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.utils.Config; import de.steamwar.fightsystem.utils.Config;
import org.bukkit.Sound;
public class SpectateOverCountdown extends Countdown { public class SpectateOverCountdown extends Countdown {
public SpectateOverCountdown() { public SpectateOverCountdown() {
super(Config.SpectatorDuration, Sound.BLOCK_NOTE_PLING, false); super(Config.SpectatorDuration, "BLOCK_NOTE_PLING", false);
} }
@Override @Override

Datei anzeigen

@ -5,14 +5,13 @@ import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.winconditions.WinconditionTechKO; import de.steamwar.fightsystem.winconditions.WinconditionTechKO;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Sound;
public class TechKOCountdown extends Countdown { public class TechKOCountdown extends Countdown {
private final FightTeam team; private final FightTeam team;
public TechKOCountdown(FightTeam team) { public TechKOCountdown(FightTeam team) {
super(WinconditionTechKO.TECH_KO_COUNTDOWN_TIME, Sound.BLOCK_NOTE_PLING, false); super(WinconditionTechKO.TECH_KO_COUNTDOWN_TIME, "BLOCK_NOTE_PLING", false);
this.team = team; this.team = team;
} }

Datei anzeigen

@ -3,12 +3,11 @@ package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.utils.Config; import de.steamwar.fightsystem.utils.Config;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Sound;
public class TimeOverCountdown extends Countdown { public class TimeOverCountdown extends Countdown {
public TimeOverCountdown() { public TimeOverCountdown() {
super(Config.TimeoutTime, Sound.BLOCK_NOTE_BASS, false); super(Config.TimeoutTime, "BLOCK_NOTE_BASS", false);
} }
@Override @Override

Datei anzeigen

@ -2,13 +2,12 @@ package de.steamwar.fightsystem.fight;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.bukkit.BukkitWorld; import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.kit.KitManager; import de.steamwar.fightsystem.kit.KitManager;
import de.steamwar.fightsystem.utils.*; import de.steamwar.fightsystem.utils.*;
@ -23,35 +22,15 @@ import org.bukkit.scoreboard.Team;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.logging.Level; import java.util.logging.Level;
public class FightTeam { public class FightTeam {
@SuppressWarnings("deprecation")
private static final int COLOR_TO_REPLACE = DyeColor.PINK.getWoolData();
@SuppressWarnings("deprecation")
private static final BaseBlock WOOL = new BaseBlock(Material.WOOL.getId(), COLOR_TO_REPLACE);
@SuppressWarnings("deprecation")
private static final BaseBlock GLASS = new BaseBlock(Material.STAINED_GLASS.getId(), COLOR_TO_REPLACE);
@SuppressWarnings("deprecation")
private static final BaseBlock CLAY = new BaseBlock(Material.CLAY.getId(), COLOR_TO_REPLACE);
@SuppressWarnings("deprecation")
private static final BaseBlock GLASS_PANE = new BaseBlock(Material.STAINED_GLASS_PANE.getId(), COLOR_TO_REPLACE);
@SuppressWarnings("deprecation")
private static final BaseBlock CONCRETE = new BaseBlock(Material.CONCRETE.getId(), COLOR_TO_REPLACE);
@SuppressWarnings("deprecation")
private static final BaseBlock CONCRETE_POWDER = new BaseBlock(Material.CONCRETE_POWDER.getId(), COLOR_TO_REPLACE);
private static final Set<BaseBlock> WOOL_SET = Collections.singleton(WOOL);
private static final Set<BaseBlock> CONCRETE_SET = Collections.singleton(CONCRETE);
private static final Set<BaseBlock> CLAY_SET = Collections.singleton(CLAY);
private static final Set<BaseBlock> GLASS_SET = Collections.singleton(GLASS);
private static final Set<BaseBlock> GLASS_PANE_SET = Collections.singleton(GLASS_PANE);
private static final Set<BaseBlock> CONCRETE_POWDER_SET = Collections.singleton(CONCRETE_POWDER);
private FightPlayer leader; private FightPlayer leader;
private final UUID designatedLeader; private final UUID designatedLeader;
private final Set<FightPlayer> players = new HashSet<>(); private final Set<FightPlayer> players = new HashSet<>();
@ -84,9 +63,18 @@ public class FightTeam {
team = FightScoreboard.getScoreboard().registerNewTeam(name); team = FightScoreboard.getScoreboard().registerNewTeam(name);
else else
team = FightScoreboard.getScoreboard().getTeam(name); team = FightScoreboard.getScoreboard().getTeam(name);
team.setColor(color); setTeamColor(team, color);
team.setAllowFriendlyFire(false); team.setAllowFriendlyFire(false);
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM); }
private void setTeamColor(Team team, ChatColor color){
switch(Core.getVersion()){
case 8:
FightTeam_8.setTeamColor(team, color);
break;
default:
FightTeam_12.setTeamColor(team, color);
}
} }
public boolean canbeLeader(Player p){ public boolean canbeLeader(Player p){
@ -256,21 +244,16 @@ public class FightTeam {
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), this::teleportToSpawn,40); Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), this::teleportToSpawn,40);
} }
@SuppressWarnings("deprecation")
private void replaceTeamColor(EditSession e){ private void replaceTeamColor(EditSession e){
CuboidRegion region = new CuboidRegion(corner, corner.add(Config.Schemsize)); CuboidRegion region = new CuboidRegion(corner, corner.add(Config.Schemsize));
DyeColor c = ColorConverter.chat2dye(color); DyeColor c = ColorConverter.chat2dye(color);
try { switch(Core.getVersion()){
e.replaceBlocks(region, WOOL_SET, new BaseBlock(WOOL.getId(), c.getWoolData())); case 8:
e.replaceBlocks(region, CONCRETE_SET, new BaseBlock(CONCRETE.getId(), c.getWoolData())); FightTeam_8.replaceTeamColor(e, c, region);
e.replaceBlocks(region, CONCRETE_POWDER_SET, new BaseBlock(CONCRETE_POWDER.getId(), c.getWoolData())); break;
e.replaceBlocks(region, CLAY_SET, new BaseBlock(CLAY.getId(), c.getWoolData())); default:
e.replaceBlocks(region, GLASS_SET, new BaseBlock(GLASS.getId(), c.getWoolData())); FightTeam_12.replaceTeamColor(e, c, region);
e.replaceBlocks(region, GLASS_PANE_SET, new BaseBlock(GLASS_PANE.getId(), c.getWoolData()));
} catch (MaxChangedBlocksException ex) {
// ignore, will never occur
} }
e.flushQueue(); e.flushQueue();

Datei anzeigen

@ -1,8 +1,10 @@
package de.steamwar.fightsystem.listener; package de.steamwar.fightsystem.listener;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightState; import de.steamwar.fightsystem.fight.FightState;
import net.md_5.bungee.api.chat.BaseComponent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -42,4 +44,23 @@ public abstract class BasicListener implements Listener {
HandlerList.unregisterAll(this); HandlerList.unregisterAll(this);
listeners.remove(this); listeners.remove(this);
} }
void toActionbar(Player player, BaseComponent... components){
switch(Core.getVersion()){
case 8:
BasicListener_8.toActionbar(player, components);
break;
default:
BasicListener_12.toActionbar(player, components);
}
}
void setAttackSpeed(Player player){
switch(Core.getVersion()){
case 8:
break;
default:
BasicListener_12.setAttackSpeed(player);
}
}
} }

Datei anzeigen

@ -1,6 +1,5 @@
package de.steamwar.fightsystem.listener; package de.steamwar.fightsystem.listener;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -15,7 +14,7 @@ public class BlockListener extends BasicListener {
if(notRunning() || notFighting(player)){ if(notRunning() || notFighting(player)){
event.setCancelled(true); event.setCancelled(true);
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§cDu darfst erst nach Fightbeginn Blöcke abbauen!")); toActionbar(player, TextComponent.fromLegacyText("§cDu darfst erst nach Fightbeginn Blöcke abbauen!"));
} }
} }
@ -25,7 +24,7 @@ public class BlockListener extends BasicListener {
if(notRunning() || notFighting(player)) { if(notRunning() || notFighting(player)) {
event.setCancelled(true); event.setCancelled(true);
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§cDu darfst erst nach Fightbeginn Blöcke setzen!")); toActionbar(player, TextComponent.fromLegacyText("§cDu darfst erst nach Fightbeginn Blöcke setzen!"));
} }
} }
} }

Datei anzeigen

@ -1,7 +1,6 @@
package de.steamwar.fightsystem.listener; package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.Fight;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -63,7 +62,7 @@ public class EntityDamageListener extends BasicListener {
if(Fight.getPlayerTeam(player) == Fight.getPlayerTeam(damager)) { if(Fight.getPlayerTeam(player) == Fight.getPlayerTeam(damager)) {
event.setCancelled(true); event.setCancelled(true);
damager.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§cDu darfst deinen Teamkollegen keinen Schaden zufügen!")); toActionbar(damager, TextComponent.fromLegacyText("§cDu darfst deinen Teamkollegen keinen Schaden zufügen!"));
} }
} }
} }

Datei anzeigen

@ -2,6 +2,7 @@ package de.steamwar.fightsystem.listener;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.weather.WeatherChangeEvent;
public class FoodLevelChangeListener extends BasicListener { public class FoodLevelChangeListener extends BasicListener {
@ -10,5 +11,8 @@ public class FoodLevelChangeListener extends BasicListener {
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler
public void onWeatherChange(WeatherChangeEvent event){
event.setCancelled(true);
}
} }

Datei anzeigen

@ -8,8 +8,6 @@ import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.utils.Config; import de.steamwar.fightsystem.utils.Config;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -25,8 +23,7 @@ public class PlayerConnectionListener extends BasicListener{
Player player = event.getPlayer(); Player player = event.getPlayer();
player.setHealth(20); player.setHealth(20);
player.setFoodLevel(20); player.setFoodLevel(20);
AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED); setAttackSpeed(player);
attribute.setBaseValue(16);
FightTeam fightTeam = Fight.getPlayerTeam(player); FightTeam fightTeam = Fight.getPlayerTeam(player);

Datei anzeigen

@ -1,11 +1,11 @@
package de.steamwar.fightsystem.listener; package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.Countdown;
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 org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -26,6 +26,6 @@ public class PlayerDeathListener extends BasicListener {
fightTeam.getFightPlayer(player).setOut(); fightTeam.getFightPlayer(player).setOut();
player.setGameMode(GameMode.SPECTATOR); player.setGameMode(GameMode.SPECTATOR);
player.teleport(fightTeam.getSpawn()); player.teleport(fightTeam.getSpawn());
Fight.playSound(Sound.ENTITY_WITHER_DEATH, 100.0F, 1.0F); Fight.playSound(Countdown.getSound("ENTITY_WITHER_DEATH"), 100.0F, 1.0F);
} }
} }

Datei anzeigen

@ -6,7 +6,6 @@ import de.steamwar.fightsystem.fight.FightState;
import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.utils.Config; import de.steamwar.fightsystem.utils.Config;
import de.steamwar.fightsystem.utils.Region; import de.steamwar.fightsystem.utils.Region;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
@ -74,6 +73,6 @@ public class PlayerMoveListener extends BasicListener {
private void reset(PlayerMoveEvent event, String message){ private void reset(PlayerMoveEvent event, String message){
Player player = event.getPlayer(); Player player = event.getPlayer();
player.teleport(event.getFrom()); player.teleport(event.getFrom());
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message)); toActionbar(player, TextComponent.fromLegacyText(message));
} }
} }

Datei anzeigen

@ -1,6 +1,5 @@
package de.steamwar.fightsystem.listener; package de.steamwar.fightsystem.listener;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
@ -11,7 +10,7 @@ public class PlayerTeleportListener extends BasicListener {
public void onTpGM3(PlayerTeleportEvent e) { public void onTpGM3(PlayerTeleportEvent e) {
if (e.getCause() == PlayerTeleportEvent.TeleportCause.SPECTATE) { if (e.getCause() == PlayerTeleportEvent.TeleportCause.SPECTATE) {
e.setCancelled(true); e.setCancelled(true);
e.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§cDu darfst diese Teleportfunktion nicht benutzen!")); toActionbar(e.getPlayer(), TextComponent.fromLegacyText("§cDu darfst diese Teleportfunktion nicht benutzen!"));
} }
} }
} }

Datei anzeigen

@ -2,7 +2,6 @@ package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.FightState; import de.steamwar.fightsystem.fight.FightState;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -16,7 +15,7 @@ public class ProjectileLaunchListener extends BasicListener {
event.setCancelled(true); event.setCancelled(true);
if(event.getEntity().getShooter() instanceof Player){ if(event.getEntity().getShooter() instanceof Player){
Player player = (Player) event.getEntity().getShooter(); Player player = (Player) event.getEntity().getShooter();
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§cDu darfst den Bogen erst nach Fightbeginn nutzen!")); toActionbar(player, TextComponent.fromLegacyText("§cDu darfst den Bogen erst nach Fightbeginn nutzen!"));
} }
} }
} }

Datei anzeigen

@ -13,18 +13,16 @@ import com.comphenix.protocol.wrappers.WrappedBlockData;
import com.comphenix.protocol.wrappers.nbt.NbtCompound; import com.comphenix.protocol.wrappers.nbt.NbtCompound;
import com.comphenix.protocol.wrappers.nbt.NbtFactory; import com.comphenix.protocol.wrappers.nbt.NbtFactory;
import com.google.common.primitives.Bytes; import com.google.common.primitives.Bytes;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
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 io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator; import io.netty.buffer.UnpooledByteBufAllocator;
import javafx.util.Pair; import javafx.util.Pair;
import net.minecraft.server.v1_12_R1.PacketPlayOutMapChunk;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_12_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.*; import java.util.*;
@ -77,16 +75,18 @@ public class TechHider {
if(Config.event()) if(Config.event())
threadMultiplier = 4; threadMultiplier = 4;
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.USE_ITEM) { if(Core.getVersion() > 8){
@Override ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.USE_ITEM) {
public void onPacketReceiving(PacketEvent e) { @Override
Player p = e.getPlayer(); public void onPacketReceiving(PacketEvent e) {
Player p = e.getPlayer();
if(p.getGameMode() == GameMode.SPECTATOR){ if(p.getGameMode() == GameMode.SPECTATOR){
e.setCancelled(true); e.setCancelled(true);
}
} }
} });
}); }
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.USE_ENTITY) { ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.USE_ENTITY) {
@Override @Override
public void onPacketReceiving(PacketEvent e) { public void onPacketReceiving(PacketEvent e) {
@ -360,11 +360,21 @@ public class TechHider {
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> { Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
for(Pair<Integer, Integer> chunk : chunksToReload){ for(Pair<Integer, Integer> chunk : chunksToReload){
if(bypass(p, chunk.getKey(), chunk.getValue())) if(bypass(p, chunk.getKey(), chunk.getValue()))
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.getKey(), chunk.getValue())).getHandle(), 65535)); reloadChunk(p, chunk);
} }
}, 40); }, 40);
} }
private static void reloadChunk(Player p, Pair<Integer, Integer> chunk){
switch(Core.getVersion()){
case 8:
TechHider_v8.reloadChunk(p, chunk);
break;
default:
TechHider_v12.reloadChunk(p, chunk);
}
}
private static boolean disabled(){ private static boolean disabled(){
return Config.event() && Config.OnlyPublicSchematics; return Config.event() && Config.OnlyPublicSchematics;
} }

31
pom.xml
Datei anzeigen

@ -4,11 +4,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>de.steamwar</groupId> <groupId>steamwar</groupId>
<artifactId>FightSystem</artifactId> <artifactId>FightSystem</artifactId>
<version>1.0</version> <version>1.0</version>
<packaging>jar</packaging>
<url>https://maven.apache.org</url> <url>https://maven.apache.org</url>
<packaging>pom</packaging>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -22,35 +22,26 @@
</repositories> </repositories>
<build> <build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.kt</exclude>
</excludes>
</resource>
</resources>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration> <configuration>
<source>8</source> <source>1.8</source>
<target>8</target> <target>1.8</target>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<modules>
<module>FightSystem_8</module>
<module>FightSystem_12</module>
<module>FightSystem_Main</module>
</modules>
<dependencies> <dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>steamwar</groupId> <groupId>steamwar</groupId>
<artifactId>SpigotCore</artifactId> <artifactId>SpigotCore</artifactId>