Replaces removed bukkit apis with modern equivalents.
This commit is contained in:
4
TODO.md
4
TODO.md
@@ -18,7 +18,7 @@
|
|||||||
- [ ] (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).
|
- [ ] 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).
|
||||||
- [ ] 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.
|
||||||
- [ ] 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.).
|
- [ ] 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.
|
- [ ] Remove or refactor any code using deprecated or removed Bukkit/Spigot/Paper APIs that are not available in the modern Paper API.
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import org.bukkit.ChatColor;
|
|||||||
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.event.Event;
|
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
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;
|
||||||
@@ -37,8 +36,6 @@ import com.majinnaibu.minecraft.plugins.mobscores.listeners.PlayerConnectListene
|
|||||||
import com.majinnaibu.minecraft.plugins.scorekeeper.ScoreKeeperPlugin;
|
import com.majinnaibu.minecraft.plugins.scorekeeper.ScoreKeeperPlugin;
|
||||||
|
|
||||||
public class MobScoresPlugin extends JavaPlugin {
|
public class MobScoresPlugin extends JavaPlugin {
|
||||||
private final MobDeathListener _mobDeathListener = new MobDeathListener(this);
|
|
||||||
private final PlayerConnectListener _playerConnectListener = new PlayerConnectListener(this);
|
|
||||||
private Map<Entity, Player> _claimedMobs = new HashMap<Entity, Player>();
|
private Map<Entity, Player> _claimedMobs = new HashMap<Entity, Player>();
|
||||||
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;
|
||||||
@@ -80,9 +77,8 @@ public class MobScoresPlugin extends JavaPlugin {
|
|||||||
pm.disablePlugin(this);
|
pm.disablePlugin(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
pm.registerEvent(Event.Type.ENTITY_DEATH, _mobDeathListener, Event.Priority.Monitor, this);
|
pm.registerEvents(new MobDeathListener(this), this);
|
||||||
pm.registerEvent(Event.Type.ENTITY_DAMAGE, _mobDeathListener, Event.Priority.Monitor, this);
|
pm.registerEvents(new PlayerConnectListener(this), this);
|
||||||
pm.registerEvent(Event.Type.PLAYER_JOIN, _playerConnectListener, Event.Priority.Monitor, this);
|
|
||||||
|
|
||||||
PluginDescriptionFile pdFile = this.getDescription();
|
PluginDescriptionFile pdFile = this.getDescription();
|
||||||
log.info(pdFile.getName() + " version " + pdFile.getVersion() + " is enabled!");
|
log.info(pdFile.getName() + " version " + pdFile.getVersion() + " is enabled!");
|
||||||
@@ -119,7 +115,6 @@ public class MobScoresPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void awardScore(Entity entity) {
|
public void awardScore(Entity entity) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
if(_claimedMobs.containsKey(entity)){
|
if(_claimedMobs.containsKey(entity)){
|
||||||
Class<?> scoreClass = entity.getClass();
|
Class<?> scoreClass = entity.getClass();
|
||||||
|
|||||||
@@ -23,18 +23,19 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.event.entity.EntityListener;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
import com.majinnaibu.minecraft.plugins.mobscores.MobScoresPlugin;
|
import com.majinnaibu.minecraft.plugins.mobscores.MobScoresPlugin;
|
||||||
|
|
||||||
public class MobDeathListener extends EntityListener {
|
public class MobDeathListener implements Listener {
|
||||||
private MobScoresPlugin _plugin = null;
|
private MobScoresPlugin _plugin = null;
|
||||||
|
|
||||||
public MobDeathListener(MobScoresPlugin plugin) {
|
public MobDeathListener(MobScoresPlugin plugin) {
|
||||||
_plugin = plugin;
|
_plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler
|
||||||
public void onEntityDamage(EntityDamageEvent event) {
|
public void onEntityDamage(EntityDamageEvent event) {
|
||||||
if(event instanceof EntityDamageByEntityEvent){
|
if(event instanceof EntityDamageByEntityEvent){
|
||||||
EntityDamageByEntityEvent ev = (EntityDamageByEntityEvent) event;
|
EntityDamageByEntityEvent ev = (EntityDamageByEntityEvent) event;
|
||||||
@@ -45,12 +46,12 @@ public class MobDeathListener extends EntityListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler
|
||||||
public void onEntityDeath(EntityDeathEvent event) {
|
public void onEntityDeath(EntityDeathEvent event) {
|
||||||
_plugin.awardScore(event.getEntity());
|
_plugin.awardScore(event.getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler
|
||||||
public void onEntityExplode(EntityExplodeEvent event) {
|
public void onEntityExplode(EntityExplodeEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,18 +18,19 @@ along with MobScores. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
package com.majinnaibu.minecraft.plugins.mobscores.listeners;
|
package com.majinnaibu.minecraft.plugins.mobscores.listeners;
|
||||||
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerListener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
import com.majinnaibu.minecraft.plugins.mobscores.MobScoresPlugin;
|
import com.majinnaibu.minecraft.plugins.mobscores.MobScoresPlugin;
|
||||||
|
|
||||||
public class PlayerConnectListener extends PlayerListener {
|
public class PlayerConnectListener implements Listener {
|
||||||
private MobScoresPlugin _plugin = null;
|
private MobScoresPlugin _plugin = null;
|
||||||
|
|
||||||
public PlayerConnectListener(MobScoresPlugin plugin) {
|
public PlayerConnectListener(MobScoresPlugin plugin) {
|
||||||
_plugin = plugin;
|
_plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
_plugin.sendPlayerScoreTable(event.getPlayer());
|
_plugin.sendPlayerScoreTable(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user