commit 35d012cf99b3fdf2280e66098384bb01c8d98f88 Author: Xelara Networks Date: Sat Jun 13 16:52:52 2026 -0400 first add diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..655ce16 --- /dev/null +++ b/pom.xml @@ -0,0 +1,47 @@ + + 4.0.0 + + com.dirtbagmc + DirtJoin + 1.0-SNAPSHOT + jar + + DirtJoin + First join effects plugin for Paper + + + 21 + UTF-8 + + + + + papermc-repo + https://repo.papermc.io/repository/maven-public/ + + + + + + io.papermc.paper + paper-api + 1.21.1-R0.1-SNAPSHOT + provided + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + 21 + + + + + diff --git a/src/main/java/com/dirtbagmc/dirtjoin/DirtJoinPlugin.java b/src/main/java/com/dirtbagmc/dirtjoin/DirtJoinPlugin.java new file mode 100644 index 0000000..2ad762d --- /dev/null +++ b/src/main/java/com/dirtbagmc/dirtjoin/DirtJoinPlugin.java @@ -0,0 +1,277 @@ +package com.dirtbagmc.dirtjoin; + +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.NamespacedKey; +import org.bukkit.Particle; +import org.bukkit.Registry; +import org.bukkit.Sound; +import org.bukkit.SoundCategory; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.command.TabExecutor; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.scheduler.BukkitTask; + +import java.time.Duration; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.UUID; + +public class DirtJoinPlugin extends JavaPlugin implements TabExecutor { + + private final Map activeParticleTasks = new HashMap<>(); + private final LegacyComponentSerializer legacy = LegacyComponentSerializer.legacyAmpersand(); + + @Override + public void onEnable() { + saveDefaultConfig(); + Bukkit.getPluginManager().registerEvents(new FirstJoinListener(this), this); + + if (getCommand("dirtjoin") != null) { + getCommand("dirtjoin").setExecutor(this); + getCommand("dirtjoin").setTabCompleter(this); + } + + getLogger().info("DirtJoin enabled."); + } + + @Override + public void onDisable() { + for (BukkitTask task : activeParticleTasks.values()) { + if (task != null) { + task.cancel(); + } + } + activeParticleTasks.clear(); + } + + public void runFirstJoinEffects(Player player) { + FileConfiguration config = getConfig(); + + if (!config.getBoolean("enabled", true)) { + return; + } + + long delay = config.getLong("delay.join-effect-start-ticks", 20L); + + Bukkit.getScheduler().runTaskLater(this, () -> { + if (!player.isOnline()) { + return; + } + + handleBlindness(player); + handleSound(player); + handleTitle(player); + handleParticles(player); + }, delay); + } + + public void runFirstJoinEffectsNow(Player player) { + FileConfiguration config = getConfig(); + + if (!config.getBoolean("enabled", true)) { + return; + } + + if (!player.isOnline()) { + return; + } + + handleBlindness(player); + handleSound(player); + handleTitle(player); + handleParticles(player); + } + + private void handleBlindness(Player player) { + FileConfiguration config = getConfig(); + if (!config.getBoolean("blindness.enabled", true)) { + return; + } + + int duration = config.getInt("blindness.duration-ticks", 40); + int amplifier = config.getInt("blindness.amplifier", 0); + boolean ambient = config.getBoolean("blindness.ambient", false); + boolean particles = config.getBoolean("blindness.particles", false); + boolean icon = config.getBoolean("blindness.icon", false); + + player.addPotionEffect(new PotionEffect( + PotionEffectType.BLINDNESS, + duration, + amplifier, + ambient, + particles, + icon + )); + } + + private void handleSound(Player player) { + FileConfiguration config = getConfig(); + if (!config.getBoolean("sound.enabled", true)) { + return; + } + + String soundName = config.getString("sound.name", "entity.ender_dragon.death"); + float volume = (float) config.getDouble("sound.volume", 0.7); + float pitch = (float) config.getDouble("sound.pitch", 1.2); + + try { + Sound sound = Registry.SOUNDS.get(NamespacedKey.minecraft(soundName.toLowerCase(Locale.ROOT))); + if (sound != null) { + player.playSound(player.getLocation(), sound, SoundCategory.MASTER, volume, pitch); + } else { + player.playSound(player.getLocation(), soundName, SoundCategory.MASTER, volume, pitch); + } + } catch (Exception ex) { + getLogger().warning("Invalid sound in config: " + soundName); + } + } + + private void handleTitle(Player player) { + FileConfiguration config = getConfig(); + if (!config.getBoolean("title.enabled", true)) { + return; + } + + int fadeIn = config.getInt("title.fade-in-ticks", 10); + int stay = config.getInt("title.stay-ticks", 40); + int fadeOut = config.getInt("title.fade-out-ticks", 10); + + String main = config.getString("title.main", "&6Welcome to Dirtbag MC"); + String sub = config.getString("title.sub", "&eStart Your Grind"); + + player.showTitle(net.kyori.adventure.title.Title.title( + legacy.deserialize(main), + legacy.deserialize(sub), + net.kyori.adventure.title.Title.Times.times( + Duration.ofMillis(fadeIn * 50L), + Duration.ofMillis(stay * 50L), + Duration.ofMillis(fadeOut * 50L) + ) + )); + } + + private void handleParticles(Player player) { + FileConfiguration config = getConfig(); + if (!config.getBoolean("particles.enabled", true)) { + return; + } + + final Particle particle; + try { + particle = Particle.valueOf(config.getString("particles.type", "PORTAL").toUpperCase(Locale.ROOT)); + } catch (Exception ex) { + getLogger().warning("Invalid particle in config. Using PORTAL."); + return; + } + + int durationTicks = config.getInt("particles.duration-ticks", 60); + long intervalTicks = config.getLong("particles.interval-ticks", 5L); + int count = config.getInt("particles.count-per-burst", 40); + double offsetX = config.getDouble("particles.offset-x", 1.0); + double offsetY = config.getDouble("particles.offset-y", 1.0); + double offsetZ = config.getDouble("particles.offset-z", 1.0); + double extra = config.getDouble("particles.extra", 0.2); + + UUID uuid = player.getUniqueId(); + + BukkitTask oldTask = activeParticleTasks.remove(uuid); + if (oldTask != null) { + oldTask.cancel(); + } + + long repeats = Math.max(1L, durationTicks / Math.max(1L, intervalTicks)); + final long[] ran = {0}; + + BukkitTask task = Bukkit.getScheduler().runTaskTimer(this, () -> { + if (!player.isOnline()) { + BukkitTask active = activeParticleTasks.remove(uuid); + if (active != null) { + active.cancel(); + } + return; + } + + Location loc = player.getLocation().clone().add(0, 1, 0); + player.getWorld().spawnParticle(particle, loc, count, offsetX, offsetY, offsetZ, extra); + + ran[0]++; + if (ran[0] >= repeats) { + BukkitTask active = activeParticleTasks.remove(uuid); + if (active != null) { + active.cancel(); + } + } + }, 0L, intervalTicks); + + activeParticleTasks.put(uuid, task); + } + + public Component color(String text) { + return legacy.deserialize(text == null ? "" : text); + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (args.length == 0) { + sender.sendMessage(color("&eUsage: /dirtjoin ")); + return true; + } + + if (args[0].equalsIgnoreCase("reload")) { + if (!sender.hasPermission("dirtjoin.reload")) { + sender.sendMessage(color(getConfig().getString("messages.no-permission", "&cYou do not have permission."))); + return true; + } + + reloadConfig(); + sender.sendMessage(color(getConfig().getString("messages.reloaded", "&aDirtJoin config reloaded."))); + return true; + } + + if (args[0].equalsIgnoreCase("test")) { + if (!sender.hasPermission("dirtjoin.test")) { + sender.sendMessage(color(getConfig().getString("messages.no-permission", "&cYou do not have permission."))); + return true; + } + + if (!(sender instanceof Player player)) { + sender.sendMessage(color("&cOnly players can use /dirtjoin test.")); + return true; + } + + runFirstJoinEffectsNow(player); + sender.sendMessage(color("&aTriggered DirtJoin effects on yourself.")); + return true; + } + + sender.sendMessage(color("&eUsage: /dirtjoin ")); + return true; + } + + @Override + public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + List completions = new ArrayList<>(); + + if (args.length == 1) { + if ("reload".startsWith(args[0].toLowerCase(Locale.ROOT))) { + completions.add("reload"); + } + if ("test".startsWith(args[0].toLowerCase(Locale.ROOT))) { + completions.add("test"); + } + } + + return completions; + } +} diff --git a/src/main/java/com/dirtbagmc/dirtjoin/FirstJoinListener.java b/src/main/java/com/dirtbagmc/dirtjoin/FirstJoinListener.java new file mode 100644 index 0000000..68b6fc1 --- /dev/null +++ b/src/main/java/com/dirtbagmc/dirtjoin/FirstJoinListener.java @@ -0,0 +1,30 @@ +package com.dirtbagmc.dirtjoin; + +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; + +public class FirstJoinListener implements Listener { + + private final DirtJoinPlugin plugin; + + public FirstJoinListener(DirtJoinPlugin plugin) { + this.plugin = plugin; + } + + @EventHandler + public void onJoin(PlayerJoinEvent event) { + Player player = event.getPlayer(); + FileConfiguration config = plugin.getConfig(); + + boolean firstJoinOnly = config.getBoolean("first-join-only", true); + + if (firstJoinOnly && player.hasPlayedBefore()) { + return; + } + + plugin.runFirstJoinEffects(player); + } +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml new file mode 100644 index 0000000..e70d9a7 --- /dev/null +++ b/src/main/resources/config.yml @@ -0,0 +1,43 @@ +enabled: true + +first-join-only: true + +title: + enabled: true + fade-in-ticks: 10 + stay-ticks: 40 + fade-out-ticks: 10 + main: "&6Welcome to Dirtbag MC" + sub: "&eStart Your Grind" + +blindness: + enabled: true + duration-ticks: 40 + amplifier: 0 + ambient: false + particles: false + icon: false + +sound: + enabled: true + name: "entity.ender_dragon.death" + volume: 0.7 + pitch: 1.2 + +particles: + enabled: true + type: "portal" + duration-ticks: 60 + interval-ticks: 5 + count-per-burst: 40 + offset-x: 1.0 + offset-y: 1.0 + offset-z: 1.0 + extra: 0.2 + +delay: + join-effect-start-ticks: 20 + +messages: + no-permission: "&cYou do not have permission." + reloaded: "&aDirtJoin config reloaded." diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml new file mode 100644 index 0000000..59c61da --- /dev/null +++ b/src/main/resources/plugin.yml @@ -0,0 +1,23 @@ +name: DirtJoin +version: 1.0-SNAPSHOT +main: com.dirtbagmc.dirtjoin.DirtJoinPlugin +api-version: '1.21' +author: DirtbagMC +description: First join effects plugin + +commands: + dirtjoin: + description: Main DirtJoin command + usage: /dirtjoin + permission: dirtjoin.use + +permissions: + dirtjoin.use: + description: Allows use of DirtJoin commands + default: op + dirtjoin.reload: + description: Allows reloading DirtJoin config + default: op + dirtjoin.test: + description: Allows testing DirtJoin effects + default: op diff --git a/target/DirtJoin-1.0-SNAPSHOT.jar b/target/DirtJoin-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..458f226 Binary files /dev/null and b/target/DirtJoin-1.0-SNAPSHOT.jar differ diff --git a/target/classes/com/dirtbagmc/dirtjoin/DirtJoinPlugin.class b/target/classes/com/dirtbagmc/dirtjoin/DirtJoinPlugin.class new file mode 100644 index 0000000..304c19e Binary files /dev/null and b/target/classes/com/dirtbagmc/dirtjoin/DirtJoinPlugin.class differ diff --git a/target/classes/com/dirtbagmc/dirtjoin/FirstJoinListener.class b/target/classes/com/dirtbagmc/dirtjoin/FirstJoinListener.class new file mode 100644 index 0000000..a43b4bf Binary files /dev/null and b/target/classes/com/dirtbagmc/dirtjoin/FirstJoinListener.class differ diff --git a/target/classes/config.yml b/target/classes/config.yml new file mode 100644 index 0000000..e70d9a7 --- /dev/null +++ b/target/classes/config.yml @@ -0,0 +1,43 @@ +enabled: true + +first-join-only: true + +title: + enabled: true + fade-in-ticks: 10 + stay-ticks: 40 + fade-out-ticks: 10 + main: "&6Welcome to Dirtbag MC" + sub: "&eStart Your Grind" + +blindness: + enabled: true + duration-ticks: 40 + amplifier: 0 + ambient: false + particles: false + icon: false + +sound: + enabled: true + name: "entity.ender_dragon.death" + volume: 0.7 + pitch: 1.2 + +particles: + enabled: true + type: "portal" + duration-ticks: 60 + interval-ticks: 5 + count-per-burst: 40 + offset-x: 1.0 + offset-y: 1.0 + offset-z: 1.0 + extra: 0.2 + +delay: + join-effect-start-ticks: 20 + +messages: + no-permission: "&cYou do not have permission." + reloaded: "&aDirtJoin config reloaded." diff --git a/target/classes/plugin.yml b/target/classes/plugin.yml new file mode 100644 index 0000000..59c61da --- /dev/null +++ b/target/classes/plugin.yml @@ -0,0 +1,23 @@ +name: DirtJoin +version: 1.0-SNAPSHOT +main: com.dirtbagmc.dirtjoin.DirtJoinPlugin +api-version: '1.21' +author: DirtbagMC +description: First join effects plugin + +commands: + dirtjoin: + description: Main DirtJoin command + usage: /dirtjoin + permission: dirtjoin.use + +permissions: + dirtjoin.use: + description: Allows use of DirtJoin commands + default: op + dirtjoin.reload: + description: Allows reloading DirtJoin config + default: op + dirtjoin.test: + description: Allows testing DirtJoin effects + default: op diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties new file mode 100644 index 0000000..eebaa96 --- /dev/null +++ b/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Sat Jun 13 16:41:36 EDT 2026 +artifactId=DirtJoin +groupId=com.dirtbagmc +version=1.0-SNAPSHOT diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..43c1899 --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,2 @@ +com/dirtbagmc/dirtjoin/FirstJoinListener.class +com/dirtbagmc/dirtjoin/DirtJoinPlugin.class diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..18808bb --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,2 @@ +/home/bitnix/Desktop/DirtJoin/src/main/java/com/dirtbagmc/dirtjoin/DirtJoinPlugin.java +/home/bitnix/Desktop/DirtJoin/src/main/java/com/dirtbagmc/dirtjoin/FirstJoinListener.java