2017-07-25 09:20:36 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.bridge;
|
2016-07-21 21:53:25 +00:00
|
|
|
|
2017-10-13 18:35:11 +00:00
|
|
|
import me.libraryaddict.disguise.DisguiseAPI;
|
|
|
|
import me.libraryaddict.disguise.LibsDisguises;
|
2018-07-25 00:06:58 +00:00
|
|
|
import me.totalfreedom.libsdisguise.DisallowedDisguises;
|
|
|
|
import me.totalfreedom.libsdisguise.TF_DisguiseAPI;
|
2016-07-21 21:53:25 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
|
|
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
|
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
|
|
|
|
public class LibsDisguisesBridge extends FreedomService
|
|
|
|
{
|
|
|
|
|
2017-10-13 18:35:11 +00:00
|
|
|
private LibsDisguises libsDisguisesPlugin = null;
|
2016-07-21 21:53:25 +00:00
|
|
|
|
|
|
|
public LibsDisguisesBridge(TotalFreedomMod plugin)
|
|
|
|
{
|
|
|
|
super(plugin);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onStart()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onStop()
|
|
|
|
{
|
|
|
|
}
|
2017-10-13 18:35:11 +00:00
|
|
|
|
2016-07-21 21:53:25 +00:00
|
|
|
public LibsDisguises getLibsDisguisesPlugin()
|
|
|
|
{
|
|
|
|
if (libsDisguisesPlugin == null)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
final Plugin libsDisguises = server.getPluginManager().getPlugin("LibsDisguises");
|
|
|
|
if (libsDisguises != null)
|
|
|
|
{
|
|
|
|
if (libsDisguises instanceof LibsDisguises)
|
|
|
|
{
|
2018-07-31 07:01:29 +00:00
|
|
|
libsDisguisesPlugin = (LibsDisguises)libsDisguises;
|
2016-07-21 21:53:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
FLog.severe(ex);
|
|
|
|
}
|
|
|
|
}
|
2016-08-26 20:06:20 +00:00
|
|
|
|
2016-07-21 21:53:25 +00:00
|
|
|
return libsDisguisesPlugin;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Boolean isDisguised(Player player)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
|
|
|
if (libsDisguises != null)
|
|
|
|
{
|
|
|
|
return DisguiseAPI.isDisguised(player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
FLog.severe(ex);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void undisguiseAll(boolean admins)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
|
|
|
|
|
|
|
if (libsDisguises == null)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Player player : server.getOnlinePlayers())
|
|
|
|
{
|
|
|
|
if (DisguiseAPI.isDisguised(player))
|
|
|
|
{
|
|
|
|
if (!admins && plugin.al.isAdmin(player))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
DisguiseAPI.undisguiseToAll(player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
FLog.severe(ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-26 20:06:20 +00:00
|
|
|
public void setDisguisesEnabled(boolean state)
|
2016-07-21 21:53:25 +00:00
|
|
|
{
|
2016-08-26 20:06:20 +00:00
|
|
|
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
2016-07-21 21:53:25 +00:00
|
|
|
|
2016-08-26 20:06:20 +00:00
|
|
|
if (libsDisguises == null)
|
2016-07-21 21:53:25 +00:00
|
|
|
{
|
2016-08-26 20:06:20 +00:00
|
|
|
return;
|
2016-07-21 21:53:25 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 20:06:20 +00:00
|
|
|
if (state)
|
2016-07-21 21:53:25 +00:00
|
|
|
{
|
2018-07-25 00:06:58 +00:00
|
|
|
TF_DisguiseAPI.enableDisguises();
|
2016-07-21 21:53:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-07-25 00:06:58 +00:00
|
|
|
TF_DisguiseAPI.disableDisguises();
|
2016-07-21 21:53:25 +00:00
|
|
|
}
|
2016-08-26 20:06:20 +00:00
|
|
|
}
|
2016-07-21 21:53:25 +00:00
|
|
|
|
2016-08-26 20:06:20 +00:00
|
|
|
public boolean isDisguisesEnabled()
|
|
|
|
{
|
|
|
|
return !DisallowedDisguises.disabled;
|
2016-07-21 21:53:25 +00:00
|
|
|
}
|
|
|
|
|
2018-07-28 07:11:48 +00:00
|
|
|
public boolean isEnabled()
|
2016-07-21 21:53:25 +00:00
|
|
|
{
|
2018-07-28 07:11:48 +00:00
|
|
|
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
2016-07-21 21:53:25 +00:00
|
|
|
|
2018-07-28 07:11:48 +00:00
|
|
|
return libsDisguises != null && libsDisguises.isEnabled();
|
2017-10-13 18:35:11 +00:00
|
|
|
}
|
2017-07-25 09:20:36 +00:00
|
|
|
}
|