2020-11-30 23:17:27 +00:00
package me.totalfreedom.totalfreedommod.command ;
import java.util.List ;
import me.totalfreedom.totalfreedommod.bridge.CoreProtectBridge ;
import me.totalfreedom.totalfreedommod.player.PlayerData ;
import me.totalfreedom.totalfreedommod.rank.Rank ;
import me.totalfreedom.totalfreedommod.util.FUtil ;
import org.bukkit.ChatColor ;
import org.bukkit.command.Command ;
import org.bukkit.command.CommandSender ;
import org.bukkit.entity.Player ;
@CommandPermissions ( level = Rank . OP , source = SourceType . ONLY_IN_GAME )
@CommandParameters ( description = " Block inspector tool for operators " , usage = " /<command> [history] <page> " , aliases = " ins " )
public class Command_inspect extends FreedomCommand
{
@Override
public boolean run ( CommandSender sender , Player playerSender , Command cmd , String commandLabel , String [ ] args , boolean senderIsConsole )
{
if ( args . length = = 0 )
{
PlayerData playerData = plugin . pl . getData ( playerSender ) ;
playerData . setInspect ( ! playerData . hasInspection ( ) ) ;
plugin . pl . save ( playerData ) ;
msg ( " Block inspector " + ( playerData . hasInspection ( ) ? " enabled. " : " disabled. " ) ) ;
return true ;
}
if ( args [ 0 ] . equalsIgnoreCase ( " history " ) )
{
int pageIndex = 1 ;
if ( args . length > = 2 )
{
try
{
pageIndex = Integer . parseInt ( args [ 1 ] ) ;
}
catch ( NumberFormatException e )
{
2021-04-05 23:13:26 +00:00
msg ( " Invalid number " , ChatColor . RED ) ;
2020-11-30 23:17:27 +00:00
}
}
FUtil . PaginationList < String > paged = CoreProtectBridge . HISTORY_MAP . get ( playerSender ) ;
if ( paged ! = null )
{
if ( pageIndex < 1 | | pageIndex > paged . getPageCount ( ) )
{
2021-04-05 23:13:26 +00:00
msg ( " Not a valid page number " , ChatColor . RED ) ;
2020-11-30 23:17:27 +00:00
return true ;
}
2021-04-05 23:13:26 +00:00
msg ( " ---- " + net . md_5 . bungee . api . ChatColor . of ( " #30ade4 " ) + " Block Inspector " + ChatColor . WHITE + " ---- " , ChatColor . WHITE ) ;
2020-11-30 23:17:27 +00:00
List < String > page = paged . getPage ( pageIndex ) ;
for ( String entries : page )
{
2021-04-05 23:13:26 +00:00
msg ( entries ) ;
2020-11-30 23:17:27 +00:00
}
2021-04-05 23:13:26 +00:00
msg ( " Page " + pageIndex + " / " + paged . getPageCount ( ) + " | To index through the pages, type " + net . md_5 . bungee . api . ChatColor . of ( " #30ade4 " ) + " /ins history <page> " , ChatColor . WHITE ) ;
2020-11-30 23:17:27 +00:00
return true ;
}
}
return true ;
}
}