From 42a3dd24ad3fb00b07166a7587ea6b04e5fabadd Mon Sep 17 00:00:00 2001 From: ToadDev <748280+Toad-Dev@users.noreply.github.com> Date: Fri, 11 Jun 2021 21:53:49 -0700 Subject: [PATCH] Put some braces back These blocks were not strictly needed but helped readability. I didn't mean for the reformatter to change them while dealing with the "this" problem. It also removed some braces in switch statements but who cares. --- .../computercraft/core/asm/Generator.java | 104 +++---- .../shared/util/CommentedConfigSpec.java | 3 +- .../computercraft/shared/util/Config.java | 271 +++++++++--------- 3 files changed, 193 insertions(+), 185 deletions(-) diff --git a/src/main/java/dan200/computercraft/core/asm/Generator.java b/src/main/java/dan200/computercraft/core/asm/Generator.java index a8b14bfce..e68732f95 100644 --- a/src/main/java/dan200/computercraft/core/asm/Generator.java +++ b/src/main/java/dan200/computercraft/core/asm/Generator.java @@ -223,60 +223,62 @@ public final class Generator mw.visitEnd(); } - MethodVisitor mw = cw.visitMethod( ACC_PUBLIC, METHOD_NAME, methodDesc, null, EXCEPTIONS ); - mw.visitCode(); - - // If we're an instance method, load the this parameter. - if( !Modifier.isStatic( method.getModifiers() ) ) { - mw.visitVarInsn( ALOAD, 1 ); - mw.visitTypeInsn( CHECKCAST, Type.getInternalName( target ) ); + MethodVisitor mw = cw.visitMethod( ACC_PUBLIC, METHOD_NAME, methodDesc, null, EXCEPTIONS ); + mw.visitCode(); + + // If we're an instance method, load the this parameter. + if( !Modifier.isStatic( method.getModifiers() ) ) + { + mw.visitVarInsn( ALOAD, 1 ); + mw.visitTypeInsn( CHECKCAST, Type.getInternalName( target ) ); + } + + int argIndex = 0; + for( java.lang.reflect.Type genericArg : method.getGenericParameterTypes() ) + { + Boolean loadedArg = loadArg( mw, target, method, genericArg, argIndex ); + if( loadedArg == null ) return null; + if( loadedArg ) argIndex++; + } + + mw.visitMethodInsn( + Modifier.isStatic( method.getModifiers() ) ? INVOKESTATIC : INVOKEVIRTUAL, + Type.getInternalName( method.getDeclaringClass() ), method.getName(), + Type.getMethodDescriptor( method ), false + ); + + // We allow a reasonable amount of flexibility on the return value's type. Alongside the obvious MethodResult, + // we convert basic types into an immediate result. + Class ret = method.getReturnType(); + if( ret != MethodResult.class ) + { + if( ret == void.class ) + { + mw.visitMethodInsn( INVOKESTATIC, INTERNAL_METHOD_RESULT, "of", "()" + DESC_METHOD_RESULT, false ); + } + else if( ret.isPrimitive() ) + { + Class boxed = Primitives.wrap( ret ); + mw.visitMethodInsn( INVOKESTATIC, Type.getInternalName( boxed ), "valueOf", "(" + Type.getDescriptor( ret ) + ")" + Type.getDescriptor( boxed ), false ); + mw.visitMethodInsn( INVOKESTATIC, INTERNAL_METHOD_RESULT, "of", "(Ljava/lang/Object;)" + DESC_METHOD_RESULT, false ); + } + else if( ret == Object[].class ) + { + mw.visitMethodInsn( INVOKESTATIC, INTERNAL_METHOD_RESULT, "of", "([Ljava/lang/Object;)" + DESC_METHOD_RESULT, false ); + } + else + { + mw.visitMethodInsn( INVOKESTATIC, INTERNAL_METHOD_RESULT, "of", "(Ljava/lang/Object;)" + DESC_METHOD_RESULT, false ); + } + } + + mw.visitInsn( ARETURN ); + + mw.visitMaxs( 0, 0 ); + mw.visitEnd(); } - int argIndex = 0; - for( java.lang.reflect.Type genericArg : method.getGenericParameterTypes() ) - { - Boolean loadedArg = loadArg( mw, target, method, genericArg, argIndex ); - if( loadedArg == null ) return null; - if( loadedArg ) argIndex++; - } - - mw.visitMethodInsn( - Modifier.isStatic( method.getModifiers() ) ? INVOKESTATIC : INVOKEVIRTUAL, - Type.getInternalName( method.getDeclaringClass() ), method.getName(), - Type.getMethodDescriptor( method ), false - ); - - // We allow a reasonable amount of flexibility on the return value's type. Alongside the obvious MethodResult, - // we convert basic types into an immediate result. - Class ret = method.getReturnType(); - if( ret != MethodResult.class ) - { - if( ret == void.class ) - { - mw.visitMethodInsn( INVOKESTATIC, INTERNAL_METHOD_RESULT, "of", "()" + DESC_METHOD_RESULT, false ); - } - else if( ret.isPrimitive() ) - { - Class boxed = Primitives.wrap( ret ); - mw.visitMethodInsn( INVOKESTATIC, Type.getInternalName( boxed ), "valueOf", "(" + Type.getDescriptor( ret ) + ")" + Type.getDescriptor( boxed ), false ); - mw.visitMethodInsn( INVOKESTATIC, INTERNAL_METHOD_RESULT, "of", "(Ljava/lang/Object;)" + DESC_METHOD_RESULT, false ); - } - else if( ret == Object[].class ) - { - mw.visitMethodInsn( INVOKESTATIC, INTERNAL_METHOD_RESULT, "of", "([Ljava/lang/Object;)" + DESC_METHOD_RESULT, false ); - } - else - { - mw.visitMethodInsn( INVOKESTATIC, INTERNAL_METHOD_RESULT, "of", "(Ljava/lang/Object;)" + DESC_METHOD_RESULT, false ); - } - } - - mw.visitInsn( ARETURN ); - - mw.visitMaxs( 0, 0 ); - mw.visitEnd(); - cw.visitEnd(); return cw.toByteArray(); diff --git a/src/main/java/dan200/computercraft/shared/util/CommentedConfigSpec.java b/src/main/java/dan200/computercraft/shared/util/CommentedConfigSpec.java index 4b1177382..830eb4a5a 100644 --- a/src/main/java/dan200/computercraft/shared/util/CommentedConfigSpec.java +++ b/src/main/java/dan200/computercraft/shared/util/CommentedConfigSpec.java @@ -32,8 +32,7 @@ public class CommentedConfigSpec extends ConfigSpec @Override public int correct( Config config ) { - return correct( config, ( action, path, incorrectValue, correctedValue ) -> { - } ); + return correct( config, ( action, path, incorrectValue, correctedValue ) -> { } ); } @Override diff --git a/src/main/java/dan200/computercraft/shared/util/Config.java b/src/main/java/dan200/computercraft/shared/util/Config.java index 1a7e737cf..241f0282d 100644 --- a/src/main/java/dan200/computercraft/shared/util/Config.java +++ b/src/main/java/dan200/computercraft/shared/util/Config.java @@ -56,173 +56,180 @@ public final class Config System.setProperty( "nightconfig.preserveInsertionOrder", "true" ); serverSpec = new CommentedConfigSpec(); - // General computers - serverSpec.comment( "computer_space_limit", - "The disk space limit for computers and turtles, in bytes" ); - serverSpec.define( "computer_space_limit", ComputerCraft.computerSpaceLimit ); + { // General computers + serverSpec.comment( "computer_space_limit", + "The disk space limit for computers and turtles, in bytes" ); + serverSpec.define( "computer_space_limit", ComputerCraft.computerSpaceLimit ); - serverSpec.comment( "floppy_space_limit", - "The disk space limit for floppy disks, in bytes" ); - serverSpec.define( "floppy_space_limit", ComputerCraft.floppySpaceLimit ); + serverSpec.comment( "floppy_space_limit", + "The disk space limit for floppy disks, in bytes" ); + serverSpec.define( "floppy_space_limit", ComputerCraft.floppySpaceLimit ); - serverSpec.comment( "maximum_open_files", - "Set how many files a computer can have open at the same time. Set to 0 for unlimited." ); - serverSpec.defineInRange( "maximum_open_files", ComputerCraft.maximumFilesOpen, 0, Integer.MAX_VALUE ); + serverSpec.comment( "maximum_open_files", + "Set how many files a computer can have open at the same time. Set to 0 for unlimited." ); + serverSpec.defineInRange( "maximum_open_files", ComputerCraft.maximumFilesOpen, 0, Integer.MAX_VALUE ); - serverSpec.comment( "disable_lua51_features", - "Set this to true to disable Lua 5.1 functions that will be removed in a future update. " + - "Useful for ensuring forward compatibility of your programs now." ); - serverSpec.define( "disable_lua51_features", ComputerCraft.disableLua51Features ); + serverSpec.comment( "disable_lua51_features", + "Set this to true to disable Lua 5.1 functions that will be removed in a future update. " + + "Useful for ensuring forward compatibility of your programs now." ); + serverSpec.define( "disable_lua51_features", ComputerCraft.disableLua51Features ); - serverSpec.comment( "default_computer_settings", - "A comma separated list of default system settings to set on new computers. Example: " + - "\"shell.autocomplete=false,lua.autocomplete=false,edit.autocomplete=false\" will disable all " + - "autocompletion" ); - serverSpec.define( "default_computer_settings", ComputerCraft.defaultComputerSettings ); + serverSpec.comment( "default_computer_settings", + "A comma separated list of default system settings to set on new computers. Example: " + + "\"shell.autocomplete=false,lua.autocomplete=false,edit.autocomplete=false\" will disable all " + + "autocompletion" ); + serverSpec.define( "default_computer_settings", ComputerCraft.defaultComputerSettings ); - serverSpec.comment( "debug_enabled", - "Enable Lua's debug library. This is sandboxed to each computer, so is generally safe to be used by players." ); - serverSpec.define( "debug_enabled", ComputerCraft.debugEnable ); + serverSpec.comment( "debug_enabled", + "Enable Lua's debug library. This is sandboxed to each computer, so is generally safe to be used by players." ); + serverSpec.define( "debug_enabled", ComputerCraft.debugEnable ); - serverSpec.comment( "log_computer_errors", - "Log exceptions thrown by peripherals and other Lua objects.\n" + - "This makes it easier for mod authors to debug problems, but may result in log spam should people use buggy methods." ); - serverSpec.define( "log_computer_errors", ComputerCraft.logComputerErrors ); + serverSpec.comment( "log_computer_errors", + "Log exceptions thrown by peripherals and other Lua objects.\n" + + "This makes it easier for mod authors to debug problems, but may result in log spam should people use buggy methods." ); + serverSpec.define( "log_computer_errors", ComputerCraft.logComputerErrors ); - serverSpec.comment( "command_require_creative", - "Require players to be in creative mode and be opped in order to interact with command computers." + - "This is the default behaviour for vanilla's Command blocks." ); - serverSpec.define( "command_require_creative", ComputerCraft.commandRequireCreative ); + serverSpec.comment( "command_require_creative", + "Require players to be in creative mode and be opped in order to interact with command computers." + + "This is the default behaviour for vanilla's Command blocks." ); + serverSpec.define( "command_require_creative", ComputerCraft.commandRequireCreative ); + } - // Execution - serverSpec.comment( "execution", - "Controls execution behaviour of computers. This is largely intended for fine-tuning " + - "servers, and generally shouldn't need to be touched" ); + { // Execution + serverSpec.comment( "execution", + "Controls execution behaviour of computers. This is largely intended for fine-tuning " + + "servers, and generally shouldn't need to be touched" ); - serverSpec.comment( "execution.computer_threads", - "Set the number of threads computers can run on. A higher number means more computers can run " + - "at once, but may induce lag.\n" + - "Please note that some mods may not work with a thread count higher than 1. Use with caution." ); - serverSpec.defineInRange( "execution.computer_threads", ComputerCraft.computerThreads, 1, Integer.MAX_VALUE ); + serverSpec.comment( "execution.computer_threads", + "Set the number of threads computers can run on. A higher number means more computers can run " + + "at once, but may induce lag.\n" + + "Please note that some mods may not work with a thread count higher than 1. Use with caution." ); + serverSpec.defineInRange( "execution.computer_threads", ComputerCraft.computerThreads, 1, Integer.MAX_VALUE ); - serverSpec.comment( "execution.max_main_global_time", - "The maximum time that can be spent executing tasks in a single tick, in milliseconds.\n" + - "Note, we will quite possibly go over this limit, as there's no way to tell how long a will take " + - "- this aims to be the upper bound of the average time." ); - serverSpec.defineInRange( "execution.max_main_global_time", (int) TimeUnit.NANOSECONDS.toMillis( ComputerCraft.maxMainGlobalTime ), 1, Integer.MAX_VALUE ); + serverSpec.comment( "execution.max_main_global_time", + "The maximum time that can be spent executing tasks in a single tick, in milliseconds.\n" + + "Note, we will quite possibly go over this limit, as there's no way to tell how long a will take " + + "- this aims to be the upper bound of the average time." ); + serverSpec.defineInRange( "execution.max_main_global_time", (int) TimeUnit.NANOSECONDS.toMillis( ComputerCraft.maxMainGlobalTime ), 1, Integer.MAX_VALUE ); - serverSpec.comment( "execution.max_main_computer_time", - "The ideal maximum time a computer can execute for in a tick, in milliseconds.\n" + - "Note, we will quite possibly go over this limit, as there's no way to tell how long a will take " + - "- this aims to be the upper bound of the average time." ); - serverSpec.defineInRange( "execution.max_main_computer_time", (int) TimeUnit.NANOSECONDS.toMillis( ComputerCraft.maxMainComputerTime ), 1, Integer.MAX_VALUE ); + serverSpec.comment( "execution.max_main_computer_time", + "The ideal maximum time a computer can execute for in a tick, in milliseconds.\n" + + "Note, we will quite possibly go over this limit, as there's no way to tell how long a will take " + + "- this aims to be the upper bound of the average time." ); + serverSpec.defineInRange( "execution.max_main_computer_time", (int) TimeUnit.NANOSECONDS.toMillis( ComputerCraft.maxMainComputerTime ), 1, Integer.MAX_VALUE ); + } - // HTTP - serverSpec.comment( "http", "Controls the HTTP API" ); + { // HTTP + serverSpec.comment( "http", "Controls the HTTP API" ); - serverSpec.comment( "http.enabled", - "Enable the \"http\" API on Computers (see \"rules\" for more fine grained control than this)." ); - serverSpec.define( "http.enabled", ComputerCraft.httpEnabled ); + serverSpec.comment( "http.enabled", + "Enable the \"http\" API on Computers (see \"rules\" for more fine grained control than this)." ); + serverSpec.define( "http.enabled", ComputerCraft.httpEnabled ); - serverSpec.comment( "http.websocket_enabled", - "Enable use of http websockets. This requires the \"http_enable\" option to also be true." ); - serverSpec.define( "http.websocket_enabled", ComputerCraft.httpWebsocketEnabled ); + serverSpec.comment( "http.websocket_enabled", + "Enable use of http websockets. This requires the \"http_enable\" option to also be true." ); + serverSpec.define( "http.websocket_enabled", ComputerCraft.httpWebsocketEnabled ); - serverSpec.comment( "http.rules", - "A list of rules which control behaviour of the \"http\" API for specific domains or IPs.\n" + - "Each rule is an item with a 'host' to match against, and a series of properties. " + - "The host may be a domain name (\"pastebin.com\"),\n" + - "wildcard (\"*.pastebin.com\") or CIDR notation (\"127.0.0.0/8\"). If no rules, the domain is blocked." ); - serverSpec.defineList( "http.rules", Arrays.asList( - AddressRuleConfig.makeRule( "$private", Action.DENY ), - AddressRuleConfig.makeRule( "*", Action.ALLOW ) - ), x -> x instanceof UnmodifiableConfig && AddressRuleConfig.checkRule( (UnmodifiableConfig) x ) ); + serverSpec.comment( "http.rules", + "A list of rules which control behaviour of the \"http\" API for specific domains or IPs.\n" + + "Each rule is an item with a 'host' to match against, and a series of properties. " + + "The host may be a domain name (\"pastebin.com\"),\n" + + "wildcard (\"*.pastebin.com\") or CIDR notation (\"127.0.0.0/8\"). If no rules, the domain is blocked." ); + serverSpec.defineList( "http.rules", Arrays.asList( + AddressRuleConfig.makeRule( "$private", Action.DENY ), + AddressRuleConfig.makeRule( "*", Action.ALLOW ) + ), x -> x instanceof UnmodifiableConfig && AddressRuleConfig.checkRule( (UnmodifiableConfig) x ) ); - serverSpec.comment( "http.max_requests", - "The number of http requests a computer can make at one time. Additional requests will be queued, and sent when the running requests have finished. Set to 0 for unlimited." ); - serverSpec.defineInRange( "http.max_requests", ComputerCraft.httpMaxRequests, 0, Integer.MAX_VALUE ); + serverSpec.comment( "http.max_requests", + "The number of http requests a computer can make at one time. Additional requests will be queued, and sent when the running requests have finished. Set to 0 for unlimited." ); + serverSpec.defineInRange( "http.max_requests", ComputerCraft.httpMaxRequests, 0, Integer.MAX_VALUE ); - serverSpec.comment( "http.max_websockets", - "The number of websockets a computer can have open at one time. Set to 0 for unlimited." ); - serverSpec.defineInRange( "http.max_websockets", ComputerCraft.httpMaxWebsockets, 1, Integer.MAX_VALUE ); + serverSpec.comment( "http.max_websockets", + "The number of websockets a computer can have open at one time. Set to 0 for unlimited." ); + serverSpec.defineInRange( "http.max_websockets", ComputerCraft.httpMaxWebsockets, 1, Integer.MAX_VALUE ); + } - // Peripherals - serverSpec.comment( "peripheral", "Various options relating to peripherals." ); + { // Peripherals + serverSpec.comment( "peripheral", "Various options relating to peripherals." ); - serverSpec.comment( "peripheral.command_block_enabled", - "Enable Command Block peripheral support" ); - serverSpec.define( "peripheral.command_block_enabled", ComputerCraft.enableCommandBlock ); + serverSpec.comment( "peripheral.command_block_enabled", + "Enable Command Block peripheral support" ); + serverSpec.define( "peripheral.command_block_enabled", ComputerCraft.enableCommandBlock ); - serverSpec.comment( "peripheral.modem_range", - "The range of Wireless Modems at low altitude in clear weather, in meters" ); - serverSpec.defineInRange( "peripheral.modem_range", ComputerCraft.modemRange, 0, MODEM_MAX_RANGE ); + serverSpec.comment( "peripheral.modem_range", + "The range of Wireless Modems at low altitude in clear weather, in meters" ); + serverSpec.defineInRange( "peripheral.modem_range", ComputerCraft.modemRange, 0, MODEM_MAX_RANGE ); - serverSpec.comment( "peripheral.modem_high_altitude_range", - "The range of Wireless Modems at maximum altitude in clear weather, in meters" ); - serverSpec.defineInRange( "peripheral.modem_high_altitude_range", ComputerCraft.modemHighAltitudeRange, 0, MODEM_MAX_RANGE ); + serverSpec.comment( "peripheral.modem_high_altitude_range", + "The range of Wireless Modems at maximum altitude in clear weather, in meters" ); + serverSpec.defineInRange( "peripheral.modem_high_altitude_range", ComputerCraft.modemHighAltitudeRange, 0, MODEM_MAX_RANGE ); - serverSpec.comment( "peripheral.modem_range_during_storm", - "The range of Wireless Modems at low altitude in stormy weather, in meters" ); - serverSpec.defineInRange( "peripheral.modem_range_during_storm", ComputerCraft.modemRangeDuringStorm, 0, MODEM_MAX_RANGE ); + serverSpec.comment( "peripheral.modem_range_during_storm", + "The range of Wireless Modems at low altitude in stormy weather, in meters" ); + serverSpec.defineInRange( "peripheral.modem_range_during_storm", ComputerCraft.modemRangeDuringStorm, 0, MODEM_MAX_RANGE ); - serverSpec.comment( "peripheral.modem_high_altitude_range_during_storm", - "The range of Wireless Modems at maximum altitude in stormy weather, in meters" ); - serverSpec.defineInRange( "peripheral.modem_high_altitude_range_during_storm", ComputerCraft.modemHighAltitudeRangeDuringStorm, 0, MODEM_MAX_RANGE ); + serverSpec.comment( "peripheral.modem_high_altitude_range_during_storm", + "The range of Wireless Modems at maximum altitude in stormy weather, in meters" ); + serverSpec.defineInRange( "peripheral.modem_high_altitude_range_during_storm", ComputerCraft.modemHighAltitudeRangeDuringStorm, 0, MODEM_MAX_RANGE ); - serverSpec.comment( "peripheral.max_notes_per_tick", - "Maximum amount of notes a speaker can play at once" ); - serverSpec.defineInRange( "peripheral.max_notes_per_tick", ComputerCraft.maxNotesPerTick, 1, Integer.MAX_VALUE ); + serverSpec.comment( "peripheral.max_notes_per_tick", + "Maximum amount of notes a speaker can play at once" ); + serverSpec.defineInRange( "peripheral.max_notes_per_tick", ComputerCraft.maxNotesPerTick, 1, Integer.MAX_VALUE ); - serverSpec.comment( "peripheral.monitor_bandwidth", - "The limit to how much monitor data can be sent *per tick*. Note:\n" + - " - Bandwidth is measured before compression, so the data sent to the client is smaller.\n" + - " - This ignores the number of players a packet is sent to. Updating a monitor for one player consumes " + - "the same bandwidth limit as sending to 20.\n" + - " - A full sized monitor sends ~25kb of data. So the default (1MB) allows for ~40 monitors to be updated " + - "in a single tick. \n" + - "Set to 0 to disable." ); - serverSpec.defineInRange( "peripheral.monitor_bandwidth", (int) ComputerCraft.monitorBandwidth, 0, Integer.MAX_VALUE ); + serverSpec.comment( "peripheral.monitor_bandwidth", + "The limit to how much monitor data can be sent *per tick*. Note:\n" + + " - Bandwidth is measured before compression, so the data sent to the client is smaller.\n" + + " - This ignores the number of players a packet is sent to. Updating a monitor for one player consumes " + + "the same bandwidth limit as sending to 20.\n" + + " - A full sized monitor sends ~25kb of data. So the default (1MB) allows for ~40 monitors to be updated " + + "in a single tick. \n" + + "Set to 0 to disable." ); + serverSpec.defineInRange( "peripheral.monitor_bandwidth", (int) ComputerCraft.monitorBandwidth, 0, Integer.MAX_VALUE ); + } - // Turtles - serverSpec.comment( "turtle", "Various options relating to turtles." ); + { // Turtles + serverSpec.comment( "turtle", "Various options relating to turtles." ); - serverSpec.comment( "turtle.need_fuel", - "Set whether Turtles require fuel to move" ); - serverSpec.define( "turtle.need_fuel", ComputerCraft.turtlesNeedFuel ); + serverSpec.comment( "turtle.need_fuel", + "Set whether Turtles require fuel to move" ); + serverSpec.define( "turtle.need_fuel", ComputerCraft.turtlesNeedFuel ); - serverSpec.comment( "turtle.normal_fuel_limit", "The fuel limit for Turtles" ); - serverSpec.defineInRange( "turtle.normal_fuel_limit", ComputerCraft.turtleFuelLimit, 0, Integer.MAX_VALUE ); + serverSpec.comment( "turtle.normal_fuel_limit", "The fuel limit for Turtles" ); + serverSpec.defineInRange( "turtle.normal_fuel_limit", ComputerCraft.turtleFuelLimit, 0, Integer.MAX_VALUE ); - serverSpec.comment( "turtle.advanced_fuel_limit", - "The fuel limit for Advanced Turtles" ); - serverSpec.defineInRange( "turtle.advanced_fuel_limit", ComputerCraft.advancedTurtleFuelLimit, 0, Integer.MAX_VALUE ); + serverSpec.comment( "turtle.advanced_fuel_limit", + "The fuel limit for Advanced Turtles" ); + serverSpec.defineInRange( "turtle.advanced_fuel_limit", ComputerCraft.advancedTurtleFuelLimit, 0, Integer.MAX_VALUE ); - serverSpec.comment( "turtle.obey_block_protection", - "If set to true, Turtles will be unable to build, dig, or enter protected areas (such as near the server spawn point)" ); - serverSpec.define( "turtle.obey_block_protection", ComputerCraft.turtlesObeyBlockProtection ); + serverSpec.comment( "turtle.obey_block_protection", + "If set to true, Turtles will be unable to build, dig, or enter protected areas (such as near the server spawn point)" ); + serverSpec.define( "turtle.obey_block_protection", ComputerCraft.turtlesObeyBlockProtection ); - serverSpec.comment( "turtle.can_push", - "If set to true, Turtles will push entities out of the way instead of stopping if there is space to do so" ); - serverSpec.define( "turtle.can_push", ComputerCraft.turtlesCanPush ); + serverSpec.comment( "turtle.can_push", + "If set to true, Turtles will push entities out of the way instead of stopping if there is space to do so" ); + serverSpec.define( "turtle.can_push", ComputerCraft.turtlesCanPush ); - serverSpec.comment( "turtle.disabled_actions", - "A list of turtle actions which are disabled." ); - serverSpec.defineList( "turtle.disabled_actions", Collections.emptyList(), x -> x instanceof String && getAction( (String) x ) != null ); + serverSpec.comment( "turtle.disabled_actions", + "A list of turtle actions which are disabled." ); + serverSpec.defineList( "turtle.disabled_actions", Collections.emptyList(), x -> x instanceof String && getAction( (String) x ) != null ); + } - serverSpec.comment( "term_sizes", "Configure the size of various computer's terminals.\n" + - "Larger terminals require more bandwidth, so use with care." ); + { // Terminal sizes + serverSpec.comment( "term_sizes", "Configure the size of various computer's terminals.\n" + + "Larger terminals require more bandwidth, so use with care." ); - serverSpec.comment( "term_sizes.computer", "Terminal size of computers" ); - serverSpec.defineInRange( "term_sizes.computer.width", ComputerCraft.computerTermWidth, 1, 255 ); - serverSpec.defineInRange( "term_sizes.computer.height", ComputerCraft.computerTermHeight, 1, 255 ); + serverSpec.comment( "term_sizes.computer", "Terminal size of computers" ); + serverSpec.defineInRange( "term_sizes.computer.width", ComputerCraft.computerTermWidth, 1, 255 ); + serverSpec.defineInRange( "term_sizes.computer.height", ComputerCraft.computerTermHeight, 1, 255 ); - serverSpec.comment( "term_sizes.pocket_computer", "Terminal size of pocket computers" ); - serverSpec.defineInRange( "term_sizes.pocket_computer.width", ComputerCraft.pocketTermWidth, 1, 255 ); - serverSpec.defineInRange( "term_sizes.pocket_computer.height", ComputerCraft.pocketTermHeight, 1, 255 ); + serverSpec.comment( "term_sizes.pocket_computer", "Terminal size of pocket computers" ); + serverSpec.defineInRange( "term_sizes.pocket_computer.width", ComputerCraft.pocketTermWidth, 1, 255 ); + serverSpec.defineInRange( "term_sizes.pocket_computer.height", ComputerCraft.pocketTermHeight, 1, 255 ); - serverSpec.comment( "term_sizes.monitor", "Maximum size of monitors (in blocks)" ); - serverSpec.defineInRange( "term_sizes.monitor.width", ComputerCraft.monitorWidth, 1, 32 ); - serverSpec.defineInRange( "term_sizes.monitor.height", ComputerCraft.monitorHeight, 1, 32 ); + serverSpec.comment( "term_sizes.monitor", "Maximum size of monitors (in blocks)" ); + serverSpec.defineInRange( "term_sizes.monitor.width", ComputerCraft.monitorWidth, 1, 32 ); + serverSpec.defineInRange( "term_sizes.monitor.height", ComputerCraft.monitorHeight, 1, 32 ); + } clientSpec = new CommentedConfigSpec(); @@ -331,7 +338,7 @@ public final class Config ComputerCraft.floppySpaceLimit = serverConfig.get( "floppy_space_limit" ); ComputerCraft.maximumFilesOpen = serverConfig.get( "maximum_open_files" ); ComputerCraft.disableLua51Features = serverConfig.get( "disable_lua51_features" ); - ComputerCraft.defaultComputerSettings = serverConfig.get( "default_computer_settings" ); + ComputerCraft.defaultComputerSettings = serverConfig.get( "default_computer_settings" ); ComputerCraft.debugEnable = serverConfig.get( "debug_enabled" ); ComputerCraft.logComputerErrors = serverConfig.get( "log_computer_errors" ); ComputerCraft.commandRequireCreative = serverConfig.get( "command_require_creative" );