mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-13 02:40:28 +00:00
Merge branch 'mc-1.15.x' into mc-1.16.x
This commit is contained in:
commit
0285260e97
@ -1,5 +1,5 @@
|
||||
# Mod properties
|
||||
mod_version=1.97.0
|
||||
mod_version=1.97.1
|
||||
|
||||
# Minecraft properties (update mods.toml when changing)
|
||||
mc_version=1.16.5
|
||||
|
@ -52,6 +52,8 @@ public final class ComputerCraft
|
||||
|
||||
public static int httpMaxRequests = 16;
|
||||
public static int httpMaxWebsockets = 4;
|
||||
public static int httpDownloadBandwidth = 32 * 1024 * 1024;
|
||||
public static int httpUploadBandwidth = 32 * 1024 * 1024;
|
||||
|
||||
public static boolean enableCommandBlock = false;
|
||||
public static int modemRange = 64;
|
||||
|
@ -20,6 +20,8 @@ import io.netty.handler.codec.http.websocketx.WebSocketHandshakeException;
|
||||
import io.netty.handler.ssl.SslContext;
|
||||
import io.netty.handler.ssl.SslContextBuilder;
|
||||
import io.netty.handler.timeout.ReadTimeoutException;
|
||||
import io.netty.handler.traffic.AbstractTrafficShapingHandler;
|
||||
import io.netty.handler.traffic.GlobalTrafficShapingHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.net.ssl.SSLException;
|
||||
@ -28,9 +30,7 @@ import javax.net.ssl.TrustManagerFactory;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.security.KeyStore;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.SynchronousQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
@ -38,10 +38,8 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public final class NetworkUtils
|
||||
{
|
||||
public static final ExecutorService EXECUTOR = new ThreadPoolExecutor(
|
||||
4, Integer.MAX_VALUE,
|
||||
60L, TimeUnit.SECONDS,
|
||||
new SynchronousQueue<>(),
|
||||
public static final ScheduledThreadPoolExecutor EXECUTOR = new ScheduledThreadPoolExecutor(
|
||||
4,
|
||||
ThreadUtils.builder( "Network" )
|
||||
.setPriority( Thread.MIN_PRIORITY + (Thread.NORM_PRIORITY - Thread.MIN_PRIORITY) / 2 )
|
||||
.build()
|
||||
@ -52,6 +50,15 @@ public final class NetworkUtils
|
||||
.build()
|
||||
);
|
||||
|
||||
public static final AbstractTrafficShapingHandler SHAPING_HANDLER = new GlobalTrafficShapingHandler(
|
||||
EXECUTOR, ComputerCraft.httpUploadBandwidth, ComputerCraft.httpDownloadBandwidth
|
||||
);
|
||||
|
||||
static
|
||||
{
|
||||
EXECUTOR.setKeepAliveTime( 60, TimeUnit.SECONDS );
|
||||
}
|
||||
|
||||
private NetworkUtils()
|
||||
{
|
||||
}
|
||||
@ -107,6 +114,16 @@ public final class NetworkUtils
|
||||
}
|
||||
}
|
||||
|
||||
public static void reloadConfig()
|
||||
{
|
||||
SHAPING_HANDLER.configure( ComputerCraft.httpUploadBandwidth, ComputerCraft.httpDownloadBandwidth );
|
||||
}
|
||||
|
||||
public static void reset()
|
||||
{
|
||||
SHAPING_HANDLER.trafficCounter().resetCumulativeTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link InetSocketAddress} from a {@link java.net.URI}.
|
||||
*
|
||||
|
@ -167,6 +167,7 @@ public class HttpRequest extends Resource<HttpRequest>
|
||||
}
|
||||
|
||||
ChannelPipeline p = ch.pipeline();
|
||||
p.addLast( NetworkUtils.SHAPING_HANDLER );
|
||||
if( sslContext != null )
|
||||
{
|
||||
p.addLast( sslContext.newHandler( ch.alloc(), uri.getHost(), socketAddress.getPort() ) );
|
||||
|
@ -145,6 +145,7 @@ public class Websocket extends Resource<Websocket>
|
||||
protected void initChannel( SocketChannel ch )
|
||||
{
|
||||
ChannelPipeline p = ch.pipeline();
|
||||
p.addLast( NetworkUtils.SHAPING_HANDLER );
|
||||
if( sslContext != null )
|
||||
{
|
||||
p.addLast( sslContext.newHandler( ch.alloc(), uri.getHost(), socketAddress.getPort() ) );
|
||||
|
@ -6,6 +6,7 @@
|
||||
package dan200.computercraft.shared;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.core.apis.http.NetworkUtils;
|
||||
import dan200.computercraft.core.computer.MainThread;
|
||||
import dan200.computercraft.core.tracking.ComputerMBean;
|
||||
import dan200.computercraft.core.tracking.Tracking;
|
||||
@ -98,6 +99,7 @@ public final class CommonHooks
|
||||
WirelessNetwork.resetNetworks();
|
||||
Tracking.reset();
|
||||
ComputerMBean.registerTracker();
|
||||
NetworkUtils.reset();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@ -106,6 +108,7 @@ public final class CommonHooks
|
||||
ComputerCraft.serverComputerRegistry.reset();
|
||||
WirelessNetwork.resetNetworks();
|
||||
Tracking.reset();
|
||||
NetworkUtils.reset();
|
||||
}
|
||||
|
||||
public static final ResourceLocation LOOT_TREASURE_DISK = new ResourceLocation( ComputerCraft.MOD_ID, "treasure_disk" );
|
||||
|
@ -12,6 +12,7 @@ import com.google.common.base.CaseFormat;
|
||||
import com.google.common.base.Converter;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.turtle.event.TurtleAction;
|
||||
import dan200.computercraft.core.apis.http.NetworkUtils;
|
||||
import dan200.computercraft.core.apis.http.options.Action;
|
||||
import dan200.computercraft.core.apis.http.options.AddressRuleConfig;
|
||||
import dan200.computercraft.shared.peripheral.monitor.MonitorRenderer;
|
||||
@ -56,6 +57,9 @@ public final class Config
|
||||
private static final ConfigValue<Integer> httpMaxRequests;
|
||||
private static final ConfigValue<Integer> httpMaxWebsockets;
|
||||
|
||||
private static final ConfigValue<Integer> httpDownloadBandwidth;
|
||||
private static final ConfigValue<Integer> httpUploadBandwidth;
|
||||
|
||||
private static final ConfigValue<Boolean> commandBlockEnabled;
|
||||
private static final ConfigValue<Integer> modemRange;
|
||||
private static final ConfigValue<Integer> modemHighAltitudeRange;
|
||||
@ -187,6 +191,20 @@ public final class Config
|
||||
.comment( "The number of websockets a computer can have open at one time. Set to 0 for unlimited." )
|
||||
.defineInRange( "max_websockets", ComputerCraft.httpMaxWebsockets, 1, Integer.MAX_VALUE );
|
||||
|
||||
builder
|
||||
.comment( "Limits bandwidth used by computers" )
|
||||
.push( "bandwidth" );
|
||||
|
||||
httpDownloadBandwidth = builder
|
||||
.comment( "The number of bytes which can be downloaded in a second. This is shared across all computers. (bytes/s)" )
|
||||
.defineInRange( "global_download", ComputerCraft.httpDownloadBandwidth, 1, Integer.MAX_VALUE );
|
||||
|
||||
httpUploadBandwidth = builder
|
||||
.comment( "The number of bytes which can be uploaded in a second. This is shared across all computers. (bytes/s)" )
|
||||
.defineInRange( "global_upload", ComputerCraft.httpUploadBandwidth, 1, Integer.MAX_VALUE );
|
||||
|
||||
builder.pop();
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
|
||||
@ -329,6 +347,8 @@ public final class Config
|
||||
|
||||
ComputerCraft.httpMaxRequests = httpMaxRequests.get();
|
||||
ComputerCraft.httpMaxWebsockets = httpMaxWebsockets.get();
|
||||
ComputerCraft.httpDownloadBandwidth = httpDownloadBandwidth.get();
|
||||
NetworkUtils.reloadConfig();
|
||||
|
||||
// Peripheral
|
||||
ComputerCraft.enableCommandBlock = commandBlockEnabled.get();
|
||||
|
@ -1,3 +1,17 @@
|
||||
# New features in CC: Tweaked 1.97.1
|
||||
* Add config options to limit total bandwidth used by the HTTP API.
|
||||
|
||||
And several bug fixes:
|
||||
* Fix selected slot indicator not appearing in turtle interface.
|
||||
* Fix crash when printers are placed as part of world generation.
|
||||
* Fix crash when breaking a speaker on a multiplayer world.
|
||||
* Prevent issue in rednet when the message ID is NaN.
|
||||
* Fix `help` program crashing when terminal changes width.
|
||||
* Ensure monitors are well-formed when placed, preventing graphical glitches
|
||||
when using Carry On or Quark.
|
||||
* Accept several more extensions in the websocket client.
|
||||
* Prevent `wget` crashing when given an invalid URL and no filename.
|
||||
|
||||
# New features in CC: Tweaked 1.97.0
|
||||
|
||||
* Update several translations (Anavrins, Jummit, Naheulf).
|
||||
|
@ -1,33 +1,15 @@
|
||||
New features in CC: Tweaked 1.97.0
|
||||
|
||||
* Update several translations (Anavrins, Jummit, Naheulf).
|
||||
* Add button to view a computer's folder to `/computercraft dump`.
|
||||
* Allow cleaning dyed turtles in a cauldron.
|
||||
* Add scale subcommand to `monitor` program (MCJack123).
|
||||
* Add option to make `textutils.serialize` not write an indent (magiczocker10).
|
||||
* Allow comparing vectors using `==` (fatboychummy).
|
||||
* Improve HTTP error messages for SSL failures.
|
||||
* Allow `craft` program to craft unlimited items (fatboychummy).
|
||||
* Impose some limits on various command queues.
|
||||
* Add buttons to shutdown and terminate to computer GUIs.
|
||||
* Add program subcompletion to several programs (Wojbie).
|
||||
* Update the `help` program to accept and (partially) highlight markdown files.
|
||||
* Remove config option for the debug API.
|
||||
* Allow setting the subprotocol header for websockets.
|
||||
* Add basic JMX monitoring on dedicated servers.
|
||||
* Add support for MoreRed bundled.
|
||||
* Allow uploading files by dropping them onto a computer.
|
||||
New features in CC: Tweaked 1.97.1
|
||||
* Add config options to limit total bandwidth used by the HTTP API.
|
||||
|
||||
And several bug fixes:
|
||||
* Fix NPE when using a treasure disk when no treasure disks are available.
|
||||
* Prevent command computers discarding command ouput when certain game rules are off.
|
||||
* Fix turtles not updating peripherals when upgrades are unequipped (Ronan-H).
|
||||
* Fix computers not shutting down on fatal errors within the Lua VM.
|
||||
* Speakers now correctly stop playing when broken, and sound follows noisy turtles and pocket computers.
|
||||
* Update the `wget` to be more resiliant in the face of user-errors.
|
||||
* Fix exiting `paint` typing "e" in the shell.
|
||||
* Fix coloured pocket computers using the wrong texture.
|
||||
* Correctly render the transparent background on pocket/normal computers.
|
||||
* Don't apply CraftTweaker actions twice on single-player worlds.
|
||||
* Fix selected slot indicator not appearing in turtle interface.
|
||||
* Fix crash when printers are placed as part of world generation.
|
||||
* Fix crash when breaking a speaker on a multiplayer world.
|
||||
* Prevent issue in rednet when the message ID is NaN.
|
||||
* Fix `help` program crashing when terminal changes width.
|
||||
* Ensure monitors are well-formed when placed, preventing graphical glitches
|
||||
when using Carry On or Quark.
|
||||
* Accept several more extensions in the websocket client.
|
||||
* Prevent `wget` crashing when given an invalid URL and no filename.
|
||||
|
||||
Type "help changelog" to see the full version history.
|
||||
|
@ -69,7 +69,7 @@ if run then
|
||||
printError(err)
|
||||
end
|
||||
else
|
||||
local sFile = tArgs[1] or getFilename(url)
|
||||
local sFile = tArgs[1] or getFilename(url) or url
|
||||
local sPath = shell.resolve(sFile)
|
||||
if fs.exists(sPath) then
|
||||
print("File already exists")
|
||||
|
Loading…
Reference in New Issue
Block a user