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:
parent
e9b8630284
commit
12b6321bab
134
pom.xml
134
pom.xml
@ -1,39 +1,97 @@
|
|||||||
<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">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
<modelVersion>4.0.0</modelVersion>
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<groupId>cn.CityCraft</groupId>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>ProtectItem</artifactId>
|
<groupId>cn.CityCraft</groupId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<artifactId>ProtectItem</artifactId>
|
||||||
<name>ProtectItem</name>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<build>
|
<name>ProtectItem</name>
|
||||||
<sourceDirectory>src</sourceDirectory>
|
<build>
|
||||||
<resources>
|
<finalName>${project.name}</finalName>
|
||||||
<resource>
|
<resources>
|
||||||
<directory>src</directory>
|
<resource>
|
||||||
<excludes>
|
<directory>src/main/resources</directory>
|
||||||
<exclude>**/*.java</exclude>
|
<filtering>true</filtering>
|
||||||
</excludes>
|
</resource>
|
||||||
</resource>
|
</resources>
|
||||||
</resources>
|
<plugins>
|
||||||
</build>
|
<plugin>
|
||||||
<repositories>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<repository>
|
<version>3.1</version>
|
||||||
<id>spigot-repo</id>
|
<configuration>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
<source>1.7</source>
|
||||||
</repository>
|
<target>1.7</target>
|
||||||
</repositories>
|
</configuration>
|
||||||
<dependencies>
|
</plugin>
|
||||||
<dependency>
|
<plugin>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<type>jar</type>
|
<version>2.3</version>
|
||||||
<version>1.8.3-R0.1-SNAPSHOT</version>
|
<configuration>
|
||||||
</dependency>
|
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||||
</dependencies>
|
<minimizeJar>true</minimizeJar>
|
||||||
<properties>
|
<artifactSet>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<includes>
|
||||||
</properties>
|
<include>cn.citycraft:PluginHelper</include>
|
||||||
<issueManagement>
|
<include>org.mcstats.*:*</include>
|
||||||
<system>GitHub</system>
|
</includes>
|
||||||
</issueManagement>
|
</artifactSet>
|
||||||
<url>https://git.coding.net/502647092/ProtectItem.git</url>
|
<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>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<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>
|
||||||
</project>
|
</project>
|
@ -13,30 +13,29 @@ import cn.citycraft.ProtectItem.listen.DropItemListen;
|
|||||||
import cn.citycraft.ProtectItem.listen.PickupItemListen;
|
import cn.citycraft.ProtectItem.listen.PickupItemListen;
|
||||||
|
|
||||||
public class ProtectItem extends JavaPlugin {
|
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 servername;
|
||||||
|
|
||||||
public String pluginname;
|
public String pluginname;
|
||||||
|
|
||||||
public boolean checkevent(Player p, ItemStack i, String type) {
|
public static String getItemName(final ItemStack i) {
|
||||||
if (p.hasPermission("pi.bypass"))
|
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;
|
return false;
|
||||||
String iname = getItemName(i);
|
}
|
||||||
Location l = p.getLocation();
|
final String iname = getItemName(i);
|
||||||
World pw = l.getWorld();
|
final Location l = p.getLocation();
|
||||||
for (String protectworld : getConfig().getStringList("ProtectWorld")) {
|
final World pw = l.getWorld();
|
||||||
|
for (final String protectworld : getConfig().getStringList("ProtectWorld")) {
|
||||||
if (pw.getName().equalsIgnoreCase(protectworld)) {
|
if (pw.getName().equalsIgnoreCase(protectworld)) {
|
||||||
for (String protectitem : getConfig().getStringList(
|
for (final String protectitem : getConfig().getStringList("ProtectItem")) {
|
||||||
"ProtectItem")) {
|
|
||||||
if (iname.equalsIgnoreCase(protectitem)) {
|
if (iname.equalsIgnoreCase(protectitem)) {
|
||||||
p.sendMessage(pluginname
|
p.sendMessage(pluginname + getmessage("Message." + type));
|
||||||
+ getmessage("Message." + type));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -45,27 +44,27 @@ public class ProtectItem extends JavaPlugin {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getmessage(String path) {
|
public String getmessage(final String path) {
|
||||||
String message = getConfig().getString(path).replaceAll("&", "§");
|
final String message = getConfig().getString(path).replaceAll("&", "§");
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String string,
|
public boolean onCommand(final CommandSender sender, final Command cmd, final String string, final String[] args) {
|
||||||
String[] args) {
|
final Player p = (Player) sender;
|
||||||
Player p = (Player) sender;
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0:
|
case 0:
|
||||||
ItemStack item = p.getItemInHand();
|
final ItemStack item = p.getItemInHand();
|
||||||
p.sendMessage("\u00a7a手上物品类型名称为: \u00a76" + getItemName(item));
|
p.sendMessage("\u00a7a手上物品类型名称为: \u00a76" + getItemName(item));
|
||||||
return true;
|
return true;
|
||||||
case 1:
|
case 1:
|
||||||
if (p.hasPermission("pi.bypass"))
|
if (p.hasPermission("pi.bypass")) {
|
||||||
if (args[0].equalsIgnoreCase("reload")) {
|
if (args[0].equalsIgnoreCase("reload")) {
|
||||||
this.reloadConfig();
|
this.reloadConfig();
|
||||||
p.sendMessage("\u00a7a配置文件已重载...");
|
p.sendMessage("\u00a7a配置文件已重载...");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
@ -75,12 +74,10 @@ public class ProtectItem extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
if (getConfig().getBoolean("Protect.Drop", true)) {
|
if (getConfig().getBoolean("Protect.Drop", true)) {
|
||||||
Bukkit.getPluginManager().registerEvents(new DropItemListen(this),
|
Bukkit.getPluginManager().registerEvents(new DropItemListen(this), this);
|
||||||
this);
|
|
||||||
}
|
}
|
||||||
if (getConfig().getBoolean("Protect.Pickup", true)) {
|
if (getConfig().getBoolean("Protect.Pickup", true)) {
|
||||||
Bukkit.getPluginManager().registerEvents(
|
Bukkit.getPluginManager().registerEvents(new PickupItemListen(this), this);
|
||||||
new PickupItemListen(this), this);
|
|
||||||
}
|
}
|
||||||
// if (getConfig().getBoolean("Protect.Break", true))
|
// if (getConfig().getBoolean("Protect.Break", true))
|
||||||
// Bukkit.getPluginManager().registerEvents(
|
// Bukkit.getPluginManager().registerEvents(
|
@ -11,14 +11,14 @@ import cn.citycraft.ProtectItem.ProtectItem;
|
|||||||
public class DropItemListen implements Listener {
|
public class DropItemListen implements Listener {
|
||||||
ProtectItem plugin;
|
ProtectItem plugin;
|
||||||
|
|
||||||
public DropItemListen(ProtectItem main) {
|
public DropItemListen(final ProtectItem main) {
|
||||||
plugin = main;
|
plugin = main;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onDropItem(PlayerDropItemEvent e) {
|
public void onDropItem(final PlayerDropItemEvent e) {
|
||||||
Player p = e.getPlayer();
|
final Player p = e.getPlayer();
|
||||||
ItemStack i = e.getItemDrop().getItemStack();
|
final ItemStack i = e.getItemDrop().getItemStack();
|
||||||
e.setCancelled(plugin.checkevent(p, i, "Drop"));
|
e.setCancelled(plugin.checkevent(p, i, "Drop"));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,15 +11,14 @@ import cn.citycraft.ProtectItem.ProtectItem;
|
|||||||
public class PickupItemListen implements Listener {
|
public class PickupItemListen implements Listener {
|
||||||
ProtectItem plugin;
|
ProtectItem plugin;
|
||||||
|
|
||||||
public PickupItemListen(ProtectItem main) {
|
public PickupItemListen(final ProtectItem main) {
|
||||||
plugin = main;
|
plugin = main;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onPickupItem(PlayerPickupItemEvent e) {
|
public void onPickupItem(final PlayerPickupItemEvent e) {
|
||||||
Player p = e.getPlayer();
|
final Player p = e.getPlayer();
|
||||||
ItemStack i = e.getItem().getItemStack();
|
final ItemStack i = e.getItem().getItemStack();
|
||||||
e.setCancelled(plugin.checkevent(p, i, "Pickup"));
|
e.setCancelled(plugin.checkevent(p, i, "Pickup"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
13
src/main/resources/plugin.yml
Normal file
13
src/main/resources/plugin.yml
Normal 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
|
@ -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
|
|
Loading…
Reference in New Issue
Block a user