1
0
mirror of https://e.coding.net/circlecloud/ProtectItem.git synced 2024-12-27 20:48:51 +00:00

move file to maven flaor...

Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
j502647092 2015-10-02 22:16:20 +08:00
parent e9b8630284
commit 12b6321bab
7 changed files with 143 additions and 87 deletions

110
pom.xml
View File

@ -1,25 +1,75 @@
<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>ProtectItem</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>ProtectItem</name>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<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>ProtectItem</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>ProtectItem</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>
<include>org.mcstats.*:*</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>org.mcstats</pattern>
<shadedPattern>${project.groupId}.${project.artifactId}.mcstats</shadedPattern>
</relocation>
<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>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>citycraft-repo</id>
<url>http://ci.citycraft.cn:8800/jenkins/plugin/repository/everything/</url>
</repository>
<repository>
<id>Plugin Metrics</id>
<url>http://repo.mcstats.org/content/repositories/public</url>
</repository>
</repositories>
<dependencies>
<dependency>
@ -28,12 +78,20 @@
<type>jar</type>
<version>1.8.3-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.citycraft</groupId>
<artifactId>PluginHelper</artifactId>
<type>jar</type>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.mcstats.bukkit</groupId>
<artifactId>metrics</artifactId>
<version>R8-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<issueManagement>
<system>GitHub</system>
</issueManagement>
<url>https://git.coding.net/502647092/ProtectItem.git</url>
</project>

View File

@ -13,30 +13,29 @@ import cn.citycraft.ProtectItem.listen.DropItemListen;
import cn.citycraft.ProtectItem.listen.PickupItemListen;
public class ProtectItem extends JavaPlugin {
public static String getItemName(ItemStack i) {
String name = i.getType().name();
int dur = i.getDurability();
String dura = i.getMaxStackSize() != 1 ? dur != 0 ? "_" + dur : "" : "";
String iname = name + dura;
return iname;
}
public String servername;
public String pluginname;
public boolean checkevent(Player p, ItemStack i, String type) {
if (p.hasPermission("pi.bypass"))
public static String getItemName(final ItemStack i) {
final String name = i.getType().name();
final int dur = i.getDurability();
final String dura = i.getMaxStackSize() != 1 ? dur != 0 ? "_" + dur : "" : "";
final String iname = name + dura;
return iname;
}
public boolean checkevent(final Player p, final ItemStack i, final String type) {
if (p.hasPermission("pi.bypass")) {
return false;
String iname = getItemName(i);
Location l = p.getLocation();
World pw = l.getWorld();
for (String protectworld : getConfig().getStringList("ProtectWorld")) {
}
final String iname = getItemName(i);
final Location l = p.getLocation();
final World pw = l.getWorld();
for (final String protectworld : getConfig().getStringList("ProtectWorld")) {
if (pw.getName().equalsIgnoreCase(protectworld)) {
for (String protectitem : getConfig().getStringList(
"ProtectItem")) {
for (final String protectitem : getConfig().getStringList("ProtectItem")) {
if (iname.equalsIgnoreCase(protectitem)) {
p.sendMessage(pluginname
+ getmessage("Message." + type));
p.sendMessage(pluginname + getmessage("Message." + type));
return true;
}
}
@ -45,27 +44,27 @@ public class ProtectItem extends JavaPlugin {
return false;
}
public String getmessage(String path) {
String message = getConfig().getString(path).replaceAll("&", "§");
public String getmessage(final String path) {
final String message = getConfig().getString(path).replaceAll("&", "§");
return message;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String string,
String[] args) {
Player p = (Player) sender;
public boolean onCommand(final CommandSender sender, final Command cmd, final String string, final String[] args) {
final Player p = (Player) sender;
switch (args.length) {
case 0:
ItemStack item = p.getItemInHand();
final ItemStack item = p.getItemInHand();
p.sendMessage("\u00a7a手上物品类型名称为: \u00a76" + getItemName(item));
return true;
case 1:
if (p.hasPermission("pi.bypass"))
if (p.hasPermission("pi.bypass")) {
if (args[0].equalsIgnoreCase("reload")) {
this.reloadConfig();
p.sendMessage("\u00a7a配置文件已重载...");
return true;
}
}
break;
default:
}
@ -75,12 +74,10 @@ public class ProtectItem extends JavaPlugin {
@Override
public void onEnable() {
if (getConfig().getBoolean("Protect.Drop", true)) {
Bukkit.getPluginManager().registerEvents(new DropItemListen(this),
this);
Bukkit.getPluginManager().registerEvents(new DropItemListen(this), this);
}
if (getConfig().getBoolean("Protect.Pickup", true)) {
Bukkit.getPluginManager().registerEvents(
new PickupItemListen(this), this);
Bukkit.getPluginManager().registerEvents(new PickupItemListen(this), this);
}
// if (getConfig().getBoolean("Protect.Break", true))
// Bukkit.getPluginManager().registerEvents(

View File

@ -11,14 +11,14 @@ import cn.citycraft.ProtectItem.ProtectItem;
public class DropItemListen implements Listener {
ProtectItem plugin;
public DropItemListen(ProtectItem main) {
public DropItemListen(final ProtectItem main) {
plugin = main;
}
@EventHandler(ignoreCancelled = true)
public void onDropItem(PlayerDropItemEvent e) {
Player p = e.getPlayer();
ItemStack i = e.getItemDrop().getItemStack();
public void onDropItem(final PlayerDropItemEvent e) {
final Player p = e.getPlayer();
final ItemStack i = e.getItemDrop().getItemStack();
e.setCancelled(plugin.checkevent(p, i, "Drop"));
}
}

View File

@ -11,15 +11,14 @@ import cn.citycraft.ProtectItem.ProtectItem;
public class PickupItemListen implements Listener {
ProtectItem plugin;
public PickupItemListen(ProtectItem main) {
public PickupItemListen(final ProtectItem main) {
plugin = main;
}
@EventHandler(ignoreCancelled = true)
public void onPickupItem(PlayerPickupItemEvent e) {
Player p = e.getPlayer();
ItemStack i = e.getItem().getItemStack();
public void onPickupItem(final PlayerPickupItemEvent e) {
final Player p = e.getPlayer();
final ItemStack i = e.getItem().getItemStack();
e.setCancelled(plugin.checkevent(p, i, "Pickup"));
}
}

View File

@ -0,0 +1,13 @@
name: ${project.artifactId}
description: ${project.description}
main: ${project.groupId}.${project.artifactId}.${project.artifactId}
version: ${project.version}
author: 喵♂呜
website: http://ci.citycraft.cn:8800/jenkins/job/${project.artifactId}/
commands:
pishow:
description: 物品保护插件
usage: 使用/pishow 查看物品名称!
permissions:
pi.bypass:
default: op

View File

@ -1,11 +0,0 @@
name: ProtectItem
main: cn.citycraft.ProtectItem.Main
version: 1.0
auther: 喵♂呜
commands:
pishow:
description: 物品保护插件
usage: 使用/pishow 查看物品名称!
permissions:
pi.bypass:
default: op