* Tweak our CommandSender.

* In lieu of running the plugin and causing confusion, give them an RuntimeException.
This commit is contained in:
Tux 2013-12-06 21:42:03 -05:00
parent 7c35aad456
commit 3925c3a313
2 changed files with 7 additions and 5 deletions

View File

@ -130,6 +130,8 @@ public class RedisBungee extends Plugin implements Listener {
loadConfig(); loadConfig();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} catch (JedisConnectionException e) {
throw new RuntimeException("Unable to connect to your Redis server!", e);
} }
if (pool != null) { if (pool != null) {
Jedis tmpRsc = pool.getResource(); Jedis tmpRsc = pool.getResource();
@ -184,7 +186,7 @@ public class RedisBungee extends Plugin implements Listener {
} }
} }
private void loadConfig() throws IOException { private void loadConfig() throws IOException, JedisConnectionException {
if (!getDataFolder().exists()) { if (!getDataFolder().exists()) {
getDataFolder().mkdir(); getDataFolder().mkdir();
} }
@ -261,10 +263,10 @@ public class RedisBungee extends Plugin implements Listener {
} catch (JedisConnectionException e) { } catch (JedisConnectionException e) {
if (rsc != null) if (rsc != null)
pool.returnBrokenResource(rsc); pool.returnBrokenResource(rsc);
getLogger().log(Level.WARNING, "Failed to connect to your Redis server! RedisBungee will still work, albeit with reduced functionality.", e);
pool.destroy(); pool.destroy();
pool = null; pool = null;
rsc = null; rsc = null;
throw e;
} finally { } finally {
if (rsc != null && pool != null) { if (rsc != null && pool != null) {
pool.returnResource(rsc); pool.returnResource(rsc);

View File

@ -9,9 +9,9 @@ package com.imaginarycode.minecraft.redisbungee;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
/** /**
* This class is the CommandSender that RedisBungee uses to dispatch commands to BungeeCord. * This class is the CommandSender that RedisBungee uses to dispatch commands to BungeeCord.
@ -40,7 +40,7 @@ public class RedisBungeeCommandSender implements CommandSender {
@Override @Override
public Collection<String> getGroups() { public Collection<String> getGroups() {
return ProxyServer.getInstance().getConsole().getGroups(); return Collections.emptySet();
} }
@Override @Override
@ -55,7 +55,7 @@ public class RedisBungeeCommandSender implements CommandSender {
@Override @Override
public boolean hasPermission(String s) { public boolean hasPermission(String s) {
return ProxyServer.getInstance().getConsole().hasPermission(s); return true;
} }
@Override @Override