@ -22,12 +22,6 @@ class Timings(commands.Cog):
# Use @commands.Cog.listener() instead of event and use @commands.command() for commands
# Use @commands.Cog.listener() instead of event and use @commands.command() for commands
# TODO: Add descriptions or hyperlink from the following links
# http://bit.ly/spiconf
# http://bit.ly/paperconf
# http://bit.ly/purpurc
async def analyze_timings ( self , message ) :
async def analyze_timings ( self , message ) :
words = message . content . replace ( " \n " , " " ) . split ( " " )
words = message . content . replace ( " \n " , " " ) . split ( " " )
timings_url = " "
timings_url = " "
@ -86,7 +80,8 @@ class Timings(commands.Cog):
timing_cost = int ( request [ " timingsMaster " ] [ " system " ] [ " timingcost " ] )
timing_cost = int ( request [ " timingsMaster " ] [ " system " ] [ " timingcost " ] )
if timing_cost > 300 :
if timing_cost > 300 :
embed_var . add_field ( name = " ❌ Timingcost " ,
embed_var . add_field ( name = " ❌ Timingcost " ,
value = " Your timingcost is " + str ( timing_cost ) + " . Find a [better host](https://www.birdflop.com). " )
value = " Your timingcost is " + str (
timing_cost ) + " . Find a [better host](https://www.birdflop.com). " )
except KeyError as key :
except KeyError as key :
print ( " Missing: " + str ( key ) )
print ( " Missing: " + str ( key ) )
unchecked + = 1
unchecked + = 1
@ -155,20 +150,28 @@ class Timings(commands.Cog):
cpu = int ( request [ " timingsMaster " ] [ " system " ] [ " cpu " ] )
cpu = int ( request [ " timingsMaster " ] [ " system " ] [ " cpu " ] )
if cpu == 1 :
if cpu == 1 :
embed_var . add_field ( name = " ❌ Threads " ,
embed_var . add_field ( name = " ❌ Threads " ,
value = " You have only " + str ( cpu ) + " thread. Find a [better host](https://www.birdflop.com). " )
value = " You have only " + str (
cpu ) + " thread. Find a [better host](https://www.birdflop.com). " )
if cpu == 2 :
if cpu == 2 :
embed_var . add_field ( name = " ❌ Threads " ,
embed_var . add_field ( name = " ❌ Threads " ,
value = " You have only " + str ( cpu ) + " threads. Find a [better host](https://www.birdflop.com). " )
value = " You have only " + str (
cpu ) + " threads. Find a [better host](https://www.birdflop.com). " )
except KeyError as key :
except KeyError as key :
print ( " Missing: " + str ( key ) )
print ( " Missing: " + str ( key ) )
unchecked + = 1
unchecked + = 1
plugins = request [ " timingsMaster " ] [ " plugins " ] if " plugins " in request [ " timingsMaster " ] else None
plugins = request [ " timingsMaster " ] [ " plugins " ] if " plugins " in request [ " timingsMaster " ] else None
server_properties = request [ " timingsMaster " ] [ " config " ] [ " server.properties " ] if " server.properties " in request [ " timingsMaster " ] [ " config " ] else None
bukkit = request [ " timingsMaster " ] [ " config " ] [ " bukkit " ] if " bukkit " in request [ " timingsMaster " ] [ " config " ] else None
spigot = request [ " timingsMaster " ] [ " config " ] [ " spigot " ] if " spigot " in request [ " timingsMaster " ] [ " config " ] else None
paper = request [ " timingsMaster " ] [ " config " ] [ " paper " ] if " paper " in request [ " timingsMaster " ] [ " config " ] else None
purpur = request [ " timingsMaster " ] [ " config " ] [ " purpur " ] if " purpur " in request [ " timingsMaster " ] [ " config " ] else None
server_properties = request [ " timingsMaster " ] [ " config " ] [ " server.properties " ] if " server.properties " in \
request [ " timingsMaster " ] [
" config " ] else None
bukkit = request [ " timingsMaster " ] [ " config " ] [ " bukkit " ] if " bukkit " in request [ " timingsMaster " ] [
" config " ] else None
spigot = request [ " timingsMaster " ] [ " config " ] [ " spigot " ] if " spigot " in request [ " timingsMaster " ] [
" config " ] else None
paper = request [ " timingsMaster " ] [ " config " ] [ " paper " ] if " paper " in request [ " timingsMaster " ] [
" config " ] else None
purpur = request [ " timingsMaster " ] [ " config " ] [ " purpur " ] if " purpur " in request [ " timingsMaster " ] [
" config " ] else None
if not YAML_ERROR :
if not YAML_ERROR :
if " plugins " in TIMINGS_CHECK :
if " plugins " in TIMINGS_CHECK :
for server_name in TIMINGS_CHECK [ " plugins " ] :
for server_name in TIMINGS_CHECK [ " plugins " ] :
@ -181,7 +184,8 @@ class Timings(commands.Cog):
stored_plugin [ " name " ] = plugin_name
stored_plugin [ " name " ] = plugin_name
embed_var . add_field ( * * create_field ( stored_plugin ) )
embed_var . add_field ( * * create_field ( stored_plugin ) )
else :
else :
eval_field ( embed_var , stored_plugin , plugin_name , unchecked , plugins , server_properties , bukkit , spigot , paper , purpur )
eval_field ( embed_var , stored_plugin , plugin_name , unchecked , plugins ,
server_properties , bukkit , spigot , paper , purpur )
if " songoda " in request [ " timingsMaster " ] [ " plugins " ] [ plugin ] [ " authors " ] . casefold ( ) :
if " songoda " in request [ " timingsMaster " ] [ " plugins " ] [ plugin ] [ " authors " ] . casefold ( ) :
if plugin == " EpicHeads " :
if plugin == " EpicHeads " :
embed_var . add_field ( name = " ❌ EpicHeads " ,
embed_var . add_field ( name = " ❌ EpicHeads " ,
@ -198,7 +202,8 @@ class Timings(commands.Cog):
config = TIMINGS_CHECK [ " config " ] [ config_name ]
config = TIMINGS_CHECK [ " config " ] [ config_name ]
for option_name in config :
for option_name in config :
option = config [ option_name ]
option = config [ option_name ]
eval_field ( embed_var , option , option_name , unchecked , plugins , server_properties , bukkit , spigot , paper , purpur )
eval_field ( embed_var , option , option_name , unchecked , plugins , server_properties , bukkit ,
spigot , paper , purpur )
else :
else :
embed_var . add_field ( name = " Error loading YAML file " ,
embed_var . add_field ( name = " Error loading YAML file " ,
value = YAML_ERROR )
value = YAML_ERROR )
@ -214,7 +219,9 @@ class Timings(commands.Cog):
using_ntvd = False
using_ntvd = False
if not using_ntvd :
if not using_ntvd :
embed_var . add_field ( name = " ❌ no-tick-view-distance " ,
embed_var . add_field ( name = " ❌ no-tick-view-distance " ,
value = " Set in [paper.yml](http://bit.ly/paperconf). Recommended: " + str ( tvd ) + " . And reduce view-distance from default ( " + str ( tvd ) + " ) in [spigot.yml](http://bit.ly/spiconf). Recommended: 3. " )
value = " Set in [paper.yml](http://bit.ly/paperconf). Recommended: " + str (
tvd ) + " . And reduce view-distance from default ( " + str (
tvd ) + " ) in [spigot.yml](http://bit.ly/spiconf). Recommended: 3. " )
except KeyError as key :
except KeyError as key :
print ( " Missing: " + str ( key ) )
print ( " Missing: " + str ( key ) )
unchecked = unchecked + 1
unchecked = unchecked + 1
@ -232,12 +239,15 @@ class Timings(commands.Cog):
issue_count = len ( embed_var . fields )
issue_count = len ( embed_var . fields )
if issue_count > = 25 :
if issue_count > = 25 :
embed_var . insert_field_at ( index = 24 , name = " Plus " + str ( issue_count - 24 ) + " more recommendations " , value = " Create a new timings report after resolving some of the above issues to see more. " )
embed_var . insert_field_at ( index = 24 , name = " Plus " + str ( issue_count - 24 ) + " more recommendations " ,
value = " Create a new timings report after resolving some of the above issues to see more. " )
if unchecked > 0 :
if unchecked > 0 :
embed_var . description = " || " + str ( unchecked ) + " missing configuration optimizations.|| "
embed_var . description = " || " + str ( unchecked ) + " missing configuration optimizations.|| "
await message . reply ( embed = embed_var )
await message . reply ( embed = embed_var )
def eval_field ( embed_var , option , option_name , unchecked , plugins = None , server_properties = None , bukkit = None , spigot = None , paper = None , purpur = None ) :
def eval_field ( embed_var , option , option_name , unchecked , plugins = None , server_properties = None , bukkit = None ,
spigot = None , paper = None , purpur = None ) :
try :
try :
for option_data in option :
for option_data in option :
add_to_field = True
add_to_field = True
@ -253,13 +263,15 @@ def eval_field(embed_var, option, option_name, unchecked, plugins=None, server_p
break
break
if add_to_field :
if add_to_field :
""" f strings don ' t like newlines so we replace the newlines with placeholder text before we eval """
""" f strings don ' t like newlines so we replace the newlines with placeholder text before we eval """
option_data [ " value " ] = eval ( ' f " " " ' + option_data [ " value " ] . replace ( " \n " , " \\ |n \\ " ) + ' " " " ' ) . replace ( " \\ |n \\ " , " \n " )
option_data [ " value " ] = eval ( ' f " " " ' + option_data [ " value " ] . replace ( " \n " , " \\ |n \\ " ) + ' " " " ' ) . replace (
" \\ |n \\ " , " \n " )
embed_var . add_field ( * * create_field ( { * * { " name " : option_name } , * * option_data } ) )
embed_var . add_field ( * * create_field ( { * * { " name " : option_name } , * * option_data } ) )
break
break
except KeyError as key :
except KeyError as key :
print ( " Missing: " + str ( key ) )
print ( " Missing: " + str ( key ) )
unchecked + = 1
unchecked + = 1
def create_field ( option ) :
def create_field ( option ) :
field = { " name " : option [ " name " ] ,
field = { " name " : option [ " name " ] ,
" value " : option [ " value " ] }
" value " : option [ " value " ] }
@ -271,5 +283,6 @@ def create_field(option):
field [ " inline " ] = option [ " inline " ]
field [ " inline " ] = option [ " inline " ]
return field
return field
def setup ( bot ) :
def setup ( bot ) :
bot . add_cog ( Timings ( bot ) )
bot . add_cog ( Timings ( bot ) )