Permalink
Browse files

Construct to mixed2018 (#511)

This set of changes completes the goals of the original construct-to-mixed branch. Function unfortunately worked with Constructs, rather than the Mixed interface. This was a violation of the Dependency Inversion Principal, which has prevented several critical improvements to the language. The problem is that in Java, there is not multiple inheritance, so while normal classes could easily extend Construct and then be added into the ecosystem, for other types of classes, where it's impossible to extend Construct (particularly because they are already extending another class, which is true in at least the cases of enums and exceptions), these objects simply could not be added into the ecosystem.

Now, everything accepts and for the most part deals with Mixed, which is an interface. This has the unfortunate side effect of breaking binary compatibility with extensions, but this change has been in the works for at least three years. As part of this change, implementing enums was used as a test case. That has now also been done, and barring a few bugs, seems to mostly work. This allows access of enums as first class objects, rather than as arrays of strings as previously implemented through reflect_pull.

The PR opens lots of possibilities in the future, and so is a welcome change to the base, but there are a few short term goals after this PR is merged:

* Move exceptions into first class status. Currently they are implemented as arrays, but this is a shoehorn and not ideal.
* Write up documentation for Enums. There is some documentation already available, and this may be mostly correct, but it should at least be read through to ensure it is correct, and then linked to the learning trail. It's also possible to iterate enums with foreach, and so this should be added as an example in various places.
* There are still a few bugs with enums, particularly it is not possible to assign an enum class to a variable. ClassType @s = ArraySortType; should work, but @s remains null. (The same is true even if @s is auto typed).
* Continue with object oriented notation. This provides a good framework to begin with. While it is possible to do EnumType[0] or EnumType['EnumName'], this is the reflective access mechanism, it should also be possible to access the enum by name like EnumType::EnumName.

Since this breaks extensions, the version number has been bumped to 3.3.4, and this PR should not be merged without coordination with extension authors. Also, before merging this PR, one more change should be made, which is to deprecate concatenation of bare strings.

* Start converting construct to mixed.

Also, the first pass at introducing Enums to the object model has been
done. This is not complete yet, until everything supports mixed, but
most of the work for that should have been done now.

* Finish implementing Mixed everywhere. Enums are first class.

Previously, exec(s) accepted an array of Constructs. While this worked
most of the time, it has serious limitations, because object types that
cannot extend Construct (i.e. enums, exceptions, dynamically defined
classes) cannot be passed around. Now, we use Mixed everywhere, instead
of Construct (at least in the interfaces), and so now things like enums
and other classes can implement Mixed, and be added into the ecosystem.
As part of this change, enums are now proper ClassTypes.

An interesting learning here is that we violated the Liskov Substitution
Pricipal early on. Had we not done that, and used an interface up front,
(depend on abstractions, not concretions) we would not have had to deal
with any of this.

Since this changes the interface of Function, this breaks ALL
extensions, thus the version has been bumped to 3.3.4. I have decided to
not add binary compatibility either, since that would introduce a
runtime penalty for every single function call, in every single script.

* This still doesn't work, due to a bug in the compiler

There is a bug in ForceImplements that doesn't respect the fact that
it's an interface.

* Support MDynamicEnum, bump version

MDynamicEnum is now supported, and these show up properly in the compiler
and reflection mechanisms. This is still not entirely useful, but this
sets the stage for some (now) easily implementable features.

* Implement Enums as objects, rather than strings

* Fix some bugs with class type system

* Allow ClassTypes to be standalone usable values

* Add a way for objects to provide a static constructor

Previously, in NativeTypeList, there was no way to customize how an invalid
instance was constructed. Now, if a subclass of Mixed provides a method named
ConstructInvalidInstance, this will be called instead. For now, this is not
necessary in any native classes, but since this picks up extension objects
as well, it might be useful already.

* enums extend mixed
  • Loading branch information...
LadyCailin committed Nov 29, 2018
1 parent 676db51 commit 4964181d782ecda71fb1846ba64e02477d28bcee
Showing with 5,752 additions and 4,133 deletions.
  1. +1 −1 pom.xml
  2. +4 −0 src/main/java/com/laytonsmith/PureUtilities/Common/Annotations/AnnotationChecks.java
  3. +13 −2 src/main/java/com/laytonsmith/PureUtilities/Common/StringUtils.java
  4. +11 −11 src/main/java/com/laytonsmith/PureUtilities/MSP/Burst.java
  5. +1 −1 src/main/java/com/laytonsmith/abstraction/blocks/MCBlockFace.java
  6. +5 −5 src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCCommand.java
  7. +3 −3 src/main/java/com/laytonsmith/abstraction/bukkit/events/BukkitAbstractEventMixin.java
  8. +2 −2 src/main/java/com/laytonsmith/abstraction/entities/MCHorse.java
  9. +1 −1 src/main/java/com/laytonsmith/abstraction/entities/MCLlama.java
  10. +1 −1 src/main/java/com/laytonsmith/abstraction/entities/MCTropicalFish.java
  11. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCArt.java
  12. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCBarColor.java
  13. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCBarStyle.java
  14. +1 −3 src/main/java/com/laytonsmith/abstraction/enums/MCBiomeType.java
  15. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCChatColor.java
  16. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCClickType.java
  17. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCCollisionType.java
  18. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCCreeperType.java
  19. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCCriteria.java
  20. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCDifficulty.java
  21. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCDisplaySlot.java
  22. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCDragType.java
  23. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCDyeColor.java
  24. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCEffect.java
  25. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCEntityEffect.java
  26. +1 −3 src/main/java/com/laytonsmith/abstraction/enums/MCEntityType.java
  27. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCEquipmentSlot.java
  28. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCFireworkType.java
  29. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCFishingState.java
  30. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCGameMode.java
  31. +12 −10 src/main/java/com/laytonsmith/abstraction/enums/MCGameRule.java
  32. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCIgniteCause.java
  33. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCInstrument.java
  34. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCInventoryAction.java
  35. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCInventoryType.java
  36. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCItemFlag.java
  37. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCMobs.java
  38. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCOcelotType.java
  39. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCOption.java
  40. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCOptionStatus.java
  41. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCParrotType.java
  42. +1 −3 src/main/java/com/laytonsmith/abstraction/enums/MCParticle.java
  43. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCPatternShape.java
  44. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCPigType.java
  45. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCPotionEffectType.java
  46. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCPotionType.java
  47. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCProfession.java
  48. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCProjectileType.java
  49. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCRabbitType.java
  50. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCRemoveCause.java
  51. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCRotation.java
  52. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCSlotType.java
  53. +1 −3 src/main/java/com/laytonsmith/abstraction/enums/MCSound.java
  54. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCSoundCategory.java
  55. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCSpawnReason.java
  56. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCTeleportCause.java
  57. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCTone.java
  58. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCTreeSpecies.java
  59. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCTreeType.java
  60. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCWolfType.java
  61. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCWorldEnvironment.java
  62. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCWorldType.java
  63. +1 −1 src/main/java/com/laytonsmith/abstraction/enums/MCZombieType.java
  64. +4 −2 src/main/java/com/laytonsmith/annotations/MDynamicEnum.java
  65. +31 −31 src/main/java/com/laytonsmith/core/ArgumentValidation.java
  66. +122 −0 src/main/java/com/laytonsmith/core/FullyQualifiedClassName.java
  67. +6 −6 src/main/java/com/laytonsmith/core/Globals.java
  68. +1 −1 src/main/java/com/laytonsmith/core/LifeCycle.java
  69. +7 −6 src/main/java/com/laytonsmith/core/{CHVersion.java → MSVersion.java}
  70. +1 −1 src/main/java/com/laytonsmith/core/Main.java
  71. +149 −27 src/main/java/com/laytonsmith/core/MethodScriptCompiler.java
  72. +51 −50 src/main/java/com/laytonsmith/core/ObjectGenerator.java
  73. +14 −14 src/main/java/com/laytonsmith/core/Optimizable.java
  74. +23 −13 src/main/java/com/laytonsmith/core/ParseTree.java
  75. +2 −2 src/main/java/com/laytonsmith/core/PlatformResolver.java
  76. +10 −9 src/main/java/com/laytonsmith/core/Procedure.java
  77. +37 −31 src/main/java/com/laytonsmith/core/Script.java
  78. +58 −38 src/main/java/com/laytonsmith/core/Static.java
  79. +2 −2 src/main/java/com/laytonsmith/core/compiler/FileOptions.java
  80. +2 −1 src/main/java/com/laytonsmith/core/compiler/MethodScriptStaticCompiler.java
  81. +2 −2 src/main/java/com/laytonsmith/core/compiler/keywords/AsKeyword.java
  82. +2 −2 src/main/java/com/laytonsmith/core/compiler/keywords/AutoKeyword.java
  83. +2 −2 src/main/java/com/laytonsmith/core/compiler/keywords/BindKeyword.java
  84. +2 −2 src/main/java/com/laytonsmith/core/compiler/keywords/CaseKeyword.java
  85. +2 −2 src/main/java/com/laytonsmith/core/compiler/keywords/CatchKeyword.java
  86. +2 −2 src/main/java/com/laytonsmith/core/compiler/keywords/ClosureKeyword.java
  87. +2 −2 src/main/java/com/laytonsmith/core/compiler/keywords/DefaultKeyword.java
  88. +2 −2 src/main/java/com/laytonsmith/core/compiler/keywords/DoKeyword.java
  89. +2 −2 src/main/java/com/laytonsmith/core/compiler/keywords/ElseKeyword.java
  90. +2 −2 src/main/java/com/laytonsmith/core/compiler/keywords/FalseKeyword.java
  91. +2 −2 src/main/java/com/laytonsmith/core/compiler/keywords/FinallyKeyword.java
  92. +2 −2 src/main/java/com/laytonsmith/core/compiler/keywords/ForKeyword.java
  93. +2 −2 src/main/java/com/laytonsmith/core/compiler/keywords/ForeachKeyword.java
  94. +2 −2 src/main/java/com/laytonsmith/core/compiler/keywords/IClosureKeyword.java
  95. +2 −2 src/main/java/com/laytonsmith/core/compiler/keywords/IfKeyword.java
  96. +2 −2 src/main/java/com/laytonsmith/core/compiler/keywords/InKeyword.java
  97. +2 −2 src/main/java/com/laytonsmith/core/compiler/keywords/InstanceofKeyword.java
  98. +2 −2 src/main/java/com/laytonsmith/core/compiler/keywords/NotInstanceofKeyword.java
  99. +2 −2 src/main/java/com/laytonsmith/core/compiler/keywords/NullKeyword.java
  100. +2 −2 src/main/java/com/laytonsmith/core/compiler/keywords/ProcKeyword.java
  101. +2 −2 src/main/java/com/laytonsmith/core/compiler/keywords/SwitchKeyword.java
  102. +2 −2 src/main/java/com/laytonsmith/core/compiler/keywords/SynchronizedKeyword.java
  103. +2 −2 src/main/java/com/laytonsmith/core/compiler/keywords/TrueKeyword.java
  104. +2 −2 src/main/java/com/laytonsmith/core/compiler/keywords/TryKeyword.java
  105. +2 −2 src/main/java/com/laytonsmith/core/compiler/keywords/WhileKeyword.java
  106. +58 −56 src/main/java/com/laytonsmith/core/constructs/CArray.java
  107. +3 −3 src/main/java/com/laytonsmith/core/constructs/CBoolean.java
  108. +14 −13 src/main/java/com/laytonsmith/core/constructs/CByteArray.java
  109. +284 −60 src/main/java/com/laytonsmith/core/constructs/CClassType.java
  110. +9 −9 src/main/java/com/laytonsmith/core/constructs/CClosure.java
  111. +3 −3 src/main/java/com/laytonsmith/core/constructs/CDecimal.java
  112. +3 −3 src/main/java/com/laytonsmith/core/constructs/CDouble.java
  113. +8 −8 src/main/java/com/laytonsmith/core/constructs/CEntry.java
  114. +1 −1 src/main/java/com/laytonsmith/core/constructs/CFunction.java
  115. +9 −8 src/main/java/com/laytonsmith/core/constructs/CIClosure.java
  116. +1 −1 src/main/java/com/laytonsmith/core/constructs/CIdentifier.java
  117. +3 −3 src/main/java/com/laytonsmith/core/constructs/CInt.java
  118. +1 −1 src/main/java/com/laytonsmith/core/constructs/CKeyword.java
  119. +3 −3 src/main/java/com/laytonsmith/core/constructs/CLabel.java
  120. +16 −15 src/main/java/com/laytonsmith/core/constructs/CMutablePrimitive.java
  121. +2 −7 src/main/java/com/laytonsmith/core/constructs/CNull.java
  122. +2 −2 src/main/java/com/laytonsmith/core/constructs/CNumber.java
  123. +3 −3 src/main/java/com/laytonsmith/core/constructs/CNumberRunner.java
  124. +4 −4 src/main/java/com/laytonsmith/core/constructs/CPackage.java
  125. +2 −2 src/main/java/com/laytonsmith/core/constructs/CPrimitive.java
  126. +3 −3 src/main/java/com/laytonsmith/core/constructs/CPrimitiveRunner.java
  127. +3 −3 src/main/java/com/laytonsmith/core/constructs/CResource.java
  128. +3 −3 src/main/java/com/laytonsmith/core/constructs/CSecureString.java
  129. +13 −12 src/main/java/com/laytonsmith/core/constructs/CSlice.java
  130. +20 −11 src/main/java/com/laytonsmith/core/constructs/CString.java
  131. +4 −0 src/main/java/com/laytonsmith/core/constructs/CSymbol.java
  132. +3 −3 src/main/java/com/laytonsmith/core/constructs/CVoid.java
  133. +70 −10 src/main/java/com/laytonsmith/core/constructs/Construct.java
  134. +5 −5 src/main/java/com/laytonsmith/core/constructs/IVariable.java
  135. +49 −9 src/main/java/com/laytonsmith/core/constructs/InstanceofUtil.java
  136. +201 −33 src/main/java/com/laytonsmith/core/constructs/NativeTypeList.java
  137. +4 −4 src/main/java/com/laytonsmith/core/events/AbstractEvent.java
  138. +13 −13 src/main/java/com/laytonsmith/core/events/BoundEvent.java
  139. +4 −4 src/main/java/com/laytonsmith/core/events/Event.java
  140. +2 −2 src/main/java/com/laytonsmith/core/events/EventMixinInterface.java
  141. +16 −16 src/main/java/com/laytonsmith/core/events/Prefilters.java
  142. +95 −95 src/main/java/com/laytonsmith/core/events/drivers/BlockEvents.java
  143. +16 −16 src/main/java/com/laytonsmith/core/events/drivers/CmdlineEvents.java
  144. +144 −144 src/main/java/com/laytonsmith/core/events/drivers/EntityEvents.java
  145. +60 −60 src/main/java/com/laytonsmith/core/events/drivers/InventoryEvents.java
  146. +176 −175 src/main/java/com/laytonsmith/core/events/drivers/PlayerEvents.java
  147. +8 −8 src/main/java/com/laytonsmith/core/events/drivers/PluginEvents.java
  148. +33 −32 src/main/java/com/laytonsmith/core/events/drivers/ServerEvents.java
  149. +34 −34 src/main/java/com/laytonsmith/core/events/drivers/VehicleEvents.java
  150. +17 −17 src/main/java/com/laytonsmith/core/events/drivers/WeatherEvents.java
  151. +18 −18 src/main/java/com/laytonsmith/core/events/drivers/WorldEvents.java
  152. +9 −8 src/main/java/com/laytonsmith/core/exceptions/CRE/AbstractCREException.java
  153. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREBadEntityException.java
  154. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREBadEntityTypeException.java
  155. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREBindException.java
  156. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CRECastException.java
  157. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREEnchantmentException.java
  158. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREError.java
  159. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREEventException.java
  160. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREException.java
  161. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREFormatException.java
  162. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREIOException.java
  163. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREIllegalArgumentException.java
  164. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREIncludeException.java
  165. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREIndexOverflowException.java
  166. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREInsufficientArgumentsException.java
  167. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREInsufficientPermissionException.java
  168. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREInvalidPluginException.java
  169. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREInvalidProcedureException.java
  170. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREInvalidWorldException.java
  171. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CRELengthException.java
  172. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CRENotFoundException.java
  173. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CRENullPointerException.java
  174. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREOAuthException.java
  175. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREPlayerOfflineException.java
  176. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREPluginChannelException.java
  177. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREPluginInternalException.java
  178. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CRERangeException.java
  179. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREReadOnlyException.java
  180. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CRESQLException.java
  181. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREScoreboardException.java
  182. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CRESecurityException.java
  183. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREShellException.java
  184. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREStackOverflowError.java
  185. +3 −3 src/main/java/com/laytonsmith/core/exceptions/CRE/CREThrowable.java
  186. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREUnageableMobException.java
  187. +51 −0 src/main/java/com/laytonsmith/core/exceptions/CRE/CREUnsupportedOperationException.java
  188. +2 −2 src/main/java/com/laytonsmith/core/exceptions/CRE/CREUntameableMobException.java
  189. +4 −4 src/main/java/com/laytonsmith/core/exceptions/ConfigRuntimeException.java
  190. +4 −4 src/main/java/com/laytonsmith/core/exceptions/FunctionReturnException.java
  191. +3 −2 src/main/java/com/laytonsmith/core/exceptions/MarshalException.java
  192. +2 −2 src/main/java/com/laytonsmith/core/extensions/ExtensionTracker.java
  193. +6 −6 src/main/java/com/laytonsmith/core/functions/AbstractFunction.java
  194. +173 −170 src/main/java/com/laytonsmith/core/functions/ArrayHandling.java
  195. +133 −132 src/main/java/com/laytonsmith/core/functions/BasicLogic.java
  196. +11 −11 src/main/java/com/laytonsmith/core/functions/BossBar.java
  197. +11 −11 src/main/java/com/laytonsmith/core/functions/BukkitMetadata.java
  198. +74 −73 src/main/java/com/laytonsmith/core/functions/ByteArrays.java
  199. +6 −6 src/main/java/com/laytonsmith/core/functions/Clipboard.java
  200. +60 −59 src/main/java/com/laytonsmith/core/functions/Cmdline.java
  201. +19 −19 src/main/java/com/laytonsmith/core/functions/Commands.java
  202. +16 −13 src/main/java/com/laytonsmith/core/functions/Compiler.java
  203. +4 −4 src/main/java/com/laytonsmith/core/functions/CompositeFunction.java
  204. +38 −38 src/main/java/com/laytonsmith/core/functions/Crypto.java
  205. +190 −182 src/main/java/com/laytonsmith/core/functions/DataHandling.java
  206. +22 −21 src/main/java/com/laytonsmith/core/functions/DataTransformations.java
  207. +29 −29 src/main/java/com/laytonsmith/core/functions/Debug.java
  208. +3 −3 src/main/java/com/laytonsmith/core/functions/DummyFunction.java
  209. +43 −42 src/main/java/com/laytonsmith/core/functions/Echoes.java
  210. +41 −41 src/main/java/com/laytonsmith/core/functions/Enchantments.java
  211. +158 −158 src/main/java/com/laytonsmith/core/functions/EntityManagement.java
  212. +80 −80 src/main/java/com/laytonsmith/core/functions/Environment.java
  213. +47 −47 src/main/java/com/laytonsmith/core/functions/EventBinding.java
  214. +25 −25 src/main/java/com/laytonsmith/core/functions/Exceptions.java
  215. +34 −33 src/main/java/com/laytonsmith/core/functions/ExecutionQueue.java
  216. +14 −14 src/main/java/com/laytonsmith/core/functions/ExtensionMeta.java
  217. +24 −24 src/main/java/com/laytonsmith/core/functions/FileHandling.java
  218. +9 −7 src/main/java/com/laytonsmith/core/functions/Function.java
  219. +2 −3 src/main/java/com/laytonsmith/core/functions/FunctionList.java
  220. +111 −110 src/main/java/com/laytonsmith/core/functions/InventoryManagement.java
  221. +20 −20 src/main/java/com/laytonsmith/core/functions/ItemMeta.java
  222. +9 −9 src/main/java/com/laytonsmith/core/functions/Marquee.java
  223. +165 −134 src/main/java/com/laytonsmith/core/functions/Math.java
  224. +51 −50 src/main/java/com/laytonsmith/core/functions/Meta.java
  225. +52 −52 src/main/java/com/laytonsmith/core/functions/Minecraft.java
  226. +116 −116 src/main/java/com/laytonsmith/core/functions/MobManagement.java
  227. +7 −6 src/main/java/com/laytonsmith/core/functions/OAuth.java
  228. +5 −5 src/main/java/com/laytonsmith/core/functions/Performance.java
  229. +5 −5 src/main/java/com/laytonsmith/core/functions/Permissions.java
  230. +19 −18 src/main/java/com/laytonsmith/core/functions/Persistence.java
  231. +252 −251 src/main/java/com/laytonsmith/core/functions/PlayerManagement.java
  232. +20 −20 src/main/java/com/laytonsmith/core/functions/PluginMeta.java
  233. +12 −12 src/main/java/com/laytonsmith/core/functions/Recipes.java
  234. +47 −47 src/main/java/com/laytonsmith/core/functions/Reflection.java
  235. +26 −25 src/main/java/com/laytonsmith/core/functions/Regex.java
  236. +7 −7 src/main/java/com/laytonsmith/core/functions/ResourceManager.java
  237. +16 −15 src/main/java/com/laytonsmith/core/functions/SQL.java
  238. +21 −21 src/main/java/com/laytonsmith/core/functions/Sandbox.java
  239. +34 −33 src/main/java/com/laytonsmith/core/functions/Scheduling.java
  240. +65 −64 src/main/java/com/laytonsmith/core/functions/Scoreboards.java
  241. +99 −98 src/main/java/com/laytonsmith/core/functions/StringHandling.java
  242. +6 −6 src/main/java/com/laytonsmith/core/functions/TaskHandling.java
  243. +16 −16 src/main/java/com/laytonsmith/core/functions/Threading.java
  244. +22 −25 src/main/java/com/laytonsmith/core/functions/Trades.java
  245. +17 −17 src/main/java/com/laytonsmith/core/functions/Weather.java
  246. +24 −23 src/main/java/com/laytonsmith/core/functions/Web.java
  247. +84 −98 src/main/java/com/laytonsmith/core/functions/World.java
  248. +10 −10 src/main/java/com/laytonsmith/core/functions/XGUI.java
  249. +2 −2 src/main/java/com/laytonsmith/core/functions/bash/BashPlatformResolver.java
  250. +7 −7 src/main/java/com/laytonsmith/core/functions/bash/BasicLogic.java
  251. +3 −3 src/main/java/com/laytonsmith/core/functions/bash/Compiler.java
  252. +5 −0 src/main/java/com/laytonsmith/core/natives/interfaces/AbstractMixedInterfaceRunner.java
  253. +5 −6 src/main/java/com/laytonsmith/core/natives/interfaces/ArrayAccess.java
  254. +3 −3 src/main/java/com/laytonsmith/core/natives/interfaces/ArrayAccessRunner.java
  255. +513 −0 src/main/java/com/laytonsmith/core/natives/interfaces/MEnumType.java
  256. +24 −0 src/main/java/com/laytonsmith/core/natives/interfaces/MEnumTypeValue.java
  257. +25 −0 src/main/java/com/laytonsmith/core/natives/interfaces/Mixed.java
  258. +4 −4 src/main/java/com/laytonsmith/core/natives/interfaces/MixedRunner.java
  259. +6 −0 src/main/java/com/laytonsmith/core/natives/interfaces/ObjectModifier.java
  260. +4 −4 src/main/java/com/laytonsmith/core/natives/interfaces/{SizableRunner.java → SizeableRunner.java}
  261. +11 −11 src/main/java/com/laytonsmith/core/snapins/CorePermissions.java
  262. +14 −14 src/main/java/com/laytonsmith/core/snapins/PackagePermission.java
  263. +7 −7 src/main/java/com/laytonsmith/core/taskmanager/CoreTaskType.java
  264. +3 −3 src/main/java/com/laytonsmith/persistence/CSVDataSource.java
  265. +11 −11 src/main/java/com/laytonsmith/persistence/DataSource.java
  266. +3 −3 src/main/java/com/laytonsmith/persistence/INIDataSource.java
  267. +3 −3 src/main/java/com/laytonsmith/persistence/JSONDataSource.java
  268. +3 −3 src/main/java/com/laytonsmith/persistence/MemoryDataSource.java
  269. +3 −3 src/main/java/com/laytonsmith/persistence/MySQLDataSource.java
  270. +3 −3 src/main/java/com/laytonsmith/persistence/RedisDataSource.java
  271. +3 −3 src/main/java/com/laytonsmith/persistence/SQLiteDataSource.java
  272. +3 −3 src/main/java/com/laytonsmith/persistence/SerializedPersistence.java
  273. +3 −3 src/main/java/com/laytonsmith/persistence/XMLDataSource.java
  274. +3 −3 src/main/java/com/laytonsmith/persistence/YMLDataSource.java
  275. +2 −1 src/main/java/com/laytonsmith/tools/Manager.java
  276. +3 −3 src/main/java/com/laytonsmith/tools/ShellEventMixin.java
  277. +4 −1 src/main/java/com/laytonsmith/tools/SyntaxHighlighters.java
  278. +3 −2 src/main/java/com/laytonsmith/tools/docgen/sitedeploy/APIBuilder.java
  279. +8 −8 src/main/java/com/laytonsmith/tools/docgen/sitedeploy/SiteDeploy.java
  280. +2 −2 src/main/java/com/laytonsmith/tools/pnviewer/PNViewer.java
  281. +10 −0 src/test/java/com/laytonsmith/core/MethodScriptCompilerTest.java
  282. +8 −7 src/test/java/com/laytonsmith/core/constructs/ClassInfoTest.java
  283. +105 −0 src/test/java/com/laytonsmith/core/constructs/EnumTest.java
  284. +40 −17 src/test/java/com/laytonsmith/core/constructs/TestCClassType.java
  285. +6 −6 src/test/java/com/laytonsmith/core/events/PrefiltersTest.java
  286. +2 −2 src/test/java/com/laytonsmith/core/functions/ArrayHandlingTest.java
  287. +2 −1 src/test/java/com/laytonsmith/testing/RandomTests.java
  288. +10 −10 src/test/java/com/laytonsmith/testing/StaticTest.java
@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.sk89q</groupId>
<artifactId>commandhelper</artifactId>
<version>3.3.3-SNAPSHOT</version>
<version>3.3.4-SNAPSHOT</version>
<name>CommandHelper</name>
<description>CommandHelper is a full blown scripting language built right into Minecraft</description>
<inceptionYear>2010</inceptionYear>
@@ -83,6 +83,10 @@ public static void checkForceImplementation() throws Exception {
Set<Class<?>> s = ClassDiscovery.getDefaultInstance().loadClassesThatExtend(superClass);
checkImplements:
for(Class<?> c : s) {
if(c.isInterface()) {
// Interfaces are exempt from the requirement
continue;
}
// First, check if maybe it has a InterfaceRunner for it
findRunner:
for(Class<?> ir : ClassDiscovery.getDefaultInstance().loadClassesWithAnnotation(InterfaceRunnerFor.class)) {
@@ -100,10 +100,21 @@ public static String Join(Map map, String entryGlue, String elementGlue, String
* @param glue The glue to use
* @return The concatenated string
*/
public static String Join(Set set, String glue) {
public static <T> String Join(Set<T> set, String glue) {
return Join(set, glue, null, null, null);
}
/**
* Joins a set together, rendering each item with the custom renderer.
* @param set
* @param glue
* @param r
* @return
*/
public static <T> String Join(Set<T> set, String glue, Renderer<T> r) {
return Join(set, glue, null, null, null, r);
}
/**
* Joins a set together (using StringBuilder's {
*
@@ -150,7 +161,7 @@ public static String Join(Set set, String glue, String lastGlue, String glueForT
* @param empty If the set is completely empty, this string is simply returned. If null, an empty string is used.
* @return The concatenated string
*/
public static String Join(Set set, String glue, String lastGlue, String glueForTwoItems, String empty) {
public static <T> String Join(Set<T> set, String glue, String lastGlue, String glueForTwoItems, String empty) {
return Join(set, glue, lastGlue, glueForTwoItems, empty, null);
}
@@ -1,6 +1,6 @@
package com.laytonsmith.PureUtilities.MSP;
import com.laytonsmith.core.CHVersion;
import com.laytonsmith.core.MSVersion;
import com.laytonsmith.core.SimpleDocumentation;
/**
@@ -20,32 +20,32 @@
public static enum BurstType implements SimpleDocumentation {
@RemoteCapability()
META("Provides meta information to the client/server. The payload will be a json with further information", CHVersion.V3_3_1),
META("Provides meta information to the client/server. The payload will be a json with further information", MSVersion.V3_3_1),
@RemoteCapability()
FUNCTION("This is a static function/procedure call. No rider information is provided, but the payload will"
+ " be a json array, with [0] being the fully qualified function name, and [1..] being the json"
+ " encoded arguments.", CHVersion.V3_3_1),
+ " encoded arguments.", MSVersion.V3_3_1),
@RemoteCapability()
METHOD("This is an instance based method call. The rider will be the json encoded object that this method"
+ " is being called on, and the payload will be the same as " + FUNCTION.name() + "'s payload.", CHVersion.V3_3_1),
+ " is being called on, and the payload will be the same as " + FUNCTION.name() + "'s payload.", MSVersion.V3_3_1),
@RemoteCapability()
RESPONSE("This is a response from a previous call. The payload will be the json encoded response.", CHVersion.V3_3_1),
RESPONSE("This is a response from a previous call. The payload will be the json encoded response.", MSVersion.V3_3_1),
@RemoteCapability()
VOID("This is a response from a previous call, but the function/procedure/method returned void. This"
+ " response is simply to inform the client/server that the response succeeded, while minimizing"
+ " the data transmitted", CHVersion.V3_3_1),
+ " the data transmitted", MSVersion.V3_3_1),
@RemoteCapability()
EXCEPTION("This is a response from a previous call, but the function/procedure/method returned with an exception."
+ " The payload will be the exception type, and the rider will be the exception message", CHVersion.V3_3_1),
+ " The payload will be the exception type, and the rider will be the exception message", MSVersion.V3_3_1),
@RemoteCapability()
ERROR("While handling the request, the remote failed unexpectedly. The payload will simply contain error information"
+ " in an unspecified format, which is intended to be helpful, but should not typically be shown to the"
+ " end user.", CHVersion.V3_3_1);
+ " end user.", MSVersion.V3_3_1);
String doc;
CHVersion version;
MSVersion version;
private BurstType(String doc, CHVersion version) {
private BurstType(String doc, MSVersion version) {
this.doc = doc;
this.version = version;
}
@@ -61,7 +61,7 @@ public String docs() {
}
@Override
public CHVersion since() {
public MSVersion since() {
return version;
}
@@ -2,7 +2,7 @@
import com.laytonsmith.annotations.MEnum;
@MEnum("BlockFace")
@MEnum("com.commandhelper.BlockFace")
public enum MCBlockFace {
NORTH(0, 0, -1),
EAST(1, 0, 0),
@@ -12,14 +12,14 @@
import com.laytonsmith.core.constructs.CBoolean;
import com.laytonsmith.core.constructs.CClosure;
import com.laytonsmith.core.constructs.CString;
import com.laytonsmith.core.constructs.Construct;
import com.laytonsmith.core.constructs.Target;
import com.laytonsmith.core.environments.CommandHelperEnvironment;
import com.laytonsmith.core.events.Driver;
import com.laytonsmith.core.events.EventUtils;
import com.laytonsmith.core.exceptions.ConfigRuntimeException;
import com.laytonsmith.core.exceptions.FunctionReturnException;
import com.laytonsmith.core.functions.Commands;
import com.laytonsmith.core.natives.interfaces.Mixed;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.command.Command;
@@ -214,15 +214,15 @@ public String toString() {
new CArray(t) // reserved for an obgen style command array
);
} catch (FunctionReturnException e) {
Construct fret = e.getReturn();
Mixed fret = e.getReturn();
if(fret instanceof CArray) {
List<String> ret = new ArrayList<>();
if(((CArray) fret).inAssociativeMode()) {
for(Construct key : ((CArray) fret).keySet()) {
for(Mixed key : ((CArray) fret).keySet()) {
ret.add(((CArray) fret).get(key, Target.UNKNOWN).val());
}
} else {
for(Construct value : ((CArray) fret).asList()) {
for(Mixed value : ((CArray) fret).asList()) {
ret.add(value.val());
}
}
@@ -257,7 +257,7 @@ public boolean handleCustomCommand(MCCommandSender sender, String label, String[
new CArray(t) // reserved for an obgen style command array
);
} catch (FunctionReturnException e) {
Construct fret = e.getReturn();
Mixed fret = e.getReturn();
if(fret instanceof CBoolean) {
return ((CBoolean) fret).getBoolean();
}
@@ -3,12 +3,12 @@
import com.laytonsmith.abstraction.bukkit.BukkitMCServer;
import com.laytonsmith.core.Static;
import com.laytonsmith.core.constructs.CString;
import com.laytonsmith.core.constructs.Construct;
import com.laytonsmith.core.constructs.Target;
import com.laytonsmith.core.events.AbstractEvent;
import com.laytonsmith.core.events.BindableEvent;
import com.laytonsmith.core.events.EventMixinInterface;
import com.laytonsmith.core.exceptions.EventException;
import com.laytonsmith.core.natives.interfaces.Mixed;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.entity.Entity;
@@ -40,8 +40,8 @@ public void cancel(BindableEvent e, boolean state) {
}
@Override
public Map<String, Construct> evaluate_helper(BindableEvent event) throws EventException {
Map<String, Construct> map = new HashMap<>();
public Map<String, Mixed> evaluate_helper(BindableEvent event) throws EventException {
Map<String, Mixed> map = new HashMap<>();
map.put("event_type", new CString(mySuper.getName(), Target.UNKNOWN));
String macro;
Object e = event._GetObject();
@@ -6,12 +6,12 @@
public interface MCHorse extends MCTameable, MCVehicle, MCInventoryHolder {
@MEnum("HorseColor")
@MEnum("com.commandhelper.HorseColor")
enum MCHorseColor {
BLACK, BROWN, CHESTNUT, CREAMY, DARK_BROWN, GRAY, WHITE
}
@MEnum("HorsePattern")
@MEnum("com.commandhelper.HorsePattern")
enum MCHorsePattern {
NONE, SOCKS, WHITEFIELD, WHITE_DOTS, BLACK_DOTS
}
@@ -4,7 +4,7 @@
public interface MCLlama extends MCChestedHorse {
@MEnum("LlamaColor")
@MEnum("com.commandhelper.LlamaColor")
enum MCLlamaColor {
CREAMY, WHITE, BROWN, GRAY
}
@@ -13,7 +13,7 @@
MCTropicalFish.MCPattern getPattern();
void setPattern(MCTropicalFish.MCPattern pattern);
@MEnum("TropicalFishPattern")
@MEnum("com.commandhelper.TropicalFishPattern")
enum MCPattern {
KOB,
SUNSTREAK,
@@ -2,7 +2,7 @@
import com.laytonsmith.annotations.MEnum;
@MEnum("Art")
@MEnum("com.commandhelper.Art")
public enum MCArt {
KEBAB,
AZTEC,
@@ -2,7 +2,7 @@
import com.laytonsmith.annotations.MEnum;
@MEnum("BarColor")
@MEnum("com.commandhelper.BarColor")
public enum MCBarColor {
PINK,
BLUE,
@@ -2,7 +2,7 @@
import com.laytonsmith.annotations.MEnum;
@MEnum("BarStyle")
@MEnum("com.commandhelper.BarStyle")
public enum MCBarStyle {
SOLID,
SEGMENTED_6,
@@ -2,7 +2,6 @@
import com.laytonsmith.PureUtilities.ClassLoading.DynamicEnum;
import com.laytonsmith.annotations.MDynamicEnum;
import com.laytonsmith.annotations.MEnum;
import com.laytonsmith.core.Static;
import java.util.ArrayList;
@@ -12,7 +11,7 @@
import java.util.Map;
import java.util.Set;
@MDynamicEnum("BiomeType")
@MDynamicEnum("com.commandhelper.BiomeType")
public abstract class MCBiomeType<Concrete> extends DynamicEnum<MCBiomeType.MCVanillaBiomeType, Concrete> {
protected static final Map<String, MCBiomeType> MAP = new HashMap<>();
@@ -70,7 +69,6 @@ public String concreteName() {
return MAP.values();
}
@MEnum("VanillaBiomeType")
public enum MCVanillaBiomeType {
OCEAN,
PLAINS,
@@ -7,7 +7,7 @@
/**
* All supported color values for chat
*/
@MEnum("ChatColor")
@MEnum("com.commandhelper.ChatColor")
public enum MCChatColor {
/**
@@ -2,7 +2,7 @@
import com.laytonsmith.annotations.MEnum;
@MEnum("ClickType")
@MEnum("com.commandhelper.ClickType")
public enum MCClickType {
/**
* The left (or primary) mouse button.
@@ -2,7 +2,7 @@
import com.laytonsmith.annotations.MEnum;
@MEnum("CollisionType")
@MEnum("com.commandhelper.CollisionType")
public enum MCCollisionType {
BLOCK,
ENTITY
@@ -2,7 +2,7 @@
import com.laytonsmith.annotations.MEnum;
@MEnum("CreeperType")
@MEnum("com.commandhelper.CreeperType")
public enum MCCreeperType {
POWERED
}
@@ -6,7 +6,7 @@
* Criteria names which trigger an objective to be modified by actions in-game
*
*/
@MEnum("Criteria")
@MEnum("com.commandhelper.Criteria")
public enum MCCriteria {
DEATHCOUNT("deathCount"),
HEALTH("health"),
@@ -2,7 +2,7 @@
import com.laytonsmith.annotations.MEnum;
@MEnum("Difficulty")
@MEnum("com.commandhelper.Difficulty")
public enum MCDifficulty {
PEACEFUL(0),
EASY(1),
@@ -6,7 +6,7 @@
* Scoreboard displayslots
*
*/
@MEnum("DisplaySlot")
@MEnum("com.commandhelper.DisplaySlot")
public enum MCDisplaySlot {
BELOW_NAME,
PLAYER_LIST,
@@ -2,7 +2,7 @@
import com.laytonsmith.annotations.MEnum;
@MEnum("DragType")
@MEnum("com.commandhelper.DragType")
public enum MCDragType {
SINGLE,
EVEN
@@ -2,7 +2,7 @@
import com.laytonsmith.annotations.MEnum;
@MEnum("DyeColor")
@MEnum("com.commandhelper.DyeColor")
public enum MCDyeColor {
WHITE,
ORANGE,
@@ -2,7 +2,7 @@
import com.laytonsmith.annotations.MEnum;
@MEnum("Effect")
@MEnum("com.commandhelper.Effect")
public enum MCEffect {
/**
* VISUAL
@@ -2,7 +2,7 @@
import com.laytonsmith.annotations.MEnum;
@MEnum("EntityEffect")
@MEnum("com.commandhelper.EntityEffect")
public enum MCEntityEffect {
ARROW_PARTICLES,
RABBIT_JUMP,
@@ -3,7 +3,6 @@
import com.laytonsmith.PureUtilities.ClassLoading.DynamicEnum;
import com.laytonsmith.abstraction.MCEntity;
import com.laytonsmith.annotations.MDynamicEnum;
import com.laytonsmith.annotations.MEnum;
import com.laytonsmith.core.Static;
import java.util.ArrayList;
@@ -13,7 +12,7 @@
import java.util.Map;
import java.util.Set;
@MDynamicEnum("EntityType")
@MDynamicEnum("com.commandhelper.EntityType")
public abstract class MCEntityType<Concrete> extends DynamicEnum<MCEntityType.MCVanillaEntityType, Concrete> {
// To be filled by the implementer
@@ -100,7 +99,6 @@ public boolean isSpawnable() {
return MAP.values();
}
@MEnum("VanillaEntityType")
public enum MCVanillaEntityType {
AREA_EFFECT_CLOUD(true),
ARMOR_STAND(true),
Oops, something went wrong.

0 comments on commit 4964181

Please sign in to comment.