Skip to content

Commit

Permalink
refactor(plugin): rename plugin to creative-glyphs keeping unemojis c…
Browse files Browse the repository at this point in the history
…ompatibility
  • Loading branch information
yusshu committed Feb 1, 2024
1 parent f42eef7 commit 1eff78b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package team.unnamed.creativeglyphs.plugin;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
Expand All @@ -26,18 +27,46 @@
import team.unnamed.creativeglyphs.resourcepack.ResourcePackGlyphWriter;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collection;
import java.util.Locale;
import java.util.Objects;
import java.util.Set;

public class CreativeGlyphsPlugin extends JavaPlugin {
public final class CreativeGlyphsPlugin extends JavaPlugin {

private PluginGlyphMap registry;
private ArtemisGlyphImporter importer;

@Override
public void onEnable() {
final Path dataFolder = getDataFolder().toPath();

//#region Backwards compatibility (creative-glyphs was called unemojis)
// unemojis should be removed
if (Bukkit.getPluginManager().isPluginEnabled("unemojis")) {
getLogger().severe(
"Can't enable creative-glyphs since unemojis is enabled! Please remove " +
"unemojis JAR file only (NOT THE unemojis FOLDER, IT WILL BE AUTOMATICALLY" +
" RENAMED). Note that creative-glyphs is the new, improved version of unemojis."
);
Bukkit.getPluginManager().disablePlugin(this);
return;
}

// Rename unemojis data folder to creative-glyphs if it exists
final Path pluginsFolder = Bukkit.getPluginsFolder().toPath();
final Path unemojisDataFolder = pluginsFolder.resolve("unemojis");
if (Files.isDirectory(unemojisDataFolder)) {
try {
Files.move(unemojisDataFolder, dataFolder);
} catch (final IOException e) {
throw new IllegalStateException("(Backwards compatibility) Couldn't" +
" rename 'unemojis' folder to '" + dataFolder.getFileName() + "'", e);
}
}
//#endregion

saveDefaultConfig();

Expand Down
17 changes: 13 additions & 4 deletions plugin/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
name: unemojis
name: creative-glyphs
version: ${project.version}
main: team.unnamed.creativeglyphs.plugin.CreativeGlyphsPlugin
api-version: 1.13
description: Unnamed Team's creative-glyphs (formerly unemojis) Plugin
description: Unnamed Team's creative-glyphs plugin
author: Unnamed Team
depend: [creative-central]
softdepend: [PlaceholderAPI, EzChat, TownyChat, DiscordSRV, LPC, MiniPlaceholders, EssentialsDiscord]
softdepend:
- PlaceholderAPI
- EzChat
- TownyChat
- DiscordSRV
- LPC
- MiniPlaceholders
- EssentialsDiscord
- CarbonChat
- unemojis # We want to detect if unemojis (old version of creative-glyphs) is installed, to warn the server admin to remove it
commands:
emojis:
description: Main command for the creative-glyphs (formerly unemojis) plugin
description: Main command for the creative-glyphs plugin
usage: /<command> update <id>

0 comments on commit 1eff78b

Please sign in to comment.