mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-07-21 03:14:46 +02:00
Merge branch '2.9' into release
This commit is contained in:
commit
fca3ad4df9
|
@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
|
|||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.craftbukkit.SetExpFix;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -103,7 +104,7 @@ public class Commandexp extends EssentialsCommand
|
|||
}
|
||||
}
|
||||
|
||||
private void expMatch(final Server server, final CommandSender sender, final String match, final String amount, final boolean toggle) throws NotEnoughArgumentsException
|
||||
private void expMatch(final Server server, final CommandSender sender, final String match, String amount, final boolean toggle) throws NotEnoughArgumentsException
|
||||
{
|
||||
boolean foundUser = false;
|
||||
for (Player matchPlayer : server.matchPlayer(match))
|
||||
|
@ -124,9 +125,25 @@ public class Commandexp extends EssentialsCommand
|
|||
sender.sendMessage(_("exp", target.getDisplayName(), SetExpFix.getTotalExperience(target), target.getLevel(), SetExpFix.getExpUntilNextLevel(target)));
|
||||
}
|
||||
|
||||
private void setExp(final CommandSender sender, final User target, final String strAmount, final boolean give)
|
||||
private void setExp(final CommandSender sender, final User target, String strAmount, final boolean give)
|
||||
{
|
||||
Long amount = Long.parseLong(strAmount);
|
||||
Long amount;
|
||||
strAmount = strAmount.toLowerCase(Locale.ENGLISH);
|
||||
if (strAmount.startsWith("l"))
|
||||
{
|
||||
strAmount = strAmount.substring(1);
|
||||
int neededLevel = Integer.parseInt(strAmount);
|
||||
if (give)
|
||||
{
|
||||
neededLevel += target.getLevel();
|
||||
}
|
||||
amount = (long)SetExpFix.getExpToLevel(neededLevel);
|
||||
SetExpFix.setTotalExperience(target, 0);
|
||||
}
|
||||
else {
|
||||
amount = Long.parseLong(strAmount);
|
||||
}
|
||||
|
||||
if (give)
|
||||
{
|
||||
amount += SetExpFix.getTotalExperience(target);
|
||||
|
|
|
@ -20,10 +20,16 @@ public class Commandtime extends EssentialsCommand
|
|||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
boolean add = false;
|
||||
final List<String> argList = new ArrayList<String>(Arrays.asList(args));
|
||||
if ((argList.remove("set") || argList.remove("add")) && Util.isInt(argList.get(0)))
|
||||
if (argList.remove("set") && !argList.isEmpty() && Util.isInt(argList.get(0)))
|
||||
{
|
||||
ess.getLogger().info("debug edited 0" + argList.get(0).toString());
|
||||
argList.set(0, argList.get(0) + "t");
|
||||
}
|
||||
if (argList.remove("add") && !argList.isEmpty() && Util.isInt(argList.get(0)))
|
||||
{
|
||||
add = true;
|
||||
argList.set(0, argList.get(0) + "t");
|
||||
}
|
||||
final String[] validArgs = argList.toArray(new String[0]);
|
||||
|
||||
|
@ -34,12 +40,27 @@ public class Commandtime extends EssentialsCommand
|
|||
worldSelector = validArgs[1];
|
||||
}
|
||||
final Set<World> worlds = getWorlds(server, sender, worldSelector);
|
||||
final String setTime;
|
||||
|
||||
// If no arguments we are reading the time
|
||||
if (validArgs.length == 0)
|
||||
{
|
||||
getWorldsTime(sender, worlds);
|
||||
return;
|
||||
if (commandLabel.equalsIgnoreCase("day") || commandLabel.equalsIgnoreCase("eday"))
|
||||
{
|
||||
setTime = "day";
|
||||
}
|
||||
else if (commandLabel.equalsIgnoreCase("night") || commandLabel.equalsIgnoreCase("enight"))
|
||||
{
|
||||
setTime = "night";
|
||||
}
|
||||
else
|
||||
{
|
||||
getWorldsTime(sender, worlds);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
setTime = validArgs[0];
|
||||
}
|
||||
|
||||
final User user = ess.getUser(sender);
|
||||
|
@ -53,14 +74,14 @@ public class Commandtime extends EssentialsCommand
|
|||
long ticks;
|
||||
try
|
||||
{
|
||||
ticks = DescParseTickFormat.parse(validArgs[0]);
|
||||
ticks = DescParseTickFormat.parse(setTime);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
throw new NotEnoughArgumentsException(e);
|
||||
}
|
||||
|
||||
setWorldsTime(sender, worlds, ticks);
|
||||
setWorldsTime(sender, worlds, ticks, add);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,14 +105,17 @@ public class Commandtime extends EssentialsCommand
|
|||
/**
|
||||
* Used to set the time and inform of the change
|
||||
*/
|
||||
private void setWorldsTime(final CommandSender sender, final Collection<World> worlds, final long ticks)
|
||||
private void setWorldsTime(final CommandSender sender, final Collection<World> worlds, final long ticks, final boolean add)
|
||||
{
|
||||
// Update the time
|
||||
for (World world : worlds)
|
||||
{
|
||||
long time = world.getTime();
|
||||
time -= time % 24000;
|
||||
world.setTime(time + 24000 + ticks);
|
||||
if (!add)
|
||||
{
|
||||
time -= time % 24000;
|
||||
}
|
||||
world.setTime(time + (add ? 0 : 24000) + ticks);
|
||||
}
|
||||
|
||||
final StringBuilder output = new StringBuilder();
|
||||
|
@ -159,4 +183,4 @@ class WorldNameComparator implements Comparator<World>
|
|||
{
|
||||
return a.getName().compareTo(b.getName());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,12 +18,27 @@ public class Commandweather extends EssentialsCommand
|
|||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final boolean isStorm;
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
if (commandLabel.equalsIgnoreCase("sun") || commandLabel.equalsIgnoreCase("esun"))
|
||||
{
|
||||
isStorm = false;
|
||||
}
|
||||
else if (commandLabel.equalsIgnoreCase("storm") || commandLabel.equalsIgnoreCase("estorm")
|
||||
|| commandLabel.equalsIgnoreCase("rain") || commandLabel.equalsIgnoreCase("erain"))
|
||||
{
|
||||
isStorm = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
isStorm = args[0].equalsIgnoreCase("storm");
|
||||
}
|
||||
|
||||
final boolean isStorm = args[0].equalsIgnoreCase("storm");
|
||||
final World world = user.getWorld();
|
||||
if (args.length > 1)
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@ public class SetExpFix
|
|||
int amount = exp;
|
||||
while (amount > 0)
|
||||
{
|
||||
final int expToLevel = getExpToLevel(player);
|
||||
final int expToLevel = getExpAtLevel(player);
|
||||
amount -= expToLevel;
|
||||
if (amount >= 0)
|
||||
{
|
||||
|
@ -39,43 +39,56 @@ public class SetExpFix
|
|||
}
|
||||
}
|
||||
|
||||
private static int getExpToLevel(final Player player)
|
||||
private static int getExpAtLevel(final Player player)
|
||||
{
|
||||
return getExpToLevel(player.getLevel());
|
||||
return getExpAtLevel(player.getLevel());
|
||||
}
|
||||
|
||||
private static int getExpToLevel(final int level)
|
||||
public static int getExpAtLevel(final int level)
|
||||
{
|
||||
if (level >= 30)
|
||||
if (level > 29)
|
||||
{
|
||||
return 62 + (level - 30) * 7;
|
||||
}
|
||||
if (level >= 15)
|
||||
if (level > 15)
|
||||
{
|
||||
return 17 + (level - 15) * 3;
|
||||
}
|
||||
return 17;
|
||||
}
|
||||
|
||||
public static int getExpToLevel(final int level)
|
||||
{
|
||||
int currentLevel = 0;
|
||||
int exp = 0;
|
||||
|
||||
while (currentLevel < level)
|
||||
{
|
||||
exp += getExpAtLevel(currentLevel);
|
||||
currentLevel++;
|
||||
}
|
||||
return exp;
|
||||
}
|
||||
|
||||
//This method is required because the bukkit player.getTotalExperience() method, shows exp that has been 'spent'.
|
||||
//Without this people would be able to use exp and then still sell it.
|
||||
public static int getTotalExperience(final Player player)
|
||||
{
|
||||
int exp = (int)Math.round(getExpToLevel(player) * player.getExp());
|
||||
int exp = (int)Math.round(getExpAtLevel(player) * player.getExp());
|
||||
int currentLevel = player.getLevel();
|
||||
|
||||
while (currentLevel > 0)
|
||||
{
|
||||
currentLevel--;
|
||||
exp += getExpToLevel(currentLevel);
|
||||
exp += getExpAtLevel(currentLevel);
|
||||
}
|
||||
return exp;
|
||||
}
|
||||
|
||||
public static int getExpUntilNextLevel(final Player player)
|
||||
{
|
||||
int exp = (int)Math.round(getExpToLevel(player) * player.getExp());
|
||||
int nextLevel = player.getLevel() + 1;
|
||||
return getExpToLevel(nextLevel) - exp;
|
||||
int exp = (int)Math.round(getExpAtLevel(player) * player.getExp());
|
||||
int nextLevel = player.getLevel();
|
||||
return getExpAtLevel(nextLevel) - exp;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.*;
|
||||
import com.earth2me.essentials.commands.NoChargeException;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
@ -62,6 +63,10 @@ public class SignKit extends EssentialsSign
|
|||
Kit.expandItems(ess, player, items);
|
||||
charge.charge(player);
|
||||
}
|
||||
catch (NoChargeException ex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new SignException(ex.getMessage(), ex);
|
||||
|
|
|
@ -156,11 +156,13 @@ player-commands:
|
|||
- signs.use.disposal
|
||||
- signs.use.enchant
|
||||
- signs.use.free
|
||||
- signs.use.gamemode
|
||||
- signs.use.gamemode
|
||||
- signs.use.heal
|
||||
- signs.use.info
|
||||
- signs.use.kit
|
||||
- signs.use.mail
|
||||
- signs.use.protection
|
||||
- signs.use.repair
|
||||
- signs.use.sell
|
||||
- signs.use.time
|
||||
- signs.use.trade
|
||||
|
@ -194,7 +196,7 @@ kits:
|
|||
delay: 10
|
||||
items:
|
||||
- 272 1
|
||||
- 273 1
|
||||
- 273 1
|
||||
- 274 1
|
||||
- 275 1
|
||||
|
||||
|
@ -207,7 +209,7 @@ kits:
|
|||
enabledSigns:
|
||||
#- color
|
||||
#- balance
|
||||
#- buy
|
||||
#- buy
|
||||
#- sell
|
||||
#- trade
|
||||
#- free
|
||||
|
@ -454,7 +456,7 @@ protect:
|
|||
alert:
|
||||
on-placement: 10,11,46,327
|
||||
on-use: 327
|
||||
on-break:
|
||||
on-break:
|
||||
|
||||
blacklist:
|
||||
|
||||
|
@ -512,7 +514,7 @@ protect:
|
|||
ender_dragon: false
|
||||
pig: false
|
||||
sheep: false
|
||||
cow: false
|
||||
cow: false
|
||||
chicken: false
|
||||
squid: false
|
||||
wolf: false
|
||||
|
|
|
@ -1733,6 +1733,8 @@ endgooframe,120,0
|
|||
endergooframe,120,0
|
||||
egooframe,120,0
|
||||
eportalframe,120,0
|
||||
enderframe,120,0
|
||||
endframe,120,0
|
||||
enderstone,121,0
|
||||
endstone,121,0
|
||||
endrock,121,0
|
||||
|
|
|
|
@ -341,7 +341,7 @@ commands:
|
|||
time:
|
||||
description: Display/Change the world time. Defaults to current world.
|
||||
usage: /<command> [day|night|dawn|17:30|4pm|4000ticks] [worldname|all]
|
||||
aliases: [etime, day, night]
|
||||
aliases: [etime, day, night, eday, enight]
|
||||
togglejail:
|
||||
description: Jails/Unjails a player and tp them to the jail specified.
|
||||
usage: /<command> <player> <jailname> [datediff]
|
||||
|
@ -425,7 +425,7 @@ commands:
|
|||
weather:
|
||||
description: Setting the weather.
|
||||
usage: /<command> <storm/sun> [duration]
|
||||
aliases: [sky,sun,storm,eweather,esky,esun,estorm]
|
||||
aliases: [sky,sun,storm,eweather,rain,erain,esky,esun,estorm]
|
||||
whois:
|
||||
description: Determine the username behind a nickname.
|
||||
usage: /<command> <nickname>
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.earth2me.essentials.IEssentials;
|
|||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
|
@ -46,11 +47,25 @@ public abstract class EssentialsChatPlayer implements Listener
|
|||
}
|
||||
synchronized (listeners)
|
||||
{
|
||||
for (IEssentialsChatListener listener : listeners.values())
|
||||
for (Map.Entry<String, IEssentialsChatListener> listener : listeners.entrySet())
|
||||
{
|
||||
if (listener.shouldHandleThisChat(event))
|
||||
try
|
||||
{
|
||||
return true;
|
||||
if (listener.getValue().shouldHandleThisChat(event))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, "Error with EssentialsChat listener of " + listener.getKey() + ": " + t.getMessage(), t);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.log(Level.WARNING, "Error with EssentialsChat listener of " + listener.getKey() + ": " + t.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -160,9 +175,23 @@ public abstract class EssentialsChatPlayer implements Listener
|
|||
String message = String.format(event.getFormat(), type.concat(sender.getDisplayName()), event.getMessage());
|
||||
synchronized (listeners)
|
||||
{
|
||||
for (IEssentialsChatListener listener : listeners.values())
|
||||
for (Map.Entry<String, IEssentialsChatListener> listener : listeners.entrySet())
|
||||
{
|
||||
message = listener.modifyMessage(event, onlinePlayer, message);
|
||||
try
|
||||
{
|
||||
message = listener.getValue().modifyMessage(event, onlinePlayer, message);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, "Error with EssentialsChat listener of " + listener.getKey() + ": " + t.getMessage(), t);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.log(Level.WARNING, "Error with EssentialsChat listener of " + listener.getKey() + ": " + t.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
onlineUser.sendMessage(message);
|
||||
|
|
|
@ -222,6 +222,7 @@ groups:
|
|||
- essentials.warp.*
|
||||
- essentials.weather
|
||||
- essentials.whois
|
||||
- essentials.workbench
|
||||
- essentials.world
|
||||
- essentials.world.*
|
||||
|
||||
|
|
|
@ -161,7 +161,11 @@ public class GlobalGroups {
|
|||
Object element;
|
||||
|
||||
// Permission nodes
|
||||
element = ((Map<String, Object>)allGroups.get(groupName)).get("permissions");
|
||||
try {
|
||||
element = ((Map<String, Object>)allGroups.get(groupName)).get("permissions");
|
||||
} catch ( Exception ex) {
|
||||
throw new IllegalArgumentException("The GlobalGroup ' " + groupName + "' is formatted incorrectly: ", ex);
|
||||
}
|
||||
|
||||
if (element != null)
|
||||
if (element instanceof List) {
|
||||
|
@ -180,7 +184,11 @@ public class GlobalGroups {
|
|||
throw new IllegalArgumentException("Unknown type of permission node for global group: " + groupName);
|
||||
|
||||
// Info nodes
|
||||
element = ((Map<String, Object>)allGroups.get(groupName)).get("info");
|
||||
try {
|
||||
element = ((Map<String, Object>)allGroups.get(groupName)).get("info");
|
||||
} catch ( Exception ex) {
|
||||
throw new IllegalArgumentException("The GlobalGroup ' " + groupName + "' is formatted incorrectly: ", ex);
|
||||
}
|
||||
|
||||
if (element != null)
|
||||
if (element instanceof MemorySection) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user