Skip to content

Commit

Permalink
Fix logger & Fix hoverEvent method
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreeam-qwq committed Nov 7, 2023
1 parent b702daa commit aa0a163
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 33 deletions.
34 changes: 22 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
# DeathMessages

![GitHub License](https://img.shields.io/github/license/Winds-Studio/DeathMessages?style=for-the-badge)![GitHub Build Status](https://img.shields.io/github/actions/workflow/status/Winds-Studio/DeathMessages/build.yml?style=for-the-badge)![Github Stars](https://img.shields.io/github/stars/Winds-Studio/DeathMessages?style=for-the-badge)

**_!Active testing - report any bugs or give suggestions_**

![GitHub License](https://img.shields.io/github/license/Winds-Studio/DeathMessages?style=for-the-badge)![GitHub Build Status](https://img.shields.io/github/actions/workflow/status/Winds-Studio/DeathMessages/build.yml?style=for-the-badge)![Github Stars](https://img.shields.io/github/stars/Winds-Studio/DeathMessages?style=for-the-badge)

Original Download Link: [SpigotMC](https://www.spigotmc.org/resources/deathmessages-deathmessagesprime-remastered.3789/) (Outdated)

## Features

- Supporting 1.12.2 - Latest Minecraft version (1.20.2)
- Compatible with Spigot / Paper / Paper forks / Forge&Bukkit Hybrid Servers
- Folia Support
- Fix a bunch of errors or issues from original DeathMessages
- Highly Optimized
- Active Development

Compatibility

- Support Java 17 and higher
- Support 1.12.2 - Latest Minecraft version (1.20.2)
- Compatible with Spigot / Paper / Paper Forks / Forge+Bukkit Hybrid Server
- Folia Support

## Portals

- [Github Releases](https://github.com/Winds-Studio/DeathMessages/releases) (Latest DEV Version)
- [SpigotMC](https://www.spigotmc.org/resources/deathmessages-deathmessagesprime-remastered.3789/) (Original DM and Outdated)

## Contact

- 📫 Discord: `dreeam___` | QQ: `2682173972`
Expand All @@ -28,13 +37,14 @@ For Developers:

## TODOs

- Adventure - To replace the replaceAll and bukkit ChatColor
- Command system, tab complete and some refactor
- Look into get entity name
- Add version comment in config
- Config
- Improve hoverEvent(opt code/showItem or showEntity)
- More issues can track in [here](https://bbs.breeze.asia/d/128-si-wang-ti-shi-wen-ti)
> - Adventure - To replace the replaceAll and bukkit ChatColor
> - Command system, tab complete and some refactor
> - Look into get entity name
> - Add version comment ins config
> - Config
> - Improve hoverEvent(opt code/showItem or showEntity)
> - VersionChecker & Custom bstats charts
> - More issues can track in [here](https://bbs.breeze.asia/d/128-si-wang-ti-shi-wen-ti)
## Special Thanks To:

Expand Down
24 changes: 13 additions & 11 deletions src/main/java/dev/mrshawn/deathmessages/DeathMessages.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
import dev.mrshawn.deathmessages.listeners.customlisteners.BroadcastEntityDeathListener;
import dev.mrshawn.deathmessages.listeners.customlisteners.BroadcastPlayerDeathListener;
import dev.mrshawn.deathmessages.listeners.mythicmobs.MobDeath;
import dev.mrshawn.deathmessages.worldguard.WorldGuard7Extension;
import dev.mrshawn.deathmessages.worldguard.WorldGuardExtension;
import dev.mrshawn.deathmessages.hooks.WorldGuard7Extension;
import dev.mrshawn.deathmessages.hooks.WorldGuardExtension;
import io.lumine.mythic.bukkit.MythicBukkit;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -81,7 +81,7 @@ public void onEnable() {
initializeOnlinePlayers();
checkGameRules();
new Metrics(this, 12365);
LogManager.getLogger().info("bStats Hook Enabled!");
LogManager.getLogger(getName()).info("bStats Hook Enabled!");
}

public void onLoad() {
Expand Down Expand Up @@ -147,26 +147,27 @@ private void initializeHooks() {
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new PlaceholderAPIExtension(this).register();
placeholderAPIEnabled = true;
LogManager.getLogger().info("PlaceholderAPI Hook Enabled!");
LogManager.getLogger(getName()).info("PlaceholderAPI Hook Enabled!");
}

if (worldGuardEnabled) {
LogManager.getLogger().info("WorldGuard Hook Enabled!");
LogManager.getLogger(getName()).info("WorldGuard Hook Enabled!");
}

if (Bukkit.getPluginManager().getPlugin("DiscordBotAPI") != null && config.getBoolean(Config.HOOKS_DISCORD_ENABLED)) {
discordBotAPIExtension = new DiscordBotAPIExtension();
LogManager.getLogger().info("DiscordBotAPI Hook Enabled!");
LogManager.getLogger(getName()).info("DiscordBotAPI Hook Enabled!");
LogManager.getLogger(getName()).warn("WARNING: You are using a outdated plugin! DiscordBotAPI support will be removed in DeathMessages 1.4.19, use DiscordSRV instead!");
}

if (Bukkit.getPluginManager().getPlugin("DiscordSRV") != null && config.getBoolean(Config.HOOKS_DISCORD_ENABLED)) {
discordSRVExtension = new DiscordSRVExtension();
LogManager.getLogger().info("DiscordSRV Hook Enabled!");
LogManager.getLogger(getName()).info("DiscordSRV Hook Enabled!");
}

if (Bukkit.getPluginManager().isPluginEnabled("PlugMan") && worldGuardExtension != null) {
Plugin plugMan = Bukkit.getPluginManager().getPlugin("PlugMan");
LogManager.getLogger().info("PlugMan found. Adding this plugin to its ignored plugins list due to WorldGuard hook being enabled!");
LogManager.getLogger(getName()).info("PlugMan found. Adding this plugin to its ignored plugins list due to WorldGuard hook being enabled!");
try {
List<String> ignoredPlugins = (List<String>) plugMan.getClass().getMethod("getIgnoredPlugins").invoke(plugMan);
if (!ignoredPlugins.contains("DeathMessages")) {
Expand All @@ -180,20 +181,20 @@ private void initializeHooks() {
if (Bukkit.getPluginManager().getPlugin("CombatLogX") != null && config.getBoolean(Config.HOOKS_COMBATLOGX_ENABLED)) {
combatLogXAPIEnabled = true;
Bukkit.getPluginManager().registerEvents(new PlayerUntag(), this);
LogManager.getLogger().info("CombatLogX Hook Enabled!");
LogManager.getLogger(getName()).info("CombatLogX Hook Enabled!");
}

if (Bukkit.getPluginManager().getPlugin("MythicMobs") != null && config.getBoolean(Config.HOOKS_MYTHICMOBS_ENABLED)) {
mythicMobs = MythicBukkit.inst();
mythicmobsEnabled = true;
LogManager.getLogger().info("MythicMobs Hook Enabled!");
LogManager.getLogger(getName()).info("MythicMobs Hook Enabled!");
Bukkit.getPluginManager().registerEvents(new MobDeath(), this);
}

if (config.getBoolean(Config.HOOKS_BUNGEE_ENABLED)) {
Bukkit.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
Bukkit.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new PluginMessaging());
LogManager.getLogger().info("Bungee Hook enabled!");
LogManager.getLogger(getName()).info("Bungee Hook enabled!");
if (config.getBoolean(Config.HOOKS_BUNGEE_SERVER_NAME_GET_FROM_BUNGEE)) {
bungeeInit = true;
} else {
Expand Down Expand Up @@ -248,6 +249,7 @@ public static DeathMessages getInstance() {
public static EventPriority getEventPriority() {
return eventPriority;
}

public @NotNull BukkitAudiences adventure() {
if(this.adventure == null) {
throw new IllegalStateException("Tried to access Adventure when the plugin was disabled!");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.mrshawn.deathmessages.worldguard;
package dev.mrshawn.deathmessages.hooks;

import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.util.Location;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.mrshawn.deathmessages.worldguard;
package dev.mrshawn.deathmessages.hooks;

import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.protection.flags.StateFlag;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void onPluginMessageReceived(String channel, @NotNull Player player, byte

if (subChannel.equals("GetServer")) {
String serverName = stream.readUTF();
LogManager.getLogger().info("Server-Name successfully initialized from Bungee! (" + serverName + ")");
LogManager.getLogger(DeathMessages.getInstance().getName()).info("Server-Name successfully initialized from Bungee! (" + serverName + ")");
DeathMessages.bungeeServerName = serverName;
config.set(Config.HOOKS_BUNGEE_SERVER_NAME_DISPLAY_NAME, Config.HOOKS_BUNGEE_SERVER_NAME_DISPLAY_NAME, serverName);
config.save();
Expand Down Expand Up @@ -66,7 +66,7 @@ public void onPluginMessageReceived(String channel, @NotNull Player player, byte

public static void sendServerNameRequest(Player p) {
if (!config.getBoolean(Config.HOOKS_BUNGEE_ENABLED)) return;
LogManager.getLogger().info("Attempting to initialize server-name variable from Bungee...");
LogManager.getLogger(DeathMessages.getInstance().getName()).info("Attempting to initialize server-name variable from Bungee...");
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("GetServer");
p.sendPluginMessage(DeathMessages.getInstance(), "BungeeCord", out.toByteArray());
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/dev/mrshawn/deathmessages/utils/Assets.java
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public static TextComponent getNaturalDeath(PlayerManager pm, String damageCause
displayName = i.getItemMeta().getDisplayName();
}

HoverEvent<HoverEvent.ShowItem> showItem = HoverEvent.showItem(Key.key(i.getType().name().toLowerCase()), i.getAmount(), BinaryTagHolder.binaryTagHolder(i.getItemMeta().getAsString()));
HoverEvent<HoverEvent.ShowItem> showItem = HoverEvent.showItem(Key.key(i.getType().name().toLowerCase()), i.getAmount(), BinaryTagHolder.binaryTagHolder(i.getItemMeta().toString()));

Component weapon = Component.text()
.append(Assets.convertFromLegacy(displayName))
Expand Down Expand Up @@ -415,7 +415,7 @@ public static TextComponent getWeapon(boolean gang, PlayerManager pm, LivingEnti
displayName = i.getItemMeta().getDisplayName();
}

HoverEvent<HoverEvent.ShowItem> showItem = HoverEvent.showItem(Key.key(i.getType().name().toLowerCase()), i.getAmount(), BinaryTagHolder.binaryTagHolder(i.getItemMeta().getAsString()));
HoverEvent<HoverEvent.ShowItem> showItem = HoverEvent.showItem(Key.key(i.getType().name().toLowerCase()), i.getAmount(), BinaryTagHolder.binaryTagHolder(i.getItemMeta().toString()));

Component weapon = Component.text()
.append(Assets.convertFromLegacy(displayName))
Expand Down Expand Up @@ -500,7 +500,7 @@ public static TextComponent getEntityDeathWeapon(Player p, Entity e, MobType mob
displayName = i.getItemMeta().getDisplayName();
}

HoverEvent<HoverEvent.ShowItem> showItem = HoverEvent.showItem(Key.key(i.getType().name().toLowerCase()), i.getAmount(), BinaryTagHolder.binaryTagHolder(i.getItemMeta().getAsString()));
HoverEvent<HoverEvent.ShowItem> showItem = HoverEvent.showItem(Key.key(i.getType().name().toLowerCase()), i.getAmount(), BinaryTagHolder.binaryTagHolder(i.getItemMeta().toString()));

Component weapon = Component.text()
.append(Assets.convertFromLegacy(displayName))
Expand Down Expand Up @@ -622,7 +622,7 @@ public static TextComponent getProjectile(boolean gang, PlayerManager pm, Living
showItem = HoverEvent.showItem(Key.key(i.getType().name().toLowerCase()), i.getAmount());
} else {
displayName = i.getItemMeta().getDisplayName();
showItem = HoverEvent.showItem(Key.key(i.getType().name().toLowerCase()), i.getAmount(), BinaryTagHolder.binaryTagHolder(i.getItemMeta().getAsString()));
showItem = HoverEvent.showItem(Key.key(i.getType().name().toLowerCase()), i.getAmount(), BinaryTagHolder.binaryTagHolder(i.getItemMeta().toString()));
}

Component weapon = Component.text()
Expand Down Expand Up @@ -708,7 +708,7 @@ public static TextComponent getEntityDeathProjectile(Player p, EntityManager em,
displayName = i.getItemMeta().getDisplayName();
}

HoverEvent<HoverEvent.ShowItem> showItem = HoverEvent.showItem(Key.key(i.getType().name().toLowerCase()), i.getAmount(), BinaryTagHolder.binaryTagHolder(i.getItemMeta().getAsString()));
HoverEvent<HoverEvent.ShowItem> showItem = HoverEvent.showItem(Key.key(i.getType().name().toLowerCase()), i.getAmount(), BinaryTagHolder.binaryTagHolder(i.getItemMeta().toString()));

Component weapon = Component.text()
.append(Assets.convertFromLegacy(displayName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package dev.mrshawn.deathmessages.utils;

import dev.mrshawn.deathmessages.DeathMessages;
import org.apache.logging.log4j.LogManager;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
Expand Down Expand Up @@ -292,7 +293,7 @@ private CommentedConfiguration flagAsFailed() {
FileInputStream stream = new FileInputStream(file);
return loadConfiguration(new InputStreamReader(stream, StandardCharsets.UTF_8));
} catch (FileNotFoundException ex) {
LogManager.getLogger().warn("File " + file.getName() + " doesn't exist.");
LogManager.getLogger(DeathMessages.getInstance().getName()).warn("File " + file.getName() + " doesn't exist.");
return new CommentedConfiguration().flagAsFailed();
}
}
Expand Down

0 comments on commit aa0a163

Please sign in to comment.