Skip to content

Commit

Permalink
Add merchant_trading check function.
Browse files Browse the repository at this point in the history
  • Loading branch information
jb-aero committed Oct 4, 2018
1 parent 11110b5 commit 754381a
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion src/main/java/com/laytonsmith/core/functions/Trades.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -422,7 +423,7 @@ public static class popen_trading extends Recipes.recipeFunction {
@Override
public Class<? extends CREThrowable>[] thrown() {
return new Class[]{CREPlayerOfflineException.class, CRELengthException.class,
CREIllegalArgumentException.class};
CREIllegalArgumentException.class, CREBadEntityException.class, CREFormatException.class};
}

@Override
Expand Down Expand Up @@ -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<>();

Expand Down

0 comments on commit 754381a

Please sign in to comment.