From 526df76ca99a3082371dcec42764a6f8d4758316 Mon Sep 17 00:00:00 2001 From: snowleo Date: Wed, 6 Jul 2011 00:55:05 +0200 Subject: [PATCH] Weather sign --- .../essentials/signs/SignWeather.java | 56 +++++++++++++++++++ Essentials/src/messages.properties | 1 + Essentials/src/messages_da.properties | 1 + Essentials/src/messages_de.properties | 1 + Essentials/src/messages_en.properties | 1 + Essentials/src/messages_fr.properties | 1 + Essentials/src/messages_nl.properties | 1 + 7 files changed, 62 insertions(+) create mode 100644 Essentials/src/com/earth2me/essentials/signs/SignWeather.java diff --git a/Essentials/src/com/earth2me/essentials/signs/SignWeather.java b/Essentials/src/com/earth2me/essentials/signs/SignWeather.java new file mode 100644 index 000000000..05496ac14 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/signs/SignWeather.java @@ -0,0 +1,56 @@ +package com.earth2me.essentials.signs; + +import com.earth2me.essentials.ChargeException; +import com.earth2me.essentials.IEssentials; +import com.earth2me.essentials.Trade; +import com.earth2me.essentials.User; +import com.earth2me.essentials.Util; + + +public class SignWeather extends EssentialsSign +{ + public SignWeather() + { + super("Weather"); + } + + @Override + protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException + { + validateTrade(sign, 2, ess); + final String timeString = sign.getLine(1); + if ("Sun".equalsIgnoreCase(timeString)) + { + sign.setLine(1, "§2Sun"); + return true; + } + if ("Storm".equalsIgnoreCase(timeString)) + { + sign.setLine(1, "§2Storm"); + return true; + } + throw new SignException(Util.i18n("onlySunStorm")); + } + + @Override + protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException + { + final Trade charge = getTrade(sign, 2, ess); + charge.isAffordableFor(player); + final String weatherString = sign.getLine(1); + if ("§2Sun".equalsIgnoreCase(weatherString)) + { + player.getWorld().setStorm(false); + charge.charge(player); + return true; + } + if ("§2Storm".equalsIgnoreCase(weatherString)) + { + player.getWorld().setStorm(true); + charge.charge(player); + return true; + } + throw new SignException(Util.i18n("onlySunStorm")); + } +} + diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index 1467df312..11bbd4687 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -199,6 +199,7 @@ now = now numberRequired = A number goes there, silly. onlyDayNight = /time only supports day/night. onlyPlayers = Only in-game players can use {0}. +onlySunStorm = /weather only supports sun/storm. parseError = Error parsing {0} on line {1} pendingTeleportCancelled = \u00a7cPending teleportation request cancelled. permissionsError = Missing Permissions/GroupManager; chat prefixes/suffixes will be disabled. diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index 8f696830c..27b3602b0 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -201,6 +201,7 @@ now = nu numberRequired = Der skal v\u00e6re et nummer, fjolle. onlyDayNight = /time underst\u00f8tter kun day/night. onlyPlayers = Kun in-game spillere kan bruge {0}. +onlySunStorm = /weather only supports sun/storm. parseError = Fejl ved parsing {0} p\u00e5 linje {1} pendingTeleportCancelled = \u00a7cVentende teleportations anmodning aflyst. permissionsError = Mangler Permissions/GroupManager; chat pr\u00e6fikser/suffikser vil v\u00e6re sl\u00e5et fra. diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index 7b287c583..110b6bcc6 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -199,6 +199,7 @@ now = jetzt numberRequired = Ein Zahl wird ben\u00f6tigt. onlyDayNight = /time unterst\u00fctzt nur day/night. onlyPlayers = Nur Spieler k\u00f6nnen {0} benutzen. +onlySunStorm = /weather unterst\u00fctzt nur sun/storm. parseError = Fehler beim Parsen von {0} in Zeile {1} pendingTeleportCancelled = \u00a7cLaufende Teleportierung abgebrochen. permissionsError = Permissions/GroupManager fehlt; Chat-Prefixe/-Suffixe sind ausgeschaltet. diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index 1467df312..11bbd4687 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -199,6 +199,7 @@ now = now numberRequired = A number goes there, silly. onlyDayNight = /time only supports day/night. onlyPlayers = Only in-game players can use {0}. +onlySunStorm = /weather only supports sun/storm. parseError = Error parsing {0} on line {1} pendingTeleportCancelled = \u00a7cPending teleportation request cancelled. permissionsError = Missing Permissions/GroupManager; chat prefixes/suffixes will be disabled. diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index c53559ed3..6cd2622a2 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -199,6 +199,7 @@ now = maintenant numberRequired = On a besoin d''un nombre ici, idiot. onlyDayNight = /time ne supporte que (jour) day/night (nuit). onlyPlayers = Seulement les joueurs en jeu peuvent utiliser {0}. +onlySunStorm = /weather only supports sun/storm. parseError = Erreur de conversion {0} \u00e0 la ligne {1} pendingTeleportCancelled = \u00a7cRequete de t\u00e9l\u00e9portation annul\u00e9e. permissionsError = Permissions/GroupManager manquant, les pr\u00e9fixes et suffixes ne seront pas affich\u00e9s. diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index 549c6a439..6ee9954e3 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -200,6 +200,7 @@ now = nu numberRequired = Er moet daar een nummer, grapjas. onlyDayNight = /time oondersteund alleen day/night. onlyPlayers = Alleen in-game spelers kunnen {0} gebruiken. +onlySunStorm = /weather only supports sun/storm. parseError = Fout bij ontleding {0} op regel {1} pendingTeleportCancelled = \u00a7cAangevraagde teleportatie afgelast. permissionsError = Vermisde Permissions/GroupManager; chat prefixes/suffixes worden uitgeschakeld.