mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-11 17:15:07 +02:00
Master -> 3.0
This commit is contained in:
@@ -1,76 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE project [ <!ENTITY buildinc SYSTEM "../build.inc.xml"> ]>
|
||||
<!-- You may freely edit this file. See commented blocks below for -->
|
||||
<!-- some examples of how to customize the build. -->
|
||||
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||
<!-- By default, only the Clean and Build commands use this build script. -->
|
||||
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
||||
<!-- the Compile on Save feature is turned off for the project. -->
|
||||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
||||
<!-- in the project's Project Properties dialog box.-->
|
||||
<project name="EssentialsChat" default="default" basedir=".">
|
||||
<description>Builds, tests, and runs the project EssentialsChat.</description>
|
||||
<import file="nbproject/build-impl.xml"/>
|
||||
&buildinc;
|
||||
<!--
|
||||
|
||||
There exist several targets which are by default empty and which can be
|
||||
used for execution of your tasks. These targets are usually executed
|
||||
before and after some main targets. They are:
|
||||
|
||||
-pre-init: called before initialization of project properties
|
||||
-post-init: called after initialization of project properties
|
||||
-pre-compile: called before javac compilation
|
||||
-post-compile: called after javac compilation
|
||||
-pre-compile-single: called before javac compilation of single file
|
||||
-post-compile-single: called after javac compilation of single file
|
||||
-pre-compile-test: called before javac compilation of JUnit tests
|
||||
-post-compile-test: called after javac compilation of JUnit tests
|
||||
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||
-pre-jar: called before JAR building
|
||||
-post-jar: called after JAR building
|
||||
-post-clean: called after cleaning build products
|
||||
|
||||
(Targets beginning with '-' are not intended to be called on their own.)
|
||||
|
||||
Example of inserting an obfuscator after compilation could look like this:
|
||||
|
||||
<target name="-post-compile">
|
||||
<obfuscate>
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
</obfuscate>
|
||||
</target>
|
||||
|
||||
For list of available properties check the imported
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
|
||||
Another way to customize the build is by overriding existing main targets.
|
||||
The targets of interest are:
|
||||
|
||||
-init-macrodef-javac: defines macro for javac compilation
|
||||
-init-macrodef-junit: defines macro for junit execution
|
||||
-init-macrodef-debug: defines macro for class debugging
|
||||
-init-macrodef-java: defines macro for class execution
|
||||
-do-jar-with-manifest: JAR building (if you are using a manifest)
|
||||
-do-jar-without-manifest: JAR building (if you are not using a manifest)
|
||||
run: execution of project
|
||||
-javadoc-build: Javadoc generation
|
||||
test-report: JUnit report generation
|
||||
|
||||
An example of overriding the target for project execution could look like this:
|
||||
|
||||
<target name="run" depends="EssentialsChat-impl.jar">
|
||||
<exec dir="bin" executable="launcher.exe">
|
||||
<arg file="${dist.jar}"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
Notice that the overridden target depends on the jar target and not only on
|
||||
the compile target as the regular run target does. Again, for a list of available
|
||||
properties which you can use, check the target you are overriding in the
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
-->
|
||||
</project>
|
File diff suppressed because it is too large
Load Diff
@@ -1,8 +0,0 @@
|
||||
build.xml.data.CRC32=7c7f517b
|
||||
build.xml.script.CRC32=71afd555
|
||||
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=7c7f517b
|
||||
nbproject/build-impl.xml.script.CRC32=52184b61
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46
|
@@ -1,113 +0,0 @@
|
||||
annotation.processing.enabled=true
|
||||
annotation.processing.enabled.in.editor=false
|
||||
annotation.processing.run.all.processors=true
|
||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||
application.title=EssentialsChat
|
||||
application.vendor=
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=120
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAnnotationArgs=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineArrayInit=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAssignment=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineBinaryOp=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineCallArgs=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineDisjunctiveCatchTypes=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineFor=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineImplements=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineMethodParams=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineParenthesized=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTernaryOp=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineThrows=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTryResources=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesAfterClassHeader=0
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesBeforeClass=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement=NEW_LINE
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.expand-tabs=false
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.importGroupsOrder=*
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indent-shift-width=4
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indentCasesFromSwitch=false
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement=NEW_LINE
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement=NEW_LINE
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeCatchOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeElseOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeFinallyOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeWhileOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.separateImportGroups=false
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceAfterTypeCast=false
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaces-per-tab=4
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.tab-size=4
|
||||
build.classes.dir=${build.dir}/classes
|
||||
build.classes.excludes=**/*.java,**/*.form
|
||||
# This directory is removed when the project is cleaned:
|
||||
build.dir=build
|
||||
build.generated.dir=${build.dir}/generated
|
||||
build.generated.sources.dir=${build.dir}/generated-sources
|
||||
# Only compile against the classpath explicitly listed here:
|
||||
build.sysclasspath=ignore
|
||||
build.test.classes.dir=${build.dir}/test/classes
|
||||
build.test.results.dir=${build.dir}/test/results
|
||||
# Uncomment to specify the preferred debugger connection transport:
|
||||
#debug.transport=dt_socket
|
||||
debug.classpath=\
|
||||
${run.classpath}
|
||||
debug.test.classpath=\
|
||||
${run.test.classpath}
|
||||
# This directory is removed when the project is cleaned:
|
||||
dist.dir=dist
|
||||
dist.jar=${dist.dir}/EssentialsChat.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
endorsed.classpath=
|
||||
excludes=
|
||||
file.reference.bukkit.jar=../lib/bukkit.jar
|
||||
includes=**
|
||||
jar.compress=true
|
||||
javac.classpath=\
|
||||
${reference.Essentials.jar}:\
|
||||
${file.reference.bukkit.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
javac.processorpath=\
|
||||
${javac.classpath}
|
||||
javac.source=1.6
|
||||
javac.target=1.6
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}:\
|
||||
${libs.junit_4.10.classpath}
|
||||
javac.test.processorpath=\
|
||||
${javac.test.classpath}
|
||||
javadoc.additionalparam=
|
||||
javadoc.author=false
|
||||
javadoc.encoding=${source.encoding}
|
||||
javadoc.noindex=false
|
||||
javadoc.nonavbar=false
|
||||
javadoc.notree=false
|
||||
javadoc.private=false
|
||||
javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
mkdist.disabled=true
|
||||
platform.active=default_platform
|
||||
project.Essentials=../Essentials
|
||||
reference.Essentials.jar=${project.Essentials}/dist/Essentials.jar
|
||||
run.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
# Space-separated list of JVM arguments used when running the project
|
||||
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
|
||||
# or test-sys-prop.name=value to set system properties for unit tests):
|
||||
run.jvmargs=
|
||||
run.test.classpath=\
|
||||
${javac.test.classpath}:\
|
||||
${build.test.classes.dir}
|
||||
source.encoding=UTF-8
|
||||
src.dir=src
|
||||
test.src.dir=test
|
@@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||
<type>org.netbeans.modules.java.j2seproject</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<name>EssentialsChat</name>
|
||||
<source-roots>
|
||||
<root id="src.dir"/>
|
||||
</source-roots>
|
||||
<test-roots>
|
||||
<root id="test.src.dir"/>
|
||||
</test-roots>
|
||||
</data>
|
||||
<libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
|
||||
<definitions>..\lib\nblibraries.properties</definitions>
|
||||
</libraries>
|
||||
<references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
|
||||
<reference>
|
||||
<foreign-project>Essentials</foreign-project>
|
||||
<artifact-type>jar</artifact-type>
|
||||
<script>build.xml</script>
|
||||
<target>jar</target>
|
||||
<clean-target>clean</clean-target>
|
||||
<id>jar</id>
|
||||
</reference>
|
||||
</references>
|
||||
</configuration>
|
||||
</project>
|
21
EssentialsChat/pom.xml
Normal file
21
EssentialsChat/pom.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>net.essentials3</groupId>
|
||||
<artifactId>BuildAll</artifactId>
|
||||
<version>3.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>EssentialsChat</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>Essentials</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@@ -0,0 +1,22 @@
|
||||
package com.earth2me.essentials.chat;
|
||||
|
||||
import com.earth2me.essentials.api.IPermission;
|
||||
import com.earth2me.essentials.permissions.BasePermission;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public class ChatPermissions {
|
||||
private static Map<String, IPermission> permissions = new HashMap<String, IPermission>();
|
||||
|
||||
public static IPermission getPermission(final String groupName)
|
||||
{
|
||||
IPermission perm = permissions.get(groupName);
|
||||
if (perm == null)
|
||||
{
|
||||
perm = new BasePermission("essentials.chat.",groupName.toLowerCase(Locale.ENGLISH));
|
||||
permissions.put(groupName, perm);
|
||||
}
|
||||
return perm;
|
||||
}
|
||||
}
|
@@ -1,25 +1,24 @@
|
||||
package com.earth2me.essentials.chat;
|
||||
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
|
||||
|
||||
public class ChatStore
|
||||
{
|
||||
private final User user;
|
||||
private final String type;
|
||||
private final Trade charge;
|
||||
private long radius;
|
||||
private final transient IUser user;
|
||||
private final transient String type;
|
||||
private final transient Trade charge;
|
||||
|
||||
ChatStore(final IEssentials ess, final User user, final String type)
|
||||
public ChatStore(final IEssentials ess, final IUser user, final String type)
|
||||
{
|
||||
this.user = user;
|
||||
this.type = type;
|
||||
this.charge = new Trade(getLongType(), ess);
|
||||
}
|
||||
|
||||
public User getUser()
|
||||
public IUser getUser()
|
||||
{
|
||||
return user;
|
||||
}
|
||||
@@ -34,18 +33,8 @@ public class ChatStore
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getLongType()
|
||||
public final String getLongType()
|
||||
{
|
||||
return type.length() == 0 ? "chat" : "chat-" + type;
|
||||
}
|
||||
|
||||
public long getRadius()
|
||||
{
|
||||
return radius;
|
||||
}
|
||||
|
||||
public void setRadius(long radius)
|
||||
{
|
||||
this.radius = radius;
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,12 @@
|
||||
package com.earth2me.essentials.chat;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.chat.listenerlevel.EssentialsChatPlayerListenerHighest;
|
||||
import com.earth2me.essentials.chat.listenerlevel.EssentialsChatPlayerListenerLowest;
|
||||
import com.earth2me.essentials.chat.listenerlevel.EssentialsChatPlayerListenerNormal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
@@ -15,13 +17,12 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
public class EssentialsChat extends JavaPlugin
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient Map<String, IEssentialsChatListener> chatListener;
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
final PluginManager pluginManager = getServer().getPluginManager();
|
||||
final IEssentials ess = (IEssentials)pluginManager.getPlugin("Essentials");
|
||||
final IEssentials ess = (IEssentials)pluginManager.getPlugin("Essentials3");
|
||||
if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion()))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("versionMismatchAll"));
|
||||
@@ -32,35 +33,21 @@ public class EssentialsChat extends JavaPlugin
|
||||
return;
|
||||
}
|
||||
|
||||
chatListener = new ConcurrentSkipListMap<String, IEssentialsChatListener>();
|
||||
final Map<PlayerChatEvent, ChatStore> chatStore = new HashMap<PlayerChatEvent, ChatStore>();
|
||||
|
||||
|
||||
final EssentialsChatPlayerListenerLowest playerListenerLowest = new EssentialsChatPlayerListenerLowest(getServer(), ess, chatListener, chatStore);
|
||||
final EssentialsChatPlayerListenerNormal playerListenerNormal = new EssentialsChatPlayerListenerNormal(getServer(), ess, chatListener, chatStore);
|
||||
final EssentialsChatPlayerListenerHighest playerListenerHighest = new EssentialsChatPlayerListenerHighest(getServer(), ess, chatListener, chatStore);
|
||||
final EssentialsChatPlayerListenerLowest playerListenerLowest = new EssentialsChatPlayerListenerLowest(getServer(), ess, chatStore);
|
||||
final EssentialsChatPlayerListenerNormal playerListenerNormal = new EssentialsChatPlayerListenerNormal(getServer(), ess, chatStore);
|
||||
final EssentialsChatPlayerListenerHighest playerListenerHighest = new EssentialsChatPlayerListenerHighest(getServer(), ess, chatStore);
|
||||
pluginManager.registerEvents(playerListenerLowest, this);
|
||||
pluginManager.registerEvents(playerListenerNormal, this);
|
||||
pluginManager.registerEvents(playerListenerHighest, this);
|
||||
|
||||
final EssentialsLocalChatEventListener localChatListener = new EssentialsLocalChatEventListener(getServer(), ess);
|
||||
pluginManager.registerEvents(localChatListener, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
if (chatListener != null)
|
||||
{
|
||||
chatListener.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void addEssentialsChatListener(final String plugin, final IEssentialsChatListener listener)
|
||||
{
|
||||
chatListener.put(plugin, listener);
|
||||
}
|
||||
|
||||
public IEssentialsChatListener removeEssentialsChatListener(final String plugin)
|
||||
{
|
||||
return chatListener.remove(plugin);
|
||||
}
|
||||
}
|
||||
|
@@ -1,15 +1,19 @@
|
||||
package com.earth2me.essentials.chat;
|
||||
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.api.ChargeException;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import com.earth2me.essentials.utils.Util;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IRanks;
|
||||
import com.earth2me.essentials.api.ISettings;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
@@ -18,18 +22,15 @@ import org.bukkit.event.player.PlayerChatEvent;
|
||||
public abstract class EssentialsChatPlayer implements Listener
|
||||
{
|
||||
protected transient IEssentials ess;
|
||||
protected final static Logger logger = Logger.getLogger("Minecraft");
|
||||
protected final transient Map<String, IEssentialsChatListener> listeners;
|
||||
protected final static Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
protected final transient Server server;
|
||||
protected final transient Map<PlayerChatEvent, ChatStore> chatStorage;
|
||||
|
||||
public EssentialsChatPlayer(final Server server,
|
||||
final IEssentials ess,
|
||||
final Map<String, IEssentialsChatListener> listeners,
|
||||
final Map<PlayerChatEvent, ChatStore> chatStorage)
|
||||
{
|
||||
this.ess = ess;
|
||||
this.listeners = listeners;
|
||||
this.server = server;
|
||||
this.chatStorage = chatStorage;
|
||||
}
|
||||
@@ -38,35 +39,6 @@ public abstract class EssentialsChatPlayer implements Listener
|
||||
{
|
||||
}
|
||||
|
||||
public boolean isAborted(final PlayerChatEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
for (IEssentialsChatListener listener : listeners.values())
|
||||
{
|
||||
if (listener.shouldHandleThisChat(event))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getChatType(final String message)
|
||||
{
|
||||
switch (message.charAt(0))
|
||||
{
|
||||
case '!':
|
||||
return "shout";
|
||||
case '?':
|
||||
return "question";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public ChatStore getChatStore(final PlayerChatEvent event)
|
||||
{
|
||||
return chatStorage.get(event);
|
||||
@@ -82,12 +54,7 @@ public abstract class EssentialsChatPlayer implements Listener
|
||||
return chatStorage.remove(event);
|
||||
}
|
||||
|
||||
protected void charge(final User user, final Trade charge) throws ChargeException
|
||||
{
|
||||
charge.charge(user);
|
||||
}
|
||||
|
||||
protected boolean charge(final PlayerChatEvent event, final ChatStore chatStore)
|
||||
protected void chargeChat(final PlayerChatEvent event, final ChatStore chatStore)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -95,34 +62,85 @@ public abstract class EssentialsChatPlayer implements Listener
|
||||
}
|
||||
catch (ChargeException e)
|
||||
{
|
||||
ess.showError(chatStore.getUser(), e, chatStore.getLongType());
|
||||
ess.getCommandHandler().showCommandError(chatStore.getUser(), chatStore.getLongType(), e);
|
||||
event.setCancelled(true);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void sendLocalChat(final PlayerChatEvent event, final ChatStore chatStore)
|
||||
protected void charge(final CommandSender sender, final Trade charge) throws ChargeException
|
||||
{
|
||||
event.setCancelled(true);
|
||||
final User sender = chatStore.getUser();
|
||||
logger.info(_("localFormat", sender.getName(), event.getMessage()));
|
||||
final Location loc = sender.getLocation();
|
||||
final World world = loc.getWorld();
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
charge.charge(ess.getUser((Player)sender));
|
||||
}
|
||||
}
|
||||
|
||||
if (charge(event, chatStore) == false)
|
||||
protected void formatChat(final PlayerChatEvent event, final ChatStore chatStore)
|
||||
{
|
||||
final IUser user = chatStore.getUser();
|
||||
if (Permissions.CHAT_COLOR.isAuthorized(user))
|
||||
{
|
||||
event.setMessage(Util.stripColor(event.getMessage()));
|
||||
}
|
||||
String group = ess.getRanks().getMainGroup(user);
|
||||
String world = user.getWorld().getName();
|
||||
|
||||
IRanks groupSettings = ess.getRanks();
|
||||
event.setFormat(groupSettings.getChatFormat(user).format(new Object[]
|
||||
{
|
||||
group, world, world.substring(0, 1).toUpperCase(Locale.ENGLISH)
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
//TODO: Flesh this out - '?' trigger is too easily accidentally triggered
|
||||
protected String getChatType(final String message)
|
||||
{
|
||||
switch (message.charAt(0))
|
||||
{
|
||||
case '!':
|
||||
return "shout";
|
||||
//case '?':
|
||||
//return "question";
|
||||
//case '@':
|
||||
// return "admin";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleLocalChat(final PlayerChatEvent event, final ChatStore chatStore)
|
||||
{
|
||||
long radius = 0;
|
||||
ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
try
|
||||
{
|
||||
radius = settings.getData().getChat().getLocalRadius();
|
||||
}
|
||||
finally
|
||||
{
|
||||
settings.unlock();
|
||||
}
|
||||
|
||||
if (radius < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
radius *= radius;
|
||||
|
||||
final IUser user = chatStore.getUser();
|
||||
|
||||
if (event.getMessage().length() > 1 && chatStore.getType().length() > 0)
|
||||
{
|
||||
String type = _("chatTypeLocal");
|
||||
final User onlineUser = ess.getUser(onlinePlayer);
|
||||
//TODO: remove reference to op
|
||||
if (onlineUser.isIgnoredPlayer(sender.getName()) && !sender.isOp())
|
||||
if (ChatPermissions.getPermission(chatStore.getType()).isAuthorized(user))
|
||||
{
|
||||
continue;
|
||||
final StringBuilder format = new StringBuilder();
|
||||
format.append(chatStore.getType()).append("Format");
|
||||
event.setMessage(event.getMessage().substring(1));
|
||||
event.setFormat(_(format.toString(), event.getFormat()));
|
||||
return;
|
||||
}
|
||||
if (!onlineUser.equals(sender))
|
||||
{
|
||||
@@ -145,12 +163,16 @@ public abstract class EssentialsChatPlayer implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
String message = String.format(event.getFormat(), type.concat(sender.getDisplayName()), event.getMessage());
|
||||
for (IEssentialsChatListener listener : listeners.values())
|
||||
{
|
||||
message = listener.modifyMessage(event, onlinePlayer, message);
|
||||
}
|
||||
onlineUser.sendMessage(message);
|
||||
final StringBuilder errorMsg = new StringBuilder();
|
||||
errorMsg.append("notAllowedTo").append(chatStore.getType().substring(0, 1).toUpperCase(Locale.ENGLISH)).append(chatStore.getType().substring(1));
|
||||
|
||||
user.sendMessage(_(errorMsg.toString()));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
final EssentialsLocalChatEvent localChat = new EssentialsLocalChatEvent(event, radius);
|
||||
ess.getServer().getPluginManager().callEvent(localChat);
|
||||
}
|
||||
}
|
||||
|
@@ -1,48 +0,0 @@
|
||||
package com.earth2me.essentials.chat;
|
||||
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
|
||||
|
||||
public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer
|
||||
{
|
||||
public EssentialsChatPlayerListenerLowest(final Server server,
|
||||
final IEssentials ess,
|
||||
final Map<String, IEssentialsChatListener> listeners,
|
||||
final Map<PlayerChatEvent, ChatStore> chatStorage)
|
||||
{
|
||||
super(server, ess, listeners, chatStorage);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@Override
|
||||
public void onPlayerChat(final PlayerChatEvent event)
|
||||
{
|
||||
if (isAborted(event))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final ChatStore chatStore = new ChatStore(ess, user, getChatType(event.getMessage()));
|
||||
setChatStore(event, chatStore);
|
||||
|
||||
/**
|
||||
* This listener should apply the general chat formatting only...then return control back the event handler
|
||||
*/
|
||||
event.setMessage(Util.formatMessage(user, "essentials.chat", event.getMessage()));
|
||||
String group = user.getGroup();
|
||||
String world = user.getWorld().getName();
|
||||
event.setFormat(ess.getSettings().getChatFormat(group).format(new Object[]
|
||||
{
|
||||
group, world, world.substring(0, 1).toUpperCase(Locale.ENGLISH)
|
||||
}));
|
||||
}
|
||||
}
|
@@ -1,72 +0,0 @@
|
||||
package com.earth2me.essentials.chat;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
|
||||
|
||||
public class EssentialsChatPlayerListenerNormal extends EssentialsChatPlayer
|
||||
{
|
||||
public EssentialsChatPlayerListenerNormal(final Server server,
|
||||
final IEssentials ess,
|
||||
final Map<String, IEssentialsChatListener> listeners,
|
||||
final Map<PlayerChatEvent, ChatStore> chatStorage)
|
||||
{
|
||||
super(server, ess, listeners, chatStorage);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@Override
|
||||
public void onPlayerChat(final PlayerChatEvent event)
|
||||
{
|
||||
if (isAborted(event))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This file should handle detection of the local chat features... if local chat is enabled, we need to handle
|
||||
* it here
|
||||
*/
|
||||
long radius = ess.getSettings().getChatRadius();
|
||||
if (radius < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
radius *= radius;
|
||||
|
||||
final ChatStore chatStore = getChatStore(event);
|
||||
final User user = chatStore.getUser();
|
||||
chatStore.setRadius(radius);
|
||||
|
||||
if (event.getMessage().length() > 1 && chatStore.getType().length() > 0)
|
||||
{
|
||||
final StringBuilder permission = new StringBuilder();
|
||||
permission.append("essentials.chat.").append(chatStore.getType());
|
||||
|
||||
if (user.isAuthorized(permission.toString()))
|
||||
{
|
||||
final StringBuilder format = new StringBuilder();
|
||||
format.append(chatStore.getType()).append("Format");
|
||||
event.setMessage(event.getMessage().substring(1));
|
||||
event.setFormat(_(format.toString(), event.getFormat()));
|
||||
return;
|
||||
}
|
||||
|
||||
final StringBuilder errorMsg = new StringBuilder();
|
||||
errorMsg.append("notAllowedTo").append(chatStore.getType().substring(0, 1).toUpperCase(Locale.ENGLISH)).append(chatStore.getType().substring(1));
|
||||
|
||||
user.sendMessage(_(errorMsg.toString()));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
sendLocalChat(event, chatStore);
|
||||
}
|
||||
}
|
@@ -0,0 +1,110 @@
|
||||
package com.earth2me.essentials.chat;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
|
||||
|
||||
public class EssentialsLocalChatEvent extends Event implements Cancellable
|
||||
{
|
||||
private Player player;
|
||||
private String message;
|
||||
private String format = "<%1$s> %2$s";
|
||||
private long radius;
|
||||
private boolean cancelled = false;
|
||||
private PlayerChatEvent parentEvent = null;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public EssentialsLocalChatEvent(final Player player, final String message, final String format, final long radius)
|
||||
{
|
||||
this.player = player;
|
||||
this.message = message;
|
||||
this.format = format;
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
public EssentialsLocalChatEvent(final PlayerChatEvent event, final long radius)
|
||||
{
|
||||
this(event.getPlayer(), event.getMessage(), event.getFormat(), radius);
|
||||
this.parentEvent = event;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel)
|
||||
{
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(final String message)
|
||||
{
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public void setPlayer(final Player player)
|
||||
{
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return player;
|
||||
}
|
||||
|
||||
public String getFormat()
|
||||
{
|
||||
return format;
|
||||
}
|
||||
|
||||
public void setFormat(final String format)
|
||||
{
|
||||
// Oh for a better way to do this!
|
||||
try
|
||||
{
|
||||
String.format(format, player, message);
|
||||
}
|
||||
catch (RuntimeException ex)
|
||||
{
|
||||
ex.fillInStackTrace();
|
||||
throw ex;
|
||||
}
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public long getRadius()
|
||||
{
|
||||
return radius;
|
||||
}
|
||||
|
||||
public void setRadius(final long radius)
|
||||
{
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
public PlayerChatEvent getParentEvent()
|
||||
{
|
||||
return parentEvent;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
package com.earth2me.essentials.chat;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
|
||||
public class EssentialsLocalChatEventListener implements Listener
|
||||
{
|
||||
protected transient IEssentials ess;
|
||||
protected final transient Server server;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
|
||||
public EssentialsLocalChatEventListener(final Server server, final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onLocalChat(final EssentialsLocalChatEvent event)
|
||||
{
|
||||
final Player sender = event.getPlayer();
|
||||
final Location loc = sender.getLocation();
|
||||
final World world = loc.getWorld();
|
||||
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
String type = _("chatTypeLocal");
|
||||
final IUser user = ess.getUser(onlinePlayer);
|
||||
//TODO: remove reference to op
|
||||
if (user.isIgnoringPlayer(sender.getName()) && !sender.isOp())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!user.equals(sender))
|
||||
{
|
||||
final Location playerLoc = user.getLocation();
|
||||
if (playerLoc.getWorld() != world)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final double delta = playerLoc.distanceSquared(loc);
|
||||
|
||||
if (delta > event.getRadius())
|
||||
{
|
||||
if (Permissions.CHAT_SPY.isAuthorized(user))
|
||||
{
|
||||
type = type.concat(_("chatTypeSpy"));
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final String message = type.concat(String.format(event.getFormat(), sender.getDisplayName(), event.getMessage()));
|
||||
user.sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
package com.earth2me.essentials.chat;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
|
||||
|
||||
public interface IEssentialsChatListener
|
||||
{
|
||||
boolean shouldHandleThisChat(PlayerChatEvent event);
|
||||
|
||||
String modifyMessage(PlayerChatEvent event, Player target, String message);
|
||||
}
|
@@ -1,6 +1,8 @@
|
||||
package com.earth2me.essentials.chat;
|
||||
package com.earth2me.essentials.chat.listenerlevel;
|
||||
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.chat.ChatStore;
|
||||
import com.earth2me.essentials.chat.EssentialsChatPlayer;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -12,10 +14,9 @@ public class EssentialsChatPlayerListenerHighest extends EssentialsChatPlayer
|
||||
{
|
||||
public EssentialsChatPlayerListenerHighest(final Server server,
|
||||
final IEssentials ess,
|
||||
final Map<String, IEssentialsChatListener> listeners,
|
||||
final Map<PlayerChatEvent, ChatStore> chatStorage)
|
||||
{
|
||||
super(server, ess, listeners, chatStorage);
|
||||
super(server, ess, chatStorage);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@@ -23,14 +24,10 @@ public class EssentialsChatPlayerListenerHighest extends EssentialsChatPlayer
|
||||
public void onPlayerChat(final PlayerChatEvent event)
|
||||
{
|
||||
final ChatStore chatStore = delChatStore(event);
|
||||
if (isAborted(event))
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This file should handle charging the user for the action before returning control back
|
||||
*/
|
||||
charge(event, chatStore);
|
||||
chargeChat(event, chatStore);
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
package com.earth2me.essentials.chat.listenerlevel;
|
||||
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.chat.ChatStore;
|
||||
import com.earth2me.essentials.chat.EssentialsChatPlayer;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
|
||||
|
||||
public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer
|
||||
{
|
||||
public EssentialsChatPlayerListenerLowest(final Server server,
|
||||
final IEssentials ess,
|
||||
final Map<PlayerChatEvent, ChatStore> chatStorage)
|
||||
{
|
||||
super(server, ess, chatStorage);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@Override
|
||||
public void onPlayerChat(final PlayerChatEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final IUser user = ess.getUser(event.getPlayer());
|
||||
final ChatStore chatStore = new ChatStore(ess, user, getChatType(event.getMessage()));
|
||||
setChatStore(event, chatStore);
|
||||
formatChat(event, chatStore);
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
package com.earth2me.essentials.chat.listenerlevel;
|
||||
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.chat.ChatStore;
|
||||
import com.earth2me.essentials.chat.EssentialsChatPlayer;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
|
||||
|
||||
public class EssentialsChatPlayerListenerNormal extends EssentialsChatPlayer
|
||||
{
|
||||
public EssentialsChatPlayerListenerNormal(final Server server,
|
||||
final IEssentials ess,
|
||||
final Map<PlayerChatEvent, ChatStore> chatStorage)
|
||||
{
|
||||
super(server, ess, chatStorage);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@Override
|
||||
public void onPlayerChat(final PlayerChatEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final ChatStore chatStore = getChatStore(event);
|
||||
handleLocalChat(event, chatStore);
|
||||
}
|
||||
}
|
@@ -2,9 +2,9 @@
|
||||
name: EssentialsChat
|
||||
main: com.earth2me.essentials.chat.EssentialsChat
|
||||
# Note to developers: This next line cannot change, or the automatic versioning system will break.
|
||||
version: TeamCity
|
||||
website: http://tiny.cc/EssentialsCommands
|
||||
version: ${build.number}
|
||||
website: http://tiny.cc/EssentialsWiki
|
||||
description: Provides chat control features for Essentials. Requires Permissions.
|
||||
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits, md_5, Okamosy]
|
||||
depend: [Essentials]
|
||||
depend: [Essentials3]
|
||||
#softdepend: [Factions]
|
Reference in New Issue
Block a user