mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-03 15:08:18 +01:00
Fixed merge error
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1034 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
441b8ad926
commit
d4973ae644
@ -1,16 +1,10 @@
|
|||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
import net.minecraft.server.InventoryPlayer;
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.*;
|
import org.bukkit.block.*;
|
||||||
import org.bukkit.craftbukkit.block.CraftSign;
|
import org.bukkit.craftbukkit.block.CraftSign;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
|
||||||
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.block.*;
|
import org.bukkit.event.block.*;
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
|
|
||||||
public class EssentialsBlockListener extends BlockListener
|
public class EssentialsBlockListener extends BlockListener
|
||||||
@ -129,86 +123,6 @@ public class EssentialsBlockListener extends BlockListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBlockRightClick(BlockRightClickEvent event)
|
|
||||||
{
|
|
||||||
User user = User.get(event.getPlayer());
|
|
||||||
if (user.isJailed()) return;
|
|
||||||
if (Essentials.getSettings().areSignsDisabled()) return;
|
|
||||||
if (event.getBlock().getType() != Material.WALL_SIGN && event.getBlock().getType() != Material.SIGN_POST)
|
|
||||||
return;
|
|
||||||
Sign sign = new CraftSign(event.getBlock());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (sign.getLine(0).equals("§1[Free]") && user.isAuthorized("essentials.signs.free.use"))
|
|
||||||
{
|
|
||||||
ItemStack item = ItemDb.get(sign.getLine(1));
|
|
||||||
CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(user.getHandle()));
|
|
||||||
inv.clear();
|
|
||||||
item.setAmount(9 * 4 * 64);
|
|
||||||
inv.addItem(item);
|
|
||||||
user.showInventory(inv);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (sign.getLine(0).equals("§1[Disposal]") && user.isAuthorized("essentials.signs.disposal.use"))
|
|
||||||
{
|
|
||||||
CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(user.getHandle()));
|
|
||||||
inv.clear();
|
|
||||||
user.showInventory(inv);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (sign.getLine(0).equals("§1[Heal]") && user.isAuthorized("essentials.signs.heal.use"))
|
|
||||||
{
|
|
||||||
if (!sign.getLine(1).isEmpty()) {
|
|
||||||
String[] l1 = sign.getLine(1).split("[ :-]+");
|
|
||||||
boolean m1 = l1[0].matches("\\$[0-9]+");
|
|
||||||
int q1 = Integer.parseInt(m1 ? l1[0].substring(1) : l1[0]);
|
|
||||||
if (q1 < 1) throw new Exception("Quantities must be greater than 0.");
|
|
||||||
if (m1)
|
|
||||||
{
|
|
||||||
if (user.getMoney() < q1) throw
|
|
||||||
new Exception("You do not have sufficient funds.");
|
|
||||||
user.takeMoney(q1);
|
|
||||||
user.sendMessage("$" + q1 + " taken from your bank account.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ItemStack i = ItemDb.get(l1[1], q1);
|
|
||||||
if (!InventoryWorkaround.containsItem((CraftInventory)user.getInventory(), true, i))
|
|
||||||
throw new Exception("You do not have " + q1 + "x " + l1[1] + ".");
|
|
||||||
InventoryWorkaround.removeItem((CraftInventory)user.getInventory(), true, i);
|
|
||||||
user.updateInventory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
user.setHealth(20);
|
|
||||||
user.sendMessage("§7You have been healed.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (sign.getLine(0).equals("§1[Mail]") && user.isAuthorized("essentials.signs.mail.use") && user.isAuthorized("essentials.mail"))
|
|
||||||
{
|
|
||||||
List<String> mail = Essentials.readMail(user);
|
|
||||||
if (mail.isEmpty())
|
|
||||||
{
|
|
||||||
user.sendMessage("§cYou do not have any mail!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (String s : mail) user.sendMessage(s);
|
|
||||||
user.sendMessage("§cTo mark your mail as read, type §c/mail clear");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (sign.getLine(0).equals("§1[Balance]") && user.isAuthorized("essentials.signs.balance.use"))
|
|
||||||
{
|
|
||||||
user.sendMessage("§7Balance: $" + user.getMoney());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Throwable ex)
|
|
||||||
{
|
|
||||||
user.sendMessage("§cError: " + ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
Block signBlock = event.getBlockAgainst();
|
Block signBlock = event.getBlockAgainst();
|
||||||
|
@ -240,7 +240,6 @@ public class EssentialsPlayerListener extends PlayerListener
|
|||||||
@Override
|
@Override
|
||||||
public void onPlayerInteract(PlayerInteractEvent event)
|
public void onPlayerInteract(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
||||||
User user = User.get(event.getPlayer());
|
User user = User.get(event.getPlayer());
|
||||||
|
Loading…
Reference in New Issue
Block a user