Skip to content

Commit

Permalink
Remove edit command & Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreeam-qwq committed Mar 16, 2024
1 parent a6d938e commit e39bc65
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 242 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import dev.mrshawn.deathmessages.listeners.EntityDamageByBlock;
import dev.mrshawn.deathmessages.listeners.EntityDamageByEntity;
import dev.mrshawn.deathmessages.listeners.EntityDeath;
import dev.mrshawn.deathmessages.listeners.OnChat;
import dev.mrshawn.deathmessages.listeners.OnInteract;
import dev.mrshawn.deathmessages.listeners.OnJoin;
import dev.mrshawn.deathmessages.listeners.OnMove;
Expand Down Expand Up @@ -78,12 +77,13 @@ public class DeathMessages extends JavaPlugin {

private static EventPriority eventPriority = EventPriority.HIGH;

// Dreeam - eg. 1.20.2-R0.1-SNAPSHOT -> 20, replace string before first decimal point, then replace all string after the second decimal point
// Dreeam - e.g. 1.20.2-R0.1-SNAPSHOT -> 20, replace string before first decimal point, then replace all string after the second decimal point
public final static int majorVersion = Integer.parseInt(Bukkit.getServer().getBukkitVersion()
.replaceFirst("^(\\d+)\\.", "")
.replaceAll("\\.(.+)", "")
);

@Override
public void onEnable() {
instance = this;
LOGGER = LogManager.getLogger(instance.getName());
Expand All @@ -107,6 +107,7 @@ public void onEnable() {
public void onLoad() {
}

@Override
public void onDisable() {
if (this.adventure != null) {
this.adventure.close();
Expand Down Expand Up @@ -134,7 +135,6 @@ private void initListeners() {
new EntityDamageByBlock(),
new EntityDamageByEntity(),
new EntityDeath(),
new OnChat(),
new OnInteract(),
new OnJoin(),
new OnMove(),
Expand Down
180 changes: 0 additions & 180 deletions Core/src/main/java/dev/mrshawn/deathmessages/commands/CommandEdit.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package dev.mrshawn.deathmessages.commands;

import dev.mrshawn.deathmessages.enums.DamageTypes;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;

import java.util.ArrayList;
Expand All @@ -25,7 +23,6 @@ public List<String> onTabComplete(CommandSender sender, Command command, String
"backup",
"blacklist",
"discordlog",
"edit",
"reload",
"restore",
"toggle",
Expand Down Expand Up @@ -57,54 +54,6 @@ public List<String> onTabComplete(CommandSender sender, Command command, String
);
}

// Dreeam TODO - Command edit Will be removed since DeathMessages 1.4.19
if (args[0].equalsIgnoreCase("edit")) {
if (args.length == 3) {
// /dm edit <player> <mobName>
if (args[1].equalsIgnoreCase("player") || args[1].equalsIgnoreCase("entity")) {
arguments.clear();
// Not checking config cause we can add sections if we want
// List<String> mobNames = new ArrayList<>(PlayerDeathMessages.getInstance().getConfig()
// .getConfigurationSection("Mobs").getKeys(false));
for (EntityType entityType : EntityType.values()) {
if (entityType.isAlive()) {
arguments.add(entityType.getEntityClass().getSimpleName().toLowerCase());
}
}
return arguments;
}
} else if (args.length == 4) {
// /dm edit <player> <mobName> <solo, gang>
if (args[1].equalsIgnoreCase("player")) {
return Arrays.asList(
"solo",
"gang"
);
} else if (args[1].equalsIgnoreCase("entity")) {
return DamageTypes.getFriendlyNames();
}
} else if (args.length == 5) {
// /dm edit <player> <mobName> <solo, gang> <damage-type>
if (args[1].equalsIgnoreCase("player")) {
return DamageTypes.getFriendlyNames();
} else if (args[1].equalsIgnoreCase("entity")) {
return Arrays.asList(
"add",
"remove",
"list"
);
}
} else if (args.length == 6) {
// /dm edit <player> <mobName> <solo, gang> <damage-type> <add, remove, list>
if (args[1].equalsIgnoreCase("player")) {
return Arrays.asList(
"add",
"remove",
"list"
);
}
}
}
return null;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.mrshawn.deathmessages.enums;

public enum DeathModes {

BASIC_MODE("Basic-Mode"),
MOBS("Mobs");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import org.bukkit.inventory.meta.ItemMeta;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ThreadLocalRandom;
Expand All @@ -64,8 +63,6 @@ public class Assets {
// Dreeam TODO - to figure out why the value defined in private static field will not change with the change of the config value
//private static final CommentedConfiguration config = Settings.getInstance().getConfig();
//private static final boolean addPrefix = config.getBoolean(Config.ADD_PREFIX_TO_ALL_MESSAGES();
public static final HashMap<String, String> addingMessage = new HashMap<>();

public static boolean isNumeric(String s) {
for (char c : s.toCharArray()) {
return Character.isDigit(c);
Expand Down Expand Up @@ -1023,6 +1020,7 @@ private static Component getI18nName(ItemStack i, Player p) {
private static Component getI18nName(LivingEntity mob) {
// Dreeam - TODO
Component i18nName;

if (Config.settings.DISPLAY_I18N_MOB_NAME()) {
i18nName = Component.empty();
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
package dev.mrshawn.deathmessages.utils;

import dev.mrshawn.deathmessages.DeathMessages;
import org.bukkit.Bukkit;

import org.bukkit.event.Listener;
import org.bukkit.plugin.PluginManager;

public class EventUtils {

public static void registerEvents(Listener... listeners) {
PluginManager pluginManager = Bukkit.getPluginManager();

for (Listener listener : listeners) {
pluginManager.registerEvents(listener, DeathMessages.getInstance());
DeathMessages.getInstance().getServer().getPluginManager().registerEvents(listener, DeathMessages.getInstance());
}
}
}

0 comments on commit e39bc65

Please sign in to comment.