mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-13 10:04:51 +02:00
Removing server layer part 2
This commit is contained in:
@@ -297,7 +297,7 @@ public class EssentialsSign
|
||||
return new Trade(amount, ess);
|
||||
}
|
||||
final ItemStack item = getItemStack(sign.getLine(itemIndex), 1, ess);
|
||||
final int amount = Math.min(getIntegerPositive(sign.getLine(amountIndex)), item.getType().getMaxStackSize() * player.getInventory().getSize());
|
||||
final int amount = Math.min(getIntegerPositive(sign.getLine(amountIndex)), item.getType().getMaxStackSize() * player.getPlayer().getInventory().getSize());
|
||||
if (item.getTypeId() == 0 || amount < 1)
|
||||
{
|
||||
throw new SignException(_("moreThanZero"));
|
||||
|
@@ -4,6 +4,7 @@ import static net.ess3.I18n._;
|
||||
import net.ess3.api.IEssentials;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.ess3.api.IPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@@ -18,12 +19,13 @@ public class EssentialsSignsPlugin extends JavaPlugin implements ISignsPlugin
|
||||
public void onEnable()
|
||||
{
|
||||
final PluginManager pluginManager = getServer().getPluginManager();
|
||||
final IEssentials ess = (IEssentials)pluginManager.getPlugin("Essentials-3");
|
||||
if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion()))
|
||||
final IPlugin plugin = (IPlugin)pluginManager.getPlugin("Essentials-3");
|
||||
final IEssentials ess = (IEssentials)plugin.getEssentials();
|
||||
if (!this.getDescription().getVersion().equals(plugin.getDescription().getVersion()))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("versionMismatchAll"));
|
||||
}
|
||||
if (!ess.isEnabled())
|
||||
if (!plugin.isEnabled())
|
||||
{
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
|
@@ -88,7 +88,7 @@ public class SignEnchant extends EssentialsSign
|
||||
level = enchantment.getMaxLevel();
|
||||
}
|
||||
|
||||
final ItemStack playerHand = player.getItemInHand();
|
||||
final ItemStack playerHand = player.getPlayer().getItemInHand();
|
||||
if (playerHand == null
|
||||
|| playerHand.getAmount() != 1
|
||||
|| (playerHand.containsEnchantment(enchantment)
|
||||
@@ -113,7 +113,7 @@ public class SignEnchant extends EssentialsSign
|
||||
|
||||
charge.charge(player);
|
||||
Trade.log("Sign", "Enchant", "Interact", username, charge, username, charge, sign.getBlock().getLocation(), ess);
|
||||
player.updateInventory();
|
||||
player.getPlayer().updateInventory();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -33,9 +33,9 @@ public class SignFree extends EssentialsSign
|
||||
}
|
||||
|
||||
item.setAmount(item.getType().getMaxStackSize());
|
||||
InventoryWorkaround.addItem(player.getInventory(), true, item);
|
||||
InventoryWorkaround.addItem(player.getPlayer().getInventory(), true, item);
|
||||
player.sendMessage("Item added to your inventory.");
|
||||
player.updateInventory();
|
||||
player.getPlayer().updateInventory();
|
||||
//TODO: wait for a fix in bukkit
|
||||
//Problem: Items can be duplicated
|
||||
//Inventory i = ess.getServer().createInventory(player, InventoryType.CHEST);
|
||||
|
@@ -43,8 +43,8 @@ public class SignGameMode extends EssentialsSign
|
||||
charge.isAffordableFor(player);
|
||||
|
||||
//this needs to be fixed
|
||||
player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
|
||||
player.sendMessage(_("gameMode", _(player.getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getDisplayName()));
|
||||
player.getPlayer().setGameMode(player.getPlayer().getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
|
||||
player.sendMessage(_("gameMode", _(player.getPlayer().getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getPlayer().getDisplayName()));
|
||||
charge.charge(player);
|
||||
return true;
|
||||
}
|
||||
|
@@ -26,9 +26,9 @@ public class SignHeal extends EssentialsSign
|
||||
{
|
||||
final Trade charge = getTrade(sign, 1, ess);
|
||||
charge.isAffordableFor(player);
|
||||
player.setHealth(20);
|
||||
player.setFoodLevel(20);
|
||||
player.setFireTicks(0);
|
||||
player.getPlayer().setHealth(20);
|
||||
player.getPlayer().setFoodLevel(20);
|
||||
player.getPlayer().setFireTicks(0);
|
||||
player.sendMessage(_("youAreHealed"));
|
||||
charge.charge(player);
|
||||
return true;
|
||||
|
@@ -4,8 +4,8 @@ package net.ess3.signs;
|
||||
import java.io.IOException;
|
||||
import net.ess3.api.ChargeException;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.economy.Trade;
|
||||
import net.ess3.user.User;
|
||||
import net.ess3.utils.textreader.IText;
|
||||
import net.ess3.utils.textreader.KeywordReplacer;
|
||||
import net.ess3.utils.textreader.TextInput;
|
||||
@@ -20,14 +20,14 @@ public class SignInfo extends EssentialsSign
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException
|
||||
protected boolean onSignCreate(final ISign sign, final IUser player, final String username, final IEssentials ess) throws SignException
|
||||
{
|
||||
validateTrade(sign, 3, ess);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException
|
||||
protected boolean onSignInteract(final ISign sign, final IUser player, final String username, final IEssentials ess) throws SignException, ChargeException
|
||||
{
|
||||
final Trade charge = getTrade(sign, 3, ess);
|
||||
charge.isAffordableFor(player);
|
||||
|
@@ -1,9 +1,11 @@
|
||||
package net.ess3.signs;
|
||||
|
||||
import static net.ess3.I18n._;
|
||||
import net.ess3.api.ChargeException;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.commands.Commandrepair;
|
||||
import net.ess3.economy.Trade;
|
||||
import net.ess3.user.User;
|
||||
|
||||
|
||||
public class SignRepair extends EssentialsSign
|
||||
@@ -14,7 +16,7 @@ public class SignRepair extends EssentialsSign
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException
|
||||
protected boolean onSignCreate(final ISign sign, final IUser player, final String username, final IEssentials ess) throws SignException
|
||||
{
|
||||
final String repairTarget = sign.getLine(1);
|
||||
if (repairTarget.isEmpty())
|
||||
@@ -30,20 +32,20 @@ public class SignRepair extends EssentialsSign
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException
|
||||
protected boolean onSignInteract(final ISign sign, final IUser player, final String username, final IEssentials ess) throws SignException, ChargeException
|
||||
{
|
||||
final Trade charge = getTrade(sign, 2, ess);
|
||||
charge.isAffordableFor(player);
|
||||
|
||||
Commandrepair command = new Commandrepair();
|
||||
command.setEssentials(ess);
|
||||
command.init(ess, "repair");
|
||||
String[] args = new String[]
|
||||
{
|
||||
sign.getLine(1)
|
||||
};
|
||||
try
|
||||
{
|
||||
command.run(ess.getServer(), player, "repair", args);
|
||||
command.run(player, "repair", args);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@@ -5,6 +5,7 @@ import net.ess3.api.ChargeException;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.economy.Trade;
|
||||
import org.bukkit.World;
|
||||
|
||||
|
||||
public class SignTime extends EssentialsSign
|
||||
@@ -38,17 +39,18 @@ public class SignTime extends EssentialsSign
|
||||
final Trade charge = getTrade(sign, 2, ess);
|
||||
charge.isAffordableFor(player);
|
||||
final String timeString = sign.getLine(1);
|
||||
long time = player.getWorld().getTime();
|
||||
final World world = player.getPlayer().getWorld();
|
||||
long time = world.getTime();
|
||||
time -= time % 24000;
|
||||
if ("§2Day".equalsIgnoreCase(timeString))
|
||||
{
|
||||
player.getWorld().setTime(time + 24000);
|
||||
world.setTime(time + 24000);
|
||||
charge.charge(player);
|
||||
return true;
|
||||
}
|
||||
if ("§2Night".equalsIgnoreCase(timeString))
|
||||
{
|
||||
player.getWorld().setTime(time + 37700);
|
||||
world.setTime(time + 37700);
|
||||
charge.charge(player);
|
||||
return true;
|
||||
}
|
||||
|
@@ -75,16 +75,17 @@ public class SignTrade extends EssentialsSign
|
||||
private Trade rechargeSign(final ISign sign, final IEssentials ess, final IUser player) throws SignException, ChargeException
|
||||
{
|
||||
final Trade trade = getTrade(sign, 2, false, false, ess);
|
||||
if (trade.getItemStack() != null && player.getItemInHand() != null
|
||||
&& trade.getItemStack().getTypeId() == player.getItemInHand().getTypeId()
|
||||
&& trade.getItemStack().getDurability() == player.getItemInHand().getDurability()
|
||||
&& trade.getItemStack().getEnchantments().equals(player.getItemInHand().getEnchantments()))
|
||||
ItemStack itemInHand = player.getPlayer().getItemInHand();
|
||||
if (trade.getItemStack() != null && itemInHand != null
|
||||
&& trade.getItemStack().getTypeId() == itemInHand.getTypeId()
|
||||
&& trade.getItemStack().getDurability() == itemInHand.getDurability()
|
||||
&& trade.getItemStack().getEnchantments().equals(itemInHand.getEnchantments()))
|
||||
{
|
||||
int amount = player.getItemInHand().getAmount();
|
||||
int amount = itemInHand.getAmount();
|
||||
amount -= amount % trade.getItemStack().getAmount();
|
||||
if (amount > 0)
|
||||
{
|
||||
final ItemStack stack = player.getItemInHand().clone();
|
||||
final ItemStack stack = itemInHand.clone();
|
||||
stack.setAmount(amount);
|
||||
final Trade store = new Trade(stack, ess);
|
||||
addAmount(sign, 2, store, ess);
|
||||
|
@@ -5,6 +5,7 @@ import net.ess3.api.ChargeException;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.economy.Trade;
|
||||
import org.bukkit.World;
|
||||
|
||||
|
||||
public class SignWeather extends EssentialsSign
|
||||
@@ -38,15 +39,16 @@ public class SignWeather extends EssentialsSign
|
||||
final Trade charge = getTrade(sign, 2, ess);
|
||||
charge.isAffordableFor(player);
|
||||
final String weatherString = sign.getLine(1);
|
||||
final World world = player.getPlayer().getWorld();
|
||||
if ("§2Sun".equalsIgnoreCase(weatherString))
|
||||
{
|
||||
player.getWorld().setStorm(false);
|
||||
world.setStorm(false);
|
||||
charge.charge(player);
|
||||
return true;
|
||||
}
|
||||
if ("§2Storm".equalsIgnoreCase(weatherString))
|
||||
{
|
||||
player.getWorld().setStorm(true);
|
||||
world.setStorm(true);
|
||||
charge.charge(player);
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user