Initial commit
This commit is contained in:
commit
84ea3c1928
|
|
@ -0,0 +1,113 @@
|
||||||
|
# User-specific stuff
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
out/
|
||||||
|
|
||||||
|
# Compiled class file
|
||||||
|
*.class
|
||||||
|
|
||||||
|
# Log file
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# BlueJ files
|
||||||
|
*.ctxt
|
||||||
|
|
||||||
|
# Package Files #
|
||||||
|
*.jar
|
||||||
|
*.war
|
||||||
|
*.nar
|
||||||
|
*.ear
|
||||||
|
*.zip
|
||||||
|
*.tar.gz
|
||||||
|
*.rar
|
||||||
|
|
||||||
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||||
|
hs_err_pid*
|
||||||
|
|
||||||
|
*~
|
||||||
|
|
||||||
|
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||||
|
.fuse_hidden*
|
||||||
|
|
||||||
|
# KDE directory preferences
|
||||||
|
.directory
|
||||||
|
|
||||||
|
# Linux trash folder which might appear on any partition or disk
|
||||||
|
.Trash-*
|
||||||
|
|
||||||
|
# .nfs files are created when an open file is removed but is still being accessed
|
||||||
|
.nfs*
|
||||||
|
|
||||||
|
# General
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# Icon must end with two \r
|
||||||
|
Icon
|
||||||
|
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear in the root of a volume
|
||||||
|
.DocumentRevisions-V100
|
||||||
|
.fseventsd
|
||||||
|
.Spotlight-V100
|
||||||
|
.TemporaryItems
|
||||||
|
.Trashes
|
||||||
|
.VolumeIcon.icns
|
||||||
|
.com.apple.timemachine.donotpresent
|
||||||
|
|
||||||
|
# Directories potentially created on remote AFP share
|
||||||
|
.AppleDB
|
||||||
|
.AppleDesktop
|
||||||
|
Network Trash Folder
|
||||||
|
Temporary Items
|
||||||
|
.apdisk
|
||||||
|
|
||||||
|
# Windows thumbnail cache files
|
||||||
|
Thumbs.db
|
||||||
|
Thumbs.db:encryptable
|
||||||
|
ehthumbs.db
|
||||||
|
ehthumbs_vista.db
|
||||||
|
|
||||||
|
# Dump file
|
||||||
|
*.stackdump
|
||||||
|
|
||||||
|
# Folder config file
|
||||||
|
[Dd]esktop.ini
|
||||||
|
|
||||||
|
# Recycle Bin used on file shares
|
||||||
|
$RECYCLE.BIN/
|
||||||
|
|
||||||
|
# Windows Installer files
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msix
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# Windows shortcuts
|
||||||
|
*.lnk
|
||||||
|
|
||||||
|
target/
|
||||||
|
|
||||||
|
pom.xml.tag
|
||||||
|
pom.xml.releaseBackup
|
||||||
|
pom.xml.versionsBackup
|
||||||
|
pom.xml.next
|
||||||
|
|
||||||
|
release.properties
|
||||||
|
dependency-reduced-pom.xml
|
||||||
|
buildNumber.properties
|
||||||
|
.mvn/timing.properties
|
||||||
|
.mvn/wrapper/maven-wrapper.jar
|
||||||
|
.flattened-pom.xml
|
||||||
|
|
||||||
|
# Common working directory
|
||||||
|
run/
|
||||||
|
|
@ -0,0 +1,75 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<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>me.cloud</groupId>
|
||||||
|
<artifactId>smpcore</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>Smpcore</name>
|
||||||
|
|
||||||
|
<description>The core for any SMP you will ever need, ever.</description>
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>9</source>
|
||||||
|
<target>9</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.2.4</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>spigotmc-repo</id>
|
||||||
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>sonatype</id>
|
||||||
|
<url>https://oss.sonatype.org/content/groups/public/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<version>1.18.2-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,167 @@
|
||||||
|
package me.cloud.smpcore;
|
||||||
|
|
||||||
|
import me.cloud.smpcore.commands.*;
|
||||||
|
import me.cloud.smpcore.events.*;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Color;
|
||||||
|
import org.bukkit.Statistic;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public class Plugin extends JavaPlugin {
|
||||||
|
|
||||||
|
private HashMap<UUID, Boolean> sleeping = new HashMap<>();
|
||||||
|
private HashMap<UUID, UUID> messages = new HashMap<>();
|
||||||
|
private ArrayList<UUID> vanished = new ArrayList<>();
|
||||||
|
public FileConfiguration config = getConfig();
|
||||||
|
|
||||||
|
public ChatColor accentColor = ChatColor.valueOf(config.getString("accent_color"));
|
||||||
|
|
||||||
|
public ArrayList<String> motds = (ArrayList<String>) config.getStringList("motds");
|
||||||
|
|
||||||
|
public ArrayList<String> joinMOTD = (ArrayList<String>) config.getStringList("join_motd");
|
||||||
|
|
||||||
|
public String chatPrefix = ChatColor.GRAY + "[" + accentColor + "SMP" + ChatColor.GRAY + "] ";
|
||||||
|
|
||||||
|
public String serverName = config.getString("server_name");
|
||||||
|
|
||||||
|
public boolean isSleeping(UUID uuid) { return sleeping.containsKey(uuid); }
|
||||||
|
|
||||||
|
public void addToMessages(UUID sender, UUID receiver ) { messages.put(sender, receiver); }
|
||||||
|
|
||||||
|
public void addToVanish(UUID uuid) { vanished.add(uuid); }
|
||||||
|
|
||||||
|
public void removeFromVanish(UUID uuid) { vanished.remove(uuid); }
|
||||||
|
|
||||||
|
public ArrayList<UUID> getVanished() { return vanished; }
|
||||||
|
|
||||||
|
public boolean isVanished(UUID uuid) { return vanished.contains(uuid); }
|
||||||
|
|
||||||
|
public void removeFromMessages(UUID sender) { messages.remove(sender); }
|
||||||
|
|
||||||
|
public boolean hasRecipient(UUID sender) {return messages.containsKey(sender); }
|
||||||
|
|
||||||
|
public UUID getRecipient(UUID sender) { return messages.get(sender);}
|
||||||
|
|
||||||
|
public void addToSleeping(UUID uuid, Boolean bool) {
|
||||||
|
sleeping.put(uuid, bool);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeFromSleeping(UUID uuid) {
|
||||||
|
sleeping.remove(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean playersSleeping() {
|
||||||
|
return sleeping.size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String plural(long num, String unit) {
|
||||||
|
return num + " " + unit + (num == 1 ? "" : "s");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reloadConfig() {
|
||||||
|
super.reloadConfig();
|
||||||
|
|
||||||
|
saveDefaultConfig();
|
||||||
|
config = getConfig();
|
||||||
|
config.options().copyDefaults(true);
|
||||||
|
saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String formatDuration(Duration duration) {
|
||||||
|
List<String> parts = new ArrayList<>();
|
||||||
|
long days = duration.toDaysPart();
|
||||||
|
if (days > 0) {
|
||||||
|
parts.add(plural(days, "day"));
|
||||||
|
}
|
||||||
|
int hours = duration.toHoursPart();
|
||||||
|
if (hours > 0 || !parts.isEmpty()) {
|
||||||
|
parts.add(plural(hours, "hour"));
|
||||||
|
}
|
||||||
|
int minutes = duration.toMinutesPart();
|
||||||
|
if (minutes > 0 || !parts.isEmpty()) {
|
||||||
|
parts.add(plural(minutes, "minute"));
|
||||||
|
}
|
||||||
|
int seconds = duration.toSecondsPart();
|
||||||
|
parts.add(plural(seconds, "second"));
|
||||||
|
return String.join(", ", parts);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
getLogger().info("Plugin has been enabled!");
|
||||||
|
getServer().getPluginManager().registerEvents(new PlayerLeave(this), this);
|
||||||
|
getServer().getPluginManager().registerEvents(new PlayerJoin(this), this);
|
||||||
|
getServer().getPluginManager().registerEvents(new PlayerChat(), this);
|
||||||
|
getServer().getPluginManager().registerEvents(new PlayerBedEnter(this), this);
|
||||||
|
getServer().getPluginManager().registerEvents(new PlayerBedExit(this), this);
|
||||||
|
getServer().getPluginManager().registerEvents(new ServerListPing(this), this);
|
||||||
|
getCommand("playtime").setExecutor(new PlaytimeCommand(this));
|
||||||
|
getCommand("ping").setExecutor(new PingCommand(this));
|
||||||
|
getCommand("alert").setExecutor(new AlertCommand(this));
|
||||||
|
getCommand("gms").setExecutor(new GamemodeSurvival(this));
|
||||||
|
getCommand("gma").setExecutor(new GamemodeAdventure(this));
|
||||||
|
getCommand("gmsp").setExecutor(new GamemodeSpectator(this));
|
||||||
|
getCommand("gmc").setExecutor(new GamemodeCreative(this));
|
||||||
|
getCommand("msg").setExecutor(new MsgCommand(this));
|
||||||
|
getCommand("r").setExecutor(new ReplyCommand(this));
|
||||||
|
getCommand("vanish").setExecutor(new VanishCommand(this));
|
||||||
|
getCommand("usage").setExecutor(new UsageCommand(this));
|
||||||
|
getCommand("smpreload").setExecutor(new ReloadCommand(this));
|
||||||
|
getCommand("heal").setExecutor(new HealCommand(this));
|
||||||
|
|
||||||
|
|
||||||
|
getServer().getScheduler().scheduleSyncRepeatingTask(this, () -> {
|
||||||
|
getServer().dispatchCommand(getServer().getConsoleSender(), "save-all");
|
||||||
|
}, 0L, 2000L);
|
||||||
|
|
||||||
|
getServer().getScheduler().scheduleSyncRepeatingTask(this, () -> {
|
||||||
|
int online = 0;
|
||||||
|
if (vanished.size() > 0) {
|
||||||
|
online = Bukkit.getOnlinePlayers().size() - vanished.size();
|
||||||
|
} else {
|
||||||
|
online = Bukkit.getOnlinePlayers().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
DateTimeFormatter format = DateTimeFormatter.ofPattern("h:mm a");
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (Bukkit.getOnlinePlayers().size() == 0) return;
|
||||||
|
if (player.hasPermission("smp.owner") || player.isOp()) {
|
||||||
|
player.setPlayerListName("§8[§cOwner§8] §c" + player.getDisplayName() + "§7 ❘§f ☠ " + player.getStatistic(Statistic.DEATHS));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
player.setPlayerListName(player.getDisplayName() + "§7 ❘§f ☠ " + player.getStatistic(Statistic.DEATHS));
|
||||||
|
}
|
||||||
|
|
||||||
|
player.setPlayerListHeaderFooter(
|
||||||
|
ChatColor.translateAlternateColorCodes('&',
|
||||||
|
"\n &7-- " + accentColor + serverName + " &7-- \n"),
|
||||||
|
ChatColor.translateAlternateColorCodes('&', "\n &7Players online: " + accentColor + online +
|
||||||
|
"\n &7Time: " + accentColor + java.time.LocalTime.now().format(format) + "\n"));
|
||||||
|
}
|
||||||
|
}, 0L, 20L);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
getLogger().info("Plugin has been disabled, goodbye!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package me.cloud.smpcore.commands;
|
||||||
|
|
||||||
|
import me.cloud.smpcore.Plugin;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class AlertCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
private final Plugin plugin;
|
||||||
|
public AlertCommand(Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if (sender != null) {
|
||||||
|
if (args.length > 0) {
|
||||||
|
String message = String.join(" ", args);
|
||||||
|
player.getServer().broadcastMessage(ChatColor.translateAlternateColorCodes('&', "&8[&cAlert&8] &r" + message));
|
||||||
|
for (Player serverPlayer : player.getWorld().getPlayers()) {
|
||||||
|
serverPlayer.playSound(serverPlayer.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1F, 0.5F);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
package me.cloud.smpcore.commands;
|
||||||
|
|
||||||
|
import me.cloud.smpcore.Plugin;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
|
public class GamemodeAdventure implements CommandExecutor {
|
||||||
|
|
||||||
|
private final Plugin plugin;
|
||||||
|
public GamemodeAdventure(Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if (sender != null) {
|
||||||
|
player.setGameMode(GameMode.ADVENTURE);
|
||||||
|
player.sendMessage(plugin.chatPrefix + "Your gamemode has been changed to " + plugin.accentColor + "Adventure");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
package me.cloud.smpcore.commands;
|
||||||
|
|
||||||
|
import me.cloud.smpcore.Plugin;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
|
public class GamemodeCreative implements CommandExecutor {
|
||||||
|
|
||||||
|
private final Plugin plugin;
|
||||||
|
public GamemodeCreative(Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if (sender != null) {
|
||||||
|
player.setGameMode(GameMode.CREATIVE);
|
||||||
|
player.sendMessage(plugin.chatPrefix + "Your gamemode has been changed to " + plugin.accentColor + "Creative");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
package me.cloud.smpcore.commands;
|
||||||
|
|
||||||
|
import me.cloud.smpcore.Plugin;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class GamemodeSpectator implements CommandExecutor {
|
||||||
|
|
||||||
|
private final Plugin plugin;
|
||||||
|
public GamemodeSpectator(Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if (sender != null) {
|
||||||
|
player.setGameMode(GameMode.SPECTATOR);
|
||||||
|
player.sendMessage(plugin.chatPrefix + "Your gamemode has been changed to " + plugin.accentColor + "Spectator");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
package me.cloud.smpcore.commands;
|
||||||
|
|
||||||
|
import me.cloud.smpcore.Plugin;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class GamemodeSurvival implements CommandExecutor {
|
||||||
|
|
||||||
|
private final Plugin plugin;
|
||||||
|
public GamemodeSurvival(Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if (sender != null) {
|
||||||
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
player.sendMessage(plugin.chatPrefix + "Your gamemode has been changed to " + plugin.accentColor + "Survival");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
package me.cloud.smpcore.commands;
|
||||||
|
|
||||||
|
import me.cloud.smpcore.Plugin;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class HealCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
private Plugin plugin;
|
||||||
|
public HealCommand(Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
if (sender != null) {
|
||||||
|
if (args.length > 0) {
|
||||||
|
if (args[0].equals("*")) {
|
||||||
|
plugin.getServer().getOnlinePlayers().forEach(target -> {
|
||||||
|
target.setHealth(20);
|
||||||
|
target.setFoodLevel(20);
|
||||||
|
target.sendMessage(plugin.accentColor + "You have been healed.");
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Healed " + plugin.accentColor + target.getDisplayName());
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Player target = plugin.getServer().getPlayer(args[0]);
|
||||||
|
if (target == null) {
|
||||||
|
player.sendMessage(ChatColor.RED + "That player isn't online!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
target.setHealth(20);
|
||||||
|
target.setFoodLevel(20);
|
||||||
|
target.sendMessage(plugin.accentColor + "You have been healed.");
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Healed " + plugin.accentColor + target.getDisplayName());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
package me.cloud.smpcore.commands;
|
||||||
|
|
||||||
|
import me.cloud.smpcore.Plugin;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class MsgCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
private final Plugin plugin;
|
||||||
|
|
||||||
|
public MsgCommand(Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
if (sender != null) {
|
||||||
|
if (args.length > 0) {
|
||||||
|
Player target = plugin.getServer().getPlayer(args[0]);
|
||||||
|
if (target == null) {
|
||||||
|
player.sendMessage(ChatColor.RED + "That player isn't online!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
String[] formattedMessage = Arrays.copyOfRange(args, 1, args.length);
|
||||||
|
String message = String.join(" ", formattedMessage);
|
||||||
|
player.sendMessage(
|
||||||
|
ChatColor.GRAY + "[" + plugin.accentColor + "you" +ChatColor.GRAY + "-> " + plugin.accentColor + target.getDisplayName() + ChatColor.GRAY + "] " + message
|
||||||
|
);
|
||||||
|
target.sendMessage(
|
||||||
|
ChatColor.GRAY + "[" + plugin.accentColor + player.getDisplayName() + ChatColor.GRAY + "-> " + plugin.accentColor + "you" + ChatColor.GRAY + "] " + message
|
||||||
|
);
|
||||||
|
plugin.addToMessages(player.getUniqueId(), target.getUniqueId());
|
||||||
|
plugin.addToMessages(target.getUniqueId(), player.getUniqueId());
|
||||||
|
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1F, 0.5F);
|
||||||
|
target.playSound(target.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1F, 2F);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
package me.cloud.smpcore.commands;
|
||||||
|
|
||||||
|
import me.cloud.smpcore.Plugin;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
|
public class PingCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
private final Plugin plugin;
|
||||||
|
|
||||||
|
public PingCommand(Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if (sender != null) {
|
||||||
|
player.sendMessage(plugin.chatPrefix + "Your ping is " + plugin.accentColor + player.getPing() + "ms");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
package me.cloud.smpcore.commands;
|
||||||
|
|
||||||
|
import me.cloud.smpcore.Plugin;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Statistic;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
|
public class PlaytimeCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
private final Plugin plugin;
|
||||||
|
|
||||||
|
public PlaytimeCommand(Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("NullableProblems")
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if (sender != null) {
|
||||||
|
long minutesPlayed = player.getStatistic(Statistic.PLAY_ONE_MINUTE);
|
||||||
|
Duration msPlayed = Duration.ofMillis(minutesPlayed * 50);
|
||||||
|
String humanized = plugin.formatDuration(msPlayed);
|
||||||
|
player.sendMessage(plugin.chatPrefix + ChatColor.GRAY + "You have played on the server for " + plugin.accentColor + humanized);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package me.cloud.smpcore.commands;
|
||||||
|
|
||||||
|
import me.cloud.smpcore.Plugin;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public class ReloadCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
private final Plugin plugin;
|
||||||
|
public ReloadCommand(Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
if (sender != null) {
|
||||||
|
try {
|
||||||
|
plugin.reloadConfig();
|
||||||
|
} catch (Exception e){
|
||||||
|
player.sendMessage(ChatColor.RED + "Hey stupid! Check the console, you fucked up.");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
package me.cloud.smpcore.commands;
|
||||||
|
|
||||||
|
import me.cloud.smpcore.Plugin;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
|
public class ReplyCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
private final Plugin plugin;
|
||||||
|
|
||||||
|
public ReplyCommand(Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if (sender != null) {
|
||||||
|
Player target = plugin.getServer().getPlayer(plugin.getRecipient(player.getUniqueId()));
|
||||||
|
|
||||||
|
if (!plugin.hasRecipient(player.getUniqueId())) {
|
||||||
|
player.sendMessage(ChatColor.RED + "You have no one to reply to!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target == null) {
|
||||||
|
player.sendMessage(ChatColor.RED + "That player isn't online!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length > 0) {
|
||||||
|
String message = String.join(" ", args);
|
||||||
|
player.sendMessage(
|
||||||
|
ChatColor.GRAY + "[" + plugin.accentColor + "you" +ChatColor.GRAY + "-> " + plugin.accentColor + target.getDisplayName() + ChatColor.GRAY + "] " + message
|
||||||
|
);
|
||||||
|
target.sendMessage(
|
||||||
|
ChatColor.GRAY + "[" + plugin.accentColor + player.getDisplayName() + ChatColor.GRAY + "-> " + plugin.accentColor + "you" + ChatColor.GRAY + "] " + message
|
||||||
|
);
|
||||||
|
plugin.addToMessages(player.getUniqueId(), target.getUniqueId());
|
||||||
|
plugin.addToMessages(target.getUniqueId(), player.getUniqueId());
|
||||||
|
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1F, 0.5F);
|
||||||
|
target.playSound(target.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1F, 2F);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
package me.cloud.smpcore.commands;
|
||||||
|
|
||||||
|
import me.cloud.smpcore.Plugin;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
|
public class UsageCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
private final Plugin plugin;
|
||||||
|
|
||||||
|
public UsageCommand(Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
float usedMem = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory());
|
||||||
|
float totalMem = Runtime.getRuntime().maxMemory();
|
||||||
|
String fmtUsedMem = Math.round(usedMem / 1048576) + "MB";
|
||||||
|
String fmtTotalMem = Math.round(totalMem / 1048576) + "MB";
|
||||||
|
long currentMs = System.currentTimeMillis();
|
||||||
|
Duration elapsedDuration = Duration.ofMillis(currentMs - plugin.startTime);
|
||||||
|
String fmtElapsed = plugin.formatDuration(elapsedDuration);
|
||||||
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.chatPrefix + "Used Memory: " + plugin.accentColor + fmtUsedMem));
|
||||||
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.chatPrefix + "Total Memory: " + plugin.accentColor + fmtTotalMem));
|
||||||
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.chatPrefix + "Uptime: " + plugin.accentColor + fmtElapsed));
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
package me.cloud.smpcore.commands;
|
||||||
|
|
||||||
|
import me.cloud.smpcore.Plugin;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class VanishCommand implements CommandExecutor {
|
||||||
|
private final Plugin plugin;
|
||||||
|
|
||||||
|
public VanishCommand(Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
if (plugin.isVanished(player.getUniqueId())) {
|
||||||
|
plugin.removeFromVanish(player.getUniqueId());
|
||||||
|
player.sendMessage(plugin.chatPrefix + "You have been" + ChatColor.GREEN + " unvanished");
|
||||||
|
plugin.getServer().broadcastMessage(ChatColor.GRAY + "[" + plugin.accentColor + "+" + ChatColor.GRAY + "] " + plugin.accentColor + player.getDisplayName() + ChatColor.GRAY + " joined the game");
|
||||||
|
|
||||||
|
for (Player serverPlayer : plugin.getServer().getOnlinePlayers()) {
|
||||||
|
serverPlayer.showPlayer(plugin, player);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
plugin.addToVanish(player.getUniqueId());
|
||||||
|
player.sendMessage(plugin.chatPrefix + "You have been" + ChatColor.GREEN + " vanished");
|
||||||
|
plugin.getServer().broadcastMessage(ChatColor.GRAY + "[" + plugin.accentColor + "-" + ChatColor.GRAY + "] " + plugin.accentColor + player.getDisplayName() + ChatColor.GRAY + " left the game");
|
||||||
|
|
||||||
|
for (Player serverPlayer : plugin.getServer().getOnlinePlayers()) {
|
||||||
|
serverPlayer.hidePlayer(plugin, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
package me.cloud.smpcore.events;
|
||||||
|
|
||||||
|
import me.cloud.smpcore.Plugin;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerBedEnterEvent;
|
||||||
|
|
||||||
|
public class PlayerBedEnter implements Listener {
|
||||||
|
|
||||||
|
private final Plugin plugin;
|
||||||
|
|
||||||
|
public PlayerBedEnter(Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBedEnter(PlayerBedEnterEvent event) {
|
||||||
|
if (!event.getBedEnterResult().toString().equals("OK")) return;
|
||||||
|
plugin.getServer().broadcastMessage(plugin.accentColor + event.getPlayer().getDisplayName() + ChatColor.GRAY + " is sleeping! Shh...");
|
||||||
|
if (plugin.playersSleeping()) return;
|
||||||
|
plugin.addToSleeping(event.getPlayer().getUniqueId(), true);
|
||||||
|
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||||
|
if (plugin.isSleeping(event.getPlayer().getUniqueId())) {
|
||||||
|
event.getPlayer().getWorld().setTime(1000);
|
||||||
|
if (event.getPlayer().getWorld().hasStorm()) {
|
||||||
|
event.getPlayer().getWorld().setThundering(false);
|
||||||
|
event.getPlayer().getWorld().setStorm(false);
|
||||||
|
}
|
||||||
|
plugin.removeFromSleeping(event.getPlayer().getUniqueId());
|
||||||
|
|
||||||
|
}
|
||||||
|
}, 80);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
package me.cloud.smpcore.events;
|
||||||
|
|
||||||
|
import me.cloud.smpcore.Plugin;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerBedLeaveEvent;
|
||||||
|
|
||||||
|
public class PlayerBedExit implements Listener {
|
||||||
|
private final Plugin plugin;
|
||||||
|
|
||||||
|
public PlayerBedExit(Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBedExit(PlayerBedLeaveEvent event) {
|
||||||
|
if (plugin.isSleeping(event.getPlayer().getUniqueId())) {
|
||||||
|
plugin.getServer().broadcastMessage(plugin.accentColor + event.getPlayer().getDisplayName() + ChatColor.GRAY + " left their bed, fast forward to day cancelled!");
|
||||||
|
plugin.removeFromSleeping(event.getPlayer().getUniqueId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package me.cloud.smpcore.events;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|
||||||
|
|
||||||
|
public class PlayerChat implements Listener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onChat(AsyncPlayerChatEvent event) {
|
||||||
|
if (event.getPlayer().hasPermission("smp.owner") || event.getPlayer().isOp()) {
|
||||||
|
event.setFormat(ChatColor.translateAlternateColorCodes('&', "&8[&cOwner&8] ") + ChatColor.RED + event.getPlayer().getDisplayName() + ChatColor.WHITE + ": " + event.getMessage());
|
||||||
|
} else {
|
||||||
|
event.setFormat(ChatColor.GRAY + event.getPlayer().getDisplayName() + ": " + ChatColor.WHITE + event.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
package me.cloud.smpcore.events;
|
||||||
|
|
||||||
|
import me.cloud.smpcore.Plugin;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class PlayerJoin implements Listener {
|
||||||
|
|
||||||
|
private final Plugin plugin;
|
||||||
|
|
||||||
|
public PlayerJoin(Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onJoin(PlayerJoinEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (!plugin.isVanished(player.getUniqueId())) {
|
||||||
|
event.setJoinMessage(ChatColor.GRAY + "[" + plugin.accentColor + "+" + ChatColor.GRAY + "] " + plugin.accentColor + event.getPlayer().getDisplayName() + ChatColor.GRAY + " joined the game");
|
||||||
|
} else {
|
||||||
|
event.setJoinMessage("");
|
||||||
|
}
|
||||||
|
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1F, 1F);
|
||||||
|
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||||
|
plugin.joinMOTD.forEach(line -> {
|
||||||
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', line));
|
||||||
|
});
|
||||||
|
}, 5);
|
||||||
|
|
||||||
|
if (plugin.getVanished().size() > 0) {
|
||||||
|
for (UUID uuid : plugin.getVanished()) {
|
||||||
|
Player vanished = plugin.getServer().getPlayer(uuid);
|
||||||
|
for (Player serverPlayer : plugin.getServer().getOnlinePlayers()) {
|
||||||
|
serverPlayer.hidePlayer(plugin, vanished);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.isVanished(player.getUniqueId())) {
|
||||||
|
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||||
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7[" + plugin.accentColor + "SMP" + "&7] You are still &avanished&7!"));
|
||||||
|
player.playSound(player.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1F, 1F);
|
||||||
|
}, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
package me.cloud.smpcore.events;
|
||||||
|
|
||||||
|
import me.cloud.smpcore.Plugin;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
|
public class PlayerLeave implements Listener {
|
||||||
|
|
||||||
|
private final Plugin plugin;
|
||||||
|
|
||||||
|
public PlayerLeave(Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onLeave(PlayerQuitEvent event) {
|
||||||
|
if (!plugin.isVanished(event.getPlayer().getUniqueId())) {
|
||||||
|
event.setQuitMessage(ChatColor.GRAY + "[" + plugin.accentColor + "-" + ChatColor.GRAY + "] " + plugin.accentColor + event.getPlayer().getDisplayName() + ChatColor.GRAY + " left the game");
|
||||||
|
} else {
|
||||||
|
event.setQuitMessage("");
|
||||||
|
}
|
||||||
|
if (plugin.hasRecipient(event.getPlayer().getUniqueId())) {
|
||||||
|
plugin.removeFromMessages(event.getPlayer().getUniqueId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
package me.cloud.smpcore.events;
|
||||||
|
|
||||||
|
import me.cloud.smpcore.Plugin;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.server.ServerListPingEvent;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
|
||||||
|
public class ServerListPing implements Listener {
|
||||||
|
|
||||||
|
private final Plugin plugin;
|
||||||
|
|
||||||
|
public ServerListPing(Plugin plugin) { this.plugin = plugin; }
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onServerListPing(ServerListPingEvent event) {
|
||||||
|
Random generator = new Random();
|
||||||
|
ArrayList<String> motds = plugin.motds;
|
||||||
|
int index = generator.nextInt(motds.size());
|
||||||
|
String motd = motds.get(index);
|
||||||
|
event.setMotd(ChatColor.translateAlternateColorCodes('&', motd.replace("%nl%", "\n")));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
# Config file for SMP Core
|
||||||
|
accent_color: GREEN
|
||||||
|
server_name: "The Default SMP"
|
||||||
|
motds: [
|
||||||
|
"welcome to the smp",
|
||||||
|
"this is a second motd"
|
||||||
|
]
|
||||||
|
|
||||||
|
join_motd: [
|
||||||
|
"this is line one",
|
||||||
|
"this is line two"
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
name: SMPCore
|
||||||
|
version: '${project.version}'
|
||||||
|
main: me.cloud.smpcore.Plugin
|
||||||
|
api-version: 1.18
|
||||||
|
prefix: SMP Core
|
||||||
|
load: STARTUP
|
||||||
|
authors: [ cloudwithax ]
|
||||||
|
description: The core for any SMP you will ever need, ever.
|
||||||
|
|
||||||
|
commands:
|
||||||
|
playtime:
|
||||||
|
description: Shows how much time you played on the server
|
||||||
|
usage: /<command>
|
||||||
|
ping:
|
||||||
|
description: Shows your ping to the server
|
||||||
|
usage: /<command>
|
||||||
|
alert:
|
||||||
|
description: Sends a message to all players on the server
|
||||||
|
permission: smp.owner
|
||||||
|
usage: /<command> [text]
|
||||||
|
gms:
|
||||||
|
description: Alias for /gamemode survival
|
||||||
|
permission: smp.owner
|
||||||
|
usage: /<command>
|
||||||
|
gma:
|
||||||
|
description: Alias for /gamemode adventure
|
||||||
|
permission: smp.owner
|
||||||
|
usage: /<command>
|
||||||
|
gmsp:
|
||||||
|
description: Alias for /gamemode spectator
|
||||||
|
permission: smp.owner
|
||||||
|
usage: /<command>
|
||||||
|
gmc:
|
||||||
|
description: Alias for /gamemode creative
|
||||||
|
permission: smp.owner
|
||||||
|
usage: /<command>
|
||||||
|
msg:
|
||||||
|
description: Messages a player
|
||||||
|
usage: /<command> [player] [message]
|
||||||
|
r:
|
||||||
|
description: Replies to a player
|
||||||
|
usage: /<command> [message]
|
||||||
|
vanish:
|
||||||
|
aliases: [ "v" ]
|
||||||
|
permission: smp.owner
|
||||||
|
description: Toggles vanish mode
|
||||||
|
usage: /<command>
|
||||||
|
usage:
|
||||||
|
permission: smp.owner
|
||||||
|
description: Shows server usage and resources
|
||||||
|
usage: /<command>
|
||||||
|
smpreload:
|
||||||
|
permission: smp.owner
|
||||||
|
description: Reloads the config
|
||||||
|
usage: /<command>
|
||||||
|
heal:
|
||||||
|
permission: smp.owner
|
||||||
|
description: Heals a player or all players using '*'
|
||||||
|
usage: /<command> [player|*]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
smp.owner:
|
||||||
|
description: Allows access to owner-only commands
|
||||||
|
default: op
|
||||||
|
smp.*:
|
||||||
|
description: Base permission for smp
|
||||||
|
default: op
|
||||||
|
children:
|
||||||
|
smp.owner: true
|
||||||
Loading…
Reference in New Issue