Permalink
Browse files

Add merchant_trading check function.

  • Loading branch information...
jb-aero committed Oct 4, 2018
1 parent 11110b5 commit 754381a80f72d9ebbb861b901c6b86d8cc35af6d
Showing with 38 additions and 1 deletion.
  1. +38 −1 src/main/java/com/laytonsmith/core/functions/Trades.java
@@ -14,6 +14,7 @@
import com.laytonsmith.core.Static;
import com.laytonsmith.core.constructs.CArray;
import com.laytonsmith.core.constructs.CBoolean;
import com.laytonsmith.core.constructs.CNull;
import com.laytonsmith.core.constructs.CString;
import com.laytonsmith.core.constructs.CVoid;
import com.laytonsmith.core.constructs.Construct;
@@ -422,7 +423,7 @@ public String docs() {
@Override
public Class<? extends CREThrowable>[] thrown() {
return new Class[]{CREPlayerOfflineException.class, CRELengthException.class,
CREIllegalArgumentException.class};
CREIllegalArgumentException.class, CREBadEntityException.class, CREFormatException.class};
}
@Override
@@ -470,6 +471,42 @@ public String docs() {
}
}
@api
public static class merchant_trading extends Recipes.recipeFunction {
@Override
public Class<? extends CREThrowable>[] thrown() {
return new Class[]{CREBadEntityException.class, CREFormatException.class, CREFormatException.class,
CREIllegalArgumentException.class, CRELengthException.class};
}
@Override
public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {
MCMerchant merchant = GetMerchant(args[0], t);
return merchant.isTrading() ? new CString(merchant.getTrader().getUniqueId().toString(), t) : CNull.NULL;
}
@Override
public Version since() {
return CHVersion.V3_3_3;
}
@Override
public String getName() {
return "merchant_trading";
}
@Override
public Integer[] numArgs() {
return new Integer[]{1};
}
@Override
public String docs() {
return "UUID {specifier} Returns the UUID of the user trading with the merchant, or null if no one is.";
}
}
public static final HashMap<String, MCMerchantRecipe> MERCHANT_RECIPES = new HashMap<>();
public static final HashMap<String, MCMerchant> VIRTUAL_MERCHANTS = new HashMap<>();

0 comments on commit 754381a

Please sign in to comment.