Skip to content

Commit

Permalink
Merged v1.6 changes to master
Browse files Browse the repository at this point in the history
  • Loading branch information
RadBuilder committed Jan 1, 2018
2 parents bf64fbd + 51b8bb4 commit 7dcfb99
Show file tree
Hide file tree
Showing 13 changed files with 111 additions and 53 deletions.
Binary file modified assets/unicode pages/unicode_page_ad.psd
Binary file not shown.
Binary file modified assets/unicode pages/unicode_page_ad.xcf
Binary file not shown.
4 changes: 2 additions & 2 deletions plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
<parent>
<groupId>io.github.radbuilder</groupId>
<artifactId>emojichat-parent</artifactId>
<version>1.5</version>
<version>1.6</version>
</parent>

<name>EmojiChat Plugin</name>
<artifactId>emojichat-plugin</artifactId>
<version>1.5</version>
<version>1.6</version>
<packaging>jar</packaging>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
* EmojiChat main class.
*
* @author RadBuilder
* @version 1.6
* @since 1.0
* @version 1.5
*/
public class EmojiChat extends JavaPlugin {
/**
Expand All @@ -39,7 +40,7 @@ public class EmojiChat extends JavaPlugin {
/**
* The ResourcePack URL.
*/
final String PACK_URL = "https://github.com/RadBuilder/EmojiChat/releases/download/v1.5/EmojiChat.ResourcePack.v1.5.zip";
final String PACK_URL = "https://github.com/RadBuilder/EmojiChat/releases/download/v1.6/EmojiChat.ResourcePack.v1.6.zip";
/**
* The SHA1 sum of the ResourcePack as a byte array.
*/
Expand All @@ -55,9 +56,11 @@ public class EmojiChat extends JavaPlugin {

@Override
public void onEnable() {
new EmojiChatConfigUpdater(this);

saveDefaultConfig();
if (!new File(getDataFolder(), "config.yml").exists()) { // If there's not a config, make one
saveDefaultConfig();
} else {
new EmojiChatConfigUpdater(this); // If there is a config, see if it can be updated
}

enabledHooks = new ArrayList<>();
emojiChatGui = new EmojiChatGui(this);
Expand All @@ -68,7 +71,7 @@ public void onEnable() {

metricsHandler = new MetricsHandler(this); // Creates the metrics handler for metrics gathering

PACK_SHA1 = BaseEncoding.base16().lowerCase().decode("787dc51caa5b01ced40517bd3d1fcf0f0873ab4e"); // Allows applying a cached version of the ResourcePack if available
PACK_SHA1 = BaseEncoding.base16().lowerCase().decode("45bd1b12a2007f8121b0ac041a0dbb3b6e934180"); // Allows applying a cached version of the ResourcePack if available

// Register the chat listener
Bukkit.getPluginManager().registerEvents(new EmojiChatListener(this), this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
* EmojiChat command class.
*
* @author RadBuilder
* @version 1.6
* @since 1.0
* @version 1.5
*/
class EmojiChatCommand implements CommandExecutor {
/**
Expand All @@ -31,7 +31,7 @@ class EmojiChatCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
if (args.length < 1) {
sender.sendMessage(ChatColor.AQUA + "EmojiChat v1.5 by RadBuilder");
sender.sendMessage(ChatColor.AQUA + "EmojiChat v1.6 by RadBuilder");
sender.sendMessage(ChatColor.AQUA + "Use " + ChatColor.GREEN + "/emojichat help" + ChatColor.AQUA + " for help.");
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* EmojiChat listener class.
*
* @author RadBuilder
* @version 1.5
* @version 1.6
* @since 1.0
*/
class EmojiChatListener implements Listener {
Expand Down Expand Up @@ -82,16 +82,18 @@ void onChat(AsyncPlayerChatEvent event) {
}

// Replace shortcuts with emojis
if (!plugin.getEmojiHandler().fixColoring()) {
// If we're not fixing the coloring, or the message is too small to have coloring
if (!plugin.getEmojiHandler().fixColoring() || message.length() < 3) {
for (String key : plugin.getEmojiHandler().getEmojis().keySet()) {
plugin.getMetricsHandler().addEmojiUsed(StringUtils.countMatches(message, key));
message = message.replace(key, plugin.getEmojiHandler().getEmojis().get(key));
}
} else {
String chatColor = message.substring(0, 2); // Gets the chat color of the message, i.e. §a
boolean hasColor = chatColor.contains("§");
for (String key : plugin.getEmojiHandler().getEmojis().keySet()) {
plugin.getMetricsHandler().addEmojiUsed(StringUtils.countMatches(message, key));
String chatColor = message.substring(0, 2); // Gets the chat color of the message, i.e. §a
message = message.replace(key, ChatColor.WHITE + plugin.getEmojiHandler().getEmojis().get(key) + (chatColor.contains("§") ? chatColor : "")); // Sets the emoji color to white for correct coloring
message = message.replace(key, ChatColor.WHITE + plugin.getEmojiHandler().getEmojis().get(key) + (hasColor ? chatColor : "")); // Sets the emoji color to white for correct coloring
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
* EmojiChat config updater.
*
* @author RadBuilder
* @version 1.5
* @version 1.6
* @since 1.5
*/
public class EmojiChatConfigUpdater {
/**
* The current config version number.
*/
private final int CONFIG_VERSION = 2;
private final int CONFIG_VERSION = 3;

/**
* Creates the EmojiChat config updater with the main class instance.
Expand All @@ -33,12 +33,9 @@ public class EmojiChatConfigUpdater {
public EmojiChatConfigUpdater(EmojiChat plugin) {
int configVersion = plugin.getConfig().getInt("config-version");

if (configVersion + 1 == CONFIG_VERSION) {
plugin.getLogger().info("Updating your config now...");
updateConfig(plugin, plugin.getConfig());
} else if (configVersion + 1 < CONFIG_VERSION) {
plugin.getLogger().info("Your config is too old to update...");
plugin.getLogger().info("Your config has been renamed to 'config_old.yml' and a new one has been generated.");
if (configVersion < CONFIG_VERSION) {
plugin.getLogger().info("Updating your config now (old: " + configVersion + ", new: " + CONFIG_VERSION + ")...");
updateConfig(plugin, plugin.getConfig(), configVersion);
}
}

Expand All @@ -47,9 +44,10 @@ public EmojiChatConfigUpdater(EmojiChat plugin) {
*
* @param plugin The EmojiChat main class instance.
* @param config The EmojiChat config.
* @param configVersion The current config version number.
*/
private void updateConfig(EmojiChat plugin, FileConfiguration config) {
// Old config values
private void updateConfig(EmojiChat plugin, FileConfiguration config, int configVersion) {
// Config v1 & v2 values
boolean fixEmojiColoring = config.getBoolean("fix-emoji-coloring");
boolean verifyDisabledList = config.getBoolean("verify-disabled-list");
List<String> disabledEmojis = config.getStringList("disabled-emojis");
Expand All @@ -58,6 +56,14 @@ private void updateConfig(EmojiChat plugin, FileConfiguration config) {
shortcuts.put(key, config.getStringList("shortcuts." + key));
}

// Config v2 values
String metricsCollection = "FULL";
boolean downloadResourcePack = true;
if (configVersion == 2) {
metricsCollection = config.getString("metrics-collection");
downloadResourcePack = config.getBoolean("download-resourcepack");
}

// Config lines
List<String> configLines = new ArrayList<>();
configLines.add("# Configuration file for EmojiChat by RadBuilder");
Expand All @@ -75,7 +81,7 @@ private void updateConfig(EmojiChat plugin, FileConfiguration config) {
configLines.add("# 'BASIC' collects data on what Java version you're using, Bukkit/Spigot version you're using, other general server");
configLines.add("# information like player count, how many emojis you've used, and shortcuts you've used.");
configLines.add("# 'OFF' collects NO DATA, however, I would appreciate it if you send at least basic data.");
configLines.add("metrics-collection: 'FULL'");
configLines.add("metrics-collection: '" + metricsCollection + "'");
configLines.add("");
configLines.add("# If you're using chat color plugins, this will remove the coloring for emojis to be displayed correctly.");
configLines.add("fix-emoji-coloring: " + fixEmojiColoring);
Expand All @@ -87,7 +93,7 @@ private void updateConfig(EmojiChat plugin, FileConfiguration config) {
configLines.add("");
configLines.add("# If EmojiChat should auto download the ResourcePack. If you'd rather have your players manually");
configLines.add("# download or use /emojichat resourcepack, set this to false.");
configLines.add("download-resourcepack: true");
configLines.add("download-resourcepack: " + downloadResourcePack);
configLines.add("");
configLines.add("# Shortcuts will replace the items in the list with the correct emoji name.");
configLines.add("# For example, :) will be replaced with :grinning:, which then will turn it into the emoji.");
Expand All @@ -98,38 +104,51 @@ private void updateConfig(EmojiChat plugin, FileConfiguration config) {
configLines.add(" - '" + shortcutListItem + "'");
}
}
configLines.add(" crazy_face:");
configLines.add(" - ':crazy:'");
configLines.add(" face_with_raised_eyebrow:");
configLines.add(" - ':hmm:'");
configLines.add(" shushing_face:");
configLines.add(" - ':shh:'");
if (configVersion == 1) {
configLines.add(" crazy_face:");
configLines.add(" - ':crazy:'");
configLines.add(" face_with_raised_eyebrow:");
configLines.add(" - ':hmm:'");
configLines.add(" shushing_face:");
configLines.add(" - ':shh:'");
}
configLines.add(" 1st_place_medal:");
configLines.add(" - ':first:'");
configLines.add(" - ':1st:'");
configLines.add(" 2nd_place_medal:");
configLines.add(" - ':second:'");
configLines.add(" - ':2nd:'");
configLines.add(" 3rd_place_medal:");
configLines.add(" - ':third:'");
configLines.add(" - ':3rd:'");
configLines.add("");
configLines.add("# Emojis to disable. Remove them from the list to enable them.");
configLines.add("# By default, profane and potentially offensive emojis are disabled.");
configLines.add("disabled-emojis:");
for (String disabledEmoji : disabledEmojis) {
configLines.add("- '" + disabledEmoji + "'");
}
configLines.add("- ':sweat_drops:'");
configLines.add("- ':banana:'");
configLines.add("- ':cherries:'");
configLines.add("- ':peach:'");
configLines.add("- ':tomato:'");
configLines.add("- ':eggplant:'");
configLines.add("- ':cucumber:'");
configLines.add("- ':beer:'");
configLines.add("- ':beers:'");
configLines.add("- ':clinking_glasses:'");
configLines.add("- ':wine_glass:'");
configLines.add("- ':tumbler_glass:'");
configLines.add("- ':cocktail:'");
configLines.add("- ':face_with_symbols_over_mouth:'");
configLines.add("- ':face_vomiting:'");
if (configVersion == 1) {
configLines.add("- ':sweat_drops:'");
configLines.add("- ':banana:'");
configLines.add("- ':cherries:'");
configLines.add("- ':peach:'");
configLines.add("- ':tomato:'");
configLines.add("- ':eggplant:'");
configLines.add("- ':cucumber:'");
configLines.add("- ':beer:'");
configLines.add("- ':beers:'");
configLines.add("- ':clinking_glasses:'");
configLines.add("- ':wine_glass:'");
configLines.add("- ':tumbler_glass:'");
configLines.add("- ':cocktail:'");
configLines.add("- ':face_with_symbols_over_mouth:'");
configLines.add("- ':face_vomiting:'");
}
configLines.add("");
configLines.add("# The config version, used to be able to update your config when future versions come out.");
configLines.add("# Don't change this, or you'll experience issues with EmojiChat.");
configLines.add("config-version: 2");
configLines.add("config-version: " + CONFIG_VERSION);

// Update the config
setConfig(plugin, configLines);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* Emoji handler class.
*
* @author RadBuilder
* @version 1.5
* @version 1.6
* @since 1.4
*/
public class EmojiHandler {
Expand Down Expand Up @@ -585,6 +585,31 @@ private void loadEmojis() {
emojis.put(":star_struck:", "궙");
emojis.put(":exploding_head:", "궚");
emojis.put(":face_vomiting:", "궛");
emojis.put(":soccer:", "궜");
emojis.put(":basketball:", "궝");
emojis.put(":football:", "궞");
emojis.put(":baseball:", "궟");
emojis.put(":tennis:", "궠");
emojis.put(":volleyball:", "궡");
emojis.put(":rugby_football:", "궢");
emojis.put(":8ball:", "궣");
emojis.put(":golf:", "궤");
emojis.put(":ping_pong:", "궥");
emojis.put(":badminton:", "궦");
emojis.put(":goal_net:", "궧");
emojis.put(":ice_hockey:", "궨");
emojis.put(":field_hockey:", "궩");
emojis.put(":cricket:", "궪");
emojis.put(":ice_skate:", "궫");
emojis.put(":bow_and_arrow:", "궬");
emojis.put(":boxing_glove:", "궭");
emojis.put(":martial_arts_uniform:", "궮");
emojis.put(":trophy:", "궯");
emojis.put(":medal_sports:", "궰");
emojis.put(":medal_military:", "궱");
emojis.put(":1st_place_medal:", "궲");
emojis.put(":2nd_place_medal:", "궳");
emojis.put(":3rd_place_medal:", "궴");
}

/**
Expand Down
11 changes: 10 additions & 1 deletion plugin/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ shortcuts:
- ':hmm:'
shushing_face:
- ':shh:'
1st_place_medal:
- ':first:'
- ':1st:'
2nd_place_medal:
- ':second:'
- ':2nd:'
3rd_place_medal:
- ':third:'
- ':3rd:'

# Emojis to disable. Remove them from the list to enable them.
# By default, profane and potentially offensive emojis are disabled.
Expand Down Expand Up @@ -88,4 +97,4 @@ disabled-emojis:

# The config version, used to be able to update your config when future versions come out.
# Don't change this, or you'll experience issues with EmojiChat.
config-version: 2
config-version: 3
2 changes: 1 addition & 1 deletion plugin/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: EmojiChat
version: 1.5
version: 1.6
description: Adds emojis to your chat
author: RadBuilder
website: "https://github.com/RadBuilder/EmojiChat/"
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>io.github.radbuilder</groupId>
<name>EmojiChat Parent</name>
<artifactId>emojichat-parent</artifactId>
<version>1.5</version>
<version>1.6</version>
<packaging>pom</packaging>

<modules>
Expand Down
Binary file modified resourcepack/assets/minecraft/textures/font/unicode_page_ad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion resourcepack/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"pack": {
"pack_format": 4,
"description": "EmojiChat v1.5 ResourcePack by RadBuilder"
"description": "EmojiChat v1.6 ResourcePack by RadBuilder"
}
}

0 comments on commit 7dcfb99

Please sign in to comment.