From 6582b9a5c4fb631837ea11a89acc3e14598e9584 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 27 Dec 2019 10:09:03 +0100 Subject: [PATCH 1/4] Adding SWSound for better Sound handling Signed-off-by: Lixfel --- .../fightsystem/countdown/Countdown_12.java | 13 +++++++++++-- .../fightsystem/countdown/Countdown_14.java | 12 +++++++----- .../steamwar/fightsystem/countdown/Countdown_8.java | 10 +++++----- .../de/steamwar/fightsystem/countdown/SWSound.java | 7 +++++++ .../steamwar/fightsystem/countdown/Countdown.java | 4 ++-- .../fightsystem/countdown/EnternCountdown.java | 2 +- .../fightsystem/countdown/EventStartCountdown.java | 2 +- .../fightsystem/countdown/PreRunningCountdown.java | 2 +- .../countdown/SpectateOverCountdown.java | 2 +- .../fightsystem/countdown/TechKOCountdown.java | 2 +- .../fightsystem/countdown/TimeOverCountdown.java | 2 +- .../fightsystem/listener/PlayerDeathListener.java | 3 ++- 12 files changed, 40 insertions(+), 21 deletions(-) create mode 100644 FightSystem_API/src/de/steamwar/fightsystem/countdown/SWSound.java diff --git a/FightSystem_12/src/de/steamwar/fightsystem/countdown/Countdown_12.java b/FightSystem_12/src/de/steamwar/fightsystem/countdown/Countdown_12.java index 8601fd1..a8c69bb 100644 --- a/FightSystem_12/src/de/steamwar/fightsystem/countdown/Countdown_12.java +++ b/FightSystem_12/src/de/steamwar/fightsystem/countdown/Countdown_12.java @@ -5,7 +5,16 @@ import org.bukkit.Sound; class Countdown_12 { private Countdown_12(){} - static Sound getSound(String sound){ - return Sound.valueOf(sound); + static Sound getSound(SWSound sound){ + switch(sound){ + case ENTITY_WITHER_DEATH: + return Sound.ENTITY_WITHER_DEATH; + case BLOCK_NOTE_BASS: + return Sound.BLOCK_NOTE_BASS; + case BLOCK_NOTE_PLING: + return Sound.BLOCK_NOTE_PLING; + default: + return null; + } } } diff --git a/FightSystem_14/src/de/steamwar/fightsystem/countdown/Countdown_14.java b/FightSystem_14/src/de/steamwar/fightsystem/countdown/Countdown_14.java index d91d9bf..1f2319d 100644 --- a/FightSystem_14/src/de/steamwar/fightsystem/countdown/Countdown_14.java +++ b/FightSystem_14/src/de/steamwar/fightsystem/countdown/Countdown_14.java @@ -5,14 +5,16 @@ import org.bukkit.Sound; class Countdown_14 { private Countdown_14(){} - static Sound getSound(String sound){ + static Sound getSound(SWSound sound){ switch(sound){ - case "BLOCK_NOTE_BASS": - return Sound.BLOCK_NOTE_BLOCK_PLING; - case "BLOCK_NOTE_PLING": + case ENTITY_WITHER_DEATH: + return Sound.ENTITY_WITHER_DEATH; + case BLOCK_NOTE_BASS: + return Sound.BLOCK_NOTE_BLOCK_BASS; + case BLOCK_NOTE_PLING: return Sound.BLOCK_NOTE_BLOCK_PLING; default: - return Sound.valueOf(sound); + return null; } } } diff --git a/FightSystem_8/src/de/steamwar/fightsystem/countdown/Countdown_8.java b/FightSystem_8/src/de/steamwar/fightsystem/countdown/Countdown_8.java index baf48fa..819e671 100644 --- a/FightSystem_8/src/de/steamwar/fightsystem/countdown/Countdown_8.java +++ b/FightSystem_8/src/de/steamwar/fightsystem/countdown/Countdown_8.java @@ -5,16 +5,16 @@ import org.bukkit.Sound; class Countdown_8 { private Countdown_8(){} - static Sound getSound(String sound){ + static Sound getSound(SWSound sound){ switch(sound){ - case "ENTITY_WITHER_DEATH": + case ENTITY_WITHER_DEATH: return Sound.WITHER_DEATH; - case "BLOCK_NOTE_BASS": + case BLOCK_NOTE_BASS: return Sound.NOTE_BASS; - case "BLOCK_NOTE_PLING": + case BLOCK_NOTE_PLING: return Sound.NOTE_PLING; default: - return Sound.valueOf(sound); + return null; } } } diff --git a/FightSystem_API/src/de/steamwar/fightsystem/countdown/SWSound.java b/FightSystem_API/src/de/steamwar/fightsystem/countdown/SWSound.java new file mode 100644 index 0000000..ea11561 --- /dev/null +++ b/FightSystem_API/src/de/steamwar/fightsystem/countdown/SWSound.java @@ -0,0 +1,7 @@ +package de.steamwar.fightsystem.countdown; + +public enum SWSound { + ENTITY_WITHER_DEATH, + BLOCK_NOTE_PLING, + BLOCK_NOTE_BASS +} diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java index f796f76..d501ba2 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java @@ -26,7 +26,7 @@ public abstract class Countdown { abstract String countdownCounting(); abstract void countdownFinished(); - Countdown(int time, String sound, boolean level) { + Countdown(int time, SWSound sound, boolean level) { this.time = time; this.sound = getSound(sound); this.level = level; @@ -36,7 +36,7 @@ public abstract class Countdown { this.taskID = bukkitScheduler.scheduleSyncRepeatingTask(FightSystem.getPlugin(), this::count, 0, 20); } - public static Sound getSound(String sound){ + public static Sound getSound(SWSound sound){ if(sound == null) return null; diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/EnternCountdown.java b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/EnternCountdown.java index f5b36b6..d737981 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/EnternCountdown.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/EnternCountdown.java @@ -7,7 +7,7 @@ import org.bukkit.Bukkit; public class EnternCountdown extends Countdown { public EnternCountdown() { - super(Config.EnterPhaseBegin, "BLOCK_NOTE_PLING", false); + super(Config.EnterPhaseBegin, SWSound.BLOCK_NOTE_PLING, false); } @Override diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/EventStartCountdown.java b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/EventStartCountdown.java index 71fbe1d..10cf9a0 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/EventStartCountdown.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/EventStartCountdown.java @@ -6,7 +6,7 @@ import de.steamwar.fightsystem.Config; public class EventStartCountdown extends Countdown { public EventStartCountdown() { - super(Config.SetupDuration, "BLOCK_NOTE_PLING", false); + super(Config.SetupDuration, SWSound.BLOCK_NOTE_PLING, false); } @Override diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java index 8ba17fc..e8c00fd 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java @@ -6,7 +6,7 @@ import de.steamwar.fightsystem.Config; public class PreRunningCountdown extends Countdown { public PreRunningCountdown() { - super(Config.PreFightDuration, "BLOCK_NOTE_PLING", true); + super(Config.PreFightDuration, SWSound.BLOCK_NOTE_PLING, true); } @Override diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java index 04f51aa..7043e6f 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java @@ -6,7 +6,7 @@ import de.steamwar.fightsystem.Config; public class SpectateOverCountdown extends Countdown { public SpectateOverCountdown() { - super(Config.SpectatorDuration, "BLOCK_NOTE_PLING", false); + super(Config.SpectatorDuration, SWSound.BLOCK_NOTE_PLING, false); } @Override diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/TechKOCountdown.java b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/TechKOCountdown.java index 04e747d..dc88975 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/TechKOCountdown.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/TechKOCountdown.java @@ -11,7 +11,7 @@ public class TechKOCountdown extends Countdown { private final FightTeam team; public TechKOCountdown(FightTeam team) { - super(WinconditionTechKO.TECH_KO_COUNTDOWN_TIME, "BLOCK_NOTE_PLING", false); + super(WinconditionTechKO.TECH_KO_COUNTDOWN_TIME, SWSound.BLOCK_NOTE_PLING, false); this.team = team; } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/TimeOverCountdown.java b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/TimeOverCountdown.java index 6b94ed9..ece88dd 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/TimeOverCountdown.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/TimeOverCountdown.java @@ -9,7 +9,7 @@ public class TimeOverCountdown extends Countdown { private final Runnable timeOver; public TimeOverCountdown(Runnable timeOver) { - super(Config.TimeoutTime, "BLOCK_NOTE_BASS", false); + super(Config.TimeoutTime, SWSound.BLOCK_NOTE_BASS, false); this.timeOver = timeOver; } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/PlayerDeathListener.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/PlayerDeathListener.java index 7ea2fb8..ae22b48 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/PlayerDeathListener.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/PlayerDeathListener.java @@ -2,6 +2,7 @@ package de.steamwar.fightsystem.listener; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.countdown.Countdown; +import de.steamwar.fightsystem.countdown.SWSound; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import org.bukkit.Bukkit; @@ -26,6 +27,6 @@ public class PlayerDeathListener extends BasicListener { fightTeam.getFightPlayer(player).setOut(); player.setGameMode(GameMode.SPECTATOR); player.teleport(fightTeam.getSpawn()); - Fight.playSound(Countdown.getSound("ENTITY_WITHER_DEATH"), 100.0F, 1.0F); + Fight.playSound(Countdown.getSound(SWSound.ENTITY_WITHER_DEATH), 100.0F, 1.0F); } } From 692cd609bc919d8e6e2c438efafe9a4ca171c2ae Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 27 Dec 2019 11:05:12 +0100 Subject: [PATCH 2/4] Adding 1.9 and 1.10 support, also refactoring Multiversion Support to current norm Signed-off-by: Lixfel --- FightSystem_10/pom.xml | 53 +++++++++++++++++++ .../fightsystem/countdown/Countdown_10.java | 11 ++++ .../fightsystem/fight/FightTeam_10.java | 26 +++++++++ .../listener/BasicListener_10.java | 20 +++++++ .../fightsystem/utils/ColorConverter_10.java | 11 ++++ .../fightsystem/utils/TechHider_10.java | 15 ++++++ .../fightsystem/utils/WaterRemover_10.java | 11 ++++ FightSystem_12/pom.xml | 8 +-- .../fightsystem/countdown/Countdown_12.java | 11 +--- .../fightsystem/fight/FightTeam_12.java | 12 +++-- .../listener/BasicListener_12.java | 10 ++-- .../fightsystem/utils/ColorConverter_12.java | 2 +- .../fightsystem/utils/WaterRemover_12.java | 2 +- .../listener/BasicListener_14.java | 20 +++++++ .../fightsystem/fight/FightTeam_8.java | 2 - .../fightsystem/utils/ColorConverter_8.java | 11 ++++ .../fightsystem/utils/WaterRemover_8.java | 11 ++++ FightSystem_9/pom.xml | 53 +++++++++++++++++++ .../fightsystem/countdown/Countdown_9.java | 20 +++++++ .../fightsystem/fight/FightTeam_9.java | 26 +++++++++ .../fightsystem/listener/BasicListener_9.java | 24 +++++++++ .../fightsystem/utils/ColorConverter_9.java | 11 ++++ .../fightsystem/utils/TechHider_9.java | 15 ++++++ .../fightsystem/utils/WaterRemover_9.java | 11 ++++ FightSystem_Main/pom.xml | 2 +- .../fightsystem/countdown/Countdown.java | 8 ++- .../steamwar/fightsystem/fight/FightTeam.java | 40 ++++++++++---- .../fightsystem/listener/BasicListener.java | 45 ++++++++++++---- .../fightsystem/utils/ColorConverter.java | 9 ++++ .../steamwar/fightsystem/utils/TechHider.java | 18 +++++-- .../fightsystem/utils/WaterRemover.java | 6 +++ pom.xml | 2 + 32 files changed, 468 insertions(+), 58 deletions(-) create mode 100644 FightSystem_10/pom.xml create mode 100644 FightSystem_10/src/de/steamwar/fightsystem/countdown/Countdown_10.java create mode 100644 FightSystem_10/src/de/steamwar/fightsystem/fight/FightTeam_10.java create mode 100644 FightSystem_10/src/de/steamwar/fightsystem/listener/BasicListener_10.java create mode 100644 FightSystem_10/src/de/steamwar/fightsystem/utils/ColorConverter_10.java create mode 100644 FightSystem_10/src/de/steamwar/fightsystem/utils/TechHider_10.java create mode 100644 FightSystem_10/src/de/steamwar/fightsystem/utils/WaterRemover_10.java create mode 100644 FightSystem_14/src/de/steamwar/fightsystem/listener/BasicListener_14.java create mode 100644 FightSystem_8/src/de/steamwar/fightsystem/utils/ColorConverter_8.java create mode 100644 FightSystem_8/src/de/steamwar/fightsystem/utils/WaterRemover_8.java create mode 100644 FightSystem_9/pom.xml create mode 100644 FightSystem_9/src/de/steamwar/fightsystem/countdown/Countdown_9.java create mode 100644 FightSystem_9/src/de/steamwar/fightsystem/fight/FightTeam_9.java create mode 100644 FightSystem_9/src/de/steamwar/fightsystem/listener/BasicListener_9.java create mode 100644 FightSystem_9/src/de/steamwar/fightsystem/utils/ColorConverter_9.java create mode 100644 FightSystem_9/src/de/steamwar/fightsystem/utils/TechHider_9.java create mode 100644 FightSystem_9/src/de/steamwar/fightsystem/utils/WaterRemover_9.java diff --git a/FightSystem_10/pom.xml b/FightSystem_10/pom.xml new file mode 100644 index 0000000..237fc8c --- /dev/null +++ b/FightSystem_10/pom.xml @@ -0,0 +1,53 @@ + + + 4.0.0 + + + steamwar + FightSystem + 1.0 + + + FightSystem_10 + 1.0 + + + src + + + src + + **/*.java + **/*.kt + + + + + + + + steamwar + FightSystem_9 + 1.0 + + + steamwar + FightSystem_API + 1.0 + + + steamwar + WorldEdit + 1.0 + provided + + + steamwar + Spigot + 1.10 + provided + + + \ No newline at end of file diff --git a/FightSystem_10/src/de/steamwar/fightsystem/countdown/Countdown_10.java b/FightSystem_10/src/de/steamwar/fightsystem/countdown/Countdown_10.java new file mode 100644 index 0000000..8f1be57 --- /dev/null +++ b/FightSystem_10/src/de/steamwar/fightsystem/countdown/Countdown_10.java @@ -0,0 +1,11 @@ +package de.steamwar.fightsystem.countdown; + +import org.bukkit.Sound; + +class Countdown_10 { + private Countdown_10(){} + + static Sound getSound(SWSound sound){ + return Countdown_9.getSound(sound); + } +} diff --git a/FightSystem_10/src/de/steamwar/fightsystem/fight/FightTeam_10.java b/FightSystem_10/src/de/steamwar/fightsystem/fight/FightTeam_10.java new file mode 100644 index 0000000..d86fc97 --- /dev/null +++ b/FightSystem_10/src/de/steamwar/fightsystem/fight/FightTeam_10.java @@ -0,0 +1,26 @@ +package de.steamwar.fightsystem.fight; + +import com.sk89q.worldedit.EditSession; +import de.steamwar.sql.NoClipboardException; +import de.steamwar.sql.Schematic; +import org.bukkit.ChatColor; +import org.bukkit.DyeColor; +import org.bukkit.scoreboard.Team; + +import java.io.IOException; + +class FightTeam_10 { + private FightTeam_10(){} + + static void setTeamColor(Team team, ChatColor color) { + FightTeam_8.setTeamColor(team, color); + } + + static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){ + FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); + } + + static EditSession pasteSchematic(Schematic schematic, int pasteX, int pasteY, int pasteZ, boolean rotate) throws Schematic.WrongVersionException, IOException, NoClipboardException { + return FightTeam_8.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate); + } +} diff --git a/FightSystem_10/src/de/steamwar/fightsystem/listener/BasicListener_10.java b/FightSystem_10/src/de/steamwar/fightsystem/listener/BasicListener_10.java new file mode 100644 index 0000000..00e7c4a --- /dev/null +++ b/FightSystem_10/src/de/steamwar/fightsystem/listener/BasicListener_10.java @@ -0,0 +1,20 @@ +package de.steamwar.fightsystem.listener; + +import net.md_5.bungee.api.chat.BaseComponent; +import org.bukkit.entity.Player; + +class BasicListener_10 { + private BasicListener_10(){} + + static void toActionbar(Player player, BaseComponent... components){ + BasicListener_9.toActionbar(player, components); + } + + static void toChat(Player player, BaseComponent... components){ + BasicListener_9.toChat(player, components); + } + + static void setAttackSpeed(Player player){ + BasicListener_9.setAttackSpeed(player); + } +} diff --git a/FightSystem_10/src/de/steamwar/fightsystem/utils/ColorConverter_10.java b/FightSystem_10/src/de/steamwar/fightsystem/utils/ColorConverter_10.java new file mode 100644 index 0000000..0223581 --- /dev/null +++ b/FightSystem_10/src/de/steamwar/fightsystem/utils/ColorConverter_10.java @@ -0,0 +1,11 @@ +package de.steamwar.fightsystem.utils; + +import org.bukkit.DyeColor; + +class ColorConverter_10 { + private ColorConverter_10(){} + + static DyeColor getSilver(){ + return ColorConverter_8.getSilver(); + } +} diff --git a/FightSystem_10/src/de/steamwar/fightsystem/utils/TechHider_10.java b/FightSystem_10/src/de/steamwar/fightsystem/utils/TechHider_10.java new file mode 100644 index 0000000..9597762 --- /dev/null +++ b/FightSystem_10/src/de/steamwar/fightsystem/utils/TechHider_10.java @@ -0,0 +1,15 @@ +package de.steamwar.fightsystem.utils; + +import javafx.util.Pair; +import net.minecraft.server.v1_10_R1.PacketPlayOutMapChunk; +import org.bukkit.craftbukkit.v1_10_R1.CraftChunk; +import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer; +import org.bukkit.entity.Player; + +class TechHider_10 { + private TechHider_10(){} + + static void reloadChunk(Player p, Pair chunk){ + ((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.getKey(), chunk.getValue())).getHandle(), 65535)); + } +} diff --git a/FightSystem_10/src/de/steamwar/fightsystem/utils/WaterRemover_10.java b/FightSystem_10/src/de/steamwar/fightsystem/utils/WaterRemover_10.java new file mode 100644 index 0000000..fe3ddcc --- /dev/null +++ b/FightSystem_10/src/de/steamwar/fightsystem/utils/WaterRemover_10.java @@ -0,0 +1,11 @@ +package de.steamwar.fightsystem.utils; + +import org.bukkit.Material; + +class WaterRemover_10 { + private WaterRemover_10(){} + + static boolean isWater(Material type){ + return WaterRemover_8.isWater(type); + } +} diff --git a/FightSystem_12/pom.xml b/FightSystem_12/pom.xml index c4ab97a..337969e 100644 --- a/FightSystem_12/pom.xml +++ b/FightSystem_12/pom.xml @@ -29,7 +29,7 @@ steamwar - FightSystem_8 + FightSystem_10 1.0 @@ -37,12 +37,6 @@ FightSystem_API 1.0 - - steamwar - FAWE - 1.0 - provided - steamwar WorldEdit diff --git a/FightSystem_12/src/de/steamwar/fightsystem/countdown/Countdown_12.java b/FightSystem_12/src/de/steamwar/fightsystem/countdown/Countdown_12.java index a8c69bb..c9e0ec9 100644 --- a/FightSystem_12/src/de/steamwar/fightsystem/countdown/Countdown_12.java +++ b/FightSystem_12/src/de/steamwar/fightsystem/countdown/Countdown_12.java @@ -6,15 +6,6 @@ class Countdown_12 { private Countdown_12(){} static Sound getSound(SWSound sound){ - switch(sound){ - case ENTITY_WITHER_DEATH: - return Sound.ENTITY_WITHER_DEATH; - case BLOCK_NOTE_BASS: - return Sound.BLOCK_NOTE_BASS; - case BLOCK_NOTE_PLING: - return Sound.BLOCK_NOTE_PLING; - default: - return null; - } + return Countdown_9.getSound(sound); } } diff --git a/FightSystem_12/src/de/steamwar/fightsystem/fight/FightTeam_12.java b/FightSystem_12/src/de/steamwar/fightsystem/fight/FightTeam_12.java index 933e4fd..0e76487 100644 --- a/FightSystem_12/src/de/steamwar/fightsystem/fight/FightTeam_12.java +++ b/FightSystem_12/src/de/steamwar/fightsystem/fight/FightTeam_12.java @@ -1,6 +1,7 @@ package de.steamwar.fightsystem.fight; import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.regions.CuboidRegion; @@ -16,7 +17,7 @@ import java.io.IOException; import java.util.Collections; import java.util.Set; -public class FightTeam_12 { +class FightTeam_12 { private FightTeam_12(){} @SuppressWarnings("deprecation") @@ -32,7 +33,6 @@ public class FightTeam_12 { static void setTeamColor(Team team, ChatColor color){ team.setColor(color); - team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM); } @@ -41,8 +41,12 @@ public class FightTeam_12 { FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); Vector corner = new Vector(cornerX, cornerY, cornerZ); CuboidRegion region = new CuboidRegion(corner, corner.add(Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ)); - e.replaceBlocks(region, CONCRETE_SET, new BaseBlock(CONCRETE.getId(), c.getWoolData())); - e.replaceBlocks(region, CONCRETE_POWDER_SET, new BaseBlock(CONCRETE_POWDER.getId(), c.getWoolData())); + 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) { + //ignored + } } static EditSession pasteSchematic(Schematic schematic, int pasteX, int pasteY, int pasteZ, boolean rotate) throws Schematic.WrongVersionException, IOException, NoClipboardException { diff --git a/FightSystem_12/src/de/steamwar/fightsystem/listener/BasicListener_12.java b/FightSystem_12/src/de/steamwar/fightsystem/listener/BasicListener_12.java index 9dc603b..a6439f6 100644 --- a/FightSystem_12/src/de/steamwar/fightsystem/listener/BasicListener_12.java +++ b/FightSystem_12/src/de/steamwar/fightsystem/listener/BasicListener_12.java @@ -1,24 +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); + BasicListener_9.toActionbar(player, components); } static void toChat(Player player, BaseComponent... components){ - player.spigot().sendMessage(ChatMessageType.CHAT, components); + BasicListener_9.toChat(player, components); } static void setAttackSpeed(Player player){ - AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED); - attribute.setBaseValue(16); + BasicListener_9.setAttackSpeed(player); } } diff --git a/FightSystem_12/src/de/steamwar/fightsystem/utils/ColorConverter_12.java b/FightSystem_12/src/de/steamwar/fightsystem/utils/ColorConverter_12.java index d86d85d..e99e3fe 100644 --- a/FightSystem_12/src/de/steamwar/fightsystem/utils/ColorConverter_12.java +++ b/FightSystem_12/src/de/steamwar/fightsystem/utils/ColorConverter_12.java @@ -6,6 +6,6 @@ class ColorConverter_12 { private ColorConverter_12(){} static DyeColor getSilver(){ - return DyeColor.SILVER; + return ColorConverter_8.getSilver(); } } diff --git a/FightSystem_12/src/de/steamwar/fightsystem/utils/WaterRemover_12.java b/FightSystem_12/src/de/steamwar/fightsystem/utils/WaterRemover_12.java index 06bbd21..cefc2ba 100644 --- a/FightSystem_12/src/de/steamwar/fightsystem/utils/WaterRemover_12.java +++ b/FightSystem_12/src/de/steamwar/fightsystem/utils/WaterRemover_12.java @@ -6,6 +6,6 @@ class WaterRemover_12 { private WaterRemover_12(){} static boolean isWater(Material type){ - return type == Material.WATER || type == Material.STATIONARY_WATER; + return WaterRemover_8.isWater(type); } } diff --git a/FightSystem_14/src/de/steamwar/fightsystem/listener/BasicListener_14.java b/FightSystem_14/src/de/steamwar/fightsystem/listener/BasicListener_14.java new file mode 100644 index 0000000..4e49c6b --- /dev/null +++ b/FightSystem_14/src/de/steamwar/fightsystem/listener/BasicListener_14.java @@ -0,0 +1,20 @@ +package de.steamwar.fightsystem.listener; + +import net.md_5.bungee.api.chat.BaseComponent; +import org.bukkit.entity.Player; + +class BasicListener_14 { + private BasicListener_14(){} + + static void toActionbar(Player player, BaseComponent... components){ + BasicListener_9.toActionbar(player, components); + } + + static void toChat(Player player, BaseComponent... components){ + BasicListener_9.toChat(player, components); + } + + static void setAttackSpeed(Player player){ + BasicListener_9.setAttackSpeed(player); + } +} diff --git a/FightSystem_8/src/de/steamwar/fightsystem/fight/FightTeam_8.java b/FightSystem_8/src/de/steamwar/fightsystem/fight/FightTeam_8.java index 75ffff2..f1872c9 100644 --- a/FightSystem_8/src/de/steamwar/fightsystem/fight/FightTeam_8.java +++ b/FightSystem_8/src/de/steamwar/fightsystem/fight/FightTeam_8.java @@ -24,7 +24,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockPhysicsEvent; -import org.bukkit.scoreboard.NameTagVisibility; import org.bukkit.scoreboard.Team; import java.io.IOException; @@ -53,7 +52,6 @@ class FightTeam_8 { static void setTeamColor(Team team, ChatColor color){ team.setPrefix("ยง" + color.getChar()); - team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS); } @SuppressWarnings("deprecation") diff --git a/FightSystem_8/src/de/steamwar/fightsystem/utils/ColorConverter_8.java b/FightSystem_8/src/de/steamwar/fightsystem/utils/ColorConverter_8.java new file mode 100644 index 0000000..75fb01b --- /dev/null +++ b/FightSystem_8/src/de/steamwar/fightsystem/utils/ColorConverter_8.java @@ -0,0 +1,11 @@ +package de.steamwar.fightsystem.utils; + +import org.bukkit.DyeColor; + +class ColorConverter_8 { + private ColorConverter_8(){} + + static DyeColor getSilver(){ + return DyeColor.SILVER; + } +} diff --git a/FightSystem_8/src/de/steamwar/fightsystem/utils/WaterRemover_8.java b/FightSystem_8/src/de/steamwar/fightsystem/utils/WaterRemover_8.java new file mode 100644 index 0000000..e4d1c23 --- /dev/null +++ b/FightSystem_8/src/de/steamwar/fightsystem/utils/WaterRemover_8.java @@ -0,0 +1,11 @@ +package de.steamwar.fightsystem.utils; + +import org.bukkit.Material; + +public class WaterRemover_8 { + private WaterRemover_8(){} + + static boolean isWater(Material type){ + return type == Material.WATER || type == Material.STATIONARY_WATER; + } +} diff --git a/FightSystem_9/pom.xml b/FightSystem_9/pom.xml new file mode 100644 index 0000000..a17fad1 --- /dev/null +++ b/FightSystem_9/pom.xml @@ -0,0 +1,53 @@ + + + 4.0.0 + + + steamwar + FightSystem + 1.0 + + + FightSystem_9 + 1.0 + + + src + + + src + + **/*.java + **/*.kt + + + + + + + + steamwar + FightSystem_8 + 1.0 + + + steamwar + FightSystem_API + 1.0 + + + steamwar + WorldEdit + 1.0 + provided + + + steamwar + Spigot + 1.9 + provided + + + \ No newline at end of file diff --git a/FightSystem_9/src/de/steamwar/fightsystem/countdown/Countdown_9.java b/FightSystem_9/src/de/steamwar/fightsystem/countdown/Countdown_9.java new file mode 100644 index 0000000..ab2da8f --- /dev/null +++ b/FightSystem_9/src/de/steamwar/fightsystem/countdown/Countdown_9.java @@ -0,0 +1,20 @@ +package de.steamwar.fightsystem.countdown; + +import org.bukkit.Sound; + +class Countdown_9 { + private Countdown_9(){} + + static Sound getSound(SWSound sound){ + switch(sound){ + case ENTITY_WITHER_DEATH: + return Sound.ENTITY_WITHER_DEATH; + case BLOCK_NOTE_BASS: + return Sound.BLOCK_NOTE_BASS; + case BLOCK_NOTE_PLING: + return Sound.BLOCK_NOTE_PLING; + default: + return null; + } + } +} diff --git a/FightSystem_9/src/de/steamwar/fightsystem/fight/FightTeam_9.java b/FightSystem_9/src/de/steamwar/fightsystem/fight/FightTeam_9.java new file mode 100644 index 0000000..1d38af3 --- /dev/null +++ b/FightSystem_9/src/de/steamwar/fightsystem/fight/FightTeam_9.java @@ -0,0 +1,26 @@ +package de.steamwar.fightsystem.fight; + +import com.sk89q.worldedit.EditSession; +import de.steamwar.sql.NoClipboardException; +import de.steamwar.sql.Schematic; +import org.bukkit.ChatColor; +import org.bukkit.DyeColor; +import org.bukkit.scoreboard.Team; + +import java.io.IOException; + +class FightTeam_9 { + private FightTeam_9(){} + + static void setTeamColor(Team team, ChatColor color){ + FightTeam_8.setTeamColor(team, color); + } + + static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){ + FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); + } + + static EditSession pasteSchematic(Schematic schematic, int pasteX, int pasteY, int pasteZ, boolean rotate) throws Schematic.WrongVersionException, IOException, NoClipboardException { + return FightTeam_8.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate); + } +} diff --git a/FightSystem_9/src/de/steamwar/fightsystem/listener/BasicListener_9.java b/FightSystem_9/src/de/steamwar/fightsystem/listener/BasicListener_9.java new file mode 100644 index 0000000..574724b --- /dev/null +++ b/FightSystem_9/src/de/steamwar/fightsystem/listener/BasicListener_9.java @@ -0,0 +1,24 @@ +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_9 { + private BasicListener_9(){} + + static void toActionbar(Player player, BaseComponent... components){ + player.spigot().sendMessage(ChatMessageType.ACTION_BAR, components); + } + + static void toChat(Player player, BaseComponent... components){ + player.spigot().sendMessage(ChatMessageType.CHAT, components); + } + + static void setAttackSpeed(Player player){ + AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED); + attribute.setBaseValue(16); + } +} diff --git a/FightSystem_9/src/de/steamwar/fightsystem/utils/ColorConverter_9.java b/FightSystem_9/src/de/steamwar/fightsystem/utils/ColorConverter_9.java new file mode 100644 index 0000000..d04b2e3 --- /dev/null +++ b/FightSystem_9/src/de/steamwar/fightsystem/utils/ColorConverter_9.java @@ -0,0 +1,11 @@ +package de.steamwar.fightsystem.utils; + +import org.bukkit.DyeColor; + +class ColorConverter_9 { + private ColorConverter_9(){} + + static DyeColor getSilver(){ + return ColorConverter_8.getSilver(); + } +} diff --git a/FightSystem_9/src/de/steamwar/fightsystem/utils/TechHider_9.java b/FightSystem_9/src/de/steamwar/fightsystem/utils/TechHider_9.java new file mode 100644 index 0000000..9ce621e --- /dev/null +++ b/FightSystem_9/src/de/steamwar/fightsystem/utils/TechHider_9.java @@ -0,0 +1,15 @@ +package de.steamwar.fightsystem.utils; + +import javafx.util.Pair; +import net.minecraft.server.v1_9_R2.PacketPlayOutMapChunk; +import org.bukkit.craftbukkit.v1_9_R2.CraftChunk; +import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer; +import org.bukkit.entity.Player; + +class TechHider_9 { + private TechHider_9(){} + + static void reloadChunk(Player p, Pair chunk){ + ((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.getKey(), chunk.getValue())).getHandle(), 65535)); + } +} diff --git a/FightSystem_9/src/de/steamwar/fightsystem/utils/WaterRemover_9.java b/FightSystem_9/src/de/steamwar/fightsystem/utils/WaterRemover_9.java new file mode 100644 index 0000000..3243269 --- /dev/null +++ b/FightSystem_9/src/de/steamwar/fightsystem/utils/WaterRemover_9.java @@ -0,0 +1,11 @@ +package de.steamwar.fightsystem.utils; + +import org.bukkit.Material; + +class WaterRemover_9 { + private WaterRemover_9(){} + + static boolean isWater(Material type){ + return WaterRemover_8.isWater(type); + } +} diff --git a/FightSystem_Main/pom.xml b/FightSystem_Main/pom.xml index 0b8092b..5143bd0 100644 --- a/FightSystem_Main/pom.xml +++ b/FightSystem_Main/pom.xml @@ -46,7 +46,7 @@ steamwar Spigot - 1.14 + 1.15 provided diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java index d501ba2..aeec8cc 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java @@ -41,10 +41,14 @@ public abstract class Countdown { return null; switch (Core.getVersion()){ - case 8: - return Countdown_8.getSound(sound); case 14: return Countdown_14.getSound(sound); + case 10: + return Countdown_10.getSound(sound); + case 9: + return Countdown_9.getSound(sound); + case 8: + return Countdown_8.getSound(sound); default: return Countdown_12.getSound(sound); } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java index 4c3d00a..e20b9bf 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -18,6 +18,7 @@ import org.bukkit.block.Block; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; +import org.bukkit.scoreboard.NameTagVisibility; import org.bukkit.scoreboard.Team; import java.io.IOException; @@ -69,18 +70,27 @@ public class FightTeam implements IFightTeam{ team = FightScoreboard.getScoreboard().registerNewTeam(name); else team = FightScoreboard.getScoreboard().getTeam(name); + assert team != null; setTeamColor(team, color); + //noinspection deprecation + team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS); team.setAllowFriendlyFire(false); } private void setTeamColor(Team team, ChatColor color){ switch(Core.getVersion()){ - case 8: - FightTeam_8.setTeamColor(team, color); - break; case 14: FightTeam_14.setTeamColor(team, color); break; + case 10: + FightTeam_10.setTeamColor(team, color); + break; + case 9: + FightTeam_9.setTeamColor(team, color); + break; + case 8: + FightTeam_8.setTeamColor(team, color); + break; default: FightTeam_12.setTeamColor(team, color); } @@ -232,12 +242,18 @@ public class FightTeam implements IFightTeam{ EditSession e; try { switch(Core.getVersion()){ - case 8: - e = FightTeam_8.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate); - break; case 14: e = FightTeam_14.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate); break; + case 10: + e = FightTeam_10.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate); + break; + case 9: + e = FightTeam_9.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate); + break; + case 8: + e = FightTeam_8.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate); + break; default: e = FightTeam_12.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate); } @@ -256,12 +272,18 @@ public class FightTeam implements IFightTeam{ DyeColor c = ColorConverter.chat2dye(color); switch(Core.getVersion()){ - case 8: - FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); - break; case 14: FightTeam_14.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); break; + case 10: + FightTeam_10.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); + break; + case 9: + FightTeam_9.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); + break; + case 8: + FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); + break; default: FightTeam_12.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/BasicListener.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/BasicListener.java index 163b7f0..1a5a629 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/BasicListener.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/BasicListener.java @@ -47,6 +47,15 @@ public abstract class BasicListener implements Listener { public static void toActionbar(Player player, BaseComponent... components){ switch(Core.getVersion()){ + case 14: + BasicListener_14.toActionbar(player, components); + break; + case 10: + BasicListener_10.toActionbar(player, components); + break; + case 9: + BasicListener_9.toActionbar(player, components); + break; case 8: BasicListener_8.toActionbar(player, components); break; @@ -55,17 +64,17 @@ public abstract class BasicListener implements Listener { } } - void setAttackSpeed(Player player){ - switch(Core.getVersion()){ - case 8: - break; - default: - BasicListener_12.setAttackSpeed(player); - } - } - public static void toChat(Player player, BaseComponent... components){ switch(Core.getVersion()){ + case 14: + BasicListener_14.toChat(player, components); + break; + case 10: + BasicListener_10.toChat(player, components); + break; + case 9: + BasicListener_9.toChat(player, components); + break; case 8: BasicListener_8.toChat(player, components); break; @@ -73,4 +82,22 @@ public abstract class BasicListener implements Listener { BasicListener_12.toChat(player, components); } } + + void setAttackSpeed(Player player){ + switch(Core.getVersion()){ + case 14: + BasicListener_14.setAttackSpeed(player); + break; + case 10: + BasicListener_10.setAttackSpeed(player); + break; + case 9: + BasicListener_9.setAttackSpeed(player); + break; + case 8: + break; + default: + BasicListener_12.setAttackSpeed(player); + } + } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/ColorConverter.java b/FightSystem_Main/src/de/steamwar/fightsystem/utils/ColorConverter.java index 890e751..6e19655 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/utils/ColorConverter.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/utils/ColorConverter.java @@ -34,6 +34,15 @@ public class ColorConverter { case 14: chat2dye.put(ChatColor.GRAY, ColorConverter_14.getSilver()); break; + case 10: + chat2dye.put(ChatColor.GRAY, ColorConverter_10.getSilver()); + break; + case 9: + chat2dye.put(ChatColor.GRAY, ColorConverter_9.getSilver()); + break; + case 8: + chat2dye.put(ChatColor.GRAY, ColorConverter_8.getSilver()); + break; default: chat2dye.put(ChatColor.GRAY, ColorConverter_12.getSilver()); } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java b/FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java index 32ae288..c506929 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java @@ -68,11 +68,13 @@ public class TechHider { blockHider(); multiBlockHider(); switch(Core.getVersion()){ - case 8: - break; case 14: TechHider_14.start(); break; + case 10: + case 9: + case 8: + break; default: TechHider_12.start(); } @@ -189,12 +191,18 @@ public class TechHider { private static void reloadChunk(Player p, Pair chunk){ switch(Core.getVersion()){ - case 8: - TechHider_8.reloadChunk(p, chunk); - break; case 14: TechHider_14.reloadChunk(p, chunk); break; + case 10: + TechHider_10.reloadChunk(p, chunk); + break; + case 9: + TechHider_9.reloadChunk(p, chunk); + break; + case 8: + TechHider_8.reloadChunk(p, chunk); + break; default: TechHider_12.reloadChunk(p, chunk); } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/WaterRemover.java b/FightSystem_Main/src/de/steamwar/fightsystem/utils/WaterRemover.java index 6f20077..9976036 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/utils/WaterRemover.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/utils/WaterRemover.java @@ -96,6 +96,12 @@ public class WaterRemover { switch(Core.getVersion()){ case 14: return WaterRemover_14.isWater(type); + case 10: + return WaterRemover_10.isWater(type); + case 9: + return WaterRemover_9.isWater(type); + case 8: + return WaterRemover_8.isWater(type); default: return WaterRemover_12.isWater(type); } diff --git a/pom.xml b/pom.xml index 2046376..8e2deb5 100644 --- a/pom.xml +++ b/pom.xml @@ -38,6 +38,8 @@ FightSystem_API FightSystem_8 + FightSystem_9 + FightSystem_10 FightSystem_12 FightSystem_14 FightSystem_Main From 27808e35e0bcace964907e0cd7986eef578f4cef Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 27 Dec 2019 11:06:09 +0100 Subject: [PATCH 3/4] Refactoring 1.14 support to vanilla WorldEdit compatibility Signed-off-by: Lixfel --- FightSystem_14/pom.xml | 11 ++++-- .../fightsystem/fight/FightTeam_14.java | 39 +++++++++++-------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/FightSystem_14/pom.xml b/FightSystem_14/pom.xml index f6d65f0..d29cb36 100644 --- a/FightSystem_14/pom.xml +++ b/FightSystem_14/pom.xml @@ -33,6 +33,12 @@ 1.14 provided + + steamwar + WorldEdit + 1.15 + provided + steamwar FightSystem_API @@ -40,9 +46,8 @@ steamwar - FAWE - 1.14 - provided + FightSystem_12 + 1.0 \ No newline at end of file diff --git a/FightSystem_14/src/de/steamwar/fightsystem/fight/FightTeam_14.java b/FightSystem_14/src/de/steamwar/fightsystem/fight/FightTeam_14.java index d5c18ee..a5eef37 100644 --- a/FightSystem_14/src/de/steamwar/fightsystem/fight/FightTeam_14.java +++ b/FightSystem_14/src/de/steamwar/fightsystem/fight/FightTeam_14.java @@ -1,6 +1,7 @@ package de.steamwar.fightsystem.fight; import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.bukkit.BukkitWorld; import com.sk89q.worldedit.extent.clipboard.Clipboard; @@ -11,7 +12,7 @@ import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.world.block.BlockState; +import com.sk89q.worldedit.world.block.BlockTypes; import de.steamwar.fightsystem.Config; import de.steamwar.sql.NoClipboardException; import de.steamwar.sql.Schematic; @@ -22,33 +23,37 @@ import org.bukkit.scoreboard.Team; import java.io.IOException; import java.util.Collections; +import java.util.Objects; import java.util.Set; class FightTeam_14 { private FightTeam_14(){} - private static final Set WOOL_SET = Collections.singleton(new BaseBlock(BlockState.get("pink_wool"))); - private static final Set CLAY_SET = Collections.singleton(new BaseBlock(BlockState.get("pink_terracotta"))); - private static final Set GLASS_SET = Collections.singleton(new BaseBlock(BlockState.get("pink_stained_glass"))); - private static final Set GLASS_PANE_SET = Collections.singleton(new BaseBlock(BlockState.get("pink_stained_glass_pane"))); - private static final Set CONCRETE_SET = Collections.singleton(new BaseBlock(BlockState.get("pink_concrete"))); - private static final Set CONCRETE_POWDER_SET = Collections.singleton(new BaseBlock(BlockState.get("pink_concrete_powder"))); + private static final Set WOOL_SET = Collections.singleton(Objects.requireNonNull(BlockTypes.PINK_WOOL).getDefaultState().toBaseBlock()); + private static final Set CLAY_SET = Collections.singleton(Objects.requireNonNull(BlockTypes.PINK_TERRACOTTA).getDefaultState().toBaseBlock()); + private static final Set GLASS_SET = Collections.singleton(Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS).getDefaultState().toBaseBlock()); + private static final Set GLASS_PANE_SET = Collections.singleton(Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS_PANE).getDefaultState().toBaseBlock()); + private static final Set CONCRETE_SET = Collections.singleton(Objects.requireNonNull(BlockTypes.PINK_CONCRETE).getDefaultState().toBaseBlock()); + private static final Set CONCRETE_POWDER_SET = Collections.singleton(Objects.requireNonNull(BlockTypes.PINK_CONCRETE_POWDER).getDefaultState().toBaseBlock()); static void setTeamColor(Team team, ChatColor color){ - team.setColor(color); - team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM); + FightTeam_10.setTeamColor(team, color); } static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){ BlockVector3 corner3 = BlockVector3.at(cornerX, cornerY, cornerZ); BlockVector3 schemsize3 = BlockVector3.at(Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ); CuboidRegion region = new CuboidRegion(corner3, corner3.add(schemsize3)); - e.replaceBlocks(region, WOOL_SET, new BaseBlock(BlockState.get(c.name().toLowerCase() + "_wool"))); - e.replaceBlocks(region, CLAY_SET, new BaseBlock(BlockState.get(c.name().toLowerCase() + "_terracotta"))); - e.replaceBlocks(region, GLASS_SET, new BaseBlock(BlockState.get(c.name().toLowerCase() + "_stained_glass"))); - e.replaceBlocks(region, GLASS_PANE_SET, new BaseBlock(BlockState.get(c.name().toLowerCase() + "_stained_glass_pane"))); - e.replaceBlocks(region, CONCRETE_SET, new BaseBlock(BlockState.get(c.name().toLowerCase() + "_concrete"))); - e.replaceBlocks(region, CONCRETE_POWDER_SET, new BaseBlock(BlockState.get(c.name().toLowerCase() + "_concrete_powder"))); + try { + e.replaceBlocks(region, WOOL_SET, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_wool")).getDefaultState().toBaseBlock()); + e.replaceBlocks(region, CLAY_SET, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_terracotta")).getDefaultState().toBaseBlock()); + e.replaceBlocks(region, GLASS_SET, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_stained_glass")).getDefaultState().toBaseBlock()); + e.replaceBlocks(region, GLASS_PANE_SET, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_stained_glass_pane")).getDefaultState().toBaseBlock()); + e.replaceBlocks(region, CONCRETE_SET, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_concrete")).getDefaultState().toBaseBlock()); + e.replaceBlocks(region, CONCRETE_POWDER_SET, Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_concrete_powder")).getDefaultState().toBaseBlock()); + } catch (MaxChangedBlocksException ex) { + //ignored + } } static EditSession pasteSchematic(Schematic schematic, int pX, int pY, int pZ, boolean rotate) throws Schematic.WrongVersionException, IOException, NoClipboardException { @@ -70,7 +75,7 @@ class FightTeam_14 { if(Config.AlignWater){ BlockVector3 it = clipboard.getMinimumPoint(); int depth = 0; - while(!clipboard.getBlock(it).getMaterial().isAir()){ + while(!clipboard.getBlock(it).getBlockType().getMaterial().isAir()){ depth++; it = it.add(0, 1, 0); } @@ -81,7 +86,7 @@ class FightTeam_14 { ClipboardHolder ch = new ClipboardHolder(clipboard); ch.setTransform(aT); Operations.completeBlindly(ch.createPaste(e).to(v).build()); - e.flushQueue(); + e.flushSession(); return e; } } From 00f22fe513d766ce3869692a4431b224b5f08723 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 27 Dec 2019 12:02:27 +0100 Subject: [PATCH 4/4] Adding 1.15 support Signed-off-by: Lixfel --- .../fightsystem/utils/TechHider_14.java | 2 +- FightSystem_15/pom.xml | 53 +++++++++++++++++++ .../fightsystem/countdown/Countdown_15.java | 11 ++++ .../fightsystem/fight/FightTeam_15.java | 26 +++++++++ .../listener/BasicListener_15.java | 20 +++++++ .../fightsystem/utils/ColorConverter_15.java | 11 ++++ .../fightsystem/utils/TechHider_15.java | 20 +++++++ .../fightsystem/utils/WaterRemover_15.java | 11 ++++ FightSystem_Main/pom.xml | 18 +++++++ .../fightsystem/countdown/Countdown.java | 2 + .../steamwar/fightsystem/fight/FightTeam.java | 9 ++++ .../fightsystem/listener/BasicListener.java | 9 ++++ .../fightsystem/utils/ColorConverter.java | 3 ++ .../steamwar/fightsystem/utils/TechHider.java | 6 +++ .../fightsystem/utils/WaterRemover.java | 2 + pom.xml | 1 + 16 files changed, 203 insertions(+), 1 deletion(-) create mode 100644 FightSystem_15/pom.xml create mode 100644 FightSystem_15/src/de/steamwar/fightsystem/countdown/Countdown_15.java create mode 100644 FightSystem_15/src/de/steamwar/fightsystem/fight/FightTeam_15.java create mode 100644 FightSystem_15/src/de/steamwar/fightsystem/listener/BasicListener_15.java create mode 100644 FightSystem_15/src/de/steamwar/fightsystem/utils/ColorConverter_15.java create mode 100644 FightSystem_15/src/de/steamwar/fightsystem/utils/TechHider_15.java create mode 100644 FightSystem_15/src/de/steamwar/fightsystem/utils/WaterRemover_15.java diff --git a/FightSystem_14/src/de/steamwar/fightsystem/utils/TechHider_14.java b/FightSystem_14/src/de/steamwar/fightsystem/utils/TechHider_14.java index 1b03adb..66cd3ff 100644 --- a/FightSystem_14/src/de/steamwar/fightsystem/utils/TechHider_14.java +++ b/FightSystem_14/src/de/steamwar/fightsystem/utils/TechHider_14.java @@ -33,7 +33,7 @@ public class TechHider_14 { chunkHider(); } - private static void chunkHider(){ + static void chunkHider(){ ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) { @Override public void onPacketSending(PacketEvent e) { diff --git a/FightSystem_15/pom.xml b/FightSystem_15/pom.xml new file mode 100644 index 0000000..b41ee8b --- /dev/null +++ b/FightSystem_15/pom.xml @@ -0,0 +1,53 @@ + + + 4.0.0 + + + steamwar + FightSystem + 1.0 + + + FightSystem_15 + 1.0 + + + src + + + src + + **/*.java + **/*.kt + + + + + + + + steamwar + Spigot + 1.15 + provided + + + steamwar + WorldEdit + 1.15 + provided + + + steamwar + FightSystem_API + 1.0 + + + steamwar + FightSystem_14 + 1.0 + + + \ No newline at end of file diff --git a/FightSystem_15/src/de/steamwar/fightsystem/countdown/Countdown_15.java b/FightSystem_15/src/de/steamwar/fightsystem/countdown/Countdown_15.java new file mode 100644 index 0000000..b644296 --- /dev/null +++ b/FightSystem_15/src/de/steamwar/fightsystem/countdown/Countdown_15.java @@ -0,0 +1,11 @@ +package de.steamwar.fightsystem.countdown; + +import org.bukkit.Sound; + +class Countdown_15 { + private Countdown_15(){} + + static Sound getSound(SWSound sound){ + return Countdown_14.getSound(sound); + } +} diff --git a/FightSystem_15/src/de/steamwar/fightsystem/fight/FightTeam_15.java b/FightSystem_15/src/de/steamwar/fightsystem/fight/FightTeam_15.java new file mode 100644 index 0000000..71eabc6 --- /dev/null +++ b/FightSystem_15/src/de/steamwar/fightsystem/fight/FightTeam_15.java @@ -0,0 +1,26 @@ +package de.steamwar.fightsystem.fight; + +import com.sk89q.worldedit.EditSession; +import de.steamwar.sql.NoClipboardException; +import de.steamwar.sql.Schematic; +import org.bukkit.ChatColor; +import org.bukkit.DyeColor; +import org.bukkit.scoreboard.Team; + +import java.io.IOException; + +class FightTeam_15 { + private FightTeam_15(){} + + static void setTeamColor(Team team, ChatColor color){ + FightTeam_10.setTeamColor(team, color); + } + + static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){ + FightTeam_14.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); + } + + static EditSession pasteSchematic(Schematic schematic, int pX, int pY, int pZ, boolean rotate) throws Schematic.WrongVersionException, IOException, NoClipboardException { + return FightTeam_14.pasteSchematic(schematic, pX, pY, pZ, rotate); + } +} diff --git a/FightSystem_15/src/de/steamwar/fightsystem/listener/BasicListener_15.java b/FightSystem_15/src/de/steamwar/fightsystem/listener/BasicListener_15.java new file mode 100644 index 0000000..1e5f1af --- /dev/null +++ b/FightSystem_15/src/de/steamwar/fightsystem/listener/BasicListener_15.java @@ -0,0 +1,20 @@ +package de.steamwar.fightsystem.listener; + +import net.md_5.bungee.api.chat.BaseComponent; +import org.bukkit.entity.Player; + +class BasicListener_15 { + private BasicListener_15(){} + + static void toActionbar(Player player, BaseComponent... components){ + BasicListener_9.toActionbar(player, components); + } + + static void toChat(Player player, BaseComponent... components){ + BasicListener_9.toChat(player, components); + } + + static void setAttackSpeed(Player player){ + BasicListener_9.setAttackSpeed(player); + } +} diff --git a/FightSystem_15/src/de/steamwar/fightsystem/utils/ColorConverter_15.java b/FightSystem_15/src/de/steamwar/fightsystem/utils/ColorConverter_15.java new file mode 100644 index 0000000..c4b030f --- /dev/null +++ b/FightSystem_15/src/de/steamwar/fightsystem/utils/ColorConverter_15.java @@ -0,0 +1,11 @@ +package de.steamwar.fightsystem.utils; + +import org.bukkit.DyeColor; + +class ColorConverter_15 { + private ColorConverter_15(){} + + static DyeColor getSilver(){ + return ColorConverter_14.getSilver(); + } +} diff --git a/FightSystem_15/src/de/steamwar/fightsystem/utils/TechHider_15.java b/FightSystem_15/src/de/steamwar/fightsystem/utils/TechHider_15.java new file mode 100644 index 0000000..5e306ca --- /dev/null +++ b/FightSystem_15/src/de/steamwar/fightsystem/utils/TechHider_15.java @@ -0,0 +1,20 @@ +package de.steamwar.fightsystem.utils; + +import javafx.util.Pair; +import net.minecraft.server.v1_15_R1.PacketPlayOutMapChunk; +import org.bukkit.craftbukkit.v1_15_R1.CraftChunk; +import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; +import org.bukkit.entity.Player; + +public class TechHider_15 { + private TechHider_15(){} + + static void reloadChunk(Player p, Pair chunk){ + ((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.getKey(), chunk.getValue())).getHandle(), 65535)); + } + + static void start(){ + TechHider_14.chunkHider(); + } + +} diff --git a/FightSystem_15/src/de/steamwar/fightsystem/utils/WaterRemover_15.java b/FightSystem_15/src/de/steamwar/fightsystem/utils/WaterRemover_15.java new file mode 100644 index 0000000..73bf6e6 --- /dev/null +++ b/FightSystem_15/src/de/steamwar/fightsystem/utils/WaterRemover_15.java @@ -0,0 +1,11 @@ +package de.steamwar.fightsystem.utils; + +import org.bukkit.Material; + +class WaterRemover_15 { + private WaterRemover_15(){} + + static boolean isWater(Material type){ + return WaterRemover_14.isWater(type); + } +} diff --git a/FightSystem_Main/pom.xml b/FightSystem_Main/pom.xml index 5143bd0..24b9bc4 100644 --- a/FightSystem_Main/pom.xml +++ b/FightSystem_Main/pom.xml @@ -55,6 +55,18 @@ 1.0 compile + + steamwar + FightSystem_9 + 1.0 + compile + + + steamwar + FightSystem_10 + 1.0 + compile + steamwar FightSystem_12 @@ -67,6 +79,12 @@ 1.0 compile + + steamwar + FightSystem_15 + 1.0 + compile + steamwar FightSystem_API diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java index aeec8cc..fe05212 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java @@ -41,6 +41,8 @@ public abstract class Countdown { return null; switch (Core.getVersion()){ + case 15: + return Countdown_15.getSound(sound); case 14: return Countdown_14.getSound(sound); case 10: diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java index e20b9bf..e69ed25 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -79,6 +79,9 @@ public class FightTeam implements IFightTeam{ private void setTeamColor(Team team, ChatColor color){ switch(Core.getVersion()){ + case 15: + FightTeam_15.setTeamColor(team, color); + break; case 14: FightTeam_14.setTeamColor(team, color); break; @@ -242,6 +245,9 @@ public class FightTeam implements IFightTeam{ EditSession e; try { switch(Core.getVersion()){ + case 15: + e = FightTeam_15.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate); + break; case 14: e = FightTeam_14.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate); break; @@ -272,6 +278,9 @@ public class FightTeam implements IFightTeam{ DyeColor c = ColorConverter.chat2dye(color); switch(Core.getVersion()){ + case 15: + FightTeam_15.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); + break; case 14: FightTeam_14.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); break; diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/BasicListener.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/BasicListener.java index 1a5a629..e78d504 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/BasicListener.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/BasicListener.java @@ -47,6 +47,9 @@ public abstract class BasicListener implements Listener { public static void toActionbar(Player player, BaseComponent... components){ switch(Core.getVersion()){ + case 15: + BasicListener_15.toActionbar(player, components); + break; case 14: BasicListener_14.toActionbar(player, components); break; @@ -66,6 +69,9 @@ public abstract class BasicListener implements Listener { public static void toChat(Player player, BaseComponent... components){ switch(Core.getVersion()){ + case 15: + BasicListener_15.toChat(player, components); + break; case 14: BasicListener_14.toChat(player, components); break; @@ -85,6 +91,9 @@ public abstract class BasicListener implements Listener { void setAttackSpeed(Player player){ switch(Core.getVersion()){ + case 15: + BasicListener_15.setAttackSpeed(player); + break; case 14: BasicListener_14.setAttackSpeed(player); break; diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/ColorConverter.java b/FightSystem_Main/src/de/steamwar/fightsystem/utils/ColorConverter.java index 6e19655..fac5478 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/utils/ColorConverter.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/utils/ColorConverter.java @@ -31,6 +31,9 @@ public class ColorConverter { //Rosa 9pink, Braun 3brown switch(Core.getVersion()){ + case 15: + chat2dye.put(ChatColor.GRAY, ColorConverter_15.getSilver()); + break; case 14: chat2dye.put(ChatColor.GRAY, ColorConverter_14.getSilver()); break; diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java b/FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java index c506929..b2ed032 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java @@ -68,6 +68,9 @@ public class TechHider { blockHider(); multiBlockHider(); switch(Core.getVersion()){ + case 15: + TechHider_15.start(); + break; case 14: TechHider_14.start(); break; @@ -191,6 +194,9 @@ public class TechHider { private static void reloadChunk(Player p, Pair chunk){ switch(Core.getVersion()){ + case 15: + TechHider_15.reloadChunk(p, chunk); + break; case 14: TechHider_14.reloadChunk(p, chunk); break; diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/WaterRemover.java b/FightSystem_Main/src/de/steamwar/fightsystem/utils/WaterRemover.java index 9976036..08eeeda 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/utils/WaterRemover.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/utils/WaterRemover.java @@ -94,6 +94,8 @@ public class WaterRemover { public static boolean isWater(Material type){ switch(Core.getVersion()){ + case 15: + return WaterRemover_15.isWater(type); case 14: return WaterRemover_14.isWater(type); case 10: diff --git a/pom.xml b/pom.xml index 8e2deb5..c7527e1 100644 --- a/pom.xml +++ b/pom.xml @@ -42,6 +42,7 @@ FightSystem_10 FightSystem_12 FightSystem_14 + FightSystem_15 FightSystem_Main