Skip to content

Commit

Permalink
!修复了无限刷经验的bug
Browse files Browse the repository at this point in the history
!在满级职业兑换经验时给予提示
!修复转型问题
!修复/trd exp空指针问题(这回是真的..)
  • Loading branch information
GQM authored and GQM committed Sep 23, 2012
1 parent 363563d commit 48c7010
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 16 deletions.
1 change: 1 addition & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="C:/Users/GQM/Desktop/server/1.25/craftbukkit-1.2.5-R4.1.jar">
<attributes>
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/com/trddiy/by664365842/CommandListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public boolean onCommand(CommandSender sender, Command cmd, String label,
plugin.sendtoserver("设置已由玩家 " + p.getName() + " 重载");
plugin.sendtoplayer(p, "设置已重载");
}
if (args.length >=2&&arg1.equals("exp") && Core.permission.has(p, "trd.exp")) {
if (arg1.equals("exp") && Core.permission.has(p, "trd.exp")) {
//plugin.sendtoplayer(p,"抱歉,功能未开放");
if(args[1] != null){
if(args.length >=2&&args[1] != null){
ifx.getItem(p, Integer.valueOf(args[1]));
}else{
plugin.sendtoplayer(p, "请输入要兑换的物品数!");
plugin.sendtoplayer(p, "请输入要用来兑换的物品数!");
}
}
if(arg1.equals("help")){
Expand Down
10 changes: 9 additions & 1 deletion src/com/trddiy/by664365842/ItemForXP.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,16 @@ public void getItem(Player p, int a) {
plugin.sendtoplayer(p, "请输入非零数字!");
return;
}
is.setAmount(is.getAmount() - a);
Hero h = plugin.getheroesplugin().getCharacterManager().getHero(p);
if(h.getLevel(h.getHeroClass()) == h.getHeroClass().getMaxLevel()){
plugin.sendtoplayer(p, "当前职业已满级!");
return;
}
if(is.getAmount() - a == 0){
p.getInventory().remove(is);
}else{
is.setAmount(is.getAmount() - a);
}
h.addExp(xp * a, h.getHeroClass());
h.syncExperience();
plugin.sendtoplayer(p, "你使用 " + ChatColor.GREEN + a + ChatColor.WHITE
Expand Down
29 changes: 17 additions & 12 deletions src/com/trddiy/by664365842/SignListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,39 @@
import org.bukkit.event.player.PlayerInteractEvent;

public class SignListener implements Listener {
//定义变量
// 定义变量
private Core plugin;
private ItemForXP ifx;
private static String name = ChatColor.BLUE + "[经验兑换]";
//构造
// 构造
public SignListener(Core plugin) {
this.plugin = plugin;
ifx = new ItemForXP(plugin);
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}

@EventHandler
public void onPlayerInteractEvent(PlayerInteractEvent event) {// 检查牌子使用
Player player = event.getPlayer();
if (event.getClickedBlock().getTypeId() == 323) {
Sign sign = (Sign) event.getClickedBlock();
if (sign.getLine(0).equals(name)) {
if (Core.permission.has(player, "trd.sign.use")) {
int amount = Integer.valueOf(sign.getLine(1));
ifx.getItem(player, amount);
} else {
plugin.sendtoplayer(player, ChatColor.RED + "你无使用此牌子的权限!");
// plugin.sendtoplayer(player,Integer.toString(event.getClickedBlock().getTypeId()));
if (event.getClickedBlock() != null) {
if (event.getClickedBlock().getTypeId() == 63) {
Sign sign = (Sign) event.getClickedBlock().getState();
if (sign.getLine(0).equals(name)) {
if (Core.permission.has(player, "trd.sign.use")) {
int amount = Integer.valueOf(sign.getLine(1));
ifx.getItem(player, amount);
} else {
plugin.sendtoplayer(player, ChatColor.RED
+ "你无使用此牌子的权限!");
}
}
}
}
}

@EventHandler
public void onplayerplaceblockevent(SignChangeEvent event) {//检查牌子创建
public void onplayerplaceblockevent(SignChangeEvent event) {// 检查牌子创建
Player p = event.getPlayer();
String[] lines = event.getLines();
if (Core.permission.has(p, "trd.sign.create")) {
Expand All @@ -45,7 +50,7 @@ public SignListener(Core plugin) {
event.setLine(0, name);
plugin.sendtoplayer(p, "建立牌子成功!");
} else {
plugin.sendtoplayer(p, "格式错误!第二行应为整数!");
plugin.sendtoplayer(p, "格式错误!第二行应为正整数!");
}
}
} else {
Expand Down

0 comments on commit 48c7010

Please sign in to comment.