2018-08-10 17:53:14 +02:00
package com.github.intellectualsites.plotsquared.plot.commands ;
2015-07-18 19:18:15 +02:00
2018-08-10 17:53:14 +02:00
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration ;
2018-11-14 14:19:56 +01:00
import com.github.intellectualsites.plotsquared.plot.PlotSquared ;
2018-08-10 17:53:14 +02:00
import com.github.intellectualsites.plotsquared.plot.config.C ;
import com.github.intellectualsites.plotsquared.plot.config.Settings ;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer ;
import com.github.intellectualsites.plotsquared.plot.util.HastebinUtility ;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil ;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager ;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler ;
2016-03-23 02:41:37 +01:00
2016-02-22 05:29:33 +01:00
import java.io.File ;
import java.io.IOException ;
2018-08-10 17:01:10 +02:00
@CommandDeclaration ( command = " debugpaste " , aliases = " dp " , usage = " /plot debugpaste " , description = " Upload settings.yml, worlds.yml, commands.yml and latest.log to www.hastebin.com " , permission = " plots.debugpaste " , category = CommandCategory . DEBUG )
2015-09-13 06:04:31 +02:00
public class DebugPaste extends SubCommand {
2016-03-22 18:53:17 +01:00
2018-08-10 17:01:10 +02:00
@Override public boolean onCommand ( final PlotPlayer player , String [ ] args ) {
2015-09-13 06:04:31 +02:00
TaskManager . runTaskAsync ( new Runnable ( ) {
2018-08-10 17:01:10 +02:00
@Override public void run ( ) {
2015-09-13 06:04:31 +02:00
try {
2018-11-14 14:19:56 +01:00
String settingsYML = HastebinUtility . upload ( PlotSquared . get ( ) . configFile ) ;
String worldsYML = HastebinUtility . upload ( PlotSquared . get ( ) . worldsFile ) ;
String commandsYML = HastebinUtility . upload ( PlotSquared . get ( ) . commandsFile ) ;
2015-07-26 13:40:48 +02:00
String latestLOG ;
2015-09-13 06:04:31 +02:00
try {
2018-11-14 15:44:07 +01:00
latestLOG = HastebinUtility . upload (
new File ( PlotSquared . get ( ) . IMP . getDirectory ( ) ,
" ../../logs/latest.log " ) ) ;
2016-05-12 23:09:35 +02:00
} catch ( IOException ignored ) {
2018-08-10 17:01:10 +02:00
MainUtil . sendMessage ( player ,
" &clatest.log is too big to be pasted, will ignore " ) ;
2015-07-26 13:40:48 +02:00
latestLOG = " too big :( " ;
}
2016-03-23 02:41:37 +01:00
StringBuilder b = new StringBuilder ( ) ;
b . append (
2018-08-10 17:01:10 +02:00
" # Welcome to this paste \ n# It is meant to provide us at IntellectualSites with better information about your "
+ " problem \ n \ n# We will start with some informational files \ n " ) ;
2016-05-12 23:09:35 +02:00
b . append ( " links.settings_yml: " ) . append ( settingsYML ) . append ( '\n' ) ;
2016-06-05 09:43:40 +02:00
b . append ( " links.worlds_yml: " ) . append ( worldsYML ) . append ( '\n' ) ;
b . append ( " links.commands_yml: " ) . append ( commandsYML ) . append ( '\n' ) ;
2016-05-12 23:09:35 +02:00
b . append ( " links.latest_log: " ) . append ( latestLOG ) . append ( '\n' ) ;
2016-03-19 19:07:55 +01:00
b . append ( " \ n# Server Information \ n " ) ;
2018-11-14 14:19:56 +01:00
int [ ] sVersion = PlotSquared . get ( ) . IMP . getServerVersion ( ) ;
2018-08-10 17:01:10 +02:00
b . append ( " version.server: " ) . append ( sVersion [ 0 ] ) . append ( '.' ) . append ( sVersion [ 1 ] )
. append ( '.' ) . append ( sVersion [ 2 ] ) . append ( '\n' ) ;
b . append ( " online_mode: " ) . append ( UUIDHandler . getUUIDWrapper ( ) ) . append ( ';' )
. append ( ! Settings . UUID . OFFLINE ) . append ( '\n' ) ;
2015-07-19 16:18:46 +02:00
b . append ( " plugins: " ) ;
2018-11-14 14:19:56 +01:00
for ( String id : PlotSquared . get ( ) . IMP . getPluginIds ( ) ) {
2016-02-10 19:59:51 +01:00
String [ ] split = id . split ( " : " ) ;
String [ ] split2 = split [ 0 ] . split ( " ; " ) ;
String enabled = split . length = = 2 ? split [ 1 ] : " unknown " ;
String name = split2 [ 0 ] ;
String version = split2 . length = = 2 ? split2 [ 1 ] : " unknown " ;
2018-08-10 17:01:10 +02:00
b . append ( " \ n " ) . append ( name ) . append ( " : \ n " ) . append ( " version: ' " )
. append ( version ) . append ( '\'' ) . append ( " \ n enabled: " ) . append ( enabled ) ;
2015-07-19 16:18:46 +02:00
}
b . append ( " \ n \ n# YAY! Now, let's see what we can find in your JVM \ n " ) ;
2016-03-23 02:41:37 +01:00
Runtime runtime = Runtime . getRuntime ( ) ;
2016-05-12 23:09:35 +02:00
b . append ( " memory.free: " ) . append ( runtime . freeMemory ( ) ) . append ( '\n' ) ;
b . append ( " memory.max: " ) . append ( runtime . maxMemory ( ) ) . append ( '\n' ) ;
2018-08-10 17:01:10 +02:00
b . append ( " java.specification.version: ' " )
. append ( System . getProperty ( " java.specification.version " ) ) . append ( " ' \ n " ) ;
b . append ( " java.vendor: ' " ) . append ( System . getProperty ( " java.vendor " ) )
. append ( " ' \ n " ) ;
b . append ( " java.version: ' " ) . append ( System . getProperty ( " java.version " ) )
. append ( " ' \ n " ) ;
2015-07-19 16:18:46 +02:00
b . append ( " os.arch: ' " ) . append ( System . getProperty ( " os.arch " ) ) . append ( " ' \ n " ) ;
b . append ( " os.name: ' " ) . append ( System . getProperty ( " os.name " ) ) . append ( " ' \ n " ) ;
2018-08-10 17:01:10 +02:00
b . append ( " os.version: ' " ) . append ( System . getProperty ( " os.version " ) )
. append ( " ' \ n \ n " ) ;
2015-07-19 16:18:46 +02:00
b . append ( " # Okay :D Great. You are now ready to create your bug report! " ) ;
2018-08-10 17:01:10 +02:00
b . append (
" \ n# You can do so at https://github.com/IntellectualSites/PlotSquared/issues " ) ;
2016-03-22 18:53:17 +01:00
2016-03-23 02:41:37 +01:00
String link = HastebinUtility . upload ( b . toString ( ) ) ;
2016-06-02 17:38:47 +02:00
player . sendMessage ( C . DEBUG_REPORT_CREATED . s ( ) . replace ( " %url% " , link ) ) ;
2016-03-23 02:41:37 +01:00
} catch ( IOException e ) {
2015-07-18 19:18:15 +02:00
e . printStackTrace ( ) ;
}
}
} ) ;
return true ;
}
}