├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .travis.yml ├── .gitignore ├── LICENSE ├── src ├── main │ └── java │ │ └── com │ │ └── voxelplugineering │ │ └── voxelsniper │ │ ├── util │ │ ├── Contextable.java │ │ ├── Nameable.java │ │ ├── Pair.java │ │ ├── brush │ │ │ └── BrushVarsHelper.java │ │ ├── ShapeValidation.java │ │ ├── FutureFutureCallable.java │ │ └── defaults │ │ │ └── DefaultAliasBuilder.java │ │ ├── service │ │ ├── InitPhase.java │ │ ├── alias │ │ │ ├── AliasOwner.java │ │ │ ├── GlobalAliasHandler.java │ │ │ ├── GlobalAliasOwner.java │ │ │ ├── AnnotationScanner.java │ │ │ └── AliasSaveTask.java │ │ ├── command │ │ │ ├── CommandSender.java │ │ │ ├── CommandRegistrar.java │ │ │ ├── MessageReceiver.java │ │ │ └── CommandHandler.java │ │ ├── event │ │ │ ├── Cancelable.java │ │ │ └── DeadEvent.java │ │ ├── eventbus │ │ │ ├── EventPriority.java │ │ │ ├── EventHandler.java │ │ │ └── EventThreadingPolicy.java │ │ ├── meta │ │ │ └── AnnotationConsumer.java │ │ ├── PreStop.java │ │ ├── PostInit.java │ │ ├── InitHook.java │ │ ├── registry │ │ │ ├── RegistryProvider.java │ │ │ ├── EntityRegistry.java │ │ │ ├── WorldRegistry.java │ │ │ ├── BiomeRegistry.java │ │ │ └── PlayerRegistry.java │ │ ├── logging │ │ │ └── LogLevel.java │ │ ├── Builder.java │ │ ├── permission │ │ │ ├── PermissionProxy.java │ │ │ └── TrivialPermissionProxy.java │ │ ├── Service.java │ │ ├── config │ │ │ ├── ConfigValue.java │ │ │ ├── ConfigurationContainer.java │ │ │ └── Configuration.java │ │ ├── text │ │ │ ├── TextFormat.java │ │ │ └── TextFormatParser.java │ │ ├── scheduler │ │ │ ├── Task.java │ │ │ └── Scheduler.java │ │ ├── platform │ │ │ └── PlatformProxy.java │ │ ├── EntityRegistryService.java │ │ └── OfflineUndoHandlerService.java │ │ ├── world │ │ ├── material │ │ │ ├── MaterialState.java │ │ │ └── Material.java │ │ ├── biome │ │ │ └── Biome.java │ │ ├── queue │ │ │ ├── OfflineUndoHandler.java │ │ │ ├── LightningChangeQueue.java │ │ │ ├── Change.java │ │ │ ├── ChangeQueueOwner.java │ │ │ └── EntityChangeQueue.java │ │ ├── Chunk.java │ │ ├── Block.java │ │ └── CommonBlock.java │ │ ├── brush │ │ ├── GlobalBrushManager.java │ │ ├── effect │ │ │ └── morphological │ │ │ │ ├── BlendBrush.java │ │ │ │ └── FilterOperation.java │ │ ├── BrushInstance.java │ │ ├── BrushAction.java │ │ ├── BrushPartType.java │ │ ├── BrushParam.java │ │ ├── Brush.java │ │ ├── BrushInfo.java │ │ ├── BrushHolder.java │ │ ├── shape │ │ │ ├── SnipeBrush.java │ │ │ ├── BallBrush.java │ │ │ └── VoxelBrush.java │ │ └── misc │ │ │ └── LightningBrush.java │ │ ├── expansion │ │ ├── Expansion.java │ │ └── ExpansionManager.java │ │ ├── entity │ │ ├── AbstractEntity.java │ │ ├── EntityType.java │ │ ├── Living.java │ │ ├── Action.java │ │ └── Player.java │ │ ├── shape │ │ └── csg │ │ │ ├── CSGShape.java │ │ │ └── OffsetShape.java │ │ ├── GunsmithMain.java │ │ ├── registry │ │ ├── WeakWrapper.java │ │ └── ProvidedWeakRegistry.java │ │ ├── config │ │ └── BaseConfiguration.java │ │ ├── commands │ │ ├── ResetCommand.java │ │ ├── RedoCommand.java │ │ └── UndoCommand.java │ │ └── event │ │ └── SnipeEvent.java └── test │ └── java │ └── com │ └── voxelplugineering │ └── voxelsniper │ └── util │ └── ContextTestUtil.java ├── pom.xml ├── gradlew.bat └── README.md /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'VoxelGunsmith' 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TVPT/VoxelGunsmith/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | notifications: 3 | email: false 4 | install: true 5 | jdk: 6 | - oraclejdk8 7 | script: ./gradlew 8 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Oct 18 20:28:30 CEST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-rc-2-bin.zip 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #Folders to ignore 2 | bin/ 3 | target/ 4 | build/ 5 | .externalToolBuilders/ 6 | .manifest 7 | buildLocal.xml 8 | 9 | #Gradle 10 | .gradle/ 11 | artifacts/ 12 | gradle-app.setting 13 | 14 | #Maven 15 | dependency-reduced-pom.xml 16 | 17 | #Files to ignore 18 | # -Eclipse- 19 | .settings 20 | .project 21 | .classpath 22 | 23 | # -IntelliJ- 24 | *.iml 25 | *.ipr 26 | *.iws 27 | .idea/ 28 | 29 | #Specific files to the project 30 | *.checkstyle 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 The Voxel Plugineering Team 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/util/Contextable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.util; 25 | 26 | /** 27 | * An object which may be added to a {@link Context}. 28 | */ 29 | public interface Contextable 30 | { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/InitPhase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | package com.voxelplugineering.voxelsniper.service; 26 | 27 | /** 28 | * An enumeration of the phases of service initialization. 29 | */ 30 | @SuppressWarnings("javadoc") 31 | public enum InitPhase 32 | { 33 | 34 | EARLY, 35 | NORMAL; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/util/Nameable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.util; 25 | 26 | /** 27 | * Represents an object which has a name. 28 | */ 29 | public interface Nameable 30 | { 31 | 32 | /** 33 | * Gets this objects name. 34 | * 35 | * @return The name 36 | */ 37 | String getName(); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/world/material/MaterialState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.world.material; 25 | 26 | /** 27 | * Represents a particular state of a material. 28 | */ 29 | public interface MaterialState 30 | { 31 | 32 | /** 33 | * Gets the material that this state belongs to. 34 | * 35 | * @return The material 36 | */ 37 | Material getType(); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/alias/AliasOwner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.alias; 25 | 26 | import java.io.File; 27 | 28 | /** 29 | * An owner of an alias handler. 30 | */ 31 | public interface AliasOwner 32 | { 33 | 34 | /** 35 | * Gets the file to which this owner's aliases are stored. 36 | * 37 | * @return The alias source 38 | */ 39 | File getAliasSource(); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/world/biome/Biome.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.world.biome; 25 | 26 | import com.voxelplugineering.voxelsniper.util.Nameable; 27 | 28 | /** 29 | * Represents a biome type. 30 | */ 31 | public interface Biome extends Nameable 32 | { 33 | 34 | /** 35 | * Gets the name of the biome. 36 | * 37 | * @return The name 38 | */ 39 | @Override 40 | String getName(); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/brush/GlobalBrushManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.brush; 25 | 26 | import com.voxelplugineering.voxelsniper.service.Service; 27 | import com.voxelplugineering.voxelsniper.service.meta.AnnotationConsumer; 28 | 29 | /** 30 | * A marker interface for the global {@link BrushManager} service. 31 | */ 32 | public interface GlobalBrushManager extends BrushManager, Service, AnnotationConsumer 33 | { 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/command/CommandSender.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.command; 25 | 26 | /** 27 | * An interface for any command source. 28 | */ 29 | public interface CommandSender extends MessageReceiver 30 | { 31 | 32 | /** 33 | * Is this command sender a player (are they a living entity within the world). 34 | * 35 | * @return Is player 36 | */ 37 | boolean isPlayer(); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/expansion/Expansion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.expansion; 25 | 26 | /** 27 | * Represents an expansion to the functionality of Gunsmith. An expansion can be thought of as a 28 | * plugin. 29 | */ 30 | public interface Expansion 31 | { 32 | 33 | /** 34 | * Initializes this expansion. 35 | */ 36 | void init(); 37 | 38 | /** 39 | * Shuts down this expansion. 40 | */ 41 | void stop(); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/event/Cancelable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.event; 25 | 26 | import static java.lang.annotation.ElementType.TYPE; 27 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 28 | 29 | import java.lang.annotation.Retention; 30 | import java.lang.annotation.Target; 31 | 32 | /** 33 | * An annotation for if an event may be canceled. 34 | */ 35 | @Retention(RUNTIME) 36 | @Target(TYPE) 37 | public @interface Cancelable 38 | { 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/eventbus/EventPriority.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.eventbus; 25 | 26 | /** 27 | * Possible EventPriority levels. 28 | * 29 | *

The ordering of these should remain constant, and in particular the priorities should be 30 | * ordered in descending order of priority.

31 | */ 32 | @SuppressWarnings("javadoc") 33 | public enum EventPriority 34 | { 35 | 36 | HIGHEST, 37 | HIGH, 38 | STANDARD, 39 | LOW, 40 | LOWEST 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/brush/effect/morphological/BlendBrush.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.brush.effect.morphological; 25 | 26 | /** 27 | * A basic blend effect brush. 28 | */ 29 | public class BlendBrush extends FilterBrush 30 | { 31 | 32 | /** 33 | * Creates a new {@link BlendBrush}. 34 | */ 35 | public BlendBrush() 36 | { 37 | super(new BlendMaterialOperation()); 38 | } 39 | 40 | @Override 41 | protected String getName() 42 | { 43 | return "blend"; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/alias/GlobalAliasHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.alias; 25 | 26 | import com.voxelplugineering.voxelsniper.service.Service; 27 | 28 | /** 29 | * A marker interface for the global {@link AliasHandler}. 30 | */ 31 | public interface GlobalAliasHandler extends AliasHandler, Service 32 | { 33 | 34 | /** 35 | * Gets the task which handles saving aliases to file. 36 | * 37 | * @return The alias save task 38 | */ 39 | AliasSaveTask getAliasSaveTask(); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/entity/AbstractEntity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.entity; 25 | 26 | import com.voxelplugineering.voxelsniper.registry.WeakWrapper; 27 | 28 | /** 29 | * An abstract entity. 30 | * 31 | * @param The underlying entity type 32 | */ 33 | public abstract class AbstractEntity extends WeakWrapperimplements Entity 34 | { 35 | 36 | /** 37 | * Creates a new AbstractEntity. 38 | * 39 | * @param value The entity 40 | */ 41 | public AbstractEntity(T value) 42 | { 43 | super(value); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/meta/AnnotationConsumer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.meta; 25 | 26 | import com.voxelplugineering.voxelsniper.service.alias.AnnotationScanner; 27 | 28 | /** 29 | * A consumer which may be registered into an {@link AnnotationScanner} and will be passed all 30 | * classes annotated with the registered annotation type. 31 | */ 32 | public interface AnnotationConsumer 33 | { 34 | 35 | /** 36 | * Consume the given class. 37 | * 38 | * @param cls The class 39 | */ 40 | void consume(Class cls); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/entity/EntityType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.entity; 25 | 26 | import com.voxelplugineering.voxelsniper.util.Nameable; 27 | 28 | /** 29 | * Represents a type of entity. 30 | */ 31 | public interface EntityType extends Nameable 32 | { 33 | 34 | /** 35 | * Gets the name of this entity type. 36 | * 37 | * @return The name 38 | */ 39 | @Override 40 | String getName(); 41 | 42 | /** 43 | * Gets if this entity type is alive. 44 | * 45 | * @return Is alive 46 | */ 47 | boolean isAlive(); 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/brush/BrushInstance.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.brush; 25 | 26 | import java.lang.annotation.ElementType; 27 | import java.lang.annotation.Retention; 28 | import java.lang.annotation.RetentionPolicy; 29 | import java.lang.annotation.Target; 30 | 31 | /** 32 | * Only valid for a field of type {@link BrushWrapper} within a brush class. The annotated field 33 | * will be automatically filled with the {@link BrushWrapper} instace for that brush. 34 | */ 35 | @Retention(RetentionPolicy.RUNTIME) 36 | @Target(ElementType.FIELD) 37 | public @interface BrushInstance 38 | { 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/command/CommandRegistrar.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.command; 25 | 26 | import com.voxelplugineering.voxelsniper.commands.Command; 27 | 28 | /** 29 | * Implemented by the specific implementations the command registrar handles the registering of 30 | * commands within the underlying APIs. 31 | */ 32 | public interface CommandRegistrar 33 | { 34 | 35 | /** 36 | * Registers the command with the underlying API. 37 | * 38 | * @param command The command to be registered, cannot be null 39 | */ 40 | void registerCommand(Command command); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/brush/BrushAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.brush; 25 | 26 | /** 27 | * Represents the various actions that a player may use to trigger the execution of their brushes. 28 | */ 29 | public enum BrushAction 30 | { 31 | 32 | /** 33 | * The primary action is use for most standard operations. 34 | */ 35 | PRIMARY, 36 | /** 37 | * The alternate action is used for brushes with secondary functions. If a brush has no 38 | * secondary function then it is used to cause the target block to be offset by one to be the 39 | * block before the target block in the ray. 40 | */ 41 | ALTERNATE; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/shape/csg/CSGShape.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.shape.csg; 25 | 26 | import com.voxelplugineering.voxelsniper.shape.Shape; 27 | import com.voxelplugineering.voxelsniper.util.math.Vector3i; 28 | 29 | /** 30 | * An abstract CSG shape. 31 | */ 32 | public interface CSGShape extends Shape 33 | { 34 | 35 | /** 36 | * Offsets this shape by the given vector. 37 | * 38 | * @param offset The offset 39 | */ 40 | void offset(Vector3i offset); 41 | 42 | /** 43 | * Creates an identical copy of this shape. 44 | * 45 | * @return The copy 46 | */ 47 | @Override 48 | CSGShape clone(); 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/PreStop.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service; 25 | 26 | import com.voxelplugineering.voxelsniper.ServiceManager; 27 | 28 | import java.lang.annotation.ElementType; 29 | import java.lang.annotation.Retention; 30 | import java.lang.annotation.RetentionPolicy; 31 | import java.lang.annotation.Target; 32 | 33 | /** 34 | * Annotates a method which will be called by the {@link ServiceManager} prior to stopping the 35 | * services. 36 | */ 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @Target(ElementType.METHOD) 39 | public @interface PreStop 40 | { 41 | 42 | /** 43 | * Gets the priority. 44 | */ 45 | int priority() default 1000; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/expansion/ExpansionManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.expansion; 25 | 26 | import java.util.Collection; 27 | 28 | /** 29 | * A manager for expansions. Handles the registration of expansions. 30 | */ 31 | public interface ExpansionManager 32 | { 33 | 34 | /** 35 | * Registers the given expansion with the manager to be referenced for system startup and 36 | * shutdown. 37 | * 38 | * @param ex The expansion 39 | */ 40 | void registerExpansion(Expansion ex); 41 | 42 | /** 43 | * Gets a collection of all registered expansions. 44 | * 45 | * @return The expansions 46 | */ 47 | Collection getExpansions(); 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/PostInit.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service; 25 | 26 | import com.voxelplugineering.voxelsniper.ServiceManager; 27 | 28 | import java.lang.annotation.ElementType; 29 | import java.lang.annotation.Retention; 30 | import java.lang.annotation.RetentionPolicy; 31 | import java.lang.annotation.Target; 32 | 33 | /** 34 | * Annotates a method which will be called by the {@link ServiceManager} immediately after the 35 | * services have been initialized. 36 | */ 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @Target(ElementType.METHOD) 39 | public @interface PostInit 40 | { 41 | 42 | /** 43 | * Gets the priority. 44 | */ 45 | int priority() default 1000; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/brush/BrushPartType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.brush; 25 | 26 | /** 27 | * An enumeration of some standard brush part types. These describe the general targeted purpose of 28 | * a brush part but should NOT be relied upon. 29 | */ 30 | public enum BrushPartType 31 | { 32 | /** 33 | * A brush part which defines a shape. 34 | */ 35 | SHAPE, 36 | /** 37 | * A brush part which modifies a pre-existing shape. 38 | */ 39 | MASK, 40 | /** 41 | * A brush part which performs an effect upon an area defined by a shape. 42 | */ 43 | EFFECT, 44 | /** 45 | * A brush part which performs some unknown purpose. 46 | */ 47 | MISC 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/brush/BrushParam.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.brush; 25 | 26 | import java.lang.annotation.ElementType; 27 | import java.lang.annotation.Retention; 28 | import java.lang.annotation.RetentionPolicy; 29 | import java.lang.annotation.Target; 30 | 31 | /** 32 | * Represents a parameter for a brush. 33 | */ 34 | @Retention(RetentionPolicy.RUNTIME) 35 | @Target(ElementType.TYPE) 36 | public @interface BrushParam 37 | { 38 | /** 39 | * Gets the parameter name. 40 | * 41 | * @return The name 42 | */ 43 | String name(); 44 | 45 | /** 46 | * Gets the description of this brush. 47 | * 48 | * @return The description 49 | */ 50 | String desc(); 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/InitHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service; 25 | 26 | import com.voxelplugineering.voxelsniper.util.Contextable; 27 | 28 | import java.lang.annotation.ElementType; 29 | import java.lang.annotation.Retention; 30 | import java.lang.annotation.RetentionPolicy; 31 | import java.lang.annotation.Target; 32 | 33 | /** 34 | * An annotation for an init hook for a service. 35 | */ 36 | @Retention(RetentionPolicy.RUNTIME) 37 | @Target(ElementType.METHOD) 38 | public @interface InitHook 39 | { 40 | 41 | /** 42 | * The target class. 43 | */ 44 | Classtarget(); 45 | 46 | /** 47 | * The priority. 48 | */ 49 | int priority() default 1000; 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/registry/RegistryProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.registry; 25 | 26 | import com.voxelplugineering.voxelsniper.util.Pair; 27 | 28 | import java.util.Optional; 29 | 30 | /** 31 | * A provider for values in a registry which is referenced when a key is not found within the 32 | * registry. 33 | * 34 | * @param the key type 35 | * @param the value type 36 | */ 37 | public interface RegistryProvider 38 | { 39 | 40 | /** 41 | * Returns a new key value part from this provider. 42 | * 43 | * @param name The name of the object to fetch. 44 | * @return A key-value {@link Pair} 45 | */ 46 | Optional> get(String name); 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/command/MessageReceiver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.command; 25 | 26 | /** 27 | * An interface for anything which may recieve messages. 28 | */ 29 | public interface MessageReceiver 30 | { 31 | 32 | /** 33 | * Sends a message to the user. 34 | * 35 | * @param msg The message to send, cannot be null or empty 36 | */ 37 | void sendMessage(String msg); 38 | 39 | /** 40 | * Sends a message to the user. Created by the same specification of 41 | * {@link String#format(String, Object...)}. 42 | * 43 | * @param format The format string 44 | * @param args The format arguments 45 | */ 46 | void sendMessage(String format, Object... args); 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/entity/Living.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.entity; 25 | 26 | /** 27 | * Represents a living entity. 28 | */ 29 | public interface Living extends Entity 30 | { 31 | 32 | /** 33 | * Gets the health of the entity. 34 | * 35 | * @return The health 36 | */ 37 | double getHealth(); 38 | 39 | /** 40 | * Sets the health of the entity to the given value. The new health will be clamped between zero 41 | * and {@link #getMaxHealth()}. 42 | * 43 | * @param health The new health 44 | */ 45 | void setHealth(double health); 46 | 47 | /** 48 | * Gets the maximum health of the entity. 49 | * 50 | * @return The max health 51 | */ 52 | double getMaxHealth(); 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/registry/EntityRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.registry; 25 | 26 | import com.voxelplugineering.voxelsniper.entity.EntityType; 27 | import com.voxelplugineering.voxelsniper.service.Service; 28 | 29 | import java.util.Optional; 30 | 31 | public interface EntityRegistry extends Service { 32 | 33 | Optional getEntityType(String name); 34 | 35 | Optional getEntityType(T type); 36 | 37 | void registerEntityType(String name, T object, EntityType entityType); 38 | 39 | default void registerEntityType(T object, EntityType entityType) { 40 | registerEntityType(entityType.getName(), object, entityType); 41 | } 42 | 43 | Iterable getEntityTypes(); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/alias/GlobalAliasOwner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.alias; 25 | 26 | import static com.google.common.base.Preconditions.checkNotNull; 27 | 28 | import java.io.File; 29 | 30 | /** 31 | * A special {@link AliasOwner} which holds the aliases common to all players. 32 | */ 33 | public class GlobalAliasOwner implements AliasOwner 34 | { 35 | 36 | private final File source; 37 | 38 | /** 39 | * Creates a new {@link GlobalAliasOwner}. 40 | * 41 | * @param source The alias source file 42 | */ 43 | public GlobalAliasOwner(File source) 44 | { 45 | this.source = checkNotNull(source); 46 | } 47 | 48 | @Override 49 | public File getAliasSource() 50 | { 51 | return this.source; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/logging/LogLevel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.logging; 25 | 26 | /** 27 | * An enumeration of all logging levels. 28 | */ 29 | @SuppressWarnings("javadoc") 30 | public enum LogLevel 31 | { 32 | 33 | OFF(-1), 34 | DEBUG(0), 35 | INFO(1), 36 | WARN(2), 37 | ERROR(3); 38 | 39 | private final int value; 40 | 41 | LogLevel(int level) 42 | { 43 | this.value = level; 44 | } 45 | 46 | /** 47 | * Gets whether the given LogLevel has a value which is greater than or equal to this log 48 | * level's value. 49 | * 50 | * @param other The other LogLevel 51 | * @return Is greater than or equal 52 | */ 53 | public boolean isGEqual(LogLevel other) 54 | { 55 | return this.value >= other.value; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/Builder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service; 25 | 26 | import com.voxelplugineering.voxelsniper.util.Contextable; 27 | 28 | import java.lang.annotation.ElementType; 29 | import java.lang.annotation.Retention; 30 | import java.lang.annotation.RetentionPolicy; 31 | import java.lang.annotation.Target; 32 | 33 | /** 34 | * An annotation to mark methods as providers for a {@link Contextable} object. 35 | */ 36 | @Retention(RetentionPolicy.RUNTIME) 37 | @Target(ElementType.METHOD) 38 | public @interface Builder 39 | { 40 | 41 | /** 42 | * The target class. 43 | */ 44 | Classtarget(); 45 | 46 | /** 47 | * The builder priority. 48 | */ 49 | int priority() default 1000; 50 | 51 | /** 52 | * The phase to initialize this in. 53 | */ 54 | InitPhase initPhase() default InitPhase.NORMAL; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/eventbus/EventHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.eventbus; 25 | 26 | import static java.lang.annotation.ElementType.METHOD; 27 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 28 | 29 | import java.lang.annotation.Retention; 30 | import java.lang.annotation.Target; 31 | 32 | /** 33 | * Annotates a method as being an event handler. 34 | * 35 | *

The annotated method must be public and take a single parameter, which is the event type 36 | * being registered.

37 | * 38 | *

It is good practice for methods annotated by this annotation to not throw exceptions.

39 | */ 40 | @Retention(RUNTIME) 41 | @Target(METHOD) 42 | public @interface EventHandler 43 | { 44 | 45 | /** 46 | * Gets the priority for this {@link EventHandler}. 47 | */ 48 | EventPriority value() default EventPriority.STANDARD; 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/permission/PermissionProxy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.permission; 25 | 26 | import com.voxelplugineering.voxelsniper.entity.Player; 27 | import com.voxelplugineering.voxelsniper.service.Service; 28 | 29 | /** 30 | * A proxy for the permission system of the specific implementation. TODO: group support within 31 | * gunsmith 32 | */ 33 | public interface PermissionProxy extends Service 34 | { 35 | 36 | /** 37 | * Checks if the user has the given permission node. Supports wildcards as permission nodes are 38 | * made of a dot-separated sequence of nodes. 39 | * 40 | * @param sniper The user to check, cannot be null 41 | * @param permission The permission node, cannot be null or empty 42 | * @return The result of the check 43 | */ 44 | boolean hasPermission(final Player sniper, final String permission); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/GunsmithMain.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper; 25 | 26 | /** 27 | * The main class for utility operations. 28 | */ 29 | public final class GunsmithMain 30 | { 31 | 32 | private GunsmithMain() 33 | { 34 | } 35 | 36 | /** 37 | * The main method. 38 | * 39 | * @param args The program arguments. 40 | */ 41 | public static void main(String[] args) 42 | { 43 | if (args.length == 1 && "--testinit".equalsIgnoreCase(args[0])) 44 | { 45 | System.out.println("Starting init -> stop cycle test."); 46 | Gunsmith.getServiceManager().start(); 47 | System.out.println(); 48 | Gunsmith.getServiceManager().shutdown(); 49 | } else 50 | { 51 | System.out.println( 52 | "Usage: java -jar Gunsmith.jar [args]\n" + "\t--testinit\t\t: Performs a full initialization to shutdown cycle.\n"); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/brush/Brush.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.brush; 25 | 26 | import com.voxelplugineering.voxelsniper.entity.Player; 27 | import com.voxelplugineering.voxelsniper.util.Context; 28 | 29 | /** 30 | * Represents a brush which may be run, only one brush instance should exist and be shared among all 31 | * users. A users individual runtime settings are stored within the {@link BrushVars}. 32 | */ 33 | public abstract class Brush 34 | { 35 | 36 | /** 37 | * Executes this brush. 38 | * 39 | * @param player The player executing the brush 40 | * @param args The player's brush variables 41 | * @return The execution result 42 | */ 43 | public abstract ExecutionResult run(Player player, BrushVars args); 44 | 45 | /** 46 | * Initializes this brush from the given context. 47 | * 48 | * @param context The context 49 | */ 50 | public void init(Context context) 51 | { 52 | 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/registry/WeakWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.registry; 25 | 26 | import static com.google.common.base.Preconditions.checkNotNull; 27 | 28 | import java.lang.ref.WeakReference; 29 | 30 | /** 31 | * A wrapper for a weakly referenced object. 32 | * 33 | * @param the object type 34 | */ 35 | public abstract class WeakWrapper 36 | { 37 | 38 | /** 39 | * The object weak reference. 40 | */ 41 | private final WeakReference reference; 42 | 43 | /** 44 | * Creates a new {@link WeakWrapper}. 45 | * 46 | * @param value The reference to wrap 47 | */ 48 | public WeakWrapper(T value) 49 | { 50 | checkNotNull(value); 51 | this.reference = new WeakReference(value); 52 | } 53 | 54 | /** 55 | * Returns the wrapped value, or null if it has been garbage collected. 56 | * 57 | * @return The wrapped object, may be null 58 | */ 59 | public T getThis() 60 | { 61 | return this.reference.get(); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/Service.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service; 25 | 26 | import com.voxelplugineering.voxelsniper.util.Contextable; 27 | 28 | /** 29 | * Represents a service, which is a portion of the system which may be started and stopped. It has 30 | * priority and implicit dependencies (TODO to be made explicit). 31 | */ 32 | public interface Service extends Contextable 33 | { 34 | 35 | /** 36 | * Gets whether this service has been started. 37 | * 38 | * @return Is started 39 | */ 40 | boolean isInitialized(); 41 | 42 | /** 43 | * Starts this service. 44 | */ 45 | void start(); 46 | 47 | /** 48 | * Stops this service. 49 | */ 50 | void shutdown(); 51 | 52 | /** 53 | * Adds a service as depending on this service. Dependent services will be shutdown before this 54 | * service. 55 | * 56 | * @param service The service 57 | * @param The service type 58 | */ 59 | void addDependent(T service); 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/permission/TrivialPermissionProxy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.permission; 25 | 26 | import com.voxelplugineering.voxelsniper.entity.Player; 27 | import com.voxelplugineering.voxelsniper.service.AbstractService; 28 | import com.voxelplugineering.voxelsniper.util.Context; 29 | 30 | /** 31 | * A trivially implemented {@link PermissionProxy} which always returns true. 32 | */ 33 | public class TrivialPermissionProxy extends AbstractService implements PermissionProxy 34 | { 35 | 36 | /** 37 | * Creates a new {@link TrivialPermissionProxy}. 38 | * 39 | * @param context The context 40 | */ 41 | public TrivialPermissionProxy(Context context) 42 | { 43 | super(context); 44 | } 45 | 46 | @Override 47 | protected void _init() 48 | { 49 | 50 | } 51 | 52 | @Override 53 | protected void _shutdown() 54 | { 55 | 56 | } 57 | 58 | @Override 59 | public boolean hasPermission(Player sniper, String permission) 60 | { 61 | return true; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/util/Pair.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.util; 25 | 26 | /** 27 | * A Connected pair of values. Named here as a key and value. 28 | * 29 | * @param the first type 30 | * @param the second type 31 | */ 32 | public class Pair 33 | { 34 | 35 | /** 36 | * The first value. 37 | */ 38 | private K key; 39 | /** 40 | * The second value. 41 | */ 42 | private V value; 43 | 44 | /** 45 | * Creates a new part. 46 | * 47 | * @param k The first value 48 | * @param v The second value 49 | */ 50 | public Pair(K k, V v) 51 | { 52 | this.key = k; 53 | this.value = v; 54 | } 55 | 56 | /** 57 | * Gets the first value. 58 | * 59 | * @return The first value 60 | */ 61 | public K getKey() 62 | { 63 | return this.key; 64 | } 65 | 66 | /** 67 | * Gets the second value. 68 | * 69 | * @return The second value 70 | */ 71 | public V getValue() 72 | { 73 | return this.value; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/entity/Action.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.entity; 25 | 26 | /** 27 | * Various user action types. 28 | */ 29 | public enum Action 30 | { 31 | /** 32 | * When the user has left-clicked air, usually pointing in a direction and not within range of 33 | * targeting a block. 34 | */ 35 | LEFT_CLICK_AIR, 36 | /** 37 | * When the user has left-clicked a block being pointed at. 38 | */ 39 | LEFT_CLICK_BLOCK, 40 | /** 41 | * When the user has middle-clicked air, usually pointing in a direction and not within range of 42 | * targeting a block. 43 | */ 44 | MIDDLE_CLICK_AIR, 45 | /** 46 | * When the user has middle-clicked a block being pointed at. 47 | */ 48 | MIDDLE_CLICK_BLOCK, 49 | /** 50 | * When the user has right-clicked air, usually pointing in a direction and not within range of 51 | * targeting a block. 52 | */ 53 | RIGHT_CLICK_AIR, 54 | /** 55 | * When the user has right-clicked a block being pointed at. 56 | */ 57 | RIGHT_CLICK_BLOCK; 58 | } 59 | -------------------------------------------------------------------------------- /src/test/java/com/voxelplugineering/voxelsniper/util/ContextTestUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.util; 25 | 26 | import static org.mockito.Mockito.mock; 27 | 28 | import com.voxelplugineering.voxelsniper.service.config.Configuration; 29 | 30 | /** 31 | * A util for creating mock {@link Context}s. 32 | */ 33 | public class ContextTestUtil 34 | { 35 | 36 | /** 37 | * Creates a completely mock context. 38 | */ 39 | public static Context create() 40 | { 41 | return create(null); 42 | } 43 | 44 | /** 45 | * Creates a context with the given objects in it, if null is passed for any params then the 46 | * class is mocked. 47 | */ 48 | public static Context create(Configuration conf) 49 | { 50 | Context c = new Context(); 51 | if (conf != null) 52 | { 53 | if (!conf.isInitialized()) 54 | { 55 | conf.start(); 56 | } 57 | c.put(conf); 58 | } else 59 | { 60 | c.put(mock(Configuration.class)); 61 | } 62 | return c; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.voxelplugineering 6 | VoxelGunsmith 7 | 2.0.0-SNAPSHOT 8 | jar 9 | 10 | VoxelGunsmith 11 | Common API for VoxelSniper implementations. 12 | http://voxelmodpack.com/ 13 | 14 | 15 | UTF-8 16 | UNKNOWN 17 | ${project.version} 18 | 19 | 20 | 21 | 22 | jenkins 23 | 24 | 25 | env.BUILD_NUMBER 26 | 27 | 28 | 29 | ${env.BUILD_NUMBER} 30 | ${project.version}-jnks${project.build.number} 31 | 32 | 33 | 34 | 35 | 36 | 37 | tvpt-repo 38 | TVPT Snapshot Repository 39 | http://vault.voxelmodpack.com/content/repositories/snapshots 40 | 41 | 42 | tvpt-repo 43 | TVPT Release Repository 44 | http://vault.voxelmodpack.com/content/repositories/releases 45 | 46 | 47 | 48 | 49 | 50 | com.google.guava 51 | guava 52 | 18.0 53 | compile 54 | false 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/config/ConfigValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.config; 25 | 26 | import java.lang.annotation.ElementType; 27 | import java.lang.annotation.Retention; 28 | import java.lang.annotation.RetentionPolicy; 29 | import java.lang.annotation.Target; 30 | 31 | /** 32 | * Annotates a field within a {@link ConfigurationContainer} to provide extra control and 33 | * information. 34 | */ 35 | @Retention(RetentionPolicy.RUNTIME) 36 | @Target(ElementType.FIELD) 37 | public @interface ConfigValue 38 | { 39 | 40 | /** 41 | * Gets the section of the value within the container. 42 | * 43 | * @return The section 44 | */ 45 | String section() default ""; 46 | 47 | /** 48 | * Gets the name of the value. If not set the name will default to the field name. 49 | * 50 | * @return The name 51 | */ 52 | String name() default ""; 53 | 54 | /** 55 | * Gets whether this value should be written out to its configuration file by default. 56 | * 57 | * @return Is hidden 58 | */ 59 | boolean hidden() default false; 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/text/TextFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.text; 25 | 26 | /** 27 | * Format codes for text formatting. 28 | */ 29 | @SuppressWarnings("javadoc") 30 | public enum TextFormat 31 | { 32 | 33 | BLACK("0"), 34 | DARK_BLUE("1"), 35 | DARK_GREEN("2"), 36 | DARK_AQUA("3"), 37 | DARK_RED("4"), 38 | DARK_PURPLE("5"), 39 | GOLD("6"), 40 | GRAY("7"), 41 | DARK_GRAY("8"), 42 | BLUE("9"), 43 | GREEN("a"), 44 | AQUA("b"), 45 | RED("c"), 46 | LIGHT_PURPLE("d"), 47 | YELLOW("e"), 48 | WHITE("f"), 49 | OBFUSCATED("k"), 50 | BOLD("l"), 51 | STRIKETHROUGH("m"), 52 | UNDERLINE("n"), 53 | ITALIC("o"), 54 | RESET("r"),; 55 | 56 | private String code; 57 | 58 | TextFormat(String c) 59 | { 60 | this.code = c; 61 | } 62 | 63 | /** 64 | * Returns the platform specific string representation of this text format. 65 | * 66 | * @return The format code 67 | */ 68 | @Override 69 | public String toString() 70 | { 71 | return "&" + this.code; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/world/queue/OfflineUndoHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.world.queue; 25 | 26 | import com.voxelplugineering.voxelsniper.service.Service; 27 | 28 | import java.util.Optional; 29 | 30 | /** 31 | * A handler for {@link UndoQueue}s for users who have disconnected from the system. These 32 | * {@link UndoQueue}s will be invalidated depending on the implementing class's policy. 33 | */ 34 | public interface OfflineUndoHandler extends Service 35 | { 36 | 37 | /** 38 | * Registers a new {@link UndoQueue} under the given key. 39 | * 40 | * @param key The key 41 | * @param undo The queue 42 | */ 43 | void register(String key, UndoQueue undo); 44 | 45 | /** 46 | * Gets the {@link UndoQueue} for the given key, if available. 47 | * 48 | * @param key The key 49 | * @return The undo queue, if available 50 | */ 51 | Optional get(String key); 52 | 53 | /** 54 | * Invalidates the given key and drops the associated {@link UndoQueue} from the handler if it 55 | * exists. 56 | * 57 | * @param key The key 58 | */ 59 | void invalidate(String key); 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/scheduler/Task.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.scheduler; 25 | 26 | /** 27 | * An abstract task for the scheduler proxy. 28 | */ 29 | public abstract class Task 30 | { 31 | 32 | private final Runnable runnable; 33 | private final int interval; 34 | 35 | /** 36 | * Creates a new {@link Task}. 37 | * 38 | * @param runnable The task's runnable 39 | * @param interval The interval of the task's execution, in milliseconds 40 | */ 41 | public Task(Runnable runnable, int interval) 42 | { 43 | this.runnable = runnable; 44 | this.interval = interval; 45 | } 46 | 47 | /** 48 | * Returns the task's runnable. 49 | * 50 | * @return The runnable 51 | */ 52 | public Runnable getRunnable() 53 | { 54 | return this.runnable; 55 | } 56 | 57 | /** 58 | * The task's interval in milliseconds. 59 | * 60 | * @return The interval 61 | */ 62 | public int getInterval() 63 | { 64 | return this.interval; 65 | } 66 | 67 | /** 68 | * Cancels this task. 69 | */ 70 | public abstract void cancel(); 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/util/brush/BrushVarsHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.util.brush; 25 | 26 | import com.voxelplugineering.voxelsniper.brush.BrushAction; 27 | import com.voxelplugineering.voxelsniper.brush.BrushKeys; 28 | import com.voxelplugineering.voxelsniper.brush.BrushVars; 29 | import com.voxelplugineering.voxelsniper.world.Block; 30 | 31 | import java.util.Optional; 32 | 33 | /** 34 | * A utility for getting common values from the {@link BrushVars}. 35 | */ 36 | public final class BrushVarsHelper 37 | { 38 | 39 | /** 40 | * Gets the target block adjusting for whether the player used the primary or alternate action. 41 | * 42 | * @param args The brush vars 43 | * @return The adjusted target block 44 | */ 45 | public static Optional getTargetBlock(BrushVars args) 46 | { 47 | BrushAction action = args.get(BrushKeys.ACTION, BrushAction.class).get(); 48 | if (action == BrushAction.PRIMARY) 49 | { 50 | return args.get(BrushKeys.TARGET_BLOCK, Block.class); 51 | } 52 | return args.get(BrushKeys.LAST_BLOCK, Block.class); 53 | } 54 | 55 | private BrushVarsHelper() 56 | { 57 | 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/world/queue/LightningChangeQueue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.world.queue; 25 | 26 | import com.voxelplugineering.voxelsniper.entity.Player; 27 | import com.voxelplugineering.voxelsniper.util.math.Vector3i; 28 | import com.voxelplugineering.voxelsniper.world.World; 29 | 30 | public class LightningChangeQueue extends ChangeQueue 31 | { 32 | 33 | private final Vector3i position; 34 | private boolean finished = false; 35 | 36 | public LightningChangeQueue(ChangeQueueOwner sniper, World world, Vector3i position) 37 | { 38 | super(sniper, world); 39 | this.position = position; 40 | } 41 | 42 | @Override 43 | public boolean isFinished() 44 | { 45 | return this.finished; 46 | } 47 | 48 | @Override 49 | public void flush() 50 | { 51 | this.owner.addPending(this); 52 | } 53 | 54 | @Override 55 | public int perform(int next) 56 | { 57 | this.world.spawnLightning(this.position, (Player) this.owner); 58 | this.finished = true; 59 | return 10; 60 | } 61 | 62 | @Override 63 | public void reset() 64 | { 65 | this.finished = false; 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/config/ConfigurationContainer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.config; 25 | 26 | import java.lang.annotation.ElementType; 27 | import java.lang.annotation.Retention; 28 | import java.lang.annotation.RetentionPolicy; 29 | import java.lang.annotation.Target; 30 | 31 | /** 32 | * Annotates a class as containing configuration values. All static fields in the class will be 33 | * considered configuration values and will be loaded into the {@link ConfigurationService}. 34 | */ 35 | @Retention(RetentionPolicy.RUNTIME) 36 | @Target(ElementType.TYPE) 37 | public @interface ConfigurationContainer 38 | { 39 | 40 | /** 41 | * Gets the container name. This will be used when persisting the configuration to file. 42 | * 43 | * @return The container name 44 | */ 45 | String name(); 46 | 47 | /** 48 | * Gets whether this configuration container should be persisted to file by default. 49 | * 50 | * @return Should persist 51 | */ 52 | boolean createByDefault() default true; 53 | 54 | /** 55 | * Gets the root configuration path. 56 | * 57 | * @return The root path 58 | */ 59 | String root() default ""; 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/entity/Player.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.entity; 25 | 26 | import com.voxelplugineering.voxelsniper.brush.BrushHolder; 27 | import com.voxelplugineering.voxelsniper.service.alias.AliasHandler; 28 | import com.voxelplugineering.voxelsniper.service.alias.AliasOwner; 29 | import com.voxelplugineering.voxelsniper.service.command.CommandSender; 30 | import com.voxelplugineering.voxelsniper.world.Block; 31 | import com.voxelplugineering.voxelsniper.world.queue.ChangeQueueOwner; 32 | 33 | import java.util.Optional; 34 | 35 | /** 36 | * Representation of a user within Gunsmith. Holds all state information relevant to the user. 37 | */ 38 | public interface Player extends CommandSender, Living, BrushHolder, ChangeQueueOwner, AliasOwner 39 | { 40 | 41 | /** 42 | * Returns this sniper's personal alias handler. 43 | * 44 | * @return The alias handler 45 | */ 46 | AliasHandler getAliasHandler(); 47 | 48 | /** 49 | * Gets the {@link Block} targeted by the player currently. 50 | * 51 | * @return The targeted block 52 | */ 53 | Optional getTargetBlock(); 54 | 55 | boolean isProcessing(); 56 | 57 | void setProcessing(boolean state); 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/config/BaseConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.config; 25 | 26 | import com.voxelplugineering.voxelsniper.service.config.ConfigValue; 27 | import com.voxelplugineering.voxelsniper.service.config.ConfigurationContainer; 28 | 29 | /** 30 | * Default base configuration values. 31 | */ 32 | @ConfigurationContainer(name = "additional", 33 | createByDefault = false) 34 | @SuppressWarnings("javadoc") 35 | public class BaseConfiguration 36 | { 37 | 38 | @ConfigValue(hidden = true) 39 | public static double playerEyeHeight = 1.62; 40 | @ConfigValue(hidden = true) 41 | public static int minimumWorldDepth = 0; 42 | @ConfigValue(hidden = true) 43 | public static int maximumWorldHeight = 255; 44 | @ConfigValue(hidden = true) 45 | public static double rayTraceStep = 0.2; 46 | 47 | public static String defaultBiomeName = "plains"; 48 | public static String defaultMaterialName = "air"; 49 | 50 | @ConfigValue(hidden = true) 51 | public static String eventBusThreadPrefix = "VoxelSniperEventBus-"; 52 | 53 | @ConfigValue(hidden = true) 54 | public static int aliasInterval = 30000; 55 | @ConfigValue(hidden = true) 56 | public static int changeInterval = 100; 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/world/Chunk.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.world; 25 | 26 | import com.voxelplugineering.voxelsniper.entity.Entity; 27 | import com.voxelplugineering.voxelsniper.util.math.Vector3i; 28 | 29 | /** 30 | * Represents a section of a world. 31 | */ 32 | public interface Chunk extends BlockVolume 33 | { 34 | 35 | /** 36 | * Gets the world that this chunk resides within. 37 | * 38 | * @return The world 39 | */ 40 | World getWorld(); 41 | 42 | /** 43 | * Returns a collection of all loaded entities within this region. 44 | * 45 | * @return The entities collection 46 | */ 47 | Iterable getLoadedEntities(); 48 | 49 | /** 50 | * Refreshes this chunk. 51 | */ 52 | void refreshChunk(); 53 | 54 | /** 55 | * Gets the minimal point of this chunk's bounding area. 56 | * 57 | * @return The minimal point 58 | */ 59 | Vector3i getMinBound(); 60 | 61 | /** 62 | * Gets the maximal point of this chunk's bounding area. 63 | * 64 | * @return The maximal point 65 | */ 66 | Vector3i getMaxBound(); 67 | 68 | /** 69 | * Gets the size of this chunk's bounding area. 70 | * 71 | * @return The size 72 | */ 73 | Vector3i getSize(); 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/event/DeadEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.event; 25 | 26 | import static com.google.common.base.Preconditions.checkArgument; 27 | import static com.google.common.base.Preconditions.checkNotNull; 28 | import static com.voxelplugineering.voxelsniper.service.eventbus.EventThreadingPolicy.Policy.ASYNCHRONOUS; 29 | 30 | import com.voxelplugineering.voxelsniper.service.eventbus.EventThreadingPolicy; 31 | 32 | /** 33 | * An event which wraps another event to indicate that it was 'dead'. An event being dead means that 34 | * it was posted but no handlers for it were registered. 35 | */ 36 | @EventThreadingPolicy(ASYNCHRONOUS) 37 | public class DeadEvent extends Event 38 | { 39 | 40 | private final Event event; 41 | 42 | /** 43 | * Creates a new {@link DeadEvent} wrapping the given event. 44 | * 45 | * @param event The event to wrap 46 | */ 47 | public DeadEvent(Event event) 48 | { 49 | checkNotNull(event); 50 | checkArgument(!event.getClass().equals(DeadEvent.class)); 51 | this.event = event; 52 | } 53 | 54 | /** 55 | * Gets the dead event. 56 | * 57 | * @return The event 58 | */ 59 | public Event getDeadEvent() 60 | { 61 | return this.event; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/scheduler/Scheduler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.scheduler; 25 | 26 | import com.voxelplugineering.voxelsniper.service.Service; 27 | 28 | import java.util.Optional; 29 | 30 | /** 31 | * A proxy for a specific implementations scheduler. 32 | */ 33 | public interface Scheduler extends Service 34 | { 35 | 36 | /** 37 | * Starts a new task synchronized to the main thread of the underlying platform. 38 | * 39 | * @param runnable The task runnable, cannot be null 40 | * @param interval The interval, in milliseconds 41 | * @return The new task 42 | */ 43 | Optional startSynchronousTask(Runnable runnable, int interval); 44 | 45 | /** 46 | * Starts a new task asynchronously. 47 | * 48 | * @param runnable The task runnable 49 | * @param interval The interval, in milliseconds 50 | * @return The new task 51 | */ 52 | Optional startAsynchronousTask(Runnable runnable, int interval); 53 | 54 | /** 55 | * Halts all the currently running tasks. 56 | */ 57 | void stopAllTasks(); 58 | 59 | /** 60 | * Gets all currently running tasks. 61 | * 62 | * @return The tasks 63 | */ 64 | Iterable getAllTasks(); 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/brush/BrushInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.brush; 25 | 26 | import java.lang.annotation.ElementType; 27 | import java.lang.annotation.Retention; 28 | import java.lang.annotation.RetentionPolicy; 29 | import java.lang.annotation.Target; 30 | 31 | /** 32 | * Marks a class as being a brush part and provides basic information about the brush. 33 | */ 34 | @Retention(RetentionPolicy.RUNTIME) 35 | @Target(ElementType.TYPE) 36 | public @interface BrushInfo 37 | { 38 | 39 | /** 40 | * Gets the brush part name. 41 | * 42 | * @return The brush name 43 | */ 44 | String name(); 45 | 46 | /** 47 | * Gets the type of the brush part. 48 | * 49 | * @return The brush part type 50 | */ 51 | BrushPartType type(); 52 | 53 | /** 54 | * Gets the help information for the brush part. 55 | * 56 | * @return The help message 57 | */ 58 | String help() default "No help is provided for this brush."; 59 | 60 | /** 61 | * Gets the parameters for this brush. 62 | * 63 | * @return The parameters 64 | */ 65 | BrushParam[] params() default {}; 66 | 67 | /** 68 | * Gets the permission key for this brush. 69 | * 70 | * @return The permission key 71 | */ 72 | String permission() default ""; 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/commands/ResetCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.commands; 25 | 26 | import com.voxelplugineering.voxelsniper.config.VoxelSniperConfiguration; 27 | import com.voxelplugineering.voxelsniper.entity.Player; 28 | import com.voxelplugineering.voxelsniper.service.command.CommandSender; 29 | import com.voxelplugineering.voxelsniper.util.Context; 30 | 31 | /** 32 | * A command get fetching the help information for a brush. 33 | */ 34 | public class ResetCommand extends Command 35 | { 36 | 37 | private final Context context; 38 | 39 | /** 40 | * Creates a new Command instance. 41 | * 42 | * @param context The context 43 | */ 44 | public ResetCommand(Context context) 45 | { 46 | super("voxelreset", "Resets your brush settings to the defualt values.", context); 47 | setAliases("d"); 48 | setPermissions("voxelsniper.command.reset"); 49 | this.context = context; 50 | } 51 | 52 | @Override 53 | public boolean execute(CommandSender sender, String[] args) 54 | { 55 | if (!sender.isPlayer()) 56 | { 57 | sender.sendMessage(VoxelSniperConfiguration.commandPlayerOnly); 58 | return true; 59 | } 60 | ((Player) sender).resetSettings(this.context); 61 | return true; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/brush/BrushHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.brush; 25 | 26 | import com.voxelplugineering.voxelsniper.util.Context; 27 | 28 | /** 29 | * An interface for anything which may have a brush selected. 30 | */ 31 | public interface BrushHolder 32 | { 33 | 34 | /** 35 | * Returns the brush manager specific to this user. 36 | * 37 | * @return The sniper's brush manager 38 | */ 39 | BrushManager getBrushManager(); 40 | 41 | /** 42 | * Sets this user's personal brush manager. 43 | * 44 | * @param manager The new brush manager 45 | */ 46 | void setBrushManager(BrushManager manager); 47 | 48 | /** 49 | * Returns the currently selected brush of this sniper. 50 | * 51 | * @return The brush 52 | */ 53 | BrushChain getCurrentBrush(); 54 | 55 | /** 56 | * Sets the current brush of this sniper. 57 | * 58 | * @param brush The new brush, cannot be null 59 | */ 60 | void setCurrentBrush(BrushChain brush); 61 | 62 | /** 63 | * Returns this sniper's current brush settings. 64 | * 65 | * @return The brush settings 66 | */ 67 | BrushVars getBrushVars(); 68 | 69 | /** 70 | * Resets the settings of this player to their default configuration. 71 | */ 72 | void resetSettings(Context context); 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/shape/csg/OffsetShape.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.shape.csg; 25 | 26 | import static com.google.common.base.Preconditions.checkNotNull; 27 | 28 | import com.voxelplugineering.voxelsniper.util.math.Vector3i; 29 | 30 | /** 31 | * A CSG shape offset by a vector. 32 | */ 33 | public abstract class OffsetShape implements CSGShape 34 | { 35 | 36 | private Vector3i origin; 37 | 38 | /** 39 | * Creates a {@link OffsetShape}. 40 | * 41 | * @param origin The offset 42 | */ 43 | public OffsetShape(Vector3i origin) 44 | { 45 | this.origin = checkNotNull(origin); 46 | } 47 | 48 | /** 49 | * Creates a default {@link OffsetShape}, offset by {0, 0, 0}. 50 | */ 51 | public OffsetShape() 52 | { 53 | this(Vector3i.ZERO); 54 | } 55 | 56 | @Override 57 | public boolean isMutable() 58 | { 59 | return false; 60 | } 61 | 62 | @Override 63 | public Vector3i getOrigin() 64 | { 65 | return this.origin; 66 | } 67 | 68 | @Override 69 | public void offset(Vector3i offset) 70 | { 71 | this.origin = this.origin.add(offset); 72 | } 73 | 74 | /** 75 | * Creates a copy of this {@link OffsetShape}. 76 | * 77 | * @return The copy 78 | */ 79 | @Override 80 | public abstract CSGShape clone(); 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/brush/shape/SnipeBrush.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.brush.shape; 25 | 26 | import com.voxelplugineering.voxelsniper.brush.Brush; 27 | import com.voxelplugineering.voxelsniper.brush.BrushContext; 28 | import com.voxelplugineering.voxelsniper.brush.BrushInfo; 29 | import com.voxelplugineering.voxelsniper.brush.BrushKeys; 30 | import com.voxelplugineering.voxelsniper.brush.BrushPartType; 31 | import com.voxelplugineering.voxelsniper.brush.BrushVars; 32 | import com.voxelplugineering.voxelsniper.brush.ExecutionResult; 33 | import com.voxelplugineering.voxelsniper.entity.Player; 34 | import com.voxelplugineering.voxelsniper.shape.Shape; 35 | import com.voxelplugineering.voxelsniper.shape.csg.CuboidShape; 36 | import com.voxelplugineering.voxelsniper.util.math.Vector3i; 37 | 38 | /** 39 | * Defines a single-block region. 40 | */ 41 | @BrushInfo(name = "snipe", 42 | type = BrushPartType.SHAPE, 43 | help = "Creates a shape around only your target block", 44 | permission = "voxelsniper.brush.snipe") 45 | public class SnipeBrush extends Brush 46 | { 47 | 48 | @Override 49 | public ExecutionResult run(Player player, BrushVars args) 50 | { 51 | Shape s = new CuboidShape(1, 1, 1, new Vector3i(0, 0, 0)); 52 | args.set(BrushContext.RUNTIME, BrushKeys.SHAPE, s); 53 | return ExecutionResult.continueExecution(); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/world/Block.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.world; 25 | 26 | import com.voxelplugineering.voxelsniper.util.math.Vector3i; 27 | import com.voxelplugineering.voxelsniper.world.material.MaterialState; 28 | 29 | import java.util.Optional; 30 | 31 | /** 32 | * Represents a material at a location in a world. 33 | */ 34 | public interface Block 35 | { 36 | 37 | /** 38 | * Gets the world that this block is within. 39 | * 40 | * @return The world 41 | */ 42 | World getWorld(); 43 | 44 | /** 45 | * Gets the location of this block. 46 | * 47 | * @return The location 48 | */ 49 | Location getLocation(); 50 | 51 | /** 52 | * Gets the position of this block within the world. 53 | * 54 | * @return The position 55 | */ 56 | Vector3i getPosition(); 57 | 58 | /** 59 | * Gets the material currently at the location of this block. Unless overridden by the specific 60 | * implementation this material may be out of date to the underlying world. 61 | * 62 | * @return The material 63 | */ 64 | MaterialState getMaterial(); 65 | 66 | /** 67 | * Gets the block at the given offset relative to this block. 68 | * 69 | * @param offset The offset 70 | * @return The block, if available 71 | */ 72 | Optional withOffset(Vector3i offset); 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/brush/misc/LightningBrush.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.brush.misc; 25 | 26 | import com.voxelplugineering.voxelsniper.brush.Brush; 27 | import com.voxelplugineering.voxelsniper.brush.BrushInfo; 28 | import com.voxelplugineering.voxelsniper.brush.BrushPartType; 29 | import com.voxelplugineering.voxelsniper.brush.BrushVars; 30 | import com.voxelplugineering.voxelsniper.brush.ExecutionResult; 31 | import com.voxelplugineering.voxelsniper.entity.Player; 32 | import com.voxelplugineering.voxelsniper.util.brush.BrushVarsHelper; 33 | import com.voxelplugineering.voxelsniper.world.Block; 34 | import com.voxelplugineering.voxelsniper.world.queue.LightningChangeQueue; 35 | 36 | /** 37 | * A brush which spawns a bolt of lightning at the targeted location. 38 | */ 39 | @BrushInfo(name = "lightning", 40 | type = BrushPartType.MISC, 41 | help = "Strikes lightning at your targeted position", 42 | permission = "voxelsniper.brush.lightning") 43 | public class LightningBrush extends Brush 44 | { 45 | 46 | @Override 47 | public ExecutionResult run(Player player, BrushVars args) 48 | { 49 | Block l = BrushVarsHelper.getTargetBlock(args).get(); 50 | new LightningChangeQueue(player, player.getWorld(), l.getPosition()).flush(); 51 | return ExecutionResult.continueExecution(); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/registry/WorldRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.registry; 25 | 26 | import com.voxelplugineering.voxelsniper.service.Service; 27 | import com.voxelplugineering.voxelsniper.world.World; 28 | 29 | import java.util.Optional; 30 | 31 | /** 32 | * A registry for world data. 33 | * 34 | * @param The underlying world type. 35 | */ 36 | public interface WorldRegistry extends Service 37 | { 38 | 39 | /** 40 | * Gets the world with the given name. 41 | * 42 | * @param name The name 43 | * @return The world, if found 44 | */ 45 | Optional getWorld(String name); 46 | 47 | /** 48 | * Gets the world representing the given underlying world object. 49 | * 50 | * @param world The underlying world type 51 | * @return The world, if found 52 | */ 53 | Optional getWorld(T world); 54 | 55 | /** 56 | * Gets a collection of all currently registered worlds. 57 | * 58 | * @return The worlds 59 | */ 60 | Iterable getLoadedWorlds(); 61 | 62 | /** 63 | * Removes the world from the registry by name. 64 | * 65 | * @param name The name 66 | */ 67 | void invalidate(String name); 68 | 69 | /** 70 | * Removes the given world from the registry. 71 | * 72 | * @param world The key 73 | */ 74 | void invalidate(T world); 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/util/ShapeValidation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.util; 25 | 26 | import static com.google.common.base.Preconditions.checkNotNull; 27 | 28 | import com.voxelplugineering.voxelsniper.shape.Shape; 29 | import com.voxelplugineering.voxelsniper.util.math.Vector3i; 30 | 31 | /** 32 | * A set of utilities for validating various shapes. 33 | */ 34 | public final class ShapeValidation 35 | { 36 | 37 | private ShapeValidation() 38 | { 39 | 40 | } 41 | 42 | /** 43 | * Checks whether the given shape is a disc. 44 | * 45 | * @param shape The shape 46 | * @return Is a disc 47 | */ 48 | public static boolean isDisc(Shape shape) 49 | { 50 | checkNotNull(shape); 51 | if (shape.getHeight() != 1) 52 | { 53 | return false; 54 | } 55 | double rx = (shape.getWidth() - 1) / 2d; 56 | double rz = (shape.getWidth() - 1) / 2d; 57 | Vector3i orig = shape.getOrigin(); 58 | for (int x = 0; x < shape.getWidth(); x++) 59 | { 60 | int dx = x - orig.getX(); 61 | for (int z = 0; z < shape.getLength(); z++) 62 | { 63 | int dz = z - orig.getZ(); 64 | if (shape.get(x, 0, z, false) ^ ((dx / rx) * (dx / rx) + (dz / rz) * (dz / rz) <= 1)) 65 | { 66 | return false; 67 | } 68 | } 69 | } 70 | return true; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/brush/shape/BallBrush.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.brush.shape; 25 | 26 | import com.voxelplugineering.voxelsniper.brush.Brush; 27 | import com.voxelplugineering.voxelsniper.brush.BrushContext; 28 | import com.voxelplugineering.voxelsniper.brush.BrushInfo; 29 | import com.voxelplugineering.voxelsniper.brush.BrushKeys; 30 | import com.voxelplugineering.voxelsniper.brush.BrushPartType; 31 | import com.voxelplugineering.voxelsniper.brush.BrushVars; 32 | import com.voxelplugineering.voxelsniper.brush.ExecutionResult; 33 | import com.voxelplugineering.voxelsniper.entity.Player; 34 | import com.voxelplugineering.voxelsniper.shape.Shape; 35 | import com.voxelplugineering.voxelsniper.shape.csg.EllipsoidShape; 36 | import com.voxelplugineering.voxelsniper.util.math.Vector3i; 37 | 38 | /** 39 | * The ball brush, defines a spherical region for later brushes to use. 40 | */ 41 | @BrushInfo(name = "ball", 42 | type = BrushPartType.SHAPE, 43 | help = "Creates a spherical shape", 44 | permission = "voxelsniper.brush.ball") 45 | public class BallBrush extends Brush 46 | { 47 | 48 | @Override 49 | public ExecutionResult run(Player player, BrushVars args) 50 | { 51 | double size = args.get(BrushKeys.BRUSH_SIZE, Double.class).get(); 52 | Shape s = new EllipsoidShape(size, size, size, new Vector3i(size, size, size)); 53 | args.set(BrushContext.RUNTIME, BrushKeys.SHAPE, s); 54 | return ExecutionResult.continueExecution(); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/platform/PlatformProxy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.platform; 25 | 26 | import com.voxelplugineering.voxelsniper.service.Service; 27 | 28 | import java.io.File; 29 | 30 | /** 31 | * The specific implementation core class, provides direct platform utilities and versioning for 32 | * Gunsmith. 33 | */ 34 | public interface PlatformProxy extends Service 35 | { 36 | 37 | /** 38 | * Gets the name of the platform, examples may include "Bukkit", "Spigot", "Sponge", etc. 39 | * 40 | * @return The name of the platform 41 | */ 42 | String getPlatformName(); 43 | 44 | /** 45 | * Gets the version of the platform. 46 | * 47 | * @return The version of the platform 48 | */ 49 | String getVersion(); 50 | 51 | /** 52 | * Gets the full version string of the platform. 53 | * 54 | * @return The full version string of the platform 55 | */ 56 | String getFullVersion(); 57 | 58 | /** 59 | * Gets the root data source provider. 60 | * 61 | * @return The root data source provider 62 | */ 63 | File getRoot(); 64 | 65 | /** 66 | * Gets the Configuration file for Metrics to be used. 67 | * 68 | * @return The file containing the configuration for Metrics 69 | */ 70 | File getMetricsFile(); 71 | 72 | /** 73 | * Gets the number of players online. 74 | * 75 | * @return The number of players online 76 | */ 77 | int getNumberOfPlayersOnline(); 78 | 79 | } 80 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | VoxelGunsmith [![Build Status](https://travis-ci.org/TVPT/VoxelGunsmith.svg?branch=master)](https://travis-ci.org/TVPT/VoxelGunsmith) 2 | =============== 3 | 4 | The premiere long-distance brush editor API for VoxelSniper. 5 | 6 | Compilation 7 | ----------- 8 | 9 | We use Gradle for dependencies and building. 10 | 11 | - Check out this repository. 12 | - Run ```./gradlew``` 13 | 14 | The master branch is automatically build on our jenkins server ([VoxelSniper Jenkins Job][JenkinsJob]). 15 | 16 | Issue Tracker Notes 17 | ------------------- 18 | 19 | How do I create a ticket the right way? 20 | 21 | - Seperate your reports. You think there is something wrong, but also want this new brush? Make life easier for us and create two tickets. We'd appriciate it big times. 22 | - Don't tell us your story of life. We want facts and information. The more information about `the Problem` you give us, the easier it is for us to figure out what's wrong. 23 | - Check the closed tickets first. Maybe someone created a similiar ticket already. If you think it's unresolved, then give us more information on there instead. 24 | 25 | 26 | ### Enhancement Request 27 | 28 | This is where imagination comes in, but make sure to keep as it easy for us. As mentioned, we don't want your story of life. We want to know what you think would be a good enhancement. 29 | 30 | Here is an example of an enhancement request. 31 | 32 | Title: `Brush that creates lines` 33 | 34 | ``` 35 | Enhancement Proposal: 36 | Creating a brush that creates a line. 37 | 38 | Suggested usage: 39 | You click two points with your arrow and it will create a line with blocks. 40 | 41 | Reason of proposal: 42 | It would be useful, since off angle lines are sometimes hard to make. 43 | ``` 44 | 45 | Keep in mind that those are guidelines. 46 | We will still look into stuff that does not follow these guidlines, but it will give you an idea what we want in a ticket and make our life easier. 47 | 48 | Pull Requests 49 | ------------- 50 | 51 | We do accept pull requests and enhancements from third parties. Guidelines how to submit your pull requests properly and how to format your code will come. 52 | 53 | Some rough guidelines for now: 54 | 55 | - Keep the number of commits to a minimum. We want to look over the commit and basically see what you've done. 56 | - Coding guidelines should try to comply to the checkstyle rules (checkstyle.xml) but not blindly. Use your mind to make smart decissions. 57 | - Give us a good description to what you've done. 58 | - Try to submit one change in one pull request and try to link it to the issue in the tracker if possible. 59 | 60 | [VoxelSniperWiki]: http://voxelwiki.com/minecraft/VoxelSniper/ 61 | [JenkinsJob]: http://ci.voxelmodpack.com/view/VoxelSniper/ 62 | [Bukkit]: http://bukkit.org/ 63 | [Maven]: http://maven.apache.org/ 64 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/util/FutureFutureCallable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.util; 25 | 26 | import com.voxelplugineering.voxelsniper.service.event.Event; 27 | 28 | import java.util.Collection; 29 | import java.util.Iterator; 30 | import java.util.concurrent.Callable; 31 | import java.util.concurrent.Future; 32 | 33 | /** 34 | * A {@link Callable} which waits for all {@link Future}s from a collection of futures to complete. 35 | */ 36 | public class FutureFutureCallable implements Callable 37 | { 38 | 39 | private final Collection> watchList; 40 | private final Event returnValue; 41 | 42 | /** 43 | * Creates a new {@link FutureFutureCallable}. 44 | * 45 | * @param futures The collection of futures to watch 46 | * @param event The event to return once the futures are complete 47 | */ 48 | public FutureFutureCallable(Collection> futures, Event event) 49 | { 50 | this.watchList = futures; 51 | this.returnValue = event; 52 | } 53 | 54 | @Override 55 | public Event call() throws Exception 56 | { 57 | for (Iterator> it = this.watchList.iterator(); it.hasNext();) 58 | { 59 | Future next = it.next(); 60 | try 61 | { 62 | next.get(); 63 | } catch (Exception ignored) 64 | { 65 | } finally 66 | { 67 | it.remove(); 68 | } 69 | } 70 | return this.returnValue; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/brush/shape/VoxelBrush.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.brush.shape; 25 | 26 | import com.voxelplugineering.voxelsniper.brush.Brush; 27 | import com.voxelplugineering.voxelsniper.brush.BrushContext; 28 | import com.voxelplugineering.voxelsniper.brush.BrushInfo; 29 | import com.voxelplugineering.voxelsniper.brush.BrushKeys; 30 | import com.voxelplugineering.voxelsniper.brush.BrushPartType; 31 | import com.voxelplugineering.voxelsniper.brush.BrushVars; 32 | import com.voxelplugineering.voxelsniper.brush.ExecutionResult; 33 | import com.voxelplugineering.voxelsniper.entity.Player; 34 | import com.voxelplugineering.voxelsniper.shape.Shape; 35 | import com.voxelplugineering.voxelsniper.shape.csg.CuboidShape; 36 | import com.voxelplugineering.voxelsniper.util.math.Vector3i; 37 | 38 | /** 39 | * A shape brush which defines a cubic area with a side length of {@code brushSize * 2 + 1}. 40 | */ 41 | @BrushInfo(name = "voxel", 42 | type = BrushPartType.SHAPE, 43 | help = "Creates a cube shape", 44 | permission = "voxelsniper.brush.voxel") 45 | public class VoxelBrush extends Brush 46 | { 47 | 48 | @Override 49 | public ExecutionResult run(Player player, BrushVars args) 50 | { 51 | int size = (int) Math.floor(args.get(BrushKeys.BRUSH_SIZE, Double.class).get()); 52 | Shape s = new CuboidShape(size * 2 + 1, size * 2 + 1, size * 2 + 1, new Vector3i(size, size, size)); 53 | args.set(BrushContext.RUNTIME, BrushKeys.SHAPE, s); 54 | return ExecutionResult.continueExecution(); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/text/TextFormatParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.text; 25 | 26 | import com.voxelplugineering.voxelsniper.service.AbstractService; 27 | import com.voxelplugineering.voxelsniper.service.Service; 28 | import com.voxelplugineering.voxelsniper.util.Context; 29 | 30 | /** 31 | * A proxy for platform specific format codes. 32 | */ 33 | public interface TextFormatParser extends Service 34 | { 35 | 36 | /** 37 | * Gets the platform specific format code for the given {@link TextFormat}. 38 | * 39 | * @param format The format code to convert 40 | * @return The platform format code 41 | */ 42 | String getFormat(TextFormat format); 43 | 44 | /** 45 | * A trivial {@link TextFormatParser} which simply returns the name of the {@link TextFormat}. 46 | */ 47 | public static class TrivialTextFormatParser extends AbstractService implements TextFormatParser 48 | { 49 | 50 | /** 51 | * Creates a new {@link TrivialTextFormatParser}. 52 | * 53 | * @param context The context 54 | */ 55 | public TrivialTextFormatParser(Context context) 56 | { 57 | super(context); 58 | } 59 | 60 | @Override 61 | public String getFormat(TextFormat format) 62 | { 63 | return ""; 64 | } 65 | 66 | @Override 67 | protected void _init() 68 | { 69 | } 70 | 71 | @Override 72 | protected void _shutdown() 73 | { 74 | } 75 | 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/eventbus/EventThreadingPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.eventbus; 25 | 26 | import static java.lang.annotation.ElementType.TYPE; 27 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 28 | 29 | import java.lang.annotation.Retention; 30 | import java.lang.annotation.Target; 31 | import java.util.concurrent.ExecutorService; 32 | 33 | /** 34 | * Annotates an event to specify the threading policy that should be followed by {@link EventBus}s 35 | * handling of the event when it is posted to the bus. 36 | */ 37 | @Retention(RUNTIME) 38 | @Target(TYPE) 39 | public @interface EventThreadingPolicy 40 | { 41 | 42 | /** 43 | * Gets the threading policy for the event. 44 | */ 45 | Policy value() default Policy.ASYNCHRONOUS_SEQUENTIAL; 46 | 47 | /** 48 | * Possible threading policies for an event post.
  • SYNCHRONIZED: handlers will be called 49 | * from the posting thread in sequential order.
  • ASYNCHRONOUS_SEQUENTIAL: handlers will 50 | * be called asynchronously to the posting thread, handlers will be called sequentially.
  • 51 | *
  • ASYNCHRONOUS: handlers will be called asynchronously to the posting thread, depending on 52 | * if the {@link EventBus}'s {@link ExecutorService} has enough threads available, the handlers 53 | * may or may not be executed sequentially.
54 | */ 55 | @SuppressWarnings("javadoc") 56 | public static enum Policy 57 | { 58 | SYNCHRONIZED, 59 | ASYNCHRONOUS_SEQUENTIAL, 60 | ASYNCHRONOUS 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/commands/RedoCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.commands; 25 | 26 | import com.voxelplugineering.voxelsniper.config.VoxelSniperConfiguration; 27 | import com.voxelplugineering.voxelsniper.entity.Player; 28 | import com.voxelplugineering.voxelsniper.service.command.CommandSender; 29 | import com.voxelplugineering.voxelsniper.util.Context; 30 | 31 | /** 32 | * A command get fetching the help information for a brush. 33 | */ 34 | public class RedoCommand extends Command 35 | { 36 | 37 | /** 38 | * Creates a new Command instance. 39 | * 40 | * @param context The context 41 | */ 42 | public RedoCommand(Context context) 43 | { 44 | super("redo", "Redoes your last n undone changes. Usage: /redo [n]", context); 45 | setAliases("vredo"); 46 | setPermissions("voxelsniper.command.redo"); 47 | } 48 | 49 | @Override 50 | public boolean execute(CommandSender sender, String[] args) 51 | { 52 | if (!sender.isPlayer()) 53 | { 54 | sender.sendMessage(VoxelSniperConfiguration.commandPlayerOnly); 55 | return true; 56 | } 57 | int n = 1; 58 | if (args.length > 0) 59 | { 60 | try 61 | { 62 | n = Integer.parseInt(args[0]); 63 | } catch (NumberFormatException ignored) 64 | { 65 | assert true; 66 | } 67 | if (n < 1) 68 | { 69 | n = 1; 70 | } 71 | } 72 | ((Player) sender).redoHistory(n); 73 | return true; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/commands/UndoCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.commands; 25 | 26 | import com.voxelplugineering.voxelsniper.config.VoxelSniperConfiguration; 27 | import com.voxelplugineering.voxelsniper.entity.Player; 28 | import com.voxelplugineering.voxelsniper.service.command.CommandSender; 29 | import com.voxelplugineering.voxelsniper.util.Context; 30 | 31 | /** 32 | * A command get fetching the help information for a brush. 33 | */ 34 | public class UndoCommand extends Command 35 | { 36 | 37 | /** 38 | * Creates a new Command instance. 39 | * 40 | * @param context The context 41 | */ 42 | public UndoCommand(Context context) 43 | { 44 | super("undo", "Undoes your last n changes. Usage: /undo [n]", context); 45 | setAliases("u", "vundo"); 46 | setPermissions("voxelsniper.command.undo"); 47 | } 48 | 49 | @Override 50 | public boolean execute(CommandSender sender, String[] args) 51 | { 52 | if (!sender.isPlayer()) 53 | { 54 | sender.sendMessage(VoxelSniperConfiguration.commandPlayerOnly); 55 | return true; 56 | } 57 | int n = 1; 58 | if (args.length > 0) 59 | { 60 | try 61 | { 62 | n = Integer.parseInt(args[0]); 63 | } catch (NumberFormatException ignored) 64 | { 65 | assert true; 66 | } 67 | if (n < 1) 68 | { 69 | n = 1; 70 | } 71 | } 72 | ((Player) sender).undoHistory(n); 73 | return true; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/world/queue/Change.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.world.queue; 25 | 26 | /** 27 | * Represents a single change. 28 | */ 29 | public abstract class Change 30 | { 31 | 32 | private final int x; 33 | private final int y; 34 | private final int z; 35 | 36 | /** 37 | * Creates a new change at the given location. 38 | * 39 | * @param x The x position of the change 40 | * @param y The y position of the change 41 | * @param z The z position of the change 42 | */ 43 | public Change(int x, int y, int z) 44 | { 45 | this.x = x; 46 | this.y = y; 47 | this.z = z; 48 | } 49 | 50 | /** 51 | * Returns the x position of this change. 52 | * 53 | * @return The x position 54 | */ 55 | public int getX() 56 | { 57 | return this.x; 58 | } 59 | 60 | /** 61 | * Returns the y position of this change. 62 | * 63 | * @return The y position 64 | */ 65 | public int getY() 66 | { 67 | return this.y; 68 | } 69 | 70 | /** 71 | * Returns the z position of this change. 72 | * 73 | * @return The z position 74 | */ 75 | public int getZ() 76 | { 77 | return this.z; 78 | } 79 | 80 | /** 81 | * Returns a new Change representing the inverse operation of this change. 82 | * 83 | * @return The inverse change 84 | */ 85 | public abstract Change getInverse(); 86 | 87 | /** 88 | * Returns a copy of this change. 89 | * 90 | * @return The clone 91 | */ 92 | @Override 93 | public abstract Change clone(); 94 | 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/alias/AnnotationScanner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.alias; 25 | 26 | import com.voxelplugineering.voxelsniper.service.Service; 27 | import com.voxelplugineering.voxelsniper.service.meta.AnnotationConsumer; 28 | 29 | import java.lang.annotation.Annotation; 30 | import java.net.URLClassLoader; 31 | 32 | /** 33 | * A service for scanning over all classes in a classloader and detecting classes annotated with 34 | * registered annotations. 35 | */ 36 | public interface AnnotationScanner extends Service 37 | { 38 | 39 | /** 40 | * Registers a consumer for a particular annotation. All classes in scanned classloaders which 41 | * are annotated with this annotation will be passed to the given consumer. 42 | * 43 | * @param target The targeted annotation 44 | * @param consumer The annotation consumer 45 | */ 46 | void register(Class target, AnnotationConsumer consumer); 47 | 48 | /** 49 | * Scans the given {@link URLClassLoader} for registered annotations. 50 | * 51 | * @param loader The class loader to scan 52 | */ 53 | void scanClassPath(URLClassLoader loader); 54 | 55 | /** 56 | * Adds an exclusion to the scanner. All classes with fully qualified names which start with an 57 | * item in the exclusion list will be ignored. 58 | * 59 | *

Packages should be deliminated with a '/' for the purposes of this exclusion list (eg. 60 | * 'com/sun/' would exclude all classes in the com.sun package).

61 | * 62 | * @param exc The new scanner exclusion 63 | */ 64 | void addScannerExclusion(String exc); 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/command/CommandHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.command; 25 | 26 | import com.voxelplugineering.voxelsniper.commands.Command; 27 | import com.voxelplugineering.voxelsniper.service.Service; 28 | 29 | import java.util.Optional; 30 | 31 | /** 32 | * Represents a handler for command execution and registration. 33 | */ 34 | public interface CommandHandler extends Service 35 | { 36 | 37 | /** 38 | * Gets this handler's {@link CommandRegistrar} if it has one. 39 | * 40 | * @return The command registrar 41 | */ 42 | Optional getRegistrar(); 43 | 44 | /** 45 | * Sets this handler's {@link CommandRegistrar}. 46 | * 47 | * @param registrar The new command registrar 48 | */ 49 | void setRegistrar(CommandRegistrar registrar); 50 | 51 | /** 52 | * Registers the given command with this handler, and its {@link CommandRegistrar} if it has 53 | * one. 54 | * 55 | * @param cmd The command to register 56 | */ 57 | void registerCommand(Command cmd); 58 | 59 | /** 60 | * Executes the given command from the given sender. 61 | * 62 | * @param sender The command sender 63 | * @param fullCommand The full command string including args 64 | */ 65 | void onCommand(CommandSender sender, String fullCommand); 66 | 67 | /** 68 | * Executes the given command with arguments from the given sender. 69 | * 70 | * @param sender The command sender 71 | * @param command The command name 72 | * @param args The command arguments 73 | */ 74 | void onCommand(CommandSender sender, String command, String... args); 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/EntityRegistryService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service; 25 | 26 | import com.google.common.collect.Lists; 27 | import com.voxelplugineering.voxelsniper.entity.EntityType; 28 | import com.voxelplugineering.voxelsniper.registry.WeakRegistry; 29 | import com.voxelplugineering.voxelsniper.service.registry.EntityRegistry; 30 | import com.voxelplugineering.voxelsniper.util.Context; 31 | 32 | import java.util.Optional; 33 | 34 | public class EntityRegistryService extends AbstractService implements EntityRegistry { 35 | 36 | private WeakRegistry registry; 37 | 38 | public EntityRegistryService(Context context) { 39 | super(context); 40 | } 41 | 42 | @Override 43 | protected void _init() { 44 | this.registry = new WeakRegistry<>(); 45 | this.registry.setCaseSensitiveKeys(false); 46 | } 47 | 48 | @Override 49 | protected void _shutdown() { 50 | this.registry = null; 51 | } 52 | 53 | @Override 54 | public Optional getEntityType(String name) { 55 | check("getEntityType"); 56 | return this.registry.get(name); 57 | } 58 | 59 | @Override 60 | public Optional getEntityType(T type) { 61 | check("getEntityType"); 62 | return this.registry.get(type); 63 | } 64 | 65 | @Override 66 | public void registerEntityType(String name, T object, EntityType entityType) { 67 | check("registerEntityType"); 68 | this.registry.register(name, object, entityType); 69 | } 70 | 71 | @Override 72 | public Iterable getEntityTypes() { 73 | check("getEntityTypes"); 74 | return Lists.newArrayList(this.registry.values()); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/util/defaults/DefaultAliasBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.util.defaults; 25 | 26 | import com.voxelplugineering.voxelsniper.service.alias.AliasHandler; 27 | import com.voxelplugineering.voxelsniper.service.alias.AliasRegistry; 28 | 29 | /** 30 | * A utility for loading default aliases. 31 | */ 32 | public final class DefaultAliasBuilder 33 | { 34 | 35 | private DefaultAliasBuilder() 36 | { 37 | 38 | } 39 | 40 | /** 41 | * Loads the standard default aliases into the given {@link AliasHandler}. 42 | * 43 | * @param registry The handler 44 | */ 45 | public static void loadDefaultAliases(AliasHandler registry) 46 | { 47 | 48 | { // brushes 49 | 50 | if (!registry.hasTarget("brush")) 51 | { 52 | registry.registerTarget("brush"); 53 | } 54 | AliasRegistry alias = registry.getRegistry("brush").get(); 55 | 56 | alias.register("b", "ball"); 57 | alias.register("d", "disc"); 58 | alias.register("cyl", "disc"); 59 | alias.register("m", "material"); 60 | alias.register("mm", "materialmask material"); 61 | alias.register("s", "snipe"); 62 | alias.register("v", "voxel"); 63 | alias.register("vd", "voxeldisc"); 64 | alias.register("over", "overlay"); 65 | alias.register("e melt", "ball melt"); 66 | alias.register("e fill", "ball fill"); 67 | alias.register("sp", "splatter"); 68 | alias.register("sb", "ball splatter"); 69 | alias.register("sd", "disc splatter"); 70 | alias.register("sover", "splatter overlay"); 71 | 72 | } 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/config/Configuration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.config; 25 | 26 | import com.voxelplugineering.voxelsniper.service.Service; 27 | 28 | import java.io.File; 29 | import java.io.IOException; 30 | 31 | /** 32 | * A storage space for configuration. 33 | */ 34 | public interface Configuration extends Service 35 | { 36 | 37 | /** 38 | * Registers the given configuration container. 39 | * 40 | * @param cls The configuration container class 41 | */ 42 | void register(Class cls); 43 | 44 | /** 45 | * Initializes available configuration containers into the given directory. This will load 46 | * configuration values from config files if they exist, and create new files if they do not. 47 | * 48 | * @param dir The directory 49 | * @param includeHidden If this should include hidden configuration 50 | * @throws IOException If there is an issue writing or reading the configuration files 51 | */ 52 | void initialize(File dir, boolean includeHidden) throws IOException; 53 | 54 | /** 55 | * Saves all available configuration containers into the given directory. 56 | * 57 | * @param dir The directory 58 | * @param includeHidden If this should include hidden configuration 59 | * @throws IOException If there is an issue writing the configuration files 60 | */ 61 | void save(File dir, boolean includeHidden) throws IOException; 62 | 63 | /** 64 | * Loads all available configuration containers from the given directory. 65 | * 66 | * @param dir The directory 67 | * @throws IOException If there is an issue reading the configuration files 68 | */ 69 | void load(File dir) throws IOException; 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/world/CommonBlock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.world; 25 | 26 | import static com.google.common.base.Preconditions.checkNotNull; 27 | 28 | import com.voxelplugineering.voxelsniper.util.math.Vector3i; 29 | import com.voxelplugineering.voxelsniper.world.material.MaterialState; 30 | 31 | import java.util.Optional; 32 | 33 | /** 34 | * A combination location and material representation of a single voxel. The location is immutable. 35 | */ 36 | public class CommonBlock implements Block 37 | { 38 | 39 | private final Location location; 40 | private final MaterialState material; 41 | 42 | /** 43 | * Creates a new CommonBlock with the given location and material. 44 | * 45 | * @param location The location, cannot be null 46 | * @param material The material, cannot be null 47 | */ 48 | public CommonBlock(Location location, MaterialState material) 49 | { 50 | this.location = checkNotNull(location, "Location cannot be null"); 51 | this.material = checkNotNull(material, "Material cannot be null"); 52 | } 53 | 54 | @Override 55 | public final Location getLocation() 56 | { 57 | return this.location; 58 | } 59 | 60 | @Override 61 | public MaterialState getMaterial() 62 | { 63 | return this.material; 64 | } 65 | 66 | @Override 67 | public World getWorld() 68 | { 69 | return this.location.getWorld(); 70 | } 71 | 72 | @Override 73 | public Vector3i getPosition() 74 | { 75 | return this.location.getFlooredPosition(); 76 | } 77 | 78 | @Override 79 | public Optional withOffset(Vector3i offset) 80 | { 81 | // TODO Auto-generated method stub 82 | return null; 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/alias/AliasSaveTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.alias; 25 | 26 | import static com.google.common.base.Preconditions.checkNotNull; 27 | 28 | import com.voxelplugineering.voxelsniper.GunsmithLogger; 29 | 30 | import com.google.common.collect.Lists; 31 | 32 | import java.io.IOException; 33 | import java.util.Iterator; 34 | import java.util.List; 35 | 36 | /** 37 | * A task for saving aliases. 38 | */ 39 | public class AliasSaveTask implements Runnable 40 | { 41 | 42 | private List dirty; 43 | 44 | /** 45 | * Creates a new {@link AliasSaveTask}. 46 | */ 47 | public AliasSaveTask() 48 | { 49 | this.dirty = Lists.newArrayList(); 50 | } 51 | 52 | /** 53 | * Queues the given {@link AliasHandler} to be saved in the next pass. 54 | * 55 | * @param alias The alias handler to queue 56 | */ 57 | public synchronized void addDirty(AliasHandler alias) 58 | { 59 | checkNotNull(alias); 60 | if (!this.dirty.contains(alias)) 61 | { 62 | this.dirty.add(alias); 63 | } 64 | } 65 | 66 | /** 67 | * Saves all pending aliases. 68 | */ 69 | public synchronized void flush() 70 | { 71 | run(); 72 | } 73 | 74 | @Override 75 | public synchronized void run() 76 | { 77 | for (Iterator it = this.dirty.iterator(); it.hasNext();) 78 | { 79 | AliasHandler alias = it.next(); 80 | try 81 | { 82 | alias.save(); 83 | } catch (IOException e) 84 | { 85 | GunsmithLogger.getLogger().error(e, "Error saving aliases"); 86 | } 87 | it.remove(); 88 | } 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/registry/BiomeRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.registry; 25 | 26 | import com.voxelplugineering.voxelsniper.service.Service; 27 | import com.voxelplugineering.voxelsniper.world.biome.Biome; 28 | 29 | import java.util.Optional; 30 | 31 | /** 32 | * A registry for biome type. 33 | * 34 | * @param The biome type 35 | */ 36 | public interface BiomeRegistry extends Service 37 | { 38 | 39 | /** 40 | * Gets the {@link Biome} with the given name. 41 | * 42 | * @param name The name 43 | * @return The biome 44 | */ 45 | Optional getBiome(String name); 46 | 47 | /** 48 | * Gets the {@link Biome} which represents the given underlying type. 49 | * 50 | * @param biome The underlying biome 51 | * @return The gunsmith biome 52 | */ 53 | Optional getBiome(T biome); 54 | 55 | /** 56 | * Registers a biome type. 57 | * 58 | * @param name The name 59 | * @param object The underlying biome object 60 | * @param biome The gunsmith biome object 61 | */ 62 | void registerBiome(String name, T object, Biome biome); 63 | 64 | /** 65 | * Registers a biome type. 66 | * 67 | * @param object The underlying biome object 68 | * @param biome The gunsmith biome object 69 | */ 70 | default void registerBiome(T object, Biome biome) 71 | { 72 | registerBiome(biome.getName(), object, biome); 73 | } 74 | 75 | /** 76 | * Gets a collection of all registered biomes. 77 | * 78 | * @return The biomes 79 | */ 80 | Iterable getBiomes(); 81 | 82 | /** 83 | * Gets the default biome. 84 | * 85 | * @return The default biome 86 | */ 87 | Biome getDefaultBiome(); 88 | 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/event/SnipeEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.event; 25 | 26 | import static com.voxelplugineering.voxelsniper.service.eventbus.EventThreadingPolicy.Policy.ASYNCHRONOUS; 27 | 28 | import com.voxelplugineering.voxelsniper.brush.BrushAction; 29 | import com.voxelplugineering.voxelsniper.entity.Player; 30 | import com.voxelplugineering.voxelsniper.service.eventbus.EventThreadingPolicy; 31 | 32 | /** 33 | * The event for a sniper action. 34 | */ 35 | @EventThreadingPolicy(ASYNCHRONOUS) 36 | public class SnipeEvent extends SniperEvent 37 | { 38 | 39 | private final double yaw; 40 | private final double pitch; 41 | private final BrushAction action; 42 | 43 | /** 44 | * Constructs a new SnipeEvent for processing. 45 | * 46 | * @param sniper The sniper involved 47 | * @param yaw The yaw 48 | * @param pitch The pitch 49 | * @param action The brush action 50 | */ 51 | public SnipeEvent(Player sniper, double yaw, double pitch, BrushAction action) 52 | { 53 | super(sniper); 54 | this.yaw = yaw; 55 | this.pitch = pitch; 56 | this.action = action; 57 | } 58 | 59 | /** 60 | * The yaw of the direction in which the player was looking. 61 | * 62 | * @return The yaw 63 | */ 64 | public double getYaw() 65 | { 66 | return this.yaw; 67 | } 68 | 69 | /** 70 | * The pitch of the direction in which the player was looking. 71 | * 72 | * @return The pitch 73 | */ 74 | public double getPitch() 75 | { 76 | return this.pitch; 77 | } 78 | 79 | /** 80 | * Gets the brush action of this snipe. 81 | * 82 | * @return The action 83 | */ 84 | public BrushAction getAction() 85 | { 86 | return this.action; 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/world/material/Material.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.world.material; 25 | 26 | import com.voxelplugineering.voxelsniper.util.Nameable; 27 | 28 | /** 29 | * Represents a material that may be applied to a block. 30 | */ 31 | public interface Material extends Nameable 32 | { 33 | 34 | /** 35 | * Gets the name of this material. 36 | * 37 | * @return The name 38 | */ 39 | @Override 40 | String getName(); 41 | 42 | /** 43 | * Gets whether the material is representing a voxel which mat be placed within the world. 44 | * 45 | * @return Is a placeable block 46 | */ 47 | boolean isBlock(); 48 | 49 | /** 50 | * Gets whether the material is affected by gravity within the world. 51 | * 52 | * @return Is affected by gravity 53 | */ 54 | boolean isAffectedByGravity(); 55 | 56 | /** 57 | * Gets if the material is solid (eg. whether a user could pass through the material 58 | * unhindered). 59 | * 60 | * @return Is a solid block 61 | */ 62 | boolean isSolid(); 63 | 64 | /** 65 | * Gets if the material is a liquid. 66 | * 67 | * @return Is a liquid 68 | */ 69 | boolean isLiquid(); 70 | 71 | /** 72 | * Gets if the material is reliant on its environment. (ex. a torch hanging from a wall is 73 | * reliant on the wall). 74 | * 75 | * @return Is reliant on the environment 76 | */ 77 | boolean isReliantOnEnvironment(); 78 | 79 | /** 80 | * Gets if the material is flammable. 81 | * 82 | * @return Is flammable 83 | */ 84 | boolean isFlammable(); 85 | 86 | /** 87 | * Gets the default {@link MaterialState} for this material. 88 | * 89 | * @return The default state 90 | */ 91 | MaterialState getDefaultState(); 92 | 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/registry/PlayerRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service.registry; 25 | 26 | import com.voxelplugineering.voxelsniper.entity.Player; 27 | import com.voxelplugineering.voxelsniper.service.Service; 28 | import com.voxelplugineering.voxelsniper.service.command.CommandSender; 29 | 30 | import java.util.Optional; 31 | 32 | /** 33 | * A factory for creating instances of {@link Player} from the specific implementation's user class. 34 | * 35 | * @param the underlying Player class 36 | */ 37 | public interface PlayerRegistry extends Service 38 | { 39 | 40 | /** 41 | * Returns a special case {@link Player} for the console of the dedicated server. Has no brush 42 | * context but can recieve messages. 43 | * 44 | * @return An {@link Player} representing the console 45 | */ 46 | CommandSender getConsoleSniperProxy(); 47 | 48 | /** 49 | * Gets the player with the given name. 50 | * 51 | * @param name The name to fetch 52 | * @return The player 53 | */ 54 | Optional getPlayer(String name); 55 | 56 | /** 57 | * Gets the player representing the given underlying player object. 58 | * 59 | * @param player The underlying player object 60 | * @return The gunsmith player object 61 | */ 62 | Optional getPlayer(T player); 63 | 64 | /** 65 | * Gets a collection of all players registered within this registry. 66 | * 67 | * @return The players 68 | */ 69 | Iterable getPlayers(); 70 | 71 | /** 72 | * Removes the player from the registry by name. 73 | * 74 | * @param name The name 75 | */ 76 | void invalidate(String name); 77 | 78 | /** 79 | * Removes the given player from the registry. 80 | * 81 | * @param player The key 82 | */ 83 | void invalidate(T player); 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/registry/ProvidedWeakRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.registry; 25 | 26 | import static com.google.common.base.Preconditions.checkNotNull; 27 | 28 | import com.voxelplugineering.voxelsniper.service.registry.RegistryProvider; 29 | import com.voxelplugineering.voxelsniper.util.Pair; 30 | 31 | import java.util.Optional; 32 | 33 | /** 34 | * A {@link WeakRegistry} which takes a custom provider which is referenced to get the value when a 35 | * key is not found within the registry. 36 | * 37 | * @param the key type 38 | * @param the value type 39 | */ 40 | public class ProvidedWeakRegistry extends WeakRegistry 41 | { 42 | 43 | /** 44 | * The provider. 45 | */ 46 | private RegistryProvider provider; 47 | 48 | /** 49 | * Creates a new {@link ProvidedWeakRegistry}. 50 | * 51 | * @param provider The provider 52 | */ 53 | public ProvidedWeakRegistry(RegistryProvider provider) 54 | { 55 | super(); 56 | this.provider = checkNotNull(provider); 57 | } 58 | 59 | @Override 60 | public Optional get(String name) 61 | { 62 | checkNotNull(name); 63 | Optional value = super.get(name); 64 | if (!value.isPresent()) 65 | { 66 | Optional> v = this.provider.get(name); 67 | if (v.isPresent()) 68 | { 69 | register(name, v.get().getKey(), v.get().getValue()); 70 | return Optional.of(v.get().getValue()); 71 | } 72 | return Optional.empty(); 73 | } 74 | return value; 75 | } 76 | 77 | /** 78 | * Sets the provider for this registry. 79 | * 80 | * @param provider The new provider 81 | */ 82 | public void setProvider(RegistryProvider provider) 83 | { 84 | this.provider = checkNotNull(provider); 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/brush/effect/morphological/FilterOperation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.brush.effect.morphological; 25 | 26 | import com.voxelplugineering.voxelsniper.util.Nameable; 27 | import com.voxelplugineering.voxelsniper.world.World; 28 | import com.voxelplugineering.voxelsniper.world.material.MaterialState; 29 | 30 | import java.util.Optional; 31 | 32 | /** 33 | * 34 | */ 35 | public interface FilterOperation extends Nameable 36 | { 37 | 38 | /** 39 | * Returns the name of this operation as it would be labeled as a brush. 40 | */ 41 | @Override 42 | String getName(); 43 | 44 | /** 45 | * Performs one step of the operation at some position in a structuring element with respect to 46 | * the material at that position. The order of the positions hit should not be assumed, and the 47 | * number of positions to be checked is arbitrary. 48 | * 49 | * x, y and z represent a location in the world, w. dx, dy and dz are all distances relative to 50 | * the origin of the structuring element. m is the material in the world at that position. 51 | * 52 | * Returns true if no more checks could possibly change the result. Returns false if the above 53 | * does not hold. 54 | * 55 | * TODO: Add argument for type of border-check to perform when outside the world's extent. 56 | */ 57 | boolean checkPosition(int x, int y, int z, int dx, int dy, int dz, World w, MaterialState m); 58 | 59 | /** 60 | * Provides a material as a result of the morphological operation. 61 | */ 62 | Optional getResult(); 63 | 64 | /** 65 | * Clears any memory relating to the previous operation performed or being performed to a state 66 | * similar to a newly constructed operation. 67 | * 68 | * Reset should be called each time after deciding a result to avoid side-effects. 69 | */ 70 | void reset(); 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/service/OfflineUndoHandlerService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.service; 25 | 26 | import com.voxelplugineering.voxelsniper.util.Context; 27 | import com.voxelplugineering.voxelsniper.world.queue.OfflineUndoHandler; 28 | import com.voxelplugineering.voxelsniper.world.queue.UndoQueue; 29 | 30 | import com.google.common.cache.Cache; 31 | import com.google.common.cache.CacheBuilder; 32 | 33 | import java.util.Optional; 34 | import java.util.concurrent.TimeUnit; 35 | 36 | /** 37 | * A standard offline undo handler which caches player {@link UndoQueue}s for a period of 60 minutes 38 | * before discarding. 39 | */ 40 | public class OfflineUndoHandlerService extends AbstractService implements OfflineUndoHandler 41 | { 42 | 43 | private static final int CACHE_EXPIRY_TIME = 60; 44 | 45 | private Cache cache; 46 | 47 | /** 48 | * Creates a new {@link OfflineUndoHandlerService}. 49 | * 50 | * @param context The context 51 | */ 52 | public OfflineUndoHandlerService(Context context) 53 | { 54 | super(context); 55 | } 56 | 57 | @Override 58 | protected void _init() 59 | { 60 | this.cache = CacheBuilder.newBuilder().expireAfterAccess(CACHE_EXPIRY_TIME, TimeUnit.MINUTES).build(); 61 | } 62 | 63 | @Override 64 | protected void _shutdown() 65 | { 66 | this.cache = null; 67 | } 68 | 69 | @Override 70 | public void register(String name, UndoQueue undo) 71 | { 72 | check("register"); 73 | this.cache.put(name, undo); 74 | } 75 | 76 | @Override 77 | public Optional get(String name) 78 | { 79 | check("get"); 80 | return Optional.ofNullable(this.cache.getIfPresent(name)); 81 | } 82 | 83 | @Override 84 | public void invalidate(String name) 85 | { 86 | check("invalidate"); 87 | this.cache.invalidate(name); 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/world/queue/ChangeQueueOwner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.world.queue; 25 | 26 | import com.voxelplugineering.voxelsniper.service.command.MessageReceiver; 27 | 28 | import java.util.Optional; 29 | 30 | /** 31 | * An interface for anything which may be the owner of a change queue. 32 | */ 33 | public interface ChangeQueueOwner extends MessageReceiver 34 | { 35 | 36 | /** 37 | * Undoes the last n changes to the world. 38 | * 39 | * @param n The number of past changes to undo, cannot be negative 40 | */ 41 | void undoHistory(int n); 42 | 43 | /** 44 | * Redoes the last n undone changes to the world. 45 | * 46 | * @param n The number of changes to redo, cannot be negative 47 | */ 48 | void redoHistory(int n); 49 | 50 | /** 51 | * Returns whether this sniper has pending change queues which have not yet been handled. 52 | * 53 | * @return Has pending changes 54 | */ 55 | boolean hasPendingChanges(); 56 | 57 | /** 58 | * Gets the number of pending changes awaiting to be handled. 59 | * 60 | * @return The pending chance count 61 | */ 62 | int getPendingChangeCount(); 63 | 64 | /** 65 | * Returns the next pending {@link ChangeQueue}. 66 | * 67 | * @return The next change queue 68 | */ 69 | Optional getNextPendingChange(); 70 | 71 | /** 72 | * Adds the given change queue to the pending changes queue. 73 | * 74 | * @param blockChangeQueue The new {@link ChangeQueue}, cannot be null 75 | */ 76 | void addPending(ChangeQueue blockChangeQueue); 77 | 78 | /** 79 | * Removes the next pending change if it has finished. 80 | */ 81 | void clearNextPending(boolean force); 82 | 83 | /** 84 | * Gets the undo history manager. 85 | * 86 | * @return The undo history manager 87 | */ 88 | UndoQueue getUndoHistory(); 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/com/voxelplugineering/voxelsniper/world/queue/EntityChangeQueue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 The Voxel Plugineering Team 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.voxelplugineering.voxelsniper.world.queue; 25 | 26 | import com.voxelplugineering.voxelsniper.entity.EntityType; 27 | import com.voxelplugineering.voxelsniper.entity.Player; 28 | import com.voxelplugineering.voxelsniper.util.math.Vector3d; 29 | import com.voxelplugineering.voxelsniper.world.World; 30 | 31 | import java.util.Random; 32 | 33 | public class EntityChangeQueue extends ChangeQueue { 34 | 35 | private static final Random rand = new Random(); 36 | 37 | private final Vector3d position; 38 | private final EntityType entityType; 39 | private final int count; 40 | private final double size; 41 | private boolean finished = false; 42 | 43 | public EntityChangeQueue(ChangeQueueOwner sniper, World world, EntityType entityType, Vector3d position, int count, double size) { 44 | super(sniper, world); 45 | this.position = position; 46 | this.entityType = entityType; 47 | this.count = count; 48 | this.size = size; 49 | } 50 | 51 | @Override 52 | public boolean isFinished() { 53 | return this.finished; 54 | } 55 | 56 | @Override 57 | public void flush() { 58 | this.owner.addPending(this); 59 | } 60 | 61 | @Override 62 | public int perform(int next) { 63 | for (int i = 0; i < this.count; i++) { 64 | double randomX = rand.nextDouble() * this.size; 65 | double randomZ = rand.nextDouble() * this.size; 66 | double plusMinus = rand.nextDouble(); 67 | double plusMinusZ = rand.nextDouble(); 68 | this.world.spawnEntity(this.entityType, this.position 69 | .add(plusMinus > 0.5 ? randomX : - randomX, 0, plusMinusZ > 0.5 ? randomZ : -randomZ), (Player) this.owner); 70 | } 71 | this.finished = true; 72 | return 10; 73 | } 74 | 75 | @Override 76 | public void reset() { 77 | this.finished = false; 78 | 79 | } 80 | } 81 | --------------------------------------------------------------------------------