初始化项目...

Signed-off-by: 502647092 <jtb1@163.com>
master
502647092 2016-01-26 23:12:30 +08:00
commit 42a299ea4a
7 changed files with 354 additions and 0 deletions

31
.classpath Normal file
View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

38
.gitignore vendored Normal file
View File

@ -0,0 +1,38 @@
# Eclipse stuff
/.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

23
.project Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>JumpPlate</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

86
pom.xml Normal file
View File

@ -0,0 +1,86 @@
<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>cn.citycraft</groupId>
<artifactId>JumpPlate</artifactId>
<version>1.0</version>
<name>JumpPlate</name>
<build>
<finalName>${project.name}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<minimizeJar>true</minimizeJar>
<artifactSet>
<includes>
<include>cn.citycraft:PluginHelper</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>cn.citycraft.PluginHelper</pattern>
<shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<jenkins.url>http://ci.citycraft.cn:8080</jenkins.url>
<update.description></update.description>
<update.changes></update.changes>
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>citycraft-repo</id>
<url>${jenkins.url}/plugin/repository/everything/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<type>jar</type>
<version>1.8.8-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.citycraft</groupId>
<artifactId>PluginHelper</artifactId>
<type>jar</type>
<version>1.0</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,152 @@
package cn.citycraft.JumpPlate;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
import org.bukkit.event.player.PlayerInteractEvent;
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.config.FileConfig;
import cn.citycraft.PluginHelper.utils.VersionChecker;
public class JumpPlate extends JavaPlugin implements Listener, HandlerCommands {
Set<String> fall = new HashSet<>();
List<Material> ml = new ArrayList<>();
String pluginname;
FileConfig config;
@EventHandler(ignoreCancelled = true)
public void onCreate(final BlockPlaceEvent e) {
final Player p = e.getPlayer();
if (e.getBlockPlaced().getType() == Material.GOLD_PLATE) {
final Location gb = e.getBlockPlaced().getLocation();
final Block loc = gb.add(0.0D, -1.0D, 0.0D).getBlock();
final Block loc_1 = gb.add(0.0D, -1.0D, 0.0D).getBlock();
final Block loc_2 = gb.add(0.0D, -1.0D, 0.0D).getBlock();
if (loc_1.getType() == Material.GLASS && loc_2.getType() == Material.LAPIS_BLOCK && ml.contains(loc.getType())) {
if (p.hasPermission("JumpPlate.reload")) {
p.sendMessage(pluginname + config.getMessage("create"));
} else {
e.setCancelled(true);
p.sendMessage(pluginname + config.getMessage("no-permission"));
}
}
}
}
@Override
public void onEnable() {
ml.add(Material.IRON_BLOCK);
ml.add(Material.GOLD_BLOCK);
ml.add(Material.DIAMOND_BLOCK);
ml.add(Material.EMERALD_BLOCK);
ml.add(Material.BEDROCK);
new HandlerSubCommand(this, "jp").registerCommands(this);
this.getServer().getPluginManager().registerEvents(this, this);
new VersionChecker(this);
}
@EventHandler
public void onFallDamage(final EntityDamageEvent e) {
if (e.getEntity() instanceof Player) {
final Player p = (Player) e.getEntity();
if (e.getCause() == DamageCause.FALL && (fall.contains(p.getName()))) {
final Location gb = p.getLocation();
final Block loc = gb.add(0.0D, -1.0D, 0.0D).getBlock();
final Block loc_1 = gb.add(0.0D, -1.0D, 0.0D).getBlock();
final Block loc_2 = gb.add(0.0D, -1.0D, 0.0D).getBlock();
if (loc_1.getType() != Material.GLASS || loc_2.getType() != Material.LAPIS_BLOCK || !ml.contains(loc.getType())) {
fall.remove(p);
}
e.setDamage(DamageModifier.BASE, 0);
}
}
}
@EventHandler
public void onJump(final PlayerInteractEvent e) {
final Player p = e.getPlayer();
if (e.getAction() != Action.PHYSICAL) {
return;
}
final Block gb = e.getClickedBlock();
if (gb.getType() != Material.GOLD_PLATE) {
return;
}
final Block loc = gb.getRelative(BlockFace.DOWN);
final Block loc_1 = gb.getRelative(BlockFace.DOWN, 2);
final Block loc_2 = gb.getRelative(BlockFace.DOWN, 3);
if ((loc_1.getType() == Material.GLASS) && (loc_2.getType() == Material.LAPIS_BLOCK)) {
if (!p.hasPermission("JumpPlate.use")) {
p.sendMessage(pluginname + config.getMessage("no-permission"));
return;
}
switch (loc.getType()) {
case IRON_BLOCK:
fall.add(p.getName());
p.setVelocity(p.getVelocity().setY(1));
break;
case GOLD_BLOCK:
fall.add(p.getName());
p.setVelocity(p.getVelocity().setY(1.5));
break;
case DIAMOND_BLOCK:
fall.add(p.getName());
p.setVelocity(p.getVelocity().setY(2));
break;
case EMERALD_BLOCK:
fall.add(p.getName());
p.setVelocity(p.getVelocity().setY(2.5));
break;
case BEDROCK:
fall.add(p.getName());
p.setVelocity(p.getVelocity().setY(config.getDouble("BEDROCK")));
break;
default:
break;
}
}
}
@Override
public void onLoad() {
config = new FileConfig(this);
pluginname = config.getMessage("pluginname");
}
@HandlerCommand(name = "reload", description = "重载插件配置", permission = "JumpPlate.reload")
private void reloadCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
this.onLoad();
sender.sendMessage(pluginname + "§a配置文件已重载!");
}
@HandlerCommand(name = "set", description = "设置基岩跳板高度", minimumArguments = 1, onlyPlayerExecutable = true, permission = "JumpPlate.reload", possibleArguments = "<跳板高度(1-10)>")
private void setCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
try {
final double drb = Double.parseDouble(args[0]);
config.set("BEDROCK", drb);
sender.sendMessage("§a基岩的跳板弹跳倍数已设置为 " + drb + "倍!");
} catch (final NumberFormatException e) {
sender.sendMessage("§c参数非法 请输入数字 1-10");
}
}
}

View File

@ -0,0 +1,4 @@
pluginname: '&6[&b超级跳板&6]&r '
no-permission: '&c你没有使用跳板的权限!'
create: '&a您成功创建了一个跳板!'
BEDROCK: 10

View File

@ -0,0 +1,20 @@
name: ${project.artifactId}
description: ${project.description}
main: ${project.groupId}.${project.artifactId}.${project.artifactId}
version: ${project.version}-git-${env.GIT_COMMIT}
author: 喵♂呜
website: ${jenkins.url}/job/${project.artifactId}/
commands:
${project.artifactId}:
description: ${project.artifactId} - ${project.description}
aliases: [jp]
usage: §b使用/${project.artifactId} help 查看帮助!
permission: ${project.artifactId}.reload
permission-message: §c你没有 <permission> 的权限来执行此命令!
permissions:
${project.artifactId}.use:
description: ${project.artifactId} 使用!
default: true
${project.artifactId}.reload:
description: 重新载入插件!
default: op