Skip to content

Commit

Permalink
Update to v0.0.3
Browse files Browse the repository at this point in the history
added /djump to toggle DoubleJump.
(permission jump.DoubleJump)
May collide with fly on survival plugin
If it keeps colliding, rollback to v0.0.2
  • Loading branch information
ssoaora authored May 12, 2020
1 parent 19adcb5 commit f8f51ee
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>jump.doublejump</groupId>
<artifactId>DoubleJump</artifactId>
<version>0.0.2-SNAPSHOT</version>
<version>0.0.3-SNAPSHOT</version>
<name>DoubleJump</name>
<repositories>
<repository>
Expand Down
33 changes: 31 additions & 2 deletions src/main/java/jump/doublejump/DoubleJump.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,61 @@
import cn.nukkit.level.Level;
import cn.nukkit.level.Sound;
import cn.nukkit.math.Vector3;
import cn.nukkit.command.Command;
import cn.nukkit.command.CommandSender;

import java.util.ArrayList;
import java.util.List;


public class DoubleJump extends PluginBase implements Listener {

List<String> toggled = new ArrayList<String>();

public void onEnable() {
this.getLogger().notice("§eThis Plugin Is Made By aesoppppp");
this.getLogger().info("§dDoubleJump v0.0.2 Is Enabled!");
this.getLogger().info("§dDoubleJump v0.0.3 Is Enabled!");
getServer().getPluginManager().registerEvents(this, this);
}

public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(label.equalsIgnoreCase("djump")) {
if(!(sender instanceof Player)) {
sender.sendMessage("§cYou must be a player to run this command!");
return false;
}
Player player = (Player) sender;
if(toggled.contains(player.getName())) {
player.sendMessage("§cYou are not Double Jumping!");
toggled.remove(player.getName());
return true;
}
player.sendMessage("§7[§6!§7] §fYou are now Double Jumping!");
toggled.add(player.getName());
return true;
}
return false;
}

@EventHandler
public void onPlayerToggleFlight(PlayerToggleFlightEvent event) {
Player player = event.getPlayer();
if(player.isCreative())
if(player.isCreative() && !toggled.contains(player.getName()))
return;
event.setCancelled(true);
player.setAllowFlight(false);
if (toggled.contains(player.getName())) {
player.setMotion(player.getLocation().getDirectionVector().multiply(2.5D).add(0.0D, 1.5D, 0.0D));
Level level = player.getLevel();
level.addSound(player.getLocation(), Sound.MOB_ENDERDRAGON_FLAP);
}
}

@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
if(!player.isCreative()
&& toggled.contains(player.getName())
&& player.isOnGround()
&& !player.getAllowFlight())
player.setAllowFlight(true);
Expand Down
14 changes: 12 additions & 2 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
name: DoubleJump
author: aesoppppp
version: 0.0.2
version: 0.0.3
main: jump.doublejump.DoubleJump
api: [1.0.0]
api: [1.0.0]

commands:
djump:
description: Toggle Djump on and off
permission: jump.Doublejump

permissions:
jump.Doublejump:
description: "Toggle Djump on and off"
default: true

0 comments on commit f8f51ee

Please sign in to comment.