mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-13 11:40:29 +00:00
Merge pull request #207 from SquidDev-CC/feature/cleanup
Fix a couple of warnings
This commit is contained in:
commit
0308ec555a
@ -83,3 +83,8 @@ processResources
|
||||
}
|
||||
}
|
||||
|
||||
gradle.projectsEvaluated {
|
||||
tasks.withType(JavaCompile) {
|
||||
options.compilerArgs << "-Xlint"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -74,18 +74,23 @@ import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
///////////////
|
||||
// UNIVERSAL //
|
||||
///////////////
|
||||
|
||||
@Mod(
|
||||
modid = "ComputerCraft", name = "ComputerCraft", version = "${version}",
|
||||
modid = ComputerCraft.MOD_ID, name = "ComputerCraft", version = "${version}",
|
||||
guiFactory = "dan200.computercraft.client.gui.GuiConfigCC$Factory"
|
||||
)
|
||||
public class ComputerCraft
|
||||
{
|
||||
public static final String MOD_ID = "ComputerCraft";
|
||||
|
||||
// GUI IDs
|
||||
public static final int diskDriveGUIID = 100;
|
||||
public static final int computerGUIID = 101;
|
||||
@ -209,7 +214,7 @@ public class ComputerCraft
|
||||
private static final Map<String, IPocketUpgrade> pocketUpgrades = new HashMap<String, IPocketUpgrade>();
|
||||
|
||||
// Implementation
|
||||
@Mod.Instance( value = "ComputerCraft" )
|
||||
@Mod.Instance( value = ComputerCraft.MOD_ID )
|
||||
public static ComputerCraft instance;
|
||||
|
||||
@SidedProxy( clientSide = "dan200.computercraft.client.proxy.ComputerCraftProxyClient", serverSide = "dan200.computercraft.server.proxy.ComputerCraftProxyServer" )
|
||||
@ -509,9 +514,8 @@ public class ComputerCraft
|
||||
}
|
||||
}
|
||||
|
||||
for( int i=0; i<permissionProviders.size(); ++i )
|
||||
for( ITurtlePermissionProvider provider : permissionProviders )
|
||||
{
|
||||
ITurtlePermissionProvider provider = permissionProviders.get( i );
|
||||
if( !provider.isBlockEnterable( world, pos ) )
|
||||
{
|
||||
return false;
|
||||
@ -531,9 +535,8 @@ public class ComputerCraft
|
||||
}
|
||||
}
|
||||
|
||||
for( int i=0; i<permissionProviders.size(); ++i )
|
||||
for( ITurtlePermissionProvider provider : permissionProviders )
|
||||
{
|
||||
ITurtlePermissionProvider provider = permissionProviders.get( i );
|
||||
if( !provider.isBlockEditable( world, pos ) )
|
||||
{
|
||||
return false;
|
||||
@ -581,13 +584,11 @@ public class ComputerCraft
|
||||
public static IPeripheral getPeripheralAt( World world, BlockPos pos, EnumFacing side )
|
||||
{
|
||||
// Try the handlers in order:
|
||||
Iterator<IPeripheralProvider> it = peripheralProviders.iterator();
|
||||
while( it.hasNext() )
|
||||
for( IPeripheralProvider peripheralProvider : peripheralProviders )
|
||||
{
|
||||
try
|
||||
{
|
||||
IPeripheralProvider handler = it.next();
|
||||
IPeripheral peripheral = handler.getPeripheral( world, pos, side );
|
||||
IPeripheral peripheral = peripheralProvider.getPeripheral( world, pos, side );
|
||||
if( peripheral != null )
|
||||
{
|
||||
return peripheral;
|
||||
@ -620,13 +621,11 @@ public class ComputerCraft
|
||||
|
||||
// Try the handlers in order:
|
||||
int combinedSignal = -1;
|
||||
Iterator<IBundledRedstoneProvider> it = bundledRedstoneProviders.iterator();
|
||||
while( it.hasNext() )
|
||||
for( IBundledRedstoneProvider bundledRedstoneProvider : bundledRedstoneProviders )
|
||||
{
|
||||
try
|
||||
{
|
||||
IBundledRedstoneProvider handler = it.next();
|
||||
int signal = handler.getBundledRedstoneOutput( world, pos, side );
|
||||
int signal = bundledRedstoneProvider.getBundledRedstoneOutput( world, pos, side );
|
||||
if( signal >= 0 )
|
||||
{
|
||||
if( combinedSignal < 0 )
|
||||
@ -652,13 +651,11 @@ public class ComputerCraft
|
||||
if( stack != null )
|
||||
{
|
||||
// Try the handlers in order:
|
||||
Iterator<IMediaProvider> it = mediaProviders.iterator();
|
||||
while( it.hasNext() )
|
||||
for( IMediaProvider mediaProvider : mediaProviders )
|
||||
{
|
||||
try
|
||||
{
|
||||
IMediaProvider handler = it.next();
|
||||
IMedia media = handler.getMedia( stack );
|
||||
IMedia media = mediaProvider.getMedia( stack );
|
||||
if( media != null )
|
||||
{
|
||||
return media;
|
||||
@ -722,7 +719,7 @@ public class ComputerCraft
|
||||
}
|
||||
}
|
||||
|
||||
public static IMount createResourceMount( Class modClass, String domain, String subPath )
|
||||
public static IMount createResourceMount( Class<?> modClass, String domain, String subPath )
|
||||
{
|
||||
// Start building list of mounts
|
||||
List<IMount> mounts = new ArrayList<IMount>();
|
||||
@ -760,11 +757,11 @@ public class ComputerCraft
|
||||
if( resourcePackDir.exists() && resourcePackDir.isDirectory() )
|
||||
{
|
||||
String[] resourcePacks = resourcePackDir.list();
|
||||
for( int i=0; i<resourcePacks.length; ++i )
|
||||
for( String resourcePack1 : resourcePacks )
|
||||
{
|
||||
try
|
||||
{
|
||||
File resourcePack = new File( resourcePackDir, resourcePacks[i] );
|
||||
File resourcePack = new File( resourcePackDir, resourcePack1 );
|
||||
if( !resourcePack.isDirectory() )
|
||||
{
|
||||
// Mount a resource pack from a jar
|
||||
@ -806,7 +803,7 @@ public class ComputerCraft
|
||||
}
|
||||
}
|
||||
|
||||
private static File getContainingJar( Class modClass )
|
||||
private static File getContainingJar( Class<?> modClass )
|
||||
{
|
||||
String path = modClass.getProtectionDomain().getCodeSource().getLocation().getPath();
|
||||
int bangIndex = path.indexOf( "!" );
|
||||
@ -831,7 +828,7 @@ public class ComputerCraft
|
||||
return file;
|
||||
}
|
||||
|
||||
private static File getDebugCodeDir( Class modClass )
|
||||
private static File getDebugCodeDir( Class<?> modClass )
|
||||
{
|
||||
String path = modClass.getProtectionDomain().getCodeSource().getLocation().getPath();
|
||||
int bangIndex = path.indexOf("!");
|
||||
|
@ -21,6 +21,8 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
@ -36,6 +38,7 @@ public final class ComputerCraftAPI
|
||||
return computerCraft != null;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static String getInstalledVersion()
|
||||
{
|
||||
findCC();
|
||||
@ -50,6 +53,7 @@ public final class ComputerCraftAPI
|
||||
return "";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static String getAPIVersion()
|
||||
{
|
||||
return "${version}";
|
||||
@ -68,7 +72,7 @@ public final class ComputerCraftAPI
|
||||
* available for writing.
|
||||
* @see #createSaveDirMount(World, String, long)
|
||||
*/
|
||||
public static int createUniqueNumberedSaveDir( World world, String parentSubPath )
|
||||
public static int createUniqueNumberedSaveDir( @Nonnull World world, @Nonnull String parentSubPath )
|
||||
{
|
||||
findCC();
|
||||
if( computerCraft_createUniqueNumberedSaveDir != null )
|
||||
@ -100,7 +104,8 @@ public final class ComputerCraftAPI
|
||||
* @see IMount
|
||||
* @see IWritableMount
|
||||
*/
|
||||
public static IWritableMount createSaveDirMount( World world, String subPath, long capacity )
|
||||
@Nullable
|
||||
public static IWritableMount createSaveDirMount( @Nonnull World world, @Nonnull String subPath, long capacity )
|
||||
{
|
||||
findCC();
|
||||
if( computerCraft_createSaveDirMount != null )
|
||||
@ -132,7 +137,8 @@ public final class ComputerCraftAPI
|
||||
* @see IComputerAccess#mountWritable(String, IWritableMount)
|
||||
* @see IMount
|
||||
*/
|
||||
public static IMount createResourceMount( Class modClass, String domain, String subPath )
|
||||
@Nullable
|
||||
public static IMount createResourceMount( @Nonnull Class<?> modClass, @Nonnull String domain, @Nonnull String subPath )
|
||||
{
|
||||
findCC();
|
||||
if( computerCraft_createResourceMount != null )
|
||||
@ -153,7 +159,7 @@ public final class ComputerCraftAPI
|
||||
* @see dan200.computercraft.api.peripheral.IPeripheral
|
||||
* @see dan200.computercraft.api.peripheral.IPeripheralProvider
|
||||
*/
|
||||
public static void registerPeripheralProvider( IPeripheralProvider handler )
|
||||
public static void registerPeripheralProvider( @Nonnull IPeripheralProvider handler )
|
||||
{
|
||||
findCC();
|
||||
if ( computerCraft_registerPeripheralProvider != null)
|
||||
@ -174,7 +180,7 @@ public final class ComputerCraftAPI
|
||||
* @param upgrade The turtle upgrade to register.
|
||||
* @see dan200.computercraft.api.turtle.ITurtleUpgrade
|
||||
*/
|
||||
public static void registerTurtleUpgrade( ITurtleUpgrade upgrade )
|
||||
public static void registerTurtleUpgrade( @Nonnull ITurtleUpgrade upgrade )
|
||||
{
|
||||
if( upgrade != null )
|
||||
{
|
||||
@ -196,7 +202,7 @@ public final class ComputerCraftAPI
|
||||
* @param handler The bundled redstone provider to register.
|
||||
* @see dan200.computercraft.api.redstone.IBundledRedstoneProvider
|
||||
*/
|
||||
public static void registerBundledRedstoneProvider( IBundledRedstoneProvider handler )
|
||||
public static void registerBundledRedstoneProvider( @Nonnull IBundledRedstoneProvider handler )
|
||||
{
|
||||
findCC();
|
||||
if( computerCraft_registerBundledRedstoneProvider != null )
|
||||
@ -219,7 +225,7 @@ public final class ComputerCraftAPI
|
||||
* If there is no block capable of emitting bundled redstone at the location, -1 will be returned.
|
||||
* @see dan200.computercraft.api.redstone.IBundledRedstoneProvider
|
||||
*/
|
||||
public static int getBundledRedstoneOutput( World world, BlockPos pos, EnumFacing side )
|
||||
public static int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side )
|
||||
{
|
||||
findCC();
|
||||
if( computerCraft_getDefaultBundledRedstoneOutput != null )
|
||||
@ -239,7 +245,7 @@ public final class ComputerCraftAPI
|
||||
* @param handler The media provider to register.
|
||||
* @see dan200.computercraft.api.media.IMediaProvider
|
||||
*/
|
||||
public static void registerMediaProvider( IMediaProvider handler )
|
||||
public static void registerMediaProvider( @Nonnull IMediaProvider handler )
|
||||
{
|
||||
findCC();
|
||||
if( computerCraft_registerMediaProvider != null )
|
||||
@ -258,7 +264,7 @@ public final class ComputerCraftAPI
|
||||
* @param handler The turtle permission provider to register.
|
||||
* @see dan200.computercraft.api.permissions.ITurtlePermissionProvider
|
||||
*/
|
||||
public static void registerPermissionProvider( ITurtlePermissionProvider handler )
|
||||
public static void registerPermissionProvider( @Nonnull ITurtlePermissionProvider handler )
|
||||
{
|
||||
findCC();
|
||||
if( computerCraft_registerPermissionProvider != null )
|
||||
@ -271,7 +277,8 @@ public final class ComputerCraftAPI
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerPocketUpgrade(IPocketUpgrade upgrade) {
|
||||
public static void registerPocketUpgrade( @Nonnull IPocketUpgrade upgrade )
|
||||
{
|
||||
findCC();
|
||||
if(computerCraft_registerPocketUpgrade != null) {
|
||||
try {
|
||||
@ -291,36 +298,36 @@ public final class ComputerCraftAPI
|
||||
if( !ccSearched ) {
|
||||
try {
|
||||
computerCraft = Class.forName( "dan200.computercraft.ComputerCraft" );
|
||||
computerCraft_getVersion = findCCMethod( "getVersion", new Class[]{
|
||||
computerCraft_getVersion = findCCMethod( "getVersion", new Class<?>[]{
|
||||
} );
|
||||
computerCraft_createUniqueNumberedSaveDir = findCCMethod( "createUniqueNumberedSaveDir", new Class[]{
|
||||
computerCraft_createUniqueNumberedSaveDir = findCCMethod( "createUniqueNumberedSaveDir", new Class<?>[]{
|
||||
World.class, String.class
|
||||
} );
|
||||
computerCraft_createSaveDirMount = findCCMethod( "createSaveDirMount", new Class[] {
|
||||
computerCraft_createSaveDirMount = findCCMethod( "createSaveDirMount", new Class<?>[] {
|
||||
World.class, String.class, Long.TYPE
|
||||
} );
|
||||
computerCraft_createResourceMount = findCCMethod( "createResourceMount", new Class[] {
|
||||
computerCraft_createResourceMount = findCCMethod( "createResourceMount", new Class<?>[] {
|
||||
Class.class, String.class, String.class
|
||||
} );
|
||||
computerCraft_registerPeripheralProvider = findCCMethod( "registerPeripheralProvider", new Class[] {
|
||||
computerCraft_registerPeripheralProvider = findCCMethod( "registerPeripheralProvider", new Class<?>[] {
|
||||
IPeripheralProvider.class
|
||||
} );
|
||||
computerCraft_registerTurtleUpgrade = findCCMethod( "registerTurtleUpgrade", new Class[] {
|
||||
computerCraft_registerTurtleUpgrade = findCCMethod( "registerTurtleUpgrade", new Class<?>[] {
|
||||
ITurtleUpgrade.class
|
||||
} );
|
||||
computerCraft_registerBundledRedstoneProvider = findCCMethod( "registerBundledRedstoneProvider", new Class[] {
|
||||
computerCraft_registerBundledRedstoneProvider = findCCMethod( "registerBundledRedstoneProvider", new Class<?>[] {
|
||||
IBundledRedstoneProvider.class
|
||||
} );
|
||||
computerCraft_getDefaultBundledRedstoneOutput = findCCMethod( "getDefaultBundledRedstoneOutput", new Class[] {
|
||||
computerCraft_getDefaultBundledRedstoneOutput = findCCMethod( "getDefaultBundledRedstoneOutput", new Class<?>[] {
|
||||
World.class, BlockPos.class, EnumFacing.class
|
||||
} );
|
||||
computerCraft_registerMediaProvider = findCCMethod( "registerMediaProvider", new Class[] {
|
||||
computerCraft_registerMediaProvider = findCCMethod( "registerMediaProvider", new Class<?>[] {
|
||||
IMediaProvider.class
|
||||
} );
|
||||
computerCraft_registerPermissionProvider = findCCMethod( "registerPermissionProvider", new Class[] {
|
||||
computerCraft_registerPermissionProvider = findCCMethod( "registerPermissionProvider", new Class<?>[] {
|
||||
ITurtlePermissionProvider.class
|
||||
} );
|
||||
computerCraft_registerPocketUpgrade = findCCMethod( "registerPocketUpgrade", new Class[] {
|
||||
computerCraft_registerPocketUpgrade = findCCMethod( "registerPocketUpgrade", new Class<?>[] {
|
||||
IPocketUpgrade.class
|
||||
} );
|
||||
} catch( Exception e ) {
|
||||
@ -331,7 +338,7 @@ public final class ComputerCraftAPI
|
||||
}
|
||||
}
|
||||
|
||||
private static Method findCCMethod( String name, Class[] args )
|
||||
private static Method findCCMethod( String name, Class<?>[] args )
|
||||
{
|
||||
try {
|
||||
if( computerCraft != null )
|
||||
@ -346,7 +353,7 @@ public final class ComputerCraftAPI
|
||||
}
|
||||
|
||||
private static boolean ccSearched = false;
|
||||
private static Class computerCraft = null;
|
||||
private static Class<?> computerCraft = null;
|
||||
private static Method computerCraft_getVersion = null;
|
||||
private static Method computerCraft_createUniqueNumberedSaveDir = null;
|
||||
private static Method computerCraft_createSaveDirMount = null;
|
||||
|
@ -10,6 +10,7 @@ import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
@ -36,7 +37,7 @@ public interface IMount
|
||||
* @return If the file exists.
|
||||
* @throws IOException If an error occurs when checking the existence of the file.
|
||||
*/
|
||||
public boolean exists( String path ) throws IOException;
|
||||
boolean exists( @Nonnull String path ) throws IOException;
|
||||
|
||||
/**
|
||||
* Returns whether a file with a given path is a directory or not.
|
||||
@ -45,7 +46,7 @@ public interface IMount
|
||||
* @return If the file exists and is a directory
|
||||
* @throws IOException If an error occurs when checking whether the file is a directory.
|
||||
*/
|
||||
public boolean isDirectory( String path ) throws IOException;
|
||||
boolean isDirectory( @Nonnull String path ) throws IOException;
|
||||
|
||||
/**
|
||||
* Returns the file names of all the files in a directory.
|
||||
@ -54,7 +55,7 @@ public interface IMount
|
||||
* @param contents A list of strings. Add all the file names to this list.
|
||||
* @throws IOException If the file was not a directory, or could not be listed.
|
||||
*/
|
||||
public void list( String path, List<String> contents ) throws IOException;
|
||||
void list( @Nonnull String path, @Nonnull List<String> contents ) throws IOException;
|
||||
|
||||
/**
|
||||
* Returns the size of a file with a given path, in bytes
|
||||
@ -63,7 +64,7 @@ public interface IMount
|
||||
* @return The size of the file, in bytes.
|
||||
* @throws IOException If the file does not exist, or its size could not be determined.
|
||||
*/
|
||||
public long getSize( String path ) throws IOException;
|
||||
long getSize( @Nonnull String path ) throws IOException;
|
||||
|
||||
/**
|
||||
* Opens a file with a given path, and returns an {@link InputStream} representing its contents.
|
||||
@ -72,5 +73,6 @@ public interface IMount
|
||||
* @return A stream representing the contents of the file.
|
||||
* @throws IOException If the file does not exist, or could not be opened.
|
||||
*/
|
||||
public InputStream openForRead( String path ) throws IOException;
|
||||
@Nonnull
|
||||
InputStream openForRead( @Nonnull String path ) throws IOException;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
@ -33,7 +34,7 @@ public interface IWritableMount extends IMount
|
||||
* @param path A file path in normalised format, relative to the mount location. ie: "programs/mynewprograms".
|
||||
* @throws IOException If the directory already exists or could not be created.
|
||||
*/
|
||||
public void makeDirectory( String path ) throws IOException;
|
||||
void makeDirectory( @Nonnull String path ) throws IOException;
|
||||
|
||||
/**
|
||||
* Deletes a directory at a given path inside the virtual file system.
|
||||
@ -41,7 +42,7 @@ public interface IWritableMount extends IMount
|
||||
* @param path A file path in normalised format, relative to the mount location. ie: "programs/myoldprograms".
|
||||
* @throws IOException If the file does not exist or could not be deleted.
|
||||
*/
|
||||
public void delete( String path ) throws IOException;
|
||||
void delete( @Nonnull String path ) throws IOException;
|
||||
|
||||
/**
|
||||
* Opens a file with a given path, and returns an {@link OutputStream} for writing to it.
|
||||
@ -50,7 +51,8 @@ public interface IWritableMount extends IMount
|
||||
* @return A stream for writing to
|
||||
* @throws IOException If the file could not be opened for writing.
|
||||
*/
|
||||
public OutputStream openForWrite( String path ) throws IOException;
|
||||
@Nonnull
|
||||
OutputStream openForWrite( @Nonnull String path ) throws IOException;
|
||||
|
||||
/**
|
||||
* Opens a file with a given path, and returns an {@link OutputStream} for appending to it.
|
||||
@ -59,7 +61,8 @@ public interface IWritableMount extends IMount
|
||||
* @return A stream for writing to.
|
||||
* @throws IOException If the file could not be opened for writing.
|
||||
*/
|
||||
public OutputStream openForAppend( String path ) throws IOException;
|
||||
@Nonnull
|
||||
OutputStream openForAppend( @Nonnull String path ) throws IOException;
|
||||
|
||||
/**
|
||||
* Get the amount of free space on the mount, in bytes. You should decrease this value as the user writes to the
|
||||
@ -68,5 +71,5 @@ public interface IWritableMount extends IMount
|
||||
* @return The amount of free space, in bytes.
|
||||
* @throws IOException If the remaining space could not be computed.
|
||||
*/
|
||||
public long getRemainingSpace() throws IOException;
|
||||
long getRemainingSpace() throws IOException;
|
||||
}
|
||||
|
@ -6,6 +6,9 @@
|
||||
|
||||
package dan200.computercraft.api.lua;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* An interface passed to peripherals and {@link ILuaObject}s by computers or turtles, providing methods
|
||||
* that allow the peripheral call to wait for events before returning, just like in lua. This is very useful if you need
|
||||
@ -28,7 +31,8 @@ public interface ILuaContext
|
||||
* event, InterruptedException will be thrown. This exception must not be caught or
|
||||
* intercepted, or the computer will leak memory and end up in a broken state.
|
||||
*/
|
||||
public Object[] pullEvent( String filter ) throws LuaException, InterruptedException;
|
||||
@Nonnull
|
||||
Object[] pullEvent( @Nullable String filter ) throws LuaException, InterruptedException;
|
||||
|
||||
/**
|
||||
* The same as {@link #pullEvent(String)}, except "terminated" events are ignored. Only use this if you want to
|
||||
@ -42,7 +46,8 @@ public interface ILuaContext
|
||||
* intercepted, or the computer will leak memory and end up in a broken state.
|
||||
* @see #pullEvent(String)
|
||||
*/
|
||||
public Object[] pullEventRaw( String filter ) throws InterruptedException;
|
||||
@Nonnull
|
||||
Object[] pullEventRaw( @Nullable String filter ) throws InterruptedException;
|
||||
|
||||
/**
|
||||
* Yield the current coroutine with some arguments until it is resumed. This method is exactly equivalent to
|
||||
@ -55,7 +60,8 @@ public interface ILuaContext
|
||||
* intercepted, or the computer will leak memory and end up in a broken state.
|
||||
* @see #pullEvent(String)
|
||||
*/
|
||||
public Object[] yield( Object[] arguments ) throws InterruptedException;
|
||||
@Nonnull
|
||||
Object[] yield( @Nullable Object[] arguments ) throws InterruptedException;
|
||||
|
||||
/**
|
||||
* Queue a task to be executed on the main server thread at the beginning of next tick, waiting for it to complete.
|
||||
@ -71,7 +77,8 @@ public interface ILuaContext
|
||||
* InterruptedException will be thrown. This exception must not be caught or
|
||||
* intercepted, or the computer will leak memory and end up in a broken state.
|
||||
*/
|
||||
public Object[] executeMainThreadTask( ILuaTask task ) throws LuaException, InterruptedException;
|
||||
@Nullable
|
||||
Object[] executeMainThreadTask( @Nonnull ILuaTask task ) throws LuaException, InterruptedException;
|
||||
|
||||
/**
|
||||
* Queue a task to be executed on the main server thread at the beginning of next tick, but do not wait for it to
|
||||
@ -86,5 +93,5 @@ public interface ILuaContext
|
||||
* @return The "id" of the task. This will be the first argument to the {@code task_completed} event.
|
||||
* @throws LuaException If the task could not be queued.
|
||||
*/
|
||||
public long issueMainThreadTask( ILuaTask task ) throws LuaException;
|
||||
long issueMainThreadTask( @Nonnull ILuaTask task ) throws LuaException;
|
||||
}
|
||||
|
@ -9,6 +9,9 @@ package dan200.computercraft.api.lua;
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* An interface for representing custom objects returned by {@link IPeripheral#callMethod(IComputerAccess, ILuaContext, int, Object[])}
|
||||
* calls.
|
||||
@ -24,7 +27,8 @@ public interface ILuaObject
|
||||
* @return The method names this object provides.
|
||||
* @see IPeripheral#getMethodNames()
|
||||
*/
|
||||
public String[] getMethodNames();
|
||||
@Nonnull
|
||||
String[] getMethodNames();
|
||||
|
||||
/**
|
||||
* Called when a user calls one of the methods that this object implements. This works the same as
|
||||
@ -47,5 +51,6 @@ public interface ILuaObject
|
||||
* intercepted, or the computer will leak memory and end up in a broken state.w
|
||||
* @see IPeripheral#callMethod(IComputerAccess, ILuaContext, int, Object[])
|
||||
*/
|
||||
public Object[] callMethod( ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException;
|
||||
@Nullable
|
||||
Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] arguments ) throws LuaException, InterruptedException;
|
||||
}
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
package dan200.computercraft.api.lua;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A task which can be executed via {@link ILuaContext#executeMainThreadTask(ILuaTask)} or
|
||||
* {@link ILuaContext#issueMainThreadTask(ILuaTask)}. This will be run on the main thread, at the beginning of the
|
||||
@ -25,5 +27,6 @@ public interface ILuaTask
|
||||
* same message as your exception. Use this to throw appropriate errors if the wrong
|
||||
* arguments are supplied to your method.
|
||||
*/
|
||||
public Object[] execute() throws LuaException;
|
||||
@Nullable
|
||||
Object[] execute() throws LuaException;
|
||||
}
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
package dan200.computercraft.api.lua;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* An exception representing an error in Lua, like that raised by the {@code error()} function.
|
||||
*/
|
||||
@ -19,12 +21,12 @@ public class LuaException extends Exception
|
||||
this( "error", 1 );
|
||||
}
|
||||
|
||||
public LuaException( String message )
|
||||
public LuaException( @Nullable String message )
|
||||
{
|
||||
this( message, 1 );
|
||||
}
|
||||
|
||||
public LuaException( String message, int level )
|
||||
public LuaException( @Nullable String message, int level )
|
||||
{
|
||||
super( message );
|
||||
m_level = level;
|
||||
|
@ -11,6 +11,9 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Represents an item that can be placed in a disk drive and used by a Computer.
|
||||
* Implement this interface on your Item class to allow it to be used in the drive.
|
||||
@ -23,7 +26,8 @@ public interface IMedia
|
||||
* @param stack The itemstack to inspect.
|
||||
* @return The label. ie: "Dan's Programs".
|
||||
*/
|
||||
public String getLabel( ItemStack stack );
|
||||
@Nullable
|
||||
String getLabel( @Nonnull ItemStack stack );
|
||||
|
||||
/**
|
||||
* Set a string representing the label of this item. Will be called vi {@code disk.setLabel()} in lua.
|
||||
@ -32,7 +36,7 @@ public interface IMedia
|
||||
* @param label The string to set the label to.
|
||||
* @return true if the label was updated, false if the label may not be modified.
|
||||
*/
|
||||
public boolean setLabel( ItemStack stack, String label );
|
||||
boolean setLabel( @Nonnull ItemStack stack, @Nullable String label );
|
||||
|
||||
/**
|
||||
* If this disk represents an item with audio (like a record), get the readable name of the audio track. ie:
|
||||
@ -41,7 +45,8 @@ public interface IMedia
|
||||
* @param stack The itemstack to inspect.
|
||||
* @return The name, or null if this item does not represent an item with audio.
|
||||
*/
|
||||
public String getAudioTitle( ItemStack stack );
|
||||
@Nullable
|
||||
String getAudioTitle( @Nonnull ItemStack stack );
|
||||
|
||||
/**
|
||||
* If this disk represents an item with audio (like a record), get the resource name of the audio track to play.
|
||||
@ -49,7 +54,8 @@ public interface IMedia
|
||||
* @param stack The itemstack to inspect.
|
||||
* @return The name, or null if this item does not represent an item with audio.
|
||||
*/
|
||||
public SoundEvent getAudio( ItemStack stack );
|
||||
@Nullable
|
||||
SoundEvent getAudio( @Nonnull ItemStack stack );
|
||||
|
||||
/**
|
||||
* If this disk represents an item with data (like a floppy disk), get a mount representing it's contents. This will
|
||||
@ -64,5 +70,6 @@ public interface IMedia
|
||||
* @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String, long)
|
||||
* @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(Class, String, String)
|
||||
*/
|
||||
public IMount createDataMount( ItemStack stack, World world );
|
||||
@Nullable
|
||||
IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world );
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ package dan200.computercraft.api.media;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* This interface is used to provide {@link IMedia} implementations for {@link ItemStack}.
|
||||
*
|
||||
@ -22,5 +25,6 @@ public interface IMediaProvider
|
||||
* @return An IMedia implementation, or null if the item is not something you wish to handle
|
||||
* @see dan200.computercraft.api.ComputerCraftAPI#registerMediaProvider(IMediaProvider)
|
||||
*/
|
||||
public IMedia getMedia( ItemStack stack );
|
||||
@Nullable
|
||||
IMedia getMedia( @Nonnull ItemStack stack );
|
||||
}
|
||||
|
@ -11,6 +11,9 @@ import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.filesystem.IWritableMount;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* The interface passed to peripherals by computers or turtles, providing methods
|
||||
* that they can call. This should not be implemented by your classes. Do not interact
|
||||
@ -33,7 +36,8 @@ public interface IComputerAccess
|
||||
* @see #unmount(String)
|
||||
* @see IMount
|
||||
*/
|
||||
public String mount( String desiredLocation, IMount mount );
|
||||
@Nullable
|
||||
String mount( @Nonnull String desiredLocation, @Nonnull IMount mount );
|
||||
|
||||
/**
|
||||
* Mount a mount onto the computer's file system in a read only mode.
|
||||
@ -51,7 +55,8 @@ public interface IComputerAccess
|
||||
* @see #unmount(String)
|
||||
* @see IMount
|
||||
*/
|
||||
public String mount( String desiredLocation, IMount mount, String driveName );
|
||||
@Nullable
|
||||
String mount( @Nonnull String desiredLocation, @Nonnull IMount mount, @Nonnull String driveName );
|
||||
|
||||
/**
|
||||
* Mount a mount onto the computer's file system in a writable mode.
|
||||
@ -67,7 +72,8 @@ public interface IComputerAccess
|
||||
* @see #unmount(String)
|
||||
* @see IMount
|
||||
*/
|
||||
public String mountWritable( String desiredLocation, IWritableMount mount );
|
||||
@Nullable
|
||||
String mountWritable( @Nonnull String desiredLocation, @Nonnull IWritableMount mount );
|
||||
|
||||
/**
|
||||
* Mount a mount onto the computer's file system in a writable mode.
|
||||
@ -84,7 +90,7 @@ public interface IComputerAccess
|
||||
* @see #unmount(String)
|
||||
* @see IMount
|
||||
*/
|
||||
public String mountWritable( String desiredLocation, IWritableMount mount, String driveName );
|
||||
String mountWritable( @Nonnull String desiredLocation, @Nonnull IWritableMount mount, @Nonnull String driveName );
|
||||
|
||||
/**
|
||||
* Unmounts a directory previously mounted onto the computers file system by {@link #mount(String, IMount)}
|
||||
@ -104,7 +110,7 @@ public interface IComputerAccess
|
||||
* @see #mount(String, IMount)
|
||||
* @see #mountWritable(String, IWritableMount)
|
||||
*/
|
||||
public void unmount( String location );
|
||||
void unmount( @Nullable String location );
|
||||
|
||||
/**
|
||||
* Returns the numerical ID of this computer.
|
||||
@ -114,7 +120,7 @@ public interface IComputerAccess
|
||||
*
|
||||
* @return The identifier.
|
||||
*/
|
||||
public int getID();
|
||||
int getID();
|
||||
|
||||
/**
|
||||
* Causes an event to be raised on this computer, which the computer can respond to by calling
|
||||
@ -134,7 +140,7 @@ public interface IComputerAccess
|
||||
* @throws RuntimeException If the peripheral has been detached.
|
||||
* @see dan200.computercraft.api.peripheral.IPeripheral#callMethod
|
||||
*/
|
||||
public void queueEvent( String event, Object[] arguments );
|
||||
void queueEvent( @Nonnull String event, @Nullable Object[] arguments );
|
||||
|
||||
/**
|
||||
* Get a string, unique to the computer, by which the computer refers to this peripheral.
|
||||
@ -146,5 +152,6 @@ public interface IComputerAccess
|
||||
* @return A string unique to the computer, but not globally.
|
||||
* @throws RuntimeException If the peripheral has been detached.
|
||||
*/
|
||||
public String getAttachmentName();
|
||||
@Nonnull
|
||||
String getAttachmentName();
|
||||
}
|
||||
|
@ -9,6 +9,9 @@ package dan200.computercraft.api.peripheral;
|
||||
import dan200.computercraft.api.lua.ILuaContext;
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* The interface that defines a peripheral. See {@link IPeripheralProvider} for how to associate blocks with peripherals.
|
||||
*/
|
||||
@ -20,7 +23,8 @@ public interface IPeripheral
|
||||
*
|
||||
* @return A string identifying the type of peripheral.
|
||||
*/
|
||||
public String getType();
|
||||
@Nonnull
|
||||
String getType();
|
||||
|
||||
/**
|
||||
* Should return an array of strings that identify the methods that this
|
||||
@ -30,7 +34,8 @@ public interface IPeripheral
|
||||
* @return An array of strings representing method names.
|
||||
* @see #callMethod
|
||||
*/
|
||||
public String[] getMethodNames();
|
||||
@Nonnull
|
||||
String[] getMethodNames();
|
||||
|
||||
/**
|
||||
* This is called when a lua program on an attached computer calls {@code peripheral.call()} with
|
||||
@ -66,7 +71,8 @@ public interface IPeripheral
|
||||
* intercepted, or the computer will leak memory and end up in a broken state.
|
||||
* @see #getMethodNames
|
||||
*/
|
||||
public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException;
|
||||
@Nullable
|
||||
Object[] callMethod( @Nonnull IComputerAccess computer, @Nonnull ILuaContext context, int method, @Nonnull Object[] arguments ) throws LuaException, InterruptedException;
|
||||
|
||||
/**
|
||||
* Is called when canAttachToSide has returned true, and a computer is attaching to the peripheral.
|
||||
@ -85,7 +91,7 @@ public interface IPeripheral
|
||||
* computers can be attached to a peripheral at once.
|
||||
* @see #detach
|
||||
*/
|
||||
public void attach( IComputerAccess computer );
|
||||
void attach( @Nonnull IComputerAccess computer );
|
||||
|
||||
/**
|
||||
* Is called when a computer is detaching from the peripheral.
|
||||
@ -102,7 +108,7 @@ public interface IPeripheral
|
||||
* computers can be attached to a peripheral at once.
|
||||
* @see #detach
|
||||
*/
|
||||
public void detach( IComputerAccess computer );
|
||||
void detach( @Nonnull IComputerAccess computer );
|
||||
|
||||
/**
|
||||
* Determine whether this peripheral is equivalent to another one.
|
||||
@ -113,5 +119,5 @@ public interface IPeripheral
|
||||
* @param other The peripheral to compare against. This may be {@code null}.
|
||||
* @return Whether these peripherals are equivalent.
|
||||
*/
|
||||
public boolean equals( IPeripheral other );
|
||||
boolean equals( @Nullable IPeripheral other );
|
||||
}
|
||||
|
@ -10,6 +10,9 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* This interface is used to create peripheral implementations for blocks.
|
||||
*
|
||||
@ -26,5 +29,6 @@ public interface IPeripheralProvider
|
||||
* @return A peripheral, or {@code null} if there is not a peripheral here you'd like to handle.
|
||||
* @see dan200.computercraft.api.ComputerCraftAPI#registerPeripheralProvider(IPeripheralProvider)
|
||||
*/
|
||||
public IPeripheral getPeripheral( World world, BlockPos pos, EnumFacing side );
|
||||
@Nullable
|
||||
IPeripheral getPeripheral( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side );
|
||||
}
|
||||
|
@ -9,6 +9,8 @@ package dan200.computercraft.api.permissions;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* This interface is used to restrict where turtles can move or build.
|
||||
*
|
||||
@ -25,7 +27,7 @@ public interface ITurtlePermissionProvider
|
||||
* @param pos The location of the block.
|
||||
* @return Whether the turtle can move into this block.
|
||||
*/
|
||||
public boolean isBlockEnterable( World world, BlockPos pos );
|
||||
boolean isBlockEnterable( @Nonnull World world, @Nonnull BlockPos pos );
|
||||
|
||||
/**
|
||||
* Determine whether a block can be modified by a turtle.
|
||||
@ -36,5 +38,5 @@ public interface ITurtlePermissionProvider
|
||||
* @param pos The location of the block.
|
||||
* @return Whether the turtle can modify this block.
|
||||
*/
|
||||
public boolean isBlockEditable( World world, BlockPos pos );
|
||||
boolean isBlockEditable( @Nonnull World world, @Nonnull BlockPos pos );
|
||||
}
|
||||
|
@ -10,6 +10,8 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* This interface is used to provide bundled redstone output for blocks.
|
||||
*
|
||||
@ -27,5 +29,5 @@ public interface IBundledRedstoneProvider
|
||||
* handle this block.
|
||||
* @see dan200.computercraft.api.ComputerCraftAPI#registerBundledRedstoneProvider(IBundledRedstoneProvider)
|
||||
*/
|
||||
public int getBundledRedstoneOutput( World world, BlockPos pos, EnumFacing side );
|
||||
int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side );
|
||||
}
|
||||
|
@ -16,6 +16,9 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* The interface passed to turtle by turtles, providing methods that they can call.
|
||||
*
|
||||
@ -29,14 +32,16 @@ public interface ITurtleAccess
|
||||
*
|
||||
* @return the world in which the turtle resides.
|
||||
*/
|
||||
public World getWorld();
|
||||
@Nonnull
|
||||
World getWorld();
|
||||
|
||||
/**
|
||||
* Returns a vector containing the integer co-ordinates at which the turtle resides.
|
||||
*
|
||||
* @return a vector containing the integer co-ordinates at which the turtle resides.
|
||||
*/
|
||||
public BlockPos getPosition();
|
||||
@Nonnull
|
||||
BlockPos getPosition();
|
||||
|
||||
/**
|
||||
* Attempt to move this turtle to a new position.
|
||||
@ -51,7 +56,7 @@ public interface ITurtleAccess
|
||||
* {@link dan200.computercraft.api.permissions.ITurtlePermissionProvider#isBlockEnterable(World, BlockPos)}.
|
||||
* @throws UnsupportedOperationException When attempting to teleport on the client side.
|
||||
*/
|
||||
public boolean teleportTo( World world, BlockPos pos );
|
||||
boolean teleportTo( @Nonnull World world, @Nonnull BlockPos pos );
|
||||
|
||||
/**
|
||||
* Returns a vector containing the floating point co-ordinates at which the turtle is rendered.
|
||||
@ -61,7 +66,8 @@ public interface ITurtleAccess
|
||||
* @return A vector containing the floating point co-ordinates at which the turtle resides.
|
||||
* @see #getVisualYaw(float)
|
||||
*/
|
||||
public Vec3d getVisualPosition( float f );
|
||||
@Nonnull
|
||||
Vec3d getVisualPosition( float f );
|
||||
|
||||
/**
|
||||
* Returns the yaw the turtle is facing when it is rendered.
|
||||
@ -70,7 +76,7 @@ public interface ITurtleAccess
|
||||
* @return The yaw the turtle is facing.
|
||||
* @see #getVisualPosition(float)
|
||||
*/
|
||||
public float getVisualYaw( float f );
|
||||
float getVisualYaw( float f );
|
||||
|
||||
/**
|
||||
* Returns the world direction the turtle is currently facing.
|
||||
@ -78,7 +84,8 @@ public interface ITurtleAccess
|
||||
* @return The world direction the turtle is currently facing.
|
||||
* @see #setDirection(EnumFacing)
|
||||
*/
|
||||
public EnumFacing getDirection();
|
||||
@Nonnull
|
||||
EnumFacing getDirection();
|
||||
|
||||
/**
|
||||
* Set the direction the turtle is facing. Note that this will not play a rotation animation, you will also need to
|
||||
@ -87,7 +94,7 @@ public interface ITurtleAccess
|
||||
* @param dir The new direction to set. This should be on either the x or z axis (so north, south, east or west).
|
||||
* @see #getDirection()
|
||||
*/
|
||||
public void setDirection( EnumFacing dir );
|
||||
void setDirection( @Nonnull EnumFacing dir );
|
||||
|
||||
/**
|
||||
* Get the currently selected slot in the turtle's inventory.
|
||||
@ -96,7 +103,7 @@ public interface ITurtleAccess
|
||||
* @see #getInventory()
|
||||
* @see #setSelectedSlot(int)
|
||||
*/
|
||||
public int getSelectedSlot();
|
||||
int getSelectedSlot();
|
||||
|
||||
/**
|
||||
* Set the currently selected slot in the turtle's inventory.
|
||||
@ -107,7 +114,7 @@ public interface ITurtleAccess
|
||||
* @see #getInventory()
|
||||
* @see #getSelectedSlot()
|
||||
*/
|
||||
public void setSelectedSlot( int slot );
|
||||
void setSelectedSlot( int slot );
|
||||
|
||||
/**
|
||||
* Sets the colour of the turtle, as if the player had dyed it with a dye item.
|
||||
@ -116,7 +123,7 @@ public interface ITurtleAccess
|
||||
* the dye from the turtle.
|
||||
* @see #getDyeColour()
|
||||
*/
|
||||
public void setDyeColour( int dyeColour );
|
||||
void setDyeColour( int dyeColour );
|
||||
|
||||
/**
|
||||
* Gets the colour the turtle has been dyed.
|
||||
@ -125,14 +132,15 @@ public interface ITurtleAccess
|
||||
* is clean.
|
||||
* @see #getDyeColour()
|
||||
*/
|
||||
public int getDyeColour();
|
||||
int getDyeColour();
|
||||
|
||||
/**
|
||||
* Get the inventory of this turtle
|
||||
*
|
||||
* @return This turtle's inventory
|
||||
*/
|
||||
public IInventory getInventory();
|
||||
@Nonnull
|
||||
IInventory getInventory();
|
||||
|
||||
/**
|
||||
* Determine whether this turtle will require fuel when performing actions.
|
||||
@ -141,7 +149,7 @@ public interface ITurtleAccess
|
||||
* @see #getFuelLevel()
|
||||
* @see #setFuelLevel(int)
|
||||
*/
|
||||
public boolean isFuelNeeded();
|
||||
boolean isFuelNeeded();
|
||||
|
||||
/**
|
||||
* Get the current fuel level of this turtle.
|
||||
@ -150,7 +158,7 @@ public interface ITurtleAccess
|
||||
* @see #isFuelNeeded()
|
||||
* @see #setFuelLevel(int)
|
||||
*/
|
||||
public int getFuelLevel();
|
||||
int getFuelLevel();
|
||||
|
||||
/**
|
||||
* Set the fuel level to a new value. It is generally preferred to use {@link #consumeFuel(int)}} or {@link #addFuel(int)}
|
||||
@ -162,14 +170,14 @@ public interface ITurtleAccess
|
||||
* @see #addFuel(int)
|
||||
* @see #consumeFuel(int)
|
||||
*/
|
||||
public void setFuelLevel( int fuel );
|
||||
void setFuelLevel( int fuel );
|
||||
|
||||
/**
|
||||
* Get the maximum amount of fuel a turtle can hold.
|
||||
*
|
||||
* @return The turtle's fuel limit.
|
||||
*/
|
||||
public int getFuelLimit();
|
||||
int getFuelLimit();
|
||||
|
||||
/**
|
||||
* Removes some fuel from the turtles fuel supply. Negative numbers can be passed in to INCREASE the fuel level of the turtle.
|
||||
@ -179,7 +187,7 @@ public interface ITurtleAccess
|
||||
* greater than the current fuel level of the turtle. No fuel will be consumed if {@code false} is returned.
|
||||
* @throws UnsupportedOperationException When attempting to consume fuel on the client side.
|
||||
*/
|
||||
public boolean consumeFuel( int fuel );
|
||||
boolean consumeFuel( int fuel );
|
||||
|
||||
/**
|
||||
* Increase the turtle's fuel level by the given amount.
|
||||
@ -187,7 +195,7 @@ public interface ITurtleAccess
|
||||
* @param fuel The amount to refuel with.
|
||||
* @throws UnsupportedOperationException When attempting to refuel on the client side.
|
||||
*/
|
||||
public void addFuel( int fuel );
|
||||
void addFuel( int fuel );
|
||||
|
||||
/**
|
||||
* Adds a custom command to the turtles command queue. Unlike peripheral methods, these custom commands will be executed
|
||||
@ -209,7 +217,8 @@ public interface ITurtleAccess
|
||||
* @see ITurtleCommand
|
||||
* @see ILuaContext#pullEvent(String)
|
||||
*/
|
||||
public Object[] executeCommand( ILuaContext context, ITurtleCommand command ) throws LuaException, InterruptedException;
|
||||
@Nonnull
|
||||
Object[] executeCommand( @Nonnull ILuaContext context, @Nonnull ITurtleCommand command ) throws LuaException, InterruptedException;
|
||||
|
||||
/**
|
||||
* Start playing a specific animation. This will prevent other turtle commands from executing until
|
||||
@ -219,7 +228,7 @@ public interface ITurtleAccess
|
||||
* @throws UnsupportedOperationException When attempting to execute play an animation on the client side.
|
||||
* @see TurtleAnimation
|
||||
*/
|
||||
public void playAnimation( TurtleAnimation animation );
|
||||
void playAnimation( @Nonnull TurtleAnimation animation );
|
||||
|
||||
/**
|
||||
* Returns the turtle on the specified side of the turtle, if there is one.
|
||||
@ -228,7 +237,8 @@ public interface ITurtleAccess
|
||||
* @return The upgrade on the specified side of the turtle, if there is one.
|
||||
* @see #setUpgrade(TurtleSide, ITurtleUpgrade)
|
||||
*/
|
||||
public ITurtleUpgrade getUpgrade( TurtleSide side );
|
||||
@Nullable
|
||||
ITurtleUpgrade getUpgrade( @Nonnull TurtleSide side );
|
||||
|
||||
/**
|
||||
* Set the upgrade for a given side, resetting peripherals and clearing upgrade specific data.
|
||||
@ -237,7 +247,7 @@ public interface ITurtleAccess
|
||||
* @param upgrade The upgrade to set, may be {@code null} to clear.
|
||||
* @see #getUpgrade(TurtleSide)
|
||||
*/
|
||||
public void setUpgrade( TurtleSide side, ITurtleUpgrade upgrade );
|
||||
void setUpgrade( @Nonnull TurtleSide side, @Nullable ITurtleUpgrade upgrade );
|
||||
|
||||
/**
|
||||
* Returns the peripheral created by the upgrade on the specified side of the turtle, if there is one.
|
||||
@ -245,7 +255,8 @@ public interface ITurtleAccess
|
||||
* @param side The side to get the peripheral from.
|
||||
* @return The peripheral created by the upgrade on the specified side of the turtle, {@code null} if none exists.
|
||||
*/
|
||||
public IPeripheral getPeripheral( TurtleSide side );
|
||||
@Nullable
|
||||
IPeripheral getPeripheral( @Nonnull TurtleSide side );
|
||||
|
||||
/**
|
||||
* Get an upgrade-specific NBT compound, which can be used to store arbitrary data.
|
||||
@ -257,7 +268,8 @@ public interface ITurtleAccess
|
||||
* @return The upgrade-specific data.
|
||||
* @see #updateUpgradeNBTData(TurtleSide)
|
||||
*/
|
||||
public NBTTagCompound getUpgradeNBTData( TurtleSide side );
|
||||
@Nonnull
|
||||
NBTTagCompound getUpgradeNBTData( @Nullable TurtleSide side );
|
||||
|
||||
/**
|
||||
* Mark the upgrade-specific data as dirty on a specific side. This is required for the data to be synced to the
|
||||
@ -266,5 +278,5 @@ public interface ITurtleAccess
|
||||
* @param side The side to mark dirty.
|
||||
* @see #updateUpgradeNBTData(TurtleSide)
|
||||
*/
|
||||
public void updateUpgradeNBTData( TurtleSide side );
|
||||
void updateUpgradeNBTData( @Nonnull TurtleSide side );
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ package dan200.computercraft.api.turtle;
|
||||
|
||||
import dan200.computercraft.api.lua.ILuaContext;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* An interface for objects executing custom turtle commands, used with {@link ITurtleAccess#executeCommand(ILuaContext, ITurtleCommand)}.
|
||||
*
|
||||
@ -28,5 +30,6 @@ public interface ITurtleCommand
|
||||
* @see TurtleCommandResult#failure(String)
|
||||
* @see TurtleCommandResult
|
||||
*/
|
||||
public TurtleCommandResult execute( ITurtleAccess turtle );
|
||||
@Nonnull
|
||||
TurtleCommandResult execute( @Nonnull ITurtleAccess turtle );
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
|
||||
|
||||
@ -36,7 +38,8 @@ public interface ITurtleUpgrade
|
||||
* @return The unique ID for this upgrade.
|
||||
* @see ComputerCraftAPI#registerTurtleUpgrade(ITurtleUpgrade)
|
||||
*/
|
||||
public ResourceLocation getUpgradeID();
|
||||
@Nonnull
|
||||
ResourceLocation getUpgradeID();
|
||||
|
||||
/**
|
||||
* Gets a numerical identifier representing this type of turtle upgrade,
|
||||
@ -47,7 +50,7 @@ public interface ITurtleUpgrade
|
||||
* @return The legacy ID, or -1 if is needed.
|
||||
* @see ComputerCraftAPI#registerTurtleUpgrade(ITurtleUpgrade)
|
||||
*/
|
||||
public int getLegacyUpgradeID();
|
||||
int getLegacyUpgradeID();
|
||||
|
||||
/**
|
||||
* Return an unlocalised string to describe this type of turtle in turtle item names.
|
||||
@ -56,7 +59,8 @@ public interface ITurtleUpgrade
|
||||
*
|
||||
* @return The localisation key for this upgrade's adjective.
|
||||
*/
|
||||
public String getUnlocalisedAdjective();
|
||||
@Nonnull
|
||||
String getUnlocalisedAdjective();
|
||||
|
||||
/**
|
||||
* Return whether this turtle adds a tool or a peripheral to the turtle.
|
||||
@ -64,7 +68,8 @@ public interface ITurtleUpgrade
|
||||
* @return The type of upgrade this is.
|
||||
* @see TurtleUpgradeType for the differences between them.
|
||||
*/
|
||||
public TurtleUpgradeType getType();
|
||||
@Nonnull
|
||||
TurtleUpgradeType getType();
|
||||
|
||||
/**
|
||||
* Return an item stack representing the type of item that a turtle must be crafted
|
||||
@ -73,7 +78,8 @@ public interface ITurtleUpgrade
|
||||
*
|
||||
* @return The item stack to craft with, or {@code null} if it cannot be crafted.
|
||||
*/
|
||||
public ItemStack getCraftingItem();
|
||||
@Nullable
|
||||
ItemStack getCraftingItem();
|
||||
|
||||
/**
|
||||
* Will only be called for peripheral upgrades. Creates a peripheral for a turtle being placed using this upgrade.
|
||||
@ -87,7 +93,8 @@ public interface ITurtleUpgrade
|
||||
* @return The newly created peripheral. You may return {@code null} if this upgrade is a Tool
|
||||
* and this method is not expected to be called.
|
||||
*/
|
||||
public IPeripheral createPeripheral( ITurtleAccess turtle, TurtleSide side );
|
||||
@Nullable
|
||||
IPeripheral createPeripheral( @Nonnull ITurtleAccess turtle, @Nonnull TurtleSide side );
|
||||
|
||||
/**
|
||||
* Will only be called for Tool turtle. Called when turtle.dig() or turtle.attack() is called
|
||||
@ -104,7 +111,8 @@ public interface ITurtleUpgrade
|
||||
* a swinging animation. You may return {@code null} if this turtle is a Peripheral and this method is not expected
|
||||
* to be called.
|
||||
*/
|
||||
public TurtleCommandResult useTool( ITurtleAccess turtle, TurtleSide side, TurtleVerb verb, EnumFacing direction );
|
||||
@Nonnull
|
||||
TurtleCommandResult useTool( @Nonnull ITurtleAccess turtle, @Nonnull TurtleSide side, @Nonnull TurtleVerb verb, @Nonnull EnumFacing direction );
|
||||
|
||||
/**
|
||||
* Called to obtain the model to be used when rendering a turtle peripheral.
|
||||
@ -119,7 +127,8 @@ public interface ITurtleUpgrade
|
||||
* a transformation of {@code null} has the same effect as the identify matrix.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Pair<IBakedModel, Matrix4f> getModel( ITurtleAccess turtle, TurtleSide side );
|
||||
@Nonnull
|
||||
Pair<IBakedModel, Matrix4f> getModel( @Nullable ITurtleAccess turtle, @Nonnull TurtleSide side );
|
||||
|
||||
/**
|
||||
* Called once per tick for each turtle which has the upgrade equipped.
|
||||
@ -127,5 +136,5 @@ public interface ITurtleUpgrade
|
||||
* @param turtle Access to the turtle that the upgrade resides on.
|
||||
* @param side Which side of the turtle (left or right) the upgrade resides on.
|
||||
*/
|
||||
public void update( ITurtleAccess turtle, TurtleSide side );
|
||||
void update( @Nonnull ITurtleAccess turtle, @Nonnull TurtleSide side );
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ package dan200.computercraft.api.turtle;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Used to indicate the result of executing a turtle command.
|
||||
*
|
||||
@ -24,6 +27,7 @@ public final class TurtleCommandResult
|
||||
*
|
||||
* @return A successful command result with no values.
|
||||
*/
|
||||
@Nonnull
|
||||
public static TurtleCommandResult success()
|
||||
{
|
||||
return success( null );
|
||||
@ -35,7 +39,8 @@ public final class TurtleCommandResult
|
||||
* @param results The results of executing this command.
|
||||
* @return A successful command result with the given values.
|
||||
*/
|
||||
public static TurtleCommandResult success( Object[] results )
|
||||
@Nonnull
|
||||
public static TurtleCommandResult success( @Nullable Object[] results )
|
||||
{
|
||||
if( results == null || results.length == 0 )
|
||||
{
|
||||
@ -52,6 +57,7 @@ public final class TurtleCommandResult
|
||||
*
|
||||
* @return A failed command result with no message.
|
||||
*/
|
||||
@Nonnull
|
||||
public static TurtleCommandResult failure()
|
||||
{
|
||||
return failure( null );
|
||||
@ -63,7 +69,8 @@ public final class TurtleCommandResult
|
||||
* @param errorMessage The error message to provide.
|
||||
* @return A failed command result with a message.
|
||||
*/
|
||||
public static TurtleCommandResult failure( String errorMessage )
|
||||
@Nonnull
|
||||
public static TurtleCommandResult failure( @Nullable String errorMessage )
|
||||
{
|
||||
if( errorMessage == null )
|
||||
{
|
||||
@ -101,6 +108,7 @@ public final class TurtleCommandResult
|
||||
*
|
||||
* @return The command's error message, or {@code null} if it was a success.
|
||||
*/
|
||||
@Nullable
|
||||
public String getErrorMessage()
|
||||
{
|
||||
return m_errorMessage;
|
||||
@ -111,6 +119,7 @@ public final class TurtleCommandResult
|
||||
*
|
||||
* @return The command's result, or {@code null} if it was a failure.
|
||||
*/
|
||||
@Nullable
|
||||
public Object[] getResults()
|
||||
{
|
||||
return m_results;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
|
@ -18,7 +18,7 @@ public class GuiConfigCC extends GuiConfig
|
||||
{
|
||||
public GuiConfigCC( GuiScreen parentScreen )
|
||||
{
|
||||
super( parentScreen, getConfigElements(), "ComputerCraft", false, false, "ComputerCraft" );
|
||||
super( parentScreen, getConfigElements(), ComputerCraft.MOD_ID, false, false, "ComputerCraft" );
|
||||
}
|
||||
|
||||
private static List<IConfigElement> getConfigElements()
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -15,7 +15,6 @@ import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -11,13 +11,10 @@ import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.RenderItem;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
public abstract class Widget extends Gui
|
||||
{
|
||||
@ -269,9 +266,8 @@ public abstract class Widget extends Gui
|
||||
FontRenderer fontRenderer = mc.fontRendererObj;
|
||||
|
||||
int width = 0;
|
||||
for( int i=0; i<lines.length; ++i )
|
||||
for( String line : lines )
|
||||
{
|
||||
String line = lines[i];
|
||||
width = Math.max( fontRenderer.getStringWidth( line ), width );
|
||||
}
|
||||
int startX = x + 12;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -48,10 +48,10 @@ public class WidgetContainer extends Widget
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
for( int i=0; i<m_widgets.size(); ++i )
|
||||
{
|
||||
m_widgets.get( i ).update();
|
||||
}
|
||||
for( Widget m_widget : m_widgets )
|
||||
{
|
||||
m_widget.update();
|
||||
}
|
||||
if( m_modalWidget != null )
|
||||
{
|
||||
m_modalWidget.update();
|
||||
@ -61,20 +61,19 @@ public class WidgetContainer extends Widget
|
||||
@Override
|
||||
public void draw( Minecraft mc, int xOrigin, int yOrigin, int mouseX, int mouseY )
|
||||
{
|
||||
for( int i=0; i<m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.draw(
|
||||
mc,
|
||||
xOrigin + getXPosition(),
|
||||
yOrigin + getYPosition(),
|
||||
(m_modalWidget == null) ? (mouseX - getXPosition()) : -99,
|
||||
(m_modalWidget == null) ? (mouseY - getYPosition()) : -99
|
||||
);
|
||||
}
|
||||
}
|
||||
for( Widget widget : m_widgets )
|
||||
{
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.draw(
|
||||
mc,
|
||||
xOrigin + getXPosition(),
|
||||
yOrigin + getYPosition(),
|
||||
(m_modalWidget == null) ? (mouseX - getXPosition()) : -99,
|
||||
(m_modalWidget == null) ? (mouseY - getYPosition()) : -99
|
||||
);
|
||||
}
|
||||
}
|
||||
if( m_modalWidget != null )
|
||||
{
|
||||
if( m_modalWidget.isVisible() )
|
||||
@ -102,20 +101,19 @@ public class WidgetContainer extends Widget
|
||||
@Override
|
||||
public void drawForeground( Minecraft mc, int xOrigin, int yOrigin, int mouseX, int mouseY )
|
||||
{
|
||||
for( int i=0; i<m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.drawForeground(
|
||||
mc,
|
||||
xOrigin + getXPosition(),
|
||||
yOrigin + getYPosition(),
|
||||
(m_modalWidget == null) ? (mouseX - getXPosition()) : -99,
|
||||
(m_modalWidget == null) ? (mouseY - getYPosition()) : -99
|
||||
);
|
||||
}
|
||||
}
|
||||
for( Widget widget : m_widgets )
|
||||
{
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.drawForeground(
|
||||
mc,
|
||||
xOrigin + getXPosition(),
|
||||
yOrigin + getYPosition(),
|
||||
(m_modalWidget == null) ? (mouseX - getXPosition()) : -99,
|
||||
(m_modalWidget == null) ? (mouseY - getYPosition()) : -99
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if( m_modalWidget != null )
|
||||
{
|
||||
@ -148,14 +146,13 @@ public class WidgetContainer extends Widget
|
||||
pos.y -= getYPosition();
|
||||
if( m_modalWidget == null )
|
||||
{
|
||||
for( int i = 0; i < m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.modifyMousePosition( pos );
|
||||
}
|
||||
}
|
||||
for( Widget widget : m_widgets )
|
||||
{
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.modifyMousePosition( pos );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -173,23 +170,22 @@ public class WidgetContainer extends Widget
|
||||
{
|
||||
if( m_modalWidget == null )
|
||||
{
|
||||
for( int i = 0; i < m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
if( widget.suppressItemTooltips(
|
||||
mc,
|
||||
xOrigin + getXPosition(),
|
||||
yOrigin + getYPosition(),
|
||||
mouseX - getXPosition(),
|
||||
mouseY - getYPosition()
|
||||
) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for( Widget widget : m_widgets )
|
||||
{
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
if( widget.suppressItemTooltips(
|
||||
mc,
|
||||
xOrigin + getXPosition(),
|
||||
yOrigin + getYPosition(),
|
||||
mouseX - getXPosition(),
|
||||
mouseY - getYPosition()
|
||||
) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -211,17 +207,16 @@ public class WidgetContainer extends Widget
|
||||
{
|
||||
if( m_modalWidget == null )
|
||||
{
|
||||
for( int i = 0; i < m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
if( widget.suppressKeyPress( c, k ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for( Widget widget : m_widgets )
|
||||
{
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
if( widget.suppressKeyPress( c, k ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -241,17 +236,16 @@ public class WidgetContainer extends Widget
|
||||
{
|
||||
if( m_modalWidget == null )
|
||||
{
|
||||
for( int i = 0; i < m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.handleMouseInput(
|
||||
mouseX - getXPosition(),
|
||||
mouseY - getYPosition()
|
||||
);
|
||||
}
|
||||
}
|
||||
for( Widget widget : m_widgets )
|
||||
{
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.handleMouseInput(
|
||||
mouseX - getXPosition(),
|
||||
mouseY - getYPosition()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -270,14 +264,13 @@ public class WidgetContainer extends Widget
|
||||
{
|
||||
if( m_modalWidget == null )
|
||||
{
|
||||
for( int i = 0; i < m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.handleKeyboardInput();
|
||||
}
|
||||
}
|
||||
for( Widget widget : m_widgets )
|
||||
{
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.handleKeyboardInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -293,18 +286,17 @@ public class WidgetContainer extends Widget
|
||||
{
|
||||
if( m_modalWidget == null )
|
||||
{
|
||||
for( int i = 0; i < m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.mouseClicked(
|
||||
mouseX - getXPosition(),
|
||||
mouseY - getYPosition(),
|
||||
mouseButton
|
||||
);
|
||||
}
|
||||
}
|
||||
for( Widget widget : m_widgets )
|
||||
{
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.mouseClicked(
|
||||
mouseX - getXPosition(),
|
||||
mouseY - getYPosition(),
|
||||
mouseButton
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -324,14 +316,13 @@ public class WidgetContainer extends Widget
|
||||
{
|
||||
if( m_modalWidget == null )
|
||||
{
|
||||
for( int i = 0; i < m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.keyTyped( c, k );
|
||||
}
|
||||
}
|
||||
for( Widget widget : m_widgets )
|
||||
{
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.keyTyped( c, k );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -38,6 +38,8 @@ import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class CCTurtleProxyClient extends CCTurtleProxyCommon
|
||||
{
|
||||
public CCTurtleProxyClient()
|
||||
@ -56,8 +58,9 @@ public class CCTurtleProxyClient extends CCTurtleProxyCommon
|
||||
{
|
||||
private ModelResourceLocation turtle_dynamic = new ModelResourceLocation( "computercraft:turtle_dynamic", "inventory" );
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation( ItemStack stack )
|
||||
public ModelResourceLocation getModelLocation( @Nonnull ItemStack stack )
|
||||
{
|
||||
return turtle_dynamic;
|
||||
}
|
||||
@ -188,7 +191,7 @@ public class CCTurtleProxyClient extends CCTurtleProxyCommon
|
||||
private static class TurtleItemColour implements IItemColor
|
||||
{
|
||||
@Override
|
||||
public int getColorFromItemstack( ItemStack stack, int tintIndex )
|
||||
public int getColorFromItemstack( @Nonnull ItemStack stack, int tintIndex )
|
||||
{
|
||||
if( tintIndex == 0 )
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -49,12 +49,12 @@ import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -88,8 +88,9 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
||||
private ModelResourceLocation computer = new ModelResourceLocation( "computercraft:CC-Computer", "inventory" );
|
||||
private ModelResourceLocation advanced_computer = new ModelResourceLocation( "computercraft:advanced_computer", "inventory" );
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation( ItemStack stack )
|
||||
public ModelResourceLocation getModelLocation( @Nonnull ItemStack stack )
|
||||
{
|
||||
ItemComputer itemComputer = (ItemComputer) stack.getItem();
|
||||
ComputerFamily family = itemComputer.getFamily( stack.getItemDamage() );
|
||||
@ -121,8 +122,9 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
||||
private ModelResourceLocation advanced_pocket_computer_on = new ModelResourceLocation( "computercraft:advanced_pocket_computer_on", "inventory" );
|
||||
private ModelResourceLocation advanced_pocket_computer_blinking = new ModelResourceLocation( "computercraft:advanced_pocket_computer_blinking", "inventory" );
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation( ItemStack stack )
|
||||
public ModelResourceLocation getModelLocation( @Nonnull ItemStack stack )
|
||||
{
|
||||
ItemPocketComputer itemPocketComputer = (ItemPocketComputer)stack.getItem();
|
||||
switch( itemPocketComputer.getFamily( stack ) )
|
||||
@ -180,7 +182,7 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
||||
mc.getItemColors().registerItemColorHandler( new IItemColor()
|
||||
{
|
||||
@Override
|
||||
public int getColorFromItemstack( ItemStack stack, int layout )
|
||||
public int getColorFromItemstack( @Nonnull ItemStack stack, int layout )
|
||||
{
|
||||
if( layout != 1 ) return 0xFFFFFF;
|
||||
|
||||
@ -219,8 +221,9 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
||||
ModelBakery.registerItemVariants( item, new ResourceLocation( "computercraft", name ) );
|
||||
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register( item, new ItemMeshDefinition()
|
||||
{
|
||||
@Nonnull
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation( ItemStack stack )
|
||||
public ModelResourceLocation getModelLocation( @Nonnull ItemStack stack )
|
||||
{
|
||||
return res;
|
||||
}
|
||||
@ -276,10 +279,10 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
||||
@Override
|
||||
public String getRecordInfo( ItemStack recordStack )
|
||||
{
|
||||
List info = new ArrayList(1);
|
||||
List<String> info = new ArrayList<String>( 1 );
|
||||
recordStack.getItem().addInformation( recordStack, null, info, false );
|
||||
if( info.size() > 0 ) {
|
||||
return info.get(0).toString();
|
||||
return info.get( 0 );
|
||||
} else {
|
||||
return super.getRecordInfo( recordStack );
|
||||
}
|
||||
@ -401,7 +404,7 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
||||
{
|
||||
ComputerCraft.clientComputerRegistry.add( instanceID, new ClientComputer( instanceID ) );
|
||||
}
|
||||
ComputerCraft.clientComputerRegistry.get( instanceID ).handlePacket( packet, (EntityPlayer) player );
|
||||
ComputerCraft.clientComputerRegistry.get( instanceID ).handlePacket( packet, player );
|
||||
break;
|
||||
}
|
||||
case ComputerCraftPacket.ComputerDeleted:
|
||||
@ -519,7 +522,7 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorFromItemstack(ItemStack stack, int layer)
|
||||
public int getColorFromItemstack( @Nonnull ItemStack stack, int layer)
|
||||
{
|
||||
return layer == 0 ? 0xFFFFFF : disk.getColor(stack);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -25,6 +25,8 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMonitor>
|
||||
{
|
||||
public TileEntityMonitorRenderer()
|
||||
@ -32,7 +34,7 @@ public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMon
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt( TileMonitor tileEntity, double posX, double posY, double posZ, float f, int i )
|
||||
public void renderTileEntityAt( @Nonnull TileMonitor tileEntity, double posX, double posY, double posZ, float f, int i )
|
||||
{
|
||||
if( tileEntity != null )
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -41,6 +41,7 @@ import net.minecraftforge.client.model.pipeline.LightUtil;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.vecmath.Matrix4f;
|
||||
import java.util.List;
|
||||
|
||||
@ -75,7 +76,7 @@ public class TileEntityTurtleRenderer extends TileEntitySpecialRenderer<TileTurt
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt( TileTurtle tileEntity, double posX, double posY, double posZ, float f, int i )
|
||||
public void renderTileEntityAt( @Nonnull TileTurtle tileEntity, double posX, double posY, double posZ, float f, int i )
|
||||
{
|
||||
if( tileEntity != null )
|
||||
{
|
||||
|
@ -10,6 +10,7 @@ import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Point3f;
|
||||
import java.util.ArrayList;
|
||||
@ -24,7 +25,7 @@ public class TurtleMultiModel implements IBakedModel
|
||||
private IBakedModel m_rightUpgradeModel;
|
||||
private Matrix4f m_rightUpgradeTransform;
|
||||
private List<BakedQuad> m_generalQuads;
|
||||
private List<BakedQuad> m_faceQuads[];
|
||||
private List<BakedQuad>[] m_faceQuads;
|
||||
|
||||
public TurtleMultiModel( IBakedModel baseModel, IBakedModel overlayModel, IBakedModel leftUpgradeModel, Matrix4f leftUpgradeTransform, IBakedModel rightUpgradeModel, Matrix4f rightUpgradeTransform )
|
||||
{
|
||||
@ -39,6 +40,7 @@ public class TurtleMultiModel implements IBakedModel
|
||||
m_faceQuads = new List[6];
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads( IBlockState state, EnumFacing side, long rand )
|
||||
{
|
||||
@ -107,18 +109,22 @@ public class TurtleMultiModel implements IBakedModel
|
||||
return m_baseModel.isBuiltInRenderer();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
{
|
||||
return m_baseModel.getParticleTexture();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public ItemCameraTransforms getItemCameraTransforms()
|
||||
{
|
||||
return m_baseModel.getItemCameraTransforms();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
@ -134,9 +140,8 @@ public class TurtleMultiModel implements IBakedModel
|
||||
else
|
||||
{
|
||||
List<BakedQuad> output = new ArrayList<BakedQuad>( input.size() );
|
||||
for( int i=0; i<input.size(); ++i )
|
||||
for( BakedQuad quad : input )
|
||||
{
|
||||
BakedQuad quad = input.get( i );
|
||||
output.add( transformQuad( quad, transform ) );
|
||||
}
|
||||
return output;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -26,10 +26,9 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ISmartVariant;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.vecmath.Matrix4f;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -102,8 +101,9 @@ public class TurtleSmartItemModel implements IBakedModel, IResourceManagerReload
|
||||
m_cachedModels = new HashMap<TurtleModelCombination, IBakedModel>();
|
||||
m_overrides = new ItemOverrideList( new ArrayList<ItemOverride>() )
|
||||
{
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity)
|
||||
public IBakedModel handleItemState( @Nonnull IBakedModel originalModel, ItemStack stack, @Nonnull World world, @Nonnull EntityLivingBase entity)
|
||||
{
|
||||
ItemTurtleBase turtle = (ItemTurtleBase) stack.getItem();
|
||||
ComputerFamily family = turtle.getFamily( stack );
|
||||
@ -127,6 +127,7 @@ public class TurtleSmartItemModel implements IBakedModel, IResourceManagerReload
|
||||
};
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
@ -134,7 +135,7 @@ public class TurtleSmartItemModel implements IBakedModel, IResourceManagerReload
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload( IResourceManager resourceManager )
|
||||
public void onResourceManagerReload( @Nonnull IResourceManager resourceManager )
|
||||
{
|
||||
m_cachedModels.clear();
|
||||
}
|
||||
@ -173,6 +174,7 @@ public class TurtleSmartItemModel implements IBakedModel, IResourceManagerReload
|
||||
|
||||
// These should not be called:
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads( IBlockState state, EnumFacing facing, long rand )
|
||||
{
|
||||
@ -197,13 +199,16 @@ public class TurtleSmartItemModel implements IBakedModel, IResourceManagerReload
|
||||
return getDefaultModel().isBuiltInRenderer();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
{
|
||||
return getDefaultModel().getParticleTexture();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public ItemCameraTransforms getItemCameraTransforms()
|
||||
{
|
||||
return getDefaultModel().getItemCameraTransforms();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -9,6 +9,8 @@ package dan200.computercraft.core.apis;
|
||||
import dan200.computercraft.api.lua.ILuaContext;
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
// Contributed by Nia
|
||||
// Based on LuaBit (http://luaforge.net/projects/bit)
|
||||
|
||||
@ -68,6 +70,7 @@ public class BitAPI implements ILuaAPI
|
||||
{
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String[] getMethodNames() {
|
||||
return new String[] {
|
||||
@ -77,7 +80,7 @@ public class BitAPI implements ILuaAPI
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod( ILuaContext context, int method, Object[] args ) throws LuaException
|
||||
public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException
|
||||
{
|
||||
Object a = args.length>0?args[0]:null;
|
||||
Object b = args.length>1?args[1]:null;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -11,6 +11,8 @@ import dan200.computercraft.api.lua.ILuaObject;
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
import dan200.computercraft.core.terminal.TextBuffer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class BufferAPI implements ILuaAPI
|
||||
{
|
||||
private static class BufferLuaObject implements ILuaObject
|
||||
@ -22,6 +24,7 @@ public class BufferAPI implements ILuaAPI
|
||||
m_buffer = buffer;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String[] getMethodNames()
|
||||
{
|
||||
@ -35,7 +38,7 @@ public class BufferAPI implements ILuaAPI
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod( ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException
|
||||
public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] arguments ) throws LuaException, InterruptedException
|
||||
{
|
||||
switch( method )
|
||||
{
|
||||
@ -165,6 +168,7 @@ public class BufferAPI implements ILuaAPI
|
||||
{
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String[] getMethodNames()
|
||||
{
|
||||
@ -174,7 +178,7 @@ public class BufferAPI implements ILuaAPI
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod( ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException
|
||||
public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] arguments ) throws LuaException, InterruptedException
|
||||
{
|
||||
switch( method )
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -14,6 +14,7 @@ import dan200.computercraft.core.filesystem.FileSystemException;
|
||||
import dan200.computercraft.core.filesystem.IMountedFileBinary;
|
||||
import dan200.computercraft.core.filesystem.IMountedFileNormal;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -54,6 +55,7 @@ public class FSAPI implements ILuaAPI
|
||||
m_fileSystem = null;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String[] getMethodNames()
|
||||
{
|
||||
@ -78,7 +80,7 @@ public class FSAPI implements ILuaAPI
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod( ILuaContext context, int method, Object[] args ) throws LuaException
|
||||
public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException
|
||||
{
|
||||
switch( method )
|
||||
{
|
||||
@ -122,7 +124,7 @@ public class FSAPI implements ILuaAPI
|
||||
throw new LuaException( "Expected string" );
|
||||
}
|
||||
String path = (String)args[0];
|
||||
return new Object[]{ m_fileSystem.getName( path ) };
|
||||
return new Object[]{ FileSystem.getName( path ) };
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
@ -357,7 +359,7 @@ public class FSAPI implements ILuaAPI
|
||||
throw new LuaException( "Expected string" );
|
||||
}
|
||||
String path = (String)args[0];
|
||||
return new Object[]{ m_fileSystem.getDirectory( path ) };
|
||||
return new Object[]{ FileSystem.getDirectory( path ) };
|
||||
}
|
||||
default:
|
||||
{
|
||||
@ -370,6 +372,7 @@ public class FSAPI implements ILuaAPI
|
||||
private static Object[] wrapBufferedReader( final IMountedFileNormal reader )
|
||||
{
|
||||
return new Object[] { new ILuaObject() {
|
||||
@Nonnull
|
||||
@Override
|
||||
public String[] getMethodNames()
|
||||
{
|
||||
@ -381,7 +384,7 @@ public class FSAPI implements ILuaAPI
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod( ILuaContext context, int method, Object[] args ) throws LuaException
|
||||
public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException
|
||||
{
|
||||
switch( method )
|
||||
{
|
||||
@ -439,6 +442,7 @@ public class FSAPI implements ILuaAPI
|
||||
private static Object[] wrapBufferedWriter( final IMountedFileNormal writer )
|
||||
{
|
||||
return new Object[] { new ILuaObject() {
|
||||
@Nonnull
|
||||
@Override
|
||||
public String[] getMethodNames()
|
||||
{
|
||||
@ -451,7 +455,7 @@ public class FSAPI implements ILuaAPI
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod( ILuaContext context, int method, Object[] args ) throws LuaException
|
||||
public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException
|
||||
{
|
||||
switch( method )
|
||||
{
|
||||
@ -521,6 +525,7 @@ public class FSAPI implements ILuaAPI
|
||||
|
||||
return new Object[] { new ILuaObject() {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String[] getMethodNames() {
|
||||
return new String[] {
|
||||
@ -530,7 +535,7 @@ public class FSAPI implements ILuaAPI
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod( ILuaContext context, int method, Object[] args) throws LuaException {
|
||||
public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args) throws LuaException {
|
||||
switch( method )
|
||||
{
|
||||
case 0:
|
||||
@ -572,6 +577,7 @@ public class FSAPI implements ILuaAPI
|
||||
|
||||
return new Object[] { new ILuaObject() {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String[] getMethodNames() {
|
||||
return new String[] {
|
||||
@ -582,7 +588,7 @@ public class FSAPI implements ILuaAPI
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod( ILuaContext context, int method, Object[] args) throws LuaException {
|
||||
public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args) throws LuaException {
|
||||
switch( method )
|
||||
{
|
||||
case 0:
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -10,14 +10,15 @@ import dan200.computercraft.api.lua.ILuaContext;
|
||||
import dan200.computercraft.api.lua.ILuaObject;
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public class HTTPAPI implements ILuaAPI
|
||||
{
|
||||
private IAPIEnvironment m_apiEnvironment;
|
||||
private List<HTTPRequest> m_httpRequests;
|
||||
private final IAPIEnvironment m_apiEnvironment;
|
||||
private final List<HTTPRequest> m_httpRequests;
|
||||
|
||||
public HTTPAPI( IAPIEnvironment environment )
|
||||
{
|
||||
@ -72,6 +73,7 @@ public class HTTPAPI implements ILuaAPI
|
||||
private static ILuaObject wrapBufferedReader( final BufferedReader reader, final int responseCode, final Map<String, String> responseHeaders )
|
||||
{
|
||||
return new ILuaObject() {
|
||||
@Nonnull
|
||||
@Override
|
||||
public String[] getMethodNames()
|
||||
{
|
||||
@ -85,7 +87,7 @@ public class HTTPAPI implements ILuaAPI
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod( ILuaContext context, int method, Object[] args ) throws LuaException
|
||||
public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException
|
||||
{
|
||||
switch( method )
|
||||
{
|
||||
@ -155,15 +157,15 @@ public class HTTPAPI implements ILuaAPI
|
||||
{
|
||||
synchronized( m_httpRequests )
|
||||
{
|
||||
Iterator<HTTPRequest> it = m_httpRequests.iterator();
|
||||
while( it.hasNext() ) {
|
||||
HTTPRequest r = it.next();
|
||||
for( HTTPRequest r : m_httpRequests )
|
||||
{
|
||||
r.cancel();
|
||||
}
|
||||
m_httpRequests.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String[] getMethodNames()
|
||||
{
|
||||
@ -174,7 +176,7 @@ public class HTTPAPI implements ILuaAPI
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod( ILuaContext context, int method, Object[] args ) throws LuaException
|
||||
public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException
|
||||
{
|
||||
switch( method )
|
||||
{
|
||||
@ -199,7 +201,7 @@ public class HTTPAPI implements ILuaAPI
|
||||
Map<String, String> headers = null;
|
||||
if( args.length >= 3 && args[2] instanceof Map )
|
||||
{
|
||||
Map table = (Map)args[2];
|
||||
Map<?, ?> table = (Map<?, ?>)args[2];
|
||||
headers = new HashMap<String, String>( table.size() );
|
||||
for( Object key : table.keySet() )
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -18,12 +18,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
class HTTPRequestException extends Exception {
|
||||
public HTTPRequestException( String s ) {
|
||||
super( s );
|
||||
}
|
||||
}
|
||||
|
||||
public class HTTPRequest
|
||||
{
|
||||
public static URL checkURL( String urlString ) throws HTTPRequestException
|
||||
@ -49,9 +43,8 @@ public class HTTPRequest
|
||||
boolean allowed = false;
|
||||
String whitelistString = ComputerCraft.http_whitelist;
|
||||
String[] allowedURLs = whitelistString.split( ";" );
|
||||
for( int i=0; i<allowedURLs.length; ++i )
|
||||
for( String allowedURL : allowedURLs )
|
||||
{
|
||||
String allowedURL = allowedURLs[i];
|
||||
Pattern allowedURLPattern = Pattern.compile( "^\\Q" + allowedURL.replaceAll( "\\*", "\\\\E.*\\\\Q" ) + "\\E$" );
|
||||
if( allowedURLPattern.matcher( url.getHost() ).matches() )
|
||||
{
|
||||
@ -274,7 +267,7 @@ public class HTTPRequest
|
||||
|
||||
public BufferedReader getContents()
|
||||
{
|
||||
String result = null;
|
||||
String result;
|
||||
synchronized(m_lock) {
|
||||
result = m_result;
|
||||
}
|
||||
@ -285,8 +278,8 @@ public class HTTPRequest
|
||||
return null;
|
||||
}
|
||||
|
||||
private Object m_lock = new Object();
|
||||
private URL m_url;
|
||||
private final Object m_lock = new Object();
|
||||
private final URL m_url;
|
||||
private final String m_urlString;
|
||||
|
||||
private boolean m_complete;
|
||||
|
@ -0,0 +1,11 @@
|
||||
package dan200.computercraft.core.apis;
|
||||
|
||||
public class HTTPRequestException extends Exception
|
||||
{
|
||||
private static final long serialVersionUID = 7591208619422744652L;
|
||||
|
||||
public HTTPRequestException( String s )
|
||||
{
|
||||
super( s );
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -14,32 +14,32 @@ import dan200.computercraft.core.terminal.Terminal;
|
||||
|
||||
public interface IAPIEnvironment
|
||||
{
|
||||
public static interface IPeripheralChangeListener
|
||||
interface IPeripheralChangeListener
|
||||
{
|
||||
public void onPeripheralChanged( int side, IPeripheral newPeripheral );
|
||||
void onPeripheralChanged( int side, IPeripheral newPeripheral );
|
||||
}
|
||||
|
||||
public Computer getComputer();
|
||||
public int getComputerID();
|
||||
public IComputerEnvironment getComputerEnvironment();
|
||||
public Terminal getTerminal();
|
||||
public FileSystem getFileSystem();
|
||||
Computer getComputer();
|
||||
int getComputerID();
|
||||
IComputerEnvironment getComputerEnvironment();
|
||||
Terminal getTerminal();
|
||||
FileSystem getFileSystem();
|
||||
|
||||
public void shutdown();
|
||||
public void reboot();
|
||||
public void queueEvent( String event, Object[] args );
|
||||
void shutdown();
|
||||
void reboot();
|
||||
void queueEvent( String event, Object[] args );
|
||||
|
||||
public void setOutput( int side, int output );
|
||||
public int getOutput( int side );
|
||||
public int getInput( int side );
|
||||
void setOutput( int side, int output );
|
||||
int getOutput( int side );
|
||||
int getInput( int side );
|
||||
|
||||
public void setBundledOutput( int side, int output );
|
||||
public int getBundledOutput( int side );
|
||||
public int getBundledInput( int side );
|
||||
void setBundledOutput( int side, int output );
|
||||
int getBundledOutput( int side );
|
||||
int getBundledInput( int side );
|
||||
|
||||
public void setPeripheralChangeListener( IPeripheralChangeListener listener );
|
||||
public IPeripheral getPeripheral( int side );
|
||||
void setPeripheralChangeListener( IPeripheralChangeListener listener );
|
||||
IPeripheral getPeripheral( int side );
|
||||
|
||||
public String getLabel();
|
||||
public void setLabel( String label );
|
||||
String getLabel();
|
||||
void setLabel( String label );
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -9,9 +9,9 @@ import dan200.computercraft.api.lua.ILuaObject;
|
||||
|
||||
public interface ILuaAPI extends ILuaObject
|
||||
{
|
||||
public String[] getNames();
|
||||
String[] getNames();
|
||||
|
||||
public void startup(); // LT
|
||||
public void advance( double _dt ); // MT
|
||||
public void shutdown(); // LT
|
||||
void startup(); // LT
|
||||
void advance( double _dt ); // MT
|
||||
void shutdown(); // LT
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -10,6 +10,7 @@ import dan200.computercraft.api.lua.ILuaContext;
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
import dan200.computercraft.shared.util.StringUtil;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.*;
|
||||
|
||||
public class OSAPI implements ILuaAPI
|
||||
@ -47,7 +48,7 @@ public class OSAPI implements ILuaAPI
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo( Alarm o )
|
||||
public int compareTo( @Nonnull Alarm o )
|
||||
{
|
||||
double t = (double)m_day * 24.0 + m_time;
|
||||
double ot = (double)m_day * 24.0 + m_time;
|
||||
@ -166,6 +167,7 @@ public class OSAPI implements ILuaAPI
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String[] getMethodNames()
|
||||
{
|
||||
@ -216,7 +218,7 @@ public class OSAPI implements ILuaAPI
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod( ILuaContext context, int method, Object[] args ) throws LuaException
|
||||
public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException
|
||||
{
|
||||
switch( method )
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -18,6 +18,7 @@ import dan200.computercraft.core.computer.ITask;
|
||||
import dan200.computercraft.core.filesystem.FileSystem;
|
||||
import dan200.computercraft.core.filesystem.FileSystemException;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.*;
|
||||
|
||||
public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChangeListener
|
||||
@ -88,9 +89,9 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
|
||||
m_attached = false;
|
||||
|
||||
// Unmount everything the detach function forgot to do
|
||||
Iterator<String> it = m_mounts.iterator();
|
||||
while( it.hasNext() ) {
|
||||
m_fileSystem.unmount( it.next() );
|
||||
for( String m_mount : m_mounts )
|
||||
{
|
||||
m_fileSystem.unmount( m_mount );
|
||||
}
|
||||
m_mounts.clear();
|
||||
}
|
||||
@ -118,13 +119,13 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
|
||||
// IComputerAccess implementation
|
||||
|
||||
@Override
|
||||
public String mount( String desiredLoc, IMount mount )
|
||||
public String mount( @Nonnull String desiredLoc, @Nonnull IMount mount )
|
||||
{
|
||||
return mount( desiredLoc, mount, m_side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized String mount( String desiredLoc, IMount mount, String driveName )
|
||||
public synchronized String mount( @Nonnull String desiredLoc, @Nonnull IMount mount, @Nonnull String driveName )
|
||||
{
|
||||
if( !m_attached )
|
||||
{
|
||||
@ -132,7 +133,7 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
|
||||
}
|
||||
|
||||
// Mount the location
|
||||
String location = null;
|
||||
String location;
|
||||
synchronized( m_fileSystem )
|
||||
{
|
||||
location = findFreeLocation( desiredLoc );
|
||||
@ -153,13 +154,13 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
|
||||
}
|
||||
|
||||
@Override
|
||||
public String mountWritable( String desiredLoc, IWritableMount mount )
|
||||
public String mountWritable( @Nonnull String desiredLoc, @Nonnull IWritableMount mount )
|
||||
{
|
||||
return mountWritable( desiredLoc, mount, m_side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized String mountWritable( String desiredLoc, IWritableMount mount, String driveName )
|
||||
public synchronized String mountWritable( @Nonnull String desiredLoc, @Nonnull IWritableMount mount, @Nonnull String driveName )
|
||||
{
|
||||
if( !m_attached )
|
||||
{
|
||||
@ -167,7 +168,7 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
|
||||
}
|
||||
|
||||
// Mount the location
|
||||
String location = null;
|
||||
String location;
|
||||
synchronized( m_fileSystem )
|
||||
{
|
||||
location = findFreeLocation( desiredLoc );
|
||||
@ -215,7 +216,7 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void queueEvent( final String event, final Object[] arguments )
|
||||
public synchronized void queueEvent( @Nonnull final String event, final Object[] arguments )
|
||||
{
|
||||
if( !m_attached ) {
|
||||
throw new RuntimeException( "You are not attached to this Computer" );
|
||||
@ -223,6 +224,7 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
|
||||
m_environment.queueEvent( event, arguments );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public synchronized String getAttachmentName()
|
||||
{
|
||||
@ -233,9 +235,9 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
|
||||
}
|
||||
}
|
||||
|
||||
private IAPIEnvironment m_environment;
|
||||
private final IAPIEnvironment m_environment;
|
||||
private FileSystem m_fileSystem;
|
||||
private PeripheralWrapper[] m_peripherals;
|
||||
private final PeripheralWrapper[] m_peripherals;
|
||||
private boolean m_running;
|
||||
|
||||
public PeripheralAPI( IAPIEnvironment _environment )
|
||||
@ -372,6 +374,7 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String[] getMethodNames()
|
||||
{
|
||||
@ -384,7 +387,7 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod( ILuaContext context, int method, Object[] args ) throws LuaException, InterruptedException
|
||||
public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException, InterruptedException
|
||||
{
|
||||
switch( method )
|
||||
{
|
||||
@ -467,15 +470,14 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
|
||||
int side = parseSide( args );
|
||||
if( side >= 0 )
|
||||
{
|
||||
PeripheralWrapper p = null;
|
||||
PeripheralWrapper p;
|
||||
synchronized( m_peripherals )
|
||||
{
|
||||
p = m_peripherals[ side ];
|
||||
}
|
||||
if( p != null )
|
||||
{
|
||||
Object[] results = p.call( context, methodName, methodArgs );
|
||||
return results;
|
||||
return p.call( context, methodName, methodArgs );
|
||||
}
|
||||
}
|
||||
throw new LuaException( "No peripheral attached" );
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -10,6 +10,7 @@ import dan200.computercraft.api.lua.ILuaContext;
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
import dan200.computercraft.core.computer.Computer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -45,6 +46,7 @@ public class RedstoneAPI implements ILuaAPI
|
||||
{
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String[] getMethodNames()
|
||||
{
|
||||
@ -67,7 +69,7 @@ public class RedstoneAPI implements ILuaAPI
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod( ILuaContext context, int method, Object[] args ) throws LuaException
|
||||
public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException
|
||||
{
|
||||
switch( method )
|
||||
{
|
||||
@ -89,7 +91,7 @@ public class RedstoneAPI implements ILuaAPI
|
||||
throw new LuaException( "Expected string, boolean" );
|
||||
}
|
||||
int side = parseSide( args );
|
||||
boolean output = ((Boolean)args[1]).booleanValue();
|
||||
boolean output = (Boolean) args[ 1 ];
|
||||
m_environment.setOutput( side, output ? 15 : 0 );
|
||||
return null;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -17,6 +17,8 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TermAPI implements ILuaAPI
|
||||
{
|
||||
private final Terminal m_terminal;
|
||||
@ -51,6 +53,7 @@ public class TermAPI implements ILuaAPI
|
||||
{
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String[] getMethodNames()
|
||||
{
|
||||
@ -117,7 +120,7 @@ public class TermAPI implements ILuaAPI
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod( ILuaContext context, int method, Object[] args ) throws LuaException
|
||||
public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException
|
||||
{
|
||||
switch( method )
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -21,7 +21,6 @@ import dan200.computercraft.core.terminal.Terminal;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class Computer
|
||||
@ -30,7 +29,7 @@ public class Computer
|
||||
"bottom", "top", "back", "front", "right", "left",
|
||||
};
|
||||
|
||||
private static enum State
|
||||
private enum State
|
||||
{
|
||||
Off,
|
||||
Starting,
|
||||
@ -187,26 +186,26 @@ public class Computer
|
||||
private boolean m_blinking;
|
||||
|
||||
private ILuaMachine m_machine;
|
||||
private List<ILuaAPI> m_apis;
|
||||
private APIEnvironment m_apiEnvironment;
|
||||
private final List<ILuaAPI> m_apis;
|
||||
private final APIEnvironment m_apiEnvironment;
|
||||
|
||||
private Terminal m_terminal;
|
||||
private final Terminal m_terminal;
|
||||
private FileSystem m_fileSystem;
|
||||
private IWritableMount m_rootMount;
|
||||
|
||||
private int[] m_internalOutput;
|
||||
private int[] m_internalBundledOutput;
|
||||
private final int[] m_internalOutput;
|
||||
private final int[] m_internalBundledOutput;
|
||||
private boolean m_internalOutputChanged;
|
||||
|
||||
private int[] m_externalOutput;
|
||||
private int[] m_externalBundledOutput;
|
||||
private final int[] m_externalOutput;
|
||||
private final int[] m_externalBundledOutput;
|
||||
private boolean m_externalOutputChanged;
|
||||
|
||||
private int[] m_input;
|
||||
private int[] m_bundledInput;
|
||||
private final int[] m_input;
|
||||
private final int[] m_bundledInput;
|
||||
private boolean m_inputChanged;
|
||||
|
||||
private IPeripheral[] m_peripherals;
|
||||
private final IPeripheral[] m_peripherals;
|
||||
|
||||
public Computer( IComputerEnvironment environment, Terminal terminal, int id )
|
||||
{
|
||||
@ -370,10 +369,8 @@ public class Computer
|
||||
// Advance our APIs
|
||||
synchronized( m_apis )
|
||||
{
|
||||
Iterator<ILuaAPI> it = m_apis.iterator();
|
||||
while( it.hasNext() )
|
||||
for(ILuaAPI api : m_apis)
|
||||
{
|
||||
ILuaAPI api = it.next();
|
||||
api.advance( _dt );
|
||||
}
|
||||
}
|
||||
@ -628,10 +625,8 @@ public class Computer
|
||||
ILuaMachine machine = new LuaJLuaMachine( this );
|
||||
|
||||
// Add the APIs
|
||||
Iterator<ILuaAPI> it = m_apis.iterator();
|
||||
while( it.hasNext() )
|
||||
for(ILuaAPI api : m_apis)
|
||||
{
|
||||
ILuaAPI api = it.next();
|
||||
machine.addAPI( api );
|
||||
api.startup();
|
||||
}
|
||||
@ -794,10 +789,8 @@ public class Computer
|
||||
// Shutdown our APIs
|
||||
synchronized( m_apis )
|
||||
{
|
||||
Iterator<ILuaAPI> it = m_apis.iterator();
|
||||
while( it.hasNext() )
|
||||
for(ILuaAPI api : m_apis)
|
||||
{
|
||||
ILuaAPI api = it.next();
|
||||
api.shutdown();
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -13,14 +13,14 @@ import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
public class ComputerThread
|
||||
{
|
||||
private static Object m_lock;
|
||||
private static final Object m_lock;
|
||||
|
||||
private static Thread m_thread;
|
||||
private static WeakHashMap <Object, LinkedBlockingQueue<ITask>> m_computerTasks;
|
||||
private static ArrayList <LinkedBlockingQueue<ITask>> m_computerTasksActive;
|
||||
private static ArrayList <LinkedBlockingQueue<ITask>> m_computerTasksPending;
|
||||
private static Object m_defaultQueue;
|
||||
private static Object m_monitor;
|
||||
private static final WeakHashMap <Object, LinkedBlockingQueue<ITask>> m_computerTasks;
|
||||
private static final ArrayList <LinkedBlockingQueue<ITask>> m_computerTasksActive;
|
||||
private static final ArrayList <LinkedBlockingQueue<ITask>> m_computerTasksPending;
|
||||
private static final Object m_defaultQueue;
|
||||
private static final Object m_monitor;
|
||||
|
||||
private static boolean m_running;
|
||||
private static boolean m_stopped;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -10,13 +10,13 @@ import dan200.computercraft.api.filesystem.IWritableMount;
|
||||
|
||||
public interface IComputerEnvironment
|
||||
{
|
||||
public int getDay();
|
||||
public double getTimeOfDay();
|
||||
public boolean isColour();
|
||||
public long getComputerSpaceLimit();
|
||||
public String getHostString();
|
||||
int getDay();
|
||||
double getTimeOfDay();
|
||||
boolean isColour();
|
||||
long getComputerSpaceLimit();
|
||||
String getHostString();
|
||||
|
||||
public int assignNewID();
|
||||
public IWritableMount createSaveDirMount( String subPath, long capacity );
|
||||
public IMount createResourceMount( String domain, String subPath );
|
||||
int assignNewID();
|
||||
IWritableMount createSaveDirMount( String subPath, long capacity );
|
||||
IMount createResourceMount( String domain, String subPath );
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -8,6 +8,6 @@ package dan200.computercraft.core.computer;
|
||||
|
||||
public interface ITask
|
||||
{
|
||||
public Computer getOwner();
|
||||
public void execute();
|
||||
Computer getOwner();
|
||||
void execute();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -8,6 +8,7 @@ package dan200.computercraft.core.filesystem;
|
||||
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
@ -27,7 +28,7 @@ public class ComboMount implements IMount
|
||||
// IMount implementation
|
||||
|
||||
@Override
|
||||
public boolean exists( String path ) throws IOException
|
||||
public boolean exists( @Nonnull String path ) throws IOException
|
||||
{
|
||||
for( int i=m_parts.length-1; i>=0; --i )
|
||||
{
|
||||
@ -41,7 +42,7 @@ public class ComboMount implements IMount
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirectory( String path ) throws IOException
|
||||
public boolean isDirectory( @Nonnull String path ) throws IOException
|
||||
{
|
||||
for( int i=m_parts.length-1; i>=0; --i )
|
||||
{
|
||||
@ -55,7 +56,7 @@ public class ComboMount implements IMount
|
||||
}
|
||||
|
||||
@Override
|
||||
public void list( String path, List<String> contents ) throws IOException
|
||||
public void list( @Nonnull String path, @Nonnull List<String> contents ) throws IOException
|
||||
{
|
||||
// Combine the lists from all the mounts
|
||||
List<String> foundFiles = null;
|
||||
@ -83,9 +84,8 @@ public class ComboMount implements IMount
|
||||
{
|
||||
// We found multiple directories, so filter for duplicates
|
||||
Set<String> seen = new HashSet<String>();
|
||||
for( int i=0; i<foundFiles.size(); ++i )
|
||||
for(String file : foundFiles)
|
||||
{
|
||||
String file = foundFiles.get(i);
|
||||
if( seen.add( file ) )
|
||||
{
|
||||
contents.add( file );
|
||||
@ -99,7 +99,7 @@ public class ComboMount implements IMount
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSize( String path ) throws IOException
|
||||
public long getSize( @Nonnull String path ) throws IOException
|
||||
{
|
||||
for( int i=m_parts.length-1; i>=0; --i )
|
||||
{
|
||||
@ -112,8 +112,9 @@ public class ComboMount implements IMount
|
||||
throw new IOException( "No such file" );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public InputStream openForRead( String path ) throws IOException
|
||||
public InputStream openForRead( @Nonnull String path ) throws IOException
|
||||
{
|
||||
for( int i=m_parts.length-1; i>=0; --i )
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -8,6 +8,7 @@ package dan200.computercraft.core.filesystem;
|
||||
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
@ -21,30 +22,31 @@ public class EmptyMount implements IMount
|
||||
// IMount implementation
|
||||
|
||||
@Override
|
||||
public boolean exists( String path ) throws IOException
|
||||
public boolean exists( @Nonnull String path ) throws IOException
|
||||
{
|
||||
return path.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirectory( String path ) throws IOException
|
||||
public boolean isDirectory( @Nonnull String path ) throws IOException
|
||||
{
|
||||
return path.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void list( String path, List<String> contents ) throws IOException
|
||||
public void list( @Nonnull String path, @Nonnull List<String> contents ) throws IOException
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSize( String path ) throws IOException
|
||||
public long getSize( @Nonnull String path ) throws IOException
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public InputStream openForRead( String path ) throws IOException
|
||||
public InputStream openForRead( @Nonnull String path ) throws IOException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -8,6 +8,7 @@ package dan200.computercraft.core.filesystem;
|
||||
|
||||
import dan200.computercraft.api.filesystem.IWritableMount;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.*;
|
||||
import java.util.List;
|
||||
|
||||
@ -39,14 +40,14 @@ public class FileMount implements IWritableMount
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write( byte[] b ) throws IOException
|
||||
public void write( @Nonnull byte[] b ) throws IOException
|
||||
{
|
||||
count( b.length );
|
||||
m_innerStream.write( b );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write( byte[] b, int off, int len ) throws IOException
|
||||
public void write( @Nonnull byte[] b, int off, int len ) throws IOException
|
||||
{
|
||||
count( len );
|
||||
m_innerStream.write( b, off, len );
|
||||
@ -94,7 +95,7 @@ public class FileMount implements IWritableMount
|
||||
// IMount implementation
|
||||
|
||||
@Override
|
||||
public boolean exists( String path ) throws IOException
|
||||
public boolean exists( @Nonnull String path ) throws IOException
|
||||
{
|
||||
if( !created() )
|
||||
{
|
||||
@ -108,7 +109,7 @@ public class FileMount implements IWritableMount
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirectory( String path ) throws IOException
|
||||
public boolean isDirectory( @Nonnull String path ) throws IOException
|
||||
{
|
||||
if( !created() )
|
||||
{
|
||||
@ -122,7 +123,7 @@ public class FileMount implements IWritableMount
|
||||
}
|
||||
|
||||
@Override
|
||||
public void list( String path, List<String> contents ) throws IOException
|
||||
public void list( @Nonnull String path, @Nonnull List<String> contents ) throws IOException
|
||||
{
|
||||
if( !created() )
|
||||
{
|
||||
@ -153,7 +154,7 @@ public class FileMount implements IWritableMount
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSize( String path ) throws IOException
|
||||
public long getSize( @Nonnull String path ) throws IOException
|
||||
{
|
||||
if( !created() )
|
||||
{
|
||||
@ -180,8 +181,9 @@ public class FileMount implements IWritableMount
|
||||
throw new IOException( "No such file" );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public InputStream openForRead( String path ) throws IOException
|
||||
public InputStream openForRead( @Nonnull String path ) throws IOException
|
||||
{
|
||||
if( created() )
|
||||
{
|
||||
@ -197,7 +199,7 @@ public class FileMount implements IWritableMount
|
||||
// IWritableMount implementation
|
||||
|
||||
@Override
|
||||
public void makeDirectory( String path ) throws IOException
|
||||
public void makeDirectory( @Nonnull String path ) throws IOException
|
||||
{
|
||||
create();
|
||||
File file = getRealPath( path );
|
||||
@ -236,7 +238,7 @@ public class FileMount implements IWritableMount
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete( String path ) throws IOException
|
||||
public void delete( @Nonnull String path ) throws IOException
|
||||
{
|
||||
if( path.length() == 0 )
|
||||
{
|
||||
@ -259,9 +261,9 @@ public class FileMount implements IWritableMount
|
||||
if( file.isDirectory() )
|
||||
{
|
||||
String[] children = file.list();
|
||||
for( int i=0; i<children.length; i++ )
|
||||
for( String aChildren : children )
|
||||
{
|
||||
deleteRecursively( new File( file, children[i] ) );
|
||||
deleteRecursively( new File( file, aChildren ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -278,8 +280,9 @@ public class FileMount implements IWritableMount
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public OutputStream openForWrite( String path ) throws IOException
|
||||
public OutputStream openForWrite( @Nonnull String path ) throws IOException
|
||||
{
|
||||
create();
|
||||
File file = getRealPath( path );
|
||||
@ -309,8 +312,9 @@ public class FileMount implements IWritableMount
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public OutputStream openForAppend( String path ) throws IOException
|
||||
public OutputStream openForAppend( @Nonnull String path ) throws IOException
|
||||
{
|
||||
if( created() )
|
||||
{
|
||||
@ -372,9 +376,9 @@ public class FileMount implements IWritableMount
|
||||
{
|
||||
long size = MINIMUM_FILE_SIZE;
|
||||
String[] contents = file.list();
|
||||
for( int i=0; i<contents.length; ++i )
|
||||
for( String content : contents )
|
||||
{
|
||||
size += measureUsedSpace( new File( file, contents[i] ) );
|
||||
size += measureUsedSpace( new File( file, content ) );
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -327,7 +327,7 @@ public class FileSystem
|
||||
throw new NullPointerException();
|
||||
}
|
||||
location = sanitizePath( location );
|
||||
if( location.indexOf( ".." ) != -1 ) {
|
||||
if( location.contains( ".." ) ) {
|
||||
throw new FileSystemException( "Cannot mount below the root" );
|
||||
}
|
||||
mount( new MountWrapper( label, location, mount ) );
|
||||
@ -427,10 +427,10 @@ public class FileSystem
|
||||
mount.list( path, list );
|
||||
|
||||
// Add any mounts that are mounted at this location
|
||||
Iterator<MountWrapper> it = m_mounts.values().iterator();
|
||||
while( it.hasNext() ) {
|
||||
MountWrapper otherMount = it.next();
|
||||
if( getDirectory( otherMount.getLocation() ).equals( path ) ) {
|
||||
for( MountWrapper otherMount : m_mounts.values() )
|
||||
{
|
||||
if( getDirectory( otherMount.getLocation() ).equals( path ) )
|
||||
{
|
||||
list.add( getName( otherMount.getLocation() ) );
|
||||
}
|
||||
}
|
||||
@ -445,9 +445,8 @@ public class FileSystem
|
||||
private void findIn( String dir, List<String> matches, Pattern wildPattern ) throws FileSystemException
|
||||
{
|
||||
String[] list = list( dir );
|
||||
for( int i=0; i<list.length; ++i )
|
||||
for( String entry : list )
|
||||
{
|
||||
String entry = list[i];
|
||||
String entryPath = dir.isEmpty() ? entry : (dir + "/" + entry);
|
||||
if( wildPattern.matcher( entryPath ).matches() )
|
||||
{
|
||||
@ -910,7 +909,7 @@ public class FileSystem
|
||||
char c = path.charAt(i);
|
||||
if( c >= 32 && Arrays.binarySearch( specialChars, c ) < 0 && (allowWildcards || c != '*') )
|
||||
{
|
||||
cleanName.append((char)c);
|
||||
cleanName.append( c );
|
||||
}
|
||||
}
|
||||
path = cleanName.toString();
|
||||
@ -918,30 +917,42 @@ public class FileSystem
|
||||
// Collapse the string into its component parts, removing ..'s
|
||||
String[] parts = path.split("/");
|
||||
Stack<String> outputParts = new Stack<String>();
|
||||
for( int n=0; n<parts.length; ++n ) {
|
||||
String part = parts[n];
|
||||
if( part.length() == 0 || part.equals(".") )
|
||||
for( String part : parts )
|
||||
{
|
||||
if( part.length() == 0 || part.equals( "." ) )
|
||||
{
|
||||
// . is redundant
|
||||
continue;
|
||||
} else if( part.equals("..") || part.equals( "..." ) ) {
|
||||
}
|
||||
else if( part.equals( ".." ) || part.equals( "..." ) )
|
||||
{
|
||||
// .. or ... can cancel out the last folder entered
|
||||
if( !outputParts.empty() ) {
|
||||
if( !outputParts.empty() )
|
||||
{
|
||||
String top = outputParts.peek();
|
||||
if( !top.equals("..") ) {
|
||||
if( !top.equals( ".." ) )
|
||||
{
|
||||
outputParts.pop();
|
||||
} else {
|
||||
outputParts.push("..");
|
||||
}
|
||||
} else {
|
||||
outputParts.push("..");
|
||||
else
|
||||
{
|
||||
outputParts.push( ".." );
|
||||
}
|
||||
}
|
||||
} else if (part.length() >= 255) {
|
||||
else
|
||||
{
|
||||
outputParts.push( ".." );
|
||||
}
|
||||
}
|
||||
else if( part.length() >= 255 )
|
||||
{
|
||||
// If part length > 255 and it is the last part
|
||||
outputParts.push( part.substring(0, 255) );
|
||||
} else {
|
||||
outputParts.push( part.substring( 0, 255 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Anything else we add to the stack
|
||||
outputParts.push(part);
|
||||
outputParts.push( part );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -7,6 +7,8 @@
|
||||
package dan200.computercraft.core.filesystem;
|
||||
|
||||
public class FileSystemException extends Exception {
|
||||
private static final long serialVersionUID = -2500631644868104029L;
|
||||
|
||||
FileSystemException( String s ) {
|
||||
super( s );
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -9,5 +9,5 @@ package dan200.computercraft.core.filesystem;
|
||||
import java.io.IOException;
|
||||
|
||||
public interface IMountedFile {
|
||||
public void close() throws IOException;
|
||||
void close() throws IOException;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -9,8 +9,8 @@ package dan200.computercraft.core.filesystem;
|
||||
import java.io.IOException;
|
||||
|
||||
public interface IMountedFileBinary extends IMountedFile {
|
||||
public int read() throws IOException;
|
||||
public void write(int i) throws IOException;
|
||||
public void close() throws IOException;
|
||||
public void flush() throws IOException;
|
||||
int read() throws IOException;
|
||||
void write( int i ) throws IOException;
|
||||
void close() throws IOException;
|
||||
void flush() throws IOException;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -9,8 +9,8 @@ package dan200.computercraft.core.filesystem;
|
||||
import java.io.IOException;
|
||||
|
||||
public interface IMountedFileNormal extends IMountedFile {
|
||||
public String readLine() throws IOException;
|
||||
public void write(String s, int off, int len, boolean newLine) throws IOException;
|
||||
public void close() throws IOException;
|
||||
public void flush() throws IOException;
|
||||
String readLine() throws IOException;
|
||||
void write( String s, int off, int len, boolean newLine ) throws IOException;
|
||||
void close() throws IOException;
|
||||
void flush() throws IOException;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -8,6 +8,7 @@ package dan200.computercraft.core.filesystem;
|
||||
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
@ -53,10 +54,7 @@ public class JarMount implements IMount
|
||||
|
||||
public void list( List<String> contents )
|
||||
{
|
||||
for( String child : m_children.keySet() )
|
||||
{
|
||||
contents.add( child );
|
||||
}
|
||||
contents.addAll( m_children.keySet() );
|
||||
}
|
||||
|
||||
public void insertChild( FileInZip child )
|
||||
@ -178,14 +176,14 @@ public class JarMount implements IMount
|
||||
// IMount implementation
|
||||
|
||||
@Override
|
||||
public boolean exists( String path ) throws IOException
|
||||
public boolean exists( @Nonnull String path ) throws IOException
|
||||
{
|
||||
FileInZip file = m_root.getFile( path );
|
||||
return file != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirectory( String path ) throws IOException
|
||||
public boolean isDirectory( @Nonnull String path ) throws IOException
|
||||
{
|
||||
FileInZip file = m_root.getFile( path );
|
||||
if( file != null )
|
||||
@ -196,7 +194,7 @@ public class JarMount implements IMount
|
||||
}
|
||||
|
||||
@Override
|
||||
public void list( String path, List<String> contents ) throws IOException
|
||||
public void list( @Nonnull String path, @Nonnull List<String> contents ) throws IOException
|
||||
{
|
||||
FileInZip file = m_root.getFile( path );
|
||||
if( file != null && file.isDirectory() )
|
||||
@ -210,7 +208,7 @@ public class JarMount implements IMount
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSize( String path ) throws IOException
|
||||
public long getSize( @Nonnull String path ) throws IOException
|
||||
{
|
||||
FileInZip file = m_root.getFile( path );
|
||||
if( file != null )
|
||||
@ -220,8 +218,9 @@ public class JarMount implements IMount
|
||||
throw new IOException( "No such file" );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public InputStream openForRead( String path ) throws IOException
|
||||
public InputStream openForRead( @Nonnull String path ) throws IOException
|
||||
{
|
||||
FileInZip file = m_root.getFile( path );
|
||||
if( file != null && !file.isDirectory() )
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -8,6 +8,7 @@ package dan200.computercraft.core.filesystem;
|
||||
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
@ -26,31 +27,32 @@ public class SubMount implements IMount
|
||||
// IMount implementation
|
||||
|
||||
@Override
|
||||
public boolean exists( String path ) throws IOException
|
||||
public boolean exists( @Nonnull String path ) throws IOException
|
||||
{
|
||||
return m_parent.exists( getFullPath( path ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirectory( String path ) throws IOException
|
||||
public boolean isDirectory( @Nonnull String path ) throws IOException
|
||||
{
|
||||
return m_parent.isDirectory( getFullPath( path ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void list( String path, List<String> contents ) throws IOException
|
||||
public void list( @Nonnull String path, @Nonnull List<String> contents ) throws IOException
|
||||
{
|
||||
m_parent.list( getFullPath( path ), contents );
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSize( String path ) throws IOException
|
||||
public long getSize( @Nonnull String path ) throws IOException
|
||||
{
|
||||
return m_parent.getSize( getFullPath( path ) );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public InputStream openForRead( String path ) throws IOException
|
||||
public InputStream openForRead( @Nonnull String path ) throws IOException
|
||||
{
|
||||
return m_parent.openForRead( getFullPath( path ) );
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -12,17 +12,17 @@ import java.io.OutputStream;
|
||||
|
||||
public interface ILuaMachine
|
||||
{
|
||||
public void addAPI( ILuaAPI api );
|
||||
void addAPI( ILuaAPI api );
|
||||
|
||||
public void loadBios( InputStream bios );
|
||||
public void handleEvent( String eventName, Object[] arguments );
|
||||
public void softAbort( String abortMessage );
|
||||
public void hardAbort( String abortMessage );
|
||||
void loadBios( InputStream bios );
|
||||
void handleEvent( String eventName, Object[] arguments );
|
||||
void softAbort( String abortMessage );
|
||||
void hardAbort( String abortMessage );
|
||||
|
||||
public boolean saveState( OutputStream output );
|
||||
public boolean restoreState( InputStream input );
|
||||
boolean saveState( OutputStream output );
|
||||
boolean restoreState( InputStream input );
|
||||
|
||||
public boolean isFinished();
|
||||
boolean isFinished();
|
||||
|
||||
public void unload();
|
||||
void unload();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -21,10 +21,10 @@ import org.luaj.vm2.lib.VarArgFunction;
|
||||
import org.luaj.vm2.lib.ZeroArgFunction;
|
||||
import org.luaj.vm2.lib.jse.JsePlatform;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
public class LuaJLuaMachine implements ILuaMachine
|
||||
@ -128,9 +128,9 @@ public class LuaJLuaMachine implements ILuaMachine
|
||||
// Add the methods of an API to the global table
|
||||
LuaTable table = wrapLuaObject( api );
|
||||
String[] names = api.getNames();
|
||||
for( int i=0; i<names.length; ++i )
|
||||
for( String name : names )
|
||||
{
|
||||
m_globals.set( names[i], table );
|
||||
m_globals.set( name, table );
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ public class LuaJLuaMachine implements ILuaMachine
|
||||
try
|
||||
{
|
||||
// Read the whole bios into a string
|
||||
String biosText = null;
|
||||
String biosText;
|
||||
try
|
||||
{
|
||||
InputStreamReader isr;
|
||||
@ -316,8 +316,6 @@ public class LuaJLuaMachine implements ILuaMachine
|
||||
throw new LuaError( abortMessage );
|
||||
}
|
||||
}
|
||||
|
||||
private static long s_nextUnusedTaskID = 0;
|
||||
|
||||
private LuaTable wrapLuaObject( ILuaObject object )
|
||||
{
|
||||
@ -335,10 +333,11 @@ public class LuaJLuaMachine implements ILuaMachine
|
||||
{
|
||||
tryAbort();
|
||||
Object[] arguments = toObjects( _args, 1 );
|
||||
Object[] results = null;
|
||||
Object[] results;
|
||||
try
|
||||
{
|
||||
results = apiObject.callMethod( new ILuaContext() {
|
||||
@Nonnull
|
||||
@Override
|
||||
public Object[] pullEvent( String filter ) throws LuaException, InterruptedException
|
||||
{
|
||||
@ -350,12 +349,14 @@ public class LuaJLuaMachine implements ILuaMachine
|
||||
return results;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Object[] pullEventRaw( String filter ) throws InterruptedException
|
||||
{
|
||||
return yield( new Object[] { filter } );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Object[] yield( Object[] yieldArgs ) throws InterruptedException
|
||||
{
|
||||
@ -372,7 +373,7 @@ public class LuaJLuaMachine implements ILuaMachine
|
||||
}
|
||||
|
||||
@Override
|
||||
public long issueMainThreadTask( final ILuaTask task ) throws LuaException
|
||||
public long issueMainThreadTask( @Nonnull final ILuaTask task ) throws LuaException
|
||||
{
|
||||
// Issue command
|
||||
final long taskID = MainThread.getUniqueTaskID();
|
||||
@ -395,10 +396,7 @@ public class LuaJLuaMachine implements ILuaMachine
|
||||
Object[] eventArguments = new Object[ results.length + 2 ];
|
||||
eventArguments[ 0 ] = taskID;
|
||||
eventArguments[ 1 ] = true;
|
||||
for( int i = 0; i < results.length; ++i )
|
||||
{
|
||||
eventArguments[ i + 2 ] = results[ i ];
|
||||
}
|
||||
System.arraycopy( results, 0, eventArguments, 2, results.length );
|
||||
m_computer.queueEvent( "task_complete", eventArguments );
|
||||
}
|
||||
else
|
||||
@ -431,7 +429,7 @@ public class LuaJLuaMachine implements ILuaMachine
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] executeMainThreadTask( final ILuaTask task ) throws LuaException, InterruptedException
|
||||
public Object[] executeMainThreadTask( @Nonnull final ILuaTask task ) throws LuaException, InterruptedException
|
||||
{
|
||||
// Issue task
|
||||
final long taskID = issueMainThreadTask( task );
|
||||
@ -448,10 +446,7 @@ public class LuaJLuaMachine implements ILuaMachine
|
||||
if( (Boolean)response[ 2 ] )
|
||||
{
|
||||
// Extract the return values from the event and return them
|
||||
for( int i = 0; i < returnValues.length; ++i )
|
||||
{
|
||||
returnValues[ i ] = response[ i + 3 ];
|
||||
}
|
||||
System.arraycopy( response, 3, returnValues, 0, returnValues.length );
|
||||
return returnValues;
|
||||
}
|
||||
else
|
||||
@ -506,7 +501,7 @@ public class LuaJLuaMachine implements ILuaMachine
|
||||
}
|
||||
else if( object instanceof Boolean )
|
||||
{
|
||||
boolean b = ((Boolean)object).booleanValue();
|
||||
boolean b = (Boolean) object;
|
||||
return LuaValue.valueOf( b );
|
||||
}
|
||||
else if( object instanceof String )
|
||||
@ -534,10 +529,8 @@ public class LuaJLuaMachine implements ILuaMachine
|
||||
m_valuesInProgress.put( object, table );
|
||||
|
||||
// Convert all keys
|
||||
Iterator it = ((Map)object).entrySet().iterator();
|
||||
while( it.hasNext() )
|
||||
for( Map.Entry<?, ?> pair : ((Map<?, ?>) object).entrySet() )
|
||||
{
|
||||
Map.Entry pair = (Map.Entry)it.next();
|
||||
LuaValue key = toValue( pair.getKey() );
|
||||
LuaValue value = toValue( pair.getValue() );
|
||||
if( !key.isnil() && !value.isnil() )
|
||||
@ -558,8 +551,7 @@ public class LuaJLuaMachine implements ILuaMachine
|
||||
}
|
||||
else if( object instanceof ILuaObject )
|
||||
{
|
||||
LuaValue table = wrapLuaObject( (ILuaObject)object );
|
||||
return table;
|
||||
return wrapLuaObject( (ILuaObject)object );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -627,7 +619,7 @@ public class LuaJLuaMachine implements ILuaMachine
|
||||
{
|
||||
return m_objectsInProgress.get( value );
|
||||
}
|
||||
Map table = new HashMap();
|
||||
Map<Object, Object> table = new HashMap<Object, Object>();
|
||||
m_objectsInProgress.put( value, table );
|
||||
|
||||
// Convert all keys
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -6,7 +6,6 @@
|
||||
|
||||
package dan200.computercraft.server.proxy;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.computer.blocks.TileComputer;
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.TileDiskDrive;
|
||||
import dan200.computercraft.shared.peripheral.printer.TilePrinter;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -10,7 +10,6 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@ -25,8 +24,8 @@ import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class BlockGeneric extends Block implements
|
||||
@ -43,12 +42,13 @@ public abstract class BlockGeneric extends Block implements
|
||||
protected abstract TileGeneric createTile( int damage );
|
||||
|
||||
@Override
|
||||
public final void dropBlockAsItemWithChance( World world, BlockPos pos, IBlockState state, float chance, int fortune )
|
||||
public final void dropBlockAsItemWithChance( World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, float chance, int fortune )
|
||||
{
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final List<ItemStack> getDrops( IBlockAccess world, BlockPos pos, IBlockState state, int fortune )
|
||||
public final List<ItemStack> getDrops( IBlockAccess world, BlockPos pos, @Nonnull IBlockState state, int fortune )
|
||||
{
|
||||
ArrayList<ItemStack> drops = new ArrayList<ItemStack>( 1 );
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
@ -60,6 +60,7 @@ public abstract class BlockGeneric extends Block implements
|
||||
return drops;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final IBlockState onBlockPlaced( World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, int damage, EntityLivingBase placer )
|
||||
{
|
||||
@ -67,7 +68,7 @@ public abstract class BlockGeneric extends Block implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean removedByPlayer( IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest )
|
||||
public final boolean removedByPlayer( @Nonnull IBlockState state, World world, @Nonnull BlockPos pos, @Nonnull EntityPlayer player, boolean willHarvest )
|
||||
{
|
||||
if( !world.isRemote )
|
||||
{
|
||||
@ -94,10 +95,8 @@ public abstract class BlockGeneric extends Block implements
|
||||
// Drop items
|
||||
if( drops.size() > 0 )
|
||||
{
|
||||
Iterator<ItemStack> it = drops.iterator();
|
||||
while( it.hasNext() )
|
||||
for (ItemStack item : drops)
|
||||
{
|
||||
ItemStack item = it.next();
|
||||
dropItem( world, pos, item );
|
||||
}
|
||||
}
|
||||
@ -109,7 +108,7 @@ public abstract class BlockGeneric extends Block implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void breakBlock( World world, BlockPos pos, IBlockState newState )
|
||||
public final void breakBlock( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState newState )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileGeneric )
|
||||
@ -121,8 +120,9 @@ public abstract class BlockGeneric extends Block implements
|
||||
world.removeTileEntity( pos );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final ItemStack getPickBlock( IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player )
|
||||
public final ItemStack getPickBlock( @Nonnull IBlockState state, RayTraceResult target, @Nonnull World world, @Nonnull BlockPos pos, EntityPlayer player )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileGeneric )
|
||||
@ -134,7 +134,7 @@ public abstract class BlockGeneric extends Block implements
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final ItemStack createStackedBlock( IBlockState state )
|
||||
protected final ItemStack createStackedBlock( @Nonnull IBlockState state )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@ -152,6 +152,7 @@ public abstract class BlockGeneric extends Block implements
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final void neighborChanged( IBlockState state, World world, BlockPos pos, Block block )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
@ -174,7 +175,7 @@ public abstract class BlockGeneric extends Block implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isSideSolid( IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side )
|
||||
public final boolean isSideSolid( IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, EnumFacing side )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileGeneric )
|
||||
@ -192,7 +193,7 @@ public abstract class BlockGeneric extends Block implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExplosionResistance( World world, BlockPos pos, Entity exploder, Explosion explosion )
|
||||
public float getExplosionResistance( World world, BlockPos pos, @Nonnull Entity exploder, Explosion explosion )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileGeneric && tile.hasWorldObj() )
|
||||
@ -206,7 +207,9 @@ public abstract class BlockGeneric extends Block implements
|
||||
return super.getExplosionResistance( exploder );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public final AxisAlignedBB getBoundingBox( IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
@ -218,14 +221,17 @@ public abstract class BlockGeneric extends Block implements
|
||||
return FULL_BLOCK_AABB;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public AxisAlignedBB getSelectedBoundingBox( IBlockState state, World worldIn, BlockPos pos )
|
||||
@Deprecated
|
||||
public final AxisAlignedBB getSelectedBoundingBox( IBlockState state, @Nonnull World world, @Nonnull BlockPos pos )
|
||||
{
|
||||
return getBoundingBox( state, worldIn, pos ).offset( pos );
|
||||
return getBoundingBox( state, world, pos ).offset( pos );
|
||||
}
|
||||
|
||||
@Override
|
||||
public final AxisAlignedBB getCollisionBoundingBox( IBlockState state, World world, BlockPos pos )
|
||||
@Deprecated
|
||||
public final AxisAlignedBB getCollisionBoundingBox( IBlockState state, @Nonnull World world, @Nonnull BlockPos pos )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileGeneric && tile.hasWorldObj() )
|
||||
@ -252,7 +258,8 @@ public abstract class BlockGeneric extends Block implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void addCollisionBoxToList( IBlockState state, World world, BlockPos pos, AxisAlignedBB bigBox, List<AxisAlignedBB> list, Entity entity )
|
||||
@Deprecated
|
||||
public final void addCollisionBoxToList( IBlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull AxisAlignedBB bigBox, @Nonnull List<AxisAlignedBB> list, Entity entity )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileGeneric && tile.hasWorldObj() )
|
||||
@ -266,10 +273,8 @@ public abstract class BlockGeneric extends Block implements
|
||||
// Add collision bounds to list
|
||||
if( collision.size() > 0 )
|
||||
{
|
||||
Iterator<AxisAlignedBB> it = collision.iterator();
|
||||
while( it.hasNext() )
|
||||
for (AxisAlignedBB localBounds : collision)
|
||||
{
|
||||
AxisAlignedBB localBounds = it.next();
|
||||
addCollisionBoxToList( pos, bigBox, list, localBounds );
|
||||
}
|
||||
}
|
||||
@ -277,6 +282,7 @@ public abstract class BlockGeneric extends Block implements
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final boolean canProvidePower( IBlockState state )
|
||||
{
|
||||
return true;
|
||||
@ -295,6 +301,7 @@ public abstract class BlockGeneric extends Block implements
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final int getStrongPower( IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing oppositeSide )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
@ -307,6 +314,7 @@ public abstract class BlockGeneric extends Block implements
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final int getWeakPower( IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing oppositeSide )
|
||||
{
|
||||
return getStrongPower( state, world, pos, oppositeSide );
|
||||
@ -335,6 +343,7 @@ public abstract class BlockGeneric extends Block implements
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean eventReceived( IBlockState state, World world, BlockPos pos, int eventID, int eventParameter )
|
||||
{
|
||||
if( world.isRemote )
|
||||
@ -349,14 +358,16 @@ public abstract class BlockGeneric extends Block implements
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final TileEntity createTileEntity( World world, IBlockState state )
|
||||
public final TileEntity createTileEntity( @Nonnull World world, @Nonnull IBlockState state )
|
||||
{
|
||||
return createTile( state );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final TileEntity createNewTileEntity( World world, int damage )
|
||||
public final TileEntity createNewTileEntity( @Nonnull World world, int damage )
|
||||
{
|
||||
return createTile( damage );
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -12,6 +12,8 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class DefaultBundledRedstoneProvider implements IBundledRedstoneProvider
|
||||
{
|
||||
public DefaultBundledRedstoneProvider()
|
||||
@ -19,7 +21,7 @@ public class DefaultBundledRedstoneProvider implements IBundledRedstoneProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBundledRedstoneOutput( World world, BlockPos pos, EnumFacing side )
|
||||
public int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side )
|
||||
{
|
||||
return getDefaultBundledRedstoneOutput( world, pos, side );
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -10,6 +10,6 @@ import net.minecraft.util.EnumFacing;
|
||||
|
||||
public interface IDirectionalTile
|
||||
{
|
||||
public EnumFacing getDirection();
|
||||
public void setDirection( EnumFacing dir );
|
||||
EnumFacing getDirection();
|
||||
void setDirection( EnumFacing dir );
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -10,6 +10,6 @@ import dan200.computercraft.core.terminal.Terminal;
|
||||
|
||||
public interface ITerminal
|
||||
{
|
||||
public Terminal getTerminal();
|
||||
public boolean isColour();
|
||||
Terminal getTerminal();
|
||||
boolean isColour();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -8,5 +8,5 @@ package dan200.computercraft.shared.common;
|
||||
|
||||
public interface ITerminalTile
|
||||
{
|
||||
public ITerminal getTerminal();
|
||||
ITerminal getTerminal();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -15,7 +15,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
@ -23,6 +22,8 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class TileGeneric extends TileEntity
|
||||
@ -48,6 +49,7 @@ public abstract class TileGeneric extends TileEntity
|
||||
{
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BlockGeneric getBlock()
|
||||
{
|
||||
Block block = worldObj.getBlockState( getPos() ).getBlock();
|
||||
@ -77,7 +79,7 @@ public abstract class TileGeneric extends TileEntity
|
||||
worldObj.setBlockState( getPos(), newState, 3 );
|
||||
}
|
||||
|
||||
public void getDroppedItems( List<ItemStack> drops, boolean creative )
|
||||
public void getDroppedItems( @Nonnull List<ItemStack> drops, boolean creative )
|
||||
{
|
||||
}
|
||||
|
||||
@ -95,7 +97,7 @@ public abstract class TileGeneric extends TileEntity
|
||||
{
|
||||
}
|
||||
|
||||
public void onNeighbourTileEntityChange( BlockPos neighbour )
|
||||
public void onNeighbourTileEntityChange( @Nonnull BlockPos neighbour )
|
||||
{
|
||||
}
|
||||
|
||||
@ -109,12 +111,13 @@ public abstract class TileGeneric extends TileEntity
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public AxisAlignedBB getBounds()
|
||||
{
|
||||
return new AxisAlignedBB( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 );
|
||||
}
|
||||
|
||||
public void getCollisionBounds( List<AxisAlignedBB> bounds )
|
||||
public void getCollisionBounds( @Nonnull List<AxisAlignedBB> bounds )
|
||||
{
|
||||
bounds.add( getBounds() );
|
||||
}
|
||||
@ -129,12 +132,12 @@ public abstract class TileGeneric extends TileEntity
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean getBundledRedstoneConnectivity( EnumFacing side )
|
||||
public boolean getBundledRedstoneConnectivity( @Nonnull EnumFacing side )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getBundledRedstoneOutput( EnumFacing side )
|
||||
public int getBundledRedstoneOutput( @Nonnull EnumFacing side )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -163,11 +166,11 @@ public abstract class TileGeneric extends TileEntity
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void writeDescription( NBTTagCompound nbttagcompound )
|
||||
protected void writeDescription( @Nonnull NBTTagCompound nbttagcompound )
|
||||
{
|
||||
}
|
||||
|
||||
protected void readDescription( NBTTagCompound nbttagcompound )
|
||||
protected void readDescription( @Nonnull NBTTagCompound nbttagcompound )
|
||||
{
|
||||
}
|
||||
|
||||
@ -186,7 +189,7 @@ public abstract class TileGeneric extends TileEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRefresh( World world, BlockPos pos, IBlockState oldState, IBlockState newState )
|
||||
public boolean shouldRefresh( World world, BlockPos pos, @Nonnull IBlockState oldState, @Nonnull IBlockState newState )
|
||||
{
|
||||
return newState.getBlock() != oldState.getBlock();
|
||||
}
|
||||
@ -215,6 +218,7 @@ public abstract class TileGeneric extends TileEntity
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound getUpdateTag ()
|
||||
{
|
||||
@ -224,7 +228,7 @@ public abstract class TileGeneric extends TileEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleUpdateTag (NBTTagCompound tag)
|
||||
public void handleUpdateTag ( @Nonnull NBTTagCompound tag)
|
||||
{
|
||||
super.handleUpdateTag(tag);
|
||||
readDescription( tag );
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -21,9 +21,9 @@ import net.minecraft.command.ICommandManager;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -61,6 +61,7 @@ public class CommandAPI implements ILuaAPI
|
||||
{
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String[] getMethodNames()
|
||||
{
|
||||
@ -111,7 +112,7 @@ public class CommandAPI implements ILuaAPI
|
||||
// Get the details of the block
|
||||
IBlockState state = world.getBlockState( pos );
|
||||
Block block = state.getBlock();
|
||||
String name = ((ResourceLocation)Block.REGISTRY.getNameForObject( block )).toString();
|
||||
String name = Block.REGISTRY.getNameForObject( block ).toString();
|
||||
int metadata = block.getMetaFromState( state );
|
||||
|
||||
Map<Object, Object> table = new HashMap<Object, Object>();
|
||||
@ -119,9 +120,8 @@ public class CommandAPI implements ILuaAPI
|
||||
table.put( "metadata", metadata );
|
||||
|
||||
Map<Object, Object> stateTable = new HashMap<Object, Object>();
|
||||
for( Object o : state.getActualState( world, pos ).getProperties().entrySet() )
|
||||
for( ImmutableMap.Entry<IProperty<?>, Comparable<?>> entry : state.getActualState( world, pos ).getProperties().entrySet() )
|
||||
{
|
||||
ImmutableMap.Entry<IProperty, Object> entry = (ImmutableMap.Entry<IProperty, Object>)o;
|
||||
String propertyName = entry.getKey().getName();
|
||||
Object value = entry.getValue();
|
||||
if( value instanceof String || value instanceof Number || value instanceof Boolean )
|
||||
@ -139,7 +139,7 @@ public class CommandAPI implements ILuaAPI
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod( ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException
|
||||
public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] arguments ) throws LuaException, InterruptedException
|
||||
{
|
||||
switch( method )
|
||||
{
|
||||
@ -193,12 +193,11 @@ public class CommandAPI implements ILuaAPI
|
||||
{
|
||||
ICommandManager commandManager = server.getCommandManager();
|
||||
ICommandSender commmandSender = m_computer.getCommandSender();
|
||||
Map commands = commandManager.getCommands();
|
||||
for( Object entryObject : commands.entrySet() )
|
||||
Map<String, ICommand> commands = commandManager.getCommands();
|
||||
for( Map.Entry<String, ICommand> entry : commands.entrySet() )
|
||||
{
|
||||
Map.Entry entry = (Map.Entry)entryObject;
|
||||
String name = (String)entry.getKey();
|
||||
ICommand command = (ICommand)entry.getValue();
|
||||
String name = entry.getKey();
|
||||
ICommand command = entry.getValue();
|
||||
try
|
||||
{
|
||||
if( command.checkPermission( server, commmandSender ) )
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -9,10 +9,8 @@ package dan200.computercraft.shared.computer.blocks;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.IComputer;
|
||||
import dan200.computercraft.shared.peripheral.common.TilePeripheralBase;
|
||||
import dan200.computercraft.shared.util.DirectionUtil;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
@ -25,6 +23,8 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class BlockCommandComputer extends BlockComputerBase
|
||||
{
|
||||
// Statics
|
||||
@ -32,7 +32,7 @@ public class BlockCommandComputer extends BlockComputerBase
|
||||
public static class Properties
|
||||
{
|
||||
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
|
||||
public static final PropertyEnum<ComputerState> STATE = PropertyEnum.<ComputerState>create("state", ComputerState.class);
|
||||
public static final PropertyEnum<ComputerState> STATE = PropertyEnum.create("state", ComputerState.class);
|
||||
}
|
||||
|
||||
// Members
|
||||
@ -50,16 +50,16 @@ public class BlockCommandComputer extends BlockComputerBase
|
||||
);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new BlockStateContainer(this, new IProperty[] {
|
||||
Properties.FACING,
|
||||
Properties.STATE
|
||||
});
|
||||
return new BlockStateContainer(this, Properties.FACING, Properties.STATE );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public IBlockState getStateFromMeta( int meta )
|
||||
{
|
||||
EnumFacing dir = EnumFacing.getFront( meta & 0x7 );
|
||||
@ -73,11 +73,13 @@ public class BlockCommandComputer extends BlockComputerBase
|
||||
@Override
|
||||
public int getMetaFromState( IBlockState state )
|
||||
{
|
||||
return ((EnumFacing)state.getValue( Properties.FACING )).getIndex();
|
||||
return state.getValue( Properties.FACING ).getIndex();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
@Deprecated
|
||||
public IBlockState getActualState( @Nonnull IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof IComputerTile )
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -12,7 +12,6 @@ import dan200.computercraft.shared.computer.core.IComputer;
|
||||
import dan200.computercraft.shared.computer.items.ItemComputer;
|
||||
import dan200.computercraft.shared.util.DirectionUtil;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
@ -22,11 +21,13 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class BlockComputer extends BlockComputerBase
|
||||
{
|
||||
// Statics
|
||||
@ -34,7 +35,7 @@ public class BlockComputer extends BlockComputerBase
|
||||
{
|
||||
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
|
||||
public static final PropertyBool ADVANCED = PropertyBool.create("advanced");
|
||||
public static final PropertyEnum<ComputerState> STATE = PropertyEnum.<ComputerState>create("state", ComputerState.class);
|
||||
public static final PropertyEnum<ComputerState> STATE = PropertyEnum.create("state", ComputerState.class);
|
||||
}
|
||||
|
||||
// Members
|
||||
@ -52,17 +53,16 @@ public class BlockComputer extends BlockComputerBase
|
||||
);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new BlockStateContainer(this, new IProperty[] {
|
||||
Properties.FACING,
|
||||
Properties.ADVANCED,
|
||||
Properties.STATE
|
||||
});
|
||||
return new BlockStateContainer( this, Properties.FACING, Properties.ADVANCED, Properties.STATE );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public IBlockState getStateFromMeta( int meta )
|
||||
{
|
||||
EnumFacing dir = EnumFacing.getFront( meta & 0x7 );
|
||||
@ -86,8 +86,8 @@ public class BlockComputer extends BlockComputerBase
|
||||
@Override
|
||||
public int getMetaFromState( IBlockState state )
|
||||
{
|
||||
int meta = ((EnumFacing)state.getValue( Properties.FACING )).getIndex();
|
||||
if( (Boolean)state.getValue( Properties.ADVANCED ) )
|
||||
int meta = state.getValue( Properties.FACING ).getIndex();
|
||||
if( state.getValue( Properties.ADVANCED ) )
|
||||
{
|
||||
meta += 8;
|
||||
}
|
||||
@ -117,8 +117,10 @@ public class BlockComputer extends BlockComputerBase
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
@Deprecated
|
||||
public IBlockState getActualState( @Nonnull IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof IComputerTile )
|
||||
@ -148,7 +150,7 @@ public class BlockComputer extends BlockComputerBase
|
||||
@Override
|
||||
public ComputerFamily getFamily( IBlockState state )
|
||||
{
|
||||
if( (Boolean)state.getValue( Properties.ADVANCED ) ) {
|
||||
if( state.getValue( Properties.ADVANCED ) ) {
|
||||
return ComputerFamily.Advanced;
|
||||
} else {
|
||||
return ComputerFamily.Normal;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -12,6 +12,8 @@ import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ComputerPeripheral
|
||||
implements IPeripheral
|
||||
{
|
||||
@ -26,12 +28,14 @@ public class ComputerPeripheral
|
||||
|
||||
// IPeripheral implementation
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String[] getMethodNames()
|
||||
{
|
||||
@ -45,7 +49,7 @@ public class ComputerPeripheral
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, Object[] arguments ) throws LuaException
|
||||
public Object[] callMethod( @Nonnull IComputerAccess computer, @Nonnull ILuaContext context, int method, @Nonnull Object[] arguments ) throws LuaException
|
||||
{
|
||||
switch( method )
|
||||
{
|
||||
@ -87,12 +91,12 @@ public class ComputerPeripheral
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attach( IComputerAccess computer )
|
||||
public void attach( @Nonnull IComputerAccess computer )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detach( IComputerAccess computer )
|
||||
public void detach( @Nonnull IComputerAccess computer )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -8,6 +8,8 @@ package dan200.computercraft.shared.computer.blocks;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public enum ComputerState implements IStringSerializable
|
||||
{
|
||||
Off( "off" ),
|
||||
@ -16,11 +18,12 @@ public enum ComputerState implements IStringSerializable
|
||||
|
||||
private String m_name;
|
||||
|
||||
private ComputerState( String name )
|
||||
ComputerState( String name )
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -12,9 +12,9 @@ import dan200.computercraft.shared.computer.core.IComputer;
|
||||
|
||||
public interface IComputerTile extends ITerminalTile
|
||||
{
|
||||
public void setComputerID( int id );
|
||||
public void setLabel( String label );
|
||||
public IComputer getComputer();
|
||||
public IComputer createComputer();
|
||||
public ComputerFamily getFamily();
|
||||
void setComputerID( int id );
|
||||
void setLabel( String label );
|
||||
IComputer getComputer();
|
||||
IComputer createComputer();
|
||||
ComputerFamily getFamily();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -21,7 +21,7 @@ import net.minecraft.util.text.*;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -53,6 +53,7 @@ public class TileCommandComputer extends TileComputer
|
||||
|
||||
// ICommandSender
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ITextComponent getDisplayName()
|
||||
{
|
||||
@ -69,7 +70,7 @@ public class TileCommandComputer extends TileComputer
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChatMessage( ITextComponent chatComponent )
|
||||
public void addChatMessage( @Nonnull ITextComponent chatComponent )
|
||||
{
|
||||
m_outputTable.put( m_outputTable.size() + 1, chatComponent.getUnformattedText() );
|
||||
}
|
||||
@ -80,12 +81,14 @@ public class TileCommandComputer extends TileComputer
|
||||
return level <= 2;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public BlockPos getPosition()
|
||||
{
|
||||
return TileCommandComputer.this.getPos();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Vec3d getPositionVector()
|
||||
{
|
||||
@ -93,6 +96,7 @@ public class TileCommandComputer extends TileComputer
|
||||
return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public World getEntityWorld()
|
||||
{
|
||||
@ -126,7 +130,7 @@ public class TileCommandComputer extends TileComputer
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillInInfo( ByteBuf buf )
|
||||
public void fillInInfo( @Nonnull ByteBuf buf )
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -142,7 +146,7 @@ public class TileCommandComputer extends TileComputer
|
||||
public EnumFacing getDirection()
|
||||
{
|
||||
IBlockState state = getBlockState();
|
||||
return (EnumFacing)state.getValue( BlockCommandComputer.Properties.FACING );
|
||||
return state.getValue( BlockCommandComputer.Properties.FACING );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -17,6 +17,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public class TileComputer extends TileComputerBase
|
||||
@ -47,7 +48,7 @@ public class TileComputer extends TileComputerBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDroppedItems( List<ItemStack> drops, boolean creative )
|
||||
public void getDroppedItems( @Nonnull List<ItemStack> drops, boolean creative )
|
||||
{
|
||||
IComputer computer = getComputer();
|
||||
if( !creative || (computer != null && computer.getLabel() != null) )
|
||||
@ -69,7 +70,7 @@ public class TileComputer extends TileComputerBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void readDescription( NBTTagCompound nbttagcompound )
|
||||
public final void readDescription( @Nonnull NBTTagCompound nbttagcompound )
|
||||
{
|
||||
super.readDescription( nbttagcompound );
|
||||
updateBlock();
|
||||
@ -86,7 +87,7 @@ public class TileComputer extends TileComputerBase
|
||||
public EnumFacing getDirection()
|
||||
{
|
||||
IBlockState state = getBlockState();
|
||||
return (EnumFacing)state.getValue( BlockComputer.Properties.FACING );
|
||||
return state.getValue( BlockComputer.Properties.FACING );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -27,6 +27,8 @@ import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public abstract class TileComputerBase extends TileGeneric
|
||||
implements IComputerTile, IDirectionalTile, ITickable
|
||||
{
|
||||
@ -167,14 +169,14 @@ public abstract class TileComputerBase extends TileGeneric
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBundledRedstoneConnectivity( EnumFacing side )
|
||||
public boolean getBundledRedstoneConnectivity( @Nonnull EnumFacing side )
|
||||
{
|
||||
int localDir = remapLocalSide( DirectionUtil.toLocal( this, side ) );
|
||||
return !isRedstoneBlockedOnSide( localDir );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBundledRedstoneOutput( EnumFacing side )
|
||||
public int getBundledRedstoneOutput( @Nonnull EnumFacing side )
|
||||
{
|
||||
int localDir = remapLocalSide( DirectionUtil.toLocal( this, side ) );
|
||||
if( !isRedstoneBlockedOnSide( localDir ) )
|
||||
@ -198,7 +200,7 @@ public abstract class TileComputerBase extends TileGeneric
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighbourTileEntityChange( BlockPos neighbour )
|
||||
public void onNeighbourTileEntityChange( @Nonnull BlockPos neighbour )
|
||||
{
|
||||
updateInput( neighbour );
|
||||
}
|
||||
@ -239,6 +241,7 @@ public abstract class TileComputerBase extends TileGeneric
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
|
||||
{
|
||||
@ -517,14 +520,14 @@ public abstract class TileComputerBase extends TileGeneric
|
||||
// Networking stuff
|
||||
|
||||
@Override
|
||||
public void writeDescription( NBTTagCompound nbttagcompound )
|
||||
public void writeDescription( @Nonnull NBTTagCompound nbttagcompound )
|
||||
{
|
||||
super.writeDescription( nbttagcompound );
|
||||
nbttagcompound.setInteger( "instanceID", createServerComputer().getInstanceID() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readDescription( NBTTagCompound nbttagcompound )
|
||||
public void readDescription( @Nonnull NBTTagCompound nbttagcompound )
|
||||
{
|
||||
super.readDescription( nbttagcompound );
|
||||
m_instanceID = nbttagcompound.getInteger( "instanceID" );
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -10,16 +10,16 @@ import dan200.computercraft.shared.common.ITerminal;
|
||||
|
||||
public interface IComputer extends ITerminal
|
||||
{
|
||||
public int getInstanceID();
|
||||
public int getID();
|
||||
public String getLabel();
|
||||
int getInstanceID();
|
||||
int getID();
|
||||
String getLabel();
|
||||
|
||||
public boolean isOn();
|
||||
public boolean isCursorDisplayed();
|
||||
public void turnOn();
|
||||
public void shutdown();
|
||||
public void reboot();
|
||||
boolean isOn();
|
||||
boolean isCursorDisplayed();
|
||||
void turnOn();
|
||||
void shutdown();
|
||||
void reboot();
|
||||
|
||||
public void queueEvent( String event );
|
||||
public void queueEvent( String event, Object[] arguments );
|
||||
void queueEvent( String event );
|
||||
void queueEvent( String event, Object[] arguments );
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -8,5 +8,5 @@ package dan200.computercraft.shared.computer.core;
|
||||
|
||||
public interface IComputerContainer
|
||||
{
|
||||
public IComputer getComputer();
|
||||
IComputer getComputer();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@ -12,6 +12,7 @@ import dan200.computercraft.shared.computer.core.IContainerComputer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ContainerComputer extends Container
|
||||
@ -25,7 +26,7 @@ public class ContainerComputer extends Container
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith( EntityPlayer player )
|
||||
public boolean canInteractWith( @Nonnull EntityPlayer player )
|
||||
{
|
||||
return m_computer.isUseableByPlayer( player );
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user