Skip to content

Commit

Permalink
Update to forge 2838, fix dupe issue and a discord placeholder issue …
Browse files Browse the repository at this point in the history
…with message formatting
  • Loading branch information
NickImpact committed Dec 21, 2020
1 parent 90ddc21 commit 7b04029
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public String parse(@NonNull String message, @NonNull List<Supplier<Object>> sou
Optional.ofNullable(this.placeholders.get(placeholder.toLowerCase())).ifPresent(parser -> {
String out = parser.parse(sources);
if(out != null) {
result.set(result.get().replaceAll("[{][{]" + placeholder + "[}][}]", out));
result.set(result.get().replace("[{][{]" + placeholder + "[}][}]", out));
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,15 +416,34 @@ public BuyItNowMessage.Purchase.Response processPurchase(BuyItNowMessage.Purchas
ps.setString(1, request.getListingID().toString());
return this.results(ps, results -> {
boolean successful = results.next();
BuyItNow listing = null;

UUID seller = this.getListing(request.getListingID()).map(Listing::getLister).orElse(Listing.SERVER_ID);
JsonObject json = GTSPlugin.getInstance().getGson().fromJson(results.getString("listing"), JsonObject.class);
if(!json.has("type")) {
throw new JsonParseException("Invalid Listing: Missing type");
}

String type = json.get("type").getAsString();
if(type.equals("bin")) {
listing = GTSService.getInstance().getGTSComponentManager()
.getListingResourceManager(BuyItNow.class)
.get()
.getDeserializer()
.deserialize(json);
} else {
throw new IllegalArgumentException("Can't purchase an Auction");
}

if(successful) {
successful = !listing.isPurchased();
}

return new BINPurchaseMessage.Response(
GTSPlugin.getInstance().getMessagingService().generatePingID(),
request.getID(),
request.getListingID(),
request.getActor(),
seller,
listing != null ? listing.getLister() : Listing.SERVER_ID,
successful,
successful ? null : ErrorCodes.ALREADY_PURCHASED
);
Expand Down
2 changes: 1 addition & 1 deletion plugin/plugin-sponge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ plugins {
apply plugin: 'net.minecraftforge.gradle.forge'

minecraft {
version = "1.12.2-14.23.5.2768"
version = "1.12.2-14.23.5.2838"
runDir = "run"
mappings = "snapshot_20180324"
useDepAts = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ public GTSSpongePlugin(GTSSpongeBootstrap bootstrap, org.slf4j.Logger fallback)
}

public void preInit() {
Utilities.setContainer(this.bootstrap.getContainer());
Impactor.getInstance().getRegistry().register(GTSPlugin.class, this);
ApiRegistrationUtil.register(new GTSAPIProvider());

String sponge = Sponge.getGame().getPlatform().getContainer(Platform.Component.API).getVersion().orElse("");
if(!sponge.startsWith("7.3")) {
throw new IllegalStateException("Invalid Sponge version");
}

Utilities.setContainer(this.bootstrap.getContainer());
Impactor.getInstance().getRegistry().register(GTSPlugin.class, this);
ApiRegistrationUtil.register(new GTSAPIProvider());

this.displayBanner();

this.getPluginLogger().info("Initializing API Components...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ public CompletableFuture<Boolean> purchase(UUID buyer, SpongeBuyItNow listing, O
Sponge.getServer().getPlayer(buyer).ifPresent(player -> {
player.sendMessage(parser.parse(
Utilities.readMessageConfigOption(MsgConfigKeys.REQUEST_FAILED),
Lists.newArrayList(() -> ErrorCodes.THIRD_PARTY_CANCELLED)
Lists.newArrayList(() -> response.getErrorCode().orElse(ErrorCodes.UNKNOWN))
));

player.sendMessage(parser.parse(
Expand Down

0 comments on commit 7b04029

Please sign in to comment.