mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-09-16 01:57:09 +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 static com.earth2me.essentials.I18n._;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import com.earth2me.essentials.craftbukkit.SetExpFix;
|
import com.earth2me.essentials.craftbukkit.SetExpFix;
|
||||||
|
import java.util.Locale;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
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;
|
boolean foundUser = false;
|
||||||
for (Player matchPlayer : server.matchPlayer(match))
|
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)));
|
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)
|
if (give)
|
||||||
{
|
{
|
||||||
amount += SetExpFix.getTotalExperience(target);
|
amount += SetExpFix.getTotalExperience(target);
|
||||||
|
@ -20,10 +20,16 @@ public class Commandtime extends EssentialsCommand
|
|||||||
@Override
|
@Override
|
||||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
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));
|
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]);
|
final String[] validArgs = argList.toArray(new String[0]);
|
||||||
|
|
||||||
@ -34,13 +40,28 @@ public class Commandtime extends EssentialsCommand
|
|||||||
worldSelector = validArgs[1];
|
worldSelector = validArgs[1];
|
||||||
}
|
}
|
||||||
final Set<World> worlds = getWorlds(server, sender, worldSelector);
|
final Set<World> worlds = getWorlds(server, sender, worldSelector);
|
||||||
|
final String setTime;
|
||||||
|
|
||||||
// If no arguments we are reading the time
|
// If no arguments we are reading the time
|
||||||
if (validArgs.length == 0)
|
if (validArgs.length == 0)
|
||||||
|
{
|
||||||
|
if (commandLabel.equalsIgnoreCase("day") || commandLabel.equalsIgnoreCase("eday"))
|
||||||
|
{
|
||||||
|
setTime = "day";
|
||||||
|
}
|
||||||
|
else if (commandLabel.equalsIgnoreCase("night") || commandLabel.equalsIgnoreCase("enight"))
|
||||||
|
{
|
||||||
|
setTime = "night";
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
getWorldsTime(sender, worlds);
|
getWorldsTime(sender, worlds);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setTime = validArgs[0];
|
||||||
|
}
|
||||||
|
|
||||||
final User user = ess.getUser(sender);
|
final User user = ess.getUser(sender);
|
||||||
if (user != null && !user.isAuthorized("essentials.time.set"))
|
if (user != null && !user.isAuthorized("essentials.time.set"))
|
||||||
@ -53,14 +74,14 @@ public class Commandtime extends EssentialsCommand
|
|||||||
long ticks;
|
long ticks;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ticks = DescParseTickFormat.parse(validArgs[0]);
|
ticks = DescParseTickFormat.parse(setTime);
|
||||||
}
|
}
|
||||||
catch (NumberFormatException e)
|
catch (NumberFormatException e)
|
||||||
{
|
{
|
||||||
throw new NotEnoughArgumentsException(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
|
* 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
|
// Update the time
|
||||||
for (World world : worlds)
|
for (World world : worlds)
|
||||||
{
|
{
|
||||||
long time = world.getTime();
|
long time = world.getTime();
|
||||||
|
if (!add)
|
||||||
|
{
|
||||||
time -= time % 24000;
|
time -= time % 24000;
|
||||||
world.setTime(time + 24000 + ticks);
|
}
|
||||||
|
world.setTime(time + (add ? 0 : 24000) + ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
final StringBuilder output = new StringBuilder();
|
final StringBuilder output = new StringBuilder();
|
||||||
|
@ -18,12 +18,27 @@ public class Commandweather extends EssentialsCommand
|
|||||||
@Override
|
@Override
|
||||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||||
{
|
{
|
||||||
|
final boolean isStorm;
|
||||||
if (args.length < 1)
|
if (args.length < 1)
|
||||||
|
{
|
||||||
|
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();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
final boolean isStorm = args[0].equalsIgnoreCase("storm");
|
else
|
||||||
|
{
|
||||||
|
isStorm = args[0].equalsIgnoreCase("storm");
|
||||||
|
}
|
||||||
final World world = user.getWorld();
|
final World world = user.getWorld();
|
||||||
if (args.length > 1)
|
if (args.length > 1)
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,7 @@ public class SetExpFix
|
|||||||
int amount = exp;
|
int amount = exp;
|
||||||
while (amount > 0)
|
while (amount > 0)
|
||||||
{
|
{
|
||||||
final int expToLevel = getExpToLevel(player);
|
final int expToLevel = getExpAtLevel(player);
|
||||||
amount -= expToLevel;
|
amount -= expToLevel;
|
||||||
if (amount >= 0)
|
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;
|
return 62 + (level - 30) * 7;
|
||||||
}
|
}
|
||||||
if (level >= 15)
|
if (level > 15)
|
||||||
{
|
{
|
||||||
return 17 + (level - 15) * 3;
|
return 17 + (level - 15) * 3;
|
||||||
}
|
}
|
||||||
return 17;
|
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'.
|
//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.
|
//Without this people would be able to use exp and then still sell it.
|
||||||
public static int getTotalExperience(final Player player)
|
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();
|
int currentLevel = player.getLevel();
|
||||||
|
|
||||||
while (currentLevel > 0)
|
while (currentLevel > 0)
|
||||||
{
|
{
|
||||||
currentLevel--;
|
currentLevel--;
|
||||||
exp += getExpToLevel(currentLevel);
|
exp += getExpAtLevel(currentLevel);
|
||||||
}
|
}
|
||||||
return exp;
|
return exp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getExpUntilNextLevel(final Player player)
|
public static int getExpUntilNextLevel(final Player player)
|
||||||
{
|
{
|
||||||
int exp = (int)Math.round(getExpToLevel(player) * player.getExp());
|
int exp = (int)Math.round(getExpAtLevel(player) * player.getExp());
|
||||||
int nextLevel = player.getLevel() + 1;
|
int nextLevel = player.getLevel();
|
||||||
return getExpToLevel(nextLevel) - exp;
|
return getExpAtLevel(nextLevel) - exp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.earth2me.essentials.signs;
|
package com.earth2me.essentials.signs;
|
||||||
|
|
||||||
import com.earth2me.essentials.*;
|
import com.earth2me.essentials.*;
|
||||||
|
import com.earth2me.essentials.commands.NoChargeException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -62,6 +63,10 @@ public class SignKit extends EssentialsSign
|
|||||||
Kit.expandItems(ess, player, items);
|
Kit.expandItems(ess, player, items);
|
||||||
charge.charge(player);
|
charge.charge(player);
|
||||||
}
|
}
|
||||||
|
catch (NoChargeException ex)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new SignException(ex.getMessage(), ex);
|
throw new SignException(ex.getMessage(), ex);
|
||||||
|
@ -158,9 +158,11 @@ player-commands:
|
|||||||
- signs.use.free
|
- signs.use.free
|
||||||
- signs.use.gamemode
|
- signs.use.gamemode
|
||||||
- signs.use.heal
|
- signs.use.heal
|
||||||
|
- signs.use.info
|
||||||
- signs.use.kit
|
- signs.use.kit
|
||||||
- signs.use.mail
|
- signs.use.mail
|
||||||
- signs.use.protection
|
- signs.use.protection
|
||||||
|
- signs.use.repair
|
||||||
- signs.use.sell
|
- signs.use.sell
|
||||||
- signs.use.time
|
- signs.use.time
|
||||||
- signs.use.trade
|
- signs.use.trade
|
||||||
|
@ -1733,6 +1733,8 @@ endgooframe,120,0
|
|||||||
endergooframe,120,0
|
endergooframe,120,0
|
||||||
egooframe,120,0
|
egooframe,120,0
|
||||||
eportalframe,120,0
|
eportalframe,120,0
|
||||||
|
enderframe,120,0
|
||||||
|
endframe,120,0
|
||||||
enderstone,121,0
|
enderstone,121,0
|
||||||
endstone,121,0
|
endstone,121,0
|
||||||
endrock,121,0
|
endrock,121,0
|
||||||
|
|
@ -341,7 +341,7 @@ commands:
|
|||||||
time:
|
time:
|
||||||
description: Display/Change the world time. Defaults to current world.
|
description: Display/Change the world time. Defaults to current world.
|
||||||
usage: /<command> [day|night|dawn|17:30|4pm|4000ticks] [worldname|all]
|
usage: /<command> [day|night|dawn|17:30|4pm|4000ticks] [worldname|all]
|
||||||
aliases: [etime, day, night]
|
aliases: [etime, day, night, eday, enight]
|
||||||
togglejail:
|
togglejail:
|
||||||
description: Jails/Unjails a player and tp them to the jail specified.
|
description: Jails/Unjails a player and tp them to the jail specified.
|
||||||
usage: /<command> <player> <jailname> [datediff]
|
usage: /<command> <player> <jailname> [datediff]
|
||||||
@ -425,7 +425,7 @@ commands:
|
|||||||
weather:
|
weather:
|
||||||
description: Setting the weather.
|
description: Setting the weather.
|
||||||
usage: /<command> <storm/sun> [duration]
|
usage: /<command> <storm/sun> [duration]
|
||||||
aliases: [sky,sun,storm,eweather,esky,esun,estorm]
|
aliases: [sky,sun,storm,eweather,rain,erain,esky,esun,estorm]
|
||||||
whois:
|
whois:
|
||||||
description: Determine the username behind a nickname.
|
description: Determine the username behind a nickname.
|
||||||
usage: /<command> <nickname>
|
usage: /<command> <nickname>
|
||||||
|
@ -6,6 +6,7 @@ import com.earth2me.essentials.IEssentials;
|
|||||||
import com.earth2me.essentials.Trade;
|
import com.earth2me.essentials.Trade;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
@ -46,13 +47,27 @@ public abstract class EssentialsChatPlayer implements Listener
|
|||||||
}
|
}
|
||||||
synchronized (listeners)
|
synchronized (listeners)
|
||||||
{
|
{
|
||||||
for (IEssentialsChatListener listener : listeners.values())
|
for (Map.Entry<String, IEssentialsChatListener> listener : listeners.entrySet())
|
||||||
{
|
{
|
||||||
if (listener.shouldHandleThisChat(event))
|
try
|
||||||
|
{
|
||||||
|
if (listener.getValue().shouldHandleThisChat(event))
|
||||||
{
|
{
|
||||||
return true;
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -160,9 +175,23 @@ public abstract class EssentialsChatPlayer implements Listener
|
|||||||
String message = String.format(event.getFormat(), type.concat(sender.getDisplayName()), event.getMessage());
|
String message = String.format(event.getFormat(), type.concat(sender.getDisplayName()), event.getMessage());
|
||||||
synchronized (listeners)
|
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);
|
onlineUser.sendMessage(message);
|
||||||
|
@ -222,6 +222,7 @@ groups:
|
|||||||
- essentials.warp.*
|
- essentials.warp.*
|
||||||
- essentials.weather
|
- essentials.weather
|
||||||
- essentials.whois
|
- essentials.whois
|
||||||
|
- essentials.workbench
|
||||||
- essentials.world
|
- essentials.world
|
||||||
- essentials.world.*
|
- essentials.world.*
|
||||||
|
|
||||||
|
@ -161,7 +161,11 @@ public class GlobalGroups {
|
|||||||
Object element;
|
Object element;
|
||||||
|
|
||||||
// Permission nodes
|
// Permission nodes
|
||||||
|
try {
|
||||||
element = ((Map<String, Object>)allGroups.get(groupName)).get("permissions");
|
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 != null)
|
||||||
if (element instanceof List) {
|
if (element instanceof List) {
|
||||||
@ -180,7 +184,11 @@ public class GlobalGroups {
|
|||||||
throw new IllegalArgumentException("Unknown type of permission node for global group: " + groupName);
|
throw new IllegalArgumentException("Unknown type of permission node for global group: " + groupName);
|
||||||
|
|
||||||
// Info nodes
|
// Info nodes
|
||||||
|
try {
|
||||||
element = ((Map<String, Object>)allGroups.get(groupName)).get("info");
|
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 != null)
|
||||||
if (element instanceof MemorySection) {
|
if (element instanceof MemorySection) {
|
||||||
|
Loading…
Reference in New Issue
Block a user