-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# This is a combination of 27 commits.
# The first commit's message is: Readd /uall and /dtoggle. Resolves #1793 # The 2nd commit message will be skipped: # Update Command_disguisetoggle.java # The 3rd commit message will be skipped: # Update LibsDisguisesBridge.java # The 4th commit message will be skipped: # Update Command_disguisetoggle.java # The 5th commit message will be skipped: # Update LibsDisguisesBridge.java # The 6th commit message will be skipped: # Update Command_undisguiseall.java # The 7th commit message will be skipped: # Check for errors, and add soft depend # The 8th commit message will be skipped: # Add uall # The 9th commit message will be skipped: # Fix Dtoggle # The 10th commit message will be skipped: # Fix Dtoggle part 2 # The 11th commit message will be skipped: # Formatting # The 12th commit message will be skipped: # More formatting # The 13th commit message will be skipped: # Remove unused import # The 14th commit message will be skipped: # Fix possible NPE # The 15th commit message will be skipped: # Fixes # The 16th commit message will be skipped: # fixes # The 17th commit message will be skipped: # fixes # The 18th commit message will be skipped: # Update LibsDisguisesBridge.java # The 19th commit message will be skipped: # Update Command_disguisetoggle.java # The 20th commit message will be skipped: # Update Command_undisguiseall.java # The 21st commit message will be skipped: # Add space # The 22nd commit message will be skipped: # Add space # The 23rd commit message will be skipped: # Resolves #1644 (#1716) # # Fix /doom breaking blocks # The 24th commit message will be skipped: # Block structure blocks from being placed # The 25th commit message will be skipped: # Improved wildcard command blocking. Fixes #1842 # The 26th commit message will be skipped: # Update the target IP when using /myadmin -o. Fixes #1841 # The 27th commit message will be skipped: # Block sign interaction. Fixes #1831
- Loading branch information
Showing
6 changed files
with
218 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
src/main/java/me/totalfreedom/totalfreedommod/bridge/LibsDisguisesBridge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
package me.totalfreedom.totalfreedommod.bridge; | ||
|
||
import me.libraryaddict.disguise.LibsDisguises; | ||
import me.libraryaddict.disguise.DisguiseAPI; | ||
import me.totalfreedom.totalfreedommod.FreedomService; | ||
import me.totalfreedom.totalfreedommod.TotalFreedomMod; | ||
import me.totalfreedom.totalfreedommod.util.FLog; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.plugin.Plugin; | ||
|
||
public class LibsDisguisesBridge extends FreedomService | ||
{ | ||
|
||
private LibsDisguises libsDisguisesPlugin = null; | ||
|
||
public LibsDisguisesBridge(TotalFreedomMod plugin) | ||
{ | ||
super(plugin); | ||
} | ||
|
||
@Override | ||
protected void onStart() | ||
{ | ||
} | ||
|
||
@Override | ||
protected void onStop() | ||
{ | ||
} | ||
|
||
public LibsDisguises getLibsDisguisesPlugin() | ||
{ | ||
if (libsDisguisesPlugin == null) | ||
{ | ||
try | ||
{ | ||
final Plugin libsDisguises = server.getPluginManager().getPlugin("LibsDisguises"); | ||
if (libsDisguises != null) | ||
{ | ||
if (libsDisguises instanceof LibsDisguises) | ||
{ | ||
libsDisguisesPlugin = (LibsDisguises) libsDisguises; | ||
} | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
FLog.severe(ex); | ||
} | ||
} | ||
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); | ||
} | ||
} | ||
|
||
public boolean setPluginEnabled(boolean enabled) | ||
{ | ||
Plugin ld = getLibsDisguisesPlugin(); | ||
|
||
if (ld == null) | ||
{ | ||
return false; | ||
} | ||
|
||
if (enabled) | ||
{ | ||
server.getPluginManager().enablePlugin(ld); | ||
} | ||
else | ||
{ | ||
server.getPluginManager().disablePlugin(ld); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public boolean isPluginEnabled() | ||
{ | ||
Plugin ld = getLibsDisguisesPlugin(); | ||
|
||
if (ld == null) | ||
{ | ||
return false; | ||
} | ||
|
||
return ld.isEnabled(); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/me/totalfreedom/totalfreedommod/command/Command_disguisetoggle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package me.totalfreedom.totalfreedommod.command; | ||
|
||
import me.totalfreedom.totalfreedommod.rank.Rank; | ||
import me.totalfreedom.totalfreedommod.util.FUtil; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH) | ||
@CommandParameters(description = "Toggle the disguise plugin", usage = "/<command>", aliases = "dtoggle") | ||
public class Command_disguisetoggle extends FreedomCommand | ||
{ | ||
|
||
@Override | ||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) | ||
{ | ||
if (plugin.ldb.getLibsDisguisesPlugin() == null) | ||
{ | ||
msg(ChatColor.RED + "LibsDisguises is not enabled."); | ||
return true; | ||
} | ||
|
||
boolean newState = !plugin.ldb.isPluginEnabled(); | ||
FUtil.adminAction(sender.getName(), (newState ? "Enabling" : "Disabling") + " disguises", false); | ||
|
||
if (!newState) | ||
{ | ||
plugin.ldb.undisguiseAll(true); | ||
} | ||
plugin.ldb.setPluginEnabled(newState); | ||
|
||
msg("Disguises are now " + (newState ? "enabled." : "disabled.")); | ||
|
||
return true; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/me/totalfreedom/totalfreedommod/command/Command_undisguiseall.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package me.totalfreedom.totalfreedommod.command; | ||
|
||
import me.libraryaddict.disguise.DisallowedDisguises; | ||
import me.totalfreedom.totalfreedommod.rank.Rank; | ||
import me.totalfreedom.totalfreedommod.util.FUtil; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH) | ||
@CommandParameters(description = "Undisguise all players on the server", usage = "/<command>", aliases = "uall") | ||
public class Command_undisguiseall extends FreedomCommand | ||
{ | ||
|
||
@Override | ||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) | ||
{ | ||
if (!plugin.ldb.isPluginEnabled()) | ||
{ | ||
msg("LibsDisguises is not enabled."); | ||
return true; | ||
} | ||
|
||
if (DisallowedDisguises.disabled) | ||
{ | ||
msg("Disguises are not enabled."); | ||
return true; | ||
} | ||
|
||
FUtil.adminAction(sender.getName(), "Undisguising all non-admins", true); | ||
|
||
plugin.ldb.undisguiseAll(false); | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters