Merge remote-tracking branch 'origin/master'

This commit is contained in:
Ethan 2020-08-01 18:57:50 -04:00
commit 29df32d748
3 changed files with 31 additions and 5 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]);

View File

@ -110,7 +110,7 @@ public class NBTTags extends ItemStat {
((StringListData) data).getList().forEach(tag -> {
array.add(tag);
item.addItemTag(new ItemTag(tag.substring(0, tag.indexOf(' ')), tag.substring(tag.indexOf(' ') + 1)));
item.addItemTag(new ItemTag(tag.substring(0, tag.indexOf(' ')), calculateObjectType(tag.substring(tag.indexOf(' ') + 1))));
});
item.addItemTag(new ItemTag("MMOITEMS_NBTTAGS", array.toString()));
}
@ -121,4 +121,20 @@ public class NBTTags extends ItemStat {
mmoitem.setData(ItemStat.NBT_TAGS,
new StringListData(new JsonParser().parse(mmoitem.getNBT().getString("MMOITEMS_NBTTAGS")).getAsJsonArray()));
}
public Object calculateObjectType(String input) {
if(input.equalsIgnoreCase("true")) return (Boolean) true;
if(input.equalsIgnoreCase("false")) return (Boolean) false;
try {
int value = Integer.parseInt(input);
return (Integer) value;
} catch(NumberFormatException e) {}
if(input.contains("[") && input.contains("]")) {
List<String> entries = new ArrayList<>();
for(String s : input.replace("[", "").replace("]", "").split("\\,"))
entries.add(s.replace("\"", ""));
return (List<?>) entries;
}
return (String) input;
}
}