diff --git a/src/main/java/de/fanta/challenges/challenges/OreBattle.java b/src/main/java/de/fanta/challenges/challenges/OreBattle.java index 718fb21..0568d25 100644 --- a/src/main/java/de/fanta/challenges/challenges/OreBattle.java +++ b/src/main/java/de/fanta/challenges/challenges/OreBattle.java @@ -8,11 +8,11 @@ import de.fanta.challenges.utils.ChatUtil; import de.fanta.challenges.utils.guiutils.GUIUtils; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -42,22 +42,22 @@ public void onActivation(TimerChangedEvent event) { if (Objects.equals(plugin.getConfig().getString("event.type"), "orebattle")) { if (event.isRunning()) { - blocklist.put(Material.EMERALD_ORE, 25); - blocklist.put(Material.DEEPSLATE_EMERALD_ORE, 20); - blocklist.put(Material.DIAMOND_ORE, 100); + blocklist.put(Material.EMERALD_ORE, 100); + blocklist.put(Material.DEEPSLATE_EMERALD_ORE, 100); + blocklist.put(Material.DIAMOND_ORE, 72); blocklist.put(Material.DEEPSLATE_DIAMOND_ORE, 45); blocklist.put(Material.GOLD_ORE, 2); - blocklist.put(Material.DEEPSLATE_GOLD_ORE, 10); - blocklist.put(Material.IRON_ORE, 2); - blocklist.put(Material.DEEPSLATE_IRON_ORE, 10); + blocklist.put(Material.DEEPSLATE_GOLD_ORE, 11); + blocklist.put(Material.IRON_ORE, 4); + blocklist.put(Material.DEEPSLATE_IRON_ORE, 15); blocklist.put(Material.COPPER_ORE, 1); - blocklist.put(Material.DEEPSLATE_COPPER_ORE, 10); - blocklist.put(Material.REDSTONE_ORE, 5); - blocklist.put(Material.DEEPSLATE_REDSTONE_ORE, 1); - blocklist.put(Material.COAL_ORE, 2); - blocklist.put(Material.DEEPSLATE_COAL_ORE, 20); - blocklist.put(Material.LAPIS_ORE, 3); - blocklist.put(Material.DEEPSLATE_LAPIS_ORE, 3); + blocklist.put(Material.DEEPSLATE_COPPER_ORE, 36); + blocklist.put(Material.REDSTONE_ORE, 43); + blocklist.put(Material.DEEPSLATE_REDSTONE_ORE, 7); + blocklist.put(Material.COAL_ORE, 1); + blocklist.put(Material.DEEPSLATE_COAL_ORE, 93); + blocklist.put(Material.LAPIS_ORE, 33); + blocklist.put(Material.DEEPSLATE_LAPIS_ORE, 22); for (Player pp : Bukkit.getOnlinePlayers()) { ItemStack pickaxe = new ItemStack(Material.NETHERITE_PICKAXE, 1); @@ -71,13 +71,13 @@ if (TeamUtils.getPlayerTeam(pp) != null) { pp.getInventory().addItem(new ItemStack(Material.NETHERITE_SWORD)); pp.getInventory().addItem(pickaxe); - pp.getInventory().addItem(new ItemStack(Material.COOKED_BEEF ,32)); + pp.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 32)); } } else { if (pp.getGameMode() == GameMode.SURVIVAL) { pp.getInventory().addItem(new ItemStack(Material.NETHERITE_SWORD)); pp.getInventory().addItem(pickaxe); - pp.getInventory().addItem(new ItemStack(Material.COOKED_BEEF ,32)); + pp.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 32)); } } } @@ -103,7 +103,9 @@ GUIUtils.sendTitleToAll("Event", "Team " + team.getChatColor() + team.getName() + ChatUtil.GREEN + " gewinnt mit " + ChatUtil.BLUE + maxEntry.getValue() + ChatUtil.GREEN + " Punkten", ChatUtil.GREEN); String[] lines = {"", "", "", " " + ChatUtil.BLUE + "Team " + team.getChatColor() + team.getName(), ChatUtil.GREEN + " hat " + maxEntry.getValue() + " Punkte und", ChatUtil.GREEN + " hat damit gewonnen!", "", ""}; for (OfflinePlayer pp : TeamUtils.getPlayersInTeam(team)) - ChatSkull.sendAll((Player) pp, lines); + if (pp.isOnline()) { + ChatSkull.sendAll((Player) pp, lines); + } } } @@ -120,6 +122,7 @@ } else { plugin.getScoreManager().updateTeamScore(e.getPlayer(), blocklist.get(e.getBlock().getType())); } + ChatUtil.sendTitleToAll("", ChatColor.BLUE + new ItemStack(e.getBlock().getType()).getI18NDisplayName() + ChatColor.GREEN + " +" + blocklist.get(e.getBlock().getType()), ChatUtil.GREEN, 3, 20, 3, false); } } } @@ -133,6 +136,7 @@ } else { plugin.getScoreManager().updateTeamScore(e.getPlayer(), -blocklist.get(e.getBlock().getType())); } + ChatUtil.sendTitleToAll("", ChatColor.BLUE + new ItemStack(e.getBlock().getType()).getI18NDisplayName() + ChatColor.RED + " -" + blocklist.get(e.getBlock().getType()), ChatUtil.GREEN, 3, 20, 3, false); } } } diff --git a/src/main/java/de/fanta/challenges/teams/TeamListener.java b/src/main/java/de/fanta/challenges/teams/TeamListener.java index 810a910..9f9b5f5 100644 --- a/src/main/java/de/fanta/challenges/teams/TeamListener.java +++ b/src/main/java/de/fanta/challenges/teams/TeamListener.java @@ -3,7 +3,9 @@ import de.fanta.challenges.Challenges; import de.fanta.challenges.guis.eventgui.TeamSelectGUI; import de.fanta.challenges.utils.ChatUtil; +import org.bukkit.Bukkit; import org.bukkit.GameMode; +import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -17,6 +19,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerSwapHandItemsEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; @@ -121,6 +124,9 @@ if (TeamUtils.getPlayerTeam(e.getPlayer()) == null) { if (playerTeams.containsKey(e.getPlayer().getUniqueId())) { TeamUtils.selectTeam(e.getPlayer(), playerTeams.get(e.getPlayer().getUniqueId())); + if (TeamUtils.getPlayerTeam(e.getPlayer()) != null && TeamUtils.getPlayerTeam(e.getPlayer()).getSpawn() != null) { + e.getPlayer().teleport(TeamUtils.getPlayerTeam(e.getPlayer()).getSpawn()); + } } else { TeamUtils.setAllPlayerWithoutTeamToTeam(); plugin.getScoreManager().updateTeamScore(e.getPlayer(), 0); @@ -131,6 +137,26 @@ } @EventHandler + public void onDeath(PlayerRespawnEvent e) { + Player p = e.getPlayer(); + + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> { + ChallengeTeam team = TeamUtils.getPlayerTeam(p); + if (team == null) { + return; + } + + Location location = team.getSpawn(); + + if (location == null) { + return; + } + + p.teleport(location); + }, 1L); + } + + @EventHandler public void onLogin(PlayerLoginEvent e) { if (plugin.getConfig().getBoolean("event.teams") && !plugin.getConfig().getBoolean("event.autoteams") && plugin.getTimer().isRunning()) { if (e.getPlayer().hasPermission("challenges.event")) { diff --git a/src/main/java/de/fanta/challenges/utils/ChatUtil.java b/src/main/java/de/fanta/challenges/utils/ChatUtil.java index 1dfae39..cf3a5ca 100644 --- a/src/main/java/de/fanta/challenges/utils/ChatUtil.java +++ b/src/main/java/de/fanta/challenges/utils/ChatUtil.java @@ -4,6 +4,7 @@ import de.iani.cubesideutils.bukkit.ChatUtilBukkit; import net.md_5.bungee.api.ChatColor; import org.bukkit.Bukkit; +import org.bukkit.Sound; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -47,4 +48,13 @@ sendMessage(player, GREEN.toString(), messageParts); } } + + public static void sendTitleToAll(String headline, String text, ChatColor textColor, int in, int time, int out, boolean pling) { + for (Player p : Bukkit.getOnlinePlayers()) { + p.sendTitle(ChatUtil.BLUE + headline, textColor + text, in, time, out); + if (pling) { + p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1.0F, 2.0F); + } + } + } } diff --git a/src/main/java/de/fanta/challenges/utils/guiutils/GUIUtils.java b/src/main/java/de/fanta/challenges/utils/guiutils/GUIUtils.java index dd0d9bc..4df3fc6 100644 --- a/src/main/java/de/fanta/challenges/utils/guiutils/GUIUtils.java +++ b/src/main/java/de/fanta/challenges/utils/guiutils/GUIUtils.java @@ -38,10 +38,7 @@ } public static void sendTitleToAll(String headline, String text, ChatColor textColor) { - for (Player p : Bukkit.getOnlinePlayers()) { - p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1.0F, 2.0F); - p.sendTitle(ChatUtil.BLUE + headline, textColor + text, 10, 60, 10); - } + ChatUtil.sendTitleToAll(headline, text, textColor, 10, 60, 10, true); } public static void setConfig(String path, Object value) {