Skip to content

Commit 1eff78b

Browse files
committed
refactor(plugin): rename plugin to creative-glyphs keeping unemojis compatibility
1 parent f42eef7 commit 1eff78b

File tree

2 files changed

+43
-5
lines changed

2 files changed

+43
-5
lines changed

plugin/src/main/java/team/unnamed/creativeglyphs/plugin/CreativeGlyphsPlugin.java

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package team.unnamed.creativeglyphs.plugin;
22

3+
import org.bukkit.Bukkit;
34
import org.bukkit.entity.Player;
45
import org.bukkit.event.EventPriority;
56
import org.bukkit.event.Listener;
@@ -26,18 +27,46 @@
2627
import team.unnamed.creativeglyphs.resourcepack.ResourcePackGlyphWriter;
2728

2829
import java.io.IOException;
30+
import java.nio.file.Files;
31+
import java.nio.file.Path;
2932
import java.util.Collection;
3033
import java.util.Locale;
3134
import java.util.Objects;
3235
import java.util.Set;
3336

34-
public class CreativeGlyphsPlugin extends JavaPlugin {
37+
public final class CreativeGlyphsPlugin extends JavaPlugin {
3538

3639
private PluginGlyphMap registry;
3740
private ArtemisGlyphImporter importer;
3841

3942
@Override
4043
public void onEnable() {
44+
final Path dataFolder = getDataFolder().toPath();
45+
46+
//#region Backwards compatibility (creative-glyphs was called unemojis)
47+
// unemojis should be removed
48+
if (Bukkit.getPluginManager().isPluginEnabled("unemojis")) {
49+
getLogger().severe(
50+
"Can't enable creative-glyphs since unemojis is enabled! Please remove " +
51+
"unemojis JAR file only (NOT THE unemojis FOLDER, IT WILL BE AUTOMATICALLY" +
52+
" RENAMED). Note that creative-glyphs is the new, improved version of unemojis."
53+
);
54+
Bukkit.getPluginManager().disablePlugin(this);
55+
return;
56+
}
57+
58+
// Rename unemojis data folder to creative-glyphs if it exists
59+
final Path pluginsFolder = Bukkit.getPluginsFolder().toPath();
60+
final Path unemojisDataFolder = pluginsFolder.resolve("unemojis");
61+
if (Files.isDirectory(unemojisDataFolder)) {
62+
try {
63+
Files.move(unemojisDataFolder, dataFolder);
64+
} catch (final IOException e) {
65+
throw new IllegalStateException("(Backwards compatibility) Couldn't" +
66+
" rename 'unemojis' folder to '" + dataFolder.getFileName() + "'", e);
67+
}
68+
}
69+
//#endregion
4170

4271
saveDefaultConfig();
4372

plugin/src/main/resources/plugin.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1-
name: unemojis
1+
name: creative-glyphs
22
version: ${project.version}
33
main: team.unnamed.creativeglyphs.plugin.CreativeGlyphsPlugin
44
api-version: 1.13
5-
description: Unnamed Team's creative-glyphs (formerly unemojis) Plugin
5+
description: Unnamed Team's creative-glyphs plugin
66
author: Unnamed Team
77
depend: [creative-central]
8-
softdepend: [PlaceholderAPI, EzChat, TownyChat, DiscordSRV, LPC, MiniPlaceholders, EssentialsDiscord]
8+
softdepend:
9+
- PlaceholderAPI
10+
- EzChat
11+
- TownyChat
12+
- DiscordSRV
13+
- LPC
14+
- MiniPlaceholders
15+
- EssentialsDiscord
16+
- CarbonChat
17+
- unemojis # We want to detect if unemojis (old version of creative-glyphs) is installed, to warn the server admin to remove it
918
commands:
1019
emojis:
11-
description: Main command for the creative-glyphs (formerly unemojis) plugin
20+
description: Main command for the creative-glyphs plugin
1221
usage: /<command> update <id>

0 commit comments

Comments
 (0)