2016-03-04 01:01:19 +00:00
package me.TheBukor.SkStuff ;
import javax.annotation.Nullable ;
import org.bukkit.Bukkit ;
import org.bukkit.Location ;
2016-03-14 01:26:43 +00:00
import org.bukkit.World ;
2016-03-04 01:01:19 +00:00
import org.bukkit.block.Block ;
2016-03-13 19:22:24 +00:00
import org.bukkit.entity.Entity ;
2016-03-04 01:01:19 +00:00
import org.bukkit.entity.Player ;
2016-03-13 07:06:43 +00:00
import org.bukkit.event.entity.EntityToggleGlideEvent ;
2016-03-04 01:01:19 +00:00
import org.bukkit.inventory.Inventory ;
import org.bukkit.inventory.ItemStack ;
2016-03-14 01:26:43 +00:00
import org.bukkit.plugin.Plugin ;
2016-03-04 01:01:19 +00:00
import org.bukkit.plugin.java.JavaPlugin ;
import com.sk89q.worldedit.EditSession ;
2016-03-14 01:26:43 +00:00
import com.sk89q.worldguard.bukkit.WGBukkit ;
import com.sk89q.worldguard.protection.flags.DefaultFlag ;
import com.sk89q.worldguard.protection.flags.Flag ;
import com.sk89q.worldguard.protection.regions.ProtectedRegion ;
2016-03-04 01:01:19 +00:00
import ch.njol.skript.Skript ;
import ch.njol.skript.classes.ClassInfo ;
2016-03-14 01:26:43 +00:00
import ch.njol.skript.classes.Parser ;
import ch.njol.skript.expressions.base.EventValueExpression ;
2016-03-04 01:01:19 +00:00
import ch.njol.skript.lang.ExpressionType ;
2016-03-14 01:26:43 +00:00
import ch.njol.skript.lang.ParseContext ;
2016-03-04 01:01:19 +00:00
import ch.njol.skript.lang.util.SimpleEvent ;
import ch.njol.skript.registrations.Classes ;
import ch.njol.skript.registrations.EventValues ;
import ch.njol.skript.util.Getter ;
import me.TheBukor.SkStuff.conditions.CondSelectionContains ;
import me.TheBukor.SkStuff.effects.EffClearPathGoals ;
2016-03-23 00:17:36 +00:00
import me.TheBukor.SkStuff.effects.EffClientChat ;
2016-03-04 01:01:19 +00:00
import me.TheBukor.SkStuff.effects.EffDrainLiquid ;
import me.TheBukor.SkStuff.effects.EffDrawLineWE ;
import me.TheBukor.SkStuff.effects.EffGZipFile ;
import me.TheBukor.SkStuff.effects.EffMakeCylinder ;
import me.TheBukor.SkStuff.effects.EffMakeJump ;
import me.TheBukor.SkStuff.effects.EffMakePyramid ;
import me.TheBukor.SkStuff.effects.EffMakeSphere ;
import me.TheBukor.SkStuff.effects.EffMakeWalls ;
import me.TheBukor.SkStuff.effects.EffNaturalize ;
import me.TheBukor.SkStuff.effects.EffPasteSchematic ;
import me.TheBukor.SkStuff.effects.EffRememberChanges ;
import me.TheBukor.SkStuff.effects.EffRemovePathGoal ;
import me.TheBukor.SkStuff.effects.EffReplaceBlocksWE ;
2016-03-23 00:17:36 +00:00
import me.TheBukor.SkStuff.effects.EffResourceSound ;
2016-03-04 01:01:19 +00:00
import me.TheBukor.SkStuff.effects.EffSetBlocksWE ;
import me.TheBukor.SkStuff.effects.EffSetPathGoal ;
import me.TheBukor.SkStuff.effects.EffShowEntityEffect ;
import me.TheBukor.SkStuff.effects.EffSimulateSnow ;
import me.TheBukor.SkStuff.effects.EffToggleVanish ;
import me.TheBukor.SkStuff.effects.EffUndoRedoSession ;
import me.TheBukor.SkStuff.events.EvtWorldEditChange ;
import me.TheBukor.SkStuff.events.WorldEditChangeHandler ;
import me.TheBukor.SkStuff.expressions.ExprChangedBlocksSession ;
import me.TheBukor.SkStuff.expressions.ExprClickedInventory ;
import me.TheBukor.SkStuff.expressions.ExprEditSessionLimit ;
import me.TheBukor.SkStuff.expressions.ExprEndermanBlocks ;
import me.TheBukor.SkStuff.expressions.ExprFileNBT ;
import me.TheBukor.SkStuff.expressions.ExprFireProof ;
2016-03-14 01:26:43 +00:00
import me.TheBukor.SkStuff.expressions.ExprFlagOfWGRegion ;
import me.TheBukor.SkStuff.expressions.ExprFlagsOfWGRegion ;
2016-03-13 07:06:43 +00:00
import me.TheBukor.SkStuff.expressions.ExprGlideState ;
2016-03-23 00:17:36 +00:00
import me.TheBukor.SkStuff.expressions.ExprInventoryOwner ;
2016-03-04 01:01:19 +00:00
import me.TheBukor.SkStuff.expressions.ExprItemNBT ;
2016-03-13 07:06:43 +00:00
import me.TheBukor.SkStuff.expressions.ExprMCIdOf ;
2016-03-14 14:22:35 +00:00
import me.TheBukor.SkStuff.expressions.ExprMCIdToItem ;
2016-03-04 01:01:19 +00:00
import me.TheBukor.SkStuff.expressions.ExprNBTListContents ;
import me.TheBukor.SkStuff.expressions.ExprNBTListIndex ;
import me.TheBukor.SkStuff.expressions.ExprNBTOf ;
import me.TheBukor.SkStuff.expressions.ExprNewEditSession ;
import me.TheBukor.SkStuff.expressions.ExprNoClip ;
import me.TheBukor.SkStuff.expressions.ExprSchematicArea ;
import me.TheBukor.SkStuff.expressions.ExprSelectionArea ;
import me.TheBukor.SkStuff.expressions.ExprSelectionOfPlayer ;
import me.TheBukor.SkStuff.expressions.ExprSelectionPos ;
import me.TheBukor.SkStuff.expressions.ExprTagOf ;
import me.TheBukor.SkStuff.expressions.ExprTimespanToNumber ;
import me.TheBukor.SkStuff.expressions.ExprToLowerCase ;
import me.TheBukor.SkStuff.expressions.ExprToUpperCase ;
import me.TheBukor.SkStuff.expressions.ExprVanishState ;
import me.TheBukor.SkStuff.expressions.ExprWordsToUpperCase ;
import me.TheBukor.SkStuff.util.NMSInterface ;
import me.TheBukor.SkStuff.util.NMS_v1_7_R4 ;
import me.TheBukor.SkStuff.util.NMS_v1_8_R3 ;
import me.TheBukor.SkStuff.util.NMS_v1_9_R1 ;
import me.TheBukor.SkStuff.util.ReflectionUtils ;
public class SkStuff extends JavaPlugin {
private int condAmount = 0 ;
private int effAmount = 0 ;
private int evtAmount = 0 ;
private int exprAmount = 0 ;
private int typeAmount = 0 ;
private static NMSInterface nmsMethods ;
2016-03-14 01:26:43 +00:00
@SuppressWarnings ( " rawtypes " )
2016-03-04 01:01:19 +00:00
public void onEnable ( ) {
if ( Bukkit . getPluginManager ( ) . getPlugin ( " Skript " ) ! = null & & Skript . isAcceptRegistrations ( ) ) {
Skript . registerAddon ( this ) ;
getLogger ( ) . info ( " SkStuff " + this . getDescription ( ) . getVersion ( ) + " has been successfully enabled! " ) ;
getLogger ( ) . info ( " Registering general non version specific stuff... " ) ;
Skript . registerEffect ( EffShowEntityEffect . class , " (display|play|show) entity effect (0<> firework[s] explo(de|sion)|1<> hurt|2<> [[iron] golem] (give|offer) (rose|poppy)|3<> [sheep] eat grass|4<> wolf shake) at %entity% " ) ;
Skript . registerExpression ( ExprToUpperCase . class , String . class , ExpressionType . SIMPLE , " %string% [converted] to [all] (cap[ital]s|upper[ ]case) " , " convert %string% to [all] (cap[ital]s|upper[ ]case) " , " capitalize [all] [char[acter]s (of|in)] %string% " ) ;
Skript . registerExpression ( ExprToLowerCase . class , String . class , ExpressionType . SIMPLE , " %string% [converted] to [all] lower[ ]case " , " convert %string% to [all] lower[ ]case " , " un[( |-)]capitalize [all] [char[acter]s (of|in)] %string% " ) ;
Skript . registerExpression ( ExprWordsToUpperCase . class , String . class , ExpressionType . SIMPLE , " (first|1st) (letter|char[acter]) (of|in) (each word|[all] words) (of|in) %string% [converted] to (cap[ital]s|upper[ ]case) (0<> |1<> ignoring [other] upper[ ]case [(char[acter]s|letters)]) " , " convert (first|1st) (letter|char[acter]) (of|in) (each word|[all] words) (of|in) %string% to (cap[ital]s|upper[ ]case) (0<> |1<> ignoring [other] upper[ ]case [(char[acter]s|letters)]) " , " capitalize (first|1st) (letter|char[acter]) (of|in) (each word|[all] words) (of|in) %string% (0<> |1<> ignoring [other] upper[ ]case [(char[acter]s|letters)]) " ) ;
Skript . registerExpression ( ExprTimespanToNumber . class , Number . class , ExpressionType . SIMPLE , " %timespan% [converted] [in]to (0<> ticks|1<> sec[ond]s|2<> min[ute]s|3<> hours|4<> days) " ) ;
Skript . registerExpression ( ExprClickedInventory . class , Inventory . class , ExpressionType . SIMPLE , " [skstuff] clicked inventory " ) ;
2016-03-23 00:17:36 +00:00
Skript . registerExpression ( ExprInventoryOwner . class , Object . class , ExpressionType . PROPERTY , " [inventory] (owner|holder) of %inventory% " , " %inventory%'s [inventory] (owner|holder) " ) ;
effAmount + = 1 ;
2016-03-14 01:38:17 +00:00
exprAmount + = 6 ;
2016-03-13 07:06:43 +00:00
if ( Skript . isRunningMinecraft ( 1 , 9 ) ) {
2016-03-23 00:17:36 +00:00
getLogger ( ) . info ( " WOW! You're using Minecraft 1.9! Lemme register some cool stuff and fixes right away! " ) ;
Skript . registerEffect ( EffResourceSound . class , " play [raw] [([resource[ ]]pack)] sound %string% for %players% at %location% [[with] (0<> volume|1<> pitch) %-number%[[(,| and)] (0<> pitch|1<> volume) %-number%]] " ) ;
2016-03-13 07:06:43 +00:00
Skript . registerEvent ( " Elytra glide toggle " , SimpleEvent . class , EntityToggleGlideEvent . class , " [entity] elytra (fl(y|ight)|glid(e|ing)) toggl(e|ing) " , " [entity] toggle elytra (fl(y|ight)|glid(e|ing)) " ) ;
2016-03-14 01:26:43 +00:00
Skript . registerExpression ( ExprGlideState . class , Boolean . class , ExpressionType . PROPERTY , " elytra (fl(y|ight)|glid(e|ing)) state of %livingentity% " , " %livingentity%'s elytra (fl(y|ight)|glid(e|ing)) state " ) ;
2016-03-13 07:06:43 +00:00
EventValues . registerEventValue ( EntityToggleGlideEvent . class , Entity . class , new Getter < Entity , EntityToggleGlideEvent > ( ) {
@Override
@Nullable
public Entity get ( EntityToggleGlideEvent e ) {
return e . getEntity ( ) ;
}
} , 0 ) ;
2016-03-23 00:17:36 +00:00
effAmount + = 1 ;
2016-03-13 07:06:43 +00:00
evtAmount + = 1 ;
exprAmount + = 1 ;
}
2016-03-04 01:01:19 +00:00
if ( setupNMSVersion ( ) ) {
getLogger ( ) . info ( " Trying to register version specific stuff... " ) ;
2016-03-06 05:50:34 +00:00
Skript . registerEffect ( EffClearPathGoals . class , " (clear|delete) [all] pathfind[er] goals (of|from) %livingentities% " ) ;
2016-03-17 23:50:07 +00:00
Skript . registerEffect ( EffRemovePathGoal . class , " remove pathfind[er] goal (0<> (avoid|run away from) entit(y|ies)|1<> break door[s]|2<> breed|3<> eat grass|4<> (flee from the sun|seek shad(e|ow))|5<> float (in[side]|on) water|6<> follow (owner|tamer)|7<> follow (adult|parent)[s]|8<> (fight back|react to|target) (damager|attacker)|9<> o(c|z)elot jump on blocks|10<31> leap at target|11<31> look at entit(y|ies)|12<31> melee attack entit(y|ies)|13<31> move to[wards] target|14<31> target nearest entity|15<31> o(c|z)elot attack [chicken[s]]|16<31> open door[s]|17<31> (panic|flee)|18<31> look around randomly|19<31> (walk around randomly|wander)|20<32> sit|21<32> [creeper] (explode|inflate|swell)|22<32> squid (swim|wander)|23<32> shoot fireball[s]|24<32> [silverfish] hide (in[side]|on) block[s]|25<32> (wake other silverfish[es]|[silverfish] call (help|reinforcement|other [hidden] silverfish[es]))|26<32> [enderm(a|e)n] pick[[ ]up] block[s]|27<32> [enderm(a|e)n] place block[s]|28<32> [enderman] attack player (staring|looking) [at eye[s]]|29<32> ghast move to[wards] target|30<33> ghast (idle move[ment]|wander|random fl(ight|y[ing]))|31<33> (tempt to|follow players (holding|with)) [a[n]] item|32<33> target [random] entity (if|when) (not tamed|untamed)|33<33> guardian attack [entity]|34<33> [z[ombie[ ]]pig[man]] attack [player[s]] (if|when) angry|35<33> [z[ombie[ ]]pig[man]] (react to|fight back|target) (attacker|damager) (if|when) angry|36<33> [rabbit] eat carrot crops|37<33> [killer] rabbit [melee] attack|38<33> slime [random] jump|39<33> slime change (direction|facing) randomly|40<34> slime (idle move[ment]|wander)|41<34> follow [entity]) from %livingentities% " ) ;
Skript . registerEffect ( EffSetPathGoal . class , " add pathfind[er] goal [[with] priority %-integer%] (0<> (avoid|run away from) %*entitydatas%[, radius %-number%[, speed %-number%[, speed (if|when) (close|near) %-number%]]]|1<> break door[s]|2<> breed[,[move[ment]] speed %-number%]|3<> eat grass|4<> (flee from the sun|seek shad(e|ow))[, [move[ment]] speed %-number%]|5<> (float (in[side]|on) water|swim)|6<> follow (owner|tamer)[, speed %-number%[, min[imum] distance %-number%[, max[imum] distance %-number%]]]|7<> follow (adult|parent)[s][, [move[ment]] speed %-number%]|8<> (fight back|react to|target) (damager|attacker) [[of] type] %*entitydatas%[, call ([for] help|reinforcement) %-boolean%]|9<> o(c|z)elot jump on blocks[, [move[ment]] speed %-number%]|10<31> leap at target[, [leap] height %-number%]|11<31> look at %*entitydatas%[, (radius|max[imum] distance) %-number%]|12<31> melee attack %*entitydatas%[, [move[ment]] speed %-number%[, (memorize|do('nt| not) forget) target [for [a] long[er] time] %-boolean%]]|13<31> move to[wards] target[, [move[ment]] speed %-number%[, (radius|max[imum] distance) %-number%]]|14<31> target nearest [entity [of] type] %*entitydatas%[, check sight %-boolean%]|15<31> o(c|z)elot attack|16<31> open door[s]|17<31> (panic|flee)[, [move[ment]] speed %-number%]|18<31> look around randomly|19<31> (walk around randomly|wander)[, [move[ment]] speed %-number%[, min[imum] [of] %-timespan% between mov(e[ment][s]|ing)]]|20<32> sit|21<32> [creeper] (explode|inflate|swell)|22<32> squid (swim around|wander)|23<32> shoot fireball[s]|24<32> [silverfish] hide (in[side]|on) block[s]|25<32> ((call|summon|wake) [other] [hidden] silverfish[es])|26<32> [enderman] pick[[ ]up] block[s]|27<32> [enderman] place block[s]|28<32> [enderman] attack player (staring|looking) at [their] eye[s]]|29<32> ghast move to[wards] target|30<33> ghast (idle move[ment]|wander|random fl(ight|y[ing]))|31<33> (tempt to|follow players (holding|with)) %-itemstack%[, [move[ment]] speed %number%[, scared of player movement %-boolean%]]|32<33> target [random] %*entitydatas% (if|when) (not |un)tamed|33<33> guardian attack [entities]|34<33> [z[ombie[ ]]pig[man]] attack [player[s]] (if|when) angry|35<33> [z[ombie[ ]]pig[man]] (react to|fight back|target) (attacker|damager) (if|when) angry|36<33> [rabbit] eat carrot crops|37<33> [killer] rabbit [melee] attack|38<33> slime [random] jump|39<33> slime change (direction|facing) randomly|40<34> slime (idle move[ment]|wander)|41<34> follow %*entitydatas%[, radius %-number%[, speed %-number%[, [custom[ ]]name[d] %-string%]]]) to %livingentities% " ) ;
2016-03-04 01:01:19 +00:00
Skript . registerEffect ( EffMakeJump . class , " make %livingentities% jump " , " force %livingentities% to jump " ) ;
Skript . registerEffect ( EffGZipFile . class , " create [a] gzip[ped] file [at] [path] %string% " ) ;
2016-03-23 00:17:36 +00:00
Skript . registerEffect ( EffClientChat . class , " make %player% (say|chat) %string% client[( |-)]side " , " force %player% to (say|chat) %string% client[( |-)]side " ) ;
2016-03-04 01:01:19 +00:00
Skript . registerExpression ( ExprNBTOf . class , Object . class , ExpressionType . PROPERTY , " nbt[[ ]tag[s]] of %~object% " , " %~object%'s nbt[[ ]tag[s]] " ) ;
Skript . registerExpression ( ExprItemNBT . class , ItemStack . class , ExpressionType . SIMPLE , " %itemstack% with [custom] nbt[[ ]tag[s]] %string% " ) ;
Skript . registerExpression ( ExprTagOf . class , Object . class , ExpressionType . PROPERTY , " [nbt[ ]]tag %string% of [[nbt] compound] %compound% " ) ;
Skript . registerExpression ( ExprFileNBT . class , Object . class , ExpressionType . PROPERTY , " nbt[[ ]tag[s]] from [file] %string% " ) ;
Skript . registerExpression ( ExprNBTListIndex . class , Object . class , ExpressionType . PROPERTY , " [nbt[ ]list] %nbtlist% index %number% " ) ;
Skript . registerExpression ( ExprNBTListContents . class , Object . class , ExpressionType . PROPERTY , " [all] contents (of|from) [nbt[ ]list] %nbtlist% " , " [nbt[ ]list] %nbtlist% contents " ) ;
Skript . registerExpression ( ExprNoClip . class , Boolean . class , ExpressionType . PROPERTY , " no[( |-)]clip (state|mode) of %entities% " , " %entities%'s no[( |-)]clip (state|mode) " ) ;
Skript . registerExpression ( ExprFireProof . class , Boolean . class , ExpressionType . PROPERTY , " fire[ ]proof (state|mode) of %entities% " , " %entities%'s fire[ ]proof (state|mode) " ) ;
Skript . registerExpression ( ExprEndermanBlocks . class , ItemStack . class , ExpressionType . PROPERTY , " blocks that %entity% can (carry|hold|grab|steal) " ) ;
2016-03-14 14:22:35 +00:00
Skript . registerExpression ( ExprMCIdOf . class , String . class , ExpressionType . PROPERTY , " (mc|minecraft) [(string|native)] id of %itemtype% " , " %itemtype%'s minecraft [(string|native)] id " ) ;
Skript . registerExpression ( ExprMCIdToItem . class , ItemStack . class , ExpressionType . SIMPLE , " item[[ ](stack|type)] (of|from) (mc|minecraft) [(string|native)] id %string% " ) ;
2016-03-04 01:01:19 +00:00
nmsMethods . registerCompoundClassInfo ( ) ;
nmsMethods . registerNBTListClassInfo ( ) ;
2016-03-23 00:17:36 +00:00
effAmount + = 6 ;
2016-03-14 14:22:35 +00:00
exprAmount + = 11 ;
2016-03-04 01:01:19 +00:00
typeAmount + = 2 ;
}
if ( Bukkit . getPluginManager ( ) . getPlugin ( " WorldEdit " ) ! = null ) {
getLogger ( ) . info ( " WorldEdit found! Registering WorldEdit stuff... " ) ;
Skript . registerCondition ( CondSelectionContains . class , " [(world[ ]edit|we)] selection of %player% (contains|has) %location% " , " %player%'s [(world[ ]edit|we)] selection (contains|has) %location% " , " [(world[ ]edit|we)] selection of %player% does(n't| not) (contain|have) %location% " , " %player%'s [(world[ ]edit|we)] selection does(n't| not) (contain|have) %location% " ) ;
Skript . registerEffect ( EffDrawLineWE . class , " (create|draw|make) [a[n]] (0<> (no(n|t)(-| )hollow|filled|)|1<> hollow) line from %location% to %location% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks% [with] thick[ness] %double% " ) ;
Skript . registerEffect ( EffUndoRedoSession . class , " (0<> undo|1<> redo) (change|edit)s (of|from) [edit[ ]session] %editsession% " ) ;
Skript . registerEffect ( EffRememberChanges . class , " make %player% (remember|be able to undo) changes (of|from) [edit[ ]session] %editsession% " ) ;
Skript . registerEffect ( EffMakeSphere . class , " (create|make) [a[n]] (0<> (no(n|t)(-| )hollow|filled|)|1<> hollow) (ellipsoid|sphere) [centered] at %location% [with] radius [of] %double%,[ ]%double%(,[ ]| and )%double% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks% " ) ;
Skript . registerEffect ( EffSimulateSnow . class , " (simulate snow at|place snow over) %location% (in|within) [a] radius [of] %double% (using|with) [edit[ ]session] %editsession% " , " make %location% snowy (in|within) [a] radius [of] %double% (using|with) [edit[ ]session] %editsession% " ) ;
Skript . registerEffect ( EffMakePyramid . class , " (create|make) [a[n]] (0<> (no(n|t)(-| )hollow|filled|)|1<> hollow) pyramid at %location% [with] radius [of] %integer% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks% " ) ;
Skript . registerEffect ( EffDrainLiquid . class , " (drain|remove) [all] liquid[s] at %location% (in|within) [a] radius [of] %double% (using|with) [edit[ ]session] %editsession% " ) ;
Skript . registerEffect ( EffNaturalize . class , " naturalize ([cuboid] region|[all] blocks) (from|between) %location% (to|and) %location% (using|with) [edit[ ]session] %editsession% " ) ;
Skript . registerEffect ( EffMakeWalls . class , " (create|make) wall[s] from %location% to %location% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks% " ) ;
Skript . registerEffect ( EffSetBlocksWE . class , " set [all] blocks (from|between) %location% (to|and) %location% to %itemstacks% (using|with) [edit[ ]session] %editsession% " ) ;
Skript . registerEffect ( EffMakeCylinder . class , " (create|make) [a[n]] (0<> (no(n|t)(-| )hollow|filled|)|1<> hollow) cylinder at %location% [with] radius [of] %double%,[ ]%integer%(,[ ]| and )%double% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks% " ) ;
Skript . registerEffect ( EffReplaceBlocksWE . class , " replace [all] %itemstacks% (from|between) %location% (to|and) %location% with %itemstacks% (using|with) [edit[ ]session] %editsession% " ) ;
Skript . registerEffect ( EffPasteSchematic . class , " paste schem[atic] %string% at %location% using [edit[ ]session] %editsession% (0<> |1<> (ignor(e|ing)|without|[with] no) air) " ) ;
Skript . registerExpression ( ExprEditSessionLimit . class , Integer . class , ExpressionType . PROPERTY , " [block] limit [change] of [edit[ ]session] %editsession% " ) ;
Skript . registerExpression ( ExprChangedBlocksSession . class , Integer . class , ExpressionType . PROPERTY , " number of [all] changed blocks (in|of) [edit[ ]session] %editsession% " ) ;
Skript . registerExpression ( ExprNewEditSession . class , EditSession . class , ExpressionType . PROPERTY , " [new] edit[ ]session in [world] %world% [with] [max[imum]] [block] limit [change] [of] %integer% " ) ;
Skript . registerExpression ( ExprSelectionOfPlayer . class , Location . class , ExpressionType . PROPERTY , " [(world[ ]edit|we)] selection of %player% " , " %player%'s [(world[ ]edit|we)] selection " ) ;
Skript . registerExpression ( ExprSelectionPos . class , Location . class , ExpressionType . PROPERTY , " [(world[ ]edit|we)] po(s|int)[ ](0<> 1|1<> 2) of %player% " , " %player%'s [(world[ ]edit|we)] po(s|int)[ ](0<> 1|1<> 2) " ) ;
Skript . registerExpression ( ExprSelectionArea . class , Integer . class , ExpressionType . SIMPLE , " (0<> volume|1<> (x( |-)size|width)|2<> (y( |-)size|height)|3<> (z( |-)size|length)|4<> area) of [(world[ ]edit|we)] selection of %player% " , " %player%'s [(world[ ]edit|we)] selection (0<> volume|1<> (x( |-)size|width)|2<> (y( |-)size|height)|3<> (z( |-)size|length)|4<> area) " ) ;
Skript . registerExpression ( ExprSchematicArea . class , Integer . class , ExpressionType . SIMPLE , " (0<> volume|1<> (x( |-)size|width)|2<> (y( |-)size|height)|3<> (z( |-)size|length)|4<> area) of schem[atic] [from] %string% " ) ;
Classes . registerClass ( new ClassInfo < EditSession > ( EditSession . class , " editsession " ) . name ( " Edit Session " ) . user ( " edit ?sessions? " ) ) ;
try {
Class . forName ( " com.sk89q.worldedit.extent.logging.AbstractLoggingExtent " ) ;
new WorldEditChangeHandler ( ) ;
Skript . registerEvent ( " WorldEdit block change " , SimpleEvent . class , EvtWorldEditChange . class , " world[ ]edit [block] (chang(e|ing)|edit[ing]) " ) ;
EventValues . registerEventValue ( EvtWorldEditChange . class , Player . class , new Getter < Player , EvtWorldEditChange > ( ) {
@Override
@Nullable
public Player get ( EvtWorldEditChange e ) {
return EvtWorldEditChange . getPlayer ( ) ;
}
} , 0 ) ;
EventValues . registerEventValue ( EvtWorldEditChange . class , Block . class , new Getter < Block , EvtWorldEditChange > ( ) {
@Override
@Nullable
public Block get ( EvtWorldEditChange e ) {
return EvtWorldEditChange . getBlock ( ) ;
}
} , 0 ) ;
evtAmount + = 1 ;
} catch ( ClassNotFoundException ex ) {
Skript . error ( " Unable to register \" On WorldEdit block change \" event! You will need to upgrade to WorldEdit 6.0 " ) ;
}
condAmount + = 1 ;
effAmount + = 13 ;
exprAmount + = 7 ;
typeAmount + = 1 ;
2016-03-14 01:26:43 +00:00
if ( Bukkit . getPluginManager ( ) . getPlugin ( " WorldGuard " ) ! = null ) { //WorldGuard depends on WorldEdit
Plugin umbaska = Bukkit . getPluginManager ( ) . getPlugin ( " Umbaska " ) ;
Plugin skRambled = Bukkit . getPluginManager ( ) . getPlugin ( " SkRambled " ) ;
boolean registerNewTypes = ( umbaska = = null & & skRambled = = null ) ;
if ( registerNewTypes ) {
2016-03-14 14:22:35 +00:00
Skript . registerExpression ( ExprFlagOfWGRegion . class , String . class , ExpressionType . PROPERTY , " [w[orld[ ]]g[uard]] flag %wgflag% of %wgregion% " ) ;
2016-03-14 01:26:43 +00:00
Skript . registerExpression ( ExprFlagsOfWGRegion . class , Flag . class , ExpressionType . PROPERTY , " all [w[orld[ ]]g[uard]] flags of %wgregion% " ) ;
Classes . registerClass ( new ClassInfo < Flag > ( Flag . class , " wgflag " ) . name ( " WorldGuard Flag " ) . user ( " (w(orld ?)?g(uard)? )?flags? " ) . defaultExpression ( new EventValueExpression < Flag > ( Flag . class ) ) . parser ( new Parser < Flag < ? > > ( ) {
@Override
@Nullable
public Flag < ? > parse ( String flag , ParseContext context ) {
return DefaultFlag . fuzzyMatchFlag ( flag ) ;
}
@Override
public String toString ( Flag < ? > flag , int flags ) {
return flag . getName ( ) . toLowerCase ( ) ;
}
@Override
public String toVariableNameString ( Flag < ? > flag ) {
return flag . getName ( ) . toLowerCase ( ) ;
}
@Override
public String getVariableNamePattern ( ) {
return " .+ " ;
}
} ) ) ;
Classes . registerClass ( new ClassInfo < ProtectedRegion > ( ProtectedRegion . class , " wgregion " ) . name ( " WorldGuard Region " ) . user ( " (w(orld ?)?g(uard)? )?regions? " ) . defaultExpression ( new EventValueExpression < > ( ProtectedRegion . class ) ) . parser ( new Parser < ProtectedRegion > ( ) {
@Override
@Nullable
public ProtectedRegion parse ( String region , ParseContext context ) {
for ( World w : Bukkit . getWorlds ( ) ) {
if ( WGBukkit . getRegionManager ( w ) . hasRegion ( region ) ) {
return WGBukkit . getRegionManager ( w ) . getRegion ( region ) ;
}
}
return null ;
}
@Override
public String toString ( ProtectedRegion region , int flags ) {
return region . getId ( ) ;
}
@Override
public String toVariableNameString ( ProtectedRegion region ) {
return region . getId ( ) ;
}
@Override
public String getVariableNamePattern ( ) {
return " .+ " ;
}
} ) ) ;
2016-03-17 23:50:07 +00:00
typeAmount + = 2 ;
2016-03-14 01:26:43 +00:00
} else {
2016-03-14 14:22:35 +00:00
Skript . registerExpression ( ExprFlagOfWGRegion . class , String . class , ExpressionType . PROPERTY , " [skstuff] [w[orld[ ]]g[uard]] flag %flag% of %protectedregion% " ) ;
2016-03-14 01:26:43 +00:00
Skript . registerExpression ( ExprFlagsOfWGRegion . class , Flag . class , ExpressionType . PROPERTY , " [skstuff] [all] [w[orld[ ]]g[uard]] flags of %protectedregion% " ) ;
}
exprAmount + = 2 ;
}
2016-03-04 01:01:19 +00:00
}
if ( Bukkit . getPluginManager ( ) . getPlugin ( " VanishNoPacket " ) ! = null ) {
getLogger ( ) . info ( " VanishNoPacket was found! Registering vanishing features... " ) ;
Skript . registerEffect ( EffToggleVanish . class , " toggle vanish (state|mode) of %player% (0<> |1<> (silently|quietly)) " , " toggle %player%'s vanish (state|mode) (0<> |1<> (silently|quietly)) " ) ;
Skript . registerExpression ( ExprVanishState . class , Boolean . class , ExpressionType . PROPERTY , " vanish (state|mode) of %player% " , " %player%'s vanish (state|mode) " ) ;
effAmount + = 1 ;
exprAmount + = 1 ;
}
getLogger ( ) . info ( " Everything ready! Loaded a total of " + condAmount + " conditions, " + effAmount + " effects, " + evtAmount + " events, " + exprAmount + " expressions and " + typeAmount + " types! " ) ;
} else {
getLogger ( ) . info ( " Unable to find Skript or Skript isn't accepting registrations, disabling SkStuff... " ) ;
Bukkit . getPluginManager ( ) . disablePlugin ( this ) ; ;
}
}
private boolean setupNMSVersion ( ) {
String version = ReflectionUtils . getVersion ( ) ;
if ( version . equals ( " v1_7_R4. " ) ) {
nmsMethods = new NMS_v1_7_R4 ( ) ;
getLogger ( ) . info ( " It looks like you're running 1.7.10! " ) ;
} else if ( version . equals ( " v1_8_R3. " ) ) {
nmsMethods = new NMS_v1_8_R3 ( ) ;
2016-03-17 23:50:07 +00:00
getLogger ( ) . info ( " It looks like you're either running 1.8.4, 1.8.7, 1.8.8 or 1.8.9! " ) ;
2016-03-04 01:01:19 +00:00
} else if ( version . equals ( " v1_9_R1. " ) ) {
nmsMethods = new NMS_v1_9_R1 ( ) ;
2016-03-17 23:50:07 +00:00
getLogger ( ) . info ( " It looks like you're running 1.9! " ) ;
2016-03-04 01:01:19 +00:00
} else {
getLogger ( ) . warning ( " It looks like you're running an unsupported server version, some features will not be available :( " ) ;
}
return nmsMethods ! = null ;
}
public static NMSInterface getNMSMethods ( ) {
return nmsMethods ;
}
public void onDisable ( ) {
getLogger ( ) . info ( " SkStuff " + this . getDescription ( ) . getVersion ( ) + " has been successfully disabled. " ) ;
}
2016-01-18 00:10:38 +00:00
}