Updates logging and message generation to use modern methods.
This commit is contained in:
10
TODO.md
10
TODO.md
@@ -7,8 +7,8 @@
|
|||||||
- [x] Remove Maven-specific files (pom.xml, .mvn/ directory, Maven wrapper scripts) and Eclipse-specific files (.classpath, .project, .settings/) if present.
|
- [x] Remove Maven-specific files (pom.xml, .mvn/ directory, Maven wrapper scripts) and Eclipse-specific files (.classpath, .project, .settings/) if present.
|
||||||
- [x] Update .gitignore to add Gradle-specific ignores and remove Maven/Eclipse-specific ignores.
|
- [x] Update .gitignore to add Gradle-specific ignores and remove Maven/Eclipse-specific ignores.
|
||||||
- [x] Ensure plugin.yml is present in src/main/resources and update for PaperMC compatibility (api-version, commands, required fields).
|
- [x] Ensure plugin.yml is present in src/main/resources and update for PaperMC compatibility (api-version, commands, required fields).
|
||||||
- [ ] Refactor all logger usage to use getLogger() from JavaPlugin.
|
- [x] Refactor all logger usage to use getLogger() from JavaPlugin.
|
||||||
- [ ] Refactor all event listeners to use the modern event system (Listener interface, @EventHandler, registerEvents).
|
- [x] Refactor all event listeners to use the modern event system (Listener interface, @EventHandler, registerEvents).
|
||||||
- [x] Replace use of org.bukkit.util.config.Configuration with the modern configuration API (getConfig(), saveConfig(), etc.).
|
- [x] Replace use of org.bukkit.util.config.Configuration with the modern configuration API (getConfig(), saveConfig(), etc.).
|
||||||
- [ ] Update score table to use Bukkit entity types or enums instead of CraftBukkit class names.
|
- [ ] Update score table to use Bukkit entity types or enums instead of CraftBukkit class names.
|
||||||
- [ ] If storing player scores, refactor to use UUID as the key instead of Player or String.
|
- [ ] If storing player scores, refactor to use UUID as the key instead of Player or String.
|
||||||
@@ -16,9 +16,9 @@
|
|||||||
- [ ] Address any bugs or incompatibilities found during testing on a modern server. _(Depends on: build and test)_
|
- [ ] Address any bugs or incompatibilities found during testing on a modern server. _(Depends on: build and test)_
|
||||||
- [ ] Update README.md and CONTRIBUTING.md with new build, usage, and development instructions. _(Depends on: bugfixes)_
|
- [ ] Update README.md and CONTRIBUTING.md with new build, usage, and development instructions. _(Depends on: bugfixes)_
|
||||||
- [ ] (Optional) Add new features, quality-of-life improvements, automated tests, or CI configuration. _(Depends on: docs update)_
|
- [ ] (Optional) Add new features, quality-of-life improvements, automated tests, or CI configuration. _(Depends on: docs update)_
|
||||||
- [ ] Update MobScores to depend on the latest version of the ScoreKeeper plugin (update dependency in build.gradle and plugin.yml as needed).
|
- [x] Update MobScores to depend on the latest version of the ScoreKeeper plugin (update dependency in build.gradle and plugin.yml as needed).
|
||||||
- [ ] Test MobScores with the latest ScoreKeeper to ensure score tracking, awarding, and all integration points work as expected (including with players who have changed names).
|
- [ ] Test MobScores with the latest ScoreKeeper to ensure score tracking, awarding, and all integration points work as expected (including with players who have changed names).
|
||||||
- [x] Refactor MobDeathListener and PlayerConnectListener to implement Listener interface and use @EventHandler annotations instead of extending EntityListener/PlayerListener.
|
- [x] Refactor MobDeathListener and PlayerConnectListener to implement Listener interface and use @EventHandler annotations instead of extending EntityListener/PlayerListener.
|
||||||
- [x] Update event registration in MobScoresPlugin to use getServer().getPluginManager().registerEvents(...).
|
- [x] Update event registration in MobScoresPlugin to use getServer().getPluginManager().registerEvents(...).
|
||||||
- [ ] Replace all usage of org.bukkit.util.config.Configuration with the modern Bukkit configuration API (getConfig(), saveConfig(), reloadConfig(), etc.).
|
- [x] Replace all usage of org.bukkit.util.config.Configuration with the modern Bukkit configuration API (getConfig(), saveConfig(), reloadConfig(), etc.).
|
||||||
- [ ] Remove or refactor any code using deprecated or removed Bukkit/Spigot/Paper APIs that are not available in the modern Paper API.
|
- [x] Remove or refactor any code using deprecated or removed Bukkit/Spigot/Paper APIs that are not available in the modern Paper API.
|
||||||
|
|||||||
@@ -16,8 +16,10 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'io.papermc.paper:paper-api:1.21.7-R0.1-SNAPSHOT'
|
|
||||||
compileOnly 'com.majinnaibu.minecraft.plugins:ScoreKeeper:0.2.1-SNAPSHOT'
|
compileOnly 'com.majinnaibu.minecraft.plugins:ScoreKeeper:0.2.1-SNAPSHOT'
|
||||||
|
compileOnly 'io.papermc.paper:paper-api:1.21.7-R0.1-SNAPSHOT'
|
||||||
|
compileOnly 'net.kyori:adventure-api:4.14.0'
|
||||||
|
|
||||||
testImplementation libs.junit.junit
|
testImplementation libs.junit.junit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ import java.util.HashMap;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Zombie;
|
import org.bukkit.entity.Zombie;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
@@ -40,9 +40,10 @@ public class MobScoresPlugin extends JavaPlugin {
|
|||||||
private Map<String, Integer> _scoreTable = new HashMap<String, Integer>();
|
private Map<String, Integer> _scoreTable = new HashMap<String, Integer>();
|
||||||
private ScoreKeeperPlugin _scoreKeeper = null;
|
private ScoreKeeperPlugin _scoreKeeper = null;
|
||||||
|
|
||||||
private final String _logStart = "[" + ChatColor.AQUA + "MobScores" + ChatColor.WHITE + "] ";
|
private final String _logPrefix = "[MobScores] ";
|
||||||
|
private final Component _messagePrefix = Component.text("[")
|
||||||
public final Logger log = Logger.getLogger("Minecraft");
|
.append(Component.text("MobScores").color(NamedTextColor.AQUA))
|
||||||
|
.append(Component.text("] ").color(NamedTextColor.WHITE));
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
@@ -80,8 +81,7 @@ public class MobScoresPlugin extends JavaPlugin {
|
|||||||
pm.registerEvents(new MobDeathListener(this), this);
|
pm.registerEvents(new MobDeathListener(this), this);
|
||||||
pm.registerEvents(new PlayerConnectListener(this), this);
|
pm.registerEvents(new PlayerConnectListener(this), this);
|
||||||
|
|
||||||
PluginDescriptionFile pdFile = this.getDescription();
|
logInfo(getPluginMeta().getName() + " version " + getPluginMeta().getVersion() + " is enabled!");
|
||||||
log.info(pdFile.getName() + " version " + pdFile.getVersion() + " is enabled!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private HashMap<String, Integer> getDefaultScoreTable() {
|
private HashMap<String, Integer> getDefaultScoreTable() {
|
||||||
@@ -125,11 +125,11 @@ public class MobScoresPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
_scoreKeeper.addScore(player, score);
|
_scoreKeeper.addScore(player, score);
|
||||||
}else{
|
}else{
|
||||||
log.warning("[MobScores] Unable to award score for {" + className + "}");
|
logWarning("Unable to award score for {" + className + "}");
|
||||||
Set<String> keys = _scoreTable.keySet();
|
Set<String> keys = _scoreTable.keySet();
|
||||||
String str = null;
|
String str = null;
|
||||||
for(Iterator<String> i = keys.iterator(); i.hasNext(); str = i.next()){
|
for(Iterator<String> i = keys.iterator(); i.hasNext(); str = i.next()){
|
||||||
log.info("{" + str + "}");
|
logInfo("{" + str + "}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -142,15 +142,23 @@ public class MobScoresPlugin extends JavaPlugin {
|
|||||||
if(pair.getValue() != 0){
|
if(pair.getValue() != 0){
|
||||||
String key = pair.getKey();
|
String key = pair.getKey();
|
||||||
if(key.startsWith("org.bukkit.craftbukkit.entity.Craft")){
|
if(key.startsWith("org.bukkit.craftbukkit.entity.Craft")){
|
||||||
player.sendMessage(_logStart + key.substring(35) + " = " + pair.getValue().toString());
|
sendPlayerMessage(player, key.substring(35) + " = " + pair.getValue().toString());
|
||||||
}else{
|
}else{
|
||||||
player.sendMessage(_logStart + key + " = " + pair.getValue().toString());
|
sendPlayerMessage(player, key + " = " + pair.getValue().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logInfo(String string) {
|
public void sendPlayerMessage(Player player, String message) {
|
||||||
log.info(_logStart + string);
|
player.sendMessage(_messagePrefix.append(Component.text(message)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logInfo(String messag) {
|
||||||
|
getLogger().info(_logPrefix + messag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logWarning(String message) {
|
||||||
|
getLogger().warning(_logPrefix + message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user