first add

This commit is contained in:
2026-06-13 16:52:52 -04:00
commit 35d012cf99
14 changed files with 495 additions and 0 deletions
View File
+47
View File
@@ -0,0 +1,47 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.dirtbagmc</groupId>
<artifactId>DirtJoin</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>DirtJoin</name>
<description>First join effects plugin for Paper</description>
<properties>
<maven.compiler.release>21</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>papermc-repo</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.21.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<release>21</release>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -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<UUID, BukkitTask> 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 <reload|test>"));
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 <reload|test>"));
return true;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
List<String> 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;
}
}
@@ -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);
}
}
+43
View File
@@ -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."
+23
View File
@@ -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 <reload|test>
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
Binary file not shown.
+43
View File
@@ -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."
+23
View File
@@ -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 <reload|test>
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
+5
View File
@@ -0,0 +1,5 @@
#Generated by Maven
#Sat Jun 13 16:41:36 EDT 2026
artifactId=DirtJoin
groupId=com.dirtbagmc
version=1.0-SNAPSHOT
@@ -0,0 +1,2 @@
com/dirtbagmc/dirtjoin/FirstJoinListener.class
com/dirtbagmc/dirtjoin/DirtJoinPlugin.class
@@ -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