mirror of
https://e.coding.net/circlecloud/RocketJump.git
synced 2025-11-24 23:56:06 +00:00
@@ -4,15 +4,9 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import cn.citycraft.PluginHelper.commands.HandlerCommand;
|
||||
import cn.citycraft.PluginHelper.commands.HandlerCommands;
|
||||
import cn.citycraft.PluginHelper.commands.HandlerSubCommand;
|
||||
import cn.citycraft.PluginHelper.commands.InvokeSubCommand;
|
||||
import cn.citycraft.PluginHelper.utils.VersionChecker;
|
||||
|
||||
/**
|
||||
@@ -21,27 +15,9 @@ import cn.citycraft.PluginHelper.utils.VersionChecker;
|
||||
* @author 喵♂呜
|
||||
* @since 2016年2月9日 下午8:50:50
|
||||
*/
|
||||
public class RocketJump extends JavaPlugin implements HandlerCommands {
|
||||
|
||||
List<String> Dante = new ArrayList<String>();
|
||||
|
||||
@HandlerCommand(name = "off", description = "§a开启火箭跳跃", permission = "rj.use", onlyPlayerExecutable = true)
|
||||
public void off(final CommandSender sender, final Command cmd, final String string, final String[] args) {
|
||||
final Player p = (Player) sender;
|
||||
this.Dante.remove(p.getName());
|
||||
sender.sendMessage("§6[RocketJump]§4已关闭...");
|
||||
if (p.getGameMode() == GameMode.SURVIVAL) {
|
||||
p.setAllowFlight(false);
|
||||
}
|
||||
}
|
||||
|
||||
@HandlerCommand(name = "on", description = "§c关闭火箭跳跃", permission = "rj.use", onlyPlayerExecutable = true)
|
||||
public void on(final CommandSender sender, final Command cmd, final String string, final String[] args) {
|
||||
final Player p = (Player) sender;
|
||||
this.Dante.add(p.getName());
|
||||
sender.sendMessage("§6[RocketJump]§a火箭跳跃已开启,双击空格启动。。。");
|
||||
p.setAllowFlight(true);
|
||||
}
|
||||
public class RocketJump extends JavaPlugin {
|
||||
static RocketJump instence;
|
||||
static List<String> Dante = new ArrayList<String>();
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
@@ -50,8 +26,11 @@ public class RocketJump extends JavaPlugin implements HandlerCommands {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
new HandlerSubCommand(this, "rj").registerCommands(this);
|
||||
getServer().getPluginManager().registerEvents(new Listen(this), this);
|
||||
instence = this;
|
||||
final InvokeSubCommand isc = new InvokeSubCommand(this, "rj");
|
||||
isc.registerCommands(new RocketJumpCommands());
|
||||
isc.setAllCommandOnlyPlayer(true);
|
||||
getServer().getPluginManager().registerEvents(new RocketJumpListen(), this);
|
||||
Bukkit.getConsoleSender().sendMessage("§aRocketJump已加载...");
|
||||
new VersionChecker(this);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package cn.citycraft.RocketJump;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cn.citycraft.PluginHelper.commands.HandlerCommand;
|
||||
import cn.citycraft.PluginHelper.commands.HandlerCommands;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 2016年2月23日 上午11:20:51
|
||||
* @author 喵♂呜
|
||||
*/
|
||||
public class RocketJumpCommands implements HandlerCommands {
|
||||
@HandlerCommand(name = "off", description = "§a开启火箭跳跃")
|
||||
public void off(final CommandSender sender, final Command cmd, final String string, final String[] args) {
|
||||
final Player p = (Player) sender;
|
||||
RocketJump.Dante.remove(p.getName());
|
||||
sender.sendMessage("§6[RocketJump]§4已关闭...");
|
||||
if (p.getGameMode() == GameMode.SURVIVAL) {
|
||||
p.setAllowFlight(false);
|
||||
}
|
||||
}
|
||||
|
||||
@HandlerCommand(name = "on", description = "§c关闭火箭跳跃")
|
||||
public void on(final CommandSender sender, final Command cmd, final String string, final String[] args) {
|
||||
final Player p = (Player) sender;
|
||||
RocketJump.Dante.add(p.getName());
|
||||
sender.sendMessage("§6[RocketJump]§a火箭跳跃已开启,双击空格启动。。。");
|
||||
p.setAllowFlight(true);
|
||||
}
|
||||
}
|
||||
@@ -17,16 +17,11 @@ import org.bukkit.event.player.PlayerToggleFlightEvent;
|
||||
/**
|
||||
* Created by a08381 on 15-3-28.
|
||||
*/
|
||||
public class Listen implements Listener {
|
||||
RocketJump plugin;
|
||||
public class RocketJumpListen implements Listener {
|
||||
List<String> fall = new ArrayList<String>();
|
||||
List<String> efc = new ArrayList<String>();
|
||||
int trng;
|
||||
|
||||
public Listen(final RocketJump main) {
|
||||
plugin = main;
|
||||
}
|
||||
|
||||
public void add(final String p) {
|
||||
if (!fall.contains(p)) {
|
||||
fall.add(p);
|
||||
@@ -47,7 +42,7 @@ public class Listen implements Listener {
|
||||
pEffect(p.getLocation(), trng);
|
||||
}
|
||||
if (p.getLocation().add(0, -1, 0).getBlock().getType() != (Material.AIR)) {
|
||||
if (plugin.Dante.contains(p.getName())) {
|
||||
if (RocketJump.Dante.contains(p.getName())) {
|
||||
p.setAllowFlight(true);
|
||||
if (fall.contains(p.getName())) {
|
||||
fall.remove(p.getName());
|
||||
@@ -72,7 +67,7 @@ public class Listen implements Listener {
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void ToggleFlightEvent(final PlayerToggleFlightEvent e) {
|
||||
final Player p = e.getPlayer();
|
||||
if (plugin.Dante.contains(p.getName())) {
|
||||
if (RocketJump.Dante.contains(p.getName())) {
|
||||
if (p.getLocation().add(0, -1, 0).getBlock().getType() == (Material.AIR) && p.getLocation().add(0, -2, 0).getBlock().getType() == (Material.AIR)) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
@@ -82,7 +77,7 @@ public class Listen implements Listener {
|
||||
pEffect(p.getLocation(), 80);
|
||||
p.setVelocity(p.getVelocity().setY(1));
|
||||
p.setAllowFlight(false);
|
||||
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
RocketJump.instence.getServer().getScheduler().runTaskLaterAsynchronously(RocketJump.instence, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (p.isOnline()) {
|
||||
@@ -90,7 +85,7 @@ public class Listen implements Listener {
|
||||
final String name = p.getName();
|
||||
efcadd(name);
|
||||
add(name);
|
||||
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
RocketJump.instence.getServer().getScheduler().runTaskLaterAsynchronously(RocketJump.instence, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (efc.contains(name)) {
|
||||
Reference in New Issue
Block a user