Skip to content
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

API 5 fork #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<dependency>
<groupId>org.spongepowered</groupId>
<artifactId>spongeapi</artifactId>
<version>4.0.0</version>
<version>5.0.0</version>
<type>jar</type>
<optional>true</optional>
<scope>provided</scope>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kitteh/vanish/Vanish.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/**
* Spiritual successor to VanishNoPacket, for Sponge.
*/
@Plugin(id = "org.kitteh.vanish", name = "Vanish", version = "4.0.3")
@Plugin(id = "vanish", name = "Vanish", version = "4.0.3-API5")
public class Vanish {
public static final String PERMISSION_VANISH = "vanish.vanish";

Expand Down
25 changes: 13 additions & 12 deletions src/main/java/org/kitteh/vanish/VanishCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.format.TextColors;
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;

import javax.annotation.Nonnull;
import java.util.HashSet;
import java.util.Set;

import javax.annotation.Nonnull;

/**
* Vanish!
*/
Expand All @@ -54,7 +56,7 @@ class VanishCommand implements CommandExecutor {

VanishCommand(Vanish plugin) {
this.plugin = plugin;
this.effect = ParticleEffect.builder().type(ParticleTypes.SMOKE_LARGE).count(1).build();
this.effect = ParticleEffect.builder().type(ParticleTypes.LARGE_SMOKE).quantity(1).build();
}

@Nonnull
Expand All @@ -65,19 +67,18 @@ public CommandResult execute(@Nonnull CommandSource commandSource, @Nonnull Comm
return CommandResult.empty();
}
Player player = (Player) commandSource;
boolean wasVisible = player.get(Keys.INVISIBLE).orElse(false);
player.offer(Keys.INVISIBLE, !wasVisible);
player.offer(Keys.INVISIBILITY_IGNORES_COLLISION, !wasVisible);
player.offer(Keys.INVISIBILITY_PREVENTS_TARGETING, !wasVisible);
boolean wasVisible = player.get(Keys.VANISH).orElse(false);
player.offer(Keys.VANISH, !wasVisible);
player.offer(Keys.VANISH_IGNORES_COLLISION, !wasVisible);
player.offer(Keys.VANISH_PREVENTS_TARGETING, !wasVisible);
if (player.hasPermission(Vanish.PERMISSION_EFFECTS_BATS)) {
Set<Entity> bats = new HashSet<>();
Location location = player.getLocation();
Location<World> location = player.getLocation();
for (int i = 0; i < 10; i++) {
location.getExtent().createEntity(EntityTypes.BAT, location.getPosition()).ifPresent(bat -> {
bats.add(bat);
location.getExtent().spawnEntity(bat, Cause.builder().owner(this.plugin).build()); // TODO Am I doing this right?
bat.offer(Keys.INVULNERABILITY_TICKS, LIFE_TICKS);
});
final Entity bat = location.getExtent().createEntity(EntityTypes.BAT, location.getPosition());
bats.add(bat);
location.getExtent().spawnEntity(bat, Cause.builder().owner(this.plugin).build()); // TODO Am I doing this right?
bat.offer(Keys.INVULNERABILITY_TICKS, LIFE_TICKS);
}
// TODO remove on shutdown too!
Sponge.getScheduler().createTaskBuilder().delayTicks(LIFE_TICKS).execute(() -> {
Expand Down