diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore index e01ebe4..cea9d96 100644 --- a/.gitignore +++ b/.gitignore @@ -1,469 +1,470 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ - -# Visual Studio 2015 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# DNX -project.lock.json -artifacts/ - -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding add-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# TODO: Comment the next line if you want to checkin your web deploy settings -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/packages/* -# except build/, which is used as an MSBuild target. -!**/packages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/packages/repositories.config -# NuGet v3's project.json files produces more ignoreable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.pfx -*.publishsettings -node_modules/ -orleans.codegen.cs - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -*.mdf -*.ldf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# JetBrains Rider -.idea/ -*.sln.imlasd - -################# -## Eclipse -################# - -*.pydevproject -.metadata/ -bin/ -tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties -.classpath -.settings/ -.loadpath -target/ -.project - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# CDT-specific -.cproject - -# PDT-specific -.buildpath - - -################# -## Visual Studio -################# - -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.sln.docstates - -# Build results - -[Dd]ebug/ -[Rr]elease/ -x64/ -build/ -[Bb]in/ -[Oo]bj/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -*_i.c -*_p.c -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.log -*.scc - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -*.ncrunch* -.*crunch*.local.xml - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.Publish.xml -*.pubxml -*.publishproj - -# NuGet Packages Directory -## TODO: If you have NuGet Package Restore enabled, uncomment the next line -#packages/ - -# Windows Azure Build Output -csx -*.build.csdef - -# Windows Store app package directory -AppPackages/ - -# Others -sql/ -*.Cache -ClientBin/ -[Ss]tyle[Cc]op.* -~$* -*~ -*.dbmdl -*.[Pp]ublish.xml -*.pfx -*.publishsettings - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file to a newer -# Visual Studio version. Backup files are not needed, because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -App_Data/*.mdf -App_Data/*.ldf - -############# -## Windows detritus -############# - -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Mac crap -.DS_Store - - -############# -## Python -############# - -*.py[cod] - -# Packages -*.egg -*.egg-info -dist/ -build/ -eggs/ -parts/ -var/ -sdist/ -develop-eggs/ -.installed.cfg - -# Installer logs -pip-log.txt - -# Unit test / coverage reports -.coverage -.tox - -#Translations -*.mo - -#Mr Developer -.mr.developer.cfg -.metadata/* -TheButtonAutoFlair/out/artifacts/Autoflair/Autoflair.jar -*.iml -*.name -.idea/compiler.xml -*.xml +libpxc.so + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.imlasd + +################# +## Eclipse +################# + +*.pydevproject +.metadata/ +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.classpath +.settings/ +.loadpath +target/ +.project + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# PDT-specific +.buildpath + + +################# +## Visual Studio +################# + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results + +[Dd]ebug/ +[Rr]elease/ +x64/ +build/ +[Bb]in/ +[Oo]bj/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.log +*.scc + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml +*.pubxml +*.publishproj + +# NuGet Packages Directory +## TODO: If you have NuGet Package Restore enabled, uncomment the next line +#packages/ + +# Windows Azure Build Output +csx +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml +*.pfx +*.publishsettings + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +App_Data/*.mdf +App_Data/*.ldf + +############# +## Windows detritus +############# + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac crap +.DS_Store + + +############# +## Python +############# + +*.py[cod] + +# Packages +*.egg +*.egg-info +dist/ +build/ +eggs/ +parts/ +var/ +sdist/ +develop-eggs/ +.installed.cfg + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.tox + +#Translations +*.mo + +#Mr Developer +.mr.developer.cfg +.metadata/* +TheButtonAutoFlair/out/artifacts/Autoflair/Autoflair.jar +*.iml +*.name +.idea/compiler.xml diff --git a/README.md b/README.md index f612a90..e06d7a6 100644 --- a/README.md +++ b/README.md @@ -1,49 +1,50 @@ # The Computer -A working modern computer in Minecraft made using VirtualBox, jni4net, C# and Java. No clientside mods required. +A working modern computer in Minecraft made using VirtualBox and Java. No clientside mods required. -I started working on this project on 2015. december 5. However I did not write much code in that time as I had to figure out how things work. -I plan on making a series where I show the whole process of creating this project. +## Video -##Video - -[![Original video](https://img.youtube.com/vi/VxSyDfxPd3s/0.jpg)](https://www.youtube.com/watch?v=VxSyDfxPd3s) +[![Video](https://img.youtube.com/vi/K4t98YUIm4M/0.jpg)](https://www.youtube.com/watch?v=K4t98YUIm4M) ## Installation requirements *Note: only the server host has to meet these requirements.* -### Currently compiled for (and tested on): -*If you don't meet these requirements, you will need to compile the files for yourself. Please help by sending the compiled version to me so more people can download it.* +* A non-Windows OS supported by VirtualBox +* Root (sudo) privileges +* Enough resources to run another OS -* Windows 7 64-bit -* VirtualBox 5 -* Spgiot/Bukkit 1.8/1.9 (with Movecraft for the mouse craft type) -* Microsoft .NET Framework 4.5 +### Tested versions: +*If you don't meet these requirements, you may need to compile the files for yourself. If you do please send the compiled version to me so more people can download it.* + +* OS X; Ubuntu 16.04/18.04 +* VirtualBox 6.0 +* Spgiot/Bukkit 1.12 * Java 8 -### Possibly works with (untested): -* Any version of Windows which supports .NET 4.5 -* Other VirtualBox versions (code modifications are probably necessary) -* Other Spigot/Bukkit versions -* Microsoft .NET Framework 4 (code modifications *are* necessary) -* Other Java versions +*The fast rendering method currently only supports 1.12.2.* -*Due to jni4net support limitations the plugin does not support other operating systems.* +### Tested on: +*The requirements vary greatly depending on what OS you want to run ingame but here are my specs that can run Overwatch in Minecraft.* + +* CPU: Intel® Pentium(R) CPU G3460 @ 3.50GHz × 2 +* RAM: 8 GB +* GPU: NVidia GeForce GTX 650 1 GB + +*Due to VirtualBox Java binding support limitations the plugin does not support Windows currently.* ## Installation -**Warning:** The first loaded world on the server (the one specified in server.properties) will **lose** the first 20 maps, though it might be only a temporary effect, it might restore after the server starts up without the plugin. *(Untested.)* +**Warning:** The first loaded world on the server (the one specified in server.properties) will temporarily **lose** the first 20 maps, although it will be back to normal if the server is loaded without the plugin. -* Install all the requirements -* Add a virtual PC if you don't have any (the first one will be started) +* Install VirtualBox +* *Using sudo,* add a virtual PC if you don't have any (the first one will be started by default) * Install an OS and Guest Additions, if you haven't already * Put the jar file into /plugins directory -* Make sure your server is set to a world that you don't mind your maps deleted from -* Start your server +* *Using sudo,* start your server ## Usage -*Please give appropriate credit and link to this page if you use this machine in one of your videos/creations/etc. You can also send me your video so I can put it here.* +*Please give appropriate credit and link to this page if you use this machine in one of your videos/creations/etc.* ### Display -*Note:* You can create as many displays as you want, but all of them will show the same. +*Note: You can create as many displays as you want, but all of them will show the same currently.* To create a display, make a 5 wide 4 high wall of item frames, then put the maps 0-19 on them starting from the top left and going downwards. You can give the maps with this command: @@ -54,22 +55,40 @@ Where you'll need to increment 0 for each map. It is also recommended to start the virtual machine first so you can distinguish the different parts of the display while placing it. #### Keyboard -You can either open the chat keyboard using /computer input key, or you can use /computer key \. You can find key names [here](https://github.com/NorbiPeti/VirtualComputer/blob/master/VirtualComputerSender/VirtualKeys.cs). Note that not all keys are currently supported. +You can either open the chat keyboard using /computer input key, or you can use /computer key \. You can find key names [here](https://github.com/NorbiPeti/VirtualComputer/blob/directvb/VirtualComputer/src/sznp/virtualcomputer/Scancode.java). #### Mouse You can "lock" the physical mouse to the virtual one with /computer input mouse, or you can move the mouse (including scrolling) with /computer mouse \ \ \ \, where dx specifies the amount of pixels to move right, and dy specifies the amount of pixels to move down, while dz and dw specify the scrolling vertically (positive values scroll down) and horizontally. To set the locked mouse speed, use /computer input mspeed \. The difference in look position will be multiplied with this number. Recommended values are between 1 and 10 (inclusive). Default: 1. -You can also use the "mouse" Movecraft craft type to move the mouse, though it's a bit unreliable. - -You can press a mouse button with /computer mouse . For example: /computer mouse leftbutton. You can find all the button names [here](https://github.com/NorbiPeti/VirtualComputer/blob/master/VirtualComputerSender/MouseBS.cs). +You can press a mouse button with /computer mouse . For example: /computer mouse leftbutton. Usable key names: +* LeftButton +* RightButton +* MiddleButton +* WheelUp +* WheelDown +* XButton1 +* XButton2 #### Sounds -Due to the way it works, it automatically plays every sound from the virtual machine **on the host computer**. This is built into VBoxHeadless, it seems. In order to make the sounds play for every connected player, we'd need a clientside mod. +Due to the way it works, it automatically plays every sound from the virtual machine **on the host computer**. This is built into the VM, it seems. In order to make the sounds play for every connected player, we'd need a clientside mod. ### Special thanks: -* The creators of VirtualBox for making it open-source and easy to use (though I had minor issues but those was because .NET had a few marshaling errors with booleans and that I needed to learn how machines work - especially keyboards) -* The creators of jni4net, after I figured it out, it was quite easy to use -* Minecraft player iie for testing and suggesting the Movecraft mouse and other ideas not related to this project -* The creator(s) of SketchMap, a plugin which I edited to create the display +* The creators of VirtualBox for making it open-source and kind of easy to use (though I had minor issues as the documentation doesn't really tell me how to write a new frontend :P and that I needed to learn how machines work - especially keyboards) +* @iiegit for testing and more testing for the non-Windows version and helping a lot to get it on /r/sequence + +# Known issues +## Port remains open (cannot bind to port) +**Fix:** Close all VirtualBox instances and wait 10 seconds. + +**Cause:** Possibly it happens because the plugin creates the VBoxSVC process, which thus inherits file descriptors such as the open server port. + +## OpenCL error + +``` +Check your environment. Failed to load codegen native library or possibly failed to locate opencl native library (opencl.dll/opencl.so). Ensure that OpenCL is in your PATH (windows) or in LD_LIBRARY_PATH (linux). +``` + +**Fix:** On Ubuntu you can install the needed library with `sudo apt install ocl-icd-opencl-dev` + diff --git a/VirtualComputer/.classpath b/VirtualComputer/.classpath index cc16eb5..be86bf9 100644 --- a/VirtualComputer/.classpath +++ b/VirtualComputer/.classpath @@ -16,6 +16,5 @@ - diff --git a/VirtualComputer/Interop.VirtualBox.dll b/VirtualComputer/Interop.VirtualBox.dll deleted file mode 100644 index 27d7e9c..0000000 Binary files a/VirtualComputer/Interop.VirtualBox.dll and /dev/null differ diff --git a/VirtualComputer/VirtualComputerSender.dll b/VirtualComputer/VirtualComputerSender.dll deleted file mode 100644 index bb667e6..0000000 Binary files a/VirtualComputer/VirtualComputerSender.dll and /dev/null differ diff --git a/VirtualComputer/VirtualComputerSender.j4n.dll b/VirtualComputer/VirtualComputerSender.j4n.dll deleted file mode 100644 index 2455c69..0000000 Binary files a/VirtualComputer/VirtualComputerSender.j4n.dll and /dev/null differ diff --git a/VirtualComputer/VirtualComputerSender.j4n.jar b/VirtualComputer/VirtualComputerSender.j4n.jar deleted file mode 100644 index 651b657..0000000 Binary files a/VirtualComputer/VirtualComputerSender.j4n.jar and /dev/null differ diff --git a/VirtualComputer/dependency-reduced-pom.xml b/VirtualComputer/dependency-reduced-pom.xml new file mode 100644 index 0000000..3e0d028 --- /dev/null +++ b/VirtualComputer/dependency-reduced-pom.xml @@ -0,0 +1,144 @@ + + + 4.0.0 + io.github.NorbiPeti + VirtualComputer + 2.0-SNAPSHOT + + + + maven-compiler-plugin + 3.5.1 + + 1.8 + 1.8 + + -g + + + + + maven-shade-plugin + 2.4.2 + + + package + + shade + + + + + + + + + + XPCOM + + + + maven-shade-plugin + + + package + + shade + + + + + org.virtualbox:VirtualBox-MSCOM + + + + + + + + + + + MSCOM + + + + maven-shade-plugin + + + package + + shade + + + + + org.virtualbox:VirtualBox + + + + + + + + + + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + repo + file://${basedir}/repo + + + + + org.spigotmc + spigot-api + 1.12-R0.1-SNAPSHOT + provided + + + commons-lang + commons-lang + + + json-simple + com.googlecode.json-simple + + + guava + com.google.guava + + + gson + com.google.code.gson + + + snakeyaml + org.yaml + + + bungeecord-chat + net.md-5 + + + + + org.virtualbox + VirtualBox-MSCOM + 6.0 + compile + + + org.bukkit + craftbukkit + 1.12.2-R0.1-SNAPSHOT + provided + + + + diff --git a/VirtualComputer/fix/IDisplaySourceBitmap.class b/VirtualComputer/fix/IDisplaySourceBitmap.class new file mode 100644 index 0000000..e22aab7 Binary files /dev/null and b/VirtualComputer/fix/IDisplaySourceBitmap.class differ diff --git a/VirtualComputer/fix/README b/VirtualComputer/fix/README new file mode 100644 index 0000000..e2322da --- /dev/null +++ b/VirtualComputer/fix/README @@ -0,0 +1,3 @@ +If a new version is released, copy this to the JAR into org/mozilla/interfaces +This fixes the source bitmap pointer return type in the Java API. + diff --git a/VirtualComputer/jni4net.j-0.8.8.0.jar b/VirtualComputer/jni4net.j-0.8.8.0.jar deleted file mode 100644 index 922c2ad..0000000 Binary files a/VirtualComputer/jni4net.j-0.8.8.0.jar and /dev/null differ diff --git a/VirtualComputer/jni4net.n-0.8.8.0.dll b/VirtualComputer/jni4net.n-0.8.8.0.dll deleted file mode 100644 index 2c7dc61..0000000 Binary files a/VirtualComputer/jni4net.n-0.8.8.0.dll and /dev/null differ diff --git a/VirtualComputer/jni4net.n.w64.v40-0.8.8.0.dll b/VirtualComputer/jni4net.n.w64.v40-0.8.8.0.dll deleted file mode 100644 index 6ff98f1..0000000 Binary files a/VirtualComputer/jni4net.n.w64.v40-0.8.8.0.dll and /dev/null differ diff --git a/VirtualComputer/lombok.config b/VirtualComputer/lombok.config new file mode 100644 index 0000000..d959b09 --- /dev/null +++ b/VirtualComputer/lombok.config @@ -0,0 +1 @@ +lombok.var.flagUsage = ALLOW diff --git a/VirtualComputer/plugin.yml b/VirtualComputer/plugin.yml deleted file mode 100644 index 9500aab..0000000 --- a/VirtualComputer/plugin.yml +++ /dev/null @@ -1,8 +0,0 @@ -name: VirtualComputer -main: sznp.virtualcomputer.PluginMain -version: 1.1 -commands: - computer: - usage: Use /computer start|stop - alias: c -softdepend: [Movecraft] diff --git a/VirtualComputer/pom.xml b/VirtualComputer/pom.xml index ed7b5b8..fc2f807 100644 --- a/VirtualComputer/pom.xml +++ b/VirtualComputer/pom.xml @@ -1,26 +1,10 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 io.github.NorbiPeti VirtualComputer - 1.2-SNAPSHOT + 2.0-SNAPSHOT - src - - - src - - **/*.java - - - - . - - *.dll - *.yml - - - maven-compiler-plugin @@ -28,6 +12,9 @@ 1.8 1.8 + + -g + @@ -41,16 +28,6 @@ shade - - - org.virtualbox:VirtualBox - - - - - - - @@ -71,24 +48,103 @@ org.spigotmc spigot-api - 1.9.2-R0.1-SNAPSHOT + 1.12-R0.1-SNAPSHOT provided - - net.countercraft - Movecraft - 3.0.0 - provided - - - net.sf.jni4net - jni4net.j - 0.8.8.0 - org.virtualbox VirtualBox - 5.1 + 6.0 + + + org.virtualbox + VirtualBox-MSCOM + 6.0 + + + org.bukkit + craftbukkit + 1.12.2-R0.1-SNAPSHOT + provided + + + + net.java.dev.jna + jna + 4.4.0 + + + + com.github.jnr + jnr-ffi + 2.1.7 + + + com.aparapi + aparapi + 1.10.0 + + + org.projectlombok + lombok + 1.16.16 + + + com.google.code.findbugs + jsr305 + 3.0.0 + + + XPCOM + + + + maven-shade-plugin + + + package + + shade + + + + + org.virtualbox:VirtualBox-MSCOM + + + + + + + + + + + MSCOM + + + + maven-shade-plugin + + + package + + shade + + + + + org.virtualbox:VirtualBox + + + + + + + + + + \ No newline at end of file diff --git a/VirtualComputer/repo/io/github/NorbiPeti/SenderBridge/1.0/SenderBridge-1.0.jar b/VirtualComputer/repo/io/github/NorbiPeti/SenderBridge/1.0/SenderBridge-1.0.jar deleted file mode 100644 index 651b657..0000000 Binary files a/VirtualComputer/repo/io/github/NorbiPeti/SenderBridge/1.0/SenderBridge-1.0.jar and /dev/null differ diff --git a/VirtualComputer/repo/org/virtualbox/VirtualBox-MSCOM/6.0/VirtualBox-MSCOM-6.0.jar b/VirtualComputer/repo/org/virtualbox/VirtualBox-MSCOM/6.0/VirtualBox-MSCOM-6.0.jar new file mode 100644 index 0000000..823cabb Binary files /dev/null and b/VirtualComputer/repo/org/virtualbox/VirtualBox-MSCOM/6.0/VirtualBox-MSCOM-6.0.jar differ diff --git a/VirtualComputer/repo/org/virtualbox/VirtualBox-MSCOM/6.0/VirtualBox-MSCOM-6.0.pom b/VirtualComputer/repo/org/virtualbox/VirtualBox-MSCOM/6.0/VirtualBox-MSCOM-6.0.pom new file mode 100644 index 0000000..1c7235a --- /dev/null +++ b/VirtualComputer/repo/org/virtualbox/VirtualBox-MSCOM/6.0/VirtualBox-MSCOM-6.0.pom @@ -0,0 +1,10 @@ + + + 4.0.0 + org.virtualbox + VirtualBox-MSCOM + 6.0 + POM was created from install:install-file + diff --git a/VirtualComputer/repo/org/virtualbox/VirtualBox-MSCOM/maven-metadata-local.xml b/VirtualComputer/repo/org/virtualbox/VirtualBox-MSCOM/maven-metadata-local.xml new file mode 100644 index 0000000..10d70c9 --- /dev/null +++ b/VirtualComputer/repo/org/virtualbox/VirtualBox-MSCOM/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + org.virtualbox + VirtualBox-MSCOM + + 6.0 + + 6.0 + + 20190405225845 + + diff --git a/VirtualComputer/repo/org/virtualbox/VirtualBox/5.1/VirtualBox-5.1-javadoc.jar b/VirtualComputer/repo/org/virtualbox/VirtualBox/5.1/VirtualBox-5.1-javadoc.jar new file mode 100644 index 0000000..4ea760b Binary files /dev/null and b/VirtualComputer/repo/org/virtualbox/VirtualBox/5.1/VirtualBox-5.1-javadoc.jar differ diff --git a/VirtualComputer/repo/org/virtualbox/VirtualBox/5.1/VirtualBox-5.1.jar b/VirtualComputer/repo/org/virtualbox/VirtualBox/5.1/VirtualBox-5.1.jar new file mode 100644 index 0000000..b0bd4ee Binary files /dev/null and b/VirtualComputer/repo/org/virtualbox/VirtualBox/5.1/VirtualBox-5.1.jar differ diff --git a/VirtualComputer/repo/io/github/NorbiPeti/SenderBridge/1.0/SenderBridge-1.0.pom b/VirtualComputer/repo/org/virtualbox/VirtualBox/5.1/VirtualBox-5.1.pom similarity index 77% rename from VirtualComputer/repo/io/github/NorbiPeti/SenderBridge/1.0/SenderBridge-1.0.pom rename to VirtualComputer/repo/org/virtualbox/VirtualBox/5.1/VirtualBox-5.1.pom index 09cb70c..35819af 100644 --- a/VirtualComputer/repo/io/github/NorbiPeti/SenderBridge/1.0/SenderBridge-1.0.pom +++ b/VirtualComputer/repo/org/virtualbox/VirtualBox/5.1/VirtualBox-5.1.pom @@ -2,8 +2,8 @@ 4.0.0 - io.github.NorbiPeti - SenderBridge - 1.0 + org.virtualbox + VirtualBox + 5.1 POM was created from install:install-file diff --git a/VirtualComputer/repo/org/virtualbox/VirtualBox/5.2/VirtualBox-5.2.jar b/VirtualComputer/repo/org/virtualbox/VirtualBox/5.2/VirtualBox-5.2.jar new file mode 100644 index 0000000..ec61f28 Binary files /dev/null and b/VirtualComputer/repo/org/virtualbox/VirtualBox/5.2/VirtualBox-5.2.jar differ diff --git a/VirtualComputer/repo/org/virtualbox/VirtualBox/5.2/VirtualBox-5.2.pom b/VirtualComputer/repo/org/virtualbox/VirtualBox/5.2/VirtualBox-5.2.pom new file mode 100755 index 0000000..fb51ba3 --- /dev/null +++ b/VirtualComputer/repo/org/virtualbox/VirtualBox/5.2/VirtualBox-5.2.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + org.virtualbox + VirtualBox + 5.2 + POM was created from install:install-file + diff --git a/VirtualComputer/repo/org/virtualbox/VirtualBox/6.0/VirtualBox-6.0.jar b/VirtualComputer/repo/org/virtualbox/VirtualBox/6.0/VirtualBox-6.0.jar new file mode 100644 index 0000000..3c8983d Binary files /dev/null and b/VirtualComputer/repo/org/virtualbox/VirtualBox/6.0/VirtualBox-6.0.jar differ diff --git a/VirtualComputer/repo/org/virtualbox/VirtualBox/6.0/VirtualBox-6.0.pom b/VirtualComputer/repo/org/virtualbox/VirtualBox/6.0/VirtualBox-6.0.pom new file mode 100644 index 0000000..9b7d6af --- /dev/null +++ b/VirtualComputer/repo/org/virtualbox/VirtualBox/6.0/VirtualBox-6.0.pom @@ -0,0 +1,10 @@ + + + 4.0.0 + org.virtualbox + VirtualBox + 6.0 + POM was created from install:install-file + diff --git a/VirtualComputer/repo/org/virtualbox/VirtualBox/maven-metadata-local.xml b/VirtualComputer/repo/org/virtualbox/VirtualBox/maven-metadata-local.xml new file mode 100644 index 0000000..ea3d226 --- /dev/null +++ b/VirtualComputer/repo/org/virtualbox/VirtualBox/maven-metadata-local.xml @@ -0,0 +1,14 @@ + + + org.virtualbox + VirtualBox + + 6.0 + + 5.1 + 5.2 + 6.0 + + 20181221211412 + + diff --git a/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/SketchMapAPI.java b/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/SketchMapAPI.java deleted file mode 100644 index c2a38da..0000000 --- a/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/SketchMapAPI.java +++ /dev/null @@ -1,217 +0,0 @@ -package com.mcplugindev.slipswhitley.sketchmap; - -/* - * This file was originally taken from https://github.com/slipswhitley/SketchMap - */ - -import java.awt.image.BufferedImage; -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import com.mcplugindev.slipswhitley.sketchmap.file.SketchMapFileException; -import com.mcplugindev.slipswhitley.sketchmap.map.RelativeLocation; -import com.mcplugindev.slipswhitley.sketchmap.map.SketchMap; - -//import com.mcplugindev.slipswhitley.sketchmap.map.SketchMap.BaseFormat; - -public class SketchMapAPI -{ - - public static SketchMap getMapByID(String id) - { - for (SketchMap map : SketchMap.getLoadedMaps()) - { - if (map.getID().equalsIgnoreCase(id)) - { - return map; - } - } - - return null; - } - - public static List getOrderedItemSet(SketchMap map) - { - List items = new ArrayList(); - - for (int y = 0; y < map.getLengthY(); y++) - { - for (int x = 0; x < map.getLengthX(); x++) - { - for (RelativeLocation loc : map.getMapCollection().keySet()) - { - if (loc.getX() != x || loc.getY() != y) - { - continue; - } - - ItemStack iStack = new ItemStack(Material.MAP, 1); - iStack.setDurability(SketchMapUtils.getMapID(map - .getMapCollection().get(loc))); - - ItemMeta iMeta = iStack.getItemMeta(); - iMeta.setDisplayName(ChatColor.GREEN + "SketchMap ID: " - + ChatColor.GOLD + map.getID() + ChatColor.GREEN - + " Pos-X: " + ChatColor.GOLD + (x + 1) - + ChatColor.GREEN + " Pos-Y: " + ChatColor.GOLD - + (y + 1)); - - iMeta.setLore(Arrays.asList(new String[] { ChatColor.GRAY - + "SketchMap ID: " + map.getID() - - })); - - iStack.setItemMeta(iMeta); - items.add(iStack); - - } - } - } - - return items; - } - - public static SketchMap loadSketchMapFromFile(File file) - throws SketchMapFileException - { - - YamlConfiguration config = null; - try - { - config = YamlConfiguration.loadConfiguration(file); - } catch (Exception ex) - { - throw new SketchMapFileException("Invalid SketchMap File \"" - + file.getName() + "\""); - } - - String[] fieldSet = { "x-panes", "y-panes", "public-protected", - "map-collection", "base-format", "map-image", }; - - for (String field : fieldSet) - { - if (!config.isSet(field)) - { - throw new SketchMapFileException( - "Unable to load SketchMap file \"" + file.getName() - + "\" missing field \"" + field + "\""); - } - } - - Integer xPanes = config.getInt("x-panes"); - if (xPanes == null || xPanes < 1) - { - throw new SketchMapFileException("Unable to load SketchMap file \"" - + file.getName() + "\" invalid field \"x-panes\""); - } - - Integer yPanes = config.getInt("y-panes"); - if (yPanes == null || yPanes < 1) - { - throw new SketchMapFileException("Unable to load SketchMap file \"" - + file.getName() + "\" invalid field \"y-panes\""); - } - - Boolean publicProtected = config.getBoolean("public-protected"); - if (publicProtected == null) - { - throw new SketchMapFileException("Unable to load SketchMap file \"" - + file.getName() + "\" invalid field \"public-protected\""); - } - - List mapList = config.getStringList("map-collection"); - if (mapList == null) - { - throw new SketchMapFileException("Unable to load SketchMap file \"" - + file.getName() + "\" invalid field \"map-collection\""); - } - - Map mapCollection = new HashMap(); - - for (String map : mapList) - { - String[] split = map.split(" "); - if (split.length != 2) - { - throw new SketchMapFileException( - "Unable to load SketchMap file \"" + file.getName() - + "\" cannot parse field in \"map-colection\""); - } - - RelativeLocation loc = RelativeLocation.fromString(split[0]); - - if (loc == null) - { - throw new SketchMapFileException( - "Unable to load SketchMap file \"" + file.getName() - + "\" cannot parse field in \"map-colection\""); - } - - Short id = null; - try - { - id = Short.parseShort(split[1]); - } catch (Exception ex) - { - throw new SketchMapFileException( - "Unable to load SketchMap file \"" + file.getName() - + "\" cannot parse field in \"map-colection\""); - } - - mapCollection.put(id, loc); - } - - //BaseFormat format = null; - /* - * try { - * format = BaseFormat.valueOf(config.getString("base-format")); - * } - * catch (Exception ex) { - * throw new SketchMapFileException("Unable to load SketchMap file \"" + - * file.getName() - * + "\" cannot parse BaseFormat from field \"base-format\""); - * } - */ - - String b64Img = config.getString("map-image"); - if (b64Img == null) - { - throw new SketchMapFileException("Unable to load SketchMap file \"" - + file.getName() + "\" invalid field \"map-image\""); - } - - BufferedImage image = null; - - try - { - image = SketchMapUtils.base64StringToImg(b64Img); - } catch (Exception ex) - { - throw new SketchMapFileException("Unable to load SketchMap file \"" - + file.getName() - + "\" parse image from field \"map-image\""); - } - - String imageID = file.getName().substring(0, - file.getName().lastIndexOf(".")); - if (getMapByID(imageID) != null) - { - throw new SketchMapFileException("Unable to load SketchMap file \"" - + file.getName() - + "\" A SketchMap by that ID already exists."); - } - - return new SketchMap(image, imageID, yPanes, yPanes, publicProtected); - } - -} diff --git a/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/SketchMapPlugin.java b/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/SketchMapPlugin.java deleted file mode 100644 index 5a46bc8..0000000 --- a/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/SketchMapPlugin.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.mcplugindev.slipswhitley.sketchmap; - -/* - * This file was originally taken from https://github.com/slipswhitley/SketchMap - */ - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.plugin.java.JavaPlugin; - -import com.mcplugindev.slipswhitley.sketchmap.listener.PlayerListener; - -public class SketchMapPlugin extends JavaPlugin -{ - private static SketchMapPlugin plugin; - - public void onEnable() - { - plugin = this; - - setupListeners(); - - sendEnabledMessage(); - } - - private void sendEnabledMessage() - { - SketchMapUtils.sendColoredConsoleMessage(ChatColor.GREEN - + "| |"); - - SketchMapUtils.sendColoredConsoleMessage(ChatColor.GREEN + "| " - + ChatColor.AQUA + "SketchMap " - + this.getDescription().getVersion() + " has been Enabled!" - + ChatColor.GREEN + " |"); - - SketchMapUtils.sendColoredConsoleMessage(ChatColor.GREEN + "| " - + ChatColor.AQUA + " Authors: SlipsWhitley & Fyrinlight" - + ChatColor.GREEN + " |"); - - SketchMapUtils.sendColoredConsoleMessage(ChatColor.GREEN - + "| |"); - } - - private void setupListeners() - { - Bukkit.getPluginManager().registerEvents(new PlayerListener(), this); - } - - public static SketchMapPlugin getPlugin() - { - return plugin; - } - -} diff --git a/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/SketchMapUtils.java b/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/SketchMapUtils.java deleted file mode 100644 index 68358ac..0000000 --- a/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/SketchMapUtils.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.mcplugindev.slipswhitley.sketchmap; - -/* - * This file was originally taken from https://github.com/slipswhitley/SketchMap - */ - -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.image.BufferedImage; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.util.Base64; -import java.util.HashSet; - -import javax.imageio.ImageIO; - -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.entity.Player; -import org.bukkit.map.MapView; - -public class SketchMapUtils -{ - - /** - * - * Image Utils - * - */ - - public static BufferedImage resize(Image img, Integer width, Integer height) - { - - img = img.getScaledInstance(width, height, Image.SCALE_SMOOTH); - - if (img instanceof BufferedImage) - { - return (BufferedImage) img; - } - - BufferedImage bimage = new BufferedImage(img.getWidth(null), - img.getHeight(null), BufferedImage.TYPE_INT_ARGB); - - Graphics2D bGr = bimage.createGraphics(); - bGr.drawImage(img, 0, 0, null); - bGr.dispose(); - - return bimage; - } - - public static BufferedImage base64StringToImg(final String base64String) - { - try - { - return ImageIO.read(new ByteArrayInputStream(Base64.getDecoder() - .decode(base64String))); - } catch (final IOException ioe) - { - throw new UncheckedIOException(ioe); - } - } - - public static void sendColoredConsoleMessage(String msg) - { - ConsoleCommandSender sender = Bukkit.getConsoleSender(); - sender.sendMessage(msg); - } - - /** - * Deprecated Methods Here :'c - */ - - @SuppressWarnings("deprecation") - public static short getMapID(MapView map) - { - return map.getId(); - } - - @SuppressWarnings("deprecation") - public static MapView getMapView(short id) - { - MapView map = Bukkit.getMap(id); - if (map != null) - { - return map; - } - - return Bukkit.createMap(getDefaultWorld()); - } - - /** - * - */ - - public static Block getTargetBlock(Player player, int i) - { - return player.getTargetBlock((HashSet) null, i); - } - - public static World getDefaultWorld() - { - return Bukkit.getWorlds().get(0); - } - -} diff --git a/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/file/SketchMapFileException.java b/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/file/SketchMapFileException.java deleted file mode 100644 index ab385e7..0000000 --- a/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/file/SketchMapFileException.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.mcplugindev.slipswhitley.sketchmap.file; - -public class SketchMapFileException extends Exception { - - /** - * - */ - private static final long serialVersionUID = 1L; - - public SketchMapFileException(String message) { - super(message); - } - -} diff --git a/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/listener/PlayerListener.java b/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/listener/PlayerListener.java deleted file mode 100644 index 2a267de..0000000 --- a/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/listener/PlayerListener.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.mcplugindev.slipswhitley.sketchmap.listener; - -import org.bukkit.ChatColor; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.entity.ItemFrame; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -public class PlayerListener implements Listener { - - @EventHandler - public void onPlayerInteract(PlayerInteractEntityEvent event) { - if(!(event.getRightClicked() instanceof ItemFrame)) { - return; - } - - ItemFrame iFrame = (ItemFrame) event.getRightClicked(); - ItemStack iHand = event.getPlayer().getItemInHand(); - - if(iHand.getType() != Material.MAP) { - return; - } - - String lore = iHand.getItemMeta().getLore().get(0); - - if(!ChatColor.stripColor(lore).startsWith("SketchMap ID:")) { - return; - } - - if(iFrame.getItem().getType() != Material.AIR) { - return; - } - - if(event.isCancelled()) { - return; - } - - event.setCancelled(true); - - - ItemStack frameItem = iHand.clone(); - frameItem.setAmount(1); - ItemMeta frameIMeta = frameItem.getItemMeta(); - - frameIMeta.setDisplayName(""); - frameItem.setItemMeta(frameIMeta); - - iFrame.setItem(frameItem); - - Player player = event.getPlayer(); - if(player.getGameMode() == GameMode.CREATIVE) { - return; - } - - if(iHand.getAmount() == 1) { - player.getInventory().setItemInHand(new ItemStack(Material.AIR)); - return; - } - - iHand.setAmount(iHand.getAmount() - 1); - - - } -} diff --git a/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/map/ImageRenderer.java b/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/map/ImageRenderer.java deleted file mode 100644 index 082ef20..0000000 --- a/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/map/ImageRenderer.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.mcplugindev.slipswhitley.sketchmap.map; - -import java.awt.image.BufferedImage; -import java.util.concurrent.TimeUnit; - -import org.bukkit.entity.Player; -import org.bukkit.map.MapCanvas; -import org.bukkit.map.MapRenderer; -import org.bukkit.map.MapView; - -public class ImageRenderer extends MapRenderer -{ - - private BufferedImage image; - - public ImageRenderer(BufferedImage image) - { - this.image = image; - } - - private int progress = 0; - public static int updatepixels = 15; - - @Override - public void render(MapView view, MapCanvas canvas, Player player) - { - long time = System.nanoTime(); - - try - { - canvas.drawImage(0, progress * updatepixels, image.getSubimage(0, - progress * updatepixels, 128, (progress * updatepixels - + updatepixels >= 128 ? 128 - progress - * updatepixels : updatepixels))); - if (progress < 128 / updatepixels) - progress++; - else - progress = 0; - - long diff = System.nanoTime() - time; - if (TimeUnit.NANOSECONDS.toMillis(diff) > 40) - { - System.out.println("Map rendering took " - + TimeUnit.NANOSECONDS.toMillis(diff) + " ms"); - } - } catch (Exception e) - { - e.printStackTrace(); - System.out.println("Progess: " + progress); - System.out.println("UpdatePixels: " + updatepixels); - } - } -} diff --git a/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/map/RelativeLocation.java b/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/map/RelativeLocation.java deleted file mode 100644 index 2030b3a..0000000 --- a/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/map/RelativeLocation.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.mcplugindev.slipswhitley.sketchmap.map; - -public class RelativeLocation { - - private int x; - private int y; - - public RelativeLocation (int x, int y) { - this.x = x; - this.y = y; - } - - - public String toString() { - return x + ":" + y; - } - - public static RelativeLocation fromString(String str) { - String[] args = str.split(":"); - if(args.length != 2) { - return null; - } - - int x = 0; - int y = 0; - - try { - x = Integer.parseInt(args[0]); - y = Integer.parseInt(args[1]); - } - catch (Exception ex) { - return null; - } - - return new RelativeLocation (x, y); - } - - - public int getX() { - return x; - } - - public int getY() { - return y; - } - - - - - - - -} diff --git a/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/map/SketchMap.java b/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/map/SketchMap.java deleted file mode 100644 index 76bac6a..0000000 --- a/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/map/SketchMap.java +++ /dev/null @@ -1,220 +0,0 @@ -package com.mcplugindev.slipswhitley.sketchmap.map; - -/* - * This file was originally taken from https://github.com/slipswhitley/SketchMap - */ - -import java.awt.image.BufferedImage; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.bukkit.Bukkit; -import org.bukkit.map.MapView; - -import com.mcplugindev.slipswhitley.sketchmap.SketchMapUtils; - -public class SketchMap -{ - - public BufferedImage image; - private String mapID; - private Integer xPanes; - private Integer yPanes; - private Boolean publicProtected; - //private BaseFormat format; - - private Map mapCollection; - - /** - * - * Create SketchMap using New Maps - * - */ - - public SketchMap(BufferedImage image, String mapID, int xPanes, int yPanes, - boolean publicProtected) - { - - this.image = SketchMapUtils.resize(image, xPanes * 128, yPanes * 128); - this.mapID = mapID; - this.xPanes = xPanes; - this.yPanes = yPanes; - this.publicProtected = publicProtected; - //this.format = format; - - this.mapCollection = new HashMap(); - - getLoadedMaps().add(this); - loadSketchMap(); - } - - private void loadSketchMap() - { - for (int x = 0; x < xPanes; x++) - { - for (int y = 0; y < yPanes; y++) - { - initMap(x, y, - Bukkit.createMap(SketchMapUtils.getDefaultWorld())); - } - } - } - - /** - * - * Create SketchMap using Specified Maps - * - */ - - public SketchMap(BufferedImage image, String mapID, int xPanes, int yPanes, - boolean publicProtected, Map mapCollection) - { - - this.image = SketchMapUtils.resize(image, xPanes * 128, yPanes * 128); - this.mapID = mapID; - this.xPanes = xPanes; - this.yPanes = yPanes; - this.publicProtected = publicProtected; - //this.format = format; - - this.mapCollection = new HashMap(); - - getLoadedMaps().add(this); - loadSketchMap(mapCollection); - } - - private void loadSketchMap(Map mapCollection) - { - for (Short mapID : mapCollection.keySet()) - { - RelativeLocation loc = mapCollection.get(mapID); - - initMap(loc.getX(), loc.getY(), SketchMapUtils.getMapView(mapID)); - } - } - - /** - * - * - * - */ - - private void initMap(int x, int y, MapView mapView) - { - BufferedImage subImage = image.getSubimage(x * 128, y * 128, 128, 128); - mapView.getRenderers().clear(); - mapView.addRenderer(new ImageRenderer(subImage)); - - mapCollection.put(new RelativeLocation(x, y), mapView); - } - - /** - * - * Get Object information - * - */ - - public String getID() - { - return mapID; - } - - public BufferedImage getImage() - { - return image; - } - - public int getLengthX() - { - return xPanes; - } - - public int getLengthY() - { - return yPanes; - } - - public boolean isPublicProtected() - { - return publicProtected; - } - - public Map getMapCollection() - { - return mapCollection; - } - - /* - * public BaseFormat getBaseFormat() { - * return format; - * } - */ - - /** - * - * Map Functions - * - * - */ - - public void delete() - { - getLoadedMaps().remove(this); - - try - { - this.finalize(); - } catch (Throwable e) - { - } - } - - /** - * - * Static Methods - * - */ - - private static Set sketchMaps; - - public static Set getLoadedMaps() - { - if (sketchMaps == null) - { - sketchMaps = new HashSet(); - } - - return sketchMaps; - } - - /* - * public enum BaseFormat { - * PNG, - * JPEG; - * - * public String getExtension() { - * if(this == BaseFormat.PNG) { - * return "png"; - * } - * if(this == BaseFormat.JPEG) { - * return "jpg"; - * } - * return null; - * } - * - * public static BaseFormat fromExtension(String ext) { - * if(ext.equalsIgnoreCase("png")) { - * return BaseFormat.PNG; - * - * } - * if(ext.equalsIgnoreCase("jpg")) { - * return BaseFormat.JPEG; - * } - * return null; - * } - * } - */ - -} diff --git a/VirtualComputer/src/main/java/sznp/virtualcomputer/Commands.java b/VirtualComputer/src/main/java/sznp/virtualcomputer/Commands.java new file mode 100644 index 0000000..a92868b --- /dev/null +++ b/VirtualComputer/src/main/java/sznp/virtualcomputer/Commands.java @@ -0,0 +1,162 @@ +package sznp.virtualcomputer; + +import org.bukkit.Bukkit; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.virtualbox_6_0.VBoxException; + +public class Commands implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { + if (args.length == 0) + return false; + switch (args[0].toLowerCase()) { + case "start": + case "poweron": + case "on": + case "startup": + int c = getMachineIndex(args); + if (c == -1) { + sender.sendMessage("§cUsage: /" + label + " start [index]"); + return true; + } + Computer.getInstance().Start(sender, c); + break; + case "stop": + case "poweroff": + case "off": + case "shutdown": + case "kill": + Computer.getInstance().Stop(sender); + break; + case "powerbutton": + case "pwrbtn": + case "powerbtn": + c = getMachineIndex(args); + if (c == -1) { + sender.sendMessage("§cUsage: /" + label + " powerbutton [index]"); + return true; + } + Computer.getInstance().PowerButton(sender, c); + break; + case "reset": + case "restart": + Computer.getInstance().Reset(sender); + break; + case "fix": + case "fixscreen": + Computer.getInstance().FixScreen(sender); + break; + case "key": + case "press": + case "presskey": + case "keypress": + if (args.length < 2) { + sender.sendMessage("§cUsage: /computer key [down/up|duration(ticks)]"); + return true; + } + if (args.length < 3) + Computer.getInstance().PressKey(sender, args[1], ""); + else + Computer.getInstance().PressKey(sender, args[1], args[2]); + break; + case "mouse": + boolean showusage = true; + if (args.length < 6) { + try { + // Command overloading, because I can :P + if (args.length > 4) // 4 "); + sender.sendMessage("§cOr: /computer mouse