├── Server └── src │ ├── test │ └── java │ │ └── net │ │ └── simon987 │ │ └── server │ │ ├── assembly │ │ ├── instruction │ │ │ ├── SetnzInstructionTest.java │ │ │ ├── CallInstructionTest.java │ │ │ ├── BrkInstructionTest.java │ │ │ ├── SetsInstructionTest.java │ │ │ ├── SetbInstructionTest.java │ │ │ ├── SetcInstructionTest.java │ │ │ ├── SeteInstructionTest.java │ │ │ ├── SetzInstructionTest.java │ │ │ ├── SetneInstructionTest.java │ │ │ ├── SetnsInstructionTest.java │ │ │ ├── SetnaeInstructionTest.java │ │ │ ├── SetoInstructionTest.java │ │ │ ├── SetaeInstructionTest.java │ │ │ ├── SetnbInstructionTest.java │ │ │ ├── SetncInstructionTest.java │ │ │ └── SetnoInstructionTest.java │ │ ├── CPUTest.java │ │ ├── TestHelper.java │ │ ├── LabelTest.java │ │ ├── DWTest.java │ │ ├── TestComment.java │ │ └── MemoryTest.java │ │ ├── FakeConfiguration.java │ │ └── ConfigHelper.java │ └── main │ ├── resources │ ├── static │ │ ├── favicon.ico │ │ ├── images │ │ │ ├── code.png │ │ │ ├── icon.png │ │ │ ├── cubot.png │ │ │ ├── world.png │ │ │ ├── hsizegrip.png │ │ │ ├── sprites.png │ │ │ ├── github-logo.png │ │ │ ├── GitHub-Mark-32px.png │ │ │ └── ng-background-dot.png │ │ └── webfonts │ │ │ ├── FSEX301-L2.ttf │ │ │ ├── MaterialIcons-Regular.ttf │ │ │ ├── MaterialIcons-Regular.woff │ │ │ └── MaterialIcons-Regular.woff2 │ └── templates │ │ ├── footer.vm │ │ ├── head.vm │ │ └── leaderboard.vm │ ├── java │ └── net │ │ └── simon987 │ │ └── server │ │ ├── game │ │ ├── objects │ │ │ ├── MessageReceiver.java │ │ │ ├── Radioactive.java │ │ │ ├── Action.java │ │ │ ├── Updatable.java │ │ │ ├── Rechargeable.java │ │ │ ├── Enterable.java │ │ │ ├── Attackable.java │ │ │ ├── HardwareHost.java │ │ │ ├── InventoryHolder.java │ │ │ └── ControllableUnit.java │ │ ├── world │ │ │ ├── WorldGenerationException.java │ │ │ ├── TilePlain.java │ │ │ ├── TileIron.java │ │ │ ├── TileCopper.java │ │ │ ├── TileWall.java │ │ │ ├── TileVoid.java │ │ │ ├── TileFluid.java │ │ │ ├── Location.java │ │ │ ├── Tile.java │ │ │ └── DayNightCycle.java │ │ ├── item │ │ │ ├── ItemVoid.java │ │ │ ├── ItemIron.java │ │ │ └── ItemCopper.java │ │ ├── debug │ │ │ ├── SaveGameCommandListener.java │ │ │ ├── CreateWorldCommandListener.java │ │ │ ├── MoveObjCommandListener.java │ │ │ ├── SetTileAtCommandListener.java │ │ │ ├── ComPortMsgCommandListener.java │ │ │ ├── SetEnergyCommandListener.java │ │ │ ├── KillAllCommandListener.java │ │ │ ├── HealObjCommandListener.java │ │ │ ├── DamageObjCommandListener.java │ │ │ └── UserInfoCommandListener.java │ │ └── pathfinding │ │ │ ├── SortedArrayList.java │ │ │ └── Node.java │ │ ├── io │ │ ├── MongoSerializable.java │ │ └── JSONSerializable.java │ │ ├── user │ │ └── RegistrationException.java │ │ ├── assembly │ │ ├── exception │ │ │ ├── CancelledException.java │ │ │ ├── IllegalOperandException.java │ │ │ ├── EmptyLineException.java │ │ │ ├── InvalidMnemonicException.java │ │ │ ├── PseudoInstructionException.java │ │ │ ├── DuplicateSectionException.java │ │ │ ├── FatalAssemblyException.java │ │ │ ├── InvalidOperandException.java │ │ │ ├── OffsetOverflowException.java │ │ │ └── AssemblyException.java │ │ ├── instruction │ │ │ ├── SalInstruction.java │ │ │ ├── SetaInstruction.java │ │ │ ├── SetbInstruction.java │ │ │ ├── SetcInstruction.java │ │ │ ├── SeteInstruction.java │ │ │ ├── SetgInstruction.java │ │ │ ├── SetlInstruction.java │ │ │ ├── SetoInstruction.java │ │ │ ├── SetsInstruction.java │ │ │ ├── SetzInstruction.java │ │ │ ├── SetaeInstruction.java │ │ │ ├── SetbeInstruction.java │ │ │ ├── SetgeInstruction.java │ │ │ ├── SetleInstruction.java │ │ │ ├── SetnaInstruction.java │ │ │ ├── SetnaeInstruction.java │ │ │ ├── SetnbInstruction.java │ │ │ ├── SetnbeInstruction.java │ │ │ ├── SetncInstruction.java │ │ │ ├── SetneInstruction.java │ │ │ ├── SetngInstruction.java │ │ │ ├── SetngeInstruction.java │ │ │ ├── SetnlInstruction.java │ │ │ ├── SetnleInstruction.java │ │ │ ├── SetnoInstruction.java │ │ │ ├── SetnsInstruction.java │ │ │ ├── SetnzInstruction.java │ │ │ ├── LeaInstruction.java │ │ │ ├── NopInstruction.java │ │ │ ├── NotInstruction.java │ │ │ ├── BrkInstruction.java │ │ │ ├── HwqInstruction.java │ │ │ ├── JmpInstruction.java │ │ │ ├── XchgInstruction.java │ │ │ ├── JoInstruction.java │ │ │ ├── JnzInstruction.java │ │ │ ├── JsInstruction.java │ │ │ ├── PopInstruction.java │ │ │ ├── JcInstruction.java │ │ │ ├── JncInstruction.java │ │ │ ├── JnoInstruction.java │ │ │ ├── JnsInstruction.java │ │ │ ├── JlInstruction.java │ │ │ ├── JzInstruction.java │ │ │ ├── PushfInstruction.java │ │ │ ├── JaInstruction.java │ │ │ ├── JnaInstruction.java │ │ │ ├── IncInstruction.java │ │ │ ├── JgInstruction.java │ │ │ ├── DecInstruction.java │ │ │ ├── JleInstruction.java │ │ │ ├── PushInstruction.java │ │ │ ├── JgeInstruction.java │ │ │ ├── HwiInstruction.java │ │ │ ├── PopfInstruction.java │ │ │ ├── RetInstruction.java │ │ │ ├── NegInstruction.java │ │ │ ├── MovInstruction.java │ │ │ ├── TestInstruction.java │ │ │ ├── OrInstruction.java │ │ │ ├── CallInstruction.java │ │ │ ├── XorInstruction.java │ │ │ └── SubInstruction.java │ │ ├── Section.java │ │ ├── DefaultRegisterSet.java │ │ ├── OperandType.java │ │ ├── Target.java │ │ ├── InstructionSet.java │ │ └── Register.java │ │ ├── web │ │ ├── GuestPolicy.java │ │ ├── AlertMessage.java │ │ ├── AlertType.java │ │ ├── HomePage.java │ │ ├── LogoutRoute.java │ │ ├── LeaderBoardPage.java │ │ ├── AccountPage.java │ │ ├── PlayPage.java │ │ ├── FloppyDownloadRoute.java │ │ ├── LoginRoute.java │ │ └── RegisterRoute.java │ │ ├── event │ │ ├── UserCreationEvent.java │ │ ├── GameEventListener.java │ │ ├── TickEvent.java │ │ ├── ObjectDeathEvent.java │ │ ├── WorldGenerationEvent.java │ │ ├── WorldUpdateEvent.java │ │ ├── CpuInitialisationEvent.java │ │ ├── GameEvent.java │ │ ├── GameEventDispatcher.java │ │ └── DebugCommandEvent.java │ │ ├── websocket │ │ ├── MessageHandler.java │ │ ├── DebugCommandHandler.java │ │ ├── KeypressHandler.java │ │ ├── OnlineUser.java │ │ ├── OnlineUserManager.java │ │ └── CodeRequestHandler.java │ │ ├── IServerConfiguration.java │ │ ├── crypto │ │ ├── Cypher.java │ │ ├── CryptoException.java │ │ ├── InvalidKeyException.java │ │ ├── InvalidCharsetException.java │ │ ├── VigenereCypher.java │ │ ├── CaesarCypher.java │ │ ├── AutokeyCypher.java │ │ ├── SecretKeyGenerator.java │ │ ├── CryptoProvider.java │ │ └── NoCypher.java │ │ ├── Main.java │ │ └── logging │ │ └── GenericFormatter.java │ └── typescript │ └── tsconfig.json ├── Plugin Cubot ├── src │ └── main │ │ ├── resources │ │ └── plugin.properties │ │ └── java │ │ └── net │ │ └── simon987 │ │ └── cubotplugin │ │ ├── CubotStatus.java │ │ ├── event │ │ ├── CubotWalkEvent.java │ │ ├── DeathEvent.java │ │ ├── WalkListener.java │ │ ├── DeathListener.java │ │ ├── PopItemCommandListener.java │ │ └── SetInventoryPosition.java │ │ ├── CubotHardwareModule.java │ │ ├── CubotCore.java │ │ ├── CubotShield.java │ │ └── CubotKeyboard.java ├── test │ └── net │ │ └── simon987 │ │ └── cubotplugin │ │ └── CubotTest.java └── pom.xml ├── Plugin Misc HW ├── src │ └── main │ │ ├── resources │ │ └── plugin.properties │ │ └── java │ │ └── net │ │ └── simon987 │ │ └── mischwplugin │ │ ├── MiscHWPlugin.java │ │ ├── event │ │ └── CpuInitialisationListener.java │ │ ├── RandomNumberGenerator.java │ │ └── Clock.java └── pom.xml ├── Plugin NPC ├── src │ └── main │ │ ├── resources │ │ ├── plugin.properties │ │ └── defaultHackedCubotHardware.json │ │ └── java │ │ └── net │ │ └── simon987 │ │ └── npcplugin │ │ ├── NPCTask.java │ │ ├── world │ │ ├── TileVaultFloor.java │ │ └── TileVaultWall.java │ │ ├── event │ │ ├── VaultCompleteEvent.java │ │ ├── CpuInitialisationListener.java │ │ └── VaultCompleteListener.java │ │ ├── VaultExitPortal.java │ │ └── ExecuteCpuTask.java └── pom.xml ├── Plugin Plant ├── src │ └── main │ │ ├── resources │ │ └── plugin.properties │ │ └── java │ │ └── net │ │ └── simon987 │ │ └── biomassplugin │ │ ├── ItemBiomass.java │ │ ├── BiomassPlugin.java │ │ └── event │ │ └── WorldCreationListener.java └── pom.xml ├── Dockerfile ├── plugin-contruction ├── src │ └── main │ │ ├── resources │ │ └── plugin.properties │ │ └── java │ │ └── net │ │ └── simon987 │ │ └── constructionplugin │ │ ├── ObstacleBlueprint.java │ │ └── ConstructionPlugin.java └── pom.xml ├── Plugin Radioactive Cloud ├── src │ └── main │ │ ├── resources │ │ └── plugin.properties │ │ └── java │ │ └── net │ │ └── simon987 │ │ └── pluginradioactivecloud │ │ ├── RadioactiveCloudPlugin.java │ │ ├── RadioactiveObstacle.java │ │ └── RadioactiveCloud.java └── pom.xml ├── Vagrantfile ├── .gitattributes ├── .gitignore ├── bootstrap.sh ├── docker-compose.yml └── CONTRIBUTING.md /Server/src/test/java/net/simon987/server/assembly/instruction/SetnzInstructionTest.java: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Plugin Cubot/src/main/resources/plugin.properties: -------------------------------------------------------------------------------- 1 | classpath=net.simon987.cubotplugin.CubotPlugin 2 | name=Cubot Plugin 3 | version=1.0 -------------------------------------------------------------------------------- /Plugin Misc HW/src/main/resources/plugin.properties: -------------------------------------------------------------------------------- 1 | classpath=net.simon987.mischwplugin.MiscHWPlugin 2 | name=Misc HW Plugin 3 | version=1.0 -------------------------------------------------------------------------------- /Server/src/test/java/net/simon987/server/assembly/CPUTest.java: -------------------------------------------------------------------------------- 1 | package net.simon987.server.assembly; 2 | 3 | public class CPUTest { 4 | 5 | 6 | } -------------------------------------------------------------------------------- /Plugin NPC/src/main/resources/plugin.properties: -------------------------------------------------------------------------------- 1 | classpath=net.simon987.npcplugin.NpcPlugin 2 | name=NPC Plugin 3 | version=1.1 4 | depend=Cubot Plugin -------------------------------------------------------------------------------- /Server/src/main/resources/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simon987/Much-Assembly-Required/HEAD/Server/src/main/resources/static/favicon.ico -------------------------------------------------------------------------------- /Plugin Plant/src/main/resources/plugin.properties: -------------------------------------------------------------------------------- 1 | classpath=net.simon987.biomassplugin.BiomassPlugin 2 | name=Biomass Plugin 3 | version=1.0 4 | depend=NPC Plugin -------------------------------------------------------------------------------- /Server/src/main/resources/static/images/code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simon987/Much-Assembly-Required/HEAD/Server/src/main/resources/static/images/code.png -------------------------------------------------------------------------------- /Server/src/main/resources/static/images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simon987/Much-Assembly-Required/HEAD/Server/src/main/resources/static/images/icon.png -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 2 | COPY /. /app/ 3 | WORKDIR /app 4 | RUN mvn package 5 | WORKDIR /app/target 6 | CMD ["java", "-jar", "/app/target/server-1.4a.jar"] -------------------------------------------------------------------------------- /Server/src/main/resources/static/images/cubot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simon987/Much-Assembly-Required/HEAD/Server/src/main/resources/static/images/cubot.png -------------------------------------------------------------------------------- /Server/src/main/resources/static/images/world.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simon987/Much-Assembly-Required/HEAD/Server/src/main/resources/static/images/world.png -------------------------------------------------------------------------------- /plugin-contruction/src/main/resources/plugin.properties: -------------------------------------------------------------------------------- 1 | classpath=net.simon987.constructionplugin.ConstructionPlugin 2 | name=Construction Plugin 3 | version=1.0 4 | -------------------------------------------------------------------------------- /Server/src/main/resources/static/images/hsizegrip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simon987/Much-Assembly-Required/HEAD/Server/src/main/resources/static/images/hsizegrip.png -------------------------------------------------------------------------------- /Server/src/main/resources/static/images/sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simon987/Much-Assembly-Required/HEAD/Server/src/main/resources/static/images/sprites.png -------------------------------------------------------------------------------- /Server/src/main/resources/static/images/github-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simon987/Much-Assembly-Required/HEAD/Server/src/main/resources/static/images/github-logo.png -------------------------------------------------------------------------------- /Plugin Radioactive Cloud/src/main/resources/plugin.properties: -------------------------------------------------------------------------------- 1 | classpath=net.simon987.pluginradioactivecloud.RadioactiveCloudPlugin 2 | name=Radioactive cloud Plugin 3 | version=1.4 -------------------------------------------------------------------------------- /Server/src/main/resources/static/webfonts/FSEX301-L2.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simon987/Much-Assembly-Required/HEAD/Server/src/main/resources/static/webfonts/FSEX301-L2.ttf -------------------------------------------------------------------------------- /Server/src/main/resources/static/images/GitHub-Mark-32px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simon987/Much-Assembly-Required/HEAD/Server/src/main/resources/static/images/GitHub-Mark-32px.png -------------------------------------------------------------------------------- /Server/src/main/resources/static/images/ng-background-dot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simon987/Much-Assembly-Required/HEAD/Server/src/main/resources/static/images/ng-background-dot.png -------------------------------------------------------------------------------- /Server/src/main/resources/static/webfonts/MaterialIcons-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simon987/Much-Assembly-Required/HEAD/Server/src/main/resources/static/webfonts/MaterialIcons-Regular.ttf -------------------------------------------------------------------------------- /Server/src/main/resources/static/webfonts/MaterialIcons-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simon987/Much-Assembly-Required/HEAD/Server/src/main/resources/static/webfonts/MaterialIcons-Regular.woff -------------------------------------------------------------------------------- /Server/src/test/java/net/simon987/server/assembly/instruction/CallInstructionTest.java: -------------------------------------------------------------------------------- 1 | package net.simon987.server.assembly.instruction; 2 | 3 | public class CallInstructionTest { 4 | 5 | 6 | 7 | } -------------------------------------------------------------------------------- /Server/src/main/resources/static/webfonts/MaterialIcons-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simon987/Much-Assembly-Required/HEAD/Server/src/main/resources/static/webfonts/MaterialIcons-Regular.woff2 -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | Vagrant.configure("2") do |config| 2 | config.vm.box = "ubuntu/trusty64" 3 | config.vm.provision :shell, path: "bootstrap.sh" 4 | config.vm.network "forwarded_port", guest: 4567, host: 4567 5 | end -------------------------------------------------------------------------------- /Server/src/main/java/net/simon987/server/game/objects/MessageReceiver.java: -------------------------------------------------------------------------------- 1 | package net.simon987.server.game.objects; 2 | 3 | public interface MessageReceiver { 4 | 5 | boolean sendMessage(char[] message); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /Plugin Cubot/test/net/simon987/cubotplugin/CubotTest.java: -------------------------------------------------------------------------------- 1 | package net.simon987.cubotplugin; 2 | 3 | 4 | import org.junit.Test; 5 | 6 | public class CubotTest { 7 | 8 | @Test 9 | public void test(){ 10 | 11 | } 12 | } -------------------------------------------------------------------------------- /Server/src/main/java/net/simon987/server/io/MongoSerializable.java: -------------------------------------------------------------------------------- 1 | package net.simon987.server.io; 2 | 3 | import org.bson.Document; 4 | 5 | public interface MongoSerializable { 6 | 7 | Document mongoSerialise(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /Server/src/main/java/net/simon987/server/game/objects/Radioactive.java: -------------------------------------------------------------------------------- 1 | package net.simon987.server.game.objects; 2 | 3 | //Alpha: ±5cm 4 | //Beta: 10-20 feet 5 | //Gamma: 100+ feet 6 | 7 | public interface Radioactive { 8 | 9 | 10 | } 11 | -------------------------------------------------------------------------------- /Plugin NPC/src/main/java/net/simon987/npcplugin/NPCTask.java: -------------------------------------------------------------------------------- 1 | package net.simon987.npcplugin; 2 | 3 | 4 | public abstract class NPCTask { 5 | 6 | public abstract boolean checkCompleted(); 7 | 8 | public abstract void tick(NonPlayerCharacter npc); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /Server/src/main/java/net/simon987/server/user/RegistrationException.java: -------------------------------------------------------------------------------- 1 | package net.simon987.server.user; 2 | 3 | public class RegistrationException extends Exception { 4 | 5 | public RegistrationException(String message) { 6 | super(message); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /Server/src/main/java/net/simon987/server/game/world/WorldGenerationException.java: -------------------------------------------------------------------------------- 1 | package net.simon987.server.game.world; 2 | 3 | public class WorldGenerationException extends Exception { 4 | public WorldGenerationException(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Server/src/main/java/net/simon987/server/io/JSONSerializable.java: -------------------------------------------------------------------------------- 1 | package net.simon987.server.io; 2 | 3 | import org.json.simple.JSONObject; 4 | 5 | public interface JSONSerializable { 6 | 7 | JSONObject jsonSerialise(); 8 | 9 | JSONObject debugJsonSerialise(); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /Server/src/main/java/net/simon987/server/assembly/exception/CancelledException.java: -------------------------------------------------------------------------------- 1 | package net.simon987.server.assembly.exception; 2 | 3 | public class CancelledException extends Exception { 4 | public CancelledException() { 5 | super("CPU Initialisation was cancelled"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Server/src/main/java/net/simon987/server/game/world/TilePlain.java: -------------------------------------------------------------------------------- 1 | package net.simon987.server.game.world; 2 | 3 | public class TilePlain extends Tile { 4 | 5 | public static final int ID = 0; 6 | 7 | @Override 8 | public int getId() { 9 | return ID; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Server/src/main/java/net/simon987/server/game/objects/Action.java: -------------------------------------------------------------------------------- 1 | package net.simon987.server.game.objects; 2 | 3 | public enum Action { 4 | IDLE, 5 | DIGGING, 6 | WALKING, 7 | WITHDRAWING, 8 | DEPOSITING, 9 | LISTENING, 10 | _PLACEHOLDER_, 11 | ATTACKING, 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Server/src/main/java/net/simon987/server/web/GuestPolicy.java: -------------------------------------------------------------------------------- 1 | package net.simon987.server.web; 2 | 3 | public enum GuestPolicy { 4 | /** 5 | * Allow guests, must login to have Cubot 6 | */ 7 | ALLOW, 8 | /** 9 | * Block guests completely 10 | */ 11 | BLOCK, 12 | } 13 | -------------------------------------------------------------------------------- /Server/src/main/java/net/simon987/server/event/UserCreationEvent.java: -------------------------------------------------------------------------------- 1 | package net.simon987.server.event; 2 | 3 | import net.simon987.server.user.User; 4 | 5 | public class UserCreationEvent extends GameEvent { 6 | 7 | public UserCreationEvent(User user) { 8 | setSource(user); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Server/src/main/java/net/simon987/server/assembly/exception/IllegalOperandException.java: -------------------------------------------------------------------------------- 1 | package net.simon987.server.assembly.exception; 2 | 3 | 4 | public class IllegalOperandException extends AssemblyException { 5 | public IllegalOperandException(String msg, int line) { 6 | super(msg, line); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Server/src/main/java/net/simon987/server/game/objects/Updatable.java: -------------------------------------------------------------------------------- 1 | package net.simon987.server.game.objects; 2 | 3 | /** 4 | * Updatable objects needs to be updated each tick 5 | */ 6 | public interface Updatable { 7 | 8 | /** 9 | * Called every tick 10 | */ 11 | void update(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Server/src/main/java/net/simon987/server/assembly/instruction/SalInstruction.java: -------------------------------------------------------------------------------- 1 | package net.simon987.server.assembly.instruction; 2 | 3 | /** 4 | * Alias of SHL instruction 5 | */ 6 | public class SalInstruction extends ShlInstruction { 7 | 8 | public SalInstruction() { 9 | super("sal"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Server/src/main/java/net/simon987/server/event/GameEventListener.java: -------------------------------------------------------------------------------- 1 | package net.simon987.server.event; 2 | 3 | /** 4 | * Listens for and handles a single type of event 5 | */ 6 | public interface GameEventListener { 7 | 8 | Class getListenedEventType(); 9 | 10 | void handle(GameEvent event); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Server/src/main/resources/templates/footer.vm: -------------------------------------------------------------------------------- 1 |
7 | * For example: MOV dstTARGET, srcTARGET 8 | *
9 | * A target is usually Memory or Register 10 | */ 11 | public interface Target { 12 | 13 | /** 14 | * Get a value from a Target at an address. 15 | * 16 | * @param address Address of the value. Can refer to a memory address or the index 17 | * of a register 18 | * @return value at specified address 19 | */ 20 | int get(int address); 21 | 22 | /** 23 | * Set a value at an address 24 | * 25 | * @param address address of the value to change 26 | * @param value value to set 27 | */ 28 | void set(int address, int value); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Server/src/test/java/net/simon987/server/FakeConfiguration.java: -------------------------------------------------------------------------------- 1 | package net.simon987.server; 2 | 3 | import java.util.Properties; 4 | 5 | public class FakeConfiguration implements IServerConfiguration { 6 | 7 | private Properties properties; 8 | 9 | 10 | public FakeConfiguration() { 11 | this.properties = new Properties(); 12 | } 13 | 14 | @Override 15 | public int getInt(String key) { 16 | return Integer.parseInt(properties.getProperty(key)); 17 | } 18 | 19 | @Override 20 | public String getString(String key) { 21 | return properties.getProperty(key); 22 | } 23 | 24 | @Override 25 | public void setInt(String key, int value) { 26 | properties.setProperty(key, String.valueOf(value)); 27 | } 28 | 29 | @Override 30 | public void setString(String key, String value) { 31 | properties.setProperty(key, value); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Server/src/main/java/net/simon987/server/assembly/instruction/HwqInstruction.java: -------------------------------------------------------------------------------- 1 | package net.simon987.server.assembly.instruction; 2 | 3 | import net.simon987.server.assembly.*; 4 | 5 | public class HwqInstruction extends Instruction { 6 | 7 | private static final int OPCODE = 28; 8 | 9 | private CPU cpu; 10 | private Register b; 11 | 12 | public HwqInstruction(CPU cpu) { 13 | super("hwq", OPCODE); 14 | this.cpu = cpu; 15 | this.b = cpu.getRegisterSet().getRegister("B"); 16 | } 17 | 18 | @Override 19 | public Status execute(Target src, int srcIndex, Status status) { 20 | b.setValue(cpu.getHardwareHost().hardwareQuery(src.get(srcIndex))); 21 | 22 | return status; 23 | } 24 | 25 | @Override 26 | public Status execute(int src, Status status) { 27 | b.setValue(cpu.getHardwareHost().hardwareQuery(src)); 28 | 29 | return status; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Server/src/test/java/net/simon987/server/ConfigHelper.java: -------------------------------------------------------------------------------- 1 | package net.simon987.server; 2 | 3 | import java.io.File; 4 | 5 | public class ConfigHelper { 6 | public static ServerConfiguration getConfig() { 7 | File workingDir = new File(""); 8 | File file = new File(workingDir.getAbsolutePath(), "config.properties"); 9 | 10 | if (!file.exists()) { 11 | File fallback = new File("Server/src/main/resources/", file.getName()); 12 | if (fallback.exists()) { 13 | file = fallback; 14 | } else { 15 | throw new AssertionError("'config.properties' and " + 16 | "'Server/src/main/resources/config.properties' cannot be found with working directory: " + 17 | workingDir.getAbsolutePath()); 18 | } 19 | } 20 | 21 | return new ServerConfiguration(file.getAbsolutePath()); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Server/src/main/java/net/simon987/server/assembly/instruction/JmpInstruction.java: -------------------------------------------------------------------------------- 1 | package net.simon987.server.assembly.instruction; 2 | 3 | import net.simon987.server.assembly.CPU; 4 | import net.simon987.server.assembly.Instruction; 5 | import net.simon987.server.assembly.Status; 6 | import net.simon987.server.assembly.Target; 7 | 8 | public class JmpInstruction extends Instruction { 9 | 10 | public static final int OPCODE = 10; 11 | 12 | private CPU cpu; 13 | 14 | public JmpInstruction(CPU cpu) { 15 | super("jmp", OPCODE); 16 | 17 | this.cpu = cpu; 18 | } 19 | 20 | @Override 21 | public Status execute(Target src, int srcIndex, Status status) { 22 | 23 | cpu.setIp((char) src.get(srcIndex)); 24 | return status; 25 | } 26 | 27 | @Override 28 | public Status execute(int src, Status status) { 29 | 30 | cpu.setIp((char) src); 31 | return status; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Server/src/main/java/net/simon987/server/assembly/InstructionSet.java: -------------------------------------------------------------------------------- 1 | package net.simon987.server.assembly; 2 | 3 | /** 4 | * A set of instructions for a CPU. 5 | *
6 | * Defines what a CPU can do 7 | */ 8 | public interface InstructionSet { 9 | 10 | /** 11 | * Get an instruction by its opcode 12 | * 13 | * @param opcode opcode of the instruction 14 | * @return the instruction, null is not found 15 | */ 16 | Instruction get(int opcode); 17 | 18 | /** 19 | * Get an instruction by its mnemonic 20 | * 21 | * @param mnemonic mnemonic of the instruction, not case sensitive 22 | * @return the instruction, if not found, the default instruction is returned 23 | */ 24 | Instruction get(String mnemonic); 25 | 26 | /** 27 | * Add an instruction to the set 28 | * 29 | * @param instruction instruction to add 30 | */ 31 | void add(Instruction instruction); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Plugin Misc HW/src/main/java/net/simon987/mischwplugin/MiscHWPlugin.java: -------------------------------------------------------------------------------- 1 | package net.simon987.mischwplugin; 2 | 3 | import net.simon987.mischwplugin.event.CpuInitialisationListener; 4 | import net.simon987.server.GameServer; 5 | import net.simon987.server.game.objects.GameRegistry; 6 | import net.simon987.server.logging.LogManager; 7 | import net.simon987.server.plugin.ServerPlugin; 8 | 9 | /** 10 | * Plugin that adds miscellaneous hardware to the game 11 | */ 12 | public class MiscHWPlugin extends ServerPlugin { 13 | 14 | 15 | @Override 16 | public void init(GameServer gameServer) { 17 | listeners.add(new CpuInitialisationListener()); 18 | 19 | GameRegistry registry = gameServer.getRegistry(); 20 | 21 | registry.registerHardware(RandomNumberGenerator.class); 22 | registry.registerHardware(Clock.class); 23 | 24 | LogManager.LOGGER.info("(Mist HW Plugin) Initialised Misc Hardware Plugin"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Server/src/main/java/net/simon987/server/game/pathfinding/SortedArrayList.java: -------------------------------------------------------------------------------- 1 | package net.simon987.server.game.pathfinding; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | 6 | /** 7 | * Wrapper of ArrayList to make it sorted 8 | *
9 | * inspired by http://www.cokeandcode.com/main/tutorials/path-finding/
10 | */
11 | public class SortedArrayList extends ArrayList
13 | * The instruction might have unexpected behavior if the an
14 | * operand of type [register + displacement] is used and its sum
15 | * is greater than 0xFFFF (It will overflow)
16 | *
18 | * The MOV instruction doesn't change any flags
19 | *
6 | * Inspired by http://www.cokeandcode.com/main/tutorials/path-finding/
7 | */
8 | public class Node implements Comparable {
9 |
10 | /**
11 | * x coordinate of the node
12 | */
13 | public int x;
14 |
15 | /**
16 | * y coordinate of the node
17 | */
18 | public int y;
19 |
20 | /**
21 | * Cost of getting from the start node to this node
22 | */
23 | public int gScore;
24 |
25 | /**
26 | * Total cost of getting from the start node to the goal
27 | */
28 | public int fScore;
29 |
30 | /**
31 | * Parent of the node
32 | */
33 | public Node parent;
34 |
35 |
36 | /**
37 | * Create a new Node
38 | *
39 | * @param x X coordinate of the node
40 | * @param y Y coordinate of the node
41 | */
42 | public Node(int x, int y) {
43 | this.x = x;
44 | this.y = y;
45 |
46 | gScore = Integer.MAX_VALUE;
47 | fScore = Integer.MAX_VALUE;
48 | }
49 |
50 | /**
51 | * Compare two Nodes using their fScore
52 | */
53 | @Override
54 | public int compareTo(Object o) {
55 | Node other = (Node) o;
56 |
57 | return Integer.compare(fScore, other.fScore);
58 | }
59 |
60 | @Override
61 | public String toString() {
62 | return "(" + this.x + ", " + this.y + ")";
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/Plugin Cubot/src/main/java/net/simon987/cubotplugin/event/PopItemCommandListener.java:
--------------------------------------------------------------------------------
1 | package net.simon987.cubotplugin.event;
2 |
3 | import net.simon987.cubotplugin.Cubot;
4 | import net.simon987.cubotplugin.CubotInventory;
5 | import net.simon987.server.GameServer;
6 | import net.simon987.server.event.DebugCommandEvent;
7 | import net.simon987.server.event.GameEvent;
8 | import net.simon987.server.event.GameEventListener;
9 | import net.simon987.server.game.objects.GameObject;
10 |
11 | public class PopItemCommandListener implements GameEventListener {
12 |
13 | @Override
14 | public Class getListenedEventType() {
15 | return DebugCommandEvent.class;
16 | }
17 |
18 | @Override
19 | public void handle(GameEvent event) {
20 |
21 | DebugCommandEvent e = (DebugCommandEvent) event;
22 |
23 | if (e.getName().equals("clearItem")) {
24 |
25 | GameObject object = GameServer.INSTANCE.getGameUniverse().getObject(e.getObjectId("objectId"));
26 |
27 | if (object != null) {
28 |
29 | if (object instanceof Cubot) {
30 |
31 | CubotInventory inventory = (CubotInventory) ((Cubot) object).getHardware(CubotInventory.class);
32 |
33 | e.reply("Removed item from inventory: " + inventory.clearItem());
34 | } else {
35 | e.reply("Object is not a Cubot");
36 | }
37 |
38 | } else {
39 | e.reply("Object not found: " + e.getLong("objectId"));
40 | }
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/Server/src/main/java/net/simon987/server/game/debug/ComPortMsgCommandListener.java:
--------------------------------------------------------------------------------
1 | package net.simon987.server.game.debug;
2 |
3 | import net.simon987.server.GameServer;
4 | import net.simon987.server.event.DebugCommandEvent;
5 | import net.simon987.server.event.GameEvent;
6 | import net.simon987.server.event.GameEventListener;
7 | import net.simon987.server.game.objects.GameObject;
8 | import net.simon987.server.game.objects.MessageReceiver;
9 | import org.bson.types.ObjectId;
10 |
11 | public class ComPortMsgCommandListener implements GameEventListener {
12 |
13 | @Override
14 | public Class getListenedEventType() {
15 | return DebugCommandEvent.class;
16 | }
17 |
18 | @Override
19 | public void handle(GameEvent event) {
20 |
21 | DebugCommandEvent e = (DebugCommandEvent) event;
22 |
23 | if (e.getName().equals("comPortMsg")) {
24 |
25 | ObjectId objectId = e.getObjectId("objectId");
26 |
27 | GameObject object = GameServer.INSTANCE.getGameUniverse().getObject(objectId);
28 |
29 | if (object != null) {
30 |
31 | if (object instanceof MessageReceiver) {
32 |
33 | e.reply("Result: " + ((MessageReceiver) object).sendMessage(e.getString("message").toCharArray()));
34 |
35 | } else {
36 | e.reply("Object " + objectId + " not MessageReceiver");
37 | }
38 |
39 | } else {
40 | e.reply("Object " + objectId + " not found");
41 | }
42 | }
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/Server/src/main/java/net/simon987/server/game/debug/SetEnergyCommandListener.java:
--------------------------------------------------------------------------------
1 | package net.simon987.server.game.debug;
2 |
3 | import net.simon987.server.GameServer;
4 | import net.simon987.server.event.DebugCommandEvent;
5 | import net.simon987.server.event.GameEvent;
6 | import net.simon987.server.event.GameEventListener;
7 | import net.simon987.server.game.objects.GameObject;
8 | import net.simon987.server.game.objects.Rechargeable;
9 |
10 | public class SetEnergyCommandListener implements GameEventListener {
11 |
12 | @Override
13 | public Class getListenedEventType() {
14 | return DebugCommandEvent.class;
15 | }
16 |
17 | @Override
18 | public void handle(GameEvent event) {
19 |
20 | DebugCommandEvent e = (DebugCommandEvent) event;
21 |
22 | if (e.getName().equals("setEnergy")) {
23 |
24 | GameObject object = GameServer.INSTANCE.getGameUniverse().getObject(e.getObjectId("objectId"));
25 |
26 | if (object != null) {
27 |
28 | if (object instanceof Rechargeable) {
29 |
30 | int oldEnergy = ((Rechargeable) object).getEnergy();
31 | ((Rechargeable) object).setEnergy(e.getInt("amount"));
32 |
33 | e.reply("Success: " + oldEnergy + " -> " + e.getInt("amount"));
34 | } else {
35 | e.reply("Object is not Rechargeable");
36 | }
37 |
38 | } else {
39 | e.reply("Object not found: " + e.getLong("objectId"));
40 | }
41 | }
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/Server/src/main/java/net/simon987/server/event/DebugCommandEvent.java:
--------------------------------------------------------------------------------
1 | package net.simon987.server.event;
2 |
3 | import net.simon987.server.websocket.OnlineUser;
4 | import org.bson.types.ObjectId;
5 | import org.json.simple.JSONObject;
6 |
7 | import java.io.IOException;
8 |
9 | public class DebugCommandEvent extends GameEvent {
10 |
11 | private JSONObject command;
12 |
13 | public DebugCommandEvent(JSONObject json, OnlineUser user) {
14 | this.command = json;
15 | this.setSource(user);
16 | }
17 |
18 | public String getName() {
19 | return (String) command.get("command");
20 | }
21 |
22 | public String getString(String key) {
23 | return (String) command.get(key);
24 | }
25 |
26 | public int getInt(String key) {
27 | return (int) (long) command.get(key);
28 | }
29 |
30 | public long getLong(String key) {
31 | return (long) command.get(key);
32 | }
33 |
34 | public ObjectId getObjectId(String key) {
35 | return new ObjectId((String) command.get(key));
36 | }
37 |
38 | /**
39 | * Send back a response to the command issuer
40 | */
41 | public void reply(String message) {
42 |
43 | JSONObject response = new JSONObject();
44 | response.put("t", "debug");
45 | response.put("message", message);
46 |
47 | try {
48 | ((OnlineUser) getSource()).getWebSocket().getRemote().sendString(response.toJSONString());
49 | } catch (IOException e) {
50 | e.printStackTrace();
51 | }
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/Plugin NPC/src/main/resources/defaultHackedCubotHardware.json:
--------------------------------------------------------------------------------
1 | {
2 | "hardware": [
3 | {
4 | "type": "net.simon987.cubotplugin.CubotLeg",
5 | "address": 1
6 | },
7 | {
8 | "type": "net.simon987.cubotplugin.CubotLaser",
9 | "address": 2
10 | },
11 | {
12 | "type": "net.simon987.cubotplugin.CubotLidar",
13 | "address": 3
14 | },
15 | {
16 | "type": "net.simon987.cubotplugin.CubotDrill",
17 | "address": 5
18 | },
19 | {
20 | "type": "net.simon987.npcplugin.NpcInventory",
21 | "item": null,
22 | "address": 6
23 | },
24 | {
25 | "type": "net.simon987.mischwplugin.RandomNumberGenerator",
26 | "address": 7
27 | },
28 | {
29 | "type": "net.simon987.mischwplugin.Clock",
30 | "address": 8
31 | },
32 | {
33 | "type": "net.simon987.cubotplugin.CubotHologram",
34 | "color": 0,
35 | "value": 0,
36 | "string": "",
37 | "mode": 0,
38 | "address": 9
39 | },
40 | {
41 | "type": "net.simon987.npcplugin.NpcBattery",
42 | "energy": 60000,
43 | "max_energy": 60000,
44 | "address": 262
45 | },
46 | {
47 | "type": "net.simon987.npcplugin.RadioReceiverHardware",
48 | "cubot": {
49 | "$oid": "5c1d43e40d3d2530aba636df"
50 | },
51 | "address": 12
52 | },
53 | {
54 | "type": "net.simon987.cubotplugin.CubotComPort",
55 | "address": 13
56 | },
57 | {
58 | "type": "net.simon987.cubotplugin.CubotCore",
59 | "address": 14
60 | }
61 | ]
62 | }
--------------------------------------------------------------------------------
/Server/src/main/java/net/simon987/server/assembly/instruction/OrInstruction.java:
--------------------------------------------------------------------------------
1 | package net.simon987.server.assembly.instruction;
2 |
3 | import net.simon987.server.assembly.Instruction;
4 | import net.simon987.server.assembly.Status;
5 | import net.simon987.server.assembly.Target;
6 | import net.simon987.server.assembly.Util;
7 |
8 | public class OrInstruction extends Instruction {
9 |
10 | public static final int OPCODE = 5;
11 |
12 | public OrInstruction() {
13 | super("or", OPCODE);
14 | }
15 |
16 | @Override
17 | public Status execute(Target dst, int dstIndex, Target src, int srcIndex, Status status) {
18 |
19 | int a = (char) dst.get(dstIndex);
20 | int b = (char) src.get(srcIndex);
21 |
22 |
23 | int result = (a | b);
24 |
25 | status.setSignFlag(Util.checkSign16(result));
26 | status.setZeroFlag((char) result == 0);
27 | status.setOverflowFlag(false);
28 | status.setCarryFlag(false);
29 |
30 | dst.set(dstIndex, result);
31 |
32 | return status;
33 | }
34 |
35 | @Override
36 | public Status execute(Target dst, int dstIndex, int src, Status status) {
37 | int a = (char) dst.get(dstIndex);
38 | int b = (char) src;
39 |
40 |
41 | int result = (a | b);
42 |
43 | status.setSignFlag(Util.checkSign16(result));
44 | status.setZeroFlag((char) result == 0);
45 | status.setOverflowFlag(false);
46 | status.setCarryFlag(false);
47 |
48 | dst.set(dstIndex, result);
49 |
50 | return status;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotKeyboard.java:
--------------------------------------------------------------------------------
1 | package net.simon987.cubotplugin;
2 |
3 | import net.simon987.server.assembly.Status;
4 | import net.simon987.server.game.objects.ControllableUnit;
5 | import org.bson.Document;
6 |
7 | public class CubotKeyboard extends CubotHardwareModule {
8 |
9 | public static final int DEFAULT_ADDRESS = 4;
10 |
11 | private static final int KEYBOARD_CLEAR_BUFFER = 0;
12 | private static final int KEYBOARD_FETCH_KEY = 1;
13 |
14 | /**
15 | * Hardware ID (Should be unique)
16 | */
17 | public static final char HWID = 0x0004;
18 |
19 | public CubotKeyboard(Cubot cubot) {
20 | super(cubot);
21 | }
22 |
23 | public CubotKeyboard(Document document, ControllableUnit cubot) {
24 | super(document, cubot);
25 | }
26 |
27 | @Override
28 | public char getId() {
29 | return HWID;
30 | }
31 |
32 | @Override
33 | public void handleInterrupt(Status status) {
34 |
35 | int a = getCpu().getRegisterSet().getRegister("A").getValue();
36 |
37 | if (a == KEYBOARD_CLEAR_BUFFER) {
38 |
39 | cubot.clearKeyboardBuffer();
40 |
41 | } else if (a == KEYBOARD_FETCH_KEY) {
42 | //pop
43 | int key = 0;
44 | if (cubot.getKeyboardBuffer().size() > 0) {
45 | key = cubot.getKeyboardBuffer().get(0);
46 | cubot.getKeyboardBuffer().remove(0);
47 | }
48 |
49 | getCpu().getRegisterSet().getRegister("B").setValue(key);
50 |
51 | }
52 |
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/Server/src/main/java/net/simon987/server/game/debug/KillAllCommandListener.java:
--------------------------------------------------------------------------------
1 | package net.simon987.server.game.debug;
2 |
3 | import net.simon987.server.GameServer;
4 | import net.simon987.server.event.DebugCommandEvent;
5 | import net.simon987.server.event.GameEvent;
6 | import net.simon987.server.event.GameEventListener;
7 | import net.simon987.server.game.objects.GameObject;
8 | import net.simon987.server.game.world.World;
9 |
10 | import java.util.ArrayList;
11 | import java.util.Arrays;
12 |
13 | public class KillAllCommandListener implements GameEventListener {
14 |
15 | @Override
16 | public Class getListenedEventType() {
17 | return DebugCommandEvent.class;
18 | }
19 |
20 | @Override
21 | public void handle(GameEvent event) {
22 |
23 | DebugCommandEvent e = (DebugCommandEvent) event;
24 |
25 | if (e.getName().equals("killAll")) {
26 |
27 | World world = GameServer.INSTANCE.getGameUniverse().getWorld(e.getInt("worldX"), e.getInt("worldY"),
28 | false, e.getString("dimension"));
29 |
30 | try {
31 |
32 | ArrayList
Used to interact with the World using hardware
11 | */
12 | public class HwiInstruction extends Instruction {
13 |
14 | public static final int OPCODE = 9;
15 |
16 | private CPU cpu;
17 |
18 | public HwiInstruction(CPU cpu) {
19 | super("hwi", OPCODE);
20 | this.cpu = cpu;
21 | }
22 |
23 | @Override
24 | public Status execute(Target src, int srcIndex, Status status) {
25 | status.setErrorFlag(cpu.getHardwareHost().hardwareInterrupt(src.get(srcIndex), cpu.getStatus()));
26 |
27 | return status;
28 | }
29 |
30 | @Override
31 | public Status execute(int src, Status status) {
32 |
33 | status.setErrorFlag(cpu.getHardwareHost().hardwareInterrupt(src, cpu.getStatus()));
34 |
35 | return status;
36 | }
37 |
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/Server/src/main/java/net/simon987/server/game/debug/CreateWorldCommandListener.java:
--------------------------------------------------------------------------------
1 | package net.simon987.server.game.debug;
2 |
3 | import net.simon987.server.GameServer;
4 | import net.simon987.server.event.DebugCommandEvent;
5 | import net.simon987.server.event.GameEvent;
6 | import net.simon987.server.event.GameEventListener;
7 | import net.simon987.server.game.world.World;
8 |
9 | public class CreateWorldCommandListener implements GameEventListener {
10 |
11 | @Override
12 | public Class getListenedEventType() {
13 | return DebugCommandEvent.class;
14 | }
15 |
16 | @Override
17 | public void handle(GameEvent event) {
18 |
19 | DebugCommandEvent e = (DebugCommandEvent) event;
20 |
21 | if (e.getName().equals("createWorld")) {
22 |
23 | World world = GameServer.INSTANCE.getGameUniverse().getWorld(e.getInt("worldX"), e.getInt("worldY"),
24 | true, e.getString("dimension"));
25 |
26 | if (world != null) {
27 |
28 | e.reply("Success");
29 |
30 | } else {
31 | e.reply("Couldn't create world");
32 | }
33 | }
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/Server/src/main/java/net/simon987/server/crypto/CryptoProvider.java:
--------------------------------------------------------------------------------
1 | package net.simon987.server.crypto;
2 |
3 | public class CryptoProvider{
4 |
5 | public static final int NO_CYPHER = 0x0000;
6 | public static final int CAESAR_CYPHER = 0x0001;
7 | public static final int VIGENERE_CYPHER = 0x0002;
8 | public static final int AUTOKEY_CYPHER = 0x0003;
9 |
10 | public static final int PASSWORD_LENGTH = 8; //Same as CubotComPort.MESSAGE_LENGTH
11 |
12 | private String charset;
13 | private RandomStringGenerator passwordGenerator;
14 |
15 | public CryptoProvider(String charset){
16 | this.charset = charset;
17 | this.passwordGenerator = new RandomStringGenerator(PASSWORD_LENGTH, charset);
18 | }
19 |
20 | public CryptoProvider(){
21 | this(RandomStringGenerator.ALPHANUMERIC_CHARSET);
22 | }
23 |
24 | public Cypher getCypher(int cypherId){
25 | switch (cypherId){
26 | case NO_CYPHER:
27 | return new NoCypher(charset);
28 | case CAESAR_CYPHER:
29 | return new CaesarCypher(charset);
30 | case VIGENERE_CYPHER:
31 | return new VigenereCypher(charset);
32 | case AUTOKEY_CYPHER:
33 | return new AutokeyCypher(charset);
34 | default:
35 | return null;
36 | }
37 | }
38 |
39 | }
--------------------------------------------------------------------------------
/Server/src/main/java/net/simon987/server/game/debug/MoveObjCommandListener.java:
--------------------------------------------------------------------------------
1 | package net.simon987.server.game.debug;
2 |
3 | import net.simon987.server.GameServer;
4 | import net.simon987.server.event.DebugCommandEvent;
5 | import net.simon987.server.event.GameEvent;
6 | import net.simon987.server.event.GameEventListener;
7 | import net.simon987.server.game.objects.GameObject;
8 |
9 | public class MoveObjCommandListener implements GameEventListener {
10 |
11 | @Override
12 | public Class getListenedEventType() {
13 | return DebugCommandEvent.class;
14 | }
15 |
16 | @Override
17 | public void handle(GameEvent event) {
18 |
19 | DebugCommandEvent e = (DebugCommandEvent) event;
20 |
21 | if (e.getName().equals("moveObj")) {
22 |
23 | GameObject object = GameServer.INSTANCE.getGameUniverse().getObject(e.getObjectId("objectId"));
24 |
25 | if (object != null) {
26 |
27 | object.setX(e.getInt("x"));
28 | object.setY(e.getInt("y"));
29 |
30 | e.reply("Success");
31 | } else {
32 | e.reply("Object not found: " + e.getLong("objectId"));
33 | }
34 | }
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/Plugin NPC/src/main/java/net/simon987/npcplugin/event/CpuInitialisationListener.java:
--------------------------------------------------------------------------------
1 | package net.simon987.npcplugin.event;
2 |
3 | import net.simon987.npcplugin.RadioReceiverHardware;
4 | import net.simon987.server.assembly.CPU;
5 | import net.simon987.server.event.CpuInitialisationEvent;
6 | import net.simon987.server.event.GameEvent;
7 | import net.simon987.server.event.GameEventListener;
8 | import net.simon987.server.game.objects.ControllableUnit;
9 | import net.simon987.server.game.objects.HardwareHost;
10 |
11 | public class CpuInitialisationListener implements GameEventListener {
12 | @Override
13 | public Class getListenedEventType() {
14 | return CpuInitialisationEvent.class;
15 | }
16 |
17 |
18 | @Override
19 | public void handle(GameEvent event) {
20 | CPU cpu = (CPU) event.getSource();
21 | ControllableUnit controllableUnit = ((CpuInitialisationEvent) event).getUnit();
22 | cpu.setHardwareHost((HardwareHost) controllableUnit);
23 |
24 | RadioReceiverHardware radioHw = new RadioReceiverHardware(controllableUnit);
25 | radioHw.setCpu(cpu);
26 |
27 | cpu.getHardwareHost().attachHardware(radioHw, RadioReceiverHardware.DEFAULT_ADDRESS);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Plugin NPC/src/main/java/net/simon987/npcplugin/ExecuteCpuTask.java:
--------------------------------------------------------------------------------
1 | package net.simon987.npcplugin;
2 |
3 | import net.simon987.server.GameServer;
4 | import net.simon987.server.game.objects.Action;
5 |
6 | public class ExecuteCpuTask extends NPCTask {
7 |
8 | private static final int MAX_EXEC_TIME = GameServer.INSTANCE.getConfig().getInt("npc_exec_time");
9 |
10 | @Override
11 | public boolean checkCompleted() {
12 | return false;
13 | }
14 |
15 | @Override
16 | public void tick(NonPlayerCharacter npc) {
17 |
18 | HackedNPC hNpc = (HackedNPC) npc;
19 |
20 | //Execute code
21 | int timeout = Math.min(hNpc.getEnergy(), MAX_EXEC_TIME);
22 | hNpc.getCpu().reset();
23 | int cost = hNpc.getCpu().execute(timeout);
24 | hNpc.spendEnergy(cost);
25 |
26 | if (hNpc.getCurrentAction() == Action.WALKING) {
27 | if (hNpc.spendEnergy(100)) {
28 | if (hNpc.incrementLocation()) {
29 | //Couldn't walk
30 | hNpc.setCurrentAction(Action.IDLE);
31 | }
32 | } else {
33 | hNpc.setCurrentAction(Action.IDLE);
34 | }
35 | }
36 |
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Plugin NPC/src/main/java/net/simon987/npcplugin/event/VaultCompleteListener.java:
--------------------------------------------------------------------------------
1 | package net.simon987.npcplugin.event;
2 |
3 | import net.simon987.server.event.GameEvent;
4 | import net.simon987.server.event.GameEventListener;
5 | import net.simon987.server.game.objects.ControllableUnit;
6 | import net.simon987.server.game.objects.GameObject;
7 | import net.simon987.server.logging.LogManager;
8 |
9 | public class VaultCompleteListener implements GameEventListener {
10 | @Override
11 | public Class getListenedEventType() {
12 | return VaultCompleteEvent.class;
13 | }
14 |
15 | @Override
16 | public void handle(GameEvent event) {
17 | VaultCompleteEvent vaultCompleteEvent = (VaultCompleteEvent) event;
18 | GameObject object = vaultCompleteEvent.getSource();
19 | if (object instanceof ControllableUnit) {
20 | LogManager.LOGGER.info(((ControllableUnit) object).getParent().getUsername() + " Completed vault " +
21 | object.getWorld().getDimension());
22 |
23 | ((ControllableUnit) object).getParent().getStats().addToStringSet("completedVaults",
24 | vaultCompleteEvent.getPortal().getWorld().getDimension());
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Plugin Plant/src/main/java/net/simon987/biomassplugin/BiomassPlugin.java:
--------------------------------------------------------------------------------
1 | package net.simon987.biomassplugin;
2 |
3 | import net.simon987.biomassplugin.event.ObjectDeathListener;
4 | import net.simon987.biomassplugin.event.WorldCreationListener;
5 | import net.simon987.biomassplugin.event.WorldUpdateListener;
6 | import net.simon987.server.GameServer;
7 | import net.simon987.server.IServerConfiguration;
8 | import net.simon987.server.game.objects.GameRegistry;
9 | import net.simon987.server.logging.LogManager;
10 | import net.simon987.server.plugin.ServerPlugin;
11 |
12 |
13 | public class BiomassPlugin extends ServerPlugin {
14 |
15 |
16 | @Override
17 | public void init(GameServer gameServer) {
18 |
19 | IServerConfiguration config = gameServer.getConfig();
20 | GameRegistry registry = gameServer.getRegistry();
21 |
22 | listeners.add(new WorldCreationListener());
23 | listeners.add(new WorldUpdateListener(config));
24 | listeners.add(new ObjectDeathListener(config));
25 |
26 | registry.registerGameObject(BiomassBlob.class);
27 | registry.registerItem(ItemBiomass.ID, ItemBiomass.class);
28 |
29 | LogManager.LOGGER.info("(BiomassPlugin) Initialised Biomass plugin");
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Server/src/main/java/net/simon987/server/assembly/instruction/PopfInstruction.java:
--------------------------------------------------------------------------------
1 | package net.simon987.server.assembly.instruction;
2 |
3 | import net.simon987.server.assembly.CPU;
4 | import net.simon987.server.assembly.Instruction;
5 | import net.simon987.server.assembly.Register;
6 | import net.simon987.server.assembly.Status;
7 |
8 | /**
9 | * Pops a single word off the top of the stack and sets the CPU flags to it.
10 | */
11 | public class PopfInstruction extends Instruction {
12 |
13 | public static final int OPCODE = 44;
14 |
15 | private CPU cpu;
16 |
17 | public PopfInstruction(CPU cpu) {
18 | super("popf", OPCODE);
19 |
20 | this.cpu = cpu;
21 | }
22 |
23 | @Override
24 | public Status execute(Status status) {
25 |
26 | Register sp = cpu.getRegisterSet().getRegister("SP");
27 |
28 | // Get the word on the top of the stack
29 | char flags = (char) cpu.getMemory().get(sp.getValue());
30 |
31 | // Overwrite the CPU flags
32 | status.fromByte(flags);
33 |
34 | // Increment SP
35 | sp.setValue(sp.getValue() + 1);
36 |
37 | return status;
38 | }
39 |
40 | public boolean noOperandsValid() {
41 | return true;
42 | }
43 | }
--------------------------------------------------------------------------------
/Server/src/main/java/net/simon987/server/web/FloppyDownloadRoute.java:
--------------------------------------------------------------------------------
1 | package net.simon987.server.web;
2 |
3 | import net.simon987.server.GameServer;
4 | import net.simon987.server.logging.LogManager;
5 | import spark.Request;
6 | import spark.Response;
7 | import spark.Route;
8 |
9 | public class FloppyDownloadRoute implements Route {
10 |
11 | @Override
12 | public Object handle(Request request, Response response) {
13 |
14 | String username = request.session().attribute("username");
15 |
16 | if (username != null) {
17 |
18 | response.header("Content-Type", "application/octet-stream");
19 | response.header("Content-Disposition", "filename=\"floppy.bin\"");
20 |
21 | try {
22 | return GameServer.INSTANCE.getGameUniverse().getUser(username).getControlledUnit().getFloppyData().getBytes();
23 | } catch (Exception e) {
24 | String message = "Encountered exception while reading floppy data: " + e.getMessage();
25 |
26 | LogManager.LOGGER.severe(message);
27 | return message;
28 | }
29 |
30 | } else {
31 | response.status(403);
32 | return "Not logged in";
33 | }
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Server/src/main/java/net/simon987/server/game/debug/SetTileAtCommandListener.java:
--------------------------------------------------------------------------------
1 | package net.simon987.server.game.debug;
2 |
3 | import net.simon987.server.GameServer;
4 | import net.simon987.server.event.DebugCommandEvent;
5 | import net.simon987.server.event.GameEvent;
6 | import net.simon987.server.event.GameEventListener;
7 | import net.simon987.server.game.world.World;
8 |
9 | public class SetTileAtCommandListener implements GameEventListener {
10 |
11 | @Override
12 | public Class getListenedEventType() {
13 | return DebugCommandEvent.class;
14 | }
15 |
16 | @Override
17 | public void handle(GameEvent event) {
18 |
19 | DebugCommandEvent e = (DebugCommandEvent) event;
20 |
21 | if (e.getName().equals("setTileAt")) {
22 |
23 | World world = GameServer.INSTANCE.getGameUniverse().getWorld(e.getInt("worldX"), e.getInt("worldY"),
24 | false, e.getString("dimension"));
25 |
26 | if (world != null) {
27 |
28 | world.getTileMap().setTileAt(e.getInt("newTile"), e.getInt("x"), e.getInt("y"));
29 | e.reply("Success");
30 |
31 | } else {
32 | e.reply("Error: World is uncharted");
33 | }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Server/src/main/java/net/simon987/server/game/world/DayNightCycle.java:
--------------------------------------------------------------------------------
1 | package net.simon987.server.game.world;
2 |
3 | import net.simon987.server.event.GameEvent;
4 | import net.simon987.server.event.GameEventListener;
5 | import net.simon987.server.event.TickEvent;
6 |
7 | public class DayNightCycle implements GameEventListener {
8 |
9 | /**
10 | * Length of an hour in ticks
11 | */
12 | private static final int HOUR_LENGTH = 16;
13 |
14 | //Current time of the day (0-23)
15 | private int currentDayTime;
16 |
17 | //Current light intensity (0-10)
18 | private int sunIntensity;
19 |
20 | @Override
21 | public Class getListenedEventType() {
22 | return TickEvent.class;
23 | }
24 |
25 | @Override
26 | public void handle(GameEvent event) {
27 |
28 | currentDayTime = (int) ((TickEvent) event).getTime() / HOUR_LENGTH % 24;
29 |
30 | // -0.25x² + 6x - 27 with a minimum of 1
31 | sunIntensity = Math.max((int) Math.round((-(0.25 * currentDayTime * currentDayTime) + (6 * currentDayTime) - 27)), 0) + 1;
32 | }
33 |
34 | public int getCurrentDayTime() {
35 | return currentDayTime;
36 | }
37 |
38 | public int getSunIntensity() {
39 | return sunIntensity;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Server/src/main/java/net/simon987/server/websocket/OnlineUserManager.java:
--------------------------------------------------------------------------------
1 | package net.simon987.server.websocket;
2 |
3 | import org.eclipse.jetty.websocket.api.Session;
4 |
5 | import java.util.ArrayList;
6 |
7 | public class OnlineUserManager {
8 |
9 | /**
10 | * List of online users.
11 | */
12 | private ArrayListLeaderboard
15 |
16 |
36 |
17 |
23 |
24 |
25 | #foreach($row in $stats)
26 | Player
18 | Completed vaults
19 | Death count
20 | Total execution time (ms)
21 | Walk distance
22 |
27 |
33 | #end
34 |
35 | $row.getKey().getUsername()
28 | $row.getValue().get("completedVaults")
29 | $row.getValue().get("death")
30 | $row.getValue().get("executionTime")
31 | $row.getValue().get("walkDistance")
32 |
12 | * FLAGS are not altered
13 | */
14 | public class CallInstruction extends Instruction {
15 |
16 | public static final int OPCODE = 21;
17 |
18 | private CPU cpu;
19 |
20 | public CallInstruction(CPU cpu) {
21 | super("call", OPCODE);
22 |
23 | this.cpu = cpu;
24 | }
25 |
26 | @Override
27 | public Status execute(Target src, int srcIndex, Status status) {
28 | //Push ip
29 | cpu.getRegisterSet().set(7, cpu.getRegisterSet().get(7) - 1); //Decrement SP (stack grows towards smaller addresses)
30 | cpu.getMemory().set(cpu.getRegisterSet().get(7), cpu.getIp());
31 |
32 | //Jmp
33 | cpu.setIp((char) src.get(srcIndex));
34 |
35 | return status;
36 | }
37 |
38 | @Override
39 | public Status execute(int src, Status status) {
40 | //Push ip
41 | cpu.getRegisterSet().set(7, cpu.getRegisterSet().get(7) - 1); //Decrement SP (stack grows towards smaller addresses)
42 | cpu.getMemory().set(cpu.getRegisterSet().get(7), cpu.getIp());
43 |
44 | //Jmp
45 | cpu.setIp((char) src);
46 |
47 | return status;
48 | }
49 | }
--------------------------------------------------------------------------------
/Server/src/main/java/net/simon987/server/game/debug/HealObjCommandListener.java:
--------------------------------------------------------------------------------
1 | package net.simon987.server.game.debug;
2 |
3 | import net.simon987.server.GameServer;
4 | import net.simon987.server.event.DebugCommandEvent;
5 | import net.simon987.server.event.GameEvent;
6 | import net.simon987.server.event.GameEventListener;
7 | import net.simon987.server.game.objects.Attackable;
8 | import net.simon987.server.game.objects.GameObject;
9 |
10 |
11 | public class HealObjCommandListener implements GameEventListener {
12 |
13 | @Override
14 | public Class getListenedEventType() {
15 | return DebugCommandEvent.class;
16 | }
17 |
18 | @Override
19 | public void handle(GameEvent event) {
20 |
21 | DebugCommandEvent e = (DebugCommandEvent) event;
22 |
23 | if (e.getName().equals("healObj")) {
24 |
25 | GameObject object = GameServer.INSTANCE.getGameUniverse().getObject(e.getObjectId("objectId"));
26 |
27 | if (object != null) {
28 |
29 | if (object instanceof Attackable) {
30 |
31 | int oldHp = ((Attackable) object).getHp();
32 | int maxHp = ((Attackable) object).getMaxHp();
33 | ((Attackable) object).heal(e.getInt("amount"));
34 |
35 | e.reply("Success: " + oldHp + "/" + maxHp + " -> " + ((Attackable) object).getHp() + "/" + maxHp);
36 | } else {
37 | e.reply("Object is not Attackable");
38 | }
39 |
40 | } else {
41 | e.reply("Object not found: " + e.getLong("objectId"));
42 | }
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Server/src/main/java/net/simon987/server/assembly/instruction/XorInstruction.java:
--------------------------------------------------------------------------------
1 | package net.simon987.server.assembly.instruction;
2 |
3 | import net.simon987.server.assembly.Instruction;
4 | import net.simon987.server.assembly.Status;
5 | import net.simon987.server.assembly.Target;
6 | import net.simon987.server.assembly.Util;
7 |
8 |
9 | public class XorInstruction extends Instruction {
10 |
11 | /**
12 | * Opcode of the instruction
13 | */
14 | public static final int OPCODE = 38;
15 |
16 | public XorInstruction() {
17 | super("xor", OPCODE);
18 | }
19 |
20 | @Override
21 | public Status execute(Target dst, int dstIndex, Target src, int srcIndex, Status status) {
22 |
23 | int a = (char) dst.get(dstIndex);
24 | int b = (char) src.get(srcIndex);
25 |
26 |
27 | int result = (a ^ b);
28 |
29 | status.setSignFlag(Util.checkSign16(result));
30 | status.setZeroFlag((char) result == 0);
31 | status.setOverflowFlag(false);
32 | status.setCarryFlag(false);
33 |
34 | dst.set(dstIndex, result);
35 |
36 | return status;
37 | }
38 |
39 | @Override
40 | public Status execute(Target dst, int dstIndex, int src, Status status) {
41 | int a = (char) dst.get(dstIndex);
42 | int b = (char) src;
43 |
44 |
45 | int result = (a ^ b);
46 |
47 | status.setSignFlag(Util.checkSign16(result));
48 | status.setZeroFlag((char) result == 0);
49 | status.setOverflowFlag(false);
50 | status.setCarryFlag(false);
51 |
52 | dst.set(dstIndex, result);
53 |
54 | return status;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/Server/src/main/java/net/simon987/server/assembly/instruction/SubInstruction.java:
--------------------------------------------------------------------------------
1 | package net.simon987.server.assembly.instruction;
2 |
3 | import net.simon987.server.assembly.Instruction;
4 | import net.simon987.server.assembly.Status;
5 | import net.simon987.server.assembly.Target;
6 | import net.simon987.server.assembly.Util;
7 |
8 | public class SubInstruction extends Instruction {
9 |
10 | public static final int OPCODE = 3;
11 |
12 | public SubInstruction() {
13 | super("sub", OPCODE);
14 | }
15 |
16 | @Override
17 | public Status execute(Target dst, int dstIndex, Target src, int srcIndex, Status status) {
18 |
19 | int a = (char) dst.get(dstIndex);
20 | int b = (char) src.get(srcIndex);
21 |
22 | int result = a - b;
23 |
24 | status.setSignFlag(Util.checkSign16(result));
25 | status.setZeroFlag((char) result == 0);
26 | status.setOverflowFlag(Util.checkOverFlowSub16(a, b));
27 | status.setCarryFlag(Util.checkCarry16(result));
28 |
29 | dst.set(dstIndex, result);
30 |
31 | return status;
32 | }
33 |
34 | @Override
35 | public Status execute(Target dst, int dstIndex, int src, Status status) {
36 |
37 | int a = (char) dst.get(dstIndex);
38 | int b = (char) src;
39 |
40 | int result = a - b;
41 |
42 | status.setSignFlag(Util.checkSign16(result));
43 | status.setZeroFlag((char) result == 0);
44 | status.setOverflowFlag(Util.checkOverFlowSub16(a, b));
45 | status.setCarryFlag(Util.checkCarry16(result));
46 |
47 | dst.set(dstIndex, result);
48 |
49 | return status;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/Server/src/main/java/net/simon987/server/game/debug/DamageObjCommandListener.java:
--------------------------------------------------------------------------------
1 | package net.simon987.server.game.debug;
2 |
3 | import net.simon987.server.GameServer;
4 | import net.simon987.server.event.DebugCommandEvent;
5 | import net.simon987.server.event.GameEvent;
6 | import net.simon987.server.event.GameEventListener;
7 | import net.simon987.server.game.objects.Attackable;
8 | import net.simon987.server.game.objects.GameObject;
9 |
10 |
11 | public class DamageObjCommandListener implements GameEventListener {
12 |
13 | @Override
14 | public Class getListenedEventType() {
15 | return DebugCommandEvent.class;
16 | }
17 |
18 | @Override
19 | public void handle(GameEvent event) {
20 |
21 | DebugCommandEvent e = (DebugCommandEvent) event;
22 |
23 | if (e.getName().equals("damageObj")) {
24 |
25 | GameObject object = GameServer.INSTANCE.getGameUniverse().getObject(e.getObjectId("objectId"));
26 |
27 | if (object != null) {
28 |
29 | if (object instanceof Attackable) {
30 |
31 | int oldHp = ((Attackable) object).getHp();
32 | int maxHp = ((Attackable) object).getMaxHp();
33 | ((Attackable) object).damage(e.getInt("amount"));
34 |
35 | e.reply("Success: " + oldHp + "/" + maxHp + " -> " + ((Attackable) object).getHp() + "/" + maxHp);
36 | } else {
37 | e.reply("Object is not Attackable");
38 | }
39 |
40 | } else {
41 | e.reply("Object not found: " + e.getLong("objectId"));
42 | }
43 | }
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/Server/src/main/java/net/simon987/server/game/debug/UserInfoCommandListener.java:
--------------------------------------------------------------------------------
1 | package net.simon987.server.game.debug;
2 |
3 | import net.simon987.server.GameServer;
4 | import net.simon987.server.event.DebugCommandEvent;
5 | import net.simon987.server.event.GameEvent;
6 | import net.simon987.server.event.GameEventListener;
7 | import net.simon987.server.game.objects.ControllableUnit;
8 | import net.simon987.server.user.User;
9 |
10 | public class UserInfoCommandListener implements GameEventListener {
11 |
12 | @Override
13 | public Class getListenedEventType() {
14 | return DebugCommandEvent.class;
15 | }
16 |
17 | @Override
18 | public void handle(GameEvent event) {
19 |
20 | DebugCommandEvent e = (DebugCommandEvent) event;
21 |
22 | if (e.getName().equals("userInfo")) {
23 |
24 | User user = GameServer.INSTANCE.getGameUniverse().getUser(e.getString("username"));
25 |
26 | if (user != null) {
27 |
28 | String message = "Showing information for user " + e.getString("username") + "\n";
29 |
30 | message += "isGuest: " + user.isGuest() + "\n";
31 |
32 | ControllableUnit unit = user.getControlledUnit();
33 | message += "ControlledUnit: " + unit.getObjectId() + " at (" + unit.getX() + ", " + unit.getY() + ")\n";
34 |
35 | message += "CPU:" + user.getControlledUnit().getCpu() + "\n";
36 | message += "Code: " + user.getUserCode();
37 |
38 | e.reply(message);
39 |
40 |
41 | } else {
42 | e.reply("User not found");
43 | }
44 | }
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/Plugin Cubot/src/main/java/net/simon987/cubotplugin/event/SetInventoryPosition.java:
--------------------------------------------------------------------------------
1 | package net.simon987.cubotplugin.event;
2 |
3 | import net.simon987.cubotplugin.Cubot;
4 | import net.simon987.cubotplugin.CubotInventory;
5 | import net.simon987.server.GameServer;
6 | import net.simon987.server.event.DebugCommandEvent;
7 | import net.simon987.server.event.GameEvent;
8 | import net.simon987.server.event.GameEventListener;
9 | import net.simon987.server.game.objects.GameObject;
10 |
11 | public class SetInventoryPosition implements GameEventListener {
12 |
13 | @Override
14 | public Class getListenedEventType() {
15 | return DebugCommandEvent.class;
16 | }
17 |
18 | @Override
19 | public void handle(GameEvent event) {
20 |
21 | DebugCommandEvent e = (DebugCommandEvent) event;
22 |
23 | if (e.getName().equals("setInventoryPosition")) {
24 |
25 | GameObject object = GameServer.INSTANCE.getGameUniverse().getObject(e.getObjectId("objectId"));
26 |
27 | if (object != null) {
28 |
29 | if (object instanceof Cubot) {
30 |
31 | int position = e.getInt("position");
32 | CubotInventory inventory = (CubotInventory) ((Cubot) object).getHardware(CubotInventory.class);
33 |
34 | inventory.setPosition(position);
35 | e.reply("Set inventory position to " + position);
36 | } else {
37 | e.reply("Object is not a Cubot");
38 | }
39 |
40 | } else {
41 | e.reply("Object not found: " + e.getLong("objectId"));
42 | }
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------