mirror of
https://e.coding.net/circlecloud/CarryEnchantBench.git
synced 2024-11-22 14:58:47 +00:00
init project...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
commit
b85f3a33bc
36
.classpath
Normal file
36
.classpath
Normal file
@ -0,0 +1,36 @@
|
||||
<?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="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||
<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="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="output" path="target/classes"/>
|
||||
</classpath>
|
36
.gitignore
vendored
Normal file
36
.gitignore
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
.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
23
.project
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>CarryEnchantBench</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.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
44
pom.xml
Normal file
44
pom.xml
Normal file
@ -0,0 +1,44 @@
|
||||
<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>CarryEnchantBench</artifactId>
|
||||
<version>1.0</version>
|
||||
<name>CarryEnchantBench</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>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/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>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
</project>
|
@ -0,0 +1,39 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.CarryEnchantBench;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import cn.citycraft.CarryEnchantBench.inventory.InventoryControl;
|
||||
import cn.citycraft.CarryEnchantBench.listen.PlayerInventoryViewListen;
|
||||
|
||||
/**
|
||||
* @author 蒋天蓓
|
||||
* 2015年8月24日下午3:48:42
|
||||
* TODO
|
||||
*/
|
||||
public class CarryEnchantBench extends JavaPlugin {
|
||||
|
||||
public InventoryControl invcontrol;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("控制台吃饱了撑着用毛线附魔台啊");
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
invcontrol.openEnchantBench(p);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
invcontrol = new InventoryControl(this);
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerInventoryViewListen(this), this);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.CarryEnchantBench.inventory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cn.citycraft.CarryEnchantBench.CarryEnchantBench;
|
||||
|
||||
/**
|
||||
* @author 蒋天蓓
|
||||
*
|
||||
*/
|
||||
public class InventoryControl {
|
||||
CarryEnchantBench plugin;
|
||||
HashMap<String, Location> enchantbench = new HashMap<String, Location>();
|
||||
|
||||
public InventoryControl(CarryEnchantBench main) {
|
||||
this.plugin = main;
|
||||
}
|
||||
|
||||
public void clearAllEnchantBench() {
|
||||
for (Entry<String, Location> item : enchantbench.entrySet()) {
|
||||
setRange(item.getValue(), Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearEnchantBench(Player player) {
|
||||
if (!isOpenEnchantBench(player))
|
||||
return;
|
||||
Location loc = enchantbench.get(player.getName());
|
||||
setRange(loc, Material.AIR);
|
||||
loc.getBlock().setType(Material.AIR);
|
||||
}
|
||||
|
||||
public boolean isOpenEnchantBench(Player player) {
|
||||
return enchantbench.containsKey(player.getName());
|
||||
}
|
||||
|
||||
public void openEnchantBench(Player player) {
|
||||
Location loc = player.getLocation();
|
||||
loc.setY(250);
|
||||
setEnchatRange(loc);
|
||||
player.openEnchanting(loc, true);
|
||||
enchantbench.put(player.getName(), loc);
|
||||
};
|
||||
|
||||
protected void setBlock(Location loc, int x, int y, int z, Material ma) {
|
||||
new Location(loc.getWorld(), loc.getBlockX() + x, loc.getBlockY() + y, loc.getBlockZ() + z).getBlock().setType(ma);
|
||||
}
|
||||
|
||||
protected void setEnchatRange(Location loc) {
|
||||
setRange(loc, Material.BOOKSHELF);
|
||||
loc.getBlock().setType(Material.ENCHANTMENT_TABLE);
|
||||
}
|
||||
|
||||
protected void setRange(Location loc, Material ma) {
|
||||
for (int i = -2; i < 3; i++) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
for (int k = -2; k < 3; k++) {
|
||||
if (!((i * k == 0) || (i * k * i * k == 1))) {
|
||||
setBlock(loc, i, j, k, ma);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.CarryEnchantBench.listen;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
import cn.citycraft.CarryEnchantBench.CarryEnchantBench;
|
||||
|
||||
/**
|
||||
* 玩家随身附魔台记录监听
|
||||
*
|
||||
* @author 蒋天蓓 2015年8月12日下午8:19:33
|
||||
*
|
||||
*/
|
||||
public class PlayerInventoryViewListen implements Listener {
|
||||
CarryEnchantBench plugin;
|
||||
|
||||
public PlayerInventoryViewListen(CarryEnchantBench main) {
|
||||
this.plugin = main;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onInventoryClose(InventoryCloseEvent e) {
|
||||
if (!(e.getPlayer() instanceof Player))
|
||||
return;
|
||||
Player player = (Player) e.getPlayer();
|
||||
Inventory inv = e.getInventory();
|
||||
if (inv.getType() == InventoryType.ENCHANTING) {
|
||||
plugin.invcontrol.clearEnchantBench(player);
|
||||
}
|
||||
}
|
||||
}
|
12
src/main/resources/plugin.yml
Normal file
12
src/main/resources/plugin.yml
Normal file
@ -0,0 +1,12 @@
|
||||
name: ${project.artifactId}
|
||||
main: ${project.groupId}.${project.artifactId}.${project.artifactId}
|
||||
website: http://ci.citycraft.cn:8800/jenkins/job/${project.artifactId}/
|
||||
version: ${project.version}
|
||||
authors: [喵♂呜]
|
||||
commands:
|
||||
ceb:
|
||||
description: 随身附魔台
|
||||
usage: §6使用§a/ceb §6打开附魔台!
|
||||
permission: ceb.use
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
|
Loading…
Reference in New Issue
Block a user