Commit 85048e8c authored by Ethan's avatar Ethan 💬
Browse files

init

parents
# 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/
<?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>MMOActionBar</groupId>
<artifactId>MMOActionBar</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>MMOActionBar</name>
<description>Allows for advanced controlling of the action bar.</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>${java.version}</source>
<target>${java.version}</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>
<configuration>
<relocations>
<relocation>
<pattern>net.kyori</pattern>
<shadedPattern>com.ehhthan.libraries</shadedPattern>
</relocation>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>com.ehhthan.libraries</shadedPattern>
</relocation>
</relocations>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<outputDirectory>C:\Users\Ethan\Desktop\TestServer\1.15.2\plugins</outputDirectory>
</configuration>
</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>
<repository>
<id>sonatype-oss</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>minebench-repo</id>
<url>https://repo.minebench.de/</url>
</repository>
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.org/repository/maven-public/</url>
<layout>default</layout>
</repository>
<repository>
<id>jitpack</id>
<url>https://jitpack.io/</url>
</repository>
<repository>
<id>CodeMC</id>
<url>https://repo.codemc.org/repository/maven-public</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.4.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.10.9</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.dmulloy2</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.5.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>1.8</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
package com.ehhthan.mmoactionbar;
import com.ehhthan.mmoactionbar.command.MMOActionBarCommand;
import com.ehhthan.mmoactionbar.manager.ConfigManager;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.Nullable;
import java.util.logging.Level;
public final class MMOActionBar extends JavaPlugin {
private static MMOActionBar plugin;
private ConfigManager configManager;
private BukkitAudiences audience;
public static MMOActionBar getInstance() {
return plugin;
}
@Override
public void onEnable() {
plugin = this;
saveDefaultConfig();
getCommand("mmoactionbar").setExecutor(new MMOActionBarCommand());
final int configVersion = getConfig().contains("config-version", true) ? getConfig().getInt("config-version") : -1;
final int defConfigVersion = getConfig().getDefaults().getInt("config-version");
if (configVersion != defConfigVersion) {
getLogger().warning("You may be using an outdated config.yml!");
getLogger().warning("(Your config version: '" + configVersion + "' | Expected config version: '"
+ defConfigVersion + "')");
}
new Metrics(this, 10321);
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
getLogger().log(Level.INFO, "PlaceholderAPI support detected.");
}
this.audience = BukkitAudiences.create(plugin);
this.configManager = new ConfigManager();
}
public void reload() {
reload(null);
}
public void reload(@Nullable CommandSender sender) {
configManager.reload();
reloadConfig();
if (sender != null)
configManager.sendMessage(sender, "plugin-reloaded", true);
}
public ConfigManager getConfigManager() {
return configManager;
}
public BukkitAudiences getAudience() {
return audience;
}
}
package com.ehhthan.mmoactionbar.command;
import com.ehhthan.mmoactionbar.MMOActionBar;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
public class MMOActionBarCommand implements CommandExecutor, TabCompleter {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (args.length == 0) {
MMOActionBar.getInstance().getConfigManager().sendMessage(sender, "unknown-command", true);
return false;
}
if (args[0].equals("reload")) {
MMOActionBar.getInstance().reload(sender);
return true;
}
MMOActionBar.getInstance().getConfigManager().sendMessage(sender, "unknown-command", true);
return false;
}
@Nullable
@Override
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
if (command.getName().equalsIgnoreCase("mmoactionbar")) {
List<String> list = new ArrayList<>();
if (args.length == 1) {
list.add("reload");
return list;
}
}
return null;
}
}
\ No newline at end of file
package com.ehhthan.mmoactionbar.file;
import com.ehhthan.mmoactionbar.MMOActionBar;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
public class ConfigFile {
private final Plugin plugin;
private final String path, name;
private final FileConfiguration config;
public ConfigFile(String name) {
this(MMOActionBar.getInstance(), "", name);
}
public ConfigFile(Plugin plugin, String name) {
this(plugin, "", name);
}
public ConfigFile(String path, String name) {
this(MMOActionBar.getInstance(), path, name);
}
public ConfigFile(Plugin plugin, String path, String name) {
this.plugin = plugin;
this.path = path;
this.name = name;
config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder() + path, name + ".yml"));
}
public FileConfiguration getConfig() {
return config;
}
public void save() {
try {
config.save(new File(plugin.getDataFolder() + path, name + ".yml"));
} catch (IOException exception) {
MMOActionBar.getInstance().getLogger().log(Level.SEVERE, "Could not save " + name + ".yml: " + exception.getMessage());
}
}
@SuppressWarnings("ResultOfMethodCallIgnored")
public void setup() {
try {
if (!new File(plugin.getDataFolder() + path).exists())
new File(plugin.getDataFolder() + path).mkdir();
if (!new File(plugin.getDataFolder() + path, name + ".yml").exists()) {
new File(plugin.getDataFolder() + path, name + ".yml").createNewFile();
}
} catch (IOException exception) {
MMOActionBar.getInstance().getLogger().log(Level.SEVERE, "Could not generate " + name + ".yml: " + exception.getMessage());
}
}
}
\ No newline at end of file
package com.ehhthan.mmoactionbar.manager;
import com.ehhthan.mmoactionbar.MMOActionBar;
import com.ehhthan.mmoactionbar.file.ConfigFile;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.command.CommandSender;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.logging.Level;
public class ConfigManager {
// cached config files
private ConfigFile language;
public ConfigManager() {
mkdir("language");
// load files with default configuration
for (DefaultFile file : DefaultFile.values())
if (file.isAutomatic())
file.checkFile();
reload();
}
public void reload() {
language = new ConfigFile("/language", "language");
}
public String getMessage(String path) {
return getMessage(path, false);
}
public String getMessage(String path, boolean hasPrefix) {
return LegacyComponentSerializer.legacySection().serialize(getComponentMessage(path, hasPrefix));
}
public Component getComponentMessage(String path) {
return getComponentMessage(path, false);
}
public Component getComponentMessage(String path, boolean hasPrefix) {
String prefix = (hasPrefix) ? language.getConfig().getString("prefix", "") : "";
String found = language.getConfig().getString(path);
return MiniMessage.get().parse(found == null ? "<MNF:" + path + ">" : prefix + found);
}
public void sendMessage(CommandSender sender, String path) {
sendMessage(sender, path, false);
}
public void sendMessage(CommandSender sender, String path, boolean hasPrefix) {
MMOActionBar.getInstance().getAudience().sender(sender).sendMessage(
getComponentMessage(path, hasPrefix));
}
private void mkdir(String path) {
File folder = new File(MMOActionBar.getInstance().getDataFolder() + "/" + path);
if (!folder.exists())
if (!folder.mkdir())
MMOActionBar.getInstance().getLogger().log(Level.WARNING, "Could not create directory!");
}
/*
* all config files that have a default configuration are stored here, they
* get copied into the plugin folder when the plugin enables
*/
public enum DefaultFile {
LANGUAGE("language/language.yml", "language", "language.yml");
private final String folderPath, fileName, resourceName;
/*
* allows to use the checkFile() method while not loading it
* automatically e.g item-types.yml
*/
private final boolean manual;
DefaultFile(String resourceName, String folderPath, String fileName) {
this(resourceName, folderPath, fileName, false);
}
DefaultFile(String resourceName, String folderPath, String fileName, boolean manual) {
this.resourceName = resourceName;
this.folderPath = folderPath;
this.fileName = fileName;
this.manual = manual;
}
public boolean isAutomatic() {
return !manual;
}
public File getFile() {
return new File(MMOActionBar.getInstance().getDataFolder() + (folderPath.equals("") ? "" : "/" + folderPath), fileName);
}
public void checkFile() {
File file = getFile();
if (!file.exists())
try {
Files.copy(MMOActionBar.getInstance().getResource("default/" + resourceName), file.getAbsoluteFile().toPath());
} catch (IOException exception) {
exception.printStackTrace();
}
}
}
}
# Do not touch this.
config-version: 1
\ No newline at end of file
prefix: '<gray>[<blue>MMOActionBar<gray>] '
unknown-command: '<red>Unknown command.'
plugin-reloaded: '<#52c754>Successfully reloaded MMOActionBar!'
\ No newline at end of file
name: MMOActionBar
version: ${project.version}
main: com.ehhthan.mmoactionbar.MMOActionBar
api-version: 1.13
depend: [ ProtocolLib ]
softdepend: [ PlaceholderAPI ]
authors: [ Ehhthan ]
description: Allows for advanced controlling of the action bar.
commands:
mmoactionbar:
description: Main mmoactionbar command.
permission: mmoactionbar.admin
aliases: [mmoab, mab, mmoa, mmbb]
permissions:
mmoactionbar.admin:
description: Access to all mmoactionbar commands.
default: op
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment