Browse files

Improve a couple edge cases

Uses of GetCommandSender() don't always handle null, so let's use console just in case. This code should rarely run, though, since players in events shouldn't be offline.

Also, because we have "enchants" in two places in item arrays, I tried to unify it a little by only prioritising meta array enchants, but it's possible that scripts might add an enchant to only the item enchant array and NOT the meta enchant array. To prioritise one over the other, it'd be safer if we first give a warning period. I'm not sure how best to accomplish this without affecting logic, so for now keep processing twice. It should be revisited later.
  • Loading branch information...
PseudoKnight committed Oct 28, 2017
1 parent d387eb6 commit 4fd48e5a1281721e6b1a221f953e9594da676419
@@ -322,7 +322,7 @@ public MCItemStack item(Construct i, Target t) {
// Fallback to enchants in item array if not in meta
if ((meta == null || !meta.hasEnchants()) && item.containsKey("enchants")) {
if (item.containsKey("enchants")) {
try {
Map<MCEnchantment, Integer> enchants = enchants((CArray) item.get("enchants", t), t);
for (Map.Entry<MCEnchantment, Integer> entry : enchants.entrySet()) {
@@ -98,8 +98,10 @@ public final void execute(ParseTree tree, BoundEvent b, Environment env, BoundEv
MCPlayer p = Static.GetPlayer(c, Target.UNKNOWN);
} catch(CREPlayerOfflineException e){
// Set env player to null to prevent incorrect inherited player from being used in a player event.
// Set env CommandSender to prevent incorrect inherited player from being used in a player event.
if(env.getEnv(CommandHelperEnvironment.class).GetPlayer() != null) {
ProfilePoint event = null;

0 comments on commit 4fd48e5

Please sign in to comment.