Skip to content

Instantly share code, notes, and snippets.

@Signifies
Created September 20, 2016 00:20
Show Gist options
  • Save Signifies/a3bcaf69b94584635e2bf7e8506f5434 to your computer and use it in GitHub Desktop.
Save Signifies/a3bcaf69b94584635e2bf7e8506f5434 to your computer and use it in GitHub Desktop.
/**
* MIT License
Copyright (c) [2016] [ES96]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package Utilities;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import me.ES96.com.CTF;
import java.util.ArrayList;
import java.util.UUID;
/**
* Created by ES359 on 7/28/16.
*/
public class Debug
{
static public final String FAILED_ACTION = "[FAILED ACTION] ";
static public final String ACTION = "[ACTION] ";
static public final String LOG = "[LOG] ";
static public final String SEVERE = "[SEVERE] &c";
static public final String PREFIX = CTFUtils.prefix;
private final final static String VERSION = "1.4.0";
static public final String pluginLog()
{
return LOG+ ""+ PREFIX;
}
static String color(String s)
{
return ChatColor.translateAlternateColorCodes('&',s);
}
static public void log(String message)
{
if(CTF.DEBUG)
{
Bukkit.getServer().getConsoleSender().sendMessage(color(message));
}
}
static public void log(Player p, String message)
{
if(CTF.DEBUG)
{
p.sendMessage(color(message));
}
}
static public void log(CommandSender p, String message)
{
if(CTF.DEBUG)
{
p.sendMessage(color(message));
}
}
public static boolean getValue()
{
return CTF.DEBUG;
}
public static void setValue(boolean val)
{
CTF.DEBUG = val;
}
/**
* Simple debug flag enabler.
* @param sender
* @param args
*/
/**
* Simple debug flag enabler.
* @param sender
* @param args
*/
static public void debugToggle(CommandSender sender, String[] args)
{
if(args.length > 1 && args[0].equalsIgnoreCase("debug"))
{
/**
* REPLACE MAINCLASS WITH YOUR MAINCLASS.
*
* EXAMPLE: <MAINCLASS>.DEBUG.
*
* Make sure to add:
* static public DEBUG = false; // To your main class.
*
*
*/
setValue(Boolean.parseBoolean(args[1]));
Bukkit.getServer().broadcastMessage(color(getValue() ? PREFIX+" &cDebugging has been Enabled." : PREFIX+"&cDebugging has been disabled."));
sender.sendMessage(color(getValue() ? "[&4DEBUG&f] &c--> &7You have &aENABLED &4Debugging." : "[&4DEBUG&f] &c--> &7You have &cDISABLED &4Debugging "));
}
}
/**
* Simple debug flag enabler.
* @param sender
* @param args
*/
static public void debugToggle(Player sender, String[] args)
{
if(args.length > 1 && args[0].equalsIgnoreCase("debug"))
{
/**
* REPLACE MAINCLASS WITH YOUR MAINCLASS.
*
* EXAMPLE: <MAINCLASS>.DEBUG.
*
* Make sure to add:
* static public DEBUG = false; // To your main class.
*
*
*/
setValue(Boolean.parseBoolean(args[1]));
Bukkit.getServer().broadcastMessage(color(getValue() ? PREFIX+" &cDebugging has been Enabled." : PREFIX+"&cDebugging has been disabled."));
sender.sendMessage(color(getValue() ? "[&4DEBUG&f] &c--> &7You have &aENABLED &4Debugging." : "[&4DEBUG&f] &c--> &7You have &cDISABLED &4Debugging "));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment