2022-11-14 00:06:44 +00:00
package net.t2code.t2codelib.SPIGOT.system.cmd ;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend ;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate ;
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI ;
2023-06-19 19:17:49 +00:00
import net.t2code.t2codelib.SPIGOT.system.T2CbungeeCommandSenderReciver ;
2022-11-14 00:06:44 +00:00
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain ;
import net.t2code.t2codelib.Util ;
import org.bukkit.Bukkit ;
import org.bukkit.command.CommandSender ;
import org.bukkit.entity.Player ;
import java.io.IOException ;
public class Commands {
public static void info ( CommandSender sender ) {
T2Ctemplate . sendInfo ( sender , T2CodeLibMain . getPlugin ( ) , Util . getSpigotID ( ) , Util . getDiscord ( ) , null , Util . getInfoText ( ) ) ;
}
public static void debug ( CommandSender sender , String [ ] args ) {
if ( args . length < 2 ) {
T2Csend . sender ( sender , " §4Use: §7/t2code debug createReportLog " ) ;
return ;
}
switch ( args [ 1 ] . toLowerCase ( ) ) {
case " createreportlog " :
2022-11-14 23:36:25 +00:00
switch ( args . length ) {
case 2 :
if ( sender instanceof Player ) {
T2Csend . sender ( sender , " <dark_red>The debug zip file is <red>automatically uploaded</red> to T2Code's servers<br>and <red>automatically deleted</red> " +
" after <red>14</red> days!<br>The file can also be deleted manually by you via command!</dark_red><br><dark_green><hover:show_text:'<yellow>Confirm the " +
" upload</yellow>'><click:run_command:'/t2c debug createReportLog confirmupload'>upload</click></hover></dark_green> <dark_gray>|</dark_gray> " +
" <gold><hover:show_text:'<red>Do not upload</red>'><click:run_command:'/t2c debug createReportLog noupload'>keep the file on your server</click></hover></gold> " ) ;
2022-11-15 01:17:26 +00:00
} else T2Csend . sender ( sender , " <dark_red>The debug zip file is <red>automatically uploaded</red> to T2Code's servers</dark_red> " +
" <br><dark_red>and <red>automatically deleted</red> after <red>14</red> days!</dark_red> " +
" <br><dark_red>The file can also be deleted manually by you via command!</dark_red> " +
" <br><green>Confirm the upload with the command:</green> " +
" <br><yellow>/t2c debug createReportLog confirmupload</yellow> " +
" <br><red>Keep the file on your server and do not upload it with the command:</red> " +
" <br><yellow>/t2c debug createReportLog noupload</yellow> " ) ;
2022-11-14 23:36:25 +00:00
break ;
case 3 :
Boolean upload = args [ 2 ] . equalsIgnoreCase ( " confirmupload " ) ;
Bukkit . getScheduler ( ) . runTaskAsynchronously ( T2CodeLibMain . getPlugin ( ) , new Runnable ( ) {
@Override
public void run ( ) {
try {
CreateReportLog . create ( sender , upload ) ;
} catch ( IOException e ) {
T2Csend . sender ( sender , Util . getPrefix ( ) + " <red>An error occurred while creating a report log! Please look in the console!</red> " ) ;
throw new RuntimeException ( e ) ;
}
}
} ) ;
break ;
default :
T2Csend . sender ( sender , " §4Use: §7/t2code debug createReportLog " ) ;
return ;
}
2022-11-14 00:06:44 +00:00
break ;
case " deletereportlog " :
if ( args . length ! = 3 ) {
T2Csend . sender ( sender , " §4Use: §7/t2code debug deleteReportLog [id] " ) ;
return ;
}
try {
2022-11-14 09:04:53 +00:00
CreateReportLog . delete ( args [ 2 ] , sender ) ;
2022-11-14 00:06:44 +00:00
} catch ( IOException e ) {
throw new RuntimeException ( e ) ;
}
break ;
default :
T2Csend . sender ( sender , " §4Use: §7/t2code debug createReportLog/deleteReportLog " ) ;
break ;
}
}
public static void updateInfo ( CommandSender sender , String [ ] args ) {
2022-11-14 17:45:54 +00:00
T2Csend . sender ( sender , T2CupdateAPI . updateInfo ( args , sender instanceof Player ) ) ;
2022-11-14 00:06:44 +00:00
}
}