1
0
mirror of https://e.coding.net/circlecloud/SimpleEssential.git synced 2024-11-17 01:18:47 +00:00

remove full rank EnchantBench...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2015-09-06 14:41:48 +08:00
parent 614fa4668d
commit aaab499a1f
7 changed files with 4 additions and 160 deletions

View File

@ -5,6 +5,7 @@
<artifactId>SimpleEssential</artifactId>
<version>1.1</version>
<name>SimpleEssential</name>
<description>轻量级基础插件</description>
<build>
<finalName>${project.name}</finalName>
<resources>
@ -27,6 +28,7 @@
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
<createDependencyReducedPom>flase</createDependencyReducedPom>
<minimizeJar>true</minimizeJar>
<artifactSet>
<includes>
@ -72,5 +74,4 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<description>轻量级基础插件</description>
</project>

View File

@ -29,8 +29,6 @@ import cn.citycraft.SimpleEssential.command.CommandTpdeny;
import cn.citycraft.SimpleEssential.command.CommandTphere;
import cn.citycraft.SimpleEssential.command.CommandWorkBench;
import cn.citycraft.SimpleEssential.config.Language;
import cn.citycraft.SimpleEssential.inventory.InventoryControl;
import cn.citycraft.SimpleEssential.listen.PlayerInventoryViewListen;
import cn.citycraft.SimpleEssential.listen.PlayerLocationListen;
import cn.citycraft.SimpleEssential.teleport.TeleportControl;
import cn.citycraft.config.FileConfig;
@ -47,22 +45,11 @@ public class SimpleEssential extends JavaPlugin {
* 传送控制
*/
public TeleportControl tpcontrol;
/**
* 容器界面控制
*/
public InventoryControl invcontrol;
/**
* 命令监听列表
*/
private List<BaseCommand> commandlist;
/**
*
*/
private void initInventoryControl() {
invcontrol = new InventoryControl(this);
}
private void initTeleportControl() {
int tpdelay = config.getInt("Teleport.delay", 3);
String tpcontorlname = config.getMessage("Teleport.name");
@ -92,15 +79,9 @@ public class SimpleEssential extends JavaPlugin {
return false;
}
@Override
public void onDisable() {
invcontrol.clearAllEnchantBench();
}
@Override
public void onEnable() {
this.initTeleportControl();
this.initInventoryControl();
this.registerCommands();
this.registerEvents();
new VersionChecker(this);
@ -158,6 +139,5 @@ public class SimpleEssential extends JavaPlugin {
*/
private void registerEvents() {
registerEvent(new PlayerLocationListen(this));
registerEvent(new PlayerInventoryViewListen(this));
}
}

View File

@ -26,7 +26,7 @@ public class CommandEnchantBench extends BaseCommand {
@Override
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
Player p = (Player) sender;
plugin.invcontrol.openEnchantBench(p);
p.openEnchanting(null, true);
}
@Override

View File

@ -13,11 +13,7 @@ public class Language {
}
public static String getMessage(String path, Object... args) {
return String.format(config.getMessage(path), args);
}
public static String[] getStringArray(String path) {
return config.getStringList(path).toArray(new String[0]);
return String.format(getMessage(path), args);
}
public static void load(Plugin p) {

View File

@ -1,21 +0,0 @@
package cn.citycraft.SimpleEssential.config;
import java.io.File;
import org.bukkit.plugin.Plugin;
import cn.citycraft.config.FileConfig;
public class PlayerConfig {
private static String CONFIG_FOLDER = "userdate";
private static FileConfig config;
public static String[] getStringArray(String path) {
return config.getStringList(path).toArray(new String[0]);
}
public void load(Plugin p, String player) {
config = new FileConfig(p, new File(p.getDataFolder(), CONFIG_FOLDER + "/" + player));
}
}

View File

@ -1,73 +0,0 @@
/**
*
*/
package cn.citycraft.SimpleEssential.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.SimpleEssential.SimpleEssential;
/**
* @author 蒋天蓓
*
*/
public class InventoryControl {
SimpleEssential plugin;
HashMap<String, Location> enchantbench = new HashMap<String, Location>();
public InventoryControl(SimpleEssential 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);
}
}
}
}
}
}

View File

@ -1,39 +0,0 @@
/**
*
*/
package cn.citycraft.SimpleEssential.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.SimpleEssential.SimpleEssential;
/**
* 玩家随身附魔台记录监听
*
* @author 蒋天蓓 2015年8月12日下午8:19:33
*
*/
public class PlayerInventoryViewListen implements Listener {
SimpleEssential plugin;
public PlayerInventoryViewListen(SimpleEssential 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);
}
}
}