mirror of
https://github.com/essentials/Essentials.git
synced 2025-09-14 00:12:06 +02:00
Compare commits
300 Commits
stable-2.7
...
precompone
Author | SHA1 | Date | |
---|---|---|---|
|
d06fc84e41 | ||
|
1cbb6f1617 | ||
|
0039f73fb3 | ||
|
a865c9ad01 | ||
|
8c5d4d83f1 | ||
|
53c9265800 | ||
|
9b25a25e91 | ||
|
a2fdf66de4 | ||
|
224e5f129e | ||
|
146599ae4b | ||
|
4203119e9a | ||
|
aefe79bbe7 | ||
|
5da1e9a220 | ||
|
a0df79cc06 | ||
|
32840e68f3 | ||
|
4da3f52164 | ||
|
cf7da7a83f | ||
|
f46948249e | ||
|
3b81593ebb | ||
|
514f07ce57 | ||
|
4f4d9f6209 | ||
|
3077ea4ef1 | ||
|
945ae71480 | ||
|
3d1c0fd157 | ||
|
fab9688abb | ||
|
b2dbb3f9e3 | ||
|
7633b136e3 | ||
|
0252d756f6 | ||
|
ad05516fd5 | ||
|
6d127012d8 | ||
|
c064da9af8 | ||
|
d05f2d7a32 | ||
|
3fc6bb4e4f | ||
|
59679e0423 | ||
|
f0c0ee1a8d | ||
|
3c98718387 | ||
|
cfdb2a36c1 | ||
|
3b7d194902 | ||
|
72d514d52f | ||
|
9fe119e720 | ||
|
4a5c431163 | ||
|
a6ac333a74 | ||
|
bc2578b788 | ||
|
effe0d5ec5 | ||
|
0ab2e745cf | ||
|
57a2ef08d4 | ||
|
2699e02f96 | ||
|
cae3c5a03e | ||
|
13206b3418 | ||
|
c713be8c82 | ||
|
62cd219b4e | ||
|
2d56de1483 | ||
|
bbc6da5106 | ||
|
b0d06ce6ed | ||
|
de1554cb68 | ||
|
c890ea8f87 | ||
|
c0517c1203 | ||
|
9efd0eb6f9 | ||
|
f0ee026fb9 | ||
|
b3fc790000 | ||
|
83f9209bcc | ||
|
691a0ef4ce | ||
|
a3c67e23c8 | ||
|
ffcdd99ad0 | ||
|
539700cb21 | ||
|
1078b7b5f2 | ||
|
f908eee76c | ||
|
b95c662ed5 | ||
|
97bd49e598 | ||
|
a60f280a1c | ||
|
e93e50f6d2 | ||
|
8ab5bad988 | ||
|
76ba5caeec | ||
|
86a1dda46c | ||
|
4326ce0d4a | ||
|
3ff1f4adbb | ||
|
492c4e8521 | ||
|
e3f3fe84ea | ||
|
6e2ac3b56e | ||
|
5c19e71858 | ||
|
a0103afde3 | ||
|
dbf30740fb | ||
|
92fa415848 | ||
|
2942ef40f3 | ||
|
3f02bcd702 | ||
|
fe050dd725 | ||
|
5b4966c888 | ||
|
8500542e93 | ||
|
2f1d9ad82c | ||
|
2c8aa20542 | ||
|
a2418a68d9 | ||
|
dff8f541fe | ||
|
d0a5656fa4 | ||
|
bc76e87366 | ||
|
bf9a67a2e4 | ||
|
95885e46c9 | ||
|
6a5fefb102 | ||
|
c47c008871 | ||
|
a31f5e219d | ||
|
9ee78bdaec | ||
|
735f9ce212 | ||
|
8f0350570e | ||
|
27365d1f1b | ||
|
ebb3a77430 | ||
|
b3252168f6 | ||
|
e1abdbdd37 | ||
|
3deff2afe7 | ||
|
8080abacd6 | ||
|
e960078e1a | ||
|
f4413633b8 | ||
|
5c44877c4c | ||
|
36d7907987 | ||
|
047f373631 | ||
|
c6aa34076a | ||
|
92f83dfe73 | ||
|
00057eaca4 | ||
|
2f96c9763f | ||
|
137b60c5f2 | ||
|
292b7b0546 | ||
|
d1d31e9769 | ||
|
f7c6759433 | ||
|
5137502646 | ||
|
9ff8b69282 | ||
|
7f269187c5 | ||
|
6d34a2aa17 | ||
|
9b58b2b9c0 | ||
|
8aa260ee34 | ||
|
25976edc2b | ||
|
8e9094a3ef | ||
|
b8944d0b25 | ||
|
69209eeb2f | ||
|
72ed86e0dd | ||
|
c689b55c4d | ||
|
746eb353a2 | ||
|
3708f2b3bb | ||
|
e563405a7d | ||
|
ae2cf3d95c | ||
|
324dd05c97 | ||
|
2a0c3eebbc | ||
|
e1660d47ba | ||
|
cbee61093e | ||
|
da3a6af92d | ||
|
df061749dd | ||
|
38a9327284 | ||
|
307c6c7bf0 | ||
|
593cb8d56e | ||
|
bdc695c85b | ||
|
8c54f37092 | ||
|
f40f5f880b | ||
|
8390594682 | ||
|
a13740f638 | ||
|
5f19cbf17b | ||
|
145b0be2f3 | ||
|
1dab4f95dd | ||
|
0ea41d9169 | ||
|
cc0e9aa84b | ||
|
6af054631f | ||
|
01a37df700 | ||
|
f93769dd1d | ||
|
125ea7c701 | ||
|
6e03ea7b7d | ||
|
9041596384 | ||
|
4b61ac9043 | ||
|
72edfacfb8 | ||
|
aa88205d95 | ||
|
8d441a4cc7 | ||
|
766935871f | ||
|
f5d65371b2 | ||
|
662749be8b | ||
|
e46fe381b4 | ||
|
04a43eb5d0 | ||
|
792f70efa5 | ||
|
46298ae858 | ||
|
d08b1a5089 | ||
|
e015cad131 | ||
|
008f0d595f | ||
|
7ee3919175 | ||
|
2560bdca4a | ||
|
16d537bd6c | ||
|
5f04d1867c | ||
|
a10f6850e5 | ||
|
36bc1adf83 | ||
|
cd8cc63113 | ||
|
947bee98a0 | ||
|
9c052b5178 | ||
|
f0dd81ee00 | ||
|
64af5b465d | ||
|
5c1d49fd0e | ||
|
79a13e97a2 | ||
|
27b0cc86de | ||
|
89c41b0508 | ||
|
ee88abafcf | ||
|
e7fd26ee64 | ||
|
8fc6684290 | ||
|
a1cf08d6ab | ||
|
42e9e105cb | ||
|
ec0d6651b0 | ||
|
a66ffd8921 | ||
|
1f2c669eca | ||
|
1d5a09a03e | ||
|
4435121c84 | ||
|
813e66b4f2 | ||
|
26d63f3666 | ||
|
0fb07d4cc1 | ||
|
cd2f819c29 | ||
|
149ce7d74d | ||
|
f26cccb663 | ||
|
81ec87d893 | ||
|
91563e9dca | ||
|
359ea194b8 | ||
|
1a0b03db4d | ||
|
c860b1c668 | ||
|
c584d74852 | ||
|
6e82419c15 | ||
|
3f6b9586b4 | ||
|
29d4e09983 | ||
|
f0def90301 | ||
|
d0e5685ac0 | ||
|
856cef3286 | ||
|
43f1c0f89d | ||
|
256d202d50 | ||
|
4884bed117 | ||
|
348bb6d0a3 | ||
|
3fdde2f764 | ||
|
390b17f0d8 | ||
|
fe9d5645f6 | ||
|
eb5c88ef08 | ||
|
6eea852b1d | ||
|
64904cdcfd | ||
|
69d57b04d9 | ||
|
768c92e5bf | ||
|
ef659d5f26 | ||
|
2a478fe03d | ||
|
703c5741bd | ||
|
d64c73fc51 | ||
|
92abba0f25 | ||
|
58057a771d | ||
|
cc3cd5e89c | ||
|
4c485f3147 | ||
|
3513d72a7b | ||
|
8432e1fc7d | ||
|
a46f6fd73d | ||
|
897571db7d | ||
|
de0a419476 | ||
|
6dd73f5247 | ||
|
a50cfb3efb | ||
|
bbcf2ecce3 | ||
|
86ea654a5d | ||
|
d2bbbd14fc | ||
|
a5398e938c | ||
|
7b01bc894d | ||
|
2678be90e3 | ||
|
781f42fba1 | ||
|
7726fd0081 | ||
|
481749b119 | ||
|
a552b88172 | ||
|
801562ac2c | ||
|
869d79ae73 | ||
|
7153676137 | ||
|
d2c1b24e4b | ||
|
b3de4276bc | ||
|
cb31939a7a | ||
|
41e0e64a5f | ||
|
a20e96af4e | ||
|
cedf363557 | ||
|
9a568992f1 | ||
|
283dc9b3c1 | ||
|
3aba996e97 | ||
|
9bb6d77bdb | ||
|
03171616fa | ||
|
69847af08a | ||
|
debcf4714a | ||
|
791e8f2d14 | ||
|
5d4f22ad84 | ||
|
31e80ba698 | ||
|
a2202439bb | ||
|
7c8c40c790 | ||
|
abd86347c7 | ||
|
5bb7d82fca | ||
|
afe8ecd3df | ||
|
244673e1fb | ||
|
de40f7f556 | ||
|
087a594449 | ||
|
c0b78cc3d5 | ||
|
ac77bbb0b4 | ||
|
b05e4079d9 | ||
|
556c990eff | ||
|
618f58c3f3 | ||
|
a7e71488c6 | ||
|
815a9dcca2 | ||
|
0155bcedb7 | ||
|
9ab2fe54fc | ||
|
0f1eb9b4f9 | ||
|
503e837cfd | ||
|
0a98b8f662 | ||
|
6e79302908 | ||
|
ecf72e27bb | ||
|
d1aea7dd35 | ||
|
b2a307ec23 | ||
|
f0dabdd4b1 |
7
.gitignore
vendored
7
.gitignore
vendored
@@ -38,3 +38,10 @@
|
||||
/WebPush/nbproject/private
|
||||
/.idea
|
||||
*.iml
|
||||
/EssentialsSigns/nbproject/private/
|
||||
/Essentials2Compat/nbproject/private/
|
||||
/Essentials2Compat/dist/
|
||||
/Essentials2Compat/build/
|
||||
/EssentialsGroupManager/bin
|
||||
/EssentialsGroupManager/.externalToolBuilders
|
||||
/EssentialsGeoIP/build
|
@@ -922,6 +922,14 @@ is divided into following sections:
|
||||
-->
|
||||
<target depends="init" if="have.sources" name="-javadoc-build">
|
||||
<mkdir dir="${dist.javadoc.dir}"/>
|
||||
<condition else="" property="javadoc.endorsed.classpath.cmd.line.arg" value="-J${endorsed.classpath.cmd.line.arg}">
|
||||
<and>
|
||||
<isset property="endorsed.classpath.cmd.line.arg"/>
|
||||
<not>
|
||||
<equals arg1="${endorsed.classpath.cmd.line.arg}" arg2=""/>
|
||||
</not>
|
||||
</and>
|
||||
</condition>
|
||||
<javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
|
||||
<classpath>
|
||||
<path path="${javac.classpath}"/>
|
||||
@@ -933,6 +941,7 @@ is divided into following sections:
|
||||
<include name="**/*.java"/>
|
||||
<exclude name="*.java"/>
|
||||
</fileset>
|
||||
<arg line="${javadoc.endorsed.classpath.cmd.line.arg}"/>
|
||||
</javadoc>
|
||||
<copy todir="${dist.javadoc.dir}">
|
||||
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
|
||||
|
@@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=28e38971@1.44.1.45
|
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||
nbproject/build-impl.xml.data.CRC32=51b33957
|
||||
nbproject/build-impl.xml.script.CRC32=c8376938
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=c12040a1@1.47.1.46
|
||||
nbproject/build-impl.xml.script.CRC32=c5170bed
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46
|
||||
|
@@ -873,6 +873,14 @@ is divided into following sections:
|
||||
-->
|
||||
<target depends="init" if="have.sources" name="-javadoc-build">
|
||||
<mkdir dir="${dist.javadoc.dir}"/>
|
||||
<condition else="" property="javadoc.endorsed.classpath.cmd.line.arg" value="-J${endorsed.classpath.cmd.line.arg}">
|
||||
<and>
|
||||
<isset property="endorsed.classpath.cmd.line.arg"/>
|
||||
<not>
|
||||
<equals arg1="${endorsed.classpath.cmd.line.arg}" arg2=""/>
|
||||
</not>
|
||||
</and>
|
||||
</condition>
|
||||
<javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
|
||||
<classpath>
|
||||
<path path="${javac.classpath}"/>
|
||||
@@ -884,6 +892,7 @@ is divided into following sections:
|
||||
<include name="**/*.java"/>
|
||||
<exclude name="*.java"/>
|
||||
</fileset>
|
||||
<arg line="${javadoc.endorsed.classpath.cmd.line.arg}"/>
|
||||
</javadoc>
|
||||
<copy todir="${dist.javadoc.dir}">
|
||||
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
|
||||
|
@@ -4,8 +4,8 @@ build.xml.stylesheet.CRC32=28e38971@1.38.2.45
|
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||
nbproject/build-impl.xml.data.CRC32=a830bc14
|
||||
nbproject/build-impl.xml.script.CRC32=40df7eaf
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=c12040a1@1.47.1.46
|
||||
nbproject/build-impl.xml.script.CRC32=a9f8842a
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46
|
||||
nbproject/profiler-build-impl.xml.data.CRC32=ab78ce15
|
||||
nbproject/profiler-build-impl.xml.script.CRC32=abda56ed
|
||||
nbproject/profiler-build-impl.xml.stylesheet.CRC32=f10cf54c@1.11.1
|
||||
|
@@ -66,16 +66,19 @@ endorsed.classpath=
|
||||
excludes=
|
||||
file.reference.BOSEconomy7.jar=../lib/BOSEconomy7.jar
|
||||
file.reference.bPermissions.jar=../lib/bPermissions.jar
|
||||
file.reference.bpermissions2.jar=../lib/bpermissions2.jar
|
||||
file.reference.bukkit.jar=../lib/bukkit.jar
|
||||
file.reference.craftbukkit.jar=../lib/craftbukkit.jar
|
||||
file.reference.iCo4.jar=../lib/iCo4.jar
|
||||
file.reference.iCo5.jar=../lib/iCo5.jar
|
||||
file.reference.iCo6.jar=../lib/iCo6.jar
|
||||
file.reference.lombok-0.10.1.jar=../lib/lombok-0.10.1.jar
|
||||
file.reference.lombok.jar=../lib/lombok-0.10.8.jar
|
||||
file.reference.MultiCurrency.jar=../lib/MultiCurrency.jar
|
||||
file.reference.Permissions3.jar=../lib/Permissions3.jar
|
||||
file.reference.PermissionsBukkit-1.2.jar=../lib/PermissionsBukkit-1.2.jar
|
||||
file.reference.PermissionsEx.jar=../lib/PermissionsEx.jar
|
||||
file.reference.Privileges.jar=..\\lib\\Privileges.jar
|
||||
file.reference.Vault.jar=../lib/Vault.jar
|
||||
includes=**
|
||||
jar.archive.disabled=${jnlp.enabled}
|
||||
jar.compress=true
|
||||
@@ -90,10 +93,13 @@ javac.classpath=\
|
||||
${file.reference.PermissionsEx.jar}:\
|
||||
${file.reference.bPermissions.jar}:\
|
||||
${file.reference.PermissionsBukkit-1.2.jar}:\
|
||||
${file.reference.lombok-0.10.1.jar}:\
|
||||
${file.reference.lombok.jar}:\
|
||||
${reference.EssentialsGroupManager.jar}:\
|
||||
${file.reference.bukkit.jar}:\
|
||||
${file.reference.craftbukkit.jar}
|
||||
${file.reference.craftbukkit.jar}:\
|
||||
${file.reference.Vault.jar}:\
|
||||
${file.reference.Privileges.jar}:\
|
||||
${file.reference.bpermissions2.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
@@ -118,7 +124,7 @@ javadoc.reference.PermissionsEx.jar=../lib/PermissionsEx-javadoc.jar
|
||||
javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
javadoc.windowtitle=Essentials Docs.
|
||||
jnlp.codebase.type=no.codebase
|
||||
jnlp.descriptor=application
|
||||
jnlp.enabled=false
|
||||
|
@@ -1,137 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.PluginCommandYamlParser;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public class AlternativeCommandsHandler
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private final transient Map<String, List<PluginCommand>> altcommands = new HashMap<String, List<PluginCommand>>();
|
||||
private final transient Map<String, String> disabledList = new HashMap<String, String>();
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public AlternativeCommandsHandler(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
for (Plugin plugin : ess.getServer().getPluginManager().getPlugins())
|
||||
{
|
||||
if (plugin.isEnabled())
|
||||
{
|
||||
addPlugin(plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final void addPlugin(final Plugin plugin)
|
||||
{
|
||||
if (plugin.getDescription().getMain().contains("com.earth2me.essentials"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final List<Command> commands = PluginCommandYamlParser.parse(plugin);
|
||||
final String pluginName = plugin.getDescription().getName().toLowerCase(Locale.ENGLISH);
|
||||
|
||||
for (Command command : commands)
|
||||
{
|
||||
final PluginCommand pc = (PluginCommand)command;
|
||||
final List<String> labels = new ArrayList<String>(pc.getAliases());
|
||||
labels.add(pc.getName());
|
||||
|
||||
PluginCommand reg = ess.getServer().getPluginCommand(pluginName + ":" + pc.getName().toLowerCase(Locale.ENGLISH));
|
||||
if (reg == null)
|
||||
{
|
||||
reg = ess.getServer().getPluginCommand(pc.getName().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
if (reg == null || !reg.getPlugin().equals(plugin))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (String label : labels)
|
||||
{
|
||||
List<PluginCommand> plugincommands = altcommands.get(label.toLowerCase(Locale.ENGLISH));
|
||||
if (plugincommands == null)
|
||||
{
|
||||
plugincommands = new ArrayList<PluginCommand>();
|
||||
altcommands.put(label.toLowerCase(Locale.ENGLISH), plugincommands);
|
||||
}
|
||||
boolean found = false;
|
||||
for (PluginCommand pc2 : plugincommands)
|
||||
{
|
||||
if (pc2.getPlugin().equals(plugin))
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
plugincommands.add(reg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removePlugin(final Plugin plugin)
|
||||
{
|
||||
final Iterator<Map.Entry<String, List<PluginCommand>>> iterator = altcommands.entrySet().iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
final Map.Entry<String, List<PluginCommand>> entry = iterator.next();
|
||||
final Iterator<PluginCommand> pcIterator = entry.getValue().iterator();
|
||||
while (pcIterator.hasNext())
|
||||
{
|
||||
final PluginCommand pc = pcIterator.next();
|
||||
if (pc.getPlugin() == null || pc.getPlugin().equals(plugin))
|
||||
{
|
||||
pcIterator.remove();
|
||||
}
|
||||
}
|
||||
if (entry.getValue().isEmpty())
|
||||
{
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PluginCommand getAlternative(final String label)
|
||||
{
|
||||
final List<PluginCommand> commands = altcommands.get(label);
|
||||
if (commands == null || commands.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (commands.size() == 1)
|
||||
{
|
||||
return commands.get(0);
|
||||
}
|
||||
// return the first command that is not an alias
|
||||
for (PluginCommand command : commands)
|
||||
{
|
||||
if (command.getName().equalsIgnoreCase(label))
|
||||
{
|
||||
return command;
|
||||
}
|
||||
}
|
||||
// return the first alias
|
||||
return commands.get(0);
|
||||
}
|
||||
|
||||
public void executed(final String label, final String otherLabel)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials: Alternative command " + label + " found, using " + otherLabel);
|
||||
}
|
||||
disabledList.put(label, otherLabel);
|
||||
}
|
||||
|
||||
public Map<String, String> disabledCommands()
|
||||
{
|
||||
return disabledList;
|
||||
}
|
||||
}
|
@@ -1,23 +1,29 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IBackup;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.ISettings;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Backup implements Runnable
|
||||
public class Backup implements Runnable, IBackup
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private static final Logger LOGGER = Bukkit.getLogger();
|
||||
private transient final Server server;
|
||||
private transient final IEssentials ess;
|
||||
private transient boolean running = false;
|
||||
private transient final AtomicBoolean running = new AtomicBoolean(false);
|
||||
private transient int taskId = -1;
|
||||
private transient boolean active = false;
|
||||
private transient final AtomicBoolean active = new AtomicBoolean(false);
|
||||
|
||||
public Backup(final IEssentials ess)
|
||||
{
|
||||
@@ -29,46 +35,57 @@ public class Backup implements Runnable
|
||||
}
|
||||
}
|
||||
|
||||
void onPlayerJoin()
|
||||
@Override
|
||||
public final void startTask()
|
||||
{
|
||||
startTask();
|
||||
}
|
||||
|
||||
private void startTask()
|
||||
if (running.compareAndSet(false, true))
|
||||
{
|
||||
if (!running)
|
||||
{
|
||||
final long interval = ess.getSettings().getBackupInterval() * 1200; // minutes -> ticks
|
||||
@Cleanup
|
||||
final ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
final long interval = settings.getData().getGeneral().getBackup().getInterval() * 1200; // minutes -> ticks
|
||||
if (interval < 1200)
|
||||
{
|
||||
running.set(false);
|
||||
return;
|
||||
}
|
||||
taskId = ess.scheduleSyncRepeatingTask(this, interval, interval);
|
||||
running = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (active)
|
||||
if (!active.compareAndSet(false, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
active = true;
|
||||
final String command = ess.getSettings().getBackupCommand();
|
||||
if (command == null || "".equals(command))
|
||||
@Cleanup
|
||||
final ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
final String command = settings.getData().getGeneral().getBackup().getCommand();
|
||||
if (command == null || command.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
LOGGER.log(Level.INFO, _("backupStarted"));
|
||||
final CommandSender cs = server.getConsoleSender();
|
||||
server.dispatchCommand(cs, "save-all");
|
||||
server.dispatchCommand(cs, "save-off");
|
||||
final CommandSender consoleSender = server.getConsoleSender();
|
||||
server.dispatchCommand(consoleSender, "save-all");
|
||||
server.dispatchCommand(consoleSender, "save-off");
|
||||
|
||||
ess.scheduleAsyncDelayedTask(
|
||||
new Runnable()
|
||||
ess.scheduleAsyncDelayedTask(new BackupRunner(command));
|
||||
}
|
||||
|
||||
|
||||
private class BackupRunner implements Runnable
|
||||
{
|
||||
private final transient String command;
|
||||
|
||||
public BackupRunner(final String command)
|
||||
{
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
@@ -108,27 +125,29 @@ public class Backup implements Runnable
|
||||
}
|
||||
finally
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable()
|
||||
ess.scheduleSyncDelayedTask(new EnableSavingRunner());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class EnableSavingRunner implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
server.dispatchCommand(cs, "save-on");
|
||||
server.dispatchCommand(server.getConsoleSender(), "save-on");
|
||||
if (server.getOnlinePlayers().length == 0)
|
||||
{
|
||||
running = false;
|
||||
running.set(false);
|
||||
if (taskId != -1)
|
||||
{
|
||||
server.getScheduler().cancelTask(taskId);
|
||||
}
|
||||
}
|
||||
active = false;
|
||||
|
||||
active.set(false);
|
||||
LOGGER.log(Level.INFO, _("backupFinished"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.api.IReplyTo;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
@@ -14,13 +14,8 @@ public final class Console implements IReplyTo
|
||||
{
|
||||
}
|
||||
|
||||
public static CommandSender getCommandSender(Server server) throws Exception
|
||||
{
|
||||
return server.getConsoleSender();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReplyTo(CommandSender user)
|
||||
public void setReplyTo(final CommandSender user)
|
||||
{
|
||||
replyTo = user;
|
||||
}
|
||||
|
@@ -16,9 +16,6 @@ import java.util.*;
|
||||
*/
|
||||
public final class DescParseTickFormat
|
||||
{
|
||||
// ============================================
|
||||
// First some information vars. TODO: Should this be in a config file?
|
||||
// --------------------------------------------
|
||||
public static final Map<String, Integer> nameToTicks = new LinkedHashMap<String, Integer>();
|
||||
public static final Set<String> resetAliases = new HashSet<String>();
|
||||
public static final int ticksAtMidnight = 18000;
|
||||
|
207
Essentials/src/com/earth2me/essentials/Economy.java
Normal file
207
Essentials/src/com/earth2me/essentials/Economy.java
Normal file
@@ -0,0 +1,207 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.*;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import com.earth2me.essentials.settings.MoneyHolder;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class Economy implements IEconomy
|
||||
{
|
||||
private final IEssentials ess;
|
||||
private final MoneyHolder npcs;
|
||||
|
||||
public Economy(IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
this.npcs = new MoneyHolder(ess);
|
||||
}
|
||||
|
||||
private double getNPCBalance(String name) throws UserDoesNotExistException
|
||||
{
|
||||
npcs.acquireReadLock();
|
||||
try
|
||||
{
|
||||
Map<String, Double> balances = npcs.getData().getBalances();
|
||||
if (balances == null)
|
||||
{
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
Double balance = npcs.getData().getBalances().get(name.toLowerCase(Locale.ENGLISH));
|
||||
if (balance == null)
|
||||
{
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
return balance;
|
||||
}
|
||||
finally
|
||||
{
|
||||
npcs.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private void setNPCBalance(String name, double balance, boolean checkExistance) throws UserDoesNotExistException
|
||||
{
|
||||
npcs.acquireWriteLock();
|
||||
try
|
||||
{
|
||||
Map<String, Double> balances = npcs.getData().getBalances();
|
||||
if (balances == null)
|
||||
{
|
||||
balances = new HashMap<String, Double>();
|
||||
npcs.getData().setBalances(balances);
|
||||
}
|
||||
if (checkExistance && !balances.containsKey(name.toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
balances.put(name.toLowerCase(Locale.ENGLISH), balance);
|
||||
}
|
||||
finally
|
||||
{
|
||||
npcs.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private double getStartingBalance()
|
||||
{
|
||||
double startingBalance = 0;
|
||||
ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
try
|
||||
{
|
||||
startingBalance = settings.getData().getEconomy().getStartingBalance();
|
||||
}
|
||||
finally
|
||||
{
|
||||
settings.unlock();
|
||||
}
|
||||
return startingBalance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReload()
|
||||
{
|
||||
this.npcs.onReload(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMoney(String name) throws UserDoesNotExistException
|
||||
{
|
||||
IUser user = ess.getUser(name);
|
||||
if (user == null)
|
||||
{
|
||||
return getNPCBalance(name);
|
||||
}
|
||||
return user.getMoney();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMoney(String name, double balance) throws NoLoanPermittedException, UserDoesNotExistException
|
||||
{
|
||||
IUser user = ess.getUser(name);
|
||||
if (user == null)
|
||||
{
|
||||
setNPCBalance(name, balance, true);
|
||||
return;
|
||||
}
|
||||
if (balance < 0.0 && !Permissions.ECO_LOAN.isAuthorized(user))
|
||||
{
|
||||
throw new NoLoanPermittedException();
|
||||
}
|
||||
user.setMoney(balance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetBalance(String name) throws NoLoanPermittedException, UserDoesNotExistException
|
||||
{
|
||||
setMoney(name, getStartingBalance());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount)
|
||||
{
|
||||
return Util.formatCurrency(amount, ess);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerExists(String name)
|
||||
{
|
||||
try
|
||||
{
|
||||
getMoney(name);
|
||||
return true;
|
||||
}
|
||||
catch (UserDoesNotExistException ex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNPC(String name) throws UserDoesNotExistException
|
||||
{
|
||||
boolean result = ess.getUser(name) == null;
|
||||
if (result)
|
||||
{
|
||||
getNPCBalance(name);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createNPC(String name)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (isNPC(name))
|
||||
{
|
||||
|
||||
setNPCBalance(name, getStartingBalance(), false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (UserDoesNotExistException ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
setNPCBalance(name, getStartingBalance(), false);
|
||||
return true;
|
||||
}
|
||||
catch (UserDoesNotExistException ex1)
|
||||
{
|
||||
//This should never happen!
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNPC(String name) throws UserDoesNotExistException
|
||||
{
|
||||
npcs.acquireWriteLock();
|
||||
try
|
||||
{
|
||||
Map<String, Double> balances = npcs.getData().getBalances();
|
||||
if (balances == null)
|
||||
{
|
||||
balances = new HashMap<String, Double>();
|
||||
npcs.getData().setBalances(balances);
|
||||
}
|
||||
if (balances.containsKey(name.toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
balances.remove(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
npcs.unlock();
|
||||
}
|
||||
}
|
||||
}
|
@@ -9,8 +9,13 @@ import java.util.regex.Pattern;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
||||
|
||||
public class Enchantments
|
||||
public final class Enchantments
|
||||
{
|
||||
|
||||
private Enchantments()
|
||||
{
|
||||
}
|
||||
|
||||
private static final transient Pattern NUMPATTERN = Pattern.compile("\\d+");
|
||||
private static final Map<String, Enchantment> ENCHANTMENTS = new HashMap<String, Enchantment>();
|
||||
|
||||
@@ -54,9 +59,15 @@ public class Enchantments
|
||||
ENCHANTMENTS.put("silktouch", Enchantment.SILK_TOUCH);
|
||||
ENCHANTMENTS.put("waterworker", Enchantment.WATER_WORKER);
|
||||
ENCHANTMENTS.put("aquaaffinity", Enchantment.WATER_WORKER);
|
||||
ENCHANTMENTS.put("firearrow", Enchantment.ARROW_FIRE);
|
||||
ENCHANTMENTS.put("arrowdamage", Enchantment.ARROW_DAMAGE);
|
||||
ENCHANTMENTS.put("arrowknockback", Enchantment.ARROW_KNOCKBACK);
|
||||
ENCHANTMENTS.put("arrowkb", Enchantment.ARROW_KNOCKBACK);
|
||||
ENCHANTMENTS.put("infinitearrows", Enchantment.ARROW_INFINITE);
|
||||
ENCHANTMENTS.put("infarrows", Enchantment.ARROW_INFINITE);
|
||||
}
|
||||
|
||||
public static Enchantment getByName(String name) {
|
||||
public static Enchantment getByName(final String name) {
|
||||
Enchantment enchantment;
|
||||
if (NUMPATTERN.matcher(name).matches()) {
|
||||
enchantment = Enchantment.getById(Integer.parseInt(name));
|
||||
|
@@ -18,25 +18,18 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.Economy;
|
||||
import com.earth2me.essentials.api.IJails;
|
||||
import com.earth2me.essentials.commands.EssentialsCommand;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.commands.NoChargeException;
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
import com.earth2me.essentials.craftbukkit.ItemDupeFix;
|
||||
import com.earth2me.essentials.perm.PermissionsHandler;
|
||||
import com.earth2me.essentials.api.*;
|
||||
import com.earth2me.essentials.listener.*;
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import com.earth2me.essentials.signs.SignBlockListener;
|
||||
import com.earth2me.essentials.signs.SignEntityListener;
|
||||
import com.earth2me.essentials.signs.SignPlayerListener;
|
||||
import com.earth2me.essentials.settings.GroupsHolder;
|
||||
import com.earth2me.essentials.settings.SettingsHolder;
|
||||
import com.earth2me.essentials.user.UserMap;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -44,39 +37,41 @@ import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.plugin.InvalidDescriptionException;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.yaml.snakeyaml.error.YAMLException;
|
||||
|
||||
|
||||
public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
public static final int BUKKIT_VERSION = 1597;
|
||||
public static final int BUKKIT_VERSION = 1952;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient ISettings settings;
|
||||
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);
|
||||
private transient Jails jails;
|
||||
private transient Warps warps;
|
||||
private transient Worth worth;
|
||||
private transient List<IConf> confList;
|
||||
private transient Backup backup;
|
||||
private transient ItemDb itemDb;
|
||||
private final transient TntExplodeListener tntListener = new TntExplodeListener(this);
|
||||
private transient IJails jails;
|
||||
private transient IKits kits;
|
||||
private transient IWarps warps;
|
||||
private transient IWorth worth;
|
||||
private transient List<IReload> reloadList;
|
||||
private transient IBackup backup;
|
||||
private transient IItemDb itemDb;
|
||||
private transient IGroups groups;
|
||||
private transient final Methods paymentMethod = new Methods();
|
||||
private transient PermissionsHandler permissionsHandler;
|
||||
private transient AlternativeCommandsHandler alternativeCommandsHandler;
|
||||
private transient UserMap userMap;
|
||||
//private transient PermissionsHandler permissionsHandler;
|
||||
private transient IUserMap userMap;
|
||||
private transient ExecuteTimer execTimer;
|
||||
private transient I18n i18n;
|
||||
private transient ICommandHandler commandHandler;
|
||||
private transient Economy economy;
|
||||
public transient boolean testing;
|
||||
|
||||
@Override
|
||||
public ISettings getSettings()
|
||||
@@ -86,6 +81,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
|
||||
public void setupForTesting(final Server server) throws IOException, InvalidDescriptionException
|
||||
{
|
||||
testing = true;
|
||||
final File dataFolder = File.createTempFile("essentialstest", "");
|
||||
if (!dataFolder.delete())
|
||||
{
|
||||
@@ -100,11 +96,11 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
LOGGER.log(Level.INFO, _("usingTempFolderForTesting"));
|
||||
LOGGER.log(Level.INFO, dataFolder.toString());
|
||||
this.initialize(null, server, new PluginDescriptionFile(new FileReader(new File("src" + File.separator + "plugin.yml"))), dataFolder, null, null);
|
||||
settings = new Settings(this);
|
||||
settings = new SettingsHolder(this);
|
||||
i18n.updateLocale("en");
|
||||
userMap = new UserMap(this);
|
||||
permissionsHandler = new PermissionsHandler(this, false);
|
||||
Economy.setEss(this);
|
||||
//permissionsHandler = new PermissionsHandler(this);
|
||||
economy = new Economy(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -124,7 +120,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
LOGGER.log(Level.WARNING, _("versionMismatch", plugin.getDescription().getName()));
|
||||
}
|
||||
}
|
||||
final Matcher versionMatch = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-R[0-9]+-b([0-9]+)jnks.*").matcher(getServer().getVersion());
|
||||
final Matcher versionMatch = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-R[0-9]+-(?:[0-9]+-g[0-9a-f]+-)?b([0-9]+)jnks.*").matcher(getServer().getVersion());
|
||||
if (versionMatch.matches())
|
||||
{
|
||||
final int versionNumber = Integer.parseInt(versionMatch.group(4));
|
||||
@@ -145,27 +141,35 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
execTimer.mark("BukkitCheck");
|
||||
try
|
||||
{
|
||||
final EssentialsUpgrade upgrade = new EssentialsUpgrade(this);
|
||||
upgrade.beforeSettings();
|
||||
execTimer.mark("Upgrade");
|
||||
confList = new ArrayList<IConf>();
|
||||
settings = new Settings(this);
|
||||
confList.add(settings);
|
||||
//final EssentialsUpgrade upgrade = new EssentialsUpgrade(this);
|
||||
//upgrade.beforeSettings();
|
||||
//execTimer.mark("Upgrade");
|
||||
reloadList = new ArrayList<IReload>();
|
||||
settings = new SettingsHolder(this);
|
||||
reloadList.add(settings);
|
||||
execTimer.mark("Settings");
|
||||
upgrade.afterSettings();
|
||||
execTimer.mark("Upgrade2");
|
||||
//upgrade.afterSettings();
|
||||
//execTimer.mark("Upgrade2");
|
||||
i18n.updateLocale(settings.getLocale());
|
||||
userMap = new UserMap(this);
|
||||
confList.add(userMap);
|
||||
reloadList.add(userMap);
|
||||
execTimer.mark("Init(Usermap)");
|
||||
warps = new Warps(getServer(), this.getDataFolder());
|
||||
confList.add(warps);
|
||||
groups = new GroupsHolder(this);
|
||||
reloadList.add((GroupsHolder)groups);
|
||||
warps = new Warps(this);
|
||||
reloadList.add(warps);
|
||||
execTimer.mark("Init(Spawn/Warp)");
|
||||
worth = new Worth(this.getDataFolder());
|
||||
confList.add(worth);
|
||||
worth = new Worth(this);
|
||||
reloadList.add(worth);
|
||||
itemDb = new ItemDb(this);
|
||||
confList.add(itemDb);
|
||||
reloadList.add(itemDb);
|
||||
execTimer.mark("Init(Worth/ItemDB)");
|
||||
kits = new Kits(this);
|
||||
reloadList.add(kits);
|
||||
commandHandler = new EssentialsCommandHandler(Essentials.class.getClassLoader(), "com.earth2me.essentials.commands.Command", "essentials.", this);
|
||||
reloadList.add(commandHandler);
|
||||
economy = new Economy(this);
|
||||
reloadList.add(economy);
|
||||
reload();
|
||||
}
|
||||
catch (YAMLException exception)
|
||||
@@ -179,14 +183,14 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
LOGGER.log(Level.SEVERE, _("essentialsHelp1"));
|
||||
}
|
||||
LOGGER.log(Level.SEVERE, exception.toString());
|
||||
pm.registerEvent(Type.PLAYER_JOIN, new PlayerListener()
|
||||
pm.registerEvents(new Listener()
|
||||
{
|
||||
@Override
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||
{
|
||||
event.getPlayer().sendMessage("Essentials failed to load, read the log file.");
|
||||
}
|
||||
}, Priority.Low, this);
|
||||
}, this);
|
||||
for (Player player : getServer().getOnlinePlayers())
|
||||
{
|
||||
player.sendMessage("Essentials failed to load, read the log file.");
|
||||
@@ -195,70 +199,33 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
return;
|
||||
}
|
||||
backup = new Backup(this);
|
||||
permissionsHandler = new PermissionsHandler(this, settings.useBukkitPermissions());
|
||||
alternativeCommandsHandler = new AlternativeCommandsHandler(this);
|
||||
//permissionsHandler = new PermissionsHandler(this);
|
||||
final EssentialsPluginListener serverListener = new EssentialsPluginListener(this);
|
||||
pm.registerEvent(Type.PLUGIN_ENABLE, serverListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.PLUGIN_DISABLE, serverListener, Priority.Low, this);
|
||||
confList.add(serverListener);
|
||||
pm.registerEvents(serverListener, this);
|
||||
reloadList.add(serverListener);
|
||||
|
||||
final EssentialsPlayerListener playerListener = new EssentialsPlayerListener(this);
|
||||
pm.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Monitor, this);
|
||||
pm.registerEvent(Type.PLAYER_QUIT, playerListener, Priority.Monitor, this);
|
||||
pm.registerEvent(Type.PLAYER_CHAT, playerListener, Priority.Lowest, this);
|
||||
pm.registerEvent(Type.PLAYER_COMMAND_PREPROCESS, playerListener, Priority.Lowest, this);
|
||||
pm.registerEvent(Type.PLAYER_MOVE, playerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_LOGIN, playerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_TELEPORT, playerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_EGG_THROW, playerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_BUCKET_EMPTY, playerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_ANIMATION, playerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_CHANGED_WORLD, playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Type.PLAYER_INTERACT, playerListener, Priority.Monitor, this);
|
||||
pm.registerEvent(Type.PLAYER_PICKUP_ITEM, playerListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.PLAYER_TELEPORT, new ItemDupeFix(), Priority.Monitor, this);
|
||||
pm.registerEvents(playerListener, this);
|
||||
|
||||
final EssentialsBlockListener blockListener = new EssentialsBlockListener(this);
|
||||
pm.registerEvent(Type.BLOCK_PLACE, blockListener, Priority.Lowest, this);
|
||||
|
||||
final SignBlockListener signBlockListener = new SignBlockListener(this);
|
||||
pm.registerEvent(Type.SIGN_CHANGE, signBlockListener, Priority.Highest, this);
|
||||
pm.registerEvent(Type.BLOCK_PLACE, signBlockListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.BLOCK_BREAK, signBlockListener, Priority.Highest, this);
|
||||
pm.registerEvent(Type.BLOCK_IGNITE, signBlockListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.BLOCK_BURN, signBlockListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.BLOCK_PISTON_EXTEND, signBlockListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.BLOCK_PISTON_RETRACT, signBlockListener, Priority.Low, this);
|
||||
|
||||
final SignPlayerListener signPlayerListener = new SignPlayerListener(this);
|
||||
pm.registerEvent(Type.PLAYER_INTERACT, signPlayerListener, Priority.Low, this);
|
||||
|
||||
final SignEntityListener signEntityListener = new SignEntityListener(this);
|
||||
pm.registerEvent(Type.ENTITY_EXPLODE, signEntityListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.ENDERMAN_PICKUP, signEntityListener, Priority.Low, this);
|
||||
pm.registerEvents(blockListener, this);
|
||||
|
||||
final EssentialsEntityListener entityListener = new EssentialsEntityListener(this);
|
||||
pm.registerEvent(Type.ENTITY_DAMAGE, entityListener, Priority.Lowest, this);
|
||||
pm.registerEvent(Type.ENTITY_COMBUST, entityListener, Priority.Lowest, this);
|
||||
pm.registerEvent(Type.ENTITY_DEATH, entityListener, Priority.Lowest, this);
|
||||
pm.registerEvent(Type.ENTITY_REGAIN_HEALTH, entityListener, Priority.Lowest, this);
|
||||
pm.registerEvent(Type.FOOD_LEVEL_CHANGE, entityListener, Priority.Lowest, this);
|
||||
pm.registerEvents(entityListener, this);
|
||||
|
||||
//TODO: Check if this should be here, and not above before reload()
|
||||
jails = new Jails(this);
|
||||
confList.add(jails);
|
||||
reloadList.add(jails);
|
||||
|
||||
pm.registerEvents(tntListener, this);
|
||||
|
||||
pm.registerEvent(Type.ENTITY_EXPLODE, tntListener, Priority.High, this);
|
||||
|
||||
final EssentialsTimer timer = new EssentialsTimer(this);
|
||||
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 100);
|
||||
Economy.setEss(this);
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 100);
|
||||
execTimer.mark("RegListeners");
|
||||
LOGGER.info(_("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), Util.joinList(this.getDescription().getAuthors())));
|
||||
final String timeroutput = execTimer.end();
|
||||
if (getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials load " + timeroutput);
|
||||
LOGGER.log(Level.INFO, "Essentials load {0}", timeroutput);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,7 +233,6 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
public void onDisable()
|
||||
{
|
||||
i18n.onDisable();
|
||||
Economy.setEss(null);
|
||||
Trade.closeLog();
|
||||
}
|
||||
|
||||
@@ -275,10 +241,10 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
Trade.closeLog();
|
||||
|
||||
for (IConf iConf : confList)
|
||||
for (IReload iReload : reloadList)
|
||||
{
|
||||
iConf.reloadConfig();
|
||||
execTimer.mark("Reload(" + iConf.getClass().getSimpleName() + ")");
|
||||
iReload.onReload();
|
||||
execTimer.mark("Reload(" + iReload.getClass().getSimpleName() + ")");
|
||||
}
|
||||
|
||||
i18n.updateLocale(settings.getLocale());
|
||||
@@ -287,124 +253,8 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
@Override
|
||||
public boolean onCommand(final CommandSender sender, final Command command, final String commandLabel, final String[] args)
|
||||
{
|
||||
return onCommandEssentials(sender, command, commandLabel, args, Essentials.class.getClassLoader(), "com.earth2me.essentials.commands.Command", "essentials.", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommandEssentials(final CommandSender sender, final Command command, final String commandLabel, final String[] args, final ClassLoader classLoader, final String commandPath, final String permissionPrefix, final IEssentialsModule module)
|
||||
{
|
||||
// Allow plugins to override the command via onCommand
|
||||
if (!getSettings().isCommandOverridden(command.getName()) && (!commandLabel.startsWith("e") || commandLabel.equalsIgnoreCase(command.getName())))
|
||||
{
|
||||
final PluginCommand pc = alternativeCommandsHandler.getAlternative(commandLabel);
|
||||
if (pc != null)
|
||||
{
|
||||
alternativeCommandsHandler.executed(commandLabel, pc.getLabel());
|
||||
return pc.execute(sender, commandLabel, args);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
User user = null;
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
user = getUser(sender);
|
||||
LOGGER.log(Level.INFO, String.format("[PLAYER_COMMAND] %s: /%s %s ", ((Player)sender).getName(), commandLabel, EssentialsCommand.getFinalArg(args, 0)));
|
||||
}
|
||||
|
||||
// New mail notification
|
||||
if (user != null && !getSettings().isCommandDisabled("mail") && !commandLabel.equals("mail") && user.isAuthorized("essentials.mail"))
|
||||
{
|
||||
final List<String> mail = user.getMails();
|
||||
if (mail != null && !mail.isEmpty())
|
||||
{
|
||||
user.sendMessage(_("youHaveNewMail", mail.size()));
|
||||
}
|
||||
}
|
||||
|
||||
// Check for disabled commands
|
||||
if (getSettings().isCommandDisabled(commandLabel))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
IEssentialsCommand cmd;
|
||||
try
|
||||
{
|
||||
cmd = (IEssentialsCommand)classLoader.loadClass(commandPath + command.getName()).newInstance();
|
||||
cmd.setEssentials(this);
|
||||
cmd.setEssentialsModule(module);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
sender.sendMessage(_("commandNotLoaded", commandLabel));
|
||||
LOGGER.log(Level.SEVERE, _("commandNotLoaded", commandLabel), ex);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check authorization
|
||||
if (user != null && !user.isAuthorized(cmd, permissionPrefix))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("deniedAccessCommand", user.getName()));
|
||||
user.sendMessage(_("noAccessCommand"));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Run the command
|
||||
try
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
cmd.run(getServer(), sender, commandLabel, command, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.run(getServer(), user, commandLabel, command, args);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (NoChargeException ex)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
catch (NotEnoughArgumentsException ex)
|
||||
{
|
||||
sender.sendMessage(command.getDescription());
|
||||
sender.sendMessage(command.getUsage().replaceAll("<command>", commandLabel));
|
||||
if (!ex.getMessage().isEmpty())
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
showError(sender, ex, commandLabel);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, _("commandFailed", commandLabel), ex);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showError(final CommandSender sender, final Throwable exception, final String commandLabel)
|
||||
{
|
||||
sender.sendMessage(_("errorWithMessage", exception.getMessage()));
|
||||
if (getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("errorCallingCommand", commandLabel), exception);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BukkitScheduler getScheduler()
|
||||
{
|
||||
return this.getServer().getScheduler();
|
||||
return commandHandler.handleCommand(sender, command, commandLabel, args);
|
||||
//return onCommandEssentials(sender, command, commandLabel, args, Essentials.class.getClassLoader(), "com.earth2me.essentials.commands.Command", "essentials.", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -414,65 +264,39 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
|
||||
@Override
|
||||
public Warps getWarps()
|
||||
public IKits getKits()
|
||||
{
|
||||
return kits;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWarps getWarps()
|
||||
{
|
||||
return warps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Worth getWorth()
|
||||
public IWorth getWorth()
|
||||
{
|
||||
return worth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Backup getBackup()
|
||||
public IBackup getBackup()
|
||||
{
|
||||
return backup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getUser(final Object base)
|
||||
public IUser getUser(final Player player)
|
||||
{
|
||||
if (base instanceof Player)
|
||||
{
|
||||
return getUser((Player)base);
|
||||
}
|
||||
if (base instanceof String)
|
||||
{
|
||||
return userMap.getUser((String)base);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private <T extends Player> User getUser(final T base)
|
||||
{
|
||||
if (base == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (base instanceof User)
|
||||
{
|
||||
return (User)base;
|
||||
}
|
||||
User user = userMap.getUser(base.getName());
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
user = new User(base, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
user.update(base);
|
||||
}
|
||||
return user;
|
||||
return userMap.getUser(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getOfflineUser(final String name)
|
||||
public IUser getUser(final String playerName)
|
||||
{
|
||||
return userMap.getUser(name);
|
||||
return userMap.getUser(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -490,9 +314,9 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addReloadListener(final IConf listener)
|
||||
public void addReloadListener(final IReload listener)
|
||||
{
|
||||
confList.add(listener);
|
||||
reloadList.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -516,8 +340,8 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
|
||||
for (Player player : players)
|
||||
{
|
||||
final User user = getUser(player);
|
||||
if (!user.isIgnoredPlayer(sender.getName()))
|
||||
final IUser user = getUser(player);
|
||||
if (!user.isIgnoringPlayer(sender.getName()))
|
||||
{
|
||||
player.sendMessage(message);
|
||||
}
|
||||
@@ -529,53 +353,47 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
@Override
|
||||
public int scheduleAsyncDelayedTask(final Runnable run)
|
||||
{
|
||||
return this.getScheduler().scheduleAsyncDelayedTask(this, run);
|
||||
return this.getServer().getScheduler().scheduleAsyncDelayedTask(this, run);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleSyncDelayedTask(final Runnable run)
|
||||
{
|
||||
return this.getScheduler().scheduleSyncDelayedTask(this, run);
|
||||
return this.getServer().getScheduler().scheduleSyncDelayedTask(this, run);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleSyncDelayedTask(final Runnable run, final long delay)
|
||||
{
|
||||
return this.getScheduler().scheduleSyncDelayedTask(this, run, delay);
|
||||
return this.getServer().getScheduler().scheduleSyncDelayedTask(this, run, delay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleSyncRepeatingTask(final Runnable run, final long delay, final long period)
|
||||
{
|
||||
return this.getScheduler().scheduleSyncRepeatingTask(this, run, delay, period);
|
||||
return this.getServer().getScheduler().scheduleSyncRepeatingTask(this, run, delay, period);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TNTExplodeListener getTNTListener()
|
||||
public TntExplodeListener getTNTListener()
|
||||
{
|
||||
return tntListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
/*@Override
|
||||
public PermissionsHandler getPermissionsHandler()
|
||||
{
|
||||
return permissionsHandler;
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public AlternativeCommandsHandler getAlternativeCommandsHandler()
|
||||
{
|
||||
return alternativeCommandsHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemDb getItemDb()
|
||||
public IItemDb getItemDb()
|
||||
{
|
||||
return itemDb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserMap getUserMap()
|
||||
public IUserMap getUserMap()
|
||||
{
|
||||
return userMap;
|
||||
}
|
||||
@@ -585,4 +403,34 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
return i18n;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGroups getGroups()
|
||||
{
|
||||
return groups;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICommandHandler getCommandHandler()
|
||||
{
|
||||
return commandHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroups(final IGroups groups)
|
||||
{
|
||||
this.groups = groups;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeReloadListener(IReload groups)
|
||||
{
|
||||
this.reloadList.remove(groups);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEconomy getEconomy()
|
||||
{
|
||||
return economy;
|
||||
}
|
||||
}
|
||||
|
@@ -1,51 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class EssentialsBlockListener extends BlockListener
|
||||
{
|
||||
private final IEssentials ess;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
public EssentialsBlockListener(IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
// Do not rely on getItemInHand();
|
||||
// http://leaky.bukkit.org/issues/663
|
||||
final ItemStack is = Util.convertBlockToItem(event.getBlockPlaced());
|
||||
if (is == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
boolean unlimitedForUser = user.hasUnlimited(is);
|
||||
if (unlimitedForUser && user.getGameMode() == GameMode.SURVIVAL)
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
user.getInventory().addItem(is);
|
||||
user.updateInventory();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,316 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.*;
|
||||
import com.earth2me.essentials.commands.EssentialsCommand;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.commands.NoChargeException;
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.PluginCommandYamlParser;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public class EssentialsCommandHandler implements ICommandHandler
|
||||
{
|
||||
private final transient ClassLoader classLoader;
|
||||
private final transient String commandPath;
|
||||
private final transient String permissionPrefix;
|
||||
private final transient IEssentialsModule module;
|
||||
private static final transient Logger LOGGER = Bukkit.getLogger();
|
||||
private final transient Map<String, List<PluginCommand>> altcommands = new HashMap<String, List<PluginCommand>>();
|
||||
private final transient Map<String, String> disabledList = new HashMap<String, String>();
|
||||
private final transient Map<String, IEssentialsCommand> commands = new HashMap<String, IEssentialsCommand>();
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public EssentialsCommandHandler(ClassLoader classLoader, String commandPath, String permissionPrefix, IEssentials ess)
|
||||
{
|
||||
this(classLoader, commandPath, permissionPrefix, null, ess);
|
||||
}
|
||||
|
||||
public EssentialsCommandHandler(ClassLoader classLoader, String commandPath, String permissionPrefix, IEssentialsModule module, IEssentials ess)
|
||||
{
|
||||
this.classLoader = classLoader;
|
||||
this.commandPath = commandPath;
|
||||
this.permissionPrefix = permissionPrefix;
|
||||
this.module = module;
|
||||
this.ess = ess;
|
||||
for (Plugin plugin : ess.getServer().getPluginManager().getPlugins())
|
||||
{
|
||||
if (plugin.isEnabled())
|
||||
{
|
||||
addPlugin(plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleCommand(final CommandSender sender, final Command command, final String commandLabel, final String[] args)
|
||||
{
|
||||
boolean disabled = false;
|
||||
boolean overridden = false;
|
||||
ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
try
|
||||
{
|
||||
disabled = settings.getData().getCommands().isDisabled(command.getName());
|
||||
overridden = !disabled || settings.getData().getCommands().isOverridden(command.getName());
|
||||
}
|
||||
finally
|
||||
{
|
||||
settings.unlock();
|
||||
}
|
||||
// Allow plugins to override the command via onCommand
|
||||
if (!overridden && (!commandLabel.startsWith("e") || commandLabel.equalsIgnoreCase(command.getName())))
|
||||
{
|
||||
final PluginCommand pc = getAlternative(commandLabel);
|
||||
if (pc != null)
|
||||
{
|
||||
|
||||
executed(commandLabel, pc.getLabel());
|
||||
try
|
||||
{
|
||||
return pc.execute(sender, commandLabel, args);
|
||||
}
|
||||
catch (final Exception ex)
|
||||
{
|
||||
final ArrayList<StackTraceElement> elements = new ArrayList<StackTraceElement>(Arrays.asList(ex.getStackTrace()));
|
||||
elements.remove(0);
|
||||
final ArrayList<StackTraceElement> toRemove = new ArrayList<StackTraceElement>();
|
||||
for (final StackTraceElement e : elements)
|
||||
{
|
||||
if (e.getClassName().equals("com.earth2me.essentials.Essentials"))
|
||||
{
|
||||
toRemove.add(e);
|
||||
}
|
||||
}
|
||||
elements.removeAll(toRemove);
|
||||
final StackTraceElement[] trace = elements.toArray(new StackTraceElement[elements.size()]);
|
||||
ex.setStackTrace(trace);
|
||||
ex.printStackTrace();
|
||||
sender.sendMessage(ChatColor.RED + "An internal error occurred while attempting to perform this command");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
IUser user = null;
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
user = ess.getUser((Player)sender);
|
||||
LOGGER.log(Level.INFO, String.format("[PLAYER_COMMAND] %s: /%s %s ", ((Player)sender).getName(), commandLabel, EssentialsCommand.getFinalArg(args, 0)));
|
||||
}
|
||||
|
||||
// Check for disabled commands
|
||||
if (disabled)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
final String commandName = command.getName().toLowerCase(Locale.ENGLISH);
|
||||
IEssentialsCommand cmd = commands.get(commandName);
|
||||
if (cmd == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd = (IEssentialsCommand)classLoader.loadClass(commandPath + commandName).newInstance();
|
||||
cmd.init(ess, commandName);
|
||||
cmd.setEssentialsModule(module);
|
||||
commands.put(commandName, cmd);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
sender.sendMessage(_("commandNotLoaded", commandName));
|
||||
LOGGER.log(Level.SEVERE, _("commandNotLoaded", commandName), ex);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check authorization
|
||||
if (sender != null && cmd.isAuthorized(sender))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("deniedAccessCommand", user.getName()));
|
||||
user.sendMessage(_("noAccessCommand"));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Run the command
|
||||
try
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
cmd.run(sender, command, commandLabel, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
user.acquireReadLock();
|
||||
try
|
||||
{
|
||||
cmd.run(user, command, commandLabel, args);
|
||||
}
|
||||
finally
|
||||
{
|
||||
user.unlock();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (NoChargeException ex)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
catch (NotEnoughArgumentsException ex)
|
||||
{
|
||||
sender.sendMessage(command.getDescription());
|
||||
sender.sendMessage(command.getUsage().replaceAll("<command>", commandLabel));
|
||||
if (!ex.getMessage().isEmpty())
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
showCommandError(sender, commandLabel, ex);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, _("commandFailed", commandLabel), ex);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showCommandError(final CommandSender sender, final String commandLabel, final Throwable exception)
|
||||
{
|
||||
sender.sendMessage(_("errorWithMessage", exception.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("errorCallingCommand", commandLabel), exception);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReload()
|
||||
{
|
||||
}
|
||||
|
||||
public final void addPlugin(final Plugin plugin)
|
||||
{
|
||||
if (plugin.getDescription().getMain().contains("com.earth2me.essentials"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final List<Command> commands = PluginCommandYamlParser.parse(plugin);
|
||||
final String pluginName = plugin.getDescription().getName().toLowerCase(Locale.ENGLISH);
|
||||
|
||||
for (Command command : commands)
|
||||
{
|
||||
final PluginCommand pc = (PluginCommand)command;
|
||||
final List<String> labels = new ArrayList<String>(pc.getAliases());
|
||||
labels.add(pc.getName());
|
||||
|
||||
PluginCommand reg = ess.getServer().getPluginCommand(pluginName + ":" + pc.getName().toLowerCase(Locale.ENGLISH));
|
||||
if (reg == null)
|
||||
{
|
||||
reg = ess.getServer().getPluginCommand(pc.getName().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
if (reg == null || !reg.getPlugin().equals(plugin))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (String label : labels)
|
||||
{
|
||||
List<PluginCommand> plugincommands = altcommands.get(label.toLowerCase(Locale.ENGLISH));
|
||||
if (plugincommands == null)
|
||||
{
|
||||
plugincommands = new ArrayList<PluginCommand>();
|
||||
altcommands.put(label.toLowerCase(Locale.ENGLISH), plugincommands);
|
||||
}
|
||||
boolean found = false;
|
||||
for (PluginCommand pc2 : plugincommands)
|
||||
{
|
||||
if (pc2.getPlugin().equals(plugin))
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
plugincommands.add(reg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removePlugin(final Plugin plugin)
|
||||
{
|
||||
final Iterator<Map.Entry<String, List<PluginCommand>>> iterator = altcommands.entrySet().iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
final Map.Entry<String, List<PluginCommand>> entry = iterator.next();
|
||||
final Iterator<PluginCommand> pcIterator = entry.getValue().iterator();
|
||||
while (pcIterator.hasNext())
|
||||
{
|
||||
final PluginCommand pc = pcIterator.next();
|
||||
if (pc.getPlugin() == null || pc.getPlugin().equals(plugin))
|
||||
{
|
||||
pcIterator.remove();
|
||||
}
|
||||
}
|
||||
if (entry.getValue().isEmpty())
|
||||
{
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PluginCommand getAlternative(final String label)
|
||||
{
|
||||
final List<PluginCommand> commands = altcommands.get(label);
|
||||
if (commands == null || commands.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (commands.size() == 1)
|
||||
{
|
||||
return commands.get(0);
|
||||
}
|
||||
// return the first command that is not an alias
|
||||
for (PluginCommand command : commands)
|
||||
{
|
||||
if (command.getName().equalsIgnoreCase(label))
|
||||
{
|
||||
return command;
|
||||
}
|
||||
}
|
||||
// return the first alias
|
||||
return commands.get(0);
|
||||
}
|
||||
|
||||
public void executed(final String label, final String otherLabel)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials: Alternative command " + label + " found, using " + otherLabel);
|
||||
}
|
||||
disabledList.put(label, otherLabel);
|
||||
}
|
||||
|
||||
public Map<String, String> disabledCommands()
|
||||
{
|
||||
return disabledList;
|
||||
}
|
||||
}
|
@@ -1,122 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.event.entity.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class EssentialsEntityListener extends EntityListener
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private final IEssentials ess;
|
||||
|
||||
public EssentialsEntityListener(IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamage(EntityDamageEvent event)
|
||||
{
|
||||
if (event instanceof EntityDamageByEntityEvent)
|
||||
{
|
||||
EntityDamageByEntityEvent edEvent = (EntityDamageByEntityEvent)event;
|
||||
Entity eAttack = edEvent.getDamager();
|
||||
Entity eDefend = edEvent.getEntity();
|
||||
if (eDefend instanceof Player && eAttack instanceof Player)
|
||||
{
|
||||
User defender = ess.getUser(eDefend);
|
||||
User attacker = ess.getUser(eAttack);
|
||||
attacker.updateActivity(true);
|
||||
ItemStack is = attacker.getItemInHand();
|
||||
List<String> commandList = attacker.getPowertool(is);
|
||||
if (commandList != null && !commandList.isEmpty())
|
||||
{
|
||||
for (String command : commandList)
|
||||
{
|
||||
|
||||
if (command != null && !command.isEmpty())
|
||||
{
|
||||
attacker.getServer().dispatchCommand(attacker, command.replaceAll("\\{player\\}", defender.getName()));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (eDefend instanceof Animals && eAttack instanceof Player)
|
||||
{
|
||||
User player = ess.getUser(eAttack);
|
||||
ItemStack hand = player.getItemInHand();
|
||||
if (hand != null && hand.getType() == Material.MILK_BUCKET) {
|
||||
((Animals)eDefend).setAge(-24000);
|
||||
hand.setType(Material.BUCKET);
|
||||
player.setItemInHand(hand);
|
||||
player.updateInventory();
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
final Player player = (Player)event.getEntity();
|
||||
player.setFireTicks(0);
|
||||
player.setRemainingAir(player.getMaximumAir());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCombust(EntityCombustEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDeath(final EntityDeathEvent event)
|
||||
{
|
||||
if (event instanceof PlayerDeathEvent)
|
||||
{
|
||||
final PlayerDeathEvent pdevent = (PlayerDeathEvent)event;
|
||||
final User user = ess.getUser(pdevent.getEntity());
|
||||
if (user.isAuthorized("essentials.back.ondeath") && !ess.getSettings().isCommandDisabled("back"))
|
||||
{
|
||||
user.setLastLocation();
|
||||
user.sendMessage(_("backAfterDeath"));
|
||||
}
|
||||
if (!ess.getSettings().areDeathMessagesEnabled())
|
||||
{
|
||||
pdevent.setDeathMessage("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityRegainHealth(EntityRegainHealthEvent event)
|
||||
{
|
||||
if (event.getRegainReason() == RegainReason.SATIATED && event.getEntity() instanceof Player
|
||||
&& ess.getUser(event.getEntity()).isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,396 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.craftbukkit.SetBed;
|
||||
import com.earth2me.essentials.textreader.IText;
|
||||
import com.earth2me.essentials.textreader.KeywordReplacer;
|
||||
import com.earth2me.essentials.textreader.TextInput;
|
||||
import com.earth2me.essentials.textreader.TextPager;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class EssentialsPlayerListener extends PlayerListener
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private final transient Server server;
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public EssentialsPlayerListener(final IEssentials parent)
|
||||
{
|
||||
this.ess = parent;
|
||||
this.server = parent.getServer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerRespawn(final PlayerRespawnEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
updateCompass(user);
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayNick();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerChat(final PlayerChatEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isMuted())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
user.sendMessage(_("playerMuted"));
|
||||
LOGGER.info(_("mutedUserSpeaks", user.getName()));
|
||||
}
|
||||
final Iterator<Player> it = event.getRecipients().iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
final User u = ess.getUser(it.next());
|
||||
if (u.isIgnoredPlayer(user.getName()))
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
user.updateActivity(true);
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayNick();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(final PlayerMoveEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
|
||||
if (user.isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
final Location from = event.getFrom();
|
||||
final Location to = event.getTo().clone();
|
||||
to.setX(from.getX());
|
||||
to.setY(from.getY());
|
||||
to.setZ(from.getZ());
|
||||
try
|
||||
{
|
||||
event.setTo(Util.getSafeDestination(to));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
event.setTo(to);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final Location afk = user.getAfkPosition();
|
||||
if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9)
|
||||
{
|
||||
user.updateActivity(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerQuit(final PlayerQuitEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (ess.getSettings().removeGodOnDisconnect() && user.isGodModeEnabled())
|
||||
{
|
||||
user.toggleGodModeEnabled();
|
||||
}
|
||||
if (user.getSavedInventory() != null)
|
||||
{
|
||||
user.getInventory().setContents(user.getSavedInventory());
|
||||
user.setSavedInventory(null);
|
||||
}
|
||||
user.updateActivity(false);
|
||||
user.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||
{
|
||||
ess.getBackup().onPlayerJoin();
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayNick();
|
||||
}
|
||||
user.setLastLoginAddress(user.getAddress().getAddress().getHostAddress());
|
||||
user.updateActivity(false);
|
||||
if (user.isAuthorized("essentials.sleepingignored"))
|
||||
{
|
||||
user.setSleepingIgnored(true);
|
||||
}
|
||||
|
||||
if (!ess.getSettings().isCommandDisabled("motd") && user.isAuthorized("essentials.motd"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final IText input = new TextInput(user, "motd", true, ess);
|
||||
final IText output = new KeywordReplacer(input, user, ess);
|
||||
final TextPager pager = new TextPager(output, true);
|
||||
pager.showPage("1", null, "motd", user);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.log(Level.WARNING, ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!ess.getSettings().isCommandDisabled("mail") && user.isAuthorized("essentials.mail"))
|
||||
{
|
||||
final List<String> mail = user.getMails();
|
||||
if (mail.isEmpty())
|
||||
{
|
||||
user.sendMessage(_("noNewMail"));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(_("youHaveNewMail", mail.size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerLogin(final PlayerLoginEvent event)
|
||||
{
|
||||
if (event.getResult() != Result.ALLOWED && event.getResult() != Result.KICK_FULL && event.getResult() != Result.KICK_BANNED)
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Disconnecting user " + event.getPlayer().toString() + " due to " + event.getResult().toString());
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
user.setNPC(false);
|
||||
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
final boolean banExpired = user.checkBanTimeout(currentTime);
|
||||
user.checkMuteTimeout(currentTime);
|
||||
user.checkJailTimeout(currentTime);
|
||||
|
||||
if (banExpired == false && (user.isBanned() || event.getResult() == Result.KICK_BANNED))
|
||||
{
|
||||
final String banReason = user.getBanReason();
|
||||
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() && !banReason.equalsIgnoreCase("ban") ? banReason : _("defaultBanReason"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (server.getOnlinePlayers().length >= server.getMaxPlayers() && !user.isAuthorized("essentials.joinfullserver"))
|
||||
{
|
||||
event.disallow(Result.KICK_FULL, _("serverFull"));
|
||||
return;
|
||||
}
|
||||
event.allow();
|
||||
|
||||
user.setLastLogin(System.currentTimeMillis());
|
||||
updateCompass(user);
|
||||
}
|
||||
|
||||
private void updateCompass(final User user)
|
||||
{
|
||||
Location loc = user.getHome(user.getLocation());
|
||||
if (loc == null)
|
||||
{
|
||||
loc = user.getBedSpawnLocation();
|
||||
}
|
||||
if (loc != null)
|
||||
{
|
||||
user.setCompassTarget(loc);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
//There is TeleportCause.COMMMAND but plugins have to actively pass the cause in on their teleports.
|
||||
if ((event.getCause() == TeleportCause.PLUGIN || event.getCause() == TeleportCause.COMMAND) && ess.getSettings().registerBackInListener())
|
||||
{
|
||||
user.setLastLocation();
|
||||
}
|
||||
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayNick();
|
||||
}
|
||||
updateCompass(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerEggThrow(final PlayerEggThrowEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final ItemStack is = new ItemStack(Material.EGG, 1);
|
||||
if (user.hasUnlimited(is))
|
||||
{
|
||||
user.getInventory().addItem(is);
|
||||
user.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.hasUnlimited(new ItemStack(event.getBucket())))
|
||||
{
|
||||
event.getItemStack().setType(event.getBucket());
|
||||
ess.scheduleSyncDelayedTask(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
user.updateInventory();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerAnimation(final PlayerAnimationEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
user.updateActivity(true);
|
||||
usePowertools(event);
|
||||
}
|
||||
|
||||
private void usePowertools(final PlayerAnimationEvent event)
|
||||
{
|
||||
if (event.getAnimationType() != PlayerAnimationType.ARM_SWING)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final ItemStack is = user.getItemInHand();
|
||||
if (is == null || is.getType() == Material.AIR || !user.arePowerToolsEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final List<String> commandList = user.getPowertool(is);
|
||||
if (commandList == null || commandList.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// We need to loop through each command and execute
|
||||
for (String command : commandList)
|
||||
{
|
||||
if (command.matches(".*\\{player\\}.*"))
|
||||
{
|
||||
//user.sendMessage("Click a player to use this command");
|
||||
continue;
|
||||
}
|
||||
else if (command.startsWith("c:"))
|
||||
{
|
||||
user.chat(command.substring(2));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.getServer().dispatchCommand(event.getPlayer(), command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final String cmd = event.getMessage().toLowerCase(Locale.ENGLISH).split(" ")[0].replace("/", "").toLowerCase(Locale.ENGLISH);
|
||||
final List<String> commands = Arrays.asList("msg", "r", "mail", "m", "t", "emsg", "tell", "er", "reply", "ereply", "email");
|
||||
if (commands.contains(cmd))
|
||||
{
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
User spyer = ess.getUser(player);
|
||||
if (spyer.isSocialSpyEnabled() && !user.equals(spyer))
|
||||
{
|
||||
player.sendMessage(user.getDisplayName() + " : " + event.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!cmd.equalsIgnoreCase("afk"))
|
||||
{
|
||||
user.updateActivity(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerChangedWorld(final PlayerChangedWorldEvent event)
|
||||
{
|
||||
if (ess.getSettings().getNoGodWorlds().contains(event.getPlayer().getLocation().getWorld().getName()))
|
||||
{
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
if (user.isGodModeEnabledRaw())
|
||||
{
|
||||
user.sendMessage(_("noGodWorldWarning"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerInteract(final PlayerInteractEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ess.getSettings().getUpdateBedAtDaytime() && event.getClickedBlock().getType() == Material.BED_BLOCK)
|
||||
{
|
||||
SetBed.setBed(event.getPlayer(), event.getClickedBlock());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerPickupItem(PlayerPickupItemEvent event)
|
||||
{
|
||||
if (event.isCancelled() || !ess.getSettings().getDisableItemPickupWhileAfk())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isAfk())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,50 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.event.server.ServerListener;
|
||||
|
||||
|
||||
public class EssentialsPluginListener extends ServerListener implements IConf
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
|
||||
public EssentialsPluginListener(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginEnable(final PluginEnableEvent event)
|
||||
{
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
ess.getAlternativeCommandsHandler().addPlugin(event.getPlugin());
|
||||
if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(ess.getServer().getPluginManager()))
|
||||
{
|
||||
LOGGER.log(Level.INFO, "[Essentials] Payment method found (" + ess.getPaymentMethod().getMethod().getName() + " version: " + ess.getPaymentMethod().getMethod().getVersion() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginDisable(final PluginDisableEvent event)
|
||||
{
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
ess.getAlternativeCommandsHandler().removePlugin(event.getPlugin());
|
||||
// Check to see if the plugin thats being disabled is the one we are using
|
||||
if (ess.getPaymentMethod() != null && ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().checkDisabled(event.getPlugin()))
|
||||
{
|
||||
ess.getPaymentMethod().reset();
|
||||
LOGGER.log(Level.INFO, "[Essentials] Payment method was disabled. No longer accepting payments.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
{
|
||||
ess.getPermissionsHandler().setUseSuperperms(ess.getSettings().useBukkitPermissions());
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
}
|
||||
}
|
@@ -1,15 +1,23 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.ISettings;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import com.earth2me.essentials.user.UserData.TimestampType;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class EssentialsTimer implements Runnable
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
private final transient Set<User> onlineUsers = new HashSet<User>();
|
||||
private final transient Set<IUser> onlineUsers = new HashSet<IUser>();
|
||||
|
||||
EssentialsTimer(final IEssentials ess)
|
||||
{
|
||||
@@ -22,19 +30,48 @@ public class EssentialsTimer implements Runnable
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
final User user = ess.getUser(player);
|
||||
|
||||
try
|
||||
{
|
||||
final IUser user = ess.getUser(player);
|
||||
onlineUsers.add(user);
|
||||
user.setLastOnlineActivity(currentTime);
|
||||
user.checkActivity();
|
||||
|
||||
boolean mailDisabled = false;
|
||||
ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
try
|
||||
{
|
||||
mailDisabled = settings.getData().getCommands().isDisabled("mail");
|
||||
}
|
||||
finally
|
||||
{
|
||||
settings.unlock();
|
||||
}
|
||||
// New mail notification
|
||||
if (user != null && !mailDisabled && Permissions.MAIL.isAuthorized(user) && !user.gotMailInfo())
|
||||
{
|
||||
final List<String> mail = user.getMails();
|
||||
if (mail != null && !mail.isEmpty())
|
||||
{
|
||||
user.sendMessage(_("youHaveNewMail", mail.size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ess.getLogger().log(Level.WARNING, "EssentialsTimer Error:", e);
|
||||
}
|
||||
}
|
||||
|
||||
final Iterator<User> iterator = onlineUsers.iterator();
|
||||
final Iterator<IUser> iterator = onlineUsers.iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
final User user = iterator.next();
|
||||
if (user.getLastOnlineActivity() < currentTime && user.getLastOnlineActivity() > user.getLastLogout())
|
||||
final IUser user = iterator.next();
|
||||
if (user.getLastOnlineActivity() < currentTime && user.getLastOnlineActivity() > user.getTimestamp(TimestampType.LOGOUT))
|
||||
{
|
||||
user.setLastLogout(user.getLastOnlineActivity());
|
||||
user.setTimestamp(TimestampType.LOGOUT, user.getLastOnlineActivity());
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.II18n;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -43,6 +44,7 @@ public class I18n implements II18n
|
||||
instance = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getCurrentLocale()
|
||||
{
|
||||
return currentLocale;
|
||||
|
@@ -1,9 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
/**
|
||||
* @deprecated New interface will be IReload in api package
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IConf {
|
||||
public void reloadConfig();
|
||||
}
|
@@ -1,67 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.IJails;
|
||||
import com.earth2me.essentials.perm.PermissionsHandler;
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
/**
|
||||
* @deprecated This will be moved to the api package soon
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IEssentials extends Plugin
|
||||
{
|
||||
void addReloadListener(IConf listener);
|
||||
|
||||
void reload();
|
||||
|
||||
boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath, String permissionPrefix, IEssentialsModule module);
|
||||
|
||||
User getUser(Object base);
|
||||
|
||||
I18n getI18n();
|
||||
|
||||
User getOfflineUser(String name);
|
||||
|
||||
World getWorld(String name);
|
||||
|
||||
int broadcastMessage(IUser sender, String message);
|
||||
|
||||
ISettings getSettings();
|
||||
|
||||
BukkitScheduler getScheduler();
|
||||
|
||||
IJails getJails();
|
||||
|
||||
Warps getWarps();
|
||||
|
||||
Worth getWorth();
|
||||
|
||||
Backup getBackup();
|
||||
|
||||
Methods getPaymentMethod();
|
||||
|
||||
int scheduleAsyncDelayedTask(Runnable run);
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run);
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run, long delay);
|
||||
|
||||
int scheduleSyncRepeatingTask(final Runnable run, long delay, long period);
|
||||
|
||||
TNTExplodeListener getTNTListener();
|
||||
|
||||
PermissionsHandler getPermissionsHandler();
|
||||
|
||||
AlternativeCommandsHandler getAlternativeCommandsHandler();
|
||||
|
||||
void showError(final CommandSender sender, final Throwable exception, final String commandLabel);
|
||||
|
||||
ItemDb getItemDb();
|
||||
|
||||
UserMap getUserMap();
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public interface IReplyTo {
|
||||
public void setReplyTo(CommandSender user);
|
||||
|
||||
public CommandSender getReplyTo();
|
||||
}
|
@@ -1,156 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
|
||||
|
||||
public interface ISettings extends IConf
|
||||
{
|
||||
boolean areSignsDisabled();
|
||||
|
||||
String format(String format, IUser user);
|
||||
|
||||
String getAnnounceNewPlayerFormat(IUser user);
|
||||
|
||||
boolean getAnnounceNewPlayers();
|
||||
|
||||
String getBackupCommand();
|
||||
|
||||
long getBackupInterval();
|
||||
|
||||
String getChatFormat(String group);
|
||||
|
||||
int getChatRadius();
|
||||
|
||||
double getCommandCost(IEssentialsCommand cmd);
|
||||
|
||||
double getCommandCost(String label);
|
||||
|
||||
String getCurrencySymbol();
|
||||
|
||||
int getOversizedStackSize();
|
||||
|
||||
int getDefaultStackSize();
|
||||
|
||||
double getHealCooldown();
|
||||
|
||||
Object getKit(String name);
|
||||
|
||||
Map<String, Object> getKits();
|
||||
|
||||
String getLocale();
|
||||
|
||||
String getNewbieSpawn();
|
||||
|
||||
String getNicknamePrefix();
|
||||
|
||||
ChatColor getOperatorColor() throws Exception;
|
||||
|
||||
boolean getPerWarpPermission();
|
||||
|
||||
boolean getProtectBoolean(final String configName, boolean def);
|
||||
|
||||
int getProtectCreeperMaxHeight();
|
||||
|
||||
List<Integer> getProtectList(final String configName);
|
||||
|
||||
boolean getProtectPreventSpawn(final String creatureName);
|
||||
|
||||
String getProtectString(final String configName);
|
||||
|
||||
boolean getRespawnAtHome();
|
||||
|
||||
List getMultipleHomes();
|
||||
|
||||
int getHomeLimit(String set);
|
||||
|
||||
int getHomeLimit(User user);
|
||||
|
||||
boolean getSortListByGroups();
|
||||
|
||||
int getSpawnMobLimit();
|
||||
|
||||
int getStartingBalance();
|
||||
|
||||
double getTeleportCooldown();
|
||||
|
||||
double getTeleportDelay();
|
||||
|
||||
boolean hidePermissionlessHelp();
|
||||
|
||||
boolean isCommandDisabled(final IEssentialsCommand cmd);
|
||||
|
||||
boolean isCommandDisabled(String label);
|
||||
|
||||
boolean isCommandOverridden(String name);
|
||||
|
||||
boolean isCommandRestricted(IEssentialsCommand cmd);
|
||||
|
||||
boolean isCommandRestricted(String label);
|
||||
|
||||
boolean isDebug();
|
||||
|
||||
boolean isEcoDisabled();
|
||||
|
||||
boolean isTradeInStacks(int id);
|
||||
|
||||
List<Integer> itemSpawnBlacklist();
|
||||
|
||||
boolean permissionBasedItemSpawn();
|
||||
|
||||
boolean showNonEssCommandsInHelp();
|
||||
|
||||
boolean spawnIfNoHome();
|
||||
|
||||
boolean warnOnBuildDisallow();
|
||||
|
||||
boolean warnOnSmite();
|
||||
|
||||
double getMaxMoney();
|
||||
|
||||
boolean isEcoLogEnabled();
|
||||
|
||||
boolean removeGodOnDisconnect();
|
||||
|
||||
boolean changeDisplayName();
|
||||
|
||||
boolean isPlayerCommand(String string);
|
||||
|
||||
boolean useBukkitPermissions();
|
||||
|
||||
boolean addPrefixSuffix();
|
||||
|
||||
boolean disablePrefix();
|
||||
|
||||
boolean disableSuffix();
|
||||
|
||||
long getAutoAfk();
|
||||
|
||||
long getAutoAfkKick();
|
||||
|
||||
boolean getFreezeAfkPlayers();
|
||||
|
||||
boolean areDeathMessagesEnabled();
|
||||
|
||||
public void setDebug(boolean debug);
|
||||
|
||||
Set<String> getNoGodWorlds();
|
||||
|
||||
boolean getUpdateBedAtDaytime();
|
||||
|
||||
boolean getRepairEnchanted();
|
||||
|
||||
boolean getIsWorldTeleportPermissions();
|
||||
|
||||
boolean registerBackInListener();
|
||||
|
||||
public boolean getDisableItemPickupWhileAfk();
|
||||
|
||||
public Priority getRespawnPriority();
|
||||
|
||||
long getTpaAcceptCancellation();
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import java.net.InetSocketAddress;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated This will be moved to the api package soon
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IUser extends Player
|
||||
{
|
||||
long getLastTeleportTimestamp();
|
||||
|
||||
boolean isAuthorized(String node);
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd);
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix);
|
||||
|
||||
void setLastTeleportTimestamp(long time);
|
||||
|
||||
Location getLastLocation();
|
||||
|
||||
Player getBase();
|
||||
|
||||
double getMoney();
|
||||
|
||||
void takeMoney(double value);
|
||||
|
||||
void giveMoney(double value);
|
||||
|
||||
String getGroup();
|
||||
|
||||
void setLastLocation();
|
||||
|
||||
Location getHome(String name) throws Exception;
|
||||
|
||||
Location getHome(Location loc) throws Exception;
|
||||
|
||||
boolean isHidden();
|
||||
|
||||
Teleport getTeleport();
|
||||
|
||||
void setJail(String jail);
|
||||
}
|
@@ -1,16 +1,22 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.IItemDb;
|
||||
import com.earth2me.essentials.storage.ManagedFile;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IItemDb;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class ItemDb implements IConf, IItemDb
|
||||
public class ItemDb implements IItemDb
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
|
||||
@@ -19,12 +25,12 @@ public class ItemDb implements IConf, IItemDb
|
||||
this.ess = ess;
|
||||
file = new ManagedFile("items.csv", ess);
|
||||
}
|
||||
private final transient Map<String, Integer> items = new HashMap<String, Integer>();
|
||||
private final transient Map<String, Short> durabilities = new HashMap<String, Short>();
|
||||
private final transient Map<String, Long> items = new HashMap<String, Long>();
|
||||
private final transient ManagedFile file;
|
||||
private static final Pattern SPLIT = Pattern.compile("[^a-zA-Z0-9]");
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
public void onReload()
|
||||
{
|
||||
final List<String> lines = file.getLines();
|
||||
|
||||
@@ -33,30 +39,54 @@ public class ItemDb implements IConf, IItemDb
|
||||
return;
|
||||
}
|
||||
|
||||
durabilities.clear();
|
||||
items.clear();
|
||||
|
||||
for (String line : lines)
|
||||
{
|
||||
line = line.trim().toLowerCase(Locale.ENGLISH);
|
||||
line = line.trim();
|
||||
if (line.length() > 0 && line.charAt(0) == '#')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final String[] parts = line.split("[^a-z0-9]");
|
||||
final String[] parts = SPLIT.split(line);
|
||||
if (parts.length < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final int numeric = Integer.parseInt(parts[1]);
|
||||
final long numeric = Integer.parseInt(parts[1]);
|
||||
|
||||
durabilities.put(parts[0].toLowerCase(Locale.ENGLISH), parts.length > 2 && !parts[2].equals("0") ? Short.parseShort(parts[2]) : 0);
|
||||
items.put(parts[0].toLowerCase(Locale.ENGLISH), numeric);
|
||||
final long durability = parts.length > 2 && !(parts[2].length() == 1 && parts[2].charAt(0) == '0') ? Short.parseShort(parts[2]) : 0;
|
||||
items.put(parts[0].toLowerCase(Locale.ENGLISH), numeric | (durability << 32));
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack get(final String id, final IUser user) throws Exception
|
||||
{
|
||||
final ItemStack stack = get(id.toLowerCase(Locale.ENGLISH));
|
||||
|
||||
@Cleanup
|
||||
com.earth2me.essentials.api.ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
|
||||
final int defaultStackSize = settings.getData().getGeneral().getDefaultStacksize();
|
||||
|
||||
if (defaultStackSize > 0)
|
||||
{
|
||||
stack.setAmount(defaultStackSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
final int oversizedStackSize = settings.getData().getGeneral().getOversizedStacksize();
|
||||
if (oversizedStackSize > 0 && Permissions.OVERSIZEDSTACKS.isAuthorized(user))
|
||||
{
|
||||
stack.setAmount(oversizedStackSize);
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
public ItemStack get(final String id, final int quantity) throws Exception
|
||||
{
|
||||
final ItemStack retval = get(id.toLowerCase(Locale.ENGLISH));
|
||||
@@ -92,10 +122,11 @@ public class ItemDb implements IConf, IItemDb
|
||||
{
|
||||
if (items.containsKey(itemname))
|
||||
{
|
||||
itemid = items.get(itemname);
|
||||
if (durabilities.containsKey(itemname) && metaData == 0)
|
||||
long item = items.get(itemname);
|
||||
itemid = (int)(item & 0xffffffffL);
|
||||
if (metaData == 0)
|
||||
{
|
||||
metaData = durabilities.get(itemname);
|
||||
metaData = (short)((item >> 32) & 0xffffL);
|
||||
}
|
||||
}
|
||||
else if (Material.getMaterial(itemname) != null)
|
||||
|
@@ -1,18 +1,27 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.IJails;
|
||||
import com.earth2me.essentials.storage.AsyncStorageObjectHolder;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IJails;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.storage.AsyncStorageObjectHolder;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
@@ -24,7 +33,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
public Jails(final IEssentials ess)
|
||||
{
|
||||
super(ess, com.earth2me.essentials.settings.Jails.class);
|
||||
reloadConfig();
|
||||
onReload();
|
||||
registerListeners();
|
||||
}
|
||||
|
||||
@@ -33,13 +42,8 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
final PluginManager pluginManager = ess.getServer().getPluginManager();
|
||||
final JailBlockListener blockListener = new JailBlockListener();
|
||||
final JailPlayerListener playerListener = new JailPlayerListener();
|
||||
pluginManager.registerEvent(Type.BLOCK_BREAK, blockListener, Priority.Low, ess);
|
||||
pluginManager.registerEvent(Type.BLOCK_DAMAGE, blockListener, Priority.Low, ess);
|
||||
pluginManager.registerEvent(Type.BLOCK_PLACE, blockListener, Priority.Low, ess);
|
||||
pluginManager.registerEvent(Type.PLAYER_INTERACT, playerListener, Priority.Low, ess);
|
||||
pluginManager.registerEvent(Type.PLAYER_RESPAWN, playerListener, Priority.High, ess);
|
||||
pluginManager.registerEvent(Type.PLAYER_TELEPORT, playerListener, Priority.High, ess);
|
||||
pluginManager.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.High, ess);
|
||||
pluginManager.registerEvents(blockListener, ess);
|
||||
pluginManager.registerEvents(playerListener, ess);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,7 +63,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
{
|
||||
throw new Exception(_("jailNotExist"));
|
||||
}
|
||||
Location loc = getData().getJails().get(jailName.toLowerCase(Locale.ENGLISH));
|
||||
Location loc = getData().getJails().get(jailName.toLowerCase(Locale.ENGLISH)).getBukkitLocation();
|
||||
if (loc == null || loc.getWorld() == null)
|
||||
{
|
||||
throw new Exception(_("jailNotExist"));
|
||||
@@ -114,12 +118,20 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
acquireReadLock();
|
||||
try
|
||||
{
|
||||
if (!(user.getBase() instanceof OfflinePlayer))
|
||||
if (!(user.isOnline()))
|
||||
{
|
||||
Location loc = getJail(jail);
|
||||
user.getTeleport().now(loc, false, TeleportCause.COMMAND);
|
||||
}
|
||||
user.setJail(jail);
|
||||
user.acquireWriteLock();
|
||||
try
|
||||
{
|
||||
user.getData().setJail(jail);
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -135,9 +147,9 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
{
|
||||
if (getData().getJails() == null)
|
||||
{
|
||||
getData().setJails(new HashMap<String, Location>());
|
||||
getData().setJails(new HashMap<String, com.earth2me.essentials.storage.Location>());
|
||||
}
|
||||
getData().getJails().put(jailName.toLowerCase(Locale.ENGLISH), loc);
|
||||
getData().getJails().put(jailName.toLowerCase(Locale.ENGLISH), new com.earth2me.essentials.storage.Location(loc));
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -146,33 +158,39 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
}
|
||||
|
||||
|
||||
private class JailBlockListener extends BlockListener
|
||||
private class JailBlockListener implements Listener
|
||||
{
|
||||
@Override
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onBlockBreak(final BlockBreakEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
@Cleanup
|
||||
final IUser user = ess.getUser(event.getPlayer());
|
||||
user.acquireReadLock();
|
||||
if (user.getData().isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onBlockPlace(final BlockPlaceEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
@Cleanup
|
||||
final IUser user = ess.getUser(event.getPlayer());
|
||||
user.acquireReadLock();
|
||||
if (user.getData().isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onBlockDamage(final BlockDamageEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
@Cleanup
|
||||
final IUser user = ess.getUser(event.getPlayer());
|
||||
user.acquireReadLock();
|
||||
if (user.getData().isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@@ -180,73 +198,102 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
}
|
||||
|
||||
|
||||
private class JailPlayerListener extends PlayerListener
|
||||
private class JailPlayerListener implements Listener
|
||||
{
|
||||
@Override
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerInteract(final PlayerInteractEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
@Cleanup
|
||||
final IUser user = ess.getUser(event.getPlayer());
|
||||
user.acquireReadLock();
|
||||
if (user.getData().isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerRespawn(final PlayerRespawnEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
|
||||
@Cleanup
|
||||
final IUser user = ess.getUser(event.getPlayer());
|
||||
user.acquireReadLock();
|
||||
if (!user.getData().isJailed() || user.getData().getJail() == null || user.getData().getJail().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
event.setRespawnLocation(getJail(user.getJail()));
|
||||
event.setRespawnLocation(getJail(user.getData().getJail()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("returnPlayerToJailError"), ex);
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()), ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerTeleport(final PlayerTeleportEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
|
||||
@Cleanup
|
||||
final IUser user = ess.getUser(event.getPlayer());
|
||||
user.acquireReadLock();
|
||||
if (!user.getData().isJailed() || user.getData().getJail() == null || user.getData().getJail().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
event.setTo(getJail(user.getJail()));
|
||||
event.setTo(getJail(user.getData().getJail()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("returnPlayerToJailError"), ex);
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()), ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()));
|
||||
}
|
||||
}
|
||||
user.sendMessage(_("jailMessage"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
|
||||
@Cleanup
|
||||
final IUser user = ess.getUser(event.getPlayer());
|
||||
user.acquireReadLock();
|
||||
if (!user.getData().isJailed() || user.getData().getJail() == null || user.getData().getJail().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
sendToJail(user, user.getJail());
|
||||
sendToJail(user, user.getData().getJail());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("returnPlayerToJailError"), ex);
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()), ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()));
|
||||
}
|
||||
}
|
||||
user.sendMessage(_("jailMessage"));
|
||||
}
|
||||
|
@@ -1,113 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.commands.NoChargeException;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import java.util.*;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Kit
|
||||
{
|
||||
//TODO: Convert this to use one of the new text classes?
|
||||
public static String listKits(final IEssentials ess, final User user) throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
final Map<String, Object> kits = ess.getSettings().getKits();
|
||||
final StringBuilder list = new StringBuilder();
|
||||
for (String kiteItem : kits.keySet())
|
||||
{
|
||||
if (user.isAuthorized("essentials.kit." + kiteItem.toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
list.append(" ").append(kiteItem);
|
||||
}
|
||||
}
|
||||
return list.toString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(_("kitError"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void checkTime(final User user, final String kitName, final Map<String, Object> els) throws NoChargeException
|
||||
{
|
||||
final double delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0L;
|
||||
final Calendar c = new GregorianCalendar();
|
||||
c.add(Calendar.SECOND, -(int)delay);
|
||||
c.add(Calendar.MILLISECOND, -(int)((delay * 1000.0) % 1000.0));
|
||||
|
||||
final long mintime = c.getTimeInMillis();
|
||||
|
||||
final Long lastTime = user.getKitTimestamp(kitName);
|
||||
if (lastTime == null || lastTime < mintime)
|
||||
{
|
||||
final Calendar now = new GregorianCalendar();
|
||||
user.setKitTimestamp(kitName, now.getTimeInMillis());
|
||||
}
|
||||
else
|
||||
{
|
||||
final Calendar future = new GregorianCalendar();
|
||||
future.setTimeInMillis(lastTime);
|
||||
future.add(Calendar.SECOND, (int)delay);
|
||||
future.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
|
||||
user.sendMessage(_("kitTimed", Util.formatDateDiff(future.getTimeInMillis())));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getItems(final User user, final Map<String, Object> els) throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
return (List<String>)els.get("items");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
user.sendMessage(_("kitError2"));
|
||||
throw new Exception(_("kitErrorHelp"));
|
||||
}
|
||||
}
|
||||
|
||||
public static void expandItems(final IEssentials ess, final User user, final List<String> items) throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
boolean spew = false;
|
||||
for (String d : items)
|
||||
{
|
||||
final String[] parts = d.split("[^0-9]+", 3);
|
||||
final int id = Material.getMaterial(Integer.parseInt(parts[0])).getId();
|
||||
final int amount = parts.length > 1 ? Integer.parseInt(parts[parts.length > 2 ? 2 : 1]) : 1;
|
||||
final short data = parts.length > 2 ? Short.parseShort(parts[1]) : 0;
|
||||
final Map<Integer, ItemStack> overfilled;
|
||||
if (user.isAuthorized("essentials.oversizedstacks"))
|
||||
{
|
||||
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), new ItemStack(id, amount, data));
|
||||
}
|
||||
else
|
||||
{
|
||||
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, new ItemStack(id, amount, data));
|
||||
}
|
||||
for (ItemStack itemStack : overfilled.values())
|
||||
{
|
||||
user.getWorld().dropItemNaturally(user.getLocation(), itemStack);
|
||||
spew = true;
|
||||
}
|
||||
}
|
||||
user.updateInventory();
|
||||
if (spew)
|
||||
{
|
||||
user.sendMessage(_("kitInvFull"));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
user.updateInventory();
|
||||
throw new Exception(_("kitError2"));
|
||||
}
|
||||
}
|
||||
}
|
90
Essentials/src/com/earth2me/essentials/Kits.java
Normal file
90
Essentials/src/com/earth2me/essentials/Kits.java
Normal file
@@ -0,0 +1,90 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IKits;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.settings.Kit;
|
||||
import com.earth2me.essentials.storage.AsyncStorageObjectHolder;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Kits extends AsyncStorageObjectHolder<com.earth2me.essentials.settings.Kits> implements IKits
|
||||
{
|
||||
public Kits(final IEssentials ess)
|
||||
{
|
||||
super(ess, com.earth2me.essentials.settings.Kits.class);
|
||||
onReload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getStorageFile() throws IOException
|
||||
{
|
||||
return new File(ess.getDataFolder(), "kits.yml");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Kit getKit(String kitName) throws Exception
|
||||
{
|
||||
acquireReadLock();
|
||||
try
|
||||
{
|
||||
if (getData().getKits() == null || kitName == null
|
||||
|| !getData().getKits().containsKey(kitName.toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
throw new Exception(_("kitError2"));
|
||||
}
|
||||
final Kit kit = getData().getKits().get(kitName.toLowerCase(Locale.ENGLISH));
|
||||
if (kit == null)
|
||||
{
|
||||
throw new Exception(_("kitError2"));
|
||||
}
|
||||
return kit;
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendKit(IUser user, String kitName) throws Exception
|
||||
{
|
||||
final Kit kit = getKit(kitName);
|
||||
sendKit(user, kit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendKit(IUser user, Kit kit) throws Exception
|
||||
{
|
||||
final List<ItemStack> itemList = kit.getItems();
|
||||
user.giveItems(itemList, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getList() throws Exception
|
||||
{
|
||||
acquireReadLock();
|
||||
try
|
||||
{
|
||||
if (getData().getKits() == null)
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return new ArrayList<String>(getData().getKits().keySet());
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return getData().getKits().isEmpty();
|
||||
}
|
||||
}
|
@@ -1,825 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.craftbukkit.OfflineBedLocation;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import lombok.Delegate;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.map.MapView;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
|
||||
public class OfflinePlayer implements Player
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
private Location location = new Location(null, 0, 0, 0, 0, 0);
|
||||
private World world;
|
||||
private UUID uniqueId = UUID.randomUUID();
|
||||
@Delegate(types = org.bukkit.OfflinePlayer.class)
|
||||
private final org.bukkit.OfflinePlayer base;
|
||||
|
||||
public OfflinePlayer(final String name, final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
this.world = ess.getServer().getWorlds().get(0);
|
||||
this.base = ess.getServer().getOfflinePlayer(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(final String string)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
return base.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisplayName(String string)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCompassTarget(Location lctn)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetSocketAddress getAddress()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kickPlayer(String string)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerInventory getInventory()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemInHand()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemInHand(ItemStack is)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHealth()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHealth(int i)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Egg throwEgg()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Snowball throwSnowball()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Arrow shootArrow()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInsideVehicle()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean leaveVehicle()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vehicle getVehicle()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation()
|
||||
{
|
||||
return location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld()
|
||||
{
|
||||
return world;
|
||||
}
|
||||
|
||||
public void setLocation(Location loc)
|
||||
{
|
||||
location = loc;
|
||||
world = loc.getWorld();
|
||||
}
|
||||
|
||||
public void teleportTo(Location lctn)
|
||||
{
|
||||
}
|
||||
|
||||
public void teleportTo(Entity entity)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEntityId()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performCommand(String string)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isPlayer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRemainingAir()
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRemainingAir(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumAir()
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaximumAir(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSneaking()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSneaking(boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateInventory()
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void chat(String string)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getEyeHeight()
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getEyeHeight(boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Block> getLineOfSight(HashSet<Byte> hs, int i)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getTargetBlock(HashSet<Byte> hs, int i)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Block> getLastTwoTargetBlocks(HashSet<Byte> hs, int i)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireTicks()
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxFireTicks()
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFireTicks(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Server getServer()
|
||||
{
|
||||
return ess == null ? null : ess.getServer();
|
||||
}
|
||||
|
||||
public Vector getMomentum()
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
public void setMomentum(Vector vector)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVelocity(Vector vector)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getVelocity()
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void damage(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void damage(int i, Entity entity)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getEyeLocation()
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRawMessage(String string)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getCompassTarget()
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumNoDamageTicks()
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaximumNoDamageTicks(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLastDamage()
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastDamage(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNoDamageTicks()
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoDamageTicks(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean teleport(Location lctn)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean teleport(Entity entity)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity getPassenger()
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setPassenger(Entity entity)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eject()
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveData()
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadData()
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSleeping()
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSleepTicks()
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Entity> getNearbyEntities(double d, double d1, double d2)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDead()
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFallDistance()
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFallDistance(float f)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSleepingIgnored(boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSleepingIgnored()
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void awardAchievement(Achievement a)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementStatistic(Statistic ststc)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementStatistic(Statistic ststc, int i)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementStatistic(Statistic ststc, Material mtrl)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementStatistic(Statistic ststc, Material mtrl, int i)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playNote(Location lctn, byte b, byte b1)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBlockChange(Location lctn, Material mtrl, byte b)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBlockChange(Location lctn, int i, byte b)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastDamageCause(EntityDamageEvent ede)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityDamageEvent getLastDamageCause()
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playEffect(Location lctn, Effect effect, int i)
|
||||
{
|
||||
throw new UnsupportedOperationException(_("notSupportedYet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendChunkChange(Location lctn, int i, int i1, int i2, byte[] bytes)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUniqueId()
|
||||
{
|
||||
return uniqueId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playNote(Location lctn, Instrument i, Note note)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerTime(long l, boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPlayerTime()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPlayerTimeOffset()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerTimeRelative()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetPlayerTime()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(String string)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(Permission prmsn)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String string)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(Permission prmsn)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionAttachment addAttachment(Plugin plugin)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln, int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionAttachment addAttachment(Plugin plugin, int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttachment(PermissionAttachment pa)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recalculatePermissions()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<PermissionAttachmentInfo> getEffectivePermissions()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMap(MapView mv)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameMode getGameMode()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGameMode(GameMode gm)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getExperience()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExperience(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLevel()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLevel(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalExperience()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTotalExperience(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExhaustion()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExhaustion(float f)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSaturation()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSaturation(float f)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFoodLevel()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFoodLevel(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getBedSpawnLocation()
|
||||
{
|
||||
return OfflineBedLocation.getBedLocation(base.getName(), ess);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSprinting()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSprinting(boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerListName(String name)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerListName()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTicksLived()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTicksLived(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHealth()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveExp(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExp()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExp(float f)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean teleport(Location lctn, TeleportCause tc)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean teleport(Entity entity, TeleportCause tc)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getKiller()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
}
|
@@ -1,38 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import lombok.Delegate;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.permissions.ServerOperator;
|
||||
|
||||
|
||||
public class PlayerExtension implements Player
|
||||
{
|
||||
@Delegate(types =
|
||||
{
|
||||
Player.class, Entity.class, CommandSender.class, ServerOperator.class,
|
||||
HumanEntity.class, ConfigurationSerializable.class, LivingEntity.class,
|
||||
Permissible.class
|
||||
})
|
||||
protected Player base;
|
||||
|
||||
public PlayerExtension(final Player base)
|
||||
{
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
public final Player getBase()
|
||||
{
|
||||
return base;
|
||||
}
|
||||
|
||||
public final Player setBase(final Player base)
|
||||
{
|
||||
return this.base = base;
|
||||
}
|
||||
}
|
@@ -1,615 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Settings implements ISettings
|
||||
{
|
||||
private final transient EssentialsConf config;
|
||||
private final static Logger logger = Logger.getLogger("Minecraft");
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public Settings(IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
config = new EssentialsConf(new File(ess.getDataFolder(), "config.yml"));
|
||||
config.setTemplateName("/config.yml");
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getRespawnAtHome()
|
||||
{
|
||||
return config.getBoolean("respawn-at-home", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUpdateBedAtDaytime()
|
||||
{
|
||||
return config.getBoolean("update-bed-at-daytime", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMultipleHomes()
|
||||
{
|
||||
return config.getKeys("sethome-multiple");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHomeLimit(final User user)
|
||||
{
|
||||
final List<String> homeList = getMultipleHomes();
|
||||
if (homeList == null)
|
||||
{
|
||||
//TODO: Replace this code to remove backwards compat, after settings are automatically updated
|
||||
// return getHomeLimit("default");
|
||||
return config.getInt("multiple-homes", 5);
|
||||
}
|
||||
int limit = getHomeLimit("default");
|
||||
for (String set : homeList)
|
||||
{
|
||||
if (user.isAuthorized("essentials.sethome.multiple." + set) && (limit < getHomeLimit(set)))
|
||||
{
|
||||
limit = getHomeLimit(set);
|
||||
}
|
||||
}
|
||||
return limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHomeLimit(final String set)
|
||||
{
|
||||
return config.getInt("sethome-multiple." + set, config.getInt("sethome-multiple.default", 3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChatRadius()
|
||||
{
|
||||
return config.getInt("chat.radius", config.getInt("chat-radius", 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTeleportDelay()
|
||||
{
|
||||
return config.getDouble("teleport-delay", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOversizedStackSize()
|
||||
{
|
||||
return config.getInt("oversized-stacksize", 64);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefaultStackSize()
|
||||
{
|
||||
return config.getInt("default-stack-size", -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartingBalance()
|
||||
{
|
||||
return config.getInt("starting-balance", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandDisabled(final IEssentialsCommand cmd)
|
||||
{
|
||||
return isCommandDisabled(cmd.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandDisabled(String label)
|
||||
{
|
||||
for (String c : config.getStringList("disabled-commands", new ArrayList<String>(0)))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(label))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return config.getBoolean("disable-" + label.toLowerCase(Locale.ENGLISH), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandRestricted(IEssentialsCommand cmd)
|
||||
{
|
||||
return isCommandRestricted(cmd.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandRestricted(String label)
|
||||
{
|
||||
for (String c : config.getStringList("restricted-commands", new ArrayList<String>(0)))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(label))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return config.getBoolean("restrict-" + label.toLowerCase(Locale.ENGLISH), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerCommand(String label)
|
||||
{
|
||||
for (String c : config.getStringList("player-commands", new ArrayList<String>(0)))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(label))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandOverridden(String name)
|
||||
{
|
||||
List<String> defaultList = new ArrayList<String>(1);
|
||||
defaultList.add("god");
|
||||
for (String c : config.getStringList("overridden-commands", defaultList))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return config.getBoolean("override-" + name.toLowerCase(Locale.ENGLISH), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCommandCost(IEssentialsCommand cmd)
|
||||
{
|
||||
return getCommandCost(cmd.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCommandCost(String label)
|
||||
{
|
||||
double cost = config.getDouble("command-costs." + label, 0.0);
|
||||
if (cost == 0.0)
|
||||
{
|
||||
cost = config.getDouble("cost-" + label, 0.0);
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNicknamePrefix()
|
||||
{
|
||||
return config.getString("nickname-prefix", "~");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTeleportCooldown()
|
||||
{
|
||||
return config.getDouble("teleport-cooldown", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHealCooldown()
|
||||
{
|
||||
return config.getDouble("heal-cooldown", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getKit(String name)
|
||||
{
|
||||
Map<String, Object> kits = (Map<String, Object>)config.getProperty("kits");
|
||||
for (Map.Entry<String, Object> entry : kits.entrySet())
|
||||
{
|
||||
if (entry.getKey().equalsIgnoreCase(name.replace('.', '_').replace('/', '_')))
|
||||
{
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getKits()
|
||||
{
|
||||
return (Map<String, Object>)config.getProperty("kits");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatColor getOperatorColor() throws Exception
|
||||
{
|
||||
String colorName = config.getString("ops-name-color", null);
|
||||
|
||||
if (colorName == null)
|
||||
{
|
||||
return ChatColor.RED;
|
||||
}
|
||||
if ("none".equalsIgnoreCase(colorName) || colorName.isEmpty())
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return ChatColor.valueOf(colorName.toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
}
|
||||
|
||||
return ChatColor.getByCode(Integer.parseInt(colorName, 16));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSpawnMobLimit()
|
||||
{
|
||||
return config.getInt("spawnmob-limit", 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showNonEssCommandsInHelp()
|
||||
{
|
||||
return config.getBoolean("non-ess-in-help", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hidePermissionlessHelp()
|
||||
{
|
||||
return config.getBoolean("hide-permissionless-help", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProtectCreeperMaxHeight()
|
||||
{
|
||||
return config.getInt("protect.creeper.max-height", -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areSignsDisabled()
|
||||
{
|
||||
return config.getBoolean("signs-disabled", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBackupInterval()
|
||||
{
|
||||
return config.getInt("backup.interval", 1440); // 1440 = 24 * 60
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBackupCommand()
|
||||
{
|
||||
return config.getString("backup.command", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChatFormat(String group)
|
||||
{
|
||||
return config.getString("chat.group-formats." + (group == null ? "Default" : group),
|
||||
config.getString("chat.format", "&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAnnounceNewPlayers()
|
||||
{
|
||||
return !config.getString("newbies.announce-format", "-").isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAnnounceNewPlayerFormat(IUser user)
|
||||
{
|
||||
return format(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!"), user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(String format, IUser user)
|
||||
{
|
||||
return format.replace('&', '§').replace("§§", "&").replace("{PLAYER}", user.getDisplayName()).replace("{DISPLAYNAME}", user.getDisplayName()).replace("{GROUP}", user.getGroup()).replace("{USERNAME}", user.getName()).replace("{ADDRESS}", user.getAddress().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNewbieSpawn()
|
||||
{
|
||||
return config.getString("newbies.spawnpoint", "default");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPerWarpPermission()
|
||||
{
|
||||
return config.getBoolean("per-warp-permission", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getSortListByGroups()
|
||||
{
|
||||
return config.getBoolean("sort-list-by-groups", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
{
|
||||
config.load();
|
||||
noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds", Collections.<String>emptyList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> itemSpawnBlacklist()
|
||||
{
|
||||
final List<Integer> epItemSpwn = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString("item-spawn-blacklist", "").split(","))
|
||||
{
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ItemStack is;
|
||||
try
|
||||
{
|
||||
is = ess.getItemDb().get(itemName);
|
||||
epItemSpwn.add(is.getTypeId());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, _("unknownItemInList", itemName, "item-spawn-blacklist"));
|
||||
}
|
||||
}
|
||||
return epItemSpwn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean spawnIfNoHome()
|
||||
{
|
||||
return config.getBoolean("spawn-if-no-home", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean warnOnBuildDisallow()
|
||||
{
|
||||
return config.getBoolean("protect.disable.warn-on-build-disallow", false);
|
||||
}
|
||||
private boolean debug = false;
|
||||
|
||||
@Override
|
||||
public boolean isDebug()
|
||||
{
|
||||
return debug || config.getBoolean("debug", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean warnOnSmite()
|
||||
{
|
||||
return config.getBoolean("warn-on-smite", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean permissionBasedItemSpawn()
|
||||
{
|
||||
return config.getBoolean("permission-based-item-spawn", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocale()
|
||||
{
|
||||
return config.getString("locale", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrencySymbol()
|
||||
{
|
||||
return config.getString("currency-symbol", "$").substring(0, 1).replaceAll("[0-9]", "$");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTradeInStacks(int id)
|
||||
{
|
||||
return config.getBoolean("trade-in-stacks-" + id, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEcoDisabled()
|
||||
{
|
||||
return config.getBoolean("disable-eco", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getProtectPreventSpawn(final String creatureName)
|
||||
{
|
||||
return config.getBoolean("protect.prevent.spawn." + creatureName, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getProtectList(final String configName)
|
||||
{
|
||||
final List<Integer> list = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString(configName, "").split(","))
|
||||
{
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ItemStack itemStack;
|
||||
try
|
||||
{
|
||||
itemStack = ess.getItemDb().get(itemName);
|
||||
list.add(itemStack.getTypeId());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, _("unknownItemInList", itemName, configName));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProtectString(final String configName)
|
||||
{
|
||||
return config.getString(configName, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getProtectBoolean(final String configName, boolean def)
|
||||
{
|
||||
return config.getBoolean(configName, def);
|
||||
}
|
||||
private final static double MAXMONEY = 10000000000000.0;
|
||||
|
||||
@Override
|
||||
public double getMaxMoney()
|
||||
{
|
||||
double max = config.getDouble("max-money", MAXMONEY);
|
||||
if (Math.abs(max) > MAXMONEY)
|
||||
{
|
||||
max = max < 0 ? -MAXMONEY : MAXMONEY;
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEcoLogEnabled()
|
||||
{
|
||||
return config.getBoolean("economy-log-enabled", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeGodOnDisconnect()
|
||||
{
|
||||
return config.getBoolean("remove-god-on-disconnect", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean changeDisplayName()
|
||||
{
|
||||
return config.getBoolean("change-displayname", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useBukkitPermissions()
|
||||
{
|
||||
return config.getBoolean("use-bukkit-permissions", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPrefixSuffix()
|
||||
{
|
||||
return config.getBoolean("add-prefix-suffix", ess.getServer().getPluginManager().isPluginEnabled("EssentialsChat"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disablePrefix()
|
||||
{
|
||||
return config.getBoolean("disablePrefix", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableSuffix()
|
||||
{
|
||||
return config.getBoolean("disableSuffix", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAutoAfk()
|
||||
{
|
||||
return config.getLong("auto-afk", 300);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAutoAfkKick()
|
||||
{
|
||||
return config.getLong("auto-afk-kick", -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFreezeAfkPlayers()
|
||||
{
|
||||
return config.getBoolean("freeze-afk-players", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areDeathMessagesEnabled()
|
||||
{
|
||||
return config.getBoolean("death-messages", true);
|
||||
}
|
||||
Set<String> noGodWorlds = new HashSet<String>();
|
||||
|
||||
@Override
|
||||
public Set<String> getNoGodWorlds()
|
||||
{
|
||||
return noGodWorlds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDebug(final boolean debug)
|
||||
{
|
||||
this.debug = debug;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getRepairEnchanted()
|
||||
{
|
||||
return config.getBoolean("repair-enchanted", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsWorldTeleportPermissions()
|
||||
{
|
||||
return config.getBoolean("world-teleport-permissions", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean registerBackInListener()
|
||||
{
|
||||
return config.getBoolean("register-back-in-listener", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getDisableItemPickupWhileAfk()
|
||||
{
|
||||
return config.getBoolean("disable-item-pickup-while-afk", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Priority getRespawnPriority()
|
||||
{
|
||||
String priority = config.getString("respawn-listener-priority", "normal").toLowerCase(Locale.ENGLISH);
|
||||
if ("lowest".equals(priority))
|
||||
{
|
||||
return Priority.Lowest;
|
||||
}
|
||||
if ("low".equals(priority))
|
||||
{
|
||||
return Priority.Low;
|
||||
}
|
||||
if ("normal".equals(priority))
|
||||
{
|
||||
return Priority.Normal;
|
||||
}
|
||||
if ("high".equals(priority))
|
||||
{
|
||||
return Priority.High;
|
||||
}
|
||||
if ("highest".equals(priority))
|
||||
{
|
||||
return Priority.Highest;
|
||||
}
|
||||
return Priority.Normal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTpaAcceptCancellation()
|
||||
{
|
||||
return config.getLong("tpa-accept-cancellation", 0);
|
||||
}
|
||||
}
|
@@ -1,8 +1,13 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.ITeleport;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.ITeleport;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import com.earth2me.essentials.user.CooldownException;
|
||||
import com.earth2me.essentials.user.UserData.TimestampType;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.logging.Logger;
|
||||
@@ -112,7 +117,7 @@ public class Teleport implements Runnable, ITeleport
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
ess.showError(user.getBase(), ex, "teleport");
|
||||
ess.getCommandHandler().showCommandError(user.getBase(), "teleport", ex);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -139,30 +144,21 @@ public class Teleport implements Runnable, ITeleport
|
||||
|
||||
public void warp(String warp, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
Location loc = ess.getWarps().getWarp(warp);
|
||||
final Location loc = ess.getWarps().getWarp(warp);
|
||||
teleport(new Target(loc), chargeFor, cause);
|
||||
user.sendMessage(_("warpingTo", warp));
|
||||
}
|
||||
|
||||
public void cooldown(boolean check) throws Exception
|
||||
{
|
||||
Calendar now = new GregorianCalendar();
|
||||
if (user.getLastTeleportTimestamp() > 0)
|
||||
try
|
||||
{
|
||||
double cooldown = ess.getSettings().getTeleportCooldown();
|
||||
Calendar cooldownTime = new GregorianCalendar();
|
||||
cooldownTime.setTimeInMillis(user.getLastTeleportTimestamp());
|
||||
cooldownTime.add(Calendar.SECOND, (int)cooldown);
|
||||
cooldownTime.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0));
|
||||
if (cooldownTime.after(now) && !user.isAuthorized("essentials.teleport.cooldown.bypass"))
|
||||
{
|
||||
throw new Exception(_("timeBeforeTeleport", Util.formatDateDiff(cooldownTime.getTimeInMillis())));
|
||||
user.checkCooldown(TimestampType.LASTTELEPORT, ess.getGroups().getTeleportCooldown(user), !check, Permissions.TELEPORT_COOLDOWN_BYPASS);
|
||||
}
|
||||
}
|
||||
// if justCheck is set, don't update lastTeleport; we're just checking
|
||||
if (!check)
|
||||
catch (CooldownException ex)
|
||||
{
|
||||
user.setLastTeleportTimestamp(now.getTimeInMillis());
|
||||
throw new Exception(_("timeBeforeTeleport", ex.getMessage()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,14 +204,14 @@ public class Teleport implements Runnable, ITeleport
|
||||
|
||||
private void teleport(Target target, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
double delay = ess.getSettings().getTeleportDelay();
|
||||
double delay = ess.getGroups().getTeleportDelay(user);
|
||||
|
||||
if (chargeFor != null)
|
||||
{
|
||||
chargeFor.isAffordableFor(user);
|
||||
}
|
||||
cooldown(true);
|
||||
if (delay <= 0 || user.isAuthorized("essentials.teleport.timer.bypass"))
|
||||
if (delay <= 0 || Permissions.TELEPORT_TIMER_BYPASS.isAuthorized(user))
|
||||
{
|
||||
cooldown(false);
|
||||
now(target, cause);
|
||||
@@ -270,12 +266,28 @@ public class Teleport implements Runnable, ITeleport
|
||||
|
||||
public void back(Trade chargeFor) throws Exception
|
||||
{
|
||||
teleport(new Target(user.getLastLocation()), chargeFor, TeleportCause.COMMAND);
|
||||
user.acquireReadLock();
|
||||
try
|
||||
{
|
||||
teleport(new Target(user.getData().getLastLocation().getBukkitLocation()), chargeFor, TeleportCause.COMMAND);
|
||||
}
|
||||
finally
|
||||
{
|
||||
user.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void back() throws Exception
|
||||
{
|
||||
now(new Target(user.getLastLocation()), TeleportCause.COMMAND);
|
||||
user.acquireReadLock();
|
||||
try
|
||||
{
|
||||
now(new Target(user.getData().getLastLocation().getBukkitLocation()), TeleportCause.COMMAND);
|
||||
}
|
||||
finally
|
||||
{
|
||||
user.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void home(IUser user, String home, Trade chargeFor) throws Exception
|
||||
|
@@ -1,8 +1,14 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.ChargeException;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.ISettings;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import com.earth2me.essentials.craftbukkit.SetExpFix;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.perm.NoCommandCostPermissions;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
@@ -12,7 +18,9 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
@@ -59,7 +67,7 @@ public class Trade
|
||||
if (getMoney() != null
|
||||
&& mon < getMoney()
|
||||
&& getMoney() > 0
|
||||
&& !user.isAuthorized("essentials.eco.loan"))
|
||||
&& !Permissions.ECO_LOAN.isAuthorized(user))
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
@@ -70,18 +78,22 @@ public class Trade
|
||||
throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " ")));
|
||||
}
|
||||
|
||||
@Cleanup
|
||||
final ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
|
||||
if (command != null && !command.isEmpty()
|
||||
&& !user.isAuthorized("essentials.nocommandcost.all")
|
||||
&& !user.isAuthorized("essentials.nocommandcost." + command)
|
||||
&& mon < ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command)
|
||||
&& 0 < ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command)
|
||||
&& !user.isAuthorized("essentials.eco.loan"))
|
||||
&& !NoCommandCostPermissions.getPermission(command).isAuthorized(user)
|
||||
&& mon < settings.getData().getEconomy().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command)
|
||||
&& 0 < settings.getData().getEconomy().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command)
|
||||
&& !Permissions.ECO_LOAN.isAuthorized(user))
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
|
||||
if (exp != null && exp > 0
|
||||
&& SetExpFix.getTotalExperience(user) < exp) {
|
||||
&& SetExpFix.getTotalExperience(user) < exp)
|
||||
{
|
||||
throw new ChargeException(_("notEnoughExperience"));
|
||||
}
|
||||
}
|
||||
@@ -103,9 +115,25 @@ public class Trade
|
||||
if (dropItems)
|
||||
{
|
||||
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItem(user.getInventory(), true, getItemStack());
|
||||
for (ItemStack itemStack : leftOver.values())
|
||||
final Location loc = user.getLocation();
|
||||
for (ItemStack dropStack : leftOver.values())
|
||||
{
|
||||
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
|
||||
final int maxStackSize = dropStack.getType().getMaxStackSize();
|
||||
final int stacks = dropStack.getAmount() / maxStackSize;
|
||||
final int leftover = dropStack.getAmount() % maxStackSize;
|
||||
final Item[] itemStacks = new Item[stacks + (leftover > 0 ? 1 : 0)];
|
||||
for (int i = 0; i < stacks; i++)
|
||||
{
|
||||
final ItemStack stack = dropStack.clone();
|
||||
stack.setAmount(maxStackSize);
|
||||
itemStacks[i] = loc.getWorld().dropItem(loc, stack);
|
||||
}
|
||||
if (leftover > 0)
|
||||
{
|
||||
final ItemStack stack = dropStack.clone();
|
||||
stack.setAmount(leftover);
|
||||
itemStacks[stacks] = loc.getWorld().dropItem(loc, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -126,7 +154,7 @@ public class Trade
|
||||
if (getMoney() != null)
|
||||
{
|
||||
final double mon = user.getMoney();
|
||||
if (mon < getMoney() && getMoney() > 0 && !user.isAuthorized("essentials.eco.loan"))
|
||||
if (mon < getMoney() && getMoney() > 0 && !Permissions.ECO_LOAN.isAuthorized(user))
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
@@ -142,12 +170,14 @@ public class Trade
|
||||
user.updateInventory();
|
||||
}
|
||||
if (command != null && !command.isEmpty()
|
||||
&& !user.isAuthorized("essentials.nocommandcost.all")
|
||||
&& !user.isAuthorized("essentials.nocommandcost." + command))
|
||||
&& !NoCommandCostPermissions.getPermission(command).isAuthorized(user))
|
||||
{
|
||||
@Cleanup
|
||||
final ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
final double mon = user.getMoney();
|
||||
final double cost = ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command);
|
||||
if (mon < cost && cost > 0 && !user.isAuthorized("essentials.eco.loan"))
|
||||
final double cost = settings.getData().getEconomy().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command);
|
||||
if (mon < cost && cost > 0 && !Permissions.ECO_LOAN.isAuthorized(user))
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
@@ -182,7 +212,10 @@ public class Trade
|
||||
|
||||
public static void log(String type, String subtype, String event, String sender, Trade charge, String receiver, Trade pay, Location loc, IEssentials ess)
|
||||
{
|
||||
if (!ess.getSettings().isEcoLogEnabled())
|
||||
@Cleanup
|
||||
final ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
if (!settings.getData().getEconomy().isLogEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -222,7 +255,7 @@ public class Trade
|
||||
{
|
||||
sb.append(charge.getMoney()).append(",");
|
||||
sb.append("money").append(",");
|
||||
sb.append(ess.getSettings().getCurrencySymbol());
|
||||
sb.append(settings.getData().getEconomy().getCurrencySymbol());
|
||||
}
|
||||
if (charge.getExperience() != null)
|
||||
{
|
||||
@@ -253,7 +286,7 @@ public class Trade
|
||||
{
|
||||
sb.append(pay.getMoney()).append(",");
|
||||
sb.append("money").append(",");
|
||||
sb.append(ess.getSettings().getCurrencySymbol());
|
||||
sb.append(settings.getData().getEconomy().getCurrencySymbol());
|
||||
}
|
||||
if (pay.getExperience() != null)
|
||||
{
|
||||
|
@@ -1,547 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
{
|
||||
private CommandSender replyTo = null;
|
||||
private transient User teleportRequester;
|
||||
private transient boolean teleportRequestHere;
|
||||
private transient final Teleport teleport;
|
||||
private transient long teleportRequestTime;
|
||||
private transient long lastOnlineActivity;
|
||||
private transient long lastActivity = System.currentTimeMillis();
|
||||
private boolean hidden = false;
|
||||
private transient Location afkPosition;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
User(final Player base, final IEssentials ess)
|
||||
{
|
||||
super(base, ess);
|
||||
teleport = new Teleport(this, ess);
|
||||
afkPosition = getLocation();
|
||||
}
|
||||
|
||||
User update(final Player base)
|
||||
{
|
||||
setBase(base);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuthorized(final IEssentialsCommand cmd)
|
||||
{
|
||||
return isAuthorized(cmd, "essentials.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuthorized(final IEssentialsCommand cmd, final String permissionPrefix)
|
||||
{
|
||||
return isAuthorized(permissionPrefix + (cmd.getName().equals("r") ? "msg" : cmd.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuthorized(final String node)
|
||||
{
|
||||
if (base instanceof OfflinePlayer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isOp())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isJailed())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return ess.getPermissionsHandler().hasPermission(base, node);
|
||||
}
|
||||
|
||||
public void healCooldown() throws Exception
|
||||
{
|
||||
final Calendar now = new GregorianCalendar();
|
||||
if (getLastHealTimestamp() > 0)
|
||||
{
|
||||
final double cooldown = ess.getSettings().getHealCooldown();
|
||||
final Calendar cooldownTime = new GregorianCalendar();
|
||||
cooldownTime.setTimeInMillis(getLastHealTimestamp());
|
||||
cooldownTime.add(Calendar.SECOND, (int)cooldown);
|
||||
cooldownTime.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0));
|
||||
if (cooldownTime.after(now) && !isAuthorized("essentials.heal.cooldown.bypass"))
|
||||
{
|
||||
throw new Exception(_("timeBeforeHeal", Util.formatDateDiff(cooldownTime.getTimeInMillis())));
|
||||
}
|
||||
}
|
||||
setLastHealTimestamp(now.getTimeInMillis());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveMoney(final double value)
|
||||
{
|
||||
giveMoney(value, null);
|
||||
}
|
||||
|
||||
public void giveMoney(final double value, final CommandSender initiator)
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
setMoney(getMoney() + value);
|
||||
sendMessage(_("addedToAccount", Util.formatCurrency(value, ess)));
|
||||
if (initiator != null)
|
||||
{
|
||||
initiator.sendMessage(_("addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
||||
public void payUser(final User reciever, final double value) throws Exception
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (canAfford(value))
|
||||
{
|
||||
setMoney(getMoney() - value);
|
||||
reciever.setMoney(reciever.getMoney() + value);
|
||||
sendMessage(_("moneySentTo", Util.formatCurrency(value, ess), reciever.getDisplayName()));
|
||||
reciever.sendMessage(_("moneyRecievedFrom", Util.formatCurrency(value, ess), getDisplayName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(_("notEnoughMoney"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void takeMoney(final double value)
|
||||
{
|
||||
takeMoney(value, null);
|
||||
}
|
||||
|
||||
public void takeMoney(final double value, final CommandSender initiator)
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
setMoney(getMoney() - value);
|
||||
sendMessage(_("takenFromAccount", Util.formatCurrency(value, ess)));
|
||||
if (initiator != null)
|
||||
{
|
||||
initiator.sendMessage(_("takenFromOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canAfford(final double cost)
|
||||
{
|
||||
final double mon = getMoney();
|
||||
return mon >= cost || isAuthorized("essentials.eco.loan");
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
this.base = new OfflinePlayer(getName(), ess);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReplyTo(final CommandSender user)
|
||||
{
|
||||
replyTo = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSender getReplyTo()
|
||||
{
|
||||
return replyTo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(final User other)
|
||||
{
|
||||
return Util.stripColor(this.getDisplayName()).compareToIgnoreCase(Util.stripColor(other.getDisplayName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object object)
|
||||
{
|
||||
if (!(object instanceof User))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return this.getName().equalsIgnoreCase(((User)object).getName());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return this.getName().hashCode();
|
||||
}
|
||||
|
||||
public Boolean canSpawnItem(final int itemId)
|
||||
{
|
||||
return !ess.getSettings().itemSpawnBlacklist().contains(itemId);
|
||||
}
|
||||
|
||||
public Location getHome() throws Exception
|
||||
{
|
||||
return getHome(getHomes().get(0));
|
||||
}
|
||||
|
||||
public void setHome()
|
||||
{
|
||||
setHome("home", getLocation());
|
||||
}
|
||||
|
||||
public void setHome(final String name)
|
||||
{
|
||||
setHome(name, getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastLocation()
|
||||
{
|
||||
setLastLocation(getLocation());
|
||||
}
|
||||
|
||||
public void requestTeleport(final User player, final boolean here)
|
||||
{
|
||||
teleportRequestTime = System.currentTimeMillis();
|
||||
teleportRequester = player;
|
||||
teleportRequestHere = here;
|
||||
}
|
||||
|
||||
public User getTeleportRequest()
|
||||
{
|
||||
return teleportRequester;
|
||||
}
|
||||
|
||||
public boolean isTeleportRequestHere()
|
||||
{
|
||||
return teleportRequestHere;
|
||||
}
|
||||
|
||||
public String getNick(boolean addprefixsuffix)
|
||||
{
|
||||
final StringBuilder nickname = new StringBuilder();
|
||||
final String nick = getNickname();
|
||||
if (ess.getSettings().isCommandDisabled("nick") || nick == null || nick.isEmpty() || nick.equals(getName()))
|
||||
{
|
||||
nickname.append(getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
nickname.append(ess.getSettings().getNicknamePrefix()).append(nick);
|
||||
}
|
||||
if (isOp())
|
||||
{
|
||||
try
|
||||
{
|
||||
nickname.insert(0, ess.getSettings().getOperatorColor().toString());
|
||||
nickname.append("§f");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (addprefixsuffix && ess.getSettings().addPrefixSuffix())
|
||||
{
|
||||
if (!ess.getSettings().disablePrefix())
|
||||
{
|
||||
final String prefix = ess.getPermissionsHandler().getPrefix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
||||
nickname.insert(0, prefix);
|
||||
}
|
||||
if (!ess.getSettings().disableSuffix())
|
||||
{
|
||||
final String suffix = ess.getPermissionsHandler().getSuffix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
||||
nickname.append(suffix);
|
||||
if (suffix.length() < 2 || !suffix.substring(suffix.length() - 2, suffix.length() - 1).equals("§"))
|
||||
{
|
||||
nickname.append("§f");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nickname.append("§f");
|
||||
}
|
||||
}
|
||||
|
||||
return nickname.toString();
|
||||
}
|
||||
|
||||
public void setDisplayNick()
|
||||
{
|
||||
String name = getNick(true);
|
||||
setDisplayName(name);
|
||||
if (name.length() > 16)
|
||||
{
|
||||
name = getNick(false);
|
||||
}
|
||||
if (name.length() > 16)
|
||||
{
|
||||
name = name.substring(0, name.charAt(15) == '§' ? 15 : 16);
|
||||
}
|
||||
try
|
||||
{
|
||||
setPlayerListName(name);
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
logger.log(Level.INFO, "Playerlist for " + name + " was not updated. Use a shorter displayname prefix.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
if (!(base instanceof OfflinePlayer) && ess.getSettings().changeDisplayName())
|
||||
{
|
||||
setDisplayNick();
|
||||
}
|
||||
return super.getDisplayName() == null ? super.getName() : super.getDisplayName();
|
||||
}
|
||||
|
||||
public Teleport getTeleport()
|
||||
{
|
||||
return teleport;
|
||||
}
|
||||
|
||||
public long getLastOnlineActivity()
|
||||
{
|
||||
return lastOnlineActivity;
|
||||
}
|
||||
|
||||
public void setLastOnlineActivity(final long timestamp)
|
||||
{
|
||||
lastOnlineActivity = timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMoney()
|
||||
{
|
||||
if (ess.getPaymentMethod().hasMethod())
|
||||
{
|
||||
try
|
||||
{
|
||||
final Method method = ess.getPaymentMethod().getMethod();
|
||||
if (!method.hasAccount(this.getName()))
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
||||
return account.balance();
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
return super.getMoney();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMoney(final double value)
|
||||
{
|
||||
if (ess.getPaymentMethod().hasMethod())
|
||||
{
|
||||
try
|
||||
{
|
||||
final Method method = ess.getPaymentMethod().getMethod();
|
||||
if (!method.hasAccount(this.getName()))
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
||||
account.set(value);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
super.setMoney(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAfk(final boolean set)
|
||||
{
|
||||
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
|
||||
if (set && !isAfk())
|
||||
{
|
||||
afkPosition = getLocation();
|
||||
}
|
||||
super.setAfk(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toggleAfk()
|
||||
{
|
||||
final boolean now = super.toggleAfk();
|
||||
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : now);
|
||||
return now;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHidden()
|
||||
{
|
||||
return hidden;
|
||||
}
|
||||
|
||||
public void setHidden(final boolean hidden)
|
||||
{
|
||||
this.hidden = hidden;
|
||||
}
|
||||
|
||||
//Returns true if status expired during this check
|
||||
public boolean checkJailTimeout(final long currentTime)
|
||||
{
|
||||
if (getJailTimeout() > 0 && getJailTimeout() < currentTime && isJailed())
|
||||
{
|
||||
setJailTimeout(0);
|
||||
setJailed(false);
|
||||
sendMessage(_("haveBeenReleased"));
|
||||
setJail(null);
|
||||
try
|
||||
{
|
||||
getTeleport().back();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//Returns true if status expired during this check
|
||||
public boolean checkMuteTimeout(final long currentTime)
|
||||
{
|
||||
if (getMuteTimeout() > 0 && getMuteTimeout() < currentTime && isMuted())
|
||||
{
|
||||
setMuteTimeout(0);
|
||||
sendMessage(_("canTalkAgain"));
|
||||
setMuted(false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//Returns true if status expired during this check
|
||||
public boolean checkBanTimeout(final long currentTime)
|
||||
{
|
||||
if (getBanTimeout() > 0 && getBanTimeout() < currentTime && isBanned())
|
||||
{
|
||||
setBanTimeout(0);
|
||||
setBanned(false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void updateActivity(final boolean broadcast)
|
||||
{
|
||||
if (isAfk())
|
||||
{
|
||||
setAfk(false);
|
||||
if (broadcast && !isHidden())
|
||||
{
|
||||
ess.broadcastMessage(this, _("userIsNotAway", getDisplayName()));
|
||||
}
|
||||
}
|
||||
lastActivity = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void checkActivity()
|
||||
{
|
||||
final long autoafkkick = ess.getSettings().getAutoAfkKick();
|
||||
if (autoafkkick > 0 && lastActivity > 0 && (lastActivity + (autoafkkick * 1000)) < System.currentTimeMillis()
|
||||
&& !isHidden() && !isAuthorized("essentials.kick.exempt") && !isAuthorized("essentials.afk.kickexempt"))
|
||||
{
|
||||
final String kickReason = _("autoAfkKickReason", autoafkkick / 60.0);
|
||||
lastActivity = 0;
|
||||
kickPlayer(kickReason);
|
||||
|
||||
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
final User user = ess.getUser(player);
|
||||
if (user.isAuthorized("essentials.kick.notify"))
|
||||
{
|
||||
player.sendMessage(_("playerKicked", Console.NAME, getName(), kickReason));
|
||||
}
|
||||
}
|
||||
}
|
||||
final long autoafk = ess.getSettings().getAutoAfk();
|
||||
if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis() && isAuthorized("essentials.afk"))
|
||||
{
|
||||
setAfk(true);
|
||||
if (!isHidden())
|
||||
{
|
||||
ess.broadcastMessage(this, _("userIsAway", getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Location getAfkPosition()
|
||||
{
|
||||
return afkPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toggleGodModeEnabled()
|
||||
{
|
||||
if (!isGodModeEnabled())
|
||||
{
|
||||
setFoodLevel(20);
|
||||
}
|
||||
return super.toggleGodModeEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGodModeEnabled()
|
||||
{
|
||||
return (super.isGodModeEnabled() && !ess.getSettings().getNoGodWorlds().contains(getLocation().getWorld().getName()))
|
||||
|| (isAfk() && ess.getSettings().getFreezeAfkPlayers());
|
||||
}
|
||||
|
||||
public boolean isGodModeEnabledRaw()
|
||||
{
|
||||
return super.isGodModeEnabled();
|
||||
}
|
||||
|
||||
public String getGroup()
|
||||
{
|
||||
return ess.getPermissionsHandler().getGroup(base);
|
||||
}
|
||||
|
||||
public boolean inGroup(final String group)
|
||||
{
|
||||
return ess.getPermissionsHandler().inGroup(base, group);
|
||||
}
|
||||
|
||||
public boolean canBuild()
|
||||
{
|
||||
return ess.getPermissionsHandler().canBuild(base, getGroup());
|
||||
}
|
||||
|
||||
public long getTeleportRequestTime()
|
||||
{
|
||||
return teleportRequestTime;
|
||||
}
|
||||
}
|
@@ -1,875 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public abstract class UserData extends PlayerExtension implements IConf
|
||||
{
|
||||
protected final transient IEssentials ess;
|
||||
private final EssentialsConf config;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
protected UserData(Player base, IEssentials ess)
|
||||
{
|
||||
super(base);
|
||||
this.ess = ess;
|
||||
File folder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!folder.exists())
|
||||
{
|
||||
folder.mkdirs();
|
||||
}
|
||||
config = new EssentialsConf(new File(folder, Util.sanitizeFileName(base.getName()) + ".yml"));
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void reloadConfig()
|
||||
{
|
||||
config.load();
|
||||
money = _getMoney();
|
||||
unlimited = _getUnlimited();
|
||||
powertools = _getPowertools();
|
||||
homes = _getHomes();
|
||||
lastLocation = _getLastLocation();
|
||||
lastTeleportTimestamp = _getLastTeleportTimestamp();
|
||||
lastHealTimestamp = _getLastHealTimestamp();
|
||||
jail = _getJail();
|
||||
mails = _getMails();
|
||||
savedInventory = _getSavedInventory();
|
||||
teleportEnabled = getTeleportEnabled();
|
||||
ignoredPlayers = getIgnoredPlayers();
|
||||
godmode = getGodModeEnabled();
|
||||
muted = getMuted();
|
||||
muteTimeout = _getMuteTimeout();
|
||||
jailed = getJailed();
|
||||
jailTimeout = _getJailTimeout();
|
||||
lastLogin = _getLastLogin();
|
||||
lastLogout = _getLastLogout();
|
||||
lastLoginAddress = _getLastLoginAddress();
|
||||
afk = getAfk();
|
||||
newplayer = getNew();
|
||||
geolocation = _getGeoLocation();
|
||||
isSocialSpyEnabled = _isSocialSpyEnabled();
|
||||
isNPC = _isNPC();
|
||||
arePowerToolsEnabled = _arePowerToolsEnabled();
|
||||
kitTimestamps = _getKitTimestamps();
|
||||
}
|
||||
private double money;
|
||||
|
||||
private double _getMoney()
|
||||
{
|
||||
double money = ess.getSettings().getStartingBalance();
|
||||
if (config.hasProperty("money"))
|
||||
{
|
||||
money = config.getDouble("money", money);
|
||||
}
|
||||
if (Math.abs(money) > ess.getSettings().getMaxMoney())
|
||||
{
|
||||
money = money < 0 ? -ess.getSettings().getMaxMoney() : ess.getSettings().getMaxMoney();
|
||||
}
|
||||
return money;
|
||||
}
|
||||
|
||||
public double getMoney()
|
||||
{
|
||||
return money;
|
||||
}
|
||||
|
||||
public void setMoney(double value)
|
||||
{
|
||||
money = value;
|
||||
if (Math.abs(money) > ess.getSettings().getMaxMoney())
|
||||
{
|
||||
money = money < 0 ? -ess.getSettings().getMaxMoney() : ess.getSettings().getMaxMoney();
|
||||
}
|
||||
config.setProperty("money", value);
|
||||
config.save();
|
||||
}
|
||||
private Map<String, Object> homes;
|
||||
|
||||
private Map<String, Object> _getHomes()
|
||||
{
|
||||
Object o = config.getProperty("homes");
|
||||
|
||||
if (o instanceof Map)
|
||||
{
|
||||
return (Map<String, Object>)o;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Location getHome(String name) throws Exception
|
||||
{
|
||||
Location loc = config.getLocation("homes." + name, getServer());
|
||||
if (loc == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
loc = config.getLocation("homes." + getHomes().get(Integer.parseInt(name) - 1), getServer());
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return loc;
|
||||
}
|
||||
|
||||
public Location getHome(final Location world)
|
||||
{
|
||||
try
|
||||
{
|
||||
Location loc;
|
||||
for (String home : getHomes())
|
||||
{
|
||||
loc = config.getLocation("homes." + home, getServer());
|
||||
if (world.getWorld() == loc.getWorld())
|
||||
{
|
||||
return loc;
|
||||
}
|
||||
|
||||
}
|
||||
loc = config.getLocation("homes." + getHomes().get(0), getServer());
|
||||
return loc;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getHomes()
|
||||
{
|
||||
return new ArrayList(homes.keySet());
|
||||
}
|
||||
|
||||
public void setHome(String name, Location loc)
|
||||
{
|
||||
//Invalid names will corrupt the yaml
|
||||
name = Util.sanitizeFileName(name);
|
||||
homes.put(name, loc);
|
||||
config.setProperty("homes." + name, loc);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public void delHome(String name) throws Exception
|
||||
{
|
||||
String search = name;
|
||||
if (!homes.containsKey(search))
|
||||
{
|
||||
search = Util.sanitizeFileName(name);
|
||||
}
|
||||
if (homes.containsKey(search))
|
||||
{
|
||||
homes.remove(name);
|
||||
config.removeProperty("homes." + name);
|
||||
config.save();
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO: move this message to messages file
|
||||
throw new Exception("Home " + name + " doesn't exist");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasHome()
|
||||
{
|
||||
if (config.hasProperty("home"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getNickname()
|
||||
{
|
||||
return config.getString("nickname");
|
||||
}
|
||||
|
||||
public void setNickname(String nick)
|
||||
{
|
||||
config.setProperty("nickname", nick);
|
||||
config.save();
|
||||
}
|
||||
private List<Integer> unlimited;
|
||||
|
||||
private List<Integer> _getUnlimited()
|
||||
{
|
||||
return config.getIntList("unlimited", new ArrayList<Integer>());
|
||||
}
|
||||
|
||||
public List<Integer> getUnlimited()
|
||||
{
|
||||
return unlimited;
|
||||
}
|
||||
|
||||
public boolean hasUnlimited(ItemStack stack)
|
||||
{
|
||||
return unlimited.contains(stack.getTypeId());
|
||||
}
|
||||
|
||||
public void setUnlimited(ItemStack stack, boolean state)
|
||||
{
|
||||
if (unlimited.contains(stack.getTypeId()))
|
||||
{
|
||||
unlimited.remove(Integer.valueOf(stack.getTypeId()));
|
||||
}
|
||||
if (state)
|
||||
{
|
||||
unlimited.add(stack.getTypeId());
|
||||
}
|
||||
config.setProperty("unlimited", unlimited);
|
||||
config.save();
|
||||
}
|
||||
private Map<Integer, Object> powertools;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<Integer, Object> _getPowertools()
|
||||
{
|
||||
Object o = config.getProperty("powertools");
|
||||
|
||||
if (o instanceof Map)
|
||||
{
|
||||
return (Map<Integer, Object>)o;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new HashMap<Integer, Object>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void clearAllPowertools()
|
||||
{
|
||||
powertools.clear();
|
||||
config.setProperty("powertools", powertools);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public List<String> getPowertool(ItemStack stack)
|
||||
{
|
||||
return (List<String>)powertools.get(stack.getTypeId());
|
||||
}
|
||||
|
||||
public void setPowertool(ItemStack stack, List<String> commandList)
|
||||
{
|
||||
if (commandList == null || commandList.isEmpty())
|
||||
{
|
||||
powertools.remove(stack.getTypeId());
|
||||
}
|
||||
else
|
||||
{
|
||||
powertools.put(stack.getTypeId(), commandList);
|
||||
}
|
||||
config.setProperty("powertools", powertools);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean hasPowerTools()
|
||||
{
|
||||
return !powertools.isEmpty();
|
||||
}
|
||||
private Location lastLocation;
|
||||
|
||||
private Location _getLastLocation()
|
||||
{
|
||||
try
|
||||
{
|
||||
return config.getLocation("lastlocation", getServer());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Location getLastLocation()
|
||||
{
|
||||
return lastLocation;
|
||||
}
|
||||
|
||||
public void setLastLocation(Location loc)
|
||||
{
|
||||
if (loc == null || loc.getWorld() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
lastLocation = loc;
|
||||
config.setProperty("lastlocation", loc);
|
||||
config.save();
|
||||
}
|
||||
private long lastTeleportTimestamp;
|
||||
|
||||
private long _getLastTeleportTimestamp()
|
||||
{
|
||||
return config.getLong("timestamps.lastteleport", 0);
|
||||
}
|
||||
|
||||
public long getLastTeleportTimestamp()
|
||||
{
|
||||
return lastTeleportTimestamp;
|
||||
}
|
||||
|
||||
public void setLastTeleportTimestamp(long time)
|
||||
{
|
||||
lastTeleportTimestamp = time;
|
||||
config.setProperty("timestamps.lastteleport", time);
|
||||
config.save();
|
||||
}
|
||||
private long lastHealTimestamp;
|
||||
|
||||
private long _getLastHealTimestamp()
|
||||
{
|
||||
return config.getLong("timestamps.lastheal", 0);
|
||||
}
|
||||
|
||||
public long getLastHealTimestamp()
|
||||
{
|
||||
return lastHealTimestamp;
|
||||
}
|
||||
|
||||
public void setLastHealTimestamp(long time)
|
||||
{
|
||||
lastHealTimestamp = time;
|
||||
config.setProperty("timestamps.lastheal", time);
|
||||
config.save();
|
||||
}
|
||||
private String jail;
|
||||
|
||||
private String _getJail()
|
||||
{
|
||||
return config.getString("jail");
|
||||
}
|
||||
|
||||
public String getJail()
|
||||
{
|
||||
return jail;
|
||||
}
|
||||
|
||||
public void setJail(String jail)
|
||||
{
|
||||
if (jail == null || jail.isEmpty())
|
||||
{
|
||||
this.jail = null;
|
||||
config.removeProperty("jail");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.jail = jail;
|
||||
config.setProperty("jail", jail);
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
private List<String> mails;
|
||||
|
||||
private List<String> _getMails()
|
||||
{
|
||||
return config.getStringList("mail", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public List<String> getMails()
|
||||
{
|
||||
return mails;
|
||||
}
|
||||
|
||||
public void setMails(List<String> mails)
|
||||
{
|
||||
if (mails == null)
|
||||
{
|
||||
config.removeProperty("mail");
|
||||
mails = _getMails();
|
||||
}
|
||||
else
|
||||
{
|
||||
config.setProperty("mail", mails);
|
||||
}
|
||||
this.mails = mails;
|
||||
config.save();
|
||||
}
|
||||
|
||||
public void addMail(String mail)
|
||||
{
|
||||
mails.add(mail);
|
||||
setMails(mails);
|
||||
}
|
||||
private ItemStack[] savedInventory;
|
||||
|
||||
public ItemStack[] getSavedInventory()
|
||||
{
|
||||
return savedInventory;
|
||||
}
|
||||
|
||||
private ItemStack[] _getSavedInventory()
|
||||
{
|
||||
int size = config.getInt("inventory.size", 0);
|
||||
if (size < 1 || (getInventory() != null && size > getInventory().getSize()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
ItemStack[] is = new ItemStack[size];
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
is[i] = config.getItemStack("inventory." + i);
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
public void setSavedInventory(ItemStack[] is)
|
||||
{
|
||||
if (is == null || is.length == 0)
|
||||
{
|
||||
savedInventory = null;
|
||||
config.removeProperty("inventory");
|
||||
}
|
||||
else
|
||||
{
|
||||
savedInventory = is;
|
||||
config.setProperty("inventory.size", is.length);
|
||||
for (int i = 0; i < is.length; i++)
|
||||
{
|
||||
if (is[i] == null || is[i].getType() == Material.AIR)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
config.setProperty("inventory." + i, is[i]);
|
||||
}
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
private boolean teleportEnabled;
|
||||
|
||||
private boolean getTeleportEnabled()
|
||||
{
|
||||
return config.getBoolean("teleportenabled", true);
|
||||
}
|
||||
|
||||
public boolean isTeleportEnabled()
|
||||
{
|
||||
return teleportEnabled;
|
||||
}
|
||||
|
||||
public void setTeleportEnabled(boolean set)
|
||||
{
|
||||
teleportEnabled = set;
|
||||
config.setProperty("teleportenabled", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean toggleTeleportEnabled()
|
||||
{
|
||||
boolean ret = !isTeleportEnabled();
|
||||
setTeleportEnabled(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public boolean toggleSocialSpy()
|
||||
{
|
||||
boolean ret = !isSocialSpyEnabled();
|
||||
setSocialSpyEnabled(ret);
|
||||
return ret;
|
||||
}
|
||||
private List<String> ignoredPlayers;
|
||||
|
||||
public List<String> getIgnoredPlayers()
|
||||
{
|
||||
return config.getStringList("ignore", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public void setIgnoredPlayers(List<String> players)
|
||||
{
|
||||
if (players == null || players.isEmpty())
|
||||
{
|
||||
ignoredPlayers = new ArrayList<String>();
|
||||
config.removeProperty("ignore");
|
||||
}
|
||||
else
|
||||
{
|
||||
ignoredPlayers = players;
|
||||
config.setProperty("ignore", players);
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean isIgnoredPlayer(String name)
|
||||
{
|
||||
return ignoredPlayers.contains(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public void setIgnoredPlayer(String name, boolean set)
|
||||
{
|
||||
if (set)
|
||||
{
|
||||
ignoredPlayers.add(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
else
|
||||
{
|
||||
ignoredPlayers.remove(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
setIgnoredPlayers(ignoredPlayers);
|
||||
}
|
||||
private boolean godmode;
|
||||
|
||||
private boolean getGodModeEnabled()
|
||||
{
|
||||
return config.getBoolean("godmode", false);
|
||||
}
|
||||
|
||||
public boolean isGodModeEnabled()
|
||||
{
|
||||
return godmode;
|
||||
}
|
||||
|
||||
public void setGodModeEnabled(boolean set)
|
||||
{
|
||||
godmode = set;
|
||||
config.setProperty("godmode", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean toggleGodModeEnabled()
|
||||
{
|
||||
boolean ret = !isGodModeEnabled();
|
||||
setGodModeEnabled(ret);
|
||||
return ret;
|
||||
}
|
||||
private boolean muted;
|
||||
|
||||
private boolean getMuted()
|
||||
{
|
||||
return config.getBoolean("muted", false);
|
||||
}
|
||||
|
||||
public boolean isMuted()
|
||||
{
|
||||
return muted;
|
||||
}
|
||||
|
||||
public void setMuted(boolean set)
|
||||
{
|
||||
muted = set;
|
||||
config.setProperty("muted", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean toggleMuted()
|
||||
{
|
||||
boolean ret = !isMuted();
|
||||
setMuted(ret);
|
||||
return ret;
|
||||
}
|
||||
private long muteTimeout;
|
||||
|
||||
private long _getMuteTimeout()
|
||||
{
|
||||
return config.getLong("timestamps.mute", 0);
|
||||
}
|
||||
|
||||
public long getMuteTimeout()
|
||||
{
|
||||
return muteTimeout;
|
||||
}
|
||||
|
||||
public void setMuteTimeout(long time)
|
||||
{
|
||||
muteTimeout = time;
|
||||
config.setProperty("timestamps.mute", time);
|
||||
config.save();
|
||||
}
|
||||
private boolean jailed;
|
||||
|
||||
private boolean getJailed()
|
||||
{
|
||||
return config.getBoolean("jailed", false);
|
||||
}
|
||||
|
||||
public boolean isJailed()
|
||||
{
|
||||
return jailed;
|
||||
}
|
||||
|
||||
public void setJailed(boolean set)
|
||||
{
|
||||
jailed = set;
|
||||
config.setProperty("jailed", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean toggleJailed()
|
||||
{
|
||||
boolean ret = !isJailed();
|
||||
setJailed(ret);
|
||||
return ret;
|
||||
}
|
||||
private long jailTimeout;
|
||||
|
||||
private long _getJailTimeout()
|
||||
{
|
||||
return config.getLong("timestamps.jail", 0);
|
||||
}
|
||||
|
||||
public long getJailTimeout()
|
||||
{
|
||||
return jailTimeout;
|
||||
}
|
||||
|
||||
public void setJailTimeout(long time)
|
||||
{
|
||||
jailTimeout = time;
|
||||
config.setProperty("timestamps.jail", time);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public String getBanReason()
|
||||
{
|
||||
return config.getString("ban.reason");
|
||||
}
|
||||
|
||||
public void setBanReason(String reason)
|
||||
{
|
||||
config.setProperty("ban.reason", reason);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public long getBanTimeout()
|
||||
{
|
||||
return config.getLong("ban.timeout", 0);
|
||||
}
|
||||
|
||||
public void setBanTimeout(long time)
|
||||
{
|
||||
config.setProperty("ban.timeout", time);
|
||||
config.save();
|
||||
}
|
||||
private long lastLogin;
|
||||
|
||||
private long _getLastLogin()
|
||||
{
|
||||
return config.getLong("timestamps.login", 0);
|
||||
}
|
||||
|
||||
public long getLastLogin()
|
||||
{
|
||||
return lastLogin;
|
||||
}
|
||||
|
||||
public void setLastLogin(long time)
|
||||
{
|
||||
lastLogin = time;
|
||||
config.setProperty("timestamps.login", time);
|
||||
config.save();
|
||||
}
|
||||
private long lastLogout;
|
||||
|
||||
private long _getLastLogout()
|
||||
{
|
||||
return config.getLong("timestamps.logout", 0);
|
||||
}
|
||||
|
||||
public long getLastLogout()
|
||||
{
|
||||
return lastLogout;
|
||||
}
|
||||
|
||||
public void setLastLogout(long time)
|
||||
{
|
||||
lastLogout = time;
|
||||
config.setProperty("timestamps.logout", time);
|
||||
config.save();
|
||||
}
|
||||
private String lastLoginAddress;
|
||||
|
||||
private String _getLastLoginAddress()
|
||||
{
|
||||
return config.getString("ipAddress", "");
|
||||
}
|
||||
|
||||
public String getLastLoginAddress()
|
||||
{
|
||||
return lastLoginAddress;
|
||||
}
|
||||
|
||||
public void setLastLoginAddress(String address)
|
||||
{
|
||||
lastLoginAddress = address;
|
||||
config.setProperty("ipAddress", address);
|
||||
config.save();
|
||||
}
|
||||
private boolean afk;
|
||||
|
||||
private boolean getAfk()
|
||||
{
|
||||
return config.getBoolean("afk", false);
|
||||
}
|
||||
|
||||
public boolean isAfk()
|
||||
{
|
||||
return afk;
|
||||
}
|
||||
|
||||
public void setAfk(boolean set)
|
||||
{
|
||||
afk = set;
|
||||
config.setProperty("afk", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean toggleAfk()
|
||||
{
|
||||
boolean ret = !isAfk();
|
||||
setAfk(ret);
|
||||
return ret;
|
||||
}
|
||||
private boolean newplayer;
|
||||
|
||||
private boolean getNew()
|
||||
{
|
||||
return config.getBoolean("newplayer", true);
|
||||
}
|
||||
|
||||
public boolean isNew()
|
||||
{
|
||||
return newplayer;
|
||||
}
|
||||
|
||||
public void setNew(boolean set)
|
||||
{
|
||||
newplayer = set;
|
||||
config.setProperty("newplayer", set);
|
||||
config.save();
|
||||
}
|
||||
private String geolocation;
|
||||
|
||||
private String _getGeoLocation()
|
||||
{
|
||||
return config.getString("geolocation");
|
||||
}
|
||||
|
||||
public String getGeoLocation()
|
||||
{
|
||||
return geolocation;
|
||||
}
|
||||
|
||||
public void setGeoLocation(String geolocation)
|
||||
{
|
||||
if (geolocation == null || geolocation.isEmpty())
|
||||
{
|
||||
this.geolocation = null;
|
||||
config.removeProperty("geolocation");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.geolocation = geolocation;
|
||||
config.setProperty("geolocation", geolocation);
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
private boolean isSocialSpyEnabled;
|
||||
|
||||
private boolean _isSocialSpyEnabled()
|
||||
{
|
||||
return config.getBoolean("socialspy", false);
|
||||
}
|
||||
|
||||
public boolean isSocialSpyEnabled()
|
||||
{
|
||||
return isSocialSpyEnabled;
|
||||
}
|
||||
|
||||
public void setSocialSpyEnabled(boolean status)
|
||||
{
|
||||
isSocialSpyEnabled = status;
|
||||
config.setProperty("socialspy", status);
|
||||
config.save();
|
||||
}
|
||||
private boolean isNPC;
|
||||
|
||||
private boolean _isNPC()
|
||||
{
|
||||
return config.getBoolean("npc", false);
|
||||
}
|
||||
|
||||
public boolean isNPC()
|
||||
{
|
||||
return isNPC;
|
||||
}
|
||||
|
||||
public void setNPC(boolean set)
|
||||
{
|
||||
isNPC = set;
|
||||
config.setProperty("npc", set);
|
||||
config.save();
|
||||
}
|
||||
private boolean arePowerToolsEnabled;
|
||||
|
||||
public boolean arePowerToolsEnabled()
|
||||
{
|
||||
return arePowerToolsEnabled;
|
||||
}
|
||||
|
||||
public void setPowerToolsEnabled(boolean set)
|
||||
{
|
||||
arePowerToolsEnabled = set;
|
||||
config.setProperty("powertoolsenabled", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean togglePowerToolsEnabled()
|
||||
{
|
||||
boolean ret = !arePowerToolsEnabled();
|
||||
setPowerToolsEnabled(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private boolean _arePowerToolsEnabled()
|
||||
{
|
||||
return config.getBoolean("powertoolsenabled", true);
|
||||
}
|
||||
private Map<String, Object> kitTimestamps;
|
||||
|
||||
private Map<String, Object> _getKitTimestamps()
|
||||
{
|
||||
final Object map = config.getProperty("timestamps.kits");
|
||||
|
||||
if (map instanceof Map)
|
||||
{
|
||||
return (Map<String, Object>)map;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
}
|
||||
|
||||
public Long getKitTimestamp(final String name)
|
||||
{
|
||||
final Number num = (Number)kitTimestamps.get(name.toLowerCase(Locale.ENGLISH));
|
||||
return num == null ? null : num.longValue();
|
||||
}
|
||||
|
||||
public void setKitTimestamp(final String name, final long time)
|
||||
{
|
||||
kitTimestamps.put(name.toLowerCase(Locale.ENGLISH), time);
|
||||
config.setProperty("timestamps.kits", kitTimestamps);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
config.save();
|
||||
}
|
||||
}
|
@@ -1,124 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class UserMap extends CacheLoader<String, User> implements IConf
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
private final transient Cache<String, User> users = CacheBuilder.newBuilder().softValues().build(this);
|
||||
private final transient ConcurrentSkipListSet<String> keys = new ConcurrentSkipListSet<String>();
|
||||
|
||||
public UserMap(final IEssentials ess)
|
||||
{
|
||||
super();
|
||||
this.ess = ess;
|
||||
loadAllUsersAsync(ess);
|
||||
}
|
||||
|
||||
private void loadAllUsersAsync(final IEssentials ess)
|
||||
{
|
||||
ess.scheduleAsyncDelayedTask(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final File userdir = new File(ess.getDataFolder(), "userdata");
|
||||
if (!userdir.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
keys.clear();
|
||||
users.invalidateAll();
|
||||
for (String string : userdir.list())
|
||||
{
|
||||
if (!string.endsWith(".yml"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final String name = string.substring(0, string.length() - 4);
|
||||
keys.add(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean userExists(final String name)
|
||||
{
|
||||
return keys.contains(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public User getUser(final String name)
|
||||
{
|
||||
try
|
||||
{
|
||||
return users.get(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
catch (ExecutionException ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
catch (UncheckedExecutionException ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public User load(final String name) throws Exception
|
||||
{
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
if (player.getName().equalsIgnoreCase(name))
|
||||
{
|
||||
keys.add(name.toLowerCase(Locale.ENGLISH));
|
||||
return new User(player, ess);
|
||||
}
|
||||
}
|
||||
final File userFile = getUserFile(name);
|
||||
if (userFile.exists())
|
||||
{
|
||||
keys.add(name.toLowerCase(Locale.ENGLISH));
|
||||
return new User(new OfflinePlayer(name, ess), ess);
|
||||
}
|
||||
throw new Exception("User not found!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
{
|
||||
loadAllUsersAsync(ess);
|
||||
}
|
||||
|
||||
public void removeUser(final String name)
|
||||
{
|
||||
keys.remove(name.toLowerCase(Locale.ENGLISH));
|
||||
users.invalidate(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public Set<String> getAllUniqueUsers()
|
||||
{
|
||||
return Collections.unmodifiableSet(keys);
|
||||
}
|
||||
|
||||
public int getUniqueUsers()
|
||||
{
|
||||
return keys.size();
|
||||
}
|
||||
|
||||
public File getUserFile(final String name)
|
||||
{
|
||||
final File userFolder = new File(ess.getDataFolder(), "userdata");
|
||||
return new File(userFolder, Util.sanitizeFileName(name) + ".yml");
|
||||
}
|
||||
}
|
@@ -1,30 +1,95 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.ISettings;
|
||||
import com.earth2me.essentials.api.InvalidNameException;
|
||||
import com.earth2me.essentials.external.gnu.inet.encoding.Punycode;
|
||||
import com.earth2me.essentials.external.gnu.inet.encoding.PunycodeException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
|
||||
public class Util
|
||||
public final class Util
|
||||
{
|
||||
private Util()
|
||||
{
|
||||
}
|
||||
private final static Logger logger = Logger.getLogger("Minecraft");
|
||||
private final static Pattern INVALIDFILECHARS = Pattern.compile("[^\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]");
|
||||
private final static Pattern INVALIDCHARS = Pattern.compile("[^\t\n\r\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]");
|
||||
|
||||
public static String sanitizeFileName(String name)
|
||||
public static String sanitizeFileName(String name) throws InvalidNameException
|
||||
{
|
||||
return name.toLowerCase(Locale.ENGLISH).replaceAll("[^a-z0-9]", "_");
|
||||
try
|
||||
{
|
||||
String r = name.toLowerCase(Locale.ENGLISH);
|
||||
r = r.replace('.', (char)('\ue200' + '.'));
|
||||
r = r.replace('\\', (char)('\ue200' + '\\'));
|
||||
r = r.replace('/', (char)('\ue200' + '/'));
|
||||
r = r.replace('"', (char)('\ue200' + '"'));
|
||||
r = r.replace('<', (char)('\ue200' + '<'));
|
||||
r = r.replace('>', (char)('\ue200' + '>'));
|
||||
r = r.replace('|', (char)('\ue200' + '|'));
|
||||
r = r.replace('?', (char)('\ue200' + '?'));
|
||||
r = r.replace('*', (char)('\ue200' + '*'));
|
||||
r = r.replace(':', (char)('\ue200' + ':'));
|
||||
r = r.replace('-', (char)('\ue200' + '-'));
|
||||
r = INVALIDFILECHARS.matcher(r).replaceAll("");
|
||||
return Punycode.encode(r);
|
||||
}
|
||||
catch (PunycodeException ex)
|
||||
{
|
||||
throw new InvalidNameException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static String decodeFileName(String name) throws InvalidNameException
|
||||
{
|
||||
try
|
||||
{
|
||||
String r = Punycode.decode(name);
|
||||
r = r.replace((char)('\ue200' + '.'), '.');
|
||||
r = r.replace((char)('\ue200' + '\\'), '\\');
|
||||
r = r.replace((char)('\ue200' + '/'), '/');
|
||||
r = r.replace((char)('\ue200' + '"'), '"');
|
||||
r = r.replace((char)('\ue200' + '<'), '<');
|
||||
r = r.replace((char)('\ue200' + '>'), '>');
|
||||
r = r.replace((char)('\ue200' + '|'), '|');
|
||||
r = r.replace((char)('\ue200' + '?'), '?');
|
||||
r = r.replace((char)('\ue200' + '*'), '*');
|
||||
r = r.replace((char)('\ue200' + ':'), ':');
|
||||
r = r.replace((char)('\ue200' + '-'), '-');
|
||||
return r;
|
||||
}
|
||||
catch (PunycodeException ex)
|
||||
{
|
||||
throw new InvalidNameException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static String sanitizeKey(String name)
|
||||
{
|
||||
return INVALIDCHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_");
|
||||
}
|
||||
|
||||
public static String sanitizeString(final String string)
|
||||
{
|
||||
return INVALIDCHARS.matcher(string).replaceAll("");
|
||||
}
|
||||
|
||||
public static String formatDateDiff(long date)
|
||||
@@ -418,7 +483,10 @@ public class Util
|
||||
|
||||
public static String formatCurrency(final double value, final IEssentials ess)
|
||||
{
|
||||
String str = ess.getSettings().getCurrencySymbol() + df.format(value);
|
||||
@Cleanup
|
||||
final ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
String str = settings.getData().getEconomy().getCurrencySymbol() + df.format(value);
|
||||
if (str.endsWith(".00"))
|
||||
{
|
||||
str = str.substring(0, str.length() - 3);
|
||||
@@ -477,7 +545,87 @@ public class Util
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
private static transient final Pattern COLOR_PATTERN = Pattern.compile("(?i)\u00A7[0-9A-F]");
|
||||
|
||||
public static void registerPermissions(String path, Collection<String> nodes, boolean hasDefault, IEssentials ess)
|
||||
{
|
||||
if (nodes == null || nodes.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PluginManager pluginManager = ess.getServer().getPluginManager();
|
||||
Permission basePerm = pluginManager.getPermission(path + ".*");
|
||||
if (basePerm != null && !basePerm.getChildren().isEmpty())
|
||||
{
|
||||
basePerm.getChildren().clear();
|
||||
}
|
||||
if (basePerm == null)
|
||||
{
|
||||
basePerm = new Permission(path + ".*", PermissionDefault.OP);
|
||||
pluginManager.addPermission(basePerm);
|
||||
Permission mainPerm = pluginManager.getPermission("essentials.*");
|
||||
if (mainPerm == null)
|
||||
{
|
||||
mainPerm = new Permission("essentials.*", PermissionDefault.OP);
|
||||
pluginManager.addPermission(mainPerm);
|
||||
}
|
||||
mainPerm.getChildren().put(basePerm.getName(), Boolean.TRUE);
|
||||
}
|
||||
|
||||
for (String nodeName : nodes)
|
||||
{
|
||||
final String permissionName = path + "." + nodeName;
|
||||
Permission perm = pluginManager.getPermission(permissionName);
|
||||
if (perm == null)
|
||||
{
|
||||
final PermissionDefault defaultPerm = hasDefault && nodeName.equalsIgnoreCase("default") ? PermissionDefault.TRUE : PermissionDefault.OP;
|
||||
perm = new Permission(permissionName, defaultPerm);
|
||||
pluginManager.addPermission(perm);
|
||||
}
|
||||
basePerm.getChildren().put(permissionName, Boolean.TRUE);
|
||||
}
|
||||
basePerm.recalculatePermissibles();
|
||||
}
|
||||
private static transient final Pattern DOT_PATTERN = Pattern.compile("\\.");
|
||||
|
||||
public static Permission registerPermission(String permission, PermissionDefault defaultPerm)
|
||||
{
|
||||
final PluginManager pluginManager = Bukkit.getServer().getPluginManager();
|
||||
final String[] parts = DOT_PATTERN.split(permission);
|
||||
final StringBuilder builder = new StringBuilder(permission.length());
|
||||
Permission parent = null;
|
||||
for (int i = 0; i < parts.length - 1; i++)
|
||||
{
|
||||
builder.append(parts[i]).append(".*");
|
||||
String permString = builder.toString();
|
||||
Permission perm = pluginManager.getPermission(permString);
|
||||
if (perm == null)
|
||||
{
|
||||
perm = new Permission(permString, PermissionDefault.FALSE);
|
||||
pluginManager.addPermission(perm);
|
||||
if (parent != null)
|
||||
{
|
||||
parent.getChildren().put(perm.getName(), Boolean.TRUE);
|
||||
}
|
||||
parent = perm;
|
||||
}
|
||||
builder.deleteCharAt(builder.length() - 1);
|
||||
}
|
||||
Permission perm = pluginManager.getPermission(permission);
|
||||
if (perm == null)
|
||||
{
|
||||
perm = new Permission(permission, defaultPerm);
|
||||
pluginManager.addPermission(perm);
|
||||
if (parent != null)
|
||||
{
|
||||
parent.getChildren().put(perm.getName(), Boolean.TRUE);
|
||||
}
|
||||
parent = perm;
|
||||
}
|
||||
perm.recalculatePermissibles();
|
||||
return perm;
|
||||
}
|
||||
private static transient final Pattern VANILLA_COLOR_PATTERN = Pattern.compile("\u00A7+[0-9A-FKa-fk]");
|
||||
private static transient final Pattern EASY_COLOR_PATTERN = Pattern.compile("&([0-9a-fk])");
|
||||
|
||||
public static String stripColor(final String input)
|
||||
{
|
||||
@@ -486,6 +634,16 @@ public class Util
|
||||
return null;
|
||||
}
|
||||
|
||||
return COLOR_PATTERN.matcher(input).replaceAll("");
|
||||
return VANILLA_COLOR_PATTERN.matcher(input).replaceAll("");
|
||||
}
|
||||
|
||||
public static String replaceColor(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return EASY_COLOR_PATTERN.matcher(input).replaceAll("\u00a7$1");
|
||||
}
|
||||
}
|
||||
|
@@ -1,120 +1,121 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IWarp;
|
||||
import com.earth2me.essentials.api.IWarps;
|
||||
import com.earth2me.essentials.api.InvalidNameException;
|
||||
import com.earth2me.essentials.commands.WarpNotFoundException;
|
||||
import com.earth2me.essentials.settings.WarpHolder;
|
||||
import com.earth2me.essentials.storage.StorageObjectMap;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
|
||||
|
||||
public class Warps implements IConf
|
||||
public class Warps extends StorageObjectMap<IWarp> implements IWarps
|
||||
{
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private final Map<StringIgnoreCase, EssentialsConf> warpPoints = new HashMap<StringIgnoreCase, EssentialsConf>();
|
||||
private final File warpsFolder;
|
||||
private final Server server;
|
||||
private static final Logger logger = Bukkit.getLogger();
|
||||
|
||||
public Warps(Server server, File dataFolder)
|
||||
public Warps(IEssentials ess)
|
||||
{
|
||||
this.server = server;
|
||||
warpsFolder = new File(dataFolder, "warps");
|
||||
if (!warpsFolder.exists())
|
||||
{
|
||||
warpsFolder.mkdirs();
|
||||
}
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return warpPoints.isEmpty();
|
||||
}
|
||||
|
||||
public Collection<String> getWarpNames()
|
||||
{
|
||||
final List<String> keys = new ArrayList<String>();
|
||||
for (StringIgnoreCase stringIgnoreCase : warpPoints.keySet())
|
||||
{
|
||||
keys.add(stringIgnoreCase.getString());
|
||||
}
|
||||
Collections.sort(keys, String.CASE_INSENSITIVE_ORDER);
|
||||
return keys;
|
||||
}
|
||||
|
||||
public Location getWarp(String warp) throws Exception
|
||||
{
|
||||
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(warp));
|
||||
if (conf == null)
|
||||
{
|
||||
throw new Exception(_("warpNotExist"));
|
||||
}
|
||||
return conf.getLocation(null, server);
|
||||
}
|
||||
|
||||
public void setWarp(String name, Location loc) throws Exception
|
||||
{
|
||||
String filename = Util.sanitizeFileName(name);
|
||||
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(name));
|
||||
if (conf == null)
|
||||
{
|
||||
File confFile = new File(warpsFolder, filename + ".yml");
|
||||
if (confFile.exists())
|
||||
{
|
||||
throw new Exception(_("similarWarpExist"));
|
||||
}
|
||||
conf = new EssentialsConf(confFile);
|
||||
warpPoints.put(new StringIgnoreCase(name), conf);
|
||||
}
|
||||
conf.setProperty(null, loc);
|
||||
conf.setProperty("name", name);
|
||||
conf.save();
|
||||
}
|
||||
|
||||
public void delWarp(String name) throws Exception
|
||||
{
|
||||
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(name));
|
||||
if (conf == null)
|
||||
{
|
||||
throw new Exception(_("warpNotExist"));
|
||||
}
|
||||
if (!conf.getFile().delete())
|
||||
{
|
||||
throw new Exception(_("warpDeleteError"));
|
||||
}
|
||||
warpPoints.remove(new StringIgnoreCase(name));
|
||||
super(ess, "warps");
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void reloadConfig()
|
||||
public boolean isEmpty()
|
||||
{
|
||||
warpPoints.clear();
|
||||
File[] listOfFiles = warpsFolder.listFiles();
|
||||
if (listOfFiles.length >= 1)
|
||||
return getKeySize() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getList()
|
||||
{
|
||||
for (int i = 0; i < listOfFiles.length; i++)
|
||||
final List<String> names = new ArrayList<String>();
|
||||
for (String key : getAllKeys())
|
||||
{
|
||||
String filename = listOfFiles[i].getName();
|
||||
if (listOfFiles[i].isFile() && filename.endsWith(".yml"))
|
||||
IWarp warp = getObject(key);
|
||||
if (warp == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
warp.acquireReadLock();
|
||||
try
|
||||
{
|
||||
EssentialsConf conf = new EssentialsConf(listOfFiles[i]);
|
||||
conf.load();
|
||||
String name = conf.getString("name");
|
||||
if (name != null)
|
||||
names.add(warp.getData().getName());
|
||||
}
|
||||
finally
|
||||
{
|
||||
warpPoints.put(new StringIgnoreCase(name), conf);
|
||||
warp.unlock();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
Collections.sort(names, String.CASE_INSENSITIVE_ORDER);
|
||||
return names;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getWarp(final String name) throws Exception
|
||||
{
|
||||
logger.log(Level.WARNING, _("loadWarpError", filename), ex);
|
||||
IWarp warp = getObject(name);
|
||||
if (warp == null)
|
||||
{
|
||||
throw new WarpNotFoundException(_("warpNotExist"));
|
||||
}
|
||||
warp.acquireReadLock();
|
||||
try
|
||||
{
|
||||
return warp.getData().getLocation().getBukkitLocation();
|
||||
}
|
||||
finally
|
||||
{
|
||||
warp.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWarp(final String name, final Location loc) throws Exception
|
||||
{
|
||||
setWarp(name, new com.earth2me.essentials.storage.Location(loc));
|
||||
}
|
||||
|
||||
public void setWarp(final String name, final com.earth2me.essentials.storage.Location loc) throws Exception
|
||||
{
|
||||
IWarp warp = getObject(name);
|
||||
if (warp == null)
|
||||
{
|
||||
warp = new WarpHolder(name, ess);
|
||||
}
|
||||
warp.acquireWriteLock();
|
||||
try
|
||||
{
|
||||
warp.getData().setLocation(loc);
|
||||
}
|
||||
finally
|
||||
{
|
||||
warp.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeWarp(final String name) throws Exception
|
||||
{
|
||||
removeObject(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getWarpFile(String name) throws InvalidNameException
|
||||
{
|
||||
return getStorageFile(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWarp load(String name) throws Exception
|
||||
{
|
||||
final IWarp warp = new WarpHolder(name, ess);
|
||||
warp.onReload();
|
||||
return warp;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,61 +1,86 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IWorth;
|
||||
import com.earth2me.essentials.storage.AsyncStorageObjectHolder;
|
||||
import com.earth2me.essentials.storage.EnchantmentLevel;
|
||||
import java.io.File;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Logger;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
|
||||
public class Worth implements IConf
|
||||
public class Worth extends AsyncStorageObjectHolder<com.earth2me.essentials.settings.Worth> implements IWorth
|
||||
{
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private final EssentialsConf config;
|
||||
|
||||
public Worth(File dataFolder)
|
||||
public Worth(final IEssentials ess)
|
||||
{
|
||||
config = new EssentialsConf(new File(dataFolder, "worth.yml"));
|
||||
config.setTemplateName("/worth.yml");
|
||||
config.load();
|
||||
}
|
||||
|
||||
public double getPrice(ItemStack itemStack)
|
||||
{
|
||||
String itemname = itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||
double result;
|
||||
result = config.getDouble("worth." + itemname + "." + itemStack.getDurability(), Double.NaN);
|
||||
if (Double.isNaN(result))
|
||||
{
|
||||
result = config.getDouble("worth." + itemname + ".0", Double.NaN);
|
||||
}
|
||||
if (Double.isNaN(result))
|
||||
{
|
||||
result = config.getDouble("worth." + itemname, Double.NaN);
|
||||
}
|
||||
if (Double.isNaN(result))
|
||||
{
|
||||
result = config.getDouble("worth-" + itemStack.getTypeId(), Double.NaN);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setPrice(ItemStack itemStack, double price)
|
||||
{
|
||||
if (itemStack.getType().getData() == null)
|
||||
{
|
||||
config.setProperty("worth." + itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""), price);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Bukkit-bug: getDurability still contains the correct value, while getData().getData() is 0.
|
||||
config.setProperty("worth." + itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "") + "." + itemStack.getDurability(), price);
|
||||
}
|
||||
config.removeProperty("worth-" + itemStack.getTypeId());
|
||||
config.save();
|
||||
super(ess, com.earth2me.essentials.settings.Worth.class);
|
||||
onReload(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
public double getPrice(final ItemStack itemStack)
|
||||
{
|
||||
config.load();
|
||||
this.acquireReadLock();
|
||||
try
|
||||
{
|
||||
final Map<MaterialData, Double> prices = this.getData().getSell();
|
||||
if (prices == null || itemStack == null)
|
||||
{
|
||||
return Double.NaN;
|
||||
}
|
||||
final Double basePrice = prices.get(itemStack.getData());
|
||||
if (basePrice == null || Double.isNaN(basePrice))
|
||||
{
|
||||
return Double.NaN;
|
||||
}
|
||||
double multiplier = 1.0;
|
||||
if (itemStack.getType().getMaxDurability() > 0) {
|
||||
multiplier *= (double)itemStack.getDurability() / (double)itemStack.getType().getMaxDurability();
|
||||
}
|
||||
if (itemStack.getEnchantments() != null && !itemStack.getEnchantments().isEmpty())
|
||||
{
|
||||
final Map<EnchantmentLevel, Double> enchantmentMultipliers = this.getData().getEnchantmentMultiplier();
|
||||
if (enchantmentMultipliers != null)
|
||||
{
|
||||
for (Map.Entry<Enchantment, Integer> entry : itemStack.getEnchantments().entrySet())
|
||||
{
|
||||
final Double enchMult = enchantmentMultipliers.get(new EnchantmentLevel(entry.getKey(), entry.getValue()));
|
||||
if (enchMult != null)
|
||||
{
|
||||
multiplier *= enchMult;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return basePrice * multiplier;
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrice(final ItemStack itemStack, final double price)
|
||||
{
|
||||
acquireWriteLock();
|
||||
try {
|
||||
if (getData().getSell() == null) {
|
||||
getData().setSell(new HashMap<MaterialData, Double>());
|
||||
}
|
||||
getData().getSell().put(itemStack.getData(), price);
|
||||
} finally {
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getStorageFile() throws IOException
|
||||
{
|
||||
return new File(ess.getDataFolder(), "worth.yml");
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package com.earth2me.essentials;
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
|
||||
public class ChargeException extends Exception
|
@@ -1,10 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import java.util.Map;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
|
||||
|
||||
public interface IAlternativeCommandsHandler
|
||||
{
|
||||
Map<String, String> disabledCommands();
|
||||
}
|
7
Essentials/src/com/earth2me/essentials/api/IBackup.java
Normal file
7
Essentials/src/com/earth2me/essentials/api/IBackup.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
|
||||
public interface IBackup extends Runnable
|
||||
{
|
||||
public void startTask();
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import java.util.Map;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public interface ICommandHandler extends IReload
|
||||
{
|
||||
Map<String, String> disabledCommands();
|
||||
|
||||
public void removePlugin(Plugin plugin);
|
||||
|
||||
public void addPlugin(Plugin plugin);
|
||||
|
||||
boolean handleCommand(CommandSender sender, Command command, String commandLabel, String[] args);
|
||||
|
||||
void showCommandError(CommandSender sender, String commandLabel, Throwable exception);
|
||||
}
|
21
Essentials/src/com/earth2me/essentials/api/IEconomy.java
Normal file
21
Essentials/src/com/earth2me/essentials/api/IEconomy.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
|
||||
public interface IEconomy extends IReload
|
||||
{
|
||||
public double getMoney(String name) throws UserDoesNotExistException;
|
||||
|
||||
public void setMoney(String name, double balance) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
public void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
public String format(double amount);
|
||||
|
||||
public boolean playerExists(String name);
|
||||
|
||||
public boolean isNPC(String name) throws UserDoesNotExistException;
|
||||
|
||||
public boolean createNPC(String name);
|
||||
|
||||
public void removeNPC(String name) throws UserDoesNotExistException;
|
||||
}
|
@@ -1,17 +1,19 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.perm.IPermissionsHandler;
|
||||
import com.earth2me.essentials.listener.TntExplodeListener;
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public interface IEssentials extends Plugin, IReload
|
||||
public interface IEssentials extends Plugin
|
||||
{
|
||||
void addReloadListener(IReload listener);
|
||||
|
||||
IUser getUser(Object base);
|
||||
IUser getUser(Player player);
|
||||
|
||||
IUser getUser(String playerName);
|
||||
|
||||
int broadcastMessage(IUser sender, String message);
|
||||
|
||||
@@ -19,7 +21,11 @@ public interface IEssentials extends Plugin, IReload
|
||||
|
||||
ISettings getSettings();
|
||||
|
||||
IJails getJail();
|
||||
IGroups getGroups();
|
||||
|
||||
IJails getJails();
|
||||
|
||||
IKits getKits();
|
||||
|
||||
IWarps getWarps();
|
||||
|
||||
@@ -29,7 +35,9 @@ public interface IEssentials extends Plugin, IReload
|
||||
|
||||
IUserMap getUserMap();
|
||||
|
||||
IEssentialsEconomy getEconomy();
|
||||
IBackup getBackup();
|
||||
|
||||
ICommandHandler getCommandHandler();
|
||||
|
||||
World getWorld(String name);
|
||||
|
||||
@@ -43,9 +51,14 @@ public interface IEssentials extends Plugin, IReload
|
||||
|
||||
int scheduleSyncRepeatingTask(Runnable run, long delay, long period);
|
||||
|
||||
IPermissionsHandler getPermissionsHandler();
|
||||
//IPermissionsHandler getPermissionsHandler();
|
||||
void reload();
|
||||
|
||||
IAlternativeCommandsHandler getAlternativeCommandsHandler();
|
||||
TntExplodeListener getTNTListener();
|
||||
|
||||
void showCommandError(CommandSender sender, String commandLabel, Throwable exception);
|
||||
void setGroups(IGroups groups);
|
||||
|
||||
void removeReloadListener(IReload groups);
|
||||
|
||||
IEconomy getEconomy();
|
||||
}
|
||||
|
@@ -1,37 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
|
||||
public interface IEssentialsEconomy
|
||||
{
|
||||
double getMoney(String name) throws UserDoesNotExistException;
|
||||
|
||||
void setMoney(String name, double balance) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
void add(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
void subtract(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
void divide(String name, double value) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
void multiply(String name, double value) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
boolean hasEnough(String name, double amount) throws UserDoesNotExistException;
|
||||
|
||||
boolean hasMore(String name, double amount) throws UserDoesNotExistException;
|
||||
|
||||
boolean hasLess(String name, double amount) throws UserDoesNotExistException;
|
||||
|
||||
boolean isNegative(String name) throws UserDoesNotExistException;
|
||||
|
||||
String format(double amount);
|
||||
|
||||
boolean playerExists(String name);
|
||||
|
||||
boolean isNPC(String name) throws UserDoesNotExistException;
|
||||
|
||||
boolean createNPC(String name);
|
||||
|
||||
void removeNPC(String name) throws UserDoesNotExistException;
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package com.earth2me.essentials;
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
|
||||
public interface IEssentialsModule
|
25
Essentials/src/com/earth2me/essentials/api/IGroups.java
Normal file
25
Essentials/src/com/earth2me/essentials/api/IGroups.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
|
||||
public interface IGroups
|
||||
{
|
||||
String getMainGroup(IUser player);
|
||||
|
||||
boolean inGroup(IUser player, String groupname);
|
||||
|
||||
double getHealCooldown(IUser player);
|
||||
|
||||
double getTeleportCooldown(IUser player);
|
||||
|
||||
double getTeleportDelay(IUser player);
|
||||
|
||||
String getPrefix(IUser player);
|
||||
|
||||
String getSuffix(IUser player);
|
||||
|
||||
int getHomeLimit(IUser player);
|
||||
|
||||
MessageFormat getChatFormat(IUser player);
|
||||
}
|
@@ -3,8 +3,10 @@ package com.earth2me.essentials.api;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public interface IItemDb
|
||||
public interface IItemDb extends IReload
|
||||
{
|
||||
ItemStack get(final String name, final IUser user) throws Exception;
|
||||
|
||||
ItemStack get(final String name, final int quantity) throws Exception;
|
||||
|
||||
ItemStack get(final String name) throws Exception;
|
||||
|
@@ -12,7 +12,7 @@ public interface IJails extends IReload
|
||||
|
||||
void removeJail(String jail) throws Exception;
|
||||
|
||||
void sendToJail(com.earth2me.essentials.IUser user, String jail) throws Exception;
|
||||
void sendToJail(IUser user, String jail) throws Exception;
|
||||
|
||||
void setJail(String jailName, Location loc) throws Exception;
|
||||
}
|
||||
|
18
Essentials/src/com/earth2me/essentials/api/IKits.java
Normal file
18
Essentials/src/com/earth2me/essentials/api/IKits.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.settings.Kit;
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
public interface IKits extends IReload
|
||||
{
|
||||
Kit getKit(String kit) throws Exception;
|
||||
|
||||
void sendKit(IUser user, String kit) throws Exception;
|
||||
|
||||
void sendKit(IUser user, Kit kit) throws Exception;
|
||||
|
||||
Collection<String> getList() throws Exception;
|
||||
|
||||
boolean isEmpty();
|
||||
}
|
17
Essentials/src/com/earth2me/essentials/api/IPermission.java
Normal file
17
Essentials/src/com/earth2me/essentials/api/IPermission.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
|
||||
public interface IPermission
|
||||
{
|
||||
String getPermission();
|
||||
|
||||
boolean isAuthorized(CommandSender sender);
|
||||
|
||||
Permission getBukkitPermission();
|
||||
|
||||
PermissionDefault getPermissionDefault();
|
||||
}
|
11
Essentials/src/com/earth2me/essentials/api/IReplyTo.java
Normal file
11
Essentials/src/com/earth2me/essentials/api/IReplyTo.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public interface IReplyTo
|
||||
{
|
||||
void setReplyTo(CommandSender user);
|
||||
|
||||
CommandSender getReplyTo();
|
||||
}
|
@@ -6,5 +6,9 @@ import com.earth2me.essentials.storage.IStorageObjectHolder;
|
||||
|
||||
public interface ISettings extends IStorageObjectHolder<Settings>
|
||||
{
|
||||
public String getLocale();
|
||||
|
||||
public boolean isDebug();
|
||||
|
||||
public void setDebug(boolean b);
|
||||
}
|
||||
|
@@ -1,10 +1,28 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.Trade;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
|
||||
|
||||
public interface ITeleport
|
||||
{
|
||||
void now(Location loc, boolean cooldown, TeleportCause cause) throws Exception;
|
||||
|
||||
void now(Entity entity, boolean cooldown, TeleportCause cause) throws Exception;
|
||||
|
||||
void back(Trade chargeFor) throws Exception;
|
||||
|
||||
void teleport(Location bed, Trade charge, TeleportCause teleportCause) throws Exception;
|
||||
|
||||
void teleport(Entity entity, Trade chargeFor, TeleportCause cause) throws Exception;
|
||||
|
||||
void home(IUser player, String toLowerCase, Trade charge) throws Exception;
|
||||
|
||||
void respawn(Trade charge, TeleportCause teleportCause) throws Exception;
|
||||
|
||||
void back() throws Exception;
|
||||
|
||||
public void warp(String name, Trade charge, TeleportCause teleportCause) throws Exception;
|
||||
}
|
||||
|
@@ -1,43 +1,104 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.storage.IStorageObjectHolder;
|
||||
import com.earth2me.essentials.user.CooldownException;
|
||||
import com.earth2me.essentials.user.UserData;
|
||||
import java.util.List;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public interface IUser extends Player, IReload
|
||||
public interface IUser extends Player, IStorageObjectHolder<UserData>, IReload, IReplyTo, Comparable<IUser>
|
||||
{
|
||||
long getLastTeleportTimestamp();
|
||||
|
||||
boolean isAuthorized(String node);
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd);
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix);
|
||||
|
||||
void setLastTeleportTimestamp(long time);
|
||||
|
||||
Location getLastLocation();
|
||||
|
||||
Player getBase();
|
||||
|
||||
double getMoney();
|
||||
|
||||
void takeMoney(double value);
|
||||
|
||||
void takeMoney(double value, CommandSender initiator);
|
||||
|
||||
void giveMoney(double value);
|
||||
|
||||
String getGroup();
|
||||
void giveMoney(double value, CommandSender initiator);
|
||||
|
||||
void giveItems(ItemStack itemStack, Boolean canSpew) throws ChargeException;
|
||||
|
||||
void giveItems(List<ItemStack> itemStacks, Boolean canSpew) throws ChargeException;
|
||||
|
||||
void setMoney(double value);
|
||||
|
||||
void payUser(final IUser reciever, final double value) throws Exception;
|
||||
|
||||
void setLastLocation();
|
||||
|
||||
Location getHome(String name) throws Exception;
|
||||
|
||||
Location getHome(Location loc) throws Exception;
|
||||
Location getHome(Location loc);
|
||||
|
||||
boolean isHidden();
|
||||
|
||||
ITeleport getTeleport();
|
||||
|
||||
void setJail(String jail);
|
||||
void checkCooldown(UserData.TimestampType cooldownType, double cooldown, boolean set, IPermission bypassPermission) throws CooldownException;
|
||||
|
||||
boolean toggleAfk();
|
||||
|
||||
void updateActivity(boolean broadcast);
|
||||
|
||||
void updateDisplayName();
|
||||
|
||||
boolean checkJailTimeout(long currentTime);
|
||||
|
||||
boolean checkMuteTimeout(long currentTime);
|
||||
|
||||
boolean checkBanTimeout(long currentTime);
|
||||
|
||||
long getTimestamp(UserData.TimestampType name);
|
||||
|
||||
void setTimestamp(UserData.TimestampType name, long value);
|
||||
|
||||
void setLastOnlineActivity(long currentTime);
|
||||
|
||||
void checkActivity();
|
||||
|
||||
long getLastOnlineActivity();
|
||||
|
||||
boolean isGodModeEnabled();
|
||||
|
||||
boolean isIgnoringPlayer(String name);
|
||||
|
||||
void setIgnoredPlayer(String name, boolean set);
|
||||
|
||||
Location getAfkPosition();
|
||||
|
||||
boolean toggleGodModeEnabled();
|
||||
|
||||
void dispose();
|
||||
|
||||
void updateCompass();
|
||||
|
||||
List<String> getHomes();
|
||||
|
||||
void addMail(String string);
|
||||
|
||||
boolean toggleMuted();
|
||||
|
||||
boolean toggleSocialSpy();
|
||||
|
||||
void requestTeleport(IUser user, boolean b);
|
||||
|
||||
boolean isTeleportRequestHere();
|
||||
|
||||
IUser getTeleportRequester();
|
||||
|
||||
boolean toggleTeleportEnabled();
|
||||
|
||||
long getTeleportRequestTime();
|
||||
|
||||
boolean gotMailInfo();
|
||||
|
||||
List<String> getMails();
|
||||
}
|
||||
|
@@ -2,19 +2,22 @@ package com.earth2me.essentials.api;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public interface IUserMap
|
||||
public interface IUserMap extends IReload
|
||||
{
|
||||
boolean userExists(final String name);
|
||||
|
||||
IUser getUser(final String name);
|
||||
IUser getUser(final Player player);
|
||||
|
||||
void removeUser(final String name);
|
||||
IUser getUser(final String playerName);
|
||||
|
||||
void removeUser(final String name) throws InvalidNameException;
|
||||
|
||||
Set<String> getAllUniqueUsers();
|
||||
|
||||
int getUniqueUsers();
|
||||
|
||||
File getUserFile(final String name);
|
||||
File getUserFile(final String name) throws InvalidNameException;
|
||||
}
|
||||
|
9
Essentials/src/com/earth2me/essentials/api/IWarp.java
Normal file
9
Essentials/src/com/earth2me/essentials/api/IWarp.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.settings.Warp;
|
||||
import com.earth2me.essentials.storage.IStorageObjectHolder;
|
||||
|
||||
|
||||
public interface IWarp extends IStorageObjectHolder<Warp>
|
||||
{
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import org.bukkit.Location;
|
||||
|
||||
@@ -8,9 +9,13 @@ public interface IWarps extends IReload
|
||||
{
|
||||
Location getWarp(String warp) throws Exception;
|
||||
|
||||
Collection<String> getWarps();
|
||||
Collection<String> getList();
|
||||
|
||||
void removeWarp(String name) throws Exception;
|
||||
|
||||
void setWarp(String name, Location loc) throws Exception;
|
||||
|
||||
public boolean isEmpty();
|
||||
|
||||
public File getWarpFile(String name) throws InvalidNameException;
|
||||
}
|
||||
|
@@ -0,0 +1,10 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
|
||||
public class InvalidNameException extends Exception
|
||||
{
|
||||
public InvalidNameException(Throwable thrwbl)
|
||||
{
|
||||
super(thrwbl);
|
||||
}
|
||||
}
|
@@ -1,23 +1,20 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
|
||||
public class Commandafk extends EssentialsCommand
|
||||
{
|
||||
public Commandafk()
|
||||
{
|
||||
super("afk");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && user.isAuthorized("essentials.afk.others"))
|
||||
if (args.length > 0 && Permissions.AFK_OTHERS.isAuthorized(user))
|
||||
{
|
||||
User afkUser = ess.getUser(ess.getServer().matchPlayer(args[0]));
|
||||
IUser afkUser = ess.getUser((Player)ess.getServer().matchPlayer(args[0]));
|
||||
if (afkUser != null)
|
||||
{
|
||||
toggleAfk(afkUser);
|
||||
@@ -29,7 +26,7 @@ public class Commandafk extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleAfk(User user)
|
||||
private void toggleAfk(IUser user)
|
||||
{
|
||||
if (!user.toggleAfk())
|
||||
{
|
||||
@@ -49,4 +46,10 @@ public class Commandafk extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionDefault getPermissionDefault()
|
||||
{
|
||||
return PermissionDefault.TRUE;
|
||||
}
|
||||
}
|
||||
|
@@ -1,21 +1,15 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
|
||||
|
||||
public class Commandantioch extends EssentialsCommand
|
||||
{
|
||||
public Commandantioch()
|
||||
{
|
||||
super("antioch");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
ess.broadcastMessage(user, "...lobbest thou thy Holy Hand Grenade of Antioch towards thy foe,");
|
||||
ess.broadcastMessage(user, "who being naughty in My sight, shall snuff it.");
|
||||
|
@@ -2,23 +2,18 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
|
||||
|
||||
public class Commandback extends EssentialsCommand
|
||||
{
|
||||
public Commandback()
|
||||
{
|
||||
super("back");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
final Trade charge = new Trade(commandName, ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.sendMessage(_("backUsageMsg"));
|
||||
user.getTeleport().back(charge);
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
|
@@ -1,26 +1,16 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Backup;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.api.IBackup;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandbackup extends EssentialsCommand
|
||||
{
|
||||
public Commandbackup()
|
||||
{
|
||||
super("backup");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final Backup backup = ess.getBackup();
|
||||
if (backup == null)
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
final IBackup backup = ess.getBackup();
|
||||
backup.run();
|
||||
sender.sendMessage(_("backupStarted"));
|
||||
}
|
||||
|
@@ -1,37 +1,31 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandbalance extends EssentialsCommand
|
||||
{
|
||||
public Commandbalance()
|
||||
{
|
||||
super("balance");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
sender.sendMessage(_("balance", Util.formatCurrency(getPlayer(server, args, 0, true).getMoney(), ess)));
|
||||
sender.sendMessage(_("balance", Util.formatCurrency(getPlayer(args, 0, true).getMoney(), ess)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final double bal = (args.length < 1
|
||||
|| !(user.isAuthorized("essentials.balance.others")
|
||||
|| user.isAuthorized("essentials.balance.other"))
|
||||
|| !Permissions.BALANCE_OTHERS.isAuthorized(user)
|
||||
? user
|
||||
: getPlayer(server, args, 0, true)).getMoney();
|
||||
: getPlayer(args, 0, true)).getMoney();
|
||||
user.sendMessage(_("balance", Util.formatCurrency(bal, ess)));
|
||||
}
|
||||
}
|
||||
|
@@ -1,24 +1,19 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.textreader.ArrayListInput;
|
||||
import com.earth2me.essentials.textreader.TextPager;
|
||||
import java.text.DateFormat;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandbalancetop extends EssentialsCommand
|
||||
{
|
||||
public Commandbalancetop()
|
||||
{
|
||||
super("balancetop");
|
||||
}
|
||||
private static final int CACHETIME = 2 * 60 * 1000;
|
||||
public static final int MINUSERS = 50;
|
||||
private static ArrayListInput cache = new ArrayListInput();
|
||||
@@ -26,7 +21,7 @@ public class Commandbalancetop extends EssentialsCommand
|
||||
private static ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
int page = 0;
|
||||
boolean force = false;
|
||||
@@ -109,10 +104,10 @@ public class Commandbalancetop extends EssentialsCommand
|
||||
final Map<String, Double> balances = new HashMap<String, Double>();
|
||||
for (String u : ess.getUserMap().getAllUniqueUsers())
|
||||
{
|
||||
final User user = ess.getUserMap().getUser(u);
|
||||
final IUser user = ess.getUserMap().getUser(u);
|
||||
if (user != null)
|
||||
{
|
||||
balances.put(u, user.getMoney());
|
||||
balances.put(user.getDisplayName(), user.getMoney());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2,32 +2,28 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Console;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.OfflinePlayer;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import com.earth2me.essentials.user.Ban;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandban extends EssentialsCommand
|
||||
{
|
||||
public Commandban()
|
||||
{
|
||||
super("ban");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
final User user = getPlayer(server, args, 0, true);
|
||||
if (user.getBase() instanceof OfflinePlayer)
|
||||
@Cleanup
|
||||
final IUser user = getPlayer(args, 0, true);
|
||||
if (user.isOnline())
|
||||
{
|
||||
if (sender instanceof Player
|
||||
&& !ess.getUser(sender).isAuthorized("essentials.ban.offline"))
|
||||
if (Permissions.BAN_EXEMPT.isAuthorized(user))
|
||||
{
|
||||
sender.sendMessage(_("banExempt"));
|
||||
return;
|
||||
@@ -35,18 +31,20 @@ public class Commandban extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
if (user.isAuthorized("essentials.ban.exempt"))
|
||||
if (Permissions.BAN_OFFLINE.isAuthorized(sender))
|
||||
{
|
||||
sender.sendMessage(_("banExempt"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
user.acquireWriteLock();
|
||||
String banReason;
|
||||
user.getData().setBan(new Ban());
|
||||
if (args.length > 1)
|
||||
{
|
||||
banReason = getFinalArg(args, 1);
|
||||
user.setBanReason(banReason);
|
||||
user.getData().getBan().setReason(banReason);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -58,8 +56,8 @@ public class Commandban extends EssentialsCommand
|
||||
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
final User player = ess.getUser(onlinePlayer);
|
||||
if (player.isAuthorized("essentials.ban.notify"))
|
||||
final IUser player = ess.getUser(onlinePlayer);
|
||||
if (Permissions.BAN_NOTIFY.isAuthorized(player))
|
||||
{
|
||||
onlinePlayer.sendMessage(_("playerBanned", senderName, user.getName(), banReason));
|
||||
}
|
||||
|
@@ -1,27 +1,24 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandbanip extends EssentialsCommand
|
||||
{
|
||||
public Commandbanip()
|
||||
{
|
||||
super("banip");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
final User player = ess.getUser(args[0]);
|
||||
@Cleanup
|
||||
final IUser player = ess.getUser(args[0]);
|
||||
player.acquireReadLock();
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
@@ -30,12 +27,12 @@ public class Commandbanip extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
final String ipAddress = player.getLastLoginAddress();
|
||||
final String ipAddress = player.getData().getIpAddress();
|
||||
if (ipAddress.length() == 0)
|
||||
{
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
ess.getServer().banIP(player.getLastLoginAddress());
|
||||
ess.getServer().banIP(player.getData().getIpAddress());
|
||||
sender.sendMessage(_("banIpAddress"));
|
||||
}
|
||||
}
|
||||
|
@@ -1,22 +1,16 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.TreeType;
|
||||
|
||||
|
||||
public class Commandbigtree extends EssentialsCommand
|
||||
{
|
||||
public Commandbigtree()
|
||||
{
|
||||
super("bigtree");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
TreeType tree;
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("redwood"))
|
||||
|
@@ -1,22 +1,17 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
|
||||
public class Commandbreak extends EssentialsCommand
|
||||
{
|
||||
public Commandbreak()
|
||||
{
|
||||
super("break");
|
||||
}
|
||||
|
||||
//TODO: Switch to use util class
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final Block block = user.getTargetBlock(null, 20);
|
||||
if (block == null)
|
||||
@@ -27,11 +22,11 @@ public class Commandbreak extends EssentialsCommand
|
||||
{
|
||||
throw new NoChargeException();
|
||||
}
|
||||
if (block.getType() == Material.BEDROCK && !user.isAuthorized("essentials.break.bedrock"))
|
||||
if (block.getType() == Material.BEDROCK && !Permissions.BREAK_BEDROCK.isAuthorized(user))
|
||||
{
|
||||
throw new Exception("You are not allowed to destroy bedrock."); //TODO: Translation
|
||||
}
|
||||
final BlockBreakEvent event = new BlockBreakEvent(block, user);
|
||||
final BlockBreakEvent event = new BlockBreakEvent(block, user.getBase());
|
||||
server.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled())
|
||||
{
|
||||
|
@@ -1,19 +1,13 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandbroadcast extends EssentialsCommand
|
||||
{
|
||||
public Commandbroadcast()
|
||||
{
|
||||
super("broadcast");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
|
@@ -1,20 +1,14 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandburn extends EssentialsCommand
|
||||
{
|
||||
public Commandburn()
|
||||
{
|
||||
super("burn");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
|
@@ -1,25 +1,20 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import java.util.List;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandclearinventory extends EssentialsCommand
|
||||
{
|
||||
public Commandclearinventory()
|
||||
{
|
||||
super("clearinventory");
|
||||
}
|
||||
|
||||
//TODO: Cleanup
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && user.isAuthorized("essentials.clearinventory.others"))
|
||||
if (args.length > 0 && Permissions.CLEARINVENTORY_OTHERS.isAuthorized(user))
|
||||
{
|
||||
//TODO: Fix fringe user match case.
|
||||
if (args[0].length() >= 3)
|
||||
@@ -59,7 +54,7 @@ public class Commandclearinventory extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
|
@@ -1,19 +1,13 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
|
||||
|
||||
public class Commandcompass extends EssentialsCommand
|
||||
{
|
||||
public Commandcompass()
|
||||
{
|
||||
super("compass");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final int bearing = (int)(user.getLocation().getYaw() + 180 + 360) % 360;
|
||||
String dir;
|
||||
|
@@ -1,34 +1,43 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Server;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commanddelhome extends EssentialsCommand
|
||||
{
|
||||
public Commanddelhome()
|
||||
{
|
||||
super("delhome");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
User user = ess.getUser(sender);
|
||||
@Cleanup
|
||||
IUser user = sender instanceof Player ? ess.getUser((Player)sender) : null;
|
||||
String name;
|
||||
final String[] expandedArg = args[0].split(":");
|
||||
String[] expandedArg;
|
||||
|
||||
if (expandedArg.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others")))
|
||||
//Allowing both formats /sethome khobbits house | /sethome khobbits:house
|
||||
final String[] nameParts = args[0].split(":");
|
||||
if (nameParts[0].length() != args[0].length())
|
||||
{
|
||||
user = getPlayer(server, expandedArg, 0, true);
|
||||
expandedArg = nameParts;
|
||||
}
|
||||
else
|
||||
{
|
||||
expandedArg = args;
|
||||
}
|
||||
|
||||
if (expandedArg.length > 1 && (user == null || Permissions.DELHOME_OTHERS.isAuthorized(user)))
|
||||
{
|
||||
user = getPlayer(expandedArg, 0, true);
|
||||
name = expandedArg[1];
|
||||
}
|
||||
else if (user == null)
|
||||
@@ -41,11 +50,10 @@ public class Commanddelhome extends EssentialsCommand
|
||||
}
|
||||
//TODO: Think up a nice error message
|
||||
/*
|
||||
* if (name.equalsIgnoreCase("bed")) {
|
||||
* throw new Exception("You cannot remove the vanilla home point");
|
||||
* }
|
||||
* if (name.equalsIgnoreCase("bed")) { throw new Exception("You cannot remove the vanilla home point"); }
|
||||
*/
|
||||
user.delHome(name.toLowerCase(Locale.ENGLISH));
|
||||
user.acquireWriteLock();
|
||||
user.getData().removeHome(name.toLowerCase(Locale.ENGLISH));
|
||||
sender.sendMessage(_("deleteHome", name));
|
||||
}
|
||||
}
|
||||
|
@@ -1,19 +1,13 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commanddeljail extends EssentialsCommand
|
||||
{
|
||||
public Commanddeljail()
|
||||
{
|
||||
super("deljail");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
|
@@ -1,25 +1,19 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commanddelwarp extends EssentialsCommand
|
||||
{
|
||||
public Commanddelwarp()
|
||||
{
|
||||
super("delwarp");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
ess.getWarps().delWarp(args[0]);
|
||||
ess.getWarps().removeWarp(args[0]);
|
||||
sender.sendMessage(_("deleteWarp", args[0]));
|
||||
}
|
||||
}
|
||||
|
@@ -1,19 +1,13 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
|
||||
|
||||
public class Commanddepth extends EssentialsCommand
|
||||
{
|
||||
public Commanddepth()
|
||||
{
|
||||
super("depth");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final int depth = user.getLocation().getBlockY() - 63;
|
||||
if (depth > 0)
|
||||
|
@@ -1,21 +1,17 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.api.ISettings;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Server;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandeco extends EssentialsCommand
|
||||
{
|
||||
public Commandeco()
|
||||
{
|
||||
super("eco");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
@@ -37,7 +33,7 @@ public class Commandeco extends EssentialsCommand
|
||||
{
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
final User player = ess.getUser(onlinePlayer);
|
||||
final IUser player = ess.getUser(onlinePlayer);
|
||||
switch (cmd)
|
||||
{
|
||||
case GIVE:
|
||||
@@ -49,14 +45,17 @@ public class Commandeco extends EssentialsCommand
|
||||
break;
|
||||
|
||||
case RESET:
|
||||
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
|
||||
@Cleanup
|
||||
ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
player.setMoney(amount == 0 ? settings.getData().getEconomy().getStartingBalance() : amount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final User player = getPlayer(server, args, 1, true);
|
||||
final IUser player = getPlayer(args, 1, true);
|
||||
switch (cmd)
|
||||
{
|
||||
case GIVE:
|
||||
@@ -68,7 +67,9 @@ public class Commandeco extends EssentialsCommand
|
||||
break;
|
||||
|
||||
case RESET:
|
||||
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
|
||||
@Cleanup ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
player.setMoney(amount == 0 ? settings.getData().getEconomy().getStartingBalance() : amount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -2,24 +2,22 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Enchantments;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.*;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.EnchantPermissions;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Commandenchant extends EssentialsCommand
|
||||
{
|
||||
public Commandenchant()
|
||||
{
|
||||
super("enchant");
|
||||
}
|
||||
|
||||
//TODO: Implement charge costs: final Trade charge = new Trade("enchant-" + enchantmentName, ess);
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final ItemStack stack = user.getItemInHand();
|
||||
if (stack == null)
|
||||
@@ -32,7 +30,7 @@ public class Commandenchant extends EssentialsCommand
|
||||
for (Map.Entry<String, Enchantment> entry : Enchantments.entrySet())
|
||||
{
|
||||
final String enchantmentName = entry.getValue().getName().toLowerCase(Locale.ENGLISH);
|
||||
if (enchantmentslist.contains(enchantmentName) || user.isAuthorized("essentials.enchant." + enchantmentName))
|
||||
if (enchantmentslist.contains(enchantmentName) || EnchantPermissions.getPermission(enchantmentName).isAuthorized(user))
|
||||
{
|
||||
enchantmentslist.add(entry.getKey());
|
||||
//enchantmentslist.add(enchantmentName);
|
||||
@@ -78,7 +76,7 @@ public class Commandenchant extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
|
||||
public static Enchantment getEnchantment(final String name, final User user) throws Exception
|
||||
public static Enchantment getEnchantment(final String name, final IUser user) throws Exception
|
||||
{
|
||||
|
||||
final Enchantment enchantment = Enchantments.getByName(name);
|
||||
@@ -87,7 +85,7 @@ public class Commandenchant extends EssentialsCommand
|
||||
throw new Exception(_("enchantmentNotFound"));
|
||||
}
|
||||
final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH);
|
||||
if (user != null && !user.isAuthorized("essentials.enchant." + enchantmentName))
|
||||
if (user != null && !EnchantPermissions.getPermission(enchantmentName).isAuthorized(user))
|
||||
{
|
||||
throw new Exception(_("enchantmentPerm", enchantmentName));
|
||||
}
|
||||
|
@@ -1,12 +1,10 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -14,41 +12,40 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class Commandessentials extends EssentialsCommand
|
||||
{
|
||||
public Commandessentials()
|
||||
{
|
||||
super("essentials");
|
||||
}
|
||||
private transient int taskid;
|
||||
private final transient Map<Player, Block> noteBlocks = new HashMap<Player, Block>();
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length == 0) {
|
||||
run_disabled(server, sender, commandLabel, args);
|
||||
if (args.length == 0)
|
||||
{
|
||||
run_disabled(sender, args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("debug"))
|
||||
{
|
||||
run_debug(server, sender, commandLabel, args);
|
||||
run_debug(sender, args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("nya"))
|
||||
{
|
||||
run_nya(server, sender, commandLabel, args);
|
||||
run_nya(sender, args);
|
||||
}
|
||||
else {
|
||||
run_reload(server, sender, commandLabel, args);
|
||||
else
|
||||
{
|
||||
run_reload(sender, args);
|
||||
}
|
||||
}
|
||||
|
||||
private void run_disabled(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
private void run_disabled(final CommandSender sender, final String[] args) throws Exception
|
||||
{
|
||||
sender.sendMessage("Essentials " + ess.getDescription().getVersion());
|
||||
sender.sendMessage("/<command> <reload/debug>");
|
||||
sender.sendMessage(_("blockList"));
|
||||
final StringBuilder disabledCommands = new StringBuilder();
|
||||
for (Map.Entry<String, String> entry : ess.getAlternativeCommandsHandler().disabledCommands().entrySet())
|
||||
for (Map.Entry<String, String> entry : ess.getCommandHandler().disabledCommands().entrySet())
|
||||
{
|
||||
if (disabledCommands.length() > 0)
|
||||
{
|
||||
if (disabledCommands.length() > 0) {
|
||||
disabledCommands.append(", ");
|
||||
}
|
||||
disabledCommands.append(entry.getKey()).append(" => ").append(entry.getValue());
|
||||
@@ -56,19 +53,19 @@ public class Commandessentials extends EssentialsCommand
|
||||
sender.sendMessage(disabledCommands.toString());
|
||||
}
|
||||
|
||||
private void run_debug(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
private void run_debug(final CommandSender sender, final String[] args) throws Exception
|
||||
{
|
||||
ess.getSettings().setDebug(!ess.getSettings().isDebug());
|
||||
sender.sendMessage("Essentials " + ess.getDescription().getVersion() + " debug mode " + (ess.getSettings().isDebug() ? "enabled" : "disabled"));
|
||||
}
|
||||
|
||||
private void run_reload(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
private void run_reload(final CommandSender sender, final String[] args) throws Exception
|
||||
{
|
||||
ess.reload();
|
||||
sender.sendMessage(_("essentialsReload", ess.getDescription().getVersion()));
|
||||
}
|
||||
|
||||
private void run_nya(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
private void run_nya(final CommandSender sender, final String[] args) throws Exception
|
||||
{
|
||||
final Map<String, Byte> noteMap = new HashMap<String, Byte>();
|
||||
noteMap.put("1F#", (byte)0x0);
|
||||
@@ -149,7 +146,7 @@ public class Commandessentials extends EssentialsCommand
|
||||
|
||||
private void stopTune()
|
||||
{
|
||||
ess.getScheduler().cancelTask(taskid);
|
||||
ess.getServer().getScheduler().cancelTask(taskid);
|
||||
for (Block block : noteBlocks.values())
|
||||
{
|
||||
if (block.getType() == Material.NOTE_BLOCK)
|
||||
|
@@ -1,32 +1,26 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandext extends EssentialsCommand
|
||||
{
|
||||
public Commandext()
|
||||
{
|
||||
super("ext");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
extinguishPlayers(server, sender, args[0]);
|
||||
extinguishPlayers(sender, args[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
@@ -35,10 +29,10 @@ public class Commandext extends EssentialsCommand
|
||||
return;
|
||||
}
|
||||
|
||||
extinguishPlayers(server, user, commandLabel);
|
||||
extinguishPlayers(user, args[0]);
|
||||
}
|
||||
|
||||
private void extinguishPlayers(final Server server, final CommandSender sender, final String name) throws Exception
|
||||
private void extinguishPlayers(final CommandSender sender, final String name) throws Exception
|
||||
{
|
||||
for (Player matchPlayer : server.matchPlayer(name))
|
||||
{
|
||||
|
@@ -1,26 +1,21 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import java.util.List;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandfeed extends EssentialsCommand
|
||||
{
|
||||
public Commandfeed()
|
||||
{
|
||||
super("feed");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && user.isAuthorized("essentials.feed.others"))
|
||||
if (args.length > 0 && Permissions.FEED_OTHERS.isAuthorized(user))
|
||||
{
|
||||
feedOtherPlayers(server,user,args[0]);
|
||||
feedOtherPlayers(user, args[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -30,7 +25,7 @@ public class Commandfeed extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
|
||||
private void feedOtherPlayers(final Server server, final CommandSender sender, final String name)
|
||||
private void feedOtherPlayers(final CommandSender sender, final String name)
|
||||
{
|
||||
final List<Player> players = server.matchPlayer(name);
|
||||
if (players.isEmpty())
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.entity.SmallFireball;
|
||||
import org.bukkit.util.Vector;
|
||||
@@ -9,13 +8,8 @@ import org.bukkit.util.Vector;
|
||||
|
||||
public class Commandfireball extends EssentialsCommand
|
||||
{
|
||||
public Commandfireball()
|
||||
{
|
||||
super("fireball");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
boolean small = false;
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("small"))
|
||||
@@ -23,7 +17,7 @@ public class Commandfireball extends EssentialsCommand
|
||||
small = true;
|
||||
}
|
||||
final Vector direction = user.getEyeLocation().getDirection().multiply(2);
|
||||
Fireball fireball = user.getWorld().spawn(user.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), small ? SmallFireball.class : Fireball.class);
|
||||
final Fireball fireball = user.getWorld().spawn(user.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), small ? SmallFireball.class : Fireball.class);
|
||||
fireball.setShooter(user.getBase());
|
||||
}
|
||||
}
|
||||
|
@@ -1,38 +1,33 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandgamemode extends EssentialsCommand
|
||||
{
|
||||
public Commandgamemode()
|
||||
{
|
||||
super("gamemode");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
gamemodeOtherPlayers(server, sender, args[0]);
|
||||
gamemodeOtherPlayers(sender, args[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && !args[0].trim().isEmpty() && user.isAuthorized("essentials.gamemode.others"))
|
||||
if (args.length > 0 && !args[0].trim().isEmpty() && Permissions.GAMEMODE_OTHERS.isAuthorized(user))
|
||||
{
|
||||
gamemodeOtherPlayers(server, user, args[0]);
|
||||
gamemodeOtherPlayers(user, args[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -40,11 +35,11 @@ public class Commandgamemode extends EssentialsCommand
|
||||
user.sendMessage(_("gameMode", _(user.getGameMode().toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName()));
|
||||
}
|
||||
|
||||
private void gamemodeOtherPlayers(final Server server, final CommandSender sender, final String name)
|
||||
private void gamemodeOtherPlayers(final CommandSender sender, final String name)
|
||||
{
|
||||
for (Player matchPlayer : server.matchPlayer(name))
|
||||
{
|
||||
final User player = ess.getUser(matchPlayer);
|
||||
final IUser player = ess.getUser(matchPlayer);
|
||||
if (player.isHidden())
|
||||
{
|
||||
continue;
|
||||
|
@@ -1,20 +1,14 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandgc extends EssentialsCommand
|
||||
{
|
||||
public Commandgc()
|
||||
{
|
||||
super("gc");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
sender.sendMessage(_("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024)));
|
||||
sender.sendMessage(_("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024)));
|
||||
|
@@ -1,24 +1,19 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandgetpos extends EssentialsCommand
|
||||
{
|
||||
public Commandgetpos()
|
||||
{
|
||||
super("getpos");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && user.isAuthorized("essentials.getpos.others"))
|
||||
if (args.length > 0 && Permissions.GETPOS_OTHERS.isAuthorized(user))
|
||||
{
|
||||
final User otherUser = getPlayer(server, args, 0);
|
||||
final IUser otherUser = getPlayer(args, 0);
|
||||
outputPosition(user, otherUser.getLocation(), user.getLocation());
|
||||
}
|
||||
else
|
||||
@@ -28,13 +23,13 @@ public class Commandgetpos extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
final User user = getPlayer(server, args, 0);
|
||||
final IUser user = getPlayer(args, 0);
|
||||
outputPosition(sender, user.getLocation(), null);
|
||||
}
|
||||
|
||||
|
@@ -1,11 +1,10 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.GivePermissions;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -14,48 +13,29 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class Commandgive extends EssentialsCommand
|
||||
{
|
||||
public Commandgive()
|
||||
{
|
||||
super("give");
|
||||
}
|
||||
|
||||
//TODO: move these messages to message file
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
final ItemStack stack = ess.getItemDb().get(args[1]);
|
||||
final IUser giveTo = getPlayer(args, 0);
|
||||
|
||||
final ItemStack stack = ess.getItemDb().get(args[1], giveTo);
|
||||
|
||||
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||
if (sender instanceof Player
|
||||
&& (ess.getSettings().permissionBasedItemSpawn()
|
||||
? (!ess.getUser(sender).isAuthorized("essentials.give.item-all")
|
||||
&& !ess.getUser(sender).isAuthorized("essentials.give.item-" + itemname)
|
||||
&& !ess.getUser(sender).isAuthorized("essentials.give.item-" + stack.getTypeId()))
|
||||
: (!ess.getUser(sender).isAuthorized("essentials.itemspawn.exempt")
|
||||
&& !ess.getUser(sender).canSpawnItem(stack.getTypeId()))))
|
||||
if (!GivePermissions.getPermission(stack.getType()).isAuthorized(sender))
|
||||
{
|
||||
throw new Exception(ChatColor.RED + "You are not allowed to spawn the item " + itemname);
|
||||
}
|
||||
|
||||
final User giveTo = getPlayer(server, args, 0);
|
||||
|
||||
if (args.length > 2 && Integer.parseInt(args[2]) > 0)
|
||||
{
|
||||
stack.setAmount(Integer.parseInt(args[2]));
|
||||
}
|
||||
else if (ess.getSettings().getDefaultStackSize() > 0)
|
||||
{
|
||||
stack.setAmount(ess.getSettings().getDefaultStackSize());
|
||||
}
|
||||
else if (ess.getSettings().getOversizedStackSize() > 0 && giveTo.isAuthorized("essentials.oversizedstacks"))
|
||||
{
|
||||
stack.setAmount(ess.getSettings().getOversizedStackSize());
|
||||
}
|
||||
|
||||
if (args.length > 3)
|
||||
{
|
||||
@@ -66,7 +46,7 @@ public class Commandgive extends EssentialsCommand
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final Enchantment enchantment = Commandenchant.getEnchantment(split[0], sender instanceof Player ? ess.getUser(sender) : null);
|
||||
final Enchantment enchantment = Commandenchant.getEnchantment(split[0], sender instanceof Player ? ess.getUser((Player)sender) : null);
|
||||
int level;
|
||||
if (split.length > 1)
|
||||
{
|
||||
@@ -85,16 +65,10 @@ public class Commandgive extends EssentialsCommand
|
||||
throw new Exception(ChatColor.RED + "You can't give air.");
|
||||
}
|
||||
|
||||
giveTo.giveItems(stack, false);
|
||||
|
||||
final String itemName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
|
||||
sender.sendMessage(ChatColor.BLUE + "Giving " + stack.getAmount() + " of " + itemName + " to " + giveTo.getDisplayName() + ".");
|
||||
if (giveTo.isAuthorized("essentials.oversizedstacks"))
|
||||
{
|
||||
InventoryWorkaround.addItem(giveTo.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack);
|
||||
}
|
||||
else
|
||||
{
|
||||
InventoryWorkaround.addItem(giveTo.getInventory(), true, stack);
|
||||
}
|
||||
giveTo.updateInventory();
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,47 +1,42 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandgod extends EssentialsCommand
|
||||
{
|
||||
public Commandgod()
|
||||
{
|
||||
super("god");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
godOtherPlayers(server, sender, args[0]);
|
||||
godOtherPlayers(sender, args[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && !args[0].trim().isEmpty() && user.isAuthorized("essentials.god.others"))
|
||||
if (args.length > 0 && !args[0].trim().isEmpty() && Permissions.GOD_OTHERS.isAuthorized(user))
|
||||
{
|
||||
godOtherPlayers(server, user, args[0]);
|
||||
godOtherPlayers(user, args[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
user.sendMessage(_("godMode", (user.toggleGodModeEnabled() ? _("enabled") : _("disabled"))));
|
||||
}
|
||||
|
||||
private void godOtherPlayers(final Server server, final CommandSender sender, final String name)
|
||||
private void godOtherPlayers(final CommandSender sender, final String name)
|
||||
{
|
||||
for (Player matchPlayer : server.matchPlayer(name))
|
||||
{
|
||||
final User player = ess.getUser(matchPlayer);
|
||||
final IUser player = ess.getUser(matchPlayer);
|
||||
if (player.isHidden())
|
||||
{
|
||||
continue;
|
||||
|
@@ -1,55 +1,47 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import com.earth2me.essentials.user.UserData.TimestampType;
|
||||
import java.util.List;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandheal extends EssentialsCommand
|
||||
{
|
||||
public Commandheal()
|
||||
{
|
||||
super("heal");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
|
||||
if (args.length > 0 && user.isAuthorized("essentials.heal.others"))
|
||||
if (args.length > 0 && Permissions.HEAL_OTHERS.isAuthorized(user))
|
||||
{
|
||||
if (!user.isAuthorized("essentials.heal.cooldown.bypass"))
|
||||
{
|
||||
user.healCooldown();
|
||||
}
|
||||
healOtherPlayers(server, user, args[0]);
|
||||
user.checkCooldown(TimestampType.LASTHEAL, ess.getGroups().getHealCooldown(user), true, Permissions.HEAL_COOLDOWN_BYPASS);
|
||||
|
||||
healOtherPlayers(user, args[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!user.isAuthorized("essentials.heal.cooldown.bypass"))
|
||||
{
|
||||
user.healCooldown();
|
||||
}
|
||||
user.checkCooldown(TimestampType.LASTHEAL, ess.getGroups().getHealCooldown(user), true, Permissions.HEAL_COOLDOWN_BYPASS);
|
||||
|
||||
user.setHealth(20);
|
||||
user.setFoodLevel(20);
|
||||
user.sendMessage(_("heal"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
healOtherPlayers(server, sender, args[0]);
|
||||
healOtherPlayers(sender, args[0]);
|
||||
}
|
||||
|
||||
private void healOtherPlayers(final Server server, final CommandSender sender, final String name)
|
||||
private void healOtherPlayers(final CommandSender sender, final String name)
|
||||
{
|
||||
final List<Player> players = server.matchPlayer(name);
|
||||
if (players.isEmpty())
|
||||
|
@@ -1,22 +1,16 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.textreader.*;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandhelp extends EssentialsCommand
|
||||
{
|
||||
public Commandhelp()
|
||||
{
|
||||
super("help");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
IText output;
|
||||
String pageStr = args.length > 0 ? args[0] : null;
|
||||
@@ -41,11 +35,11 @@ public class Commandhelp extends EssentialsCommand
|
||||
output = new KeywordReplacer(input, user, ess);
|
||||
}
|
||||
final TextPager pager = new TextPager(output);
|
||||
pager.showPage(pageStr, chapterPageStr, "help", user);
|
||||
pager.showPage(pageStr, chapterPageStr, commandLabel, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
sender.sendMessage(_("helpConsole"));
|
||||
}
|
||||
|
@@ -1,33 +1,29 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandhelpop extends EssentialsCommand
|
||||
{
|
||||
public Commandhelpop()
|
||||
{
|
||||
super("helpop");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
final String message = _("helpOp", user.getDisplayName(), getFinalArg(args, 0));
|
||||
final String message = _("helpOp", user.getDisplayName(), Util.stripColor(getFinalArg(args, 0)));
|
||||
logger.log(Level.INFO, message);
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
final User player = ess.getUser(onlinePlayer);
|
||||
if (!player.isAuthorized("essentials.helpop.receive"))
|
||||
final IUser player = ess.getUser(onlinePlayer);
|
||||
if (!Permissions.HELPOP_RECEIVE.isAuthorized(player))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@@ -2,40 +2,36 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
|
||||
|
||||
public class Commandhome extends EssentialsCommand
|
||||
{
|
||||
public Commandhome()
|
||||
{
|
||||
super("home");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
final Trade charge = new Trade(commandName, ess);
|
||||
charge.isAffordableFor(user);
|
||||
User player = user;
|
||||
IUser player = user;
|
||||
String homeName = "";
|
||||
String[] nameParts;
|
||||
if (args.length > 0)
|
||||
{
|
||||
nameParts = args[0].split(":");
|
||||
if (nameParts[0].length() == args[0].length() || !user.isAuthorized("essentials.home.others"))
|
||||
if (nameParts[0].length() == args[0].length() || !Permissions.HOME_OTHERS.isAuthorized(user))
|
||||
{
|
||||
homeName = nameParts[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
player = getPlayer(server, nameParts, 0, true);
|
||||
player = getPlayer(nameParts, 0, true);
|
||||
if (nameParts.length > 1)
|
||||
{
|
||||
homeName = nameParts[1];
|
||||
@@ -47,27 +43,31 @@ public class Commandhome extends EssentialsCommand
|
||||
if ("bed".equalsIgnoreCase(homeName))
|
||||
{
|
||||
final Location bed = player.getBedSpawnLocation();
|
||||
if (bed != null)
|
||||
if (bed != null && bed.getBlock().getType() == Material.BED_BLOCK)
|
||||
{
|
||||
user.getTeleport().teleport(bed, charge, TeleportCause.COMMAND);
|
||||
return;
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
user.getTeleport().home(player, homeName.toLowerCase(Locale.ENGLISH), charge);
|
||||
}
|
||||
catch (NotEnoughArgumentsException e)
|
||||
{
|
||||
Location bed = player.getBedSpawnLocation();
|
||||
if (bed != null && bed.getBlock().getType() != Material.BED_BLOCK)
|
||||
{
|
||||
bed = null;
|
||||
}
|
||||
final List<String> homes = player.getHomes();
|
||||
if (homes.isEmpty() && player.equals(user))
|
||||
{
|
||||
final Location bed = player.getBedSpawnLocation();
|
||||
if (bed != null)
|
||||
{
|
||||
user.getTeleport().teleport(bed, charge, TeleportCause.COMMAND);
|
||||
return;
|
||||
throw new NoChargeException();
|
||||
}
|
||||
user.getTeleport().respawn(charge, TeleportCause.COMMAND);
|
||||
return;
|
||||
|
||||
}
|
||||
else if (homes.isEmpty())
|
||||
{
|
||||
@@ -76,11 +76,13 @@ public class Commandhome extends EssentialsCommand
|
||||
else if (homes.size() == 1 && player.equals(user))
|
||||
{
|
||||
user.getTeleport().home(player, homes.get(0), charge);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bed != null)
|
||||
{
|
||||
homes.add("bed");
|
||||
}
|
||||
user.sendMessage(_("homes", Util.joinList(homes)));
|
||||
}
|
||||
}
|
||||
|
@@ -1,39 +1,34 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
|
||||
|
||||
public class Commandignore extends EssentialsCommand
|
||||
{
|
||||
public Commandignore()
|
||||
{
|
||||
super("ignore");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
User player;
|
||||
IUser player;
|
||||
try
|
||||
{
|
||||
player = getPlayer(server, args, 0);
|
||||
player = getPlayer(args, 0);
|
||||
}
|
||||
catch (NoSuchFieldException ex)
|
||||
{
|
||||
player = ess.getOfflineUser(args[0]);
|
||||
player = ess.getUser(args[0]);
|
||||
}
|
||||
if (player == null)
|
||||
{
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
final String name = player.getName();
|
||||
if (user.isIgnoredPlayer(name))
|
||||
user.acquireWriteLock();
|
||||
if (user.isIgnoringPlayer(name))
|
||||
{
|
||||
user.setIgnoredPlayer(name, false);
|
||||
user.sendMessage(_("unignorePlayer", player.getName()));
|
||||
|
@@ -4,23 +4,17 @@ import com.earth2me.essentials.textreader.IText;
|
||||
import com.earth2me.essentials.textreader.KeywordReplacer;
|
||||
import com.earth2me.essentials.textreader.TextInput;
|
||||
import com.earth2me.essentials.textreader.TextPager;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandinfo extends EssentialsCommand
|
||||
{
|
||||
public Commandinfo()
|
||||
{
|
||||
super("info");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final IText input = new TextInput(sender, "info", true, ess);
|
||||
final IText output = new KeywordReplacer(input, sender, ess);
|
||||
final TextPager pager = new TextPager(output);
|
||||
pager.showPage(args.length > 0 ? args[0] : null, args.length > 1 ? args[1] : null, "info", sender);
|
||||
pager.showPage(args.length > 0 ? args[0] : null, args.length > 1 ? args[1] : null, commandLabel, sender);
|
||||
}
|
||||
}
|
||||
|
@@ -1,43 +1,38 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.user.Inventory;
|
||||
import java.util.Arrays;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Commandinvsee extends EssentialsCommand
|
||||
{
|
||||
public Commandinvsee()
|
||||
{
|
||||
super("invsee");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
|
||||
if (args.length < 1 && user.getSavedInventory() == null)
|
||||
if (args.length < 1 && user.getData().getInventory() == null)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
User invUser = user;
|
||||
IUser invUser = user;
|
||||
if (args.length == 1)
|
||||
{
|
||||
invUser = getPlayer(server, args, 0);
|
||||
invUser = getPlayer(args, 0);
|
||||
}
|
||||
if (invUser == user && user.getSavedInventory() != null)
|
||||
user.acquireWriteLock();
|
||||
if (invUser == user && user.getData().getInventory() != null)
|
||||
{
|
||||
invUser.getInventory().setContents(user.getSavedInventory());
|
||||
user.setSavedInventory(null);
|
||||
invUser.getInventory().setContents(user.getData().getInventory().getBukkitInventory());
|
||||
user.getData().setInventory(null);
|
||||
user.sendMessage(_("invRestored"));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
|
||||
if (user.getSavedInventory() == null)
|
||||
if (user.getData().getInventory() == null)
|
||||
{
|
||||
user.setSavedInventory(user.getInventory().getContents());
|
||||
user.getData().setInventory(new Inventory(user.getInventory().getContents()));
|
||||
}
|
||||
ItemStack[] invUserStack = invUser.getInventory().getContents();
|
||||
final int userStackLength = user.getInventory().getContents().length;
|
||||
|
@@ -1,38 +1,27 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.ItemPermissions;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Commanditem extends EssentialsCommand
|
||||
{
|
||||
public Commanditem()
|
||||
{
|
||||
super("item");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
final ItemStack stack = ess.getItemDb().get(args[0]);
|
||||
final ItemStack stack = ess.getItemDb().get(args[0], user);
|
||||
|
||||
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||
if (ess.getSettings().permissionBasedItemSpawn()
|
||||
? (!user.isAuthorized("essentials.itemspawn.item-all")
|
||||
&& !user.isAuthorized("essentials.itemspawn.item-" + itemname)
|
||||
&& !user.isAuthorized("essentials.itemspawn.item-" + stack.getTypeId()))
|
||||
: (!user.isAuthorized("essentials.itemspawn.exempt")
|
||||
&& !user.canSpawnItem(stack.getTypeId())))
|
||||
if (!ItemPermissions.getPermission(stack.getType()).isAuthorized(user))
|
||||
{
|
||||
throw new Exception(_("cantSpawnItem", itemname));
|
||||
}
|
||||
@@ -41,14 +30,6 @@ public class Commanditem extends EssentialsCommand
|
||||
{
|
||||
stack.setAmount(Integer.parseInt(args[1]));
|
||||
}
|
||||
else if (ess.getSettings().getDefaultStackSize() > 0)
|
||||
{
|
||||
stack.setAmount(ess.getSettings().getDefaultStackSize());
|
||||
}
|
||||
else if (ess.getSettings().getOversizedStackSize() > 0 && user.isAuthorized("essentials.oversizedstacks"))
|
||||
{
|
||||
stack.setAmount(ess.getSettings().getOversizedStackSize());
|
||||
}
|
||||
|
||||
if (args.length > 2)
|
||||
{
|
||||
@@ -78,16 +59,9 @@ public class Commanditem extends EssentialsCommand
|
||||
throw new Exception(_("cantSpawnItem", "Air"));
|
||||
}
|
||||
|
||||
user.giveItems(stack, false);
|
||||
|
||||
final String displayName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
|
||||
user.sendMessage(_("itemSpawn", stack.getAmount(), displayName));
|
||||
if (user.isAuthorized("essentials.oversizedstacks"))
|
||||
{
|
||||
InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack);
|
||||
}
|
||||
else
|
||||
{
|
||||
InventoryWorkaround.addItem(user.getInventory(), true, stack);
|
||||
}
|
||||
user.updateInventory();
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -8,13 +7,8 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class Commanditemdb extends EssentialsCommand
|
||||
{
|
||||
public Commanditemdb()
|
||||
{
|
||||
super("find");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
ItemStack itemStack = null;
|
||||
if (args.length < 1)
|
||||
|
@@ -1,19 +1,13 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandjails extends EssentialsCommand
|
||||
{
|
||||
public Commandjails()
|
||||
{
|
||||
super("jails");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
sender.sendMessage("§7" + Util.joinList(" ", ess.getJails().getList()));
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user