Permalink
Browse files

Throw exception when trying to reuse ID

  • Loading branch information...
jb-aero committed Oct 24, 2018
1 parent 6a594f1 commit 491c18c9982a2fdb61ba1ec88b141aa24d87c446
Showing with 8 additions and 8 deletions.
  1. +8 −8 src/main/java/com/laytonsmith/core/functions/Trades.java
@@ -203,16 +203,16 @@ public String docs() {
@Override
public Class<? extends CREThrowable>[] thrown() {
return new Class[0];
return new Class[] {CREIllegalArgumentException.class};
}
@Override
public Construct exec(Target t, Environment env, Construct... args) throws ConfigRuntimeException {
if(VIRTUAL_MERCHANTS.containsKey(args[0].val())) {
return CBoolean.FALSE;
throw new CREIllegalArgumentException("There is already a merchant with id " + args[0].val(), t);
} else {
VIRTUAL_MERCHANTS.put(args[0].val(), Static.getServer().createMerchant(args[1].val()));
return CBoolean.TRUE;
return CVoid.VOID;
}
}
@@ -233,11 +233,11 @@ public String getName() {
@Override
public String docs() {
return "boolean {ID, title} Creates a merchant that can be traded with by players but is not attached to"
+ " a physical entity. Will return true if the ID was newly added, and false if the ID was already"
+ " in use. The ID given should not be a UUID. The title is the text that will display at the top"
+ " of the window while a player is trading with it. This list will persist across recompiles,"
+ " but not across server restarts.";
return "void {ID, title} Creates a merchant that can be traded with by players but is not attached to"
+ " a physical entity. The ID given should not be a UUID. The title is the text that will display"
+ " at the top of the window while a player is trading with it. Created merchants will persist"
+ " across recompiles, but not across server restarts. An exception will be thrown if a merchant"
+ " already exists using the given ID.";
}
}

0 comments on commit 491c18c

Please sign in to comment.