mirror of
https://e.coding.net/circlecloud/RocketJump.git
synced 2024-12-27 20:48:50 +00:00
init project...
Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
commit
984302a1dc
40
.gitignore
vendored
Normal file
40
.gitignore
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
# Eclipse stuff
|
||||
/.classpath
|
||||
/.project
|
||||
/.settings
|
||||
|
||||
# netbeans
|
||||
/nbproject
|
||||
|
||||
# we use maven!
|
||||
/build.xml
|
||||
|
||||
# maven
|
||||
/target
|
||||
/repo
|
||||
|
||||
# vim
|
||||
.*.sw[a-p]
|
||||
|
||||
# various other potential build files
|
||||
/build
|
||||
/bin
|
||||
/dist
|
||||
/manifest.mf
|
||||
|
||||
/world
|
||||
|
||||
# Mac filesystem dust
|
||||
*.DS_Store
|
||||
|
||||
# intellij
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# Project Stuff
|
||||
/src/main/resources/Soulbound
|
||||
|
||||
# Atlassian Stuff
|
||||
/atlassian-ide-plugin.xml
|
40
pom.xml
Normal file
40
pom.xml
Normal file
@ -0,0 +1,40 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>RocketJump</groupId>
|
||||
<artifactId>RocketJump</artifactId>
|
||||
<version>0.0.2-SNAPSHOT</version>
|
||||
<name>RocketJump</name>
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src</directory>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<type>jar</type>
|
||||
<version>1.8.3-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
</project>
|
118
src/cn/citycraft/RocketJump/Listen.java
Normal file
118
src/cn/citycraft/RocketJump/Listen.java
Normal file
@ -0,0 +1,118 @@
|
||||
package cn.citycraft.RocketJump;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
||||
|
||||
/**
|
||||
* Created by a08381 on 15-3-28.
|
||||
*/
|
||||
public class Listen implements Listener {
|
||||
Main plugin;
|
||||
List<String> fall = new ArrayList<String>();
|
||||
List<String> efc = new ArrayList<String>();
|
||||
int trng;
|
||||
|
||||
public Listen(Main main) {
|
||||
plugin = main;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void MoveEvent(PlayerMoveEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if (efc.contains(p.getName())) {
|
||||
trng -= 1;
|
||||
pEffect(p.getLocation(), trng);
|
||||
}
|
||||
if (p.getLocation().add(0, -1, 0).getBlock().getType() != (Material.AIR))
|
||||
if (plugin.Dante.contains(p.getName())) {
|
||||
p.setAllowFlight(true);
|
||||
if (fall.contains(p.getName()))
|
||||
fall.remove(p.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void ToggleFlightEvent(PlayerToggleFlightEvent e) {
|
||||
final Player p = e.getPlayer();
|
||||
if (plugin.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;
|
||||
}
|
||||
if (!p.isFlying()) {
|
||||
e.setCancelled(true);
|
||||
pEffect(p.getLocation(), 80);
|
||||
p.setVelocity(p.getVelocity().setY(1));
|
||||
p.setAllowFlight(false);
|
||||
plugin.getServer().getScheduler()
|
||||
.runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (p.isOnline()) {
|
||||
p.setVelocity(p.getVelocity().setY(10));
|
||||
final String name = p.getName();
|
||||
efcadd(name);
|
||||
add(name);
|
||||
plugin.getServer()
|
||||
.getScheduler()
|
||||
.runTaskLaterAsynchronously(plugin,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (efc.contains(name))
|
||||
efc.remove(name);
|
||||
}
|
||||
}, 30);
|
||||
}
|
||||
}
|
||||
}, 10);
|
||||
trng = 30;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void pEffect(Location loc, int range) {
|
||||
int i;
|
||||
if (range < 2)
|
||||
range = 2;
|
||||
for (i = 0; i < range; i++) {
|
||||
loc.getWorld().playEffect(loc, Effect.LAVA_POP, 10, 100);
|
||||
loc.getWorld().playEffect(loc, Effect.PORTAL, 10, 100);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFallDamage(EntityDamageEvent e) {
|
||||
if (e.getEntity() instanceof Player) {
|
||||
Player p = (Player) e.getEntity();
|
||||
if (e.getCause() == DamageCause.FALL) {
|
||||
if (fall.contains(p.getName())) {
|
||||
fall.remove(p.getName());
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void add(String p) {
|
||||
if (!fall.contains(p))
|
||||
fall.add(p);
|
||||
}
|
||||
|
||||
public void efcadd(String p) {
|
||||
if (!efc.contains(p))
|
||||
efc.add(p);
|
||||
}
|
||||
}
|
49
src/cn/citycraft/RocketJump/Main.java
Normal file
49
src/cn/citycraft/RocketJump/Main.java
Normal file
@ -0,0 +1,49 @@
|
||||
package cn.citycraft.RocketJump;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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;
|
||||
/**
|
||||
* Created by a08381 on 15-3-28.
|
||||
*/
|
||||
public class Main extends JavaPlugin {
|
||||
|
||||
List<String> Dante = new ArrayList<String>() ;
|
||||
|
||||
public void onEnable() {
|
||||
getServer().getPluginManager().registerEvents(new Listen(this), this);
|
||||
getLogger().info("§aRocketJump已加载...");
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String string,
|
||||
String[] args) {
|
||||
Player p = (Player) sender;
|
||||
if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("on")) {
|
||||
this.Dante.add(p.getName());
|
||||
sender.sendMessage("§6[RocketJump]§a火箭跳跃已开启,双击空格启动。。。");
|
||||
p.setAllowFlight(true);
|
||||
return true;
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("off")) {
|
||||
this.Dante.remove(p.getName());
|
||||
sender.sendMessage("§6[RocketJump]§4已关闭...");
|
||||
if (p.getGameMode() == GameMode.SURVIVAL)
|
||||
p.setAllowFlight(false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public void onDisable() {
|
||||
getLogger().info( "§4RocketJump已卸载...");
|
||||
}
|
||||
|
||||
}
|
13
src/plugin.yml
Normal file
13
src/plugin.yml
Normal file
@ -0,0 +1,13 @@
|
||||
name: RocketJump
|
||||
main: cn.citycraft.RocketJump.Main
|
||||
version: 1.1
|
||||
author: j502647092
|
||||
commands:
|
||||
rj:
|
||||
description: RocketJump插件
|
||||
usage: 使用/rj <on|off> 切换RocketJump!
|
||||
permission: rj.use
|
||||
permission-message: §c你没有此命令的权限!
|
||||
permissions:
|
||||
rj.use:
|
||||
default: op
|
Loading…
Reference in New Issue
Block a user