diff --git a/pom.xml b/pom.xml
index c88f92d..edf402c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -33,14 +33,6 @@
mongodb-driver-sync
4.11.1
-
-
- com.sk89q.worldedit
- worldedit-core
- 6.0.0-SNAPSHOT
- system
- ${project.basedir}/libs/WorldEdit.jar
-
org.github.paperspigot
paperspigot-api
@@ -48,7 +40,13 @@
system
${project.basedir}/libs/PaperSpigot-1.8.8-R0.1-SNAPSHOT.jar
-
+
+ com.sk89q.worldedit
+ worldedit-core
+ 6.0.0-SNAPSHOT
+ system
+ ${project.basedir}/libs/WorldEdit.jar
+
com.boydti
fawe-api
@@ -62,13 +60,11 @@
3.0.2
compile
-
co.aikar
acf-paper
0.5.1-SNAPSHOT
-
me.clip
placeholderapi
diff --git a/src/main/java/me/lrxh/practice/Locale.java b/src/main/java/me/lrxh/practice/Locale.java
index 2894238..0bbd8c2 100644
--- a/src/main/java/me/lrxh/practice/Locale.java
+++ b/src/main/java/me/lrxh/practice/Locale.java
@@ -48,7 +48,10 @@ public enum Locale {
MATCH_NO_LONGER_SPECTATING("MATCH.NO_LONGER_SPECTATING"),
MATCH_PLAYING_ARENA("MATCH.PLAYING_ARENA"),
MATCH_START("MATCH.START"),
+ MATCH_BED_BROKEN("MATCH.BED_BROKEN"),
MATCH_START_TIMER("MATCH.START_TIMER"),
+ MATCH_RESPAWN_TIMER("MATCH.RESPAWN_TIMER"),
+ MATCH_RESPAWNED("MATCH.RESPAWNED"),
MATCH_STARTED("MATCH.STARTED"),
MATCH_WARNING("MATCH.WARNING"),
MATCH_END_DETAILS("MATCH.END_DETAILS"),
@@ -58,6 +61,7 @@ public enum Locale {
MATCH_CLICK_TO_VIEW_HOVER("MATCH.CLICK_TO_VIEW_HOVER"),
MATCH_ELO_CHANGES("MATCH.ELO_CHANGES"),
MATCH_PLAYER_KILLED("MATCH.PLAYER_KILLED"),
+ MATCH_PLAYER_FINAL_KILL("MATCH.PLAYER_FINAL_KILL"),
MATCH_PLAYER_DIED("MATCH.PLAYER_DIED"),
REMATCH_SENT_REQUEST("REMATCH.SENT_REQUEST"),
REMATCH_RECEIVED_REQUEST("REMATCH.RECEIVED_REQUEST"),
diff --git a/src/main/java/me/lrxh/practice/Practice.java b/src/main/java/me/lrxh/practice/Practice.java
index fefd86a..54e7419 100644
--- a/src/main/java/me/lrxh/practice/Practice.java
+++ b/src/main/java/me/lrxh/practice/Practice.java
@@ -126,7 +126,6 @@ public void onEnable() {
new LeaderboardThread().start();
new Metrics(this, 20915);
-
Arrays.asList(
new KitEditorListener(),
new PartyListener(),
@@ -152,6 +151,11 @@ public void onEnable() {
world.setDifficulty(Difficulty.HARD);
clearEntities(world);
});
+
+ for (World world : getInstance().getServer().getWorlds()) {
+ world.setGameRuleValue("doDaylightCycle", "false");
+ }
+
Plugin placeholderAPI = getServer().getPluginManager().getPlugin("PlaceholderAPI");
if (placeholderAPI != null && placeholderAPI.isEnabled()) {
new Placeholder().register();
diff --git a/src/main/java/me/lrxh/practice/arena/Arena.java b/src/main/java/me/lrxh/practice/arena/Arena.java
index c2b1c92..546f75f 100644
--- a/src/main/java/me/lrxh/practice/arena/Arena.java
+++ b/src/main/java/me/lrxh/practice/arena/Arena.java
@@ -30,8 +30,6 @@ public class Arena extends Cuboid {
protected Location spawnA;
protected Location spawnB;
protected boolean active;
- protected Location bedA;
- protected Location bedB;
private List kits = new ArrayList<>();
private Map chunkSnapshots = new HashMap<>();
@@ -70,13 +68,6 @@ public static void init() {
arena.setSpawnB(LocationUtil.deserialize(configuration.getString(path + ".spawnB")));
}
- if (configuration.contains(path + ".bedA")) {
- arena.setBedA(LocationUtil.deserialize(configuration.getString(path + ".bedA")));
- }
-
- if (configuration.contains(path + ".bedB")) {
- arena.setBedB(LocationUtil.deserialize(configuration.getString(path + ".bedB")));
- }
String displayName = configuration.getString(path + ".displayName");
arena.setDisplayName(displayName);
@@ -98,13 +89,6 @@ public static void init() {
duplicate.setSpawnA(spawn1);
duplicate.setSpawnB(spawn2);
- if (configuration.contains(path + ".bedA")) {
- arena.setBedA(LocationUtil.deserialize(configuration.getString(path + ".bedA")));
- }
-
- if (configuration.contains(path + ".bedB")) {
- arena.setBedB(LocationUtil.deserialize(configuration.getString(path + ".bedB")));
- }
duplicate.setKits(arena.getKits());
((StandaloneArena) arena).getDuplicates().add(duplicate);
@@ -207,6 +191,11 @@ public int getMaxBuildHeight() {
return highest + 5;
}
+ public int getDeathZone() {
+ int lowest = (int) (Math.min(spawnA.getY(), spawnB.getY()));
+ return lowest - 8;
+ }
+
public Location getSpawnA() {
if (spawnA == null) {
return null;
diff --git a/src/main/java/me/lrxh/practice/arena/command/ArenaCommand.java b/src/main/java/me/lrxh/practice/arena/command/ArenaCommand.java
index e75a466..f5216f9 100644
--- a/src/main/java/me/lrxh/practice/arena/command/ArenaCommand.java
+++ b/src/main/java/me/lrxh/practice/arena/command/ArenaCommand.java
@@ -15,7 +15,6 @@
import me.lrxh.practice.util.CC;
import me.lrxh.practice.util.ChatComponentBuilder;
import me.lrxh.practice.util.ChatHelper;
-import me.lrxh.practice.util.PlayerUtil;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import org.apache.commons.lang.StringEscapeUtils;
@@ -122,8 +121,8 @@ public void setDisplayName(Player player, String arenaName, String value) {
}
Arena arena = Arena.getByName(arenaName);
arena.setDisplayName(value);
-
- player.sendMessage(CC.GREEN + "Successfully set " + arena.getDisplayName() + " display name!");
+ arena.save();
+ player.sendMessage(CC.GREEN + "Successfully set " + arena.getName() + " display name!");
}
@@ -377,28 +376,6 @@ public void setspawn(Player player, String arenaName, SpawnType pos) {
player.sendMessage(CC.GREEN + "Updated spawn point " + pos + " for arena " + arena.getName());
}
- @Subcommand("setBedSpawn")
- @CommandCompletion("@arenas")
- @Syntax(" ")
- public void setBedSpawn(Player player, String arenaName, SpawnType pos) {
- if (checkArena(arenaName)) {
- player.sendMessage(CC.translate("&4ERROR - &cArena doesn't exists!"));
- return;
- }
- if (!(PlayerUtil.getTargetBlock(player, 6).getType().equals(Material.BED_BLOCK) || PlayerUtil.getTargetBlock(player, 6).getType().equals(Material.BED))) {
- player.sendMessage(CC.translate("&4ERROR - &cYou aren't looking at a bed!"));
- return;
- }
- Arena arena = Arena.getByName(arenaName);
- if (pos.equals(SpawnType.A)) {
- arena.setBedA(PlayerUtil.getTargetBlock(player, 6).getLocation());
- } else {
- arena.setBedB(PlayerUtil.getTargetBlock(player, 6).getLocation());
- }
-
- arena.save();
- player.sendMessage(CC.GREEN + "Updated bed " + pos + " for arena " + arena.getDisplayName());
- }
private boolean checkArena(String arena) {
return !Arena.getArenas().contains(Arena.getByName(arena));
diff --git a/src/main/java/me/lrxh/practice/arena/impl/StandaloneArena.java b/src/main/java/me/lrxh/practice/arena/impl/StandaloneArena.java
index 757edfc..abbb6ca 100644
--- a/src/main/java/me/lrxh/practice/arena/impl/StandaloneArena.java
+++ b/src/main/java/me/lrxh/practice/arena/impl/StandaloneArena.java
@@ -37,8 +37,6 @@ public void save() {
configuration.set(path + ".spawnA", LocationUtil.serialize(spawnA));
configuration.set(path + ".displayName", displayName);
configuration.set(path + ".spawnB", LocationUtil.serialize(spawnB));
- configuration.set(path + ".bedA", LocationUtil.serialize(bedA));
- configuration.set(path + ".bedB", LocationUtil.serialize(bedB));
configuration.set(path + ".cuboid.location1", LocationUtil.serialize(getLowerCorner()));
configuration.set(path + ".cuboid.location2", LocationUtil.serialize(getUpperCorner()));
configuration.set(path + ".kits", getKits());
diff --git a/src/main/java/me/lrxh/practice/kit/KitLoadout.java b/src/main/java/me/lrxh/practice/kit/KitLoadout.java
index 4c46d7e..3a72858 100644
--- a/src/main/java/me/lrxh/practice/kit/KitLoadout.java
+++ b/src/main/java/me/lrxh/practice/kit/KitLoadout.java
@@ -21,9 +21,4 @@ public KitLoadout(String customName) {
this.contents = new ItemStack[36];
}
- public KitLoadout(ItemStack[] armor, ItemStack[] contents) {
- this.armor = armor;
- this.contents = contents;
- }
-
}
diff --git a/src/main/java/me/lrxh/practice/kit/command/KitCommand.java b/src/main/java/me/lrxh/practice/kit/command/KitCommand.java
index 56014bb..8a684c0 100644
--- a/src/main/java/me/lrxh/practice/kit/command/KitCommand.java
+++ b/src/main/java/me/lrxh/practice/kit/command/KitCommand.java
@@ -66,7 +66,7 @@ public void help3(Player player) {
player.sendMessage(CC.translate("&7* &c/kit hpregen &7 - &fSet HPRegen rule"));
player.sendMessage(CC.translate("&7* &c/kit hitdelay &7 - &fSet hit delay"));
player.sendMessage(CC.translate("&7* &c/kit boxing &7 - &fAdd Boxing rule"));
-// player.sendMessage(CC.translate("&7* &c/kit bedwars &7 - &fAdd Bedwars rule"));
+ player.sendMessage(CC.translate("&7* &c/kit bedwars &7 - &fAdd Bedwars rule"));
player.sendMessage(CC.translate("&7&m-----------------------------------------"));
}
@@ -255,22 +255,22 @@ public void build(Player player, String kitName) {
player.sendMessage(CC.GREEN + "You updated the kit's build status to " + (kit.getGameRules().isBuild() ? "Enabled" : ChatColor.RED + "Disabled" + "."));
}
-// @Subcommand("bedwars")
-// @CommandCompletion("@kits")
-// @Syntax("")
-// public void bedwars(Player player, String kitName) {
-// if (!Kit.getKits().contains(Kit.getByName(kitName))) {
-// player.sendMessage(CC.translate("&4ERROR - &cKit doesn't exists!"));
-// return;
-// }
-// Kit kit = Kit.getByName(kitName);
-// if (kit == null) return;
-//
-// kit.getGameRules().setBedwars(!kit.getGameRules().isBedwars());
-// kit.save();
-//
-// player.sendMessage(CC.GREEN + "You updated the kit's bedwars status to " + (kit.getGameRules().isBedwars() ? "Enabled" : ChatColor.RED + "Disabled" + "."));
-// }
+ @Subcommand("bedwars")
+ @CommandCompletion("@kits")
+ @Syntax("")
+ public void bedwars(Player player, String kitName) {
+ if (!Kit.getKits().contains(Kit.getByName(kitName))) {
+ player.sendMessage(CC.translate("&4ERROR - &cKit doesn't exists!"));
+ return;
+ }
+ Kit kit = Kit.getByName(kitName);
+ if (kit == null) return;
+
+ kit.getGameRules().setBedwars(!kit.getGameRules().isBedwars());
+ kit.save();
+
+ player.sendMessage(CC.GREEN + "You updated the kit's bedwars status to " + (kit.getGameRules().isBedwars() ? "Enabled" : ChatColor.RED + "Disabled" + "."));
+ }
@Subcommand("spleef")
@CommandCompletion("@kits")
diff --git a/src/main/java/me/lrxh/practice/leaderboards/LeaderboardsMenu.java b/src/main/java/me/lrxh/practice/leaderboards/LeaderboardsMenu.java
index 637269a..00023d9 100644
--- a/src/main/java/me/lrxh/practice/leaderboards/LeaderboardsMenu.java
+++ b/src/main/java/me/lrxh/practice/leaderboards/LeaderboardsMenu.java
@@ -6,15 +6,13 @@
import me.lrxh.practice.queue.Queue;
import me.lrxh.practice.util.CC;
import me.lrxh.practice.util.ItemBuilder;
+import me.lrxh.practice.util.PlayerUtil;
import me.lrxh.practice.util.TimeUtil;
import me.lrxh.practice.util.menu.Button;
import me.lrxh.practice.util.menu.Menu;
import me.lrxh.practice.util.menu.filters.Filters;
-import org.bukkit.Material;
-import org.bukkit.SkullType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.meta.SkullMeta;
import java.util.ArrayList;
import java.util.HashMap;
@@ -63,11 +61,6 @@ public Map getButtons(Player player) {
private class GlobalStatsButton extends Button {
public ItemStack getButtonItem(Player player) {
- ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) SkullType.PLAYER.ordinal());
- SkullMeta skullMeta = (SkullMeta) head.getItemMeta();
- skullMeta.setOwner(player.getName());
- head.setItemMeta(skullMeta);
-
List lore = new ArrayList<>();
Profile profile = Profile.getByUuid(player.getUniqueId());
@@ -80,7 +73,7 @@ public ItemStack getButtonItem(Player player) {
}
- return new ItemBuilder(head)
+ return new ItemBuilder(PlayerUtil.getPlayerHead(player.getUniqueId()))
.name(Practice.getInstance().getMenusConfig().getString("LEADERBOARD.GLOBAL-STATS.GLOBAL-STATS-NAME"))
.lore(lore)
.clearEnchantments()
diff --git a/src/main/java/me/lrxh/practice/match/Match.java b/src/main/java/me/lrxh/practice/match/Match.java
index 756adb4..1767878 100644
--- a/src/main/java/me/lrxh/practice/match/Match.java
+++ b/src/main/java/me/lrxh/practice/match/Match.java
@@ -25,7 +25,11 @@
import org.bukkit.entity.Firework;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkMeta;
+import org.bukkit.potion.PotionEffect;
+import org.bukkit.potion.PotionEffectType;
+import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import java.util.ArrayList;
@@ -47,17 +51,22 @@ public abstract class Match {
private final Queue queue;
private final List placedBlocks;
private final List changedBlocks;
+ protected boolean bedABroken;
+ protected boolean bedBBroken;
@Setter
protected MatchState state = MatchState.STARTING_ROUND;
protected long timeData;
protected MatchLogicTask logicTask;
private boolean duel;
+
public Match(Queue queue, Kit kit, Arena arena, boolean ranked, boolean duel) {
this.queue = queue;
this.kit = kit;
this.arena = arena;
this.ranked = ranked;
+ this.bedABroken = false;
+ this.bedBBroken = false;
this.snapshots = new ArrayList<>();
this.spectators = new ArrayList<>();
this.droppedItems = new ArrayList<>();
@@ -164,9 +173,13 @@ public void setupPlayer(Player player) {
if (kitData.getKitCount() > 0) {
profile.getKitData().get(getKit()).giveBooks(player);
} else {
- player.getInventory().setArmorContents(getKit().getKitLoadout().getArmor());
- player.getInventory().setContents(getKit().getKitLoadout().getContents());
+ GameParticipant participantA = getParticipantA();
+ player.getInventory().setArmorContents(InventoryUtil.color(getKit().getKitLoadout().getArmor(), participantA.containsPlayer(player.getUniqueId()) ? Color.RED : Color.BLUE).toArray(new ItemStack[0]));
+ //player.getInventory().setArmorContents(getKit().getKitLoadout().getArmor());
+ player.getInventory().setContents(InventoryUtil.color(getKit().getKitLoadout().getContents(), participantA.containsPlayer(player.getUniqueId()) ? Color.RED : Color.BLUE).toArray(new ItemStack[0]));
+ //player.getInventory().setContents(getKit().getKitLoadout().getContents());
player.sendMessage(Locale.MATCH_GIVE_KIT.format(player, "Default", kit.getName()));
+ profile.getMatch().getGamePlayer(player).setKitLoadout(kit.getKitLoadout());
}
}
}
@@ -365,6 +378,103 @@ public void onRoundEnd() {
}
}
+ public void respawn(UUID playerUUID) {
+ Profile profile = Profile.getByUuid(playerUUID);
+ Player player = Bukkit.getPlayer(playerUUID);
+ MatchGamePlayer gamePlayer = profile.getMatch().getGamePlayer(player);
+ if (gamePlayer.isRespawned()) {
+ return;
+ }
+ if (state != MatchState.PLAYING_ROUND) {
+ return;
+ }
+
+ gamePlayer.setRespawned(true);
+
+
+ sendDeathMessage(player, PlayerUtil.getLastAttacker(player), false);
+ player.addPotionEffect(
+ new PotionEffect(PotionEffectType.WEAKNESS, Integer.MAX_VALUE, 0));
+
+ hidePlayer(playerUUID);
+
+ player.getInventory().clear();
+ player.getInventory().setArmorContents(null);
+ player.updateInventory();
+ player.setHealth(player.getMaxHealth());
+ player.setFoodLevel(20);
+ player.setGameMode(GameMode.ADVENTURE);
+
+ player.setVelocity(player.getVelocity().add(new Vector(0, 0.25, 0)));
+ player.setAllowFlight(true);
+ player.setFlying(true);
+ player.setVelocity(player.getVelocity().add(new Vector(0, 0.15, 0)));
+ player.setAllowFlight(true);
+ player.setFlying(true);
+ new BukkitRunnable() {
+ int countdown = 3;
+
+ @Override
+ public void run() {
+ if (countdown > 0) {
+ player.sendMessage(Locale.MATCH_RESPAWN_TIMER.format(player, countdown));
+ countdown--;
+ } else {
+ player.sendMessage(Locale.MATCH_RESPAWNED.format(player));
+ player.setAllowFlight(false);
+ player.setFlying(false);
+ boolean aTeam = getParticipantA().containsPlayer(player.getUniqueId());
+ Location spawn = aTeam ? getArena().getSpawnA() : getArena().getSpawnB();
+ player.teleport(spawn);
+ player.getInventory().setArmorContents(InventoryUtil.color(gamePlayer.getKitLoadout().getArmor(), aTeam ? Color.RED : Color.BLUE).toArray(new ItemStack[0]));
+ player.getInventory().setContents(gamePlayer.getKitLoadout().getContents());
+ player.setGameMode(GameMode.SURVIVAL);
+ showPlayer(playerUUID);
+ gamePlayer.setRespawned(false);
+ this.cancel();
+ }
+ }
+ }.runTaskTimer(Practice.getInstance(), 0L, 20L);
+
+
+ }
+
+ public void broadcast(String message) {
+ for (GameParticipant gameParticipant : getParticipants()) {
+ for (MatchGamePlayer gamePlayer : gameParticipant.getPlayers()) {
+ gamePlayer.getPlayer().sendMessage(message);
+ }
+ }
+
+ for (Player player : getSpectatorsAsPlayers()) {
+ player.sendMessage(message);
+ }
+ }
+
+ public void hidePlayer(UUID playerUUID) {
+ for (GameParticipant gameParticipant : getParticipants()) {
+ for (MatchGamePlayer gamePlayer : gameParticipant.getPlayers()) {
+ gamePlayer.getPlayer().hidePlayer(Bukkit.getPlayer(playerUUID));
+ }
+ }
+
+ for (Player player : getSpectatorsAsPlayers()) {
+ player.hidePlayer(Bukkit.getPlayer(playerUUID));
+ }
+ }
+
+ public void showPlayer(UUID playerUUID) {
+ for (GameParticipant gameParticipant : getParticipants()) {
+ for (MatchGamePlayer gamePlayer : gameParticipant.getPlayers()) {
+ gamePlayer.getPlayer().showPlayer(Bukkit.getPlayer(playerUUID));
+ }
+ }
+
+ for (Player player : getSpectatorsAsPlayers()) {
+ player.showPlayer(Bukkit.getPlayer(playerUUID));
+ }
+ }
+
public abstract boolean canEndRound();
public void onDisconnect(Player dead) {
@@ -392,6 +502,8 @@ public void onDeath(Player dead) {
}
MatchGamePlayer deadGamePlayer = getGamePlayer(dead);
+ Player killer = PlayerUtil.getLastAttacker(dead);
+
// Don't continue if the player is already dead
if (deadGamePlayer.isDead()) {
@@ -402,7 +514,6 @@ public void onDeath(Player dead) {
deadGamePlayer.setDead(true);
// Get killer
- Player killer = PlayerUtil.getLastAttacker(dead);
if (killer != null) {
Profile killerProfile = Profile.getByUuid(killer.getUniqueId());
Location location = dead.getLocation();
@@ -458,7 +569,6 @@ public void onDeath(Player dead) {
if (player != null) {
VisibilityLogic.handle(player, dead);
- sendDeathMessage(player, dead, killer);
if (player != dead) {
Profile winnerProfile = Profile.getByUuid(player.getUniqueId());
if (!Practice.getInstance().getCache().getMatch(matchId).isDuel()) {
@@ -470,13 +580,17 @@ public void onDeath(Player dead) {
}
}
+ if (kit.getGameRules().isBedwars()) {
+ sendDeathMessage(dead, killer, true);
+ }
+
// Handle visibility for spectators
// Send death message
for (Player player : getSpectatorsAsPlayers()) {
VisibilityLogic.handle(player, dead);
- sendDeathMessage(player, dead, killer);
}
+
if (canEndRound()) {
state = MatchState.ENDING_ROUND;
timeData = System.currentTimeMillis() - timeData;
@@ -511,6 +625,14 @@ public GameParticipant getParticipant(Player player) {
return null;
}
+ public GameParticipant getParticipantA() {
+ return getParticipants().get(0);
+ }
+
+ public GameParticipant getParticipantB() {
+ return getParticipants().get(1);
+ }
+
public MatchGamePlayer getGamePlayer(Player player) {
for (GameParticipant gameParticipant : getParticipants()) {
for (MatchGamePlayer gamePlayer : gameParticipant.getPlayers()) {
@@ -652,21 +774,74 @@ protected List getSpectatorsAsPlayers() {
public abstract List generateEndComponents();
- public void sendDeathMessage(Player player, Player dead, Player killer) {
+ public void sendDeathMessage(Player dead, Player killer, boolean finalKill) {
String deathMessage;
+ if (finalKill) {
+ for (GameParticipant gameParticipant : getParticipants()) {
+ for (MatchGamePlayer gamePlayer : gameParticipant.getPlayers()) {
+ Player player = gamePlayer.getPlayer();
+ if (killer == null) {
+ deathMessage = Locale.MATCH_PLAYER_FINAL_KILL.format(player,
+ getRelationColor(player, dead) + dead.getName()
+ );
+ } else {
+ deathMessage = Locale.MATCH_PLAYER_FINAL_KILL.format(player,
+ getRelationColor(player, dead) + dead.getName(),
+ getRelationColor(player, killer) + killer.getName()
+ );
+ }
+ player.sendMessage(deathMessage);
+ }
+ }
- if (killer == null) {
- deathMessage = Locale.MATCH_PLAYER_DIED.format(player,
- getRelationColor(player, dead) + dead.getName()
- );
- } else {
- deathMessage = Locale.MATCH_PLAYER_KILLED.format(player,
- getRelationColor(player, dead) + dead.getName(),
- getRelationColor(player, killer) + killer.getName()
- );
+ for (Player player : getSpectatorsAsPlayers()) {
+ if (killer == null) {
+ deathMessage = Locale.MATCH_PLAYER_FINAL_KILL.format(player,
+ getRelationColor(player, dead) + dead.getName()
+ );
+ } else {
+ deathMessage = Locale.MATCH_PLAYER_FINAL_KILL.format(player,
+ getRelationColor(player, dead) + dead.getName(),
+ getRelationColor(player, killer) + killer.getName()
+ );
+ }
+ player.sendMessage(deathMessage);
+ }
+ return;
+ }
+
+
+ for (GameParticipant gameParticipant : getParticipants()) {
+ for (MatchGamePlayer gamePlayer : gameParticipant.getPlayers()) {
+ Player player = gamePlayer.getPlayer();
+ if (killer == null) {
+ deathMessage = Locale.MATCH_PLAYER_DIED.format(player,
+ getRelationColor(player, dead) + dead.getName()
+ );
+ } else {
+ deathMessage = Locale.MATCH_PLAYER_KILLED.format(player,
+ getRelationColor(player, dead) + dead.getName(),
+ getRelationColor(player, killer) + killer.getName()
+ );
+ }
+ player.sendMessage(deathMessage);
+ }
+ }
+
+ for (Player player : getSpectatorsAsPlayers()) {
+ if (killer == null) {
+ deathMessage = Locale.MATCH_PLAYER_DIED.format(player,
+ getRelationColor(player, dead) + dead.getName()
+ );
+ } else {
+ deathMessage = Locale.MATCH_PLAYER_KILLED.format(player,
+ getRelationColor(player, dead) + dead.getName(),
+ getRelationColor(player, killer) + killer.getName()
+ );
+ }
+ player.sendMessage(deathMessage);
}
- player.sendMessage(deathMessage);
}
}
diff --git a/src/main/java/me/lrxh/practice/match/MatchListener.java b/src/main/java/me/lrxh/practice/match/MatchListener.java
index 6a1ffd5..4dec1cc 100644
--- a/src/main/java/me/lrxh/practice/match/MatchListener.java
+++ b/src/main/java/me/lrxh/practice/match/MatchListener.java
@@ -5,14 +5,14 @@
import me.lrxh.practice.arena.Arena;
import me.lrxh.practice.kit.KitLoadout;
import me.lrxh.practice.match.menu.ViewInventoryMenu;
+import me.lrxh.practice.match.participant.MatchGamePlayer;
+import me.lrxh.practice.participant.GameParticipant;
import me.lrxh.practice.profile.Profile;
import me.lrxh.practice.profile.ProfileState;
import me.lrxh.practice.profile.hotbar.HotbarItem;
-import me.lrxh.practice.util.CC;
-import me.lrxh.practice.util.Cooldown;
-import me.lrxh.practice.util.PlayerUtil;
-import me.lrxh.practice.util.TimeUtil;
+import me.lrxh.practice.util.*;
import org.apache.commons.lang.StringEscapeUtils;
+import org.bukkit.Color;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -44,7 +44,6 @@ public class MatchListener implements Listener {
public void onPlayerMoveEvent(PlayerMoveEvent event) {
Profile profile = Profile.getByUuid(event.getPlayer().getUniqueId());
-
if (profile.getState() == ProfileState.FIGHTING) {
if (profile.getMatch().getKit().getGameRules().isSumo() ||
profile.getMatch().getKit().getGameRules().isSpleef()) {
@@ -56,6 +55,22 @@ public void onPlayerMoveEvent(PlayerMoveEvent event) {
match.onDeath(event.getPlayer());
}
}
+ if (profile.getMatch().getKit().getGameRules().isBedwars()) {
+ Player player = event.getPlayer();
+ Match match = profile.getMatch();
+
+ boolean bedGone = match.getParticipantA().containsPlayer(player.getUniqueId()) ? match.bedBBroken : match.bedABroken;
+
+ if (profile.getMatch().kit.getGameRules().isBedwars()) {
+ if (!(player.getLocation().getY() >= match.getArena().getDeathZone()) && !match.getGamePlayer(player).isRespawned()) {
+ if (!bedGone) {
+ match.respawn(player.getUniqueId());
+ } else {
+ profile.getMatch().onDeath(player);
+ }
+ }
+ }
+ }
}
}
@@ -106,12 +121,35 @@ public void onBlockBreakEvent(BlockBreakEvent event) {
if (profile.getState() == ProfileState.FIGHTING) {
Match match = profile.getMatch();
- if (match.kit.getGameRules().isBedwars()) {
- if (event.getBlock().getLocation().equals(event.getPlayer().getBedSpawnLocation())) {
- event.getPlayer().sendMessage(CC.translate("&cYou can't break your own bed!"));
+ if (event.getBlock().getType() == Material.BED_BLOCK || event.getBlock().getType() == Material.BED) {
+ Player player = event.getPlayer();
+
+ GameParticipant participantA = match.getParticipantA();
+
+ boolean aTeam = match.getParticipantA().containsPlayer(player.getUniqueId());
+
+ Location spawn = aTeam ? match.getArena().getSpawnA() : match.getArena().getSpawnB();
+
+ Location bed = event.getBlock().getLocation();
+ if (bed.distanceSquared(spawn) > bed.distanceSquared(participantA != null && participantA.containsPlayer(match.getOpponent(player.getUniqueId()).getUniqueId()) ?
+ match.getArena().getSpawnA() : match.getArena().getSpawnB())) {
+
+ if (aTeam) {
+ match.setBedABroken(true);
+ } else {
+ match.setBedBBroken(true);
+ }
+
+ } else if (bed.distanceSquared(spawn) < bed.distanceSquared(match.getOpponent(player.getUniqueId()).getLocation())) {
+ player.sendMessage(CC.translate("&cYou cannot break your own bed!"));
event.setCancelled(true);
+ return;
}
+
+ match.broadcast(Locale.MATCH_BED_BROKEN.format(player, aTeam ? CC.translate("&cRed") : CC.translate("&9Blue"),
+ aTeam ? CC.translate("&c" + player.getName()) : CC.translate("&9" + player.getName())));
}
+
if (match.getKit().getGameRules().isBuild() && match.getState() == MatchState.PLAYING_ROUND) {
if (match.getKit().getGameRules().isSpleef()) {
if (event.getBlock().getType() == Material.SNOW_BLOCK ||
@@ -130,7 +168,7 @@ public void onBlockBreakEvent(BlockBreakEvent event) {
} else {
event.setCancelled(true);
}
- if (match.kit.getGameRules().isBedwars() && (event.getBlock().getType().equals(Material.BED_BLOCK) || event.getBlock().getType().equals(Material.BED))) {
+ if (match.kit.getGameRules().isBedwars() && (event.getBlock().getType().equals(Material.BED_BLOCK) || event.getBlock().getType().equals(Material.BED)) || event.getBlock().getType().equals(Material.ENDER_STONE) || (event.getBlock().getType().equals(Material.WOOD) && event.getBlock().getData() == 0)) {
event.setCancelled(false);
}
} else {
@@ -231,18 +269,43 @@ public void onPlayerDropItemEvent(PlayerDropItemEvent event) {
}
}
+ @EventHandler
+ public void onPlayerPickUpEvent(PlayerPickupItemEvent event) {
+ Player player = event.getPlayer();
+ Profile profile = Profile.getByUuid(player.getUniqueId());
+ if (profile.getMatch() != null && profile.getMatch().getState().equals(MatchState.ENDING_MATCH)) {
+ event.setCancelled(true);
+ }
+ }
+
@EventHandler
public void onPlayerDeathEvent(PlayerDeathEvent event) {
+ Player player = event.getEntity();
event.setDeathMessage(null);
- event.getDrops().clear();
+
+ player.getInventory().setContents(new ItemStack[36]);
+
+ PlayerUtil.animateDeath(player);
Profile profile = Profile.getByUuid(event.getEntity().getUniqueId());
if (profile.getState() == ProfileState.FIGHTING) {
- if (profile.getMatch().kit.getGameRules().isBedwars()) {
- PlayerUtil.animateDeath(event.getEntity());
+
+ Match match = profile.getMatch();
+ boolean aTeam = match.getParticipantA().containsPlayer(player.getUniqueId());
+
+ boolean bedGone = aTeam ? match.bedBBroken : match.bedABroken;
+
+ if (profile.getMatch().getKit().getGameRules().isBedwars()) {
+ event.getDrops().clear();
+ if (!bedGone) {
+ match.respawn(player.getUniqueId());
+ } else {
+ profile.getMatch().onDeath(player);
+ }
return;
}
+
List- entities = new ArrayList<>();
event.getDrops().forEach(itemStack -> {
@@ -252,8 +315,8 @@ public void onPlayerDeathEvent(PlayerDeathEvent event) {
}
});
- profile.getMatch().getDroppedItems().addAll(entities);
- profile.getMatch().onDeath(event.getEntity());
+ match.getDroppedItems().addAll(entities);
+ match.onDeath(event.getEntity());
}
}
@@ -339,9 +402,23 @@ public void onEntityDamage(EntityDamageEvent event) {
Profile profile = Profile.getByUuid(player.getUniqueId());
if (profile.getState() == ProfileState.FIGHTING) {
+
if (event.getCause() == EntityDamageEvent.DamageCause.VOID) {
- profile.getMatch().onDeath(player);
- return;
+
+ Match match = profile.getMatch();
+ GameParticipant participantA = match.getParticipant(player);
+
+ boolean bedGone = participantA != null && participantA.containsPlayer(event.getEntity().getUniqueId()) ? match.bedABroken : match.bedBBroken;
+ if (profile.getMatch().kit.getGameRules().isBedwars() && !bedGone) {
+ Location spawn = participantA != null && participantA.containsPlayer(event.getEntity().getUniqueId()) ?
+ match.getArena().getSpawnA() : match.getArena().getSpawnB();
+
+ event.getEntity().teleport(spawn);
+ return;
+ } else {
+ profile.getMatch().onDeath(player);
+ return;
+ }
}
if (profile.getMatch().getState() != MatchState.PLAYING_ROUND) {
@@ -607,7 +684,9 @@ public void onPlayerInteractEvent(PlayerInteractEvent event) {
if (kitLoadout != null) {
player.sendMessage(Locale.MATCH_GIVE_KIT.format(player, kitLoadout.getCustomName(), kitName));
- player.getInventory().setArmorContents(kitLoadout.getArmor());
+ profile.getMatch().getGamePlayer(player).setKitLoadout(kitLoadout);
+ GameParticipant participantA = match.getParticipantA();
+ player.getInventory().setArmorContents(InventoryUtil.color(kitLoadout.getArmor(), participantA.containsPlayer(player.getUniqueId()) ? Color.RED : Color.BLUE).toArray(new ItemStack[0]));
player.getInventory().setContents(kitLoadout.getContents());
player.updateInventory();
event.setCancelled(true);
diff --git a/src/main/java/me/lrxh/practice/match/impl/BasicFreeForAllMatch.java b/src/main/java/me/lrxh/practice/match/impl/BasicFreeForAllMatch.java
index d709a6d..4ba9249 100644
--- a/src/main/java/me/lrxh/practice/match/impl/BasicFreeForAllMatch.java
+++ b/src/main/java/me/lrxh/practice/match/impl/BasicFreeForAllMatch.java
@@ -12,11 +12,14 @@
import me.lrxh.practice.queue.Queue;
import me.lrxh.practice.util.CC;
import me.lrxh.practice.util.ChatComponentBuilder;
+import me.lrxh.practice.util.InventoryUtil;
import me.lrxh.practice.util.PlayerUtil;
import net.md_5.bungee.api.chat.BaseComponent;
+import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.List;
@@ -47,7 +50,7 @@ public void setupPlayer(Player player) {
PlayerUtil.reset(player);
// Deny movement if the kit is sumo
- if (getKit().getGameRules().isSumo()) {
+ if (getKit().getGameRules().isSumo() || getKit().getGameRules().isBedwars()) {
PlayerUtil.denyMovement(player);
}
@@ -63,9 +66,14 @@ public void setupPlayer(Player player) {
if (kitData.getKitCount() > 0) {
profile.getKitData().get(getKit()).giveBooks(player);
} else {
- player.getInventory().setArmorContents(getKit().getKitLoadout().getArmor());
- player.getInventory().setContents(getKit().getKitLoadout().getContents());
+ GameParticipant participantA = this.getParticipantA();
+ player.getInventory().setArmorContents(InventoryUtil.color(getKit().getKitLoadout().getArmor(), participantA.containsPlayer(player.getUniqueId()) ? Color.RED : Color.BLUE).toArray(new ItemStack[0]));
+ //player.getInventory().setArmorContents(getKit().getKitLoadout().getArmor());
+ //player.getInventory().setContents(getKit().getKitLoadout().getContents());
+ player.getInventory().setContents(InventoryUtil.color(getKit().getKitLoadout().getContents(), participantA.containsPlayer(player.getUniqueId()) ? Color.RED : Color.BLUE).toArray(new ItemStack[0]));
+
player.sendMessage(Locale.MATCH_GIVE_KIT.format(player, "Default", kit.getName()));
+ profile.getMatch().getGamePlayer(player).setKitLoadout(kit.getKitLoadout());
}
}
@@ -121,6 +129,7 @@ public boolean isOnSameTeam(Player first, Player second) {
@Override
public List> getParticipants() {
+ System.out.println("This getting ran");
return new ArrayList<>(participants);
}
diff --git a/src/main/java/me/lrxh/practice/match/impl/BasicTeamMatch.java b/src/main/java/me/lrxh/practice/match/impl/BasicTeamMatch.java
index 2033127..8165611 100644
--- a/src/main/java/me/lrxh/practice/match/impl/BasicTeamMatch.java
+++ b/src/main/java/me/lrxh/practice/match/impl/BasicTeamMatch.java
@@ -53,6 +53,7 @@ public void setupPlayer(Player player) {
// Teleport the player to their spawn point
Location spawn = participantA.containsPlayer(player.getUniqueId()) ?
getArena().getSpawnA() : getArena().getSpawnB();
+
if (kit.getGameRules().isBedwars()) {
if (participantA.containsPlayer(player.getUniqueId())) {
player.setBedSpawnLocation(arena.getBedA());
diff --git a/src/main/java/me/lrxh/practice/match/menu/MatchDetailsMenu.java b/src/main/java/me/lrxh/practice/match/menu/MatchDetailsMenu.java
index 73ec555..45dd1d6 100644
--- a/src/main/java/me/lrxh/practice/match/menu/MatchDetailsMenu.java
+++ b/src/main/java/me/lrxh/practice/match/menu/MatchDetailsMenu.java
@@ -2,10 +2,7 @@
import lombok.AllArgsConstructor;
import me.lrxh.practice.match.MatchSnapshot;
-import me.lrxh.practice.util.InventoryUtil;
-import me.lrxh.practice.util.ItemBuilder;
-import me.lrxh.practice.util.PotionUtil;
-import me.lrxh.practice.util.TimeUtil;
+import me.lrxh.practice.util.*;
import me.lrxh.practice.util.menu.Button;
import me.lrxh.practice.util.menu.Menu;
import me.lrxh.practice.util.menu.button.DisplayButton;
@@ -13,11 +10,9 @@
import org.apache.commons.lang.StringEscapeUtils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
-import org.bukkit.SkullType;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.potion.PotionEffect;
import java.util.*;
@@ -86,12 +81,7 @@ private class HealthButton extends Button {
@Override
public ItemStack getButtonItem(Player player) {
- ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) SkullType.PLAYER.ordinal());
- SkullMeta skullMeta = (SkullMeta) head.getItemMeta();
- skullMeta.setOwner(player.getName());
- head.setItemMeta(skullMeta);
-
- return new ItemBuilder(head)
+ return new ItemBuilder(PlayerUtil.getPlayerHead(snapshot.getUuid()))
.name("&bHealth: &f" + health + "/10 &4" + StringEscapeUtils.unescapeJava("❤"))
.amount((int) (health == 0 ? 1 : health), false)
.clearFlags()
@@ -181,7 +171,7 @@ public ItemStack getButtonItem(Player player) {
MatchSnapshot snapshot = MatchSnapshot.getByUuid(opponent);
if (snapshot != null) {
- return new ItemBuilder(Material.PAPER)
+ return new ItemBuilder(Material.LEVER)
.name("&7Press to switch to " + Bukkit.getPlayer(opponent).getName() + " inventory.")
.lore("&aClick to Switch")
.clearFlags()
diff --git a/src/main/java/me/lrxh/practice/match/participant/MatchGamePlayer.java b/src/main/java/me/lrxh/practice/match/participant/MatchGamePlayer.java
index a32e363..0c455f1 100644
--- a/src/main/java/me/lrxh/practice/match/participant/MatchGamePlayer.java
+++ b/src/main/java/me/lrxh/practice/match/participant/MatchGamePlayer.java
@@ -2,21 +2,24 @@
import lombok.Getter;
import lombok.Setter;
+import me.lrxh.practice.kit.KitLoadout;
import me.lrxh.practice.participant.GamePlayer;
import java.util.UUID;
@Getter
+@Setter
public class MatchGamePlayer extends GamePlayer {
private final int elo;
- @Setter
private int eloMod;
private int hits;
private int longestCombo;
private int combo;
private int potionsThrown;
private int potionsMissed;
+ private boolean respawned = false;
+ private KitLoadout kitLoadout = null;
public MatchGamePlayer(UUID uuid, String username) {
this(uuid, username, 0);
diff --git a/src/main/java/me/lrxh/practice/match/task/MatchLogicTask.java b/src/main/java/me/lrxh/practice/match/task/MatchLogicTask.java
index b516f24..7d48ba0 100644
--- a/src/main/java/me/lrxh/practice/match/task/MatchLogicTask.java
+++ b/src/main/java/me/lrxh/practice/match/task/MatchLogicTask.java
@@ -32,7 +32,7 @@ public MatchLogicTask(Match match) {
public void run() {
nextAction--;
if (match.getState() == MatchState.STARTING_ROUND) {
- if (match.getKit().getGameRules().isSumo()) {
+ if (match.getKit().getGameRules().isSumo() || match.getKit().getGameRules().isBedwars()) {
for (GameParticipant gameParticipant : match.getParticipants()) {
for (GamePlayer gamePlayer : gameParticipant.getPlayers()) {
PlayerUtil.denyMovement(gamePlayer.getPlayer());
@@ -46,7 +46,7 @@ public void run() {
match.sendMessage(" ");
match.sendMessage(Locale.MATCH_WARNING.format());
match.sendSound(Sound.ORB_PICKUP, 1.0F, 1.0F);
- if (match.getKit().getGameRules().isSumo()) {
+ if (match.getKit().getGameRules().isSumo() || match.getKit().getGameRules().isBedwars()) {
for (GameParticipant gameParticipant : match.getParticipants()) {
for (GamePlayer gamePlayer : gameParticipant.getPlayers()) {
PlayerUtil.allowMovement(gamePlayer.getPlayer());
diff --git a/src/main/java/me/lrxh/practice/menus/StatsMenu.java b/src/main/java/me/lrxh/practice/menus/StatsMenu.java
index 5731663..400c5b6 100644
--- a/src/main/java/me/lrxh/practice/menus/StatsMenu.java
+++ b/src/main/java/me/lrxh/practice/menus/StatsMenu.java
@@ -6,15 +6,13 @@
import me.lrxh.practice.profile.Profile;
import me.lrxh.practice.queue.Queue;
import me.lrxh.practice.util.ItemBuilder;
+import me.lrxh.practice.util.PlayerUtil;
import me.lrxh.practice.util.menu.Button;
import me.lrxh.practice.util.menu.Menu;
import me.lrxh.practice.util.menu.filters.Filters;
import org.bukkit.Bukkit;
-import org.bukkit.Material;
-import org.bukkit.SkullType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.meta.SkullMeta;
import java.util.ArrayList;
import java.util.HashMap;
@@ -62,10 +60,6 @@ public Map getButtons(Player player) {
@AllArgsConstructor
private class GlobalStatsButton extends Button {
public ItemStack getButtonItem(Player player) {
- ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) SkullType.PLAYER.ordinal());
- SkullMeta skullMeta = (SkullMeta) head.getItemMeta();
- skullMeta.setOwner(target.getName());
- head.setItemMeta(skullMeta);
List lore = new ArrayList<>();
Profile profile = Profile.getByUuid(target.getUniqueId());
@@ -79,7 +73,7 @@ public ItemStack getButtonItem(Player player) {
}
- return new ItemBuilder(head)
+ return new ItemBuilder(PlayerUtil.getPlayerHead(target.getUniqueId()))
.name(Practice.getInstance().getMenusConfig().getString("STATS.GLOBAL-STATS.GLOBAL-STATS-NAME"))
.lore(lore)
.clearEnchantments()
diff --git a/src/main/java/me/lrxh/practice/participant/GameParticipant.java b/src/main/java/me/lrxh/practice/participant/GameParticipant.java
index 0b4a88a..5aada9b 100644
--- a/src/main/java/me/lrxh/practice/participant/GameParticipant.java
+++ b/src/main/java/me/lrxh/practice/participant/GameParticipant.java
@@ -12,12 +12,11 @@
import java.util.UUID;
@Getter
+@Setter
public class GameParticipant {
private final T leader;
- @Setter
private int roundWins;
- @Setter
private boolean eliminated;
public GameParticipant(T leader) {
diff --git a/src/main/java/me/lrxh/practice/profile/ProfileListener.java b/src/main/java/me/lrxh/practice/profile/ProfileListener.java
index 2549630..1deb991 100644
--- a/src/main/java/me/lrxh/practice/profile/ProfileListener.java
+++ b/src/main/java/me/lrxh/practice/profile/ProfileListener.java
@@ -14,6 +14,7 @@
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
+import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -94,6 +95,12 @@ public void onEntityDamageEvent(EntityDamageEvent event) {
}
}
+ @EventHandler
+ public void soilChangePlayer(PlayerInteractEvent event) {
+ if (event.getAction() == Action.PHYSICAL && event.getClickedBlock().getType() == Material.SOIL)
+ event.setCancelled(true);
+ }
+
@EventHandler
public void onOptionsOpenedEvent(OptionsOpenedEvent event) {
event.getButtons().add(new ShowScoreboardOptionButton());
diff --git a/src/main/java/me/lrxh/practice/queue/menu/QueueSelectKitMenu.java b/src/main/java/me/lrxh/practice/queue/menu/QueueSelectKitMenu.java
index d13c853..435c1aa 100644
--- a/src/main/java/me/lrxh/practice/queue/menu/QueueSelectKitMenu.java
+++ b/src/main/java/me/lrxh/practice/queue/menu/QueueSelectKitMenu.java
@@ -160,7 +160,7 @@ private String replaceLeaderboardPlaceholders(String line, Queue queue) {
@Override
public void clicked(Player player, ClickType clickType) {
Profile profile = Profile.getByUuid(player.getUniqueId());
- if(!profile.getFollowing().isEmpty()){
+ if (!profile.getFollowing().isEmpty()) {
player.sendMessage(CC.translate("&4ERROR - &cYou can't queue while following someone!"));
player.closeInventory();
return;
diff --git a/src/main/java/me/lrxh/practice/scoreboard/ScoreboardAdapter.java b/src/main/java/me/lrxh/practice/scoreboard/ScoreboardAdapter.java
index 70907f8..9343393 100644
--- a/src/main/java/me/lrxh/practice/scoreboard/ScoreboardAdapter.java
+++ b/src/main/java/me/lrxh/practice/scoreboard/ScoreboardAdapter.java
@@ -59,6 +59,9 @@ public List getLines(Player player) {
if (match.getKit().getGameRules().isBoxing()) {
return PlaceholderUtil.format(new ArrayList<>(Practice.getInstance().getScoreboardConfig().getStringList("MATCH.IN-MATCH-BOXING")), player);
}
+ if (match.getKit().getGameRules().isBedwars()) {
+ return PlaceholderUtil.format(new ArrayList<>(Practice.getInstance().getScoreboardConfig().getStringList("MATCH.IN-MATCH-BEDWARS")), player);
+ }
return PlaceholderUtil.format(new ArrayList<>(Practice.getInstance().getScoreboardConfig().getStringList("MATCH.IN-MATCH")), player);
}
}
diff --git a/src/main/java/me/lrxh/practice/util/BaseEvent.java b/src/main/java/me/lrxh/practice/util/BaseEvent.java
index 434cf03..df27cf2 100644
--- a/src/main/java/me/lrxh/practice/util/BaseEvent.java
+++ b/src/main/java/me/lrxh/practice/util/BaseEvent.java
@@ -4,6 +4,7 @@
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
+
public class BaseEvent extends Event {
private static final HandlerList handlers = new HandlerList();
diff --git a/src/main/java/me/lrxh/practice/util/EntityUtils.java b/src/main/java/me/lrxh/practice/util/EntityUtils.java
new file mode 100644
index 0000000..cfbe667
--- /dev/null
+++ b/src/main/java/me/lrxh/practice/util/EntityUtils.java
@@ -0,0 +1,12 @@
+package me.lrxh.practice.util;
+
+import lombok.experimental.UtilityClass;
+
+@UtilityClass
+public class EntityUtils {
+ private int currentFakeEntityId = -1;
+
+ public int getFakeEntityId() {
+ return currentFakeEntityId--;
+ }
+}
diff --git a/src/main/java/me/lrxh/practice/util/InventoryUtil.java b/src/main/java/me/lrxh/practice/util/InventoryUtil.java
index 8428315..bb71fd2 100644
--- a/src/main/java/me/lrxh/practice/util/InventoryUtil.java
+++ b/src/main/java/me/lrxh/practice/util/InventoryUtil.java
@@ -1,11 +1,13 @@
package me.lrxh.practice.util;
import me.lrxh.practice.Practice;
+import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.meta.ItemMeta;
+import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionEffect;
@@ -246,4 +248,17 @@ public static void removeCrafting(Material material) {
}
}
+ public static List color(ItemStack[] itemStackList, Color color) {
+ List items = new ArrayList<>();
+ for (ItemStack itemStack : itemStackList) {
+ if (itemStack.getType() == Material.LEATHER_BOOTS || itemStack.getType() == Material.LEATHER_CHESTPLATE || itemStack.getType() == Material.LEATHER_HELMET
+ || itemStack.getType() == Material.LEATHER_LEGGINGS) {
+ LeatherArmorMeta meta = (LeatherArmorMeta) itemStack.getItemMeta();
+ meta.setColor(color);
+ itemStack.setItemMeta(meta);
+ }
+ items.add(itemStack);
+ }
+ return items;
+ }
}
diff --git a/src/main/java/me/lrxh/practice/util/PlaceholderUtil.java b/src/main/java/me/lrxh/practice/util/PlaceholderUtil.java
index 443aca8..f723cb4 100644
--- a/src/main/java/me/lrxh/practice/util/PlaceholderUtil.java
+++ b/src/main/java/me/lrxh/practice/util/PlaceholderUtil.java
@@ -66,6 +66,11 @@ public static List format(List lines, Player player) {
line = line.replaceAll("", String.valueOf(match.getGamePlayer(player).getHits()));
line = line.replaceAll("", String.valueOf(match.getGamePlayer(match.getOpponent(player.getUniqueId())).getHits()));
line = line.replaceAll("", getDifference(player));
+
+ if (match.getKit().getGameRules().isBedwars()) {
+ line = line.replaceAll("", match.isBedABroken() ? CC.RED + CC.X : CC.GREEN + CC.CHECKMARK);
+ line = line.replaceAll("", match.isBedBBroken() ? CC.RED + CC.X : CC.GREEN + CC.CHECKMARK);
+ }
}
if (profile.getState() == ProfileState.SPECTATING) {
diff --git a/src/main/java/me/lrxh/practice/util/PlayerUtil.java b/src/main/java/me/lrxh/practice/util/PlayerUtil.java
index 606e26c..49cf52d 100644
--- a/src/main/java/me/lrxh/practice/util/PlayerUtil.java
+++ b/src/main/java/me/lrxh/practice/util/PlayerUtil.java
@@ -1,36 +1,53 @@
package me.lrxh.practice.util;
+import lombok.experimental.UtilityClass;
import me.lrxh.practice.Practice;
import me.lrxh.practice.profile.SpawnTeleportEvent;
import net.minecraft.server.v1_8_R3.MinecraftServer;
+import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityStatus;
import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn;
-import org.bukkit.Bukkit;
-import org.bukkit.GameMode;
-import org.bukkit.Location;
-import org.bukkit.block.Block;
+import org.bukkit.*;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
-import org.bukkit.util.BlockIterator;
import java.lang.reflect.Field;
+import java.util.HashSet;
+import java.util.Set;
import java.util.UUID;
+@UtilityClass
public class PlayerUtil {
- private static Field STATUS_PACKET_ID_FIELD;
- private static Field STATUS_PACKET_STATUS_FIELD;
- private static Field SPAWN_PACKET_ID_FIELD;
+ private Field STATUS_PACKET_ID_FIELD;
+ private Field STATUS_PACKET_STATUS_FIELD;
+ private Field SPAWN_PACKET_ID_FIELD;
- public static void setLastAttacker(Player victim, Player attacker) {
+ static {
+ try {
+ STATUS_PACKET_ID_FIELD = PacketPlayOutEntityStatus.class.getDeclaredField("a");
+ STATUS_PACKET_ID_FIELD.setAccessible(true);
+
+ STATUS_PACKET_STATUS_FIELD = PacketPlayOutEntityStatus.class.getDeclaredField("b");
+ STATUS_PACKET_STATUS_FIELD.setAccessible(true);
+
+ SPAWN_PACKET_ID_FIELD = PacketPlayOutNamedEntitySpawn.class.getDeclaredField("a");
+ SPAWN_PACKET_ID_FIELD.setAccessible(true);
+ } catch (NoSuchFieldException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void setLastAttacker(Player victim, Player attacker) {
victim.setMetadata("lastAttacker", new FixedMetadataValue(Practice.getInstance(), attacker.getUniqueId()));
}
- public static Player getLastAttacker(Player victim) {
+ public Player getLastAttacker(Player victim) {
if (victim.hasMetadata("lastAttacker")) {
return Bukkit.getPlayer((UUID) victim.getMetadata("lastAttacker").get(0).value());
} else {
@@ -38,7 +55,15 @@ public static Player getLastAttacker(Player victim) {
}
}
- public static void reset(Player player) {
+ public ItemStack getPlayerHead(UUID playerUUID) {
+ ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) SkullType.PLAYER.ordinal());
+ SkullMeta skullMeta = (SkullMeta) head.getItemMeta();
+ skullMeta.setOwner(Bukkit.getPlayer(playerUUID).getName());
+ head.setItemMeta(skullMeta);
+ return head;
+ }
+
+ public void reset(Player player) {
if (!player.hasMetadata("frozen")) {
player.setWalkSpeed(0.2F);
@@ -64,7 +89,7 @@ public static void reset(Player player) {
player.updateInventory();
}
- public static void denyMovement(Player player) {
+ public void denyMovement(Player player) {
player.setFlying(false);
player.setWalkSpeed(0.0F);
player.setFoodLevel(0);
@@ -72,7 +97,7 @@ public static void denyMovement(Player player) {
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 200));
}
- public static void allowMovement(Player player) {
+ public void allowMovement(Player player) {
player.setFlying(false);
player.setWalkSpeed(0.2F);
player.setFoodLevel(20);
@@ -80,21 +105,8 @@ public static void allowMovement(Player player) {
player.removePotionEffect(PotionEffectType.JUMP);
}
- public static Block getTargetBlock(Player player, int distance) {
- BlockIterator iterator = new BlockIterator(player, distance);
- Block block = null;
-
- while (iterator.hasNext()) {
- block = iterator.next();
- if (block.getType().isSolid()) {
- break;
- }
- }
-
- return block;
- }
- public static void teleportToSpawn(Player player) {
+ public void teleportToSpawn(Player player) {
Location location = Practice.getInstance().getCache().getSpawn() == null ? Practice.getInstance().getServer().getWorlds().get(0).getSpawnLocation() : Practice.getInstance().getCache().getSpawn();
SpawnTeleportEvent event = new SpawnTeleportEvent(player, location);
@@ -105,43 +117,34 @@ public static void teleportToSpawn(Player player) {
}
}
- public static void animateDeath(Player player) {
+ public void animateDeath(Player player) {
+ int entityId = EntityUtils.getFakeEntityId();
+ PacketPlayOutNamedEntitySpawn spawnPacket = new PacketPlayOutNamedEntitySpawn(((CraftPlayer) player).getHandle());
+ PacketPlayOutEntityStatus statusPacket = new PacketPlayOutEntityStatus();
try {
- if (STATUS_PACKET_ID_FIELD == null) {
- STATUS_PACKET_ID_FIELD = PacketPlayOutEntityStatus.class.getDeclaredField("a");
- STATUS_PACKET_ID_FIELD.setAccessible(true);
- }
-
- if (STATUS_PACKET_STATUS_FIELD == null) {
- STATUS_PACKET_STATUS_FIELD = PacketPlayOutEntityStatus.class.getDeclaredField("b");
- STATUS_PACKET_STATUS_FIELD.setAccessible(true);
- }
-
- if (SPAWN_PACKET_ID_FIELD == null) {
- SPAWN_PACKET_ID_FIELD = PacketPlayOutNamedEntitySpawn.class.getDeclaredField("a");
- SPAWN_PACKET_ID_FIELD.setAccessible(true);
- }
-
- SPAWN_PACKET_ID_FIELD.set(new PacketPlayOutNamedEntitySpawn(((CraftPlayer) player).getHandle()), -1);
- STATUS_PACKET_ID_FIELD.set(new PacketPlayOutEntityStatus(), -1);
- STATUS_PACKET_STATUS_FIELD.set(new PacketPlayOutEntityStatus(), (byte) 3);
-
- final int radius = MinecraftServer.getServer().getPlayerList().d();
-
+ SPAWN_PACKET_ID_FIELD.set(spawnPacket, entityId);
+ STATUS_PACKET_ID_FIELD.set(statusPacket, entityId);
+ STATUS_PACKET_STATUS_FIELD.set(statusPacket, (byte) 3);
+ int radius = MinecraftServer.getServer().getPlayerList().d();
+ Set sentTo = new HashSet<>();
for (Entity entity : player.getNearbyEntities(radius, radius, radius)) {
- if (!(entity instanceof Player)) {
+ if (entity instanceof Player) {
Player watcher = (Player) entity;
-
if (!watcher.getUniqueId().equals(player.getUniqueId())) {
- break;
+ ((CraftPlayer) watcher).getHandle().playerConnection.sendPacket(spawnPacket);
+ ((CraftPlayer) watcher).getHandle().playerConnection.sendPacket(statusPacket);
+ sentTo.add(watcher);
}
-
- ((CraftPlayer) watcher).getHandle().playerConnection.sendPacket(new PacketPlayOutNamedEntitySpawn(((CraftPlayer) player).getHandle()));
- ((CraftPlayer) watcher).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityStatus());
}
}
- } catch (Exception ignored) {
+
+ Bukkit.getScheduler().runTaskLater(Practice.getInstance(), () -> {
+ for (Player watcher : sentTo) {
+ ((CraftPlayer) watcher).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityDestroy(entityId));
+ }
+ }, 100L);
+ } catch (IllegalAccessException ignored) {
}
}
}
diff --git a/src/main/resources/messages.yml b/src/main/resources/messages.yml
index 999cd72..6658b3a 100644
--- a/src/main/resources/messages.yml
+++ b/src/main/resources/messages.yml
@@ -31,14 +31,14 @@ OPTIONS:
MENU_SOUNDS_DISABLED: '&cDisabled Menu sounds!'
SILENT_ENABLED: '&aEnabled Silent Mode!'
SILENT_DISABLED: '&cDisabled Silent Mode!'
- FOLLOW_START: '&bStarted following &f{0}.'
- FOLLOW_END: '&bStopped following &f{0}.'
+ FOLLOW_START: 'Started following &f{0}.'
+ FOLLOW_END: 'Stopped following &f{0}.'
LEADERBOARD:
MESSAGE: '&aLeaderboards Refreshed!'
FOLLOW:
- FOLLOW_START: '&bStarted following &f{0}.'
- FOLLOW_END: '&bStopped following &f{0}.'
- FOLLOWED_LEFT: '&b{0} &left.'
+ FOLLOW_START: 'Started following &f{0}.'
+ FOLLOW_END: 'Stopped following &f{0}.'
+ FOLLOWED_LEFT: '{0} &left.'
PARTY:
HELP:
- '&7&m------------------------------------------------'
@@ -104,14 +104,17 @@ MATCH:
NOW_SPECTATING: {0} &eis now spectating.
NO_LONGER_SPECTATING: {0} &eis no longer spectating.
PLAYING_ARENA: ' '
- START_TIMER: '&fMatch starting in &b{0}&f...'
+ START_TIMER: '&fMatch starting in {0}&f...'
+ RESPAWN_TIMER: '&fRespawning in {0}&f...'
+ RESPAWNED: '&aRespawned!'
+ BED_BROKEN: '{0} Bed &fwas broken by {1}'
STARTED: '&aMatch started!'
WARNING: '&4&lWARNING: &cIrregular clicking methods such as butterfly clicking,
changing your debounce time, and other modifications are strongly discouraged
and may result in a ban, Your debounce time should be 10 ms.'
END_DETAILS:
- '&7&m------------------------------------------------'
- - '&bPost-Match Inventories &7&o&7(Click to view)'
+ - 'Post-Match Inventories &7&o&7(Click to view)'
- '%INVENTORIES%'
- '%ELO_CHANGES%'
- '&7&m------------------------------------------------'
@@ -123,6 +126,7 @@ MATCH:
- '&a{0} +{1} ({2}) &7| &c{3} -{4} ({5})'
PLAYER_KILLED: '&a{1} &7killed &c{0}&7.'
PLAYER_DIED: '{0} &7committed suicide.'
+ PLAYER_FINAL_KILL: '&a{1} &7killed &c{0}&7. &b&lFINAL KILL'
ROUNDS_TO_WIN: ''
REMATCH:
SENT_REQUEST: