Skip to content

Commit

Permalink
fixed npe in vault integration
Browse files Browse the repository at this point in the history
  • Loading branch information
strumswell committed Mar 2, 2020
1 parent c86023d commit f0a2b05
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 39 deletions.
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: ServerlistMOTD
author: Strumswell
version: X-2018-10-20
version: X-2020-03-02
description: Change your Serverlist Motd!
load: POSTWORLD
depend: [ProtocolLib]
Expand Down
5 changes: 1 addition & 4 deletions src/cloud/bolte/serverlistmotd/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ public void onEnable() {
saveDefaultConfig();
IO.loadFlatfileIntoHashMap(new File("plugins/ServerlistMOTD/IP_UUID.dat"), IP_UUID);

//Handover plugin instance to SpigotConfig
SpigotConfig config = new SpigotConfig(this);

//Handover plugin instance to ProtocolLibImplementation
ProtocolLibImplementation pli = new ProtocolLibImplementation(this);

//Register listeners
Expand All @@ -67,7 +64,7 @@ public void onEnable() {
this.getCommand("serverlist").setExecutor(new Serverlist());

//Setup Vault for money var
VaultIntegration.setupVault();
VaultIntegration.setupEconomy();

//Timer for saving userdata to disk
BukkitScheduler scheduler = getServer().getScheduler();
Expand Down
2 changes: 1 addition & 1 deletion src/cloud/bolte/serverlistmotd/cmd/Serverlist.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
switch(args.length) {
case 0:
sender.sendMessage("§8§l---------------------------------");
sender.sendMessage("§e§lServerlist§6§lMOTD | §cFIRESTORM UPDATE");
sender.sendMessage("§e§lServerlist§6§lMOTD");
sender.sendMessage("§7 §o~by Strumswell");
sender.sendMessage("§8§l---------------------------------");
sender.sendMessage("§6§l> §eList of commands:");
Expand Down
35 changes: 2 additions & 33 deletions src/cloud/bolte/serverlistmotd/util/VaultIntegration.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,13 @@
import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider;

import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission;

public class VaultIntegration {

public static Permission perms = null;
public static Economy econ = null;
public static Chat chat = null;

private static boolean setupPermissions() {
RegisteredServiceProvider<Permission> rsp = Bukkit.getServer().getServicesManager()
.getRegistration(Permission.class);
perms = rsp.getProvider();
return perms != null;
}

private static boolean setupChat() {
RegisteredServiceProvider<Chat> rsp = Bukkit.getServer().getServicesManager().getRegistration(Chat.class);
chat = rsp.getProvider();
return chat != null;
}

private static boolean setupEconomy() {
public static boolean setupEconomy() {
if (Bukkit.getPluginManager().getPlugin("Vault") == null) {
Bukkit.getLogger().warning("[ServerlistMOTD] Couldn't find Vault. No %money%!");
return false;
Expand All @@ -40,25 +23,11 @@ private static boolean setupEconomy() {
return false;
}
econ = rsp.getProvider();
Bukkit.getLogger().info("[ServerlistMOTD] Using "+econ+" via Vault.");
return econ != null;
}

public static Economy getEcononomy() {
return econ;
}

public static Permission getPermissions() {
return perms;
}

public static Chat getChat() {
return chat;
}

public static void setupVault() {
if (setupEconomy()){
setupChat();
setupPermissions();
}
}
}

0 comments on commit f0a2b05

Please sign in to comment.