Small fixes

- Fixed PlayerData error
- Fixed ArrayIndexOutOfBoundsException in MI command
This commit is contained in:
ASangarin 2020-08-01 21:59:07 +02:00
parent 8d876e49b0
commit be44a8cbc5
2 changed files with 14 additions and 4 deletions

View File

@ -188,8 +188,13 @@ public class MMOItems extends JavaPlugin {
* allows now to use a glitchy itemEquipEvent. must be called after
* loading the config since it checks for a config option
*/
Bukkit.getScheduler().runTaskTimer(this, () -> Bukkit.getOnlinePlayers().forEach(player -> PlayerData.get(player).checkForInventoryUpdate()),
100, getConfig().getInt("inventory-update-delay"));
Bukkit.getScheduler().runTaskTimer(this, new Runnable() {
@Override
public void run() {
for(Player player : Bukkit.getOnlinePlayers())
PlayerData.get(player).checkForInventoryUpdate();
}
}, 100, getConfig().getInt("inventory-update-delay"));
if (Bukkit.getPluginManager().getPlugin("Residence") != null) {
flagPlugin = new ResidenceFlags();

View File

@ -1099,8 +1099,13 @@ public class MMOItemsCommand implements CommandExecutor {
"Usage: /mi <type> <item> (player) (min-max) (unident-chance) (drop-chance)");
// target
Player target = args.length > 2 ? Bukkit.getPlayer(args[2]) : (Player) sender;
Validate.notNull(target, "Could not find player called '" + args[2] + "'.");
Player target;
if(args.length > 2) {
target = Bukkit.getPlayer(args[2]);
Validate.notNull(target, "Could not find player called '" + args[2] + "'.");
}
else
target = (Player) sender;
// item
Type type = MMOItems.plugin.getTypes().getOrThrow(args[0]);