diff --git a/src/main/java/dev/plex/command/impl/PlexCMD.java b/src/main/java/dev/plex/command/impl/PlexCMD.java index f9da571..b23e3fc 100644 --- a/src/main/java/dev/plex/command/impl/PlexCMD.java +++ b/src/main/java/dev/plex/command/impl/PlexCMD.java @@ -17,10 +17,8 @@ import java.util.stream.Collectors; import dev.plex.util.PlexLog; import dev.plex.util.PlexUtils; import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.minimessage.MiniMessage; import org.apache.commons.lang.StringUtils; import org.bukkit.command.CommandSender; -import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/dev/plex/listener/impl/SpawnListener.java b/src/main/java/dev/plex/listener/impl/SpawnListener.java index a6356b0..e3d2b25 100644 --- a/src/main/java/dev/plex/listener/impl/SpawnListener.java +++ b/src/main/java/dev/plex/listener/impl/SpawnListener.java @@ -18,6 +18,7 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import java.util.Arrays; +import java.util.Collection; import java.util.List; public class SpawnListener extends PlexListener @@ -31,10 +32,8 @@ public class SpawnListener extends PlexListener { event.setCancelled(true); Location location = event.getLocation(); - for (Player player : location.getNearbyEntitiesByType(Player.class, 10)) - { - PlexUtils.disabledEffect(player, location); - } + Collection coll = location.getNearbyEntitiesByType(Player.class, 10); + PlexUtils.disabledEffectMultiple(coll.toArray(new Player[coll.size()]), location); // dont let intellij auto correct toArray to an empty array (for efficiency) } } diff --git a/src/main/java/dev/plex/util/PlexUtils.java b/src/main/java/dev/plex/util/PlexUtils.java index a410a78..04d3360 100644 --- a/src/main/java/dev/plex/util/PlexUtils.java +++ b/src/main/java/dev/plex/util/PlexUtils.java @@ -74,6 +74,15 @@ public class PlexUtils extends PlexBase player.playSound(location, org.bukkit.Sound.BLOCK_FIRE_EXTINGUISH, 0.5f, 0.5f); } + public static void disabledEffectMultiple(Player[] players, Location location) + { + Particle.CLOUD.builder().location(location).receivers(players).extra(0).offset(0.5,0.5,0.5).count(5).spawn(); + Particle.FLAME.builder().location(location).receivers(players).extra(0).offset(0.5,0.5,0.5).count(3).spawn(); + Particle.SOUL_FIRE_FLAME.builder().location(location).receivers(players).offset(0.5,0.5,0.5).extra(0).count(2).spawn(); + // note that the sound is played to everyone who is close enough to hear it + players[0].getWorld().playSound(location, org.bukkit.Sound.BLOCK_FIRE_EXTINGUISH, 0.5f, 0.5f); + } + public static ChatColor randomChatColor() { return CHAT_COLOR_POOL.get(RANDOM.nextInt(CHAT_COLOR_POOL.size())); diff --git a/src/main/java/dev/plex/util/UpdateChecker.java b/src/main/java/dev/plex/util/UpdateChecker.java index 01da09d..610ab4a 100644 --- a/src/main/java/dev/plex/util/UpdateChecker.java +++ b/src/main/java/dev/plex/util/UpdateChecker.java @@ -8,6 +8,7 @@ import dev.plex.Plex; import dev.plex.PlexBase; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.minimessage.MiniMessage; import org.apache.commons.io.FileUtils; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpGet; @@ -135,6 +136,23 @@ public class UpdateChecker extends PlexBase } public void updateJar() + { + updateJar(null); + } + + private void sendOrLog(CommandSender sender, String message) + { + if (sender == null) + { + PlexLog.log(message); + } + else + { + sender.sendMessage(MiniMessage.miniMessage().deserialize(message)); + } + } + + public void updateJar(CommandSender sender) { CloseableHttpClient client = HttpClients.createDefault(); HttpGet get = new HttpGet(DOWNLOAD_PAGE + "job/master/lastSuccessfulBuild/api/json"); @@ -144,7 +162,7 @@ public class UpdateChecker extends PlexBase JSONObject object = new JSONObject(EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8)); JSONObject artifact = object.getJSONArray("artifacts").getJSONObject(0); String name = artifact.getString("fileName"); - PlexLog.log("Downloading latest Plex jar file: " + name); + sendOrLog(sender, "Downloading latest Plex jar file: " + name); CompletableFuture.runAsync(() -> { try @@ -153,7 +171,7 @@ public class UpdateChecker extends PlexBase new URL(DOWNLOAD_PAGE + "job/master/lastSuccessfulBuild/artifact/build/libs/" + name), new File(Bukkit.getUpdateFolderFile(), name) ); - PlexLog.log("Saved new jar. Please restart your server."); + sendOrLog(sender, "Saved new jar. Please restart your server."); } catch (IOException e) {