-
-
Notifications
You must be signed in to change notification settings - Fork 371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduces toggle effect & expression #4154
Open
Olyno
wants to merge
104
commits into
SkriptLang:dev/feature
Choose a base branch
from
Olyno:feature/toggleChanger
base: dev/feature
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+184
−41
Open
Changes from 64 commits
Commits
Show all changes
104 commits
Select commit
Hold shift + click to select a range
ddb40a8
feat(changemode): introduces toggle mode
Olyno 7c6dfb5
merge: master
Olyno f5d6762
fix(unreachable): remove unecessary statement
Olyno 9f53cc5
fix(unreachable): remove unecessary statement
Olyno 7c799fe
fix(condition): missing pipe sign
Olyno 62af771
revert(ExprWhitelist): reset mode affected
Olyno 717cb84
fix(ExprGlowing): missing toggle mode in acceptChange
Olyno c9c87be
Merge branch 'feature/toggleChanger' of github.com:Olyno/Skript into …
Olyno 59f8e68
Merge branch 'master' into feature/toggleChanger
Olyno e6ddeea
Merge branch 'master' into feature/toggleChanger
Olyno d6cd4d6
fix(conflict): merge master
Olyno 759e1f0
chore(toggle): replaces ChangeMode.TOGGLE with ChangeMode.SET
Olyno a95f19e
docs(toggle): add missing version update
Olyno 37408c7
chore(toggle): remove syntax conflict & unwanted changes
Olyno dd8c9d0
chore(toggle): remove unwanted changes
Olyno fb3af6f
chore(toggle): remove unwanted changes
Olyno 2ade451
chore(toggle): remove missing unwanted changes
Olyno c4fb185
fix: tests
Olyno cb93dd8
chore(toggle): move toggle booleans to EffToggle
Olyno 63e0ff7
fix(toggle): check parsing type
Olyno 7ac2de5
fix(toggle): make tests work
Olyno f6438c8
fix(typo): description of toggle effect
Olyno 6f88032
fix(toggle): make init check work
Olyno 8070373
fix(toggle): make requiered changes
Olyno 7f3cef9
chore: merge changes
Olyno 8ae20b5
chore(toggle): remove unwanted stuff
Olyno dbc20e6
Merge branch 'master' into feature/toggleChanger
Olyno 3075255
Merge branch 'master' of github.com:SkriptLang/Skript into feature/to…
Olyno 8397e24
fix: indentation
Olyno 912f0d8
docs(ExprToggled): precise we toggle a boolean value
Olyno d3b07a5
fix(ExprToggled): wrong annotation indentation
Olyno 0da3b69
fix(EffToggle): remove boilerplate and unecessary code
Olyno 4565ff4
fix(EffToggle): boolean value check
Olyno 026a132
fix: conflict
Olyno 9cc2f23
fix(EffToggle): apply change to lists
Olyno ef85caf
fix(ExprToggled): issue with Expression#stream method
Olyno f6667d7
Merge branch 'master' into feature/toggleChanger
Olyno 94dd2b0
Merge branch 'master' into feature/toggleChanger
Olyno d8b81c6
fix: toggle condition
Olyno 2ffed85
feat: optimize toggle operation
Olyno 338f097
fix: typing
Olyno 1fd0cdc
fix: returning only boolean
Olyno 29b1496
test: add block test
Olyno a41d1c4
Merge branch 'master' into feature/toggleChanger
Olyno 533ecaa
More readable patterns
Olyno 0ca5809
Remove comment
Olyno 6d33a9c
Improve code quality
Olyno fa349dc
revert: asked
Olyno c51a1ea
chore: remove empty line
Olyno 7d2b381
chore: change pattern of ExprToggle
Olyno 63df787
Merge branch 'feature/toggleChanger' of github.com:Olyno/Skript into …
Olyno f1c249f
merge: master
Olyno 9ca79a9
revert: add missing new line for test
Olyno 1611bb3
chore: rename ExprToggled to ExprInverse
Olyno 6cd8135
fix: toggle test
Olyno 702206d
fix(typo): apply review
Olyno 876933a
Merge branch 'master' of github.com:SkriptLang/Skript into feature/to…
Olyno 3af8951
revert: unecessary change
Olyno c60cd74
ups
Olyno 0c02931
chore: remove unused imports
Olyno bb053c0
docs: remove comment
Olyno eab9c59
docs: update description
Olyno 3bfb357
chore: short code
Olyno 83e461a
Merge branch 'master' into feature/toggleChanger
Olyno 964c998
Merge branch 'master' into feature/toggleChanger
Olyno b3884c0
chore: adds check before toggle
Olyno 596644c
Merge branch 'master' into feature/toggleChanger
Olyno ab8b35f
chore: add missing closures
Olyno 2fb4096
chore: remove finals
Olyno b813df0
chore: simplify workflow
Olyno e397038
fix: toggle wasn't working correctly
Olyno 23d711a
Merge branch 'master' into feature/toggleChanger
Olyno 832374d
fix: missing value when boolean toggle
Olyno 07601b3
merge: master
Olyno 08397f5
Merge branch 'master' into feature/toggleChanger
Olyno 27b9169
fix: incompatibility Java version method
Olyno 54fbcca
Merge branch 'feature/toggleChanger' of github.com:Olyno/Skript into …
Olyno 6a3f2a2
fix: block wasn't added to the list
Olyno 0cfa688
Merge branch 'master' into feature/toggleChanger
Olyno e3f1622
test: rename test name
Olyno 68fead4
chore: remove unecessary part
Olyno 439639c
chore: update code with review
Olyno 9121b2a
Merge branch 'master' into feature/toggleChanger
Olyno 64bd9c3
Merge branch 'master' into feature/toggleChanger
Olyno 75d999e
Merge branch 'dev/feature' into feature/toggleChanger
Moderocky c20f01f
Merge branch 'dev/feature' into feature/toggleChanger
Moderocky 14cc4e0
Merge branch 'dev/feature' into feature/toggleChanger
Olyno fa7d13c
Merge branch 'dev/feature' into feature/toggleChanger
sovdeeth fc6840c
Merge branch 'dev/feature' into feature/toggleChanger
Moderocky 6cde78c
Merge branch 'dev/feature' into feature/toggleChanger
Olyno 5d5cb4a
chore(formatting): fix formatting
Olyno 9bb3ed5
chore(formatting): fix formatting
Olyno ae5960f
chore(formatting): fix formatting
Olyno 8ee2c1b
chore(formatting): fix formatting
Olyno 1315872
chore: collect as array directly
Olyno bbabd72
Merge branch 'dev/feature' into feature/toggleChanger
Olyno b5dd7b5
chore: rename 'toggledExpr' to 'togglables'
Olyno 41a45fe
fix(toggle): try to fix unexpected behavior
Olyno 15a8bf2
Merge branch 'dev/feature' into feature/toggleChanger
Olyno 7259c54
Merge branch 'dev/feature' into feature/toggleChanger
sovdeeth 565fe7d
Merge branch 'dev/feature' into feature/toggleChanger
Olyno ab9b399
chore(EffToggle): check if accepts more than single value
Olyno 8bc1de4
fix(EffToggle): avoid index reset when possible
Olyno adf2438
fix(test): rephrase error
Olyno File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/** | ||
* This file is part of Skript. | ||
* | ||
* Skript is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Skript is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Skript. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* Copyright Peter Güttinger, SkriptLang team and contributors | ||
*/ | ||
package ch.njol.skript.expressions; | ||
|
||
import org.bukkit.event.Event; | ||
import org.eclipse.jdt.annotation.Nullable; | ||
|
||
import ch.njol.skript.Skript; | ||
import ch.njol.skript.doc.Description; | ||
import ch.njol.skript.doc.Examples; | ||
import ch.njol.skript.doc.Name; | ||
import ch.njol.skript.doc.Since; | ||
import ch.njol.skript.lang.Expression; | ||
import ch.njol.skript.lang.ExpressionType; | ||
import ch.njol.skript.lang.SkriptParser.ParseResult; | ||
import ch.njol.skript.lang.util.SimpleExpression; | ||
import ch.njol.util.Kleenean; | ||
|
||
@Name("Inverse Boolean") | ||
@Description("An expression to obtain the inverse value of a boolean") | ||
@Examples("set {_gravity} to inverse of player's flight mode") | ||
@Since("INSERT VERSION") | ||
public class ExprInverse extends SimpleExpression<Boolean> { | ||
|
||
static { | ||
Skript.registerExpression(ExprInverse.class, Boolean.class, ExpressionType.COMBINED, | ||
"[the] (inverse|opposite) of %booleans%" | ||
); | ||
} | ||
|
||
private Expression<Boolean> booleanExpr; | ||
|
||
@Override | ||
@SuppressWarnings("unchecked") | ||
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { | ||
booleanExpr = (Expression<Boolean>) exprs[0]; | ||
return true; | ||
} | ||
|
||
@Override | ||
@Nullable | ||
protected Boolean[] get(Event event) { | ||
Boolean[] original = booleanExpr.getArray(event); | ||
Boolean[] toggled = new Boolean[original.length]; | ||
for (int i = 0; i < original.length; i++) | ||
toggled[i] = !original[i]; | ||
Olyno marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return toggled; | ||
} | ||
|
||
@Override | ||
public boolean isSingle() { | ||
return booleanExpr.isSingle(); | ||
} | ||
|
||
@Override | ||
public Class<? extends Boolean> getReturnType() { | ||
return Boolean.class; | ||
} | ||
|
||
@Override | ||
public String toString(@Nullable Event event, boolean debug) { | ||
return "inverse of " + booleanExpr.toString(event, debug); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
test "change modes": | ||
Olyno marked this conversation as resolved.
Show resolved
Hide resolved
|
||
set {_x} to 0 | ||
assert {_x} is 0 with "{_x} should be set to 0" | ||
add 1 to {_x} | ||
assert {_x} is 1 with "{_x} should be incremented to 1" | ||
remove 1 from {_x} | ||
assert {_x} is 0 with "{_x} should be decremented to 1" | ||
delete {_x} | ||
assert {_x} is not set with "{_x} should be deleted" | ||
|
||
add "a" to {_letters::*} | ||
assert {_letters::1} is "a" with "{_letters::1} should be set to 'a'" | ||
add "b" to {_letters::*} | ||
assert {_letters::2} is "b" with "{_letters::2} should be set to 'b'" | ||
remove "b" from {_letters::*} | ||
assert {_letters::2} is not set with "{_letters::2} should be removed" | ||
clear {_letters::*} | ||
assert amount of {_letters::*} is 0 with "{_letters::*} should be cleared" | ||
Olyno marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
set {_isToggled} to false | ||
assert {_isToggled} is false with "{_isToggled} should be set to false" | ||
toggle {_isToggled} | ||
assert {_isToggled} is true with "{_isToggled} should be toggled to true" | ||
set {_toggle::*} to false, false and false | ||
assert {_toggle::1} is false with "{_toggle::1} should be set to false" | ||
assert {_toggle::2} is false with "{_toggle::2} should be set to false" | ||
assert {_toggle::3} is false with "{_toggle::3} should be set to false" | ||
toggle {_toggle::*} | ||
assert {_toggle::1} is true with "{_toggle::1} should be toggled to true" | ||
assert {_toggle::2} is true with "{_toggle::2} should be toggled to true" | ||
assert {_toggle::3} is true with "{_toggle::3} should be toggled to true" | ||
assert inverse of {_isToggled} is false with "{_isToggled} should be toggled to false" | ||
|
||
set {_block} to block at location(10, 10, 10, world "world") | ||
set {_list::*} to true and {_block} | ||
toggle {_list::*} | ||
assert {_list::1} is false with "{_list::1} should be set to false" | ||
assert amount of {_list::*} is 2 with "{_list::*} should be set to false and {_block}" | ||
Olyno marked this conversation as resolved.
Show resolved
Hide resolved
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coming a bit late with this suggestion, but wouldn't 'enable' and 'disable' be nice alternatives? Not a big deal though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, because this effect toggles the boolean, changing the value from true to false, and false to true. Using "enable" or "disable" instead would make the value "true" only or "false" only. A simple "set" would be enough in that case.