Fixed NPE when running a custom build of CraftBukkit. This fixes issue #BUKKIT-765

Dieser Commit ist enthalten in:
Nathan Adams 2012-02-18 14:06:21 +00:00
Ursprung d057ee1e07
Commit 3b634b14f6
3 geänderte Dateien mit 6 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -1024,7 +1024,7 @@ public final class CraftServer implements Server {
} }
public void onPlayerJoin(Player player) { public void onPlayerJoin(Player player) {
if ((updater.isEnabled()) && (player.hasPermission(Server.BROADCAST_CHANNEL_ADMINISTRATIVE))) { if ((updater.isEnabled()) && (updater.getCurrent() != null) && (player.hasPermission(Server.BROADCAST_CHANNEL_ADMINISTRATIVE))) {
if ((updater.getCurrent().isBroken()) && (updater.getOnBroken().contains(updater.WARN_OPERATORS))) { if ((updater.getCurrent().isBroken()) && (updater.getOnBroken().contains(updater.WARN_OPERATORS))) {
player.sendMessage(ChatColor.DARK_RED + "The version of CraftBukkit that this server is running is known to be broken. Please consider updating to the latest version at dl.bukkit.org."); player.sendMessage(ChatColor.DARK_RED + "The version of CraftBukkit that this server is running is known to be broken. Please consider updating to the latest version at dl.bukkit.org.");
} else if ((updater.isUpdateAvailable()) && (updater.getOnUpdate().contains(updater.WARN_OPERATORS))) { } else if ((updater.isUpdateAvailable()) && (updater.getOnUpdate().contains(updater.WARN_OPERATORS))) {

Datei anzeigen

@ -65,8 +65,8 @@ public class AutoUpdater {
new Thread() { new Thread() {
@Override @Override
public void run() { public void run() {
current = service.getArtifact(currentSlug); current = service.getArtifact(currentSlug, "current artifact information; perhaps you are running a custom version?");
latest = service.getArtifact("latest-" + channel); latest = service.getArtifact("latest-" + channel, "latest artifact information");
if (isUpdateAvailable()) { if (isUpdateAvailable()) {
if ((current.isBroken()) && (onBroken.contains(WARN_CONSOLE))) { if ((current.isBroken()) && (onBroken.contains(WARN_CONSOLE))) {

Datei anzeigen

@ -1,15 +1,11 @@
package org.bukkit.craftbukkit.updater; package org.bukkit.craftbukkit.updater;
import com.google.gson.*; import com.google.gson.*;
import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URLEncoder;
import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
@ -25,13 +21,13 @@ public class BukkitDLUpdaterService {
this.host = host; this.host = host;
} }
public ArtifactDetails getArtifact(String slug) { public ArtifactDetails getArtifact(String slug, String name) {
try { try {
return fetchArtifact(slug); return fetchArtifact(slug);
} catch (UnsupportedEncodingException ex) { } catch (UnsupportedEncodingException ex) {
Logger.getLogger(BukkitDLUpdaterService.class.getName()).log(Level.WARNING, "Could not get Artifact details for the auto-updater: " + ex.getClass().getSimpleName()); Logger.getLogger(BukkitDLUpdaterService.class.getName()).log(Level.WARNING, "Could not get " + name + ": " + ex.getClass().getSimpleName());
} catch (IOException ex) { } catch (IOException ex) {
Logger.getLogger(BukkitDLUpdaterService.class.getName()).log(Level.WARNING, "Could not get Artifact details for the auto-updater: " + ex.getClass().getSimpleName()); Logger.getLogger(BukkitDLUpdaterService.class.getName()).log(Level.WARNING, "Could not get " + name + ": " + ex.getClass().getSimpleName());
} }
return null; return null;