Add config check for Towny and Factions channel in /chwho

This commit is contained in:
Aust1n46 2020-05-04 22:16:36 -04:00
parent ea62962bd3
commit 950a74bd23
2 changed files with 14 additions and 10 deletions

View File

@ -76,11 +76,11 @@ public class Chwho extends MineverseCommand {
continue; continue;
} }
} }
if(pluginManager.isPluginEnabled("Towny") && sender instanceof Player) { if(plugin.getConfig().getBoolean("enable_towny_channel") && pluginManager.isPluginEnabled("Towny") && sender instanceof Player) {
try { try {
Resident r = TownyUniverse.getDataSource().getResident(p.getName());
Resident pp = TownyUniverse.getDataSource().getResident(((Player) sender).getName());
if(channel.getName().equalsIgnoreCase("Town")) { if(channel.getName().equalsIgnoreCase("Town")) {
Resident r = TownyUniverse.getDataSource().getResident(p.getName());
Resident pp = TownyUniverse.getDataSource().getResident(((Player) sender).getName());
if(!pp.hasTown()) { if(!pp.hasTown()) {
if(playerlist.length() + p.getName().length() > linecount) { if(playerlist.length() + p.getName().length() > linecount) {
playerlist += "\n"; playerlist += "\n";
@ -103,6 +103,8 @@ public class Chwho extends MineverseCommand {
} }
} }
if(channel.getName().equalsIgnoreCase("Nation")) { if(channel.getName().equalsIgnoreCase("Nation")) {
Resident r = TownyUniverse.getDataSource().getResident(p.getName());
Resident pp = TownyUniverse.getDataSource().getResident(((Player) sender).getName());
if(!pp.hasNation()) { if(!pp.hasNation()) {
if(playerlist.length() + p.getName().length() > linecount) { if(playerlist.length() + p.getName().length() > linecount) {
playerlist += "\n"; playerlist += "\n";
@ -129,11 +131,11 @@ public class Chwho extends MineverseCommand {
ex.printStackTrace(); ex.printStackTrace();
} }
} }
if(pluginManager.isPluginEnabled("Factions") && sender instanceof Player) { if(plugin.getConfig().getBoolean("enable_factions_channel") && pluginManager.isPluginEnabled("Factions") && sender instanceof Player) {
try { try {
MPlayer mplayer = MPlayer.get(p.getPlayer());
MPlayer mplayerp = MPlayer.get((Player) sender);
if(channel.getName().equalsIgnoreCase("Faction")) { if(channel.getName().equalsIgnoreCase("Faction")) {
MPlayer mplayer = MPlayer.get(p.getPlayer());
MPlayer mplayerp = MPlayer.get((Player) sender);
if(!mplayerp.hasFaction()) { if(!mplayerp.hasFaction()) {
if(playerlist.length() + p.getName().length() > linecount) { if(playerlist.length() + p.getName().length() > linecount) {
playerlist += "\n"; playerlist += "\n";

View File

@ -350,9 +350,9 @@ public class ChatListener implements Listener {
} }
if(plugin.getConfig().getBoolean("enable_towny_channel") && pluginManager.isPluginEnabled("Towny")) { if(plugin.getConfig().getBoolean("enable_towny_channel") && pluginManager.isPluginEnabled("Towny")) {
try { try {
Resident r = TownyUniverse.getDataSource().getResident(p.getName());
Resident pp = TownyUniverse.getDataSource().getResident(mcp.getName());
if(eventChannel.getName().equalsIgnoreCase("Town")) { if(eventChannel.getName().equalsIgnoreCase("Town")) {
Resident r = TownyUniverse.getDataSource().getResident(p.getName());
Resident pp = TownyUniverse.getDataSource().getResident(mcp.getName());
if(!pp.hasTown()) { if(!pp.hasTown()) {
recipients.remove(p.getPlayer()); recipients.remove(p.getPlayer());
recipientCount--; recipientCount--;
@ -370,6 +370,8 @@ public class ChatListener implements Listener {
} }
} }
if(eventChannel.getName().equalsIgnoreCase("Nation")) { if(eventChannel.getName().equalsIgnoreCase("Nation")) {
Resident r = TownyUniverse.getDataSource().getResident(p.getName());
Resident pp = TownyUniverse.getDataSource().getResident(mcp.getName());
if(!pp.hasNation()) { if(!pp.hasNation()) {
recipients.remove(p.getPlayer()); recipients.remove(p.getPlayer());
recipientCount--; recipientCount--;
@ -394,9 +396,9 @@ public class ChatListener implements Listener {
if(plugin.getConfig().getBoolean("enable_factions_channel") && pluginManager.isPluginEnabled("Factions")) { if(plugin.getConfig().getBoolean("enable_factions_channel") && pluginManager.isPluginEnabled("Factions")) {
try { try {
MPlayer mplayer = MPlayer.get(mcp.getPlayer());
MPlayer mplayerp = MPlayer.get(p.getPlayer());
if(eventChannel.getName().equalsIgnoreCase("Faction")) { if(eventChannel.getName().equalsIgnoreCase("Faction")) {
MPlayer mplayer = MPlayer.get(mcp.getPlayer());
MPlayer mplayerp = MPlayer.get(p.getPlayer());
if(!mplayer.hasFaction()) { if(!mplayer.hasFaction()) {
recipients.remove(p.getPlayer()); recipients.remove(p.getPlayer());
recipientCount--; recipientCount--;