From 4fc838f9dce95234d3175184d1a3e7fc49e10f7e Mon Sep 17 00:00:00 2001 From: Ryan Leach Date: Wed, 20 Apr 2016 23:09:46 +0930 Subject: [PATCH] Update to SpongeAPI 4.0.3 --- build.gradle | 4 ++-- .../id/rleach/translate/TranslateWithBing.java | 16 +++++++++------- .../data/LanguageDataManipulatorBuilder.java | 3 +-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/build.gradle b/build.gradle index 74e5679..f3088d7 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ apply plugin: 'java' apply plugin: 'com.github.johnrengelman.shadow' group 'au.id.rleach' -version '1.1.1' +version '1.1.2' sourceCompatibility = 1.8 @@ -40,5 +40,5 @@ dependencies { testCompile group: 'junit', name: 'junit', version: '4.11' shadow translator compile translator - compile 'org.spongepowered:spongeapi:3.0.0' + compile 'org.spongepowered:spongeapi:4.0.3' } \ No newline at end of file diff --git a/src/main/java/au/id/rleach/translate/TranslateWithBing.java b/src/main/java/au/id/rleach/translate/TranslateWithBing.java index 59b9c24..eb1d1f3 100644 --- a/src/main/java/au/id/rleach/translate/TranslateWithBing.java +++ b/src/main/java/au/id/rleach/translate/TranslateWithBing.java @@ -36,13 +36,17 @@ import org.spongepowered.api.text.format.TextColors; import org.spongepowered.api.text.serializer.TextSerializers; -import javax.inject.Inject; import java.io.IOException; import java.net.URL; -import java.util.*; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Optional; + +import javax.inject.Inject; -@Plugin(id="TranslateWithBing", name="TranslateWithBing", version="1.1.1") +@Plugin(id="translatewithbing", name="TranslateWithBing", version="1.1.2") public class TranslateWithBing { @Inject @@ -194,10 +198,8 @@ public void chatEvent(final MessageChannelEvent.Chat chat, @First final Player p .map(p -> (Player) p) .iterator(); final ImmutableListMultimap multiMap = Multimaps.index(playerI, this::languageFromPlayer); - final Optional optMessage = chat.getMessage(); - optMessage.ifPresent( - message -> sendTranslatedMessages(player, multiMap, message) - ); + final Text message = chat.getMessage(); + sendTranslatedMessages(player, multiMap, message); } private Language languageFromPlayer(final Player p){ diff --git a/src/main/java/au/id/rleach/translate/data/LanguageDataManipulatorBuilder.java b/src/main/java/au/id/rleach/translate/data/LanguageDataManipulatorBuilder.java index c71168f..902d1b7 100644 --- a/src/main/java/au/id/rleach/translate/data/LanguageDataManipulatorBuilder.java +++ b/src/main/java/au/id/rleach/translate/data/LanguageDataManipulatorBuilder.java @@ -3,7 +3,6 @@ import org.spongepowered.api.data.DataHolder; import org.spongepowered.api.data.DataView; import org.spongepowered.api.data.manipulator.DataManipulatorBuilder; -import org.spongepowered.api.util.persistence.InvalidDataException; import java.util.Optional; @@ -20,7 +19,7 @@ public Optional createFrom(DataHolder dataHolder) { } @Override - public Optional build(DataView container) throws InvalidDataException { + public Optional build(DataView container) { // Note that this should check the Queries.CONTENT_VERSION, but for the sake of demonstration // it's not necessary if (container.contains(TranslateKeys.Language.getQuery())) {