Skip to content

Commit

Permalink
Merge pull request #21 from Oribuin/v1.2.0
Browse files Browse the repository at this point in the history
v1.2.0
  • Loading branch information
Oribuin authored Apr 4, 2023
2 parents 3e318c4 + c6f9f25 commit 2d98fe0
Show file tree
Hide file tree
Showing 62 changed files with 3,650 additions and 1,627 deletions.
49 changes: 28 additions & 21 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,60 +1,67 @@
import org.apache.tools.ant.filters.ReplaceTokens

plugins {
id "java"
id "java-library"
id "com.github.johnrengelman.shadow" version "7.1.0"
id "maven-publish"
}

group "xyz.oribuin"
version "1.1.10"
version "1.2.0-SNAPSHOT"

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

compileJava {
options.encoding = 'UTF-8'
options.compilerArgs += ['-parameters']
options.fork = true
options.encoding = 'UTF-8'
}

repositories {
mavenCentral()
mavenLocal()

maven { url "https://libraries.minecraft.net" }
maven { url "https://repo.papermc.io/repository/maven-public/" }
maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" }
maven { url "https://repo.rosewooddev.io/repository/public/" }
maven { url "https://repo.extendedclip.com/content/repositories/placeholderapi/" }
maven { url "https://repo.codemc.org/repository/maven-public/" }
maven { url "https://jitpack.io" }

maven { url "https://repo.mattstudios.me/artifactory/public/" }
maven { url = "https://libraries.minecraft.net" }
maven { url = "https://repo.papermc.io/repository/maven-public/" }
maven { url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" }
maven { url = "https://repo.rosewooddev.io/repository/public/" }
maven { url = "https://repo.extendedclip.com/content/repositories/placeholderapi/" }
maven { url = "https://repo.codemc.org/repository/maven-public/" }
maven { url = "https://jitpack.io" }
maven { url = "https://repo.mattstudios.me/artifactory/public/" }

}

dependencies {
// General Dependencies
compileOnly 'org.spigotmc:spigot-api:1.19.2-R0.1-SNAPSHOT'
compileOnly 'me.clip:placeholderapi:2.10.9'
compileOnly 'io.papermc.paper:paper-api:1.19.3-R0.1-SNAPSHOT'
compileOnly 'org.jetbrains:annotations:23.0.0'
compileOnly 'com.mojang:authlib:1.5.21'

// Plugins
compileOnly 'com.github.MilkBowl:VaultAPI:1.7'
compileOnly 'me.clip:placeholderapi:2.11.3'
compileOnly "com.github.oraxen:oraxen:afc4903680"
compileOnly 'com.arcaniax:HeadDatabase-API:1.3.1', {
exclude group: 'org.spigotmc'
}

// Mojang dependencies
compileOnly 'com.mojang:authlib:1.5.21'

// Frameworks & APIs
implementation "dev.rosewood:rosegarden:1.1.0.48-SNAPSHOT"
implementation('dev.triumphteam:triumph-gui:3.1.4') { // https://mf.mattstudios.me/triumph-gui/introduction
api "dev.rosewood:rosegarden:1.2.1"
api('dev.triumphteam:triumph-gui:3.1.4') { // https://mf.mattstudios.me/triumph-gui/introduction
exclude group: "com.google.code.gson", module: "gson" // Remove GSON, Already included in spigot api
}
}


shadowJar {
archiveClassifier.set(null)
minimize {
exclude(dependency("dev.rosewood:rosegarden:.*"))
}

relocate("dev.rosewood.rosegarden", "${project.group}.eternaltags.libs.rosegarden")
relocate("dev.triumphteam.gui", "${project.group}.eternaltags.libs.gui")
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/xyz/oribuin/eternaltags/EternalAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
import xyz.oribuin.eternaltags.manager.TagsManager;
import xyz.oribuin.eternaltags.obj.Category;
import xyz.oribuin.eternaltags.obj.Tag;

import java.util.UUID;
Expand Down Expand Up @@ -55,6 +56,28 @@ public void setTag(OfflinePlayer player, Tag tag) {
this.tagManager.setTag(player.getUniqueId(), tag);
}

/**
* Get a category from the id
*
* @param id The id of the tag
* @return The [Category] belonging to the id, This category is nullable
*/
@Nullable
public Category getCategory(String id) {
return this.tagManager.getCategory(id);
}

/**
* Get the category of a tag
*
* @param tag The tag
* @return The [Category] belonging to the tag, This category is nullable
*/
@Nullable
public Category getCategory(Tag tag) {
return this.tagManager.getCategory(tag);
}

public static EternalAPI getInstance() {
if (instance == null)
instance = new EternalAPI();
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/xyz/oribuin/eternaltags/EternalTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ public void enable() {
// Make sure the server has PlaceholderAPI
if (!pluginManager.isPluginEnabled("PlaceholderAPI")) {
this.getLogger().severe("Please install PlaceholderAPI onto your server to use this plugin.");
this.getServer().getPluginManager().disablePlugin(this);
pluginManager.disablePlugin(this);
return;
}

// Make sure the server is on MC 1.16
if (NMSUtil.getVersionNumber() < 16) {
this.getLogger().severe("This plugin only supports 1.16+ Minecraft.");
this.getServer().getPluginManager().disablePlugin(this);
pluginManager.disablePlugin(this);
return;
}

Expand Down Expand Up @@ -75,7 +75,6 @@ protected List<Class<? extends Manager>> getManagerLoadPriority() {
return Arrays.asList(
ConversionManager.class,
TagsManager.class,
MenuManager.class,
PluginConversionManager.class
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package xyz.oribuin.eternaltags.command.argument;

import dev.rosewood.rosegarden.RosePlugin;
import dev.rosewood.rosegarden.command.framework.ArgumentParser;
import dev.rosewood.rosegarden.command.framework.RoseCommandArgumentHandler;
import dev.rosewood.rosegarden.command.framework.RoseCommandArgumentInfo;
import dev.rosewood.rosegarden.utils.StringPlaceholders;
import xyz.oribuin.eternaltags.manager.TagsManager;
import xyz.oribuin.eternaltags.obj.Category;

import java.util.List;
import java.util.Map;

public class CategoryArgumentHandler extends RoseCommandArgumentHandler<Category> {

public CategoryArgumentHandler(RosePlugin rosePlugin) {
super(rosePlugin, Category.class);
}

@Override
protected Category handleInternal(RoseCommandArgumentInfo argumentInfo, ArgumentParser argumentParser) throws HandledArgumentException {
String input = argumentParser.next();
Category value = this.rosePlugin.getManager(TagsManager.class).getCategory(input.toLowerCase());
if (value == null || value.isGlobal())
throw new HandledArgumentException("argument-handler-category", StringPlaceholders.single("input", input));

return value;
}

@Override
protected List<String> suggestInternal(RoseCommandArgumentInfo argumentInfo, ArgumentParser argumentParser) {
argumentParser.next();

return this.rosePlugin.getManager(TagsManager.class).getCachedCategories()
.entrySet()
.stream().filter(entry -> !entry.getValue().isGlobal())
.map(Map.Entry::getKey)
.toList();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package xyz.oribuin.eternaltags.command.argument;

import dev.rosewood.rosegarden.RosePlugin;
import dev.rosewood.rosegarden.command.framework.ArgumentParser;
import dev.rosewood.rosegarden.command.framework.RoseCommandArgumentHandler;
import dev.rosewood.rosegarden.command.framework.RoseCommandArgumentInfo;
import dev.rosewood.rosegarden.utils.StringPlaceholders;
import org.bukkit.Material;

import java.util.Arrays;
import java.util.List;

public class MaterialArgumentHandler extends RoseCommandArgumentHandler<Material> {

public MaterialArgumentHandler(RosePlugin rosePlugin) {
super(rosePlugin, Material.class);
}

@Override
protected Material handleInternal(RoseCommandArgumentInfo argumentInfo, ArgumentParser argumentParser) throws HandledArgumentException {
String input = argumentParser.next();
Material value = Material.matchMaterial(input);
if (value == null)
throw new HandledArgumentException("argument-handler-material", StringPlaceholders.single("input", input));

return value;
}

@Override
protected List<String> suggestInternal(RoseCommandArgumentInfo argumentInfo, ArgumentParser argumentParser) {
argumentParser.next();

return Arrays.stream(Material.values()).map(material -> material.name().toLowerCase()).toList();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package xyz.oribuin.eternaltags.command.command;

import dev.rosewood.rosegarden.RosePlugin;
import dev.rosewood.rosegarden.command.framework.CommandContext;
import dev.rosewood.rosegarden.command.framework.RoseCommand;
import dev.rosewood.rosegarden.command.framework.RoseCommandWrapper;
import dev.rosewood.rosegarden.command.framework.annotation.RoseExecutable;
import org.bukkit.entity.Player;
import xyz.oribuin.eternaltags.gui.MenuProvider;
import xyz.oribuin.eternaltags.gui.menu.CategoryGUI;

public class CategoriesCommand extends RoseCommand {

public CategoriesCommand(RosePlugin rosePlugin, RoseCommandWrapper parent) {
super(rosePlugin, parent);
}

@RoseExecutable
public void execute(CommandContext context) {
MenuProvider.get(CategoryGUI.class).open((Player) context.getSender());
}

@Override
protected String getDefaultName() {
return "categories";
}

@Override
public String getDescriptionKey() {
return "command-categories-description";
}

@Override
public String getRequiredPermission() {
return "eternaltags.categories";
}

@Override
public boolean isPlayerOnly() {
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,33 @@
import dev.rosewood.rosegarden.command.framework.CommandContext;
import dev.rosewood.rosegarden.command.framework.RoseCommand;
import dev.rosewood.rosegarden.command.framework.RoseCommandWrapper;
import dev.rosewood.rosegarden.command.framework.RoseSubCommand;
import dev.rosewood.rosegarden.command.framework.annotation.RoseExecutable;
import dev.rosewood.rosegarden.utils.StringPlaceholders;
import xyz.oribuin.eternaltags.manager.LocaleManager;
import xyz.oribuin.eternaltags.manager.TagsManager;
import xyz.oribuin.eternaltags.obj.EditOption;
import xyz.oribuin.eternaltags.command.command.edit.EditCategoryCommand;
import xyz.oribuin.eternaltags.command.command.edit.EditIconCommand;
import xyz.oribuin.eternaltags.command.command.edit.EditDescriptionCommand;
import xyz.oribuin.eternaltags.command.command.edit.EditNameCommand;
import xyz.oribuin.eternaltags.command.command.edit.EditOrderCommand;
import xyz.oribuin.eternaltags.command.command.edit.EditPermissionCommand;
import xyz.oribuin.eternaltags.command.command.edit.EditTagCommand;
import xyz.oribuin.eternaltags.obj.Tag;

public class EditCommand extends RoseCommand {

public EditCommand(RosePlugin rosePlugin, RoseCommandWrapper parent) {
super(rosePlugin, parent);
super(rosePlugin, parent,
EditCategoryCommand.class,
EditDescriptionCommand.class,
EditIconCommand.class,
EditNameCommand.class,
EditOrderCommand.class,
EditPermissionCommand.class,
EditTagCommand.class);
}

@RoseExecutable
public void execute(CommandContext context, Tag tag, EditOption option, String value) {
final LocaleManager locale = this.rosePlugin.getManager(LocaleManager.class);
final TagsManager manager = this.rosePlugin.getManager(TagsManager.class);

option.getAction().accept(tag, value);

manager.saveTag(tag);
manager.updateActiveTag(tag);

final StringPlaceholders placeholders = StringPlaceholders.builder()
.addPlaceholder("tag", manager.getDisplayTag(tag, null))
.addPlaceholder("option", option.name().toLowerCase())
.addPlaceholder("id", tag.getId())
.addPlaceholder("name", tag.getName())
.addPlaceholder("value", value)
.build();

locale.sendMessage(context.getSender(), "command-edit-edited", placeholders);
public void execute(CommandContext context, RoseSubCommand command) {
// Has no functionality, just used to pass the tag to the subcommand
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import dev.rosewood.rosegarden.command.framework.annotation.RoseExecutable;
import dev.rosewood.rosegarden.utils.StringPlaceholders;
import org.bukkit.entity.Player;
import xyz.oribuin.eternaltags.gui.FavouritesGUI;
import xyz.oribuin.eternaltags.gui.MenuProvider;
import xyz.oribuin.eternaltags.gui.menu.FavouritesGUI;
import xyz.oribuin.eternaltags.manager.LocaleManager;
import xyz.oribuin.eternaltags.manager.MenuManager;
import xyz.oribuin.eternaltags.manager.TagsManager;
import xyz.oribuin.eternaltags.obj.Tag;

Expand All @@ -30,11 +30,11 @@ public void execute(CommandContext context, @Optional Tag tag) {
Player sender = (Player) context.getSender();

if (tag == null) {
this.rosePlugin.getManager(MenuManager.class).get(FavouritesGUI.class).open(sender);
MenuProvider.get(FavouritesGUI.class).open(sender);
return;
}

if (!sender.hasPermission(tag.getPermission())) {
if (!manager.canUseTag(sender, tag)) {
locale.sendMessage(sender, "command-favorite-no-permission");
return;
}
Expand Down
Loading

0 comments on commit 2d98fe0

Please sign in to comment.