Moved files
This commit is contained in:
parent
c439a34294
commit
fef61b1801
17 changed files with 1130 additions and 1481 deletions
223
ButtonLib/.gitignore
vendored
223
ButtonLib/.gitignore
vendored
|
@ -1,223 +0,0 @@
|
||||||
#################
|
|
||||||
## Eclipse
|
|
||||||
#################
|
|
||||||
|
|
||||||
*.pydevproject
|
|
||||||
.project
|
|
||||||
.metadata/
|
|
||||||
bin/
|
|
||||||
tmp/
|
|
||||||
*.tmp
|
|
||||||
*.bak
|
|
||||||
*.swp
|
|
||||||
*~.nib
|
|
||||||
local.properties
|
|
||||||
.classpath
|
|
||||||
.settings/
|
|
||||||
.loadpath
|
|
||||||
target/
|
|
||||||
.project
|
|
||||||
|
|
||||||
# External tool builders
|
|
||||||
.externalToolBuilders/
|
|
||||||
|
|
||||||
# Locally stored "Eclipse launch configurations"
|
|
||||||
*.launch
|
|
||||||
|
|
||||||
# CDT-specific
|
|
||||||
.cproject
|
|
||||||
|
|
||||||
# PDT-specific
|
|
||||||
.buildpath
|
|
||||||
|
|
||||||
|
|
||||||
#################
|
|
||||||
## Visual Studio
|
|
||||||
#################
|
|
||||||
|
|
||||||
## Ignore Visual Studio temporary files, build results, and
|
|
||||||
## files generated by popular Visual Studio add-ons.
|
|
||||||
|
|
||||||
# User-specific files
|
|
||||||
*.suo
|
|
||||||
*.user
|
|
||||||
*.sln.docstates
|
|
||||||
|
|
||||||
# Build results
|
|
||||||
|
|
||||||
[Dd]ebug/
|
|
||||||
[Rr]elease/
|
|
||||||
x64/
|
|
||||||
build/
|
|
||||||
[Bb]in/
|
|
||||||
[Oo]bj/
|
|
||||||
|
|
||||||
# MSTest test Results
|
|
||||||
[Tt]est[Rr]esult*/
|
|
||||||
[Bb]uild[Ll]og.*
|
|
||||||
|
|
||||||
*_i.c
|
|
||||||
*_p.c
|
|
||||||
*.ilk
|
|
||||||
*.meta
|
|
||||||
*.obj
|
|
||||||
*.pch
|
|
||||||
*.pdb
|
|
||||||
*.pgc
|
|
||||||
*.pgd
|
|
||||||
*.rsp
|
|
||||||
*.sbr
|
|
||||||
*.tlb
|
|
||||||
*.tli
|
|
||||||
*.tlh
|
|
||||||
*.tmp
|
|
||||||
*.tmp_proj
|
|
||||||
*.log
|
|
||||||
*.vspscc
|
|
||||||
*.vssscc
|
|
||||||
.builds
|
|
||||||
*.pidb
|
|
||||||
*.log
|
|
||||||
*.scc
|
|
||||||
|
|
||||||
# Visual C++ cache files
|
|
||||||
ipch/
|
|
||||||
*.aps
|
|
||||||
*.ncb
|
|
||||||
*.opensdf
|
|
||||||
*.sdf
|
|
||||||
*.cachefile
|
|
||||||
|
|
||||||
# Visual Studio profiler
|
|
||||||
*.psess
|
|
||||||
*.vsp
|
|
||||||
*.vspx
|
|
||||||
|
|
||||||
# Guidance Automation Toolkit
|
|
||||||
*.gpState
|
|
||||||
|
|
||||||
# ReSharper is a .NET coding add-in
|
|
||||||
_ReSharper*/
|
|
||||||
*.[Rr]e[Ss]harper
|
|
||||||
|
|
||||||
# TeamCity is a build add-in
|
|
||||||
_TeamCity*
|
|
||||||
|
|
||||||
# DotCover is a Code Coverage Tool
|
|
||||||
*.dotCover
|
|
||||||
|
|
||||||
# NCrunch
|
|
||||||
*.ncrunch*
|
|
||||||
.*crunch*.local.xml
|
|
||||||
|
|
||||||
# Installshield output folder
|
|
||||||
[Ee]xpress/
|
|
||||||
|
|
||||||
# DocProject is a documentation generator add-in
|
|
||||||
DocProject/buildhelp/
|
|
||||||
DocProject/Help/*.HxT
|
|
||||||
DocProject/Help/*.HxC
|
|
||||||
DocProject/Help/*.hhc
|
|
||||||
DocProject/Help/*.hhk
|
|
||||||
DocProject/Help/*.hhp
|
|
||||||
DocProject/Help/Html2
|
|
||||||
DocProject/Help/html
|
|
||||||
|
|
||||||
# Click-Once directory
|
|
||||||
publish/
|
|
||||||
|
|
||||||
# Publish Web Output
|
|
||||||
*.Publish.xml
|
|
||||||
*.pubxml
|
|
||||||
*.publishproj
|
|
||||||
|
|
||||||
# NuGet Packages Directory
|
|
||||||
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
|
|
||||||
#packages/
|
|
||||||
|
|
||||||
# Windows Azure Build Output
|
|
||||||
csx
|
|
||||||
*.build.csdef
|
|
||||||
|
|
||||||
# Windows Store app package directory
|
|
||||||
AppPackages/
|
|
||||||
|
|
||||||
# Others
|
|
||||||
sql/
|
|
||||||
*.Cache
|
|
||||||
ClientBin/
|
|
||||||
[Ss]tyle[Cc]op.*
|
|
||||||
~$*
|
|
||||||
*~
|
|
||||||
*.dbmdl
|
|
||||||
*.[Pp]ublish.xml
|
|
||||||
*.pfx
|
|
||||||
*.publishsettings
|
|
||||||
|
|
||||||
# RIA/Silverlight projects
|
|
||||||
Generated_Code/
|
|
||||||
|
|
||||||
# Backup & report files from converting an old project file to a newer
|
|
||||||
# Visual Studio version. Backup files are not needed, because we have git ;-)
|
|
||||||
_UpgradeReport_Files/
|
|
||||||
Backup*/
|
|
||||||
UpgradeLog*.XML
|
|
||||||
UpgradeLog*.htm
|
|
||||||
|
|
||||||
# SQL Server files
|
|
||||||
App_Data/*.mdf
|
|
||||||
App_Data/*.ldf
|
|
||||||
|
|
||||||
#############
|
|
||||||
## Windows detritus
|
|
||||||
#############
|
|
||||||
|
|
||||||
# Windows image file caches
|
|
||||||
Thumbs.db
|
|
||||||
ehthumbs.db
|
|
||||||
|
|
||||||
# Folder config file
|
|
||||||
Desktop.ini
|
|
||||||
|
|
||||||
# Recycle Bin used on file shares
|
|
||||||
$RECYCLE.BIN/
|
|
||||||
|
|
||||||
# Mac crap
|
|
||||||
.DS_Store
|
|
||||||
|
|
||||||
|
|
||||||
#############
|
|
||||||
## Python
|
|
||||||
#############
|
|
||||||
|
|
||||||
*.py[cod]
|
|
||||||
|
|
||||||
# Packages
|
|
||||||
*.egg
|
|
||||||
*.egg-info
|
|
||||||
dist/
|
|
||||||
build/
|
|
||||||
eggs/
|
|
||||||
parts/
|
|
||||||
var/
|
|
||||||
sdist/
|
|
||||||
develop-eggs/
|
|
||||||
.installed.cfg
|
|
||||||
|
|
||||||
# Installer logs
|
|
||||||
pip-log.txt
|
|
||||||
|
|
||||||
# Unit test / coverage reports
|
|
||||||
.coverage
|
|
||||||
.tox
|
|
||||||
|
|
||||||
#Translations
|
|
||||||
*.mo
|
|
||||||
|
|
||||||
#Mr Developer
|
|
||||||
.mr.developer.cfg
|
|
||||||
.metadata/*
|
|
||||||
TheButtonAutoFlair/out/artifacts/Autoflair/Autoflair.jar
|
|
||||||
*.iml
|
|
||||||
*.name
|
|
||||||
.idea/compiler.xml
|
|
|
@ -1,2 +0,0 @@
|
||||||
# ButtonLib
|
|
||||||
A library that stores everything common to the TBMC plugins
|
|
|
@ -1,122 +0,0 @@
|
||||||
<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>
|
|
||||||
<groupId>com.github.TBMCPlugins.ButtonLib</groupId>
|
|
||||||
<artifactId>ButtonLib</artifactId>
|
|
||||||
<version>master-SNAPSHOT</version>
|
|
||||||
<name>ButtonLib</name>
|
|
||||||
<description>ButtonCore</description>
|
|
||||||
<build>
|
|
||||||
<sourceDirectory>src/main/java</sourceDirectory>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src</directory>
|
|
||||||
<excludes>
|
|
||||||
<exclude>**/*.java</exclude>
|
|
||||||
</excludes>
|
|
||||||
</resource>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<includes>
|
|
||||||
<include>*.properties</include>
|
|
||||||
<include>*.yml</include>
|
|
||||||
<include>*.csv</include>
|
|
||||||
<include>*.txt</include>
|
|
||||||
</includes>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
<finalName>ButtonCore</finalName>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>3.3</version>
|
|
||||||
<configuration>
|
|
||||||
<source>1.8</source>
|
|
||||||
<target>1.8</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<!-- <<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<version>2.4.2</version> <executions> <execution> <phase>package</phase>
|
|
||||||
<goals> <goal>shade</goal> </goals> <configuration> <artifactSet> <includes>
|
|
||||||
</includes> </artifactSet> <pluginExecution> <action> <execute /> </action>
|
|
||||||
</pluginExecution> </configuration> </execution> </executions> </plugin> -->
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
|
||||||
<version>3.0.1</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>copy</id>
|
|
||||||
<phase>compile</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>copy-resources</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<outputDirectory>target</outputDirectory>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>resources</directory>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>spigot-repo</id>
|
|
||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>jitpack.io</id>
|
|
||||||
<url>https://jitpack.io/</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot-api</artifactId>
|
|
||||||
<version>1.9.2-R0.1-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-io -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-io</groupId>
|
|
||||||
<artifactId>commons-io</artifactId>
|
|
||||||
<version>1.3.2</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.TBMCPlugins.ButtonLib</groupId>
|
|
||||||
<artifactId>Towny</artifactId>
|
|
||||||
<version>master-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.reflections/reflections -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.reflections</groupId>
|
|
||||||
<artifactId>reflections</artifactId>
|
|
||||||
<version>0.9.10</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
<organization>
|
|
||||||
<name>TBMCPlugins</name>
|
|
||||||
<url>https://github.com/TBMCPlugins</url>
|
|
||||||
</organization>
|
|
||||||
<distributionManagement>
|
|
||||||
<repository>
|
|
||||||
<id>internal.repo</id>
|
|
||||||
<name>Temporary Staging Repository</name>
|
|
||||||
<url>file://${project.build.directory}/mvn-repo/${project.name}</url>
|
|
||||||
</repository>
|
|
||||||
</distributionManagement>
|
|
||||||
<properties>
|
|
||||||
<!-- github server corresponds to entry in ~/.m2/settings.xml -->
|
|
||||||
<github.global.server>github</github.global.server>
|
|
||||||
</properties>
|
|
||||||
<scm>
|
|
||||||
<url>https://github.com/TBMCPlugins/mvn-repo</url>
|
|
||||||
<connection>scm:git:https://github.com/TBMCPlugins/mvn-repo.git</connection>
|
|
||||||
<developerConnection>scm:git:https://github.com/TBMCPlugins/mvn-repo.git</developerConnection>
|
|
||||||
</scm>
|
|
||||||
</project>
|
|
|
@ -1,4 +0,0 @@
|
||||||
name: ButtonPluginBucket
|
|
||||||
main: buttondevteam.bucket.MainPlugin
|
|
||||||
version: 1.0
|
|
||||||
author: TBMCPlugins
|
|
|
@ -1,154 +1,154 @@
|
||||||
package buttondevteam.lib;
|
package buttondevteam.lib;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.EventException;
|
import org.bukkit.event.EventException;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.EventExecutor;
|
import org.bukkit.plugin.EventExecutor;
|
||||||
import org.bukkit.plugin.IllegalPluginAccessException;
|
import org.bukkit.plugin.IllegalPluginAccessException;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.RegisteredListener;
|
import org.bukkit.plugin.RegisteredListener;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
public abstract class EventExceptionHandler { // https://gist.github.com/aadnk/5430459
|
public abstract class EventExceptionHandler { // https://gist.github.com/aadnk/5430459
|
||||||
// For wrapping a registered listener
|
// For wrapping a registered listener
|
||||||
private static class ExceptionRegisteredListener extends RegisteredListener {
|
private static class ExceptionRegisteredListener extends RegisteredListener {
|
||||||
/**
|
/**
|
||||||
* Represents an event executor that does nothing. This is not really necessary in the current
|
* Represents an event executor that does nothing. This is not really necessary in the current
|
||||||
* implementation of CraftBukkit, but we will take no chances.
|
* implementation of CraftBukkit, but we will take no chances.
|
||||||
*/
|
*/
|
||||||
private static EventExecutor NULL_EXECUTOR = new EventExecutor() {
|
private static EventExecutor NULL_EXECUTOR = new EventExecutor() {
|
||||||
@Override
|
@Override
|
||||||
public void execute(Listener listener, Event event) throws EventException {
|
public void execute(Listener listener, Event event) throws EventException {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private final RegisteredListener delegate;
|
private final RegisteredListener delegate;
|
||||||
private final EventExceptionHandler handler;
|
private final EventExceptionHandler handler;
|
||||||
|
|
||||||
public ExceptionRegisteredListener(RegisteredListener delegate, EventExceptionHandler handler) {
|
public ExceptionRegisteredListener(RegisteredListener delegate, EventExceptionHandler handler) {
|
||||||
super(delegate.getListener(), NULL_EXECUTOR, delegate.getPriority(),
|
super(delegate.getListener(), NULL_EXECUTOR, delegate.getPriority(),
|
||||||
delegate.getPlugin(), delegate.isIgnoringCancelled());
|
delegate.getPlugin(), delegate.isIgnoringCancelled());
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
this.handler = handler;
|
this.handler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void callEvent(Event event) throws EventException {
|
public void callEvent(Event event) throws EventException {
|
||||||
try {
|
try {
|
||||||
delegate.callEvent(event);
|
delegate.callEvent(event);
|
||||||
} catch (EventException e) {
|
} catch (EventException e) {
|
||||||
if (!handler.handle(e.getCause(), event)) {
|
if (!handler.handle(e.getCause(), event)) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
if (!handler.handle(e, event)) {
|
if (!handler.handle(e, event)) {
|
||||||
doThrow(e);
|
doThrow(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WARNING: HORRIBLE, HORRIBLE HACK to get around checked exceptions
|
// WARNING: HORRIBLE, HORRIBLE HACK to get around checked exceptions
|
||||||
private static void doThrow(Throwable e) {
|
private static void doThrow(Throwable e) {
|
||||||
ExceptionRegisteredListener.<RuntimeException> doThrowInner(e);
|
ExceptionRegisteredListener.<RuntimeException> doThrowInner(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static <E extends Throwable> void doThrowInner(Throwable e) throws E {
|
private static <E extends Throwable> void doThrowInner(Throwable e) throws E {
|
||||||
throw (E) e;
|
throw (E) e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register Bukkit event handlers with a given exception handler.
|
* Register Bukkit event handlers with a given exception handler.
|
||||||
* @param listener - a class of event handlers.
|
* @param listener - a class of event handlers.
|
||||||
* @param plugin - the current plugin.
|
* @param plugin - the current plugin.
|
||||||
* @param handler - exception handler.
|
* @param handler - exception handler.
|
||||||
*/
|
*/
|
||||||
public static void registerEvents(Listener listener, Plugin plugin, EventExceptionHandler handler) {
|
public static void registerEvents(Listener listener, Plugin plugin, EventExceptionHandler handler) {
|
||||||
Validate.notNull(plugin, "Plugin cannot be NULL.");
|
Validate.notNull(plugin, "Plugin cannot be NULL.");
|
||||||
|
|
||||||
registerEvents(plugin.getServer().getPluginManager(), listener, plugin, handler);
|
registerEvents(plugin.getServer().getPluginManager(), listener, plugin, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register Bukkit event handlers with a given exception handler.
|
* Register Bukkit event handlers with a given exception handler.
|
||||||
* @param manager - the current plugin manager.
|
* @param manager - the current plugin manager.
|
||||||
* @param listener - a class of event handlers.
|
* @param listener - a class of event handlers.
|
||||||
* @param plugin - the current plugin.
|
* @param plugin - the current plugin.
|
||||||
* @param handler - exception handler.
|
* @param handler - exception handler.
|
||||||
*/
|
*/
|
||||||
public static void registerEvents(PluginManager manager, Listener listener, Plugin plugin, EventExceptionHandler handler) {
|
public static void registerEvents(PluginManager manager, Listener listener, Plugin plugin, EventExceptionHandler handler) {
|
||||||
Validate.notNull(manager, "Manager cannot be NULL.");
|
Validate.notNull(manager, "Manager cannot be NULL.");
|
||||||
Validate.notNull(listener, "Listener cannot be NULL.");
|
Validate.notNull(listener, "Listener cannot be NULL.");
|
||||||
Validate.notNull(plugin, "Plugin cannot be NULL.");
|
Validate.notNull(plugin, "Plugin cannot be NULL.");
|
||||||
Validate.notNull(handler, "Handler cannot be NULL.");
|
Validate.notNull(handler, "Handler cannot be NULL.");
|
||||||
|
|
||||||
if (!plugin.isEnabled()) {
|
if (!plugin.isEnabled()) {
|
||||||
throw new IllegalPluginAccessException("Plugin attempted to register " + listener + " while not enabled");
|
throw new IllegalPluginAccessException("Plugin attempted to register " + listener + " while not enabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create normal listeners
|
// Create normal listeners
|
||||||
for (Map.Entry<Class<? extends Event>, Set<RegisteredListener>> entry :
|
for (Map.Entry<Class<? extends Event>, Set<RegisteredListener>> entry :
|
||||||
plugin.getPluginLoader().createRegisteredListeners(listener, plugin).entrySet()) {
|
plugin.getPluginLoader().createRegisteredListeners(listener, plugin).entrySet()) {
|
||||||
|
|
||||||
// Wrap these listeners in our exception handler
|
// Wrap these listeners in our exception handler
|
||||||
getHandlerList(entry.getKey()).registerAll(wrapAll(entry.getValue(), handler));
|
getHandlerList(entry.getKey()).registerAll(wrapAll(entry.getValue(), handler));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap every listener in the given collection around an exception handler.
|
* Wrap every listener in the given collection around an exception handler.
|
||||||
* @param listeners - the listeners to wrap.
|
* @param listeners - the listeners to wrap.
|
||||||
* @param handler - the exception handler to add.
|
* @param handler - the exception handler to add.
|
||||||
* @return The wrapped listeners.
|
* @return The wrapped listeners.
|
||||||
*/
|
*/
|
||||||
private static Collection<RegisteredListener> wrapAll(Collection<RegisteredListener> listeners, EventExceptionHandler handler) {
|
private static Collection<RegisteredListener> wrapAll(Collection<RegisteredListener> listeners, EventExceptionHandler handler) {
|
||||||
List<RegisteredListener> output = Lists.newArrayList();
|
List<RegisteredListener> output = Lists.newArrayList();
|
||||||
|
|
||||||
for (RegisteredListener listener : listeners) {
|
for (RegisteredListener listener : listeners) {
|
||||||
output.add(new ExceptionRegisteredListener(listener, handler));
|
output.add(new ExceptionRegisteredListener(listener, handler));
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the handler list associated with the given class.
|
* Retrieve the handler list associated with the given class.
|
||||||
* @param clazz - given event class.
|
* @param clazz - given event class.
|
||||||
* @return Associated handler list.
|
* @return Associated handler list.
|
||||||
*/
|
*/
|
||||||
private static HandlerList getHandlerList(Class<? extends Event> clazz) {
|
private static HandlerList getHandlerList(Class<? extends Event> clazz) {
|
||||||
// Class must have Event as its superclass
|
// Class must have Event as its superclass
|
||||||
while (clazz.getSuperclass() != null && Event.class.isAssignableFrom(clazz.getSuperclass())) {
|
while (clazz.getSuperclass() != null && Event.class.isAssignableFrom(clazz.getSuperclass())) {
|
||||||
try {
|
try {
|
||||||
Method method = clazz.getDeclaredMethod("getHandlerList");
|
Method method = clazz.getDeclaredMethod("getHandlerList");
|
||||||
method.setAccessible(true);
|
method.setAccessible(true);
|
||||||
return (HandlerList) method.invoke(null);
|
return (HandlerList) method.invoke(null);
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
// Keep on searching
|
// Keep on searching
|
||||||
clazz = clazz.getSuperclass().asSubclass(Event.class);
|
clazz = clazz.getSuperclass().asSubclass(Event.class);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new IllegalPluginAccessException(e.getMessage());
|
throw new IllegalPluginAccessException(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new IllegalPluginAccessException("Unable to find handler list for event " + clazz.getName());
|
throw new IllegalPluginAccessException("Unable to find handler list for event " + clazz.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle a given exception.
|
* Handle a given exception.
|
||||||
* @param ex - the exception to handle.
|
* @param ex - the exception to handle.
|
||||||
* @param event - the event that was being handled.
|
* @param event - the event that was being handled.
|
||||||
* @return TRUE to indicate that the exception has been handled, FALSE to rethrow it.
|
* @return TRUE to indicate that the exception has been handled, FALSE to rethrow it.
|
||||||
*/
|
*/
|
||||||
public abstract boolean handle(Throwable ex, Event event);
|
public abstract boolean handle(Throwable ex, Event event);
|
||||||
}
|
}
|
|
@ -1,99 +1,99 @@
|
||||||
package buttondevteam.lib;
|
package buttondevteam.lib;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
public final class TBMCCoreAPI {
|
public final class TBMCCoreAPI {
|
||||||
/**
|
/**
|
||||||
* Updates or installs the specified plugin. The plugin must use Maven.
|
* Updates or installs the specified plugin. The plugin must use Maven.
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* The plugin's repository name.
|
* The plugin's repository name.
|
||||||
* @return Error message or empty string
|
* @return Error message or empty string
|
||||||
*/
|
*/
|
||||||
public static String UpdatePlugin(String name) {
|
public static String UpdatePlugin(String name) {
|
||||||
List<String> plugins = GetPluginNames();
|
List<String> plugins = GetPluginNames();
|
||||||
String correctname = null;
|
String correctname = null;
|
||||||
for (String plugin : plugins) {
|
for (String plugin : plugins) {
|
||||||
if (plugin.equalsIgnoreCase(name)) {
|
if (plugin.equalsIgnoreCase(name)) {
|
||||||
correctname = plugin; // Fixes capitalization
|
correctname = plugin; // Fixes capitalization
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (correctname == null) {
|
if (correctname == null) {
|
||||||
Bukkit.getLogger().warning("There was an error while updating TBMC plugin: " + name);
|
Bukkit.getLogger().warning("There was an error while updating TBMC plugin: " + name);
|
||||||
return "Can't find plugin: " + name;
|
return "Can't find plugin: " + name;
|
||||||
}
|
}
|
||||||
Bukkit.getLogger().info("Updating TBMC plugin: " + correctname);
|
Bukkit.getLogger().info("Updating TBMC plugin: " + correctname);
|
||||||
String ret = "";
|
String ret = "";
|
||||||
URL url;
|
URL url;
|
||||||
try {
|
try {
|
||||||
url = new URL("https://jitpack.io/com/github/TBMCPlugins/" + correctname + "/master-SNAPSHOT/" + correctname
|
url = new URL("https://jitpack.io/com/github/TBMCPlugins/" + correctname + "/master-SNAPSHOT/" + correctname
|
||||||
+ "-master-SNAPSHOT.jar"); // ButtonLib exception not required, not a separate plugin
|
+ "-master-SNAPSHOT.jar"); // ButtonLib exception not required, not a separate plugin
|
||||||
FileUtils.copyURLToFile(url, new File("plugins/" + correctname + ".jar"));
|
FileUtils.copyURLToFile(url, new File("plugins/" + correctname + ".jar"));
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
ret = "Can't find JAR, the build probably failed. Build log (scroll to bottom):\nhttps://jitpack.io/com/github/TBMCPlugins/"
|
ret = "Can't find JAR, the build probably failed. Build log (scroll to bottom):\nhttps://jitpack.io/com/github/TBMCPlugins/"
|
||||||
+ correctname + "/master-SNAPSHOT/build.log";
|
+ correctname + "/master-SNAPSHOT/build.log";
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
ret = "IO error!\n" + e.getMessage();
|
ret = "IO error!\n" + e.getMessage();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Bukkit.getLogger().warning("Error!\n" + e);
|
Bukkit.getLogger().warning("Error!\n" + e);
|
||||||
ret = e.toString();
|
ret = e.toString();
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves all the repository names from the GitHub organization.
|
* Retrieves all the repository names from the GitHub organization.
|
||||||
*
|
*
|
||||||
* @return A list of names
|
* @return A list of names
|
||||||
*/
|
*/
|
||||||
public static List<String> GetPluginNames() {
|
public static List<String> GetPluginNames() {
|
||||||
List<String> ret = new ArrayList<>();
|
List<String> ret = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
String resp = DownloadString("https://api.github.com/orgs/TBMCPlugins/repos");
|
String resp = DownloadString("https://api.github.com/orgs/TBMCPlugins/repos");
|
||||||
JsonArray arr = new JsonParser().parse(resp).getAsJsonArray();
|
JsonArray arr = new JsonParser().parse(resp).getAsJsonArray();
|
||||||
for (JsonElement obj : arr) {
|
for (JsonElement obj : arr) {
|
||||||
JsonObject jobj = obj.getAsJsonObject();
|
JsonObject jobj = obj.getAsJsonObject();
|
||||||
ret.add(jobj.get("name").getAsString());
|
ret.add(jobj.get("name").getAsString());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String DownloadString(String urlstr) throws MalformedURLException, IOException {
|
public static String DownloadString(String urlstr) throws MalformedURLException, IOException {
|
||||||
URL url = new URL(urlstr);
|
URL url = new URL(urlstr);
|
||||||
URLConnection con = url.openConnection();
|
URLConnection con = url.openConnection();
|
||||||
con.setRequestProperty("User-Agent", "TBMCPlugins");
|
con.setRequestProperty("User-Agent", "TBMCPlugins");
|
||||||
InputStream in = con.getInputStream();
|
InputStream in = con.getInputStream();
|
||||||
String encoding = con.getContentEncoding();
|
String encoding = con.getContentEncoding();
|
||||||
encoding = encoding == null ? "UTF-8" : encoding;
|
encoding = encoding == null ? "UTF-8" : encoding;
|
||||||
String body = IOUtils.toString(in, encoding);
|
String body = IOUtils.toString(in, encoding);
|
||||||
in.close();
|
in.close();
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SendException(String sourcemsg, Exception e) {
|
public static void SendException(String sourcemsg, Exception e) {
|
||||||
Bukkit.getPluginManager().callEvent(new TBMCExceptionEvent(sourcemsg, e));
|
Bukkit.getPluginManager().callEvent(new TBMCExceptionEvent(sourcemsg, e));
|
||||||
Bukkit.getLogger().warning(sourcemsg);
|
Bukkit.getLogger().warning(sourcemsg);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,57 +1,57 @@
|
||||||
package buttondevteam.lib;
|
package buttondevteam.lib;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import buttondevteam.lib.TBMCPlayer.InfoTarget;
|
import buttondevteam.lib.TBMCPlayer.InfoTarget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* This event gets called (ideally) each time an exception occurs in a TBMC plugin. To call it, use {@link TBMCCoreAPI#SendException(String, Exception)}.
|
* This event gets called (ideally) each time an exception occurs in a TBMC plugin. To call it, use {@link TBMCCoreAPI#SendException(String, Exception)}.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author Norbi
|
* @author Norbi
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TBMCExceptionEvent extends Event {
|
public class TBMCExceptionEvent extends Event {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private String sourcemsg;
|
private String sourcemsg;
|
||||||
private Exception exception;
|
private Exception exception;
|
||||||
|
|
||||||
TBMCExceptionEvent(String sourcemsg, Exception exception) {
|
TBMCExceptionEvent(String sourcemsg, Exception exception) {
|
||||||
this.sourcemsg = sourcemsg;
|
this.sourcemsg = sourcemsg;
|
||||||
this.exception = exception;
|
this.exception = exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the source message (where did this exception occur, etc.)
|
* Gets the source message (where did this exception occur, etc.)
|
||||||
*
|
*
|
||||||
* @return The message
|
* @return The message
|
||||||
*/
|
*/
|
||||||
public String getSourceMessage() {
|
public String getSourceMessage() {
|
||||||
return sourcemsg;
|
return sourcemsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the exception
|
* Gets the exception
|
||||||
*
|
*
|
||||||
* @return The exception
|
* @return The exception
|
||||||
*/
|
*/
|
||||||
public Exception getException() {
|
public Exception getException() {
|
||||||
return exception;
|
return exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,465 +1,465 @@
|
||||||
package buttondevteam.lib;
|
package buttondevteam.lib;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import com.palmergames.bukkit.towny.Towny;
|
import com.palmergames.bukkit.towny.Towny;
|
||||||
import com.palmergames.bukkit.towny.object.Resident;
|
import com.palmergames.bukkit.towny.object.Resident;
|
||||||
import com.palmergames.bukkit.towny.object.TownyUniverse;
|
import com.palmergames.bukkit.towny.object.TownyUniverse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* The class for holding data common to all TBMC plugins
|
* The class for holding data common to all TBMC plugins
|
||||||
* </p>
|
* </p>
|
||||||
* <p>
|
* <p>
|
||||||
* Use {@link #asPluginPlayer(Class)} to get plugin-specific data
|
* Use {@link #asPluginPlayer(Class)} to get plugin-specific data
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author Norbi
|
* @author Norbi
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TBMCPlayer implements AutoCloseable {
|
public class TBMCPlayer implements AutoCloseable {
|
||||||
private static final String TBMC_PLAYERS_DIR = "TBMC/players";
|
private static final String TBMC_PLAYERS_DIR = "TBMC/players";
|
||||||
|
|
||||||
private HashMap<String, Object> data = new HashMap<>();
|
private HashMap<String, Object> data = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Gets a player data entry for the caller plugin returning the desired type.<br>
|
* Gets a player data entry for the caller plugin returning the desired type.<br>
|
||||||
* <i>It will automatically determine the key and the return type.</i><br>
|
* <i>It will automatically determine the key and the return type.</i><br>
|
||||||
* Usage:
|
* Usage:
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* {@code
|
* {@code
|
||||||
* public String getPlayerName() {
|
* public String getPlayerName() {
|
||||||
* return getData();
|
* return getData();
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @return The value or null if not found
|
* @return The value or null if not found
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected <T> T getData() {
|
protected <T> T getData() {
|
||||||
StackTraceElement st = new Exception().getStackTrace()[1];
|
StackTraceElement st = new Exception().getStackTrace()[1];
|
||||||
String mname = st.getMethodName();
|
String mname = st.getMethodName();
|
||||||
if (!mname.startsWith("get"))
|
if (!mname.startsWith("get"))
|
||||||
throw new UnsupportedOperationException("Can only use getData from a getXYZ method");
|
throw new UnsupportedOperationException("Can only use getData from a getXYZ method");
|
||||||
Object ret = getLoadedPlayers().get(uuid).data.get(mname.substring("get".length()).toLowerCase());
|
Object ret = getLoadedPlayers().get(uuid).data.get(mname.substring("get".length()).toLowerCase());
|
||||||
if (Integer.class.isAssignableFrom(ret.getClass()))
|
if (Integer.class.isAssignableFrom(ret.getClass()))
|
||||||
throw new UnsupportedOperationException("For integers use getIntData()");
|
throw new UnsupportedOperationException("For integers use getIntData()");
|
||||||
return (T) ret;
|
return (T) ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a player data entry <i>based on the caller method</i><br>
|
* Sets a player data entry <i>based on the caller method</i><br>
|
||||||
* Usage:
|
* Usage:
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* {@code
|
* {@code
|
||||||
* public String setPlayerName(String value) {
|
* public String setPlayerName(String value) {
|
||||||
* return setData(value);
|
* return setData(value);
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param value
|
* @param value
|
||||||
* The value to set
|
* The value to set
|
||||||
*/
|
*/
|
||||||
protected void setData(Object value) {
|
protected void setData(Object value) {
|
||||||
StackTraceElement st = new Exception().getStackTrace()[1];
|
StackTraceElement st = new Exception().getStackTrace()[1];
|
||||||
String mname = st.getMethodName();
|
String mname = st.getMethodName();
|
||||||
if (!mname.startsWith("set"))
|
if (!mname.startsWith("set"))
|
||||||
throw new UnsupportedOperationException("Can only use setData from a setXYZ method");
|
throw new UnsupportedOperationException("Can only use setData from a setXYZ method");
|
||||||
getLoadedPlayers().get(uuid).data.put(mname.substring("set".length()).toLowerCase(), value);
|
getLoadedPlayers().get(uuid).data.put(mname.substring("set".length()).toLowerCase(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Gets a player data entry for the caller plugin returning the desired type, <b>which is an enum</b><br>
|
* Gets a player data entry for the caller plugin returning the desired type, <b>which is an enum</b><br>
|
||||||
* <i>It will automatically determine the key and the return type.</i><br>
|
* <i>It will automatically determine the key and the return type.</i><br>
|
||||||
* Usage:
|
* Usage:
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* {@code
|
* {@code
|
||||||
* public String getSomeEnum() {
|
* public String getSomeEnum() {
|
||||||
* return getEnumData();
|
* return getEnumData();
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @return The value or null if not found
|
* @return The value or null if not found
|
||||||
*/
|
*/
|
||||||
protected <T extends Enum<T>> T getEnumData(Class<T> cl) {
|
protected <T extends Enum<T>> T getEnumData(Class<T> cl) {
|
||||||
StackTraceElement st = new Exception().getStackTrace()[1];
|
StackTraceElement st = new Exception().getStackTrace()[1];
|
||||||
String mname = st.getMethodName();
|
String mname = st.getMethodName();
|
||||||
if (!mname.startsWith("get"))
|
if (!mname.startsWith("get"))
|
||||||
throw new UnsupportedOperationException("Can only use getEnumData from a getXYZ method");
|
throw new UnsupportedOperationException("Can only use getEnumData from a getXYZ method");
|
||||||
final String retstr = (String) getLoadedPlayers().get(uuid).data
|
final String retstr = (String) getLoadedPlayers().get(uuid).data
|
||||||
.get(mname.substring("get".length()).toLowerCase());
|
.get(mname.substring("get".length()).toLowerCase());
|
||||||
if (retstr != null)
|
if (retstr != null)
|
||||||
return Enum.valueOf(cl, retstr);
|
return Enum.valueOf(cl, retstr);
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a player data entry <i>based on the caller method</i><br>
|
* Sets a player data entry <i>based on the caller method</i><br>
|
||||||
* Usage:
|
* Usage:
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* {@code
|
* {@code
|
||||||
* public String setSomeEnum(SomeEnum value) {
|
* public String setSomeEnum(SomeEnum value) {
|
||||||
* return setEnumData(value);
|
* return setEnumData(value);
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param value
|
* @param value
|
||||||
* The value to set
|
* The value to set
|
||||||
*/
|
*/
|
||||||
protected void setEnumData(Enum<?> value) {
|
protected void setEnumData(Enum<?> value) {
|
||||||
StackTraceElement st = new Exception().getStackTrace()[1];
|
StackTraceElement st = new Exception().getStackTrace()[1];
|
||||||
String mname = st.getMethodName();
|
String mname = st.getMethodName();
|
||||||
if (!mname.startsWith("set"))
|
if (!mname.startsWith("set"))
|
||||||
throw new UnsupportedOperationException("Can only use setEnumData from a setXYZ method");
|
throw new UnsupportedOperationException("Can only use setEnumData from a setXYZ method");
|
||||||
getLoadedPlayers().get(uuid).data.put(mname.substring("set".length()).toLowerCase(), value.toString());
|
getLoadedPlayers().get(uuid).data.put(mname.substring("set".length()).toLowerCase(), value.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Gets a player data entry for the caller plugin returning the desired type, <b>which is a number</b><br>
|
* Gets a player data entry for the caller plugin returning the desired type, <b>which is a number</b><br>
|
||||||
* <i>It will automatically determine the key and the return type.</i><br>
|
* <i>It will automatically determine the key and the return type.</i><br>
|
||||||
* Usage:
|
* Usage:
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* {@code
|
* {@code
|
||||||
* public short getNumber() {
|
* public short getNumber() {
|
||||||
* return getIntData();
|
* return getIntData();
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @return The value or null if not found
|
* @return The value or null if not found
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected <T extends Number> T getIntData(Class<T> cl) {
|
protected <T extends Number> T getIntData(Class<T> cl) {
|
||||||
StackTraceElement st = new Exception().getStackTrace()[1];
|
StackTraceElement st = new Exception().getStackTrace()[1];
|
||||||
String mname = st.getMethodName();
|
String mname = st.getMethodName();
|
||||||
if (!mname.startsWith("get"))
|
if (!mname.startsWith("get"))
|
||||||
throw new UnsupportedOperationException("Can only use getIntData from a getXYZ method");
|
throw new UnsupportedOperationException("Can only use getIntData from a getXYZ method");
|
||||||
Object obj = getLoadedPlayers().get(uuid).data.get(mname.substring("get".length()).toLowerCase());
|
Object obj = getLoadedPlayers().get(uuid).data.get(mname.substring("get".length()).toLowerCase());
|
||||||
if (!(obj instanceof Integer))
|
if (!(obj instanceof Integer))
|
||||||
throw new UnsupportedOperationException("The retrieved object isn't a number: " + obj);
|
throw new UnsupportedOperationException("The retrieved object isn't a number: " + obj);
|
||||||
Integer int_ = (Integer) obj;
|
Integer int_ = (Integer) obj;
|
||||||
if (Short.class.isAssignableFrom(cl))
|
if (Short.class.isAssignableFrom(cl))
|
||||||
return (T) (Object) int_.shortValue();
|
return (T) (Object) int_.shortValue();
|
||||||
else
|
else
|
||||||
return (T) (Object) int_;
|
return (T) (Object) int_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a player data entry <i>based on the caller method</i><br>
|
* Sets a player data entry <i>based on the caller method</i><br>
|
||||||
* Usage:
|
* Usage:
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* {@code
|
* {@code
|
||||||
* public String setNumber(short value) {
|
* public String setNumber(short value) {
|
||||||
* return setIntData(value);
|
* return setIntData(value);
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param value
|
* @param value
|
||||||
* The value to set
|
* The value to set
|
||||||
*/
|
*/
|
||||||
protected void setIntData(Number value) {
|
protected void setIntData(Number value) {
|
||||||
StackTraceElement st = new Exception().getStackTrace()[1];
|
StackTraceElement st = new Exception().getStackTrace()[1];
|
||||||
String mname = st.getMethodName();
|
String mname = st.getMethodName();
|
||||||
if (!mname.startsWith("set"))
|
if (!mname.startsWith("set"))
|
||||||
throw new UnsupportedOperationException("Can only use setIntData from a setXYZ method");
|
throw new UnsupportedOperationException("Can only use setIntData from a setXYZ method");
|
||||||
getLoadedPlayers().get(uuid).data.put(mname.substring("set".length()).toLowerCase(), value);
|
getLoadedPlayers().get(uuid).data.put(mname.substring("set".length()).toLowerCase(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the player's Minecraft name
|
* Gets the player's Minecraft name
|
||||||
*
|
*
|
||||||
* @return The player's Minecraft name
|
* @return The player's Minecraft name
|
||||||
*/
|
*/
|
||||||
public String getPlayerName() {
|
public String getPlayerName() {
|
||||||
return getData();
|
return getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the player's Minecraft name
|
* Sets the player's Minecraft name
|
||||||
*
|
*
|
||||||
* @param playerName
|
* @param playerName
|
||||||
* the new name
|
* the new name
|
||||||
*/
|
*/
|
||||||
public void setPlayerName(String playerName) {
|
public void setPlayerName(String playerName) {
|
||||||
setData(playerName);
|
setData(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private UUID uuid; // Do not save it in the file
|
private UUID uuid; // Do not save it in the file
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the player's UUID
|
* Get the player's UUID
|
||||||
*
|
*
|
||||||
* @return The Minecraft UUID of the player
|
* @return The Minecraft UUID of the player
|
||||||
*/
|
*/
|
||||||
public UUID getUuid() {
|
public UUID getUuid() {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the TBMCPlayer object as a specific plugin player, keeping it's data *
|
* Gets the TBMCPlayer object as a specific plugin player, keeping it's data *
|
||||||
*
|
*
|
||||||
* @param p
|
* @param p
|
||||||
* Player to get
|
* Player to get
|
||||||
* @param cl
|
* @param cl
|
||||||
* The TBMCPlayer subclass
|
* The TBMCPlayer subclass
|
||||||
*/
|
*/
|
||||||
public <T extends TBMCPlayer> T asPluginPlayer(Class<T> cl) {
|
public <T extends TBMCPlayer> T asPluginPlayer(Class<T> cl) {
|
||||||
T obj = null;
|
T obj = null;
|
||||||
try {
|
try {
|
||||||
obj = cl.newInstance();
|
obj = cl.newInstance();
|
||||||
((TBMCPlayer) obj).uuid = uuid;
|
((TBMCPlayer) obj).uuid = uuid;
|
||||||
((TBMCPlayer) obj).data.putAll(data);
|
((TBMCPlayer) obj).data.putAll(data);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HashMap<UUID, TBMCPlayer> LoadedPlayers = new HashMap<>();
|
private static HashMap<UUID, TBMCPlayer> LoadedPlayers = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method returns a TBMC player from their name. Calling this method may return an offline player which will load it, therefore it's highly recommended to use {@link #close()} to unload the
|
* This method returns a TBMC player from their name. Calling this method may return an offline player which will load it, therefore it's highly recommended to use {@link #close()} to unload the
|
||||||
* player data. Using try-with-resources may be the easiest way to achieve this. Example:
|
* player data. Using try-with-resources may be the easiest way to achieve this. Example:
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* {@code
|
* {@code
|
||||||
* try(TBMCPlayer player = getFromName(p))
|
* try(TBMCPlayer player = getFromName(p))
|
||||||
* {
|
* {
|
||||||
* ...
|
* ...
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* The player's name
|
* The player's name
|
||||||
* @return The {@link TBMCPlayer} object for the player
|
* @return The {@link TBMCPlayer} object for the player
|
||||||
*/
|
*/
|
||||||
public static TBMCPlayer getFromName(String name) {
|
public static TBMCPlayer getFromName(String name) {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
OfflinePlayer p = Bukkit.getOfflinePlayer(name);
|
OfflinePlayer p = Bukkit.getOfflinePlayer(name);
|
||||||
if (p != null)
|
if (p != null)
|
||||||
return getPlayer(p);
|
return getPlayer(p);
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method returns a TBMC player from a Bukkit player. Calling this method may return an offline player, therefore it's highly recommended to use {@link #close()} to unload the player data.
|
* This method returns a TBMC player from a Bukkit player. Calling this method may return an offline player, therefore it's highly recommended to use {@link #close()} to unload the player data.
|
||||||
* Using try-with-resources may be the easiest way to achieve this. Example:
|
* Using try-with-resources may be the easiest way to achieve this. Example:
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* {@code
|
* {@code
|
||||||
* try(TBMCPlayer player = getPlayer(p))
|
* try(TBMCPlayer player = getPlayer(p))
|
||||||
* {
|
* {
|
||||||
* ...
|
* ...
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param p
|
* @param p
|
||||||
* The Player object
|
* The Player object
|
||||||
* @return The {@link TBMCPlayer} object for the player
|
* @return The {@link TBMCPlayer} object for the player
|
||||||
*/
|
*/
|
||||||
public static TBMCPlayer getPlayer(OfflinePlayer p) {
|
public static TBMCPlayer getPlayer(OfflinePlayer p) {
|
||||||
if (TBMCPlayer.getLoadedPlayers().containsKey(p.getUniqueId()))
|
if (TBMCPlayer.getLoadedPlayers().containsKey(p.getUniqueId()))
|
||||||
return TBMCPlayer.getLoadedPlayers().get(p.getUniqueId());
|
return TBMCPlayer.getLoadedPlayers().get(p.getUniqueId());
|
||||||
else
|
else
|
||||||
return TBMCPlayer.loadPlayer(p);
|
return TBMCPlayer.loadPlayer(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method returns a TBMC player from a player UUID. Calling this method may return an offline player, therefore it's highly recommended to use {@link #close()} to unload the player data.
|
* This method returns a TBMC player from a player UUID. Calling this method may return an offline player, therefore it's highly recommended to use {@link #close()} to unload the player data.
|
||||||
* Using try-with-resources may be the easiest way to achieve this. Example:
|
* Using try-with-resources may be the easiest way to achieve this. Example:
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* {@code
|
* {@code
|
||||||
* try(TBMCPlayer player = getPlayer(p))
|
* try(TBMCPlayer player = getPlayer(p))
|
||||||
* {
|
* {
|
||||||
* ...
|
* ...
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param p
|
* @param p
|
||||||
* The Player object
|
* The Player object
|
||||||
* @return The {@link TBMCPlayer} object for the player
|
* @return The {@link TBMCPlayer} object for the player
|
||||||
*/
|
*/
|
||||||
public static TBMCPlayer getPlayer(UUID uuid) {
|
public static TBMCPlayer getPlayer(UUID uuid) {
|
||||||
if (TBMCPlayer.getLoadedPlayers().containsKey(uuid))
|
if (TBMCPlayer.getLoadedPlayers().containsKey(uuid))
|
||||||
return TBMCPlayer.getLoadedPlayers().get(uuid);
|
return TBMCPlayer.getLoadedPlayers().get(uuid);
|
||||||
else
|
else
|
||||||
return TBMCPlayer.loadPlayer(Bukkit.getOfflinePlayer(uuid));
|
return TBMCPlayer.loadPlayer(Bukkit.getOfflinePlayer(uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a convenience method for {@link #getPlayer(OfflinePlayer)}.{@link #asPluginPlayer(Class)}.
|
* This is a convenience method for {@link #getPlayer(OfflinePlayer)}.{@link #asPluginPlayer(Class)}.
|
||||||
*
|
*
|
||||||
* See those methods for more information.
|
* See those methods for more information.
|
||||||
*
|
*
|
||||||
* @param p
|
* @param p
|
||||||
* Player to get
|
* Player to get
|
||||||
* @param cl
|
* @param cl
|
||||||
* The TBMCPlayer subclass
|
* The TBMCPlayer subclass
|
||||||
* @return The player as a subtype of TBMCPlayer
|
* @return The player as a subtype of TBMCPlayer
|
||||||
*/
|
*/
|
||||||
public static <T extends TBMCPlayer> T getPlayerAs(OfflinePlayer p, Class<T> cl) {
|
public static <T extends TBMCPlayer> T getPlayerAs(OfflinePlayer p, Class<T> cl) {
|
||||||
return getPlayer(p).asPluginPlayer(cl);
|
return getPlayer(p).asPluginPlayer(cl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a convenience method for {@link #getPlayer(UUID)}.{@link #asPluginPlayer(Class)}
|
* This is a convenience method for {@link #getPlayer(UUID)}.{@link #asPluginPlayer(Class)}
|
||||||
*
|
*
|
||||||
* See those methods for more information.
|
* See those methods for more information.
|
||||||
*
|
*
|
||||||
* @param uuid
|
* @param uuid
|
||||||
* The UUID of the player to get
|
* The UUID of the player to get
|
||||||
* @param cl
|
* @param cl
|
||||||
* The TBMCPlayer subclass
|
* The TBMCPlayer subclass
|
||||||
* @return The player as a subtype of TBMCPlayer
|
* @return The player as a subtype of TBMCPlayer
|
||||||
*/
|
*/
|
||||||
public static <T extends TBMCPlayer> T getPlayerAs(UUID uuid, Class<T> cl) {
|
public static <T extends TBMCPlayer> T getPlayerAs(UUID uuid, Class<T> cl) {
|
||||||
return getPlayer(uuid).asPluginPlayer(cl);
|
return getPlayer(uuid).asPluginPlayer(cl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only intended to use from ButtonCore
|
* Only intended to use from ButtonCore
|
||||||
*/
|
*/
|
||||||
public static TBMCPlayer loadPlayer(OfflinePlayer p) {
|
public static TBMCPlayer loadPlayer(OfflinePlayer p) {
|
||||||
if (getLoadedPlayers().containsKey(p.getUniqueId()))
|
if (getLoadedPlayers().containsKey(p.getUniqueId()))
|
||||||
return getLoadedPlayers().get(p.getUniqueId());
|
return getLoadedPlayers().get(p.getUniqueId());
|
||||||
File file = new File(TBMC_PLAYERS_DIR);
|
File file = new File(TBMC_PLAYERS_DIR);
|
||||||
file.mkdirs();
|
file.mkdirs();
|
||||||
file = new File(TBMC_PLAYERS_DIR, p.getUniqueId().toString() + ".yml");
|
file = new File(TBMC_PLAYERS_DIR, p.getUniqueId().toString() + ".yml");
|
||||||
if (!file.exists())
|
if (!file.exists())
|
||||||
return addPlayer(p);
|
return addPlayer(p);
|
||||||
else {
|
else {
|
||||||
final YamlConfiguration yc = new YamlConfiguration();
|
final YamlConfiguration yc = new YamlConfiguration();
|
||||||
try {
|
try {
|
||||||
yc.load(file);
|
yc.load(file);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
new Exception("Failed to load player data for " + p.getUniqueId(), e).printStackTrace();
|
new Exception("Failed to load player data for " + p.getUniqueId(), e).printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
TBMCPlayer player = new TBMCPlayer();
|
TBMCPlayer player = new TBMCPlayer();
|
||||||
player.uuid = p.getUniqueId();
|
player.uuid = p.getUniqueId();
|
||||||
player.data.putAll(yc.getValues(true));
|
player.data.putAll(yc.getValues(true));
|
||||||
getLoadedPlayers().put(p.getUniqueId(), player); // Accessing any value requires it to be in the map
|
getLoadedPlayers().put(p.getUniqueId(), player); // Accessing any value requires it to be in the map
|
||||||
Bukkit.getLogger().info("Loaded player: " + player.getPlayerName());
|
Bukkit.getLogger().info("Loaded player: " + player.getPlayerName());
|
||||||
if (player.getPlayerName() == null) {
|
if (player.getPlayerName() == null) {
|
||||||
player.setPlayerName(p.getName());
|
player.setPlayerName(p.getName());
|
||||||
Bukkit.getLogger().info("Player name saved: " + player.getPlayerName());
|
Bukkit.getLogger().info("Player name saved: " + player.getPlayerName());
|
||||||
} else if (!p.getName().equals(player.getPlayerName())) {
|
} else if (!p.getName().equals(player.getPlayerName())) {
|
||||||
Bukkit.getLogger().info("Renaming " + player.getPlayerName() + " to " + p.getName());
|
Bukkit.getLogger().info("Renaming " + player.getPlayerName() + " to " + p.getName());
|
||||||
TownyUniverse tu = Towny.getPlugin(Towny.class).getTownyUniverse();
|
TownyUniverse tu = Towny.getPlugin(Towny.class).getTownyUniverse();
|
||||||
Resident resident = tu.getResidentMap().get(player.getPlayerName());
|
Resident resident = tu.getResidentMap().get(player.getPlayerName());
|
||||||
if (resident == null)
|
if (resident == null)
|
||||||
Bukkit.getLogger().warning("Resident not found - couldn't rename in Towny.");
|
Bukkit.getLogger().warning("Resident not found - couldn't rename in Towny.");
|
||||||
else if (tu.getResidentMap().contains(p.getName()))
|
else if (tu.getResidentMap().contains(p.getName()))
|
||||||
Bukkit.getLogger().warning("Target resident name is already in use."); // TODO: Handle
|
Bukkit.getLogger().warning("Target resident name is already in use."); // TODO: Handle
|
||||||
else
|
else
|
||||||
resident.setName(p.getName());
|
resident.setName(p.getName());
|
||||||
player.setPlayerName(p.getName());
|
player.setPlayerName(p.getName());
|
||||||
Bukkit.getLogger().info("Renaming done.");
|
Bukkit.getLogger().info("Renaming done.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load in other plugins
|
// Load in other plugins
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new TBMCPlayerLoadEvent(yc, player));
|
Bukkit.getServer().getPluginManager().callEvent(new TBMCPlayerLoadEvent(yc, player));
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only intended to use from ButtonCore
|
* Only intended to use from ButtonCore
|
||||||
*/
|
*/
|
||||||
public static TBMCPlayer addPlayer(OfflinePlayer p) {
|
public static TBMCPlayer addPlayer(OfflinePlayer p) {
|
||||||
TBMCPlayer player = new TBMCPlayer();
|
TBMCPlayer player = new TBMCPlayer();
|
||||||
player.uuid = p.getUniqueId();
|
player.uuid = p.getUniqueId();
|
||||||
getLoadedPlayers().put(p.getUniqueId(), player); // Accessing any value requires it to be in the map
|
getLoadedPlayers().put(p.getUniqueId(), player); // Accessing any value requires it to be in the map
|
||||||
player.setPlayerName(p.getName());
|
player.setPlayerName(p.getName());
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new TBMCPlayerAddEvent(player));
|
Bukkit.getServer().getPluginManager().callEvent(new TBMCPlayerAddEvent(player));
|
||||||
savePlayer(player);
|
savePlayer(player);
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only intended to use from ButtonCore
|
* Only intended to use from ButtonCore
|
||||||
*/
|
*/
|
||||||
public static void savePlayer(TBMCPlayer player) {
|
public static void savePlayer(TBMCPlayer player) {
|
||||||
YamlConfiguration yc = new YamlConfiguration();
|
YamlConfiguration yc = new YamlConfiguration();
|
||||||
for (Entry<String, Object> item : player.data.entrySet())
|
for (Entry<String, Object> item : player.data.entrySet())
|
||||||
yc.set(item.getKey(), item.getValue());
|
yc.set(item.getKey(), item.getValue());
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new TBMCPlayerSaveEvent(yc, player));
|
Bukkit.getServer().getPluginManager().callEvent(new TBMCPlayerSaveEvent(yc, player));
|
||||||
try {
|
try {
|
||||||
yc.save(TBMC_PLAYERS_DIR + "/" + player.uuid + ".yml");
|
yc.save(TBMC_PLAYERS_DIR + "/" + player.uuid + ".yml");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
new Exception("Failed to save player data for " + player.getPlayerName(), e).printStackTrace();
|
new Exception("Failed to save player data for " + player.getPlayerName(), e).printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only intended to use from ButtonCore
|
* Only intended to use from ButtonCore
|
||||||
*/
|
*/
|
||||||
public static void joinPlayer(TBMCPlayer player) {
|
public static void joinPlayer(TBMCPlayer player) {
|
||||||
getLoadedPlayers().put(player.uuid, player);
|
getLoadedPlayers().put(player.uuid, player);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new TBMCPlayerJoinEvent(player));
|
Bukkit.getServer().getPluginManager().callEvent(new TBMCPlayerJoinEvent(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only intended to use from ButtonCore
|
* Only intended to use from ButtonCore
|
||||||
*/
|
*/
|
||||||
public static void quitPlayer(TBMCPlayer player) {
|
public static void quitPlayer(TBMCPlayer player) {
|
||||||
getLoadedPlayers().remove(player.uuid);
|
getLoadedPlayers().remove(player.uuid);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new TBMCPlayerQuitEvent(player));
|
Bukkit.getServer().getPluginManager().callEvent(new TBMCPlayerQuitEvent(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* By default the player data will only get cleaned from memory when the player quits. Therefore this method must be called when accessing an offline player to clean the player data up. Calling
|
* By default the player data will only get cleaned from memory when the player quits. Therefore this method must be called when accessing an offline player to clean the player data up. Calling
|
||||||
* this method will have no effect on online players.<br>
|
* this method will have no effect on online players.<br>
|
||||||
* Therefore, the recommended use is to call it when using {@link #GetPlayer} or use try-with-resources.
|
* Therefore, the recommended use is to call it when using {@link #GetPlayer} or use try-with-resources.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
if (!Bukkit.getPlayer(uuid).isOnline())
|
if (!Bukkit.getPlayer(uuid).isOnline())
|
||||||
getLoadedPlayers().remove(uuid);
|
getLoadedPlayers().remove(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<UUID, TBMCPlayer> getLoadedPlayers() {
|
public static HashMap<UUID, TBMCPlayer> getLoadedPlayers() {
|
||||||
return LoadedPlayers;
|
return LoadedPlayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get player information. This method calls the {@link TBMCPlayerGetInfoEvent} to get all the player information across the TBMC plugins.
|
* Get player information. This method calls the {@link TBMCPlayerGetInfoEvent} to get all the player information across the TBMC plugins.
|
||||||
*
|
*
|
||||||
* @param target
|
* @param target
|
||||||
* The {@link InfoTarget} to return the info for.
|
* The {@link InfoTarget} to return the info for.
|
||||||
* @return The player information.
|
* @return The player information.
|
||||||
*/
|
*/
|
||||||
public String getInfo(InfoTarget target) {
|
public String getInfo(InfoTarget target) {
|
||||||
TBMCPlayerGetInfoEvent event = new TBMCPlayerGetInfoEvent(this, target);
|
TBMCPlayerGetInfoEvent event = new TBMCPlayerGetInfoEvent(this, target);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
return event.getResult();
|
return event.getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum InfoTarget {
|
public enum InfoTarget {
|
||||||
MCHover, MCCommand, Discord
|
MCHover, MCCommand, Discord
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,36 +1,36 @@
|
||||||
package buttondevteam.lib;
|
package buttondevteam.lib;
|
||||||
|
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* This event gets called when a new player joins. After this event, the
|
* This event gets called when a new player joins. After this event, the
|
||||||
* {@link TBMCPlayerSaveEvent} will be called.
|
* {@link TBMCPlayerSaveEvent} will be called.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author Norbi
|
* @author Norbi
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TBMCPlayerAddEvent extends Event {
|
public class TBMCPlayerAddEvent extends Event {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private TBMCPlayer player;
|
private TBMCPlayer player;
|
||||||
|
|
||||||
public TBMCPlayerAddEvent(TBMCPlayer player) {
|
public TBMCPlayerAddEvent(TBMCPlayer player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TBMCPlayer GetPlayer() {
|
public TBMCPlayer GetPlayer() {
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,73 +1,73 @@
|
||||||
package buttondevteam.lib;
|
package buttondevteam.lib;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import buttondevteam.lib.TBMCPlayer.InfoTarget;
|
import buttondevteam.lib.TBMCPlayer.InfoTarget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* This event gets called when player information is requested. It can be used to give more per-plugin information about a player.
|
* This event gets called when player information is requested. It can be used to give more per-plugin information about a player.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author Norbi
|
* @author Norbi
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TBMCPlayerGetInfoEvent extends Event {
|
public class TBMCPlayerGetInfoEvent extends Event {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private TBMCPlayer player;
|
private TBMCPlayer player;
|
||||||
private List<String> infolines;
|
private List<String> infolines;
|
||||||
private TBMCPlayer.InfoTarget target;
|
private TBMCPlayer.InfoTarget target;
|
||||||
|
|
||||||
TBMCPlayerGetInfoEvent(TBMCPlayer player, TBMCPlayer.InfoTarget target) {
|
TBMCPlayerGetInfoEvent(TBMCPlayer player, TBMCPlayer.InfoTarget target) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
infolines = new ArrayList<>();
|
infolines = new ArrayList<>();
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the {@link TBMCPlayer} object
|
* Get the {@link TBMCPlayer} object
|
||||||
*
|
*
|
||||||
* @return A player object
|
* @return A player object
|
||||||
*/
|
*/
|
||||||
public TBMCPlayer getPlayer() {
|
public TBMCPlayer getPlayer() {
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a line to the information text. The line should be in the format of <i>key: value</i> .
|
* Add a line to the information text. The line should be in the format of <i>key: value</i> .
|
||||||
*
|
*
|
||||||
* @param infoline
|
* @param infoline
|
||||||
* The line to add
|
* The line to add
|
||||||
*/
|
*/
|
||||||
public void addInfo(String infoline) {
|
public void addInfo(String infoline) {
|
||||||
infolines.add(infoline);
|
infolines.add(infoline);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the {@link InfoTarget} we want the information for. Use this to format the returned string.
|
* Get the {@link InfoTarget} we want the information for. Use this to format the returned string.
|
||||||
*
|
*
|
||||||
* @return The target of the information.
|
* @return The target of the information.
|
||||||
*/
|
*/
|
||||||
public TBMCPlayer.InfoTarget getTarget() {
|
public TBMCPlayer.InfoTarget getTarget() {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getResult() {
|
String getResult() {
|
||||||
return infolines.stream().collect(Collectors.joining("\n"));
|
return infolines.stream().collect(Collectors.joining("\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,27 +1,27 @@
|
||||||
package buttondevteam.lib;
|
package buttondevteam.lib;
|
||||||
|
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
public class TBMCPlayerJoinEvent extends Event {
|
public class TBMCPlayerJoinEvent extends Event {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private TBMCPlayer player;
|
private TBMCPlayer player;
|
||||||
|
|
||||||
public TBMCPlayerJoinEvent(TBMCPlayer player) {
|
public TBMCPlayerJoinEvent(TBMCPlayer player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TBMCPlayer GetPlayer() {
|
public TBMCPlayer GetPlayer() {
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,34 +1,34 @@
|
||||||
package buttondevteam.lib;
|
package buttondevteam.lib;
|
||||||
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
public class TBMCPlayerLoadEvent extends Event {
|
public class TBMCPlayerLoadEvent extends Event {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private YamlConfiguration yaml;
|
private YamlConfiguration yaml;
|
||||||
private TBMCPlayer player;
|
private TBMCPlayer player;
|
||||||
|
|
||||||
public TBMCPlayerLoadEvent(YamlConfiguration yaml, TBMCPlayer player) {
|
public TBMCPlayerLoadEvent(YamlConfiguration yaml, TBMCPlayer player) {
|
||||||
this.yaml = yaml;
|
this.yaml = yaml;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public YamlConfiguration GetPlayerConfig() {
|
public YamlConfiguration GetPlayerConfig() {
|
||||||
return yaml;
|
return yaml;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TBMCPlayer GetPlayer() {
|
public TBMCPlayer GetPlayer() {
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,27 +1,27 @@
|
||||||
package buttondevteam.lib;
|
package buttondevteam.lib;
|
||||||
|
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
public class TBMCPlayerQuitEvent extends Event {
|
public class TBMCPlayerQuitEvent extends Event {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private TBMCPlayer player;
|
private TBMCPlayer player;
|
||||||
|
|
||||||
public TBMCPlayerQuitEvent(TBMCPlayer player) {
|
public TBMCPlayerQuitEvent(TBMCPlayer player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TBMCPlayer GetPlayer() {
|
public TBMCPlayer GetPlayer() {
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,34 +1,34 @@
|
||||||
package buttondevteam.lib;
|
package buttondevteam.lib;
|
||||||
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
public class TBMCPlayerSaveEvent extends Event {
|
public class TBMCPlayerSaveEvent extends Event {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private YamlConfiguration yaml;
|
private YamlConfiguration yaml;
|
||||||
private TBMCPlayer player;
|
private TBMCPlayer player;
|
||||||
|
|
||||||
public TBMCPlayerSaveEvent(YamlConfiguration yaml, TBMCPlayer player) {
|
public TBMCPlayerSaveEvent(YamlConfiguration yaml, TBMCPlayer player) {
|
||||||
this.yaml = yaml;
|
this.yaml = yaml;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public YamlConfiguration GetPlayerConfig() {
|
public YamlConfiguration GetPlayerConfig() {
|
||||||
return yaml;
|
return yaml;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TBMCPlayer GetPlayer() {
|
public TBMCPlayer GetPlayer() {
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,99 +1,99 @@
|
||||||
package buttondevteam.lib.chat;
|
package buttondevteam.lib.chat;
|
||||||
|
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.reflections.Reflections;
|
import org.reflections.Reflections;
|
||||||
import org.reflections.scanners.SubTypesScanner;
|
import org.reflections.scanners.SubTypesScanner;
|
||||||
import org.reflections.util.ClasspathHelper;
|
import org.reflections.util.ClasspathHelper;
|
||||||
import org.reflections.util.ConfigurationBuilder;
|
import org.reflections.util.ConfigurationBuilder;
|
||||||
|
|
||||||
import buttondevteam.lib.TBMCPlayer;
|
import buttondevteam.lib.TBMCPlayer;
|
||||||
|
|
||||||
public class TBMCChatAPI {
|
public class TBMCChatAPI {
|
||||||
|
|
||||||
private static HashMap<String, TBMCCommandBase> commands = new HashMap<String, TBMCCommandBase>();
|
private static HashMap<String, TBMCCommandBase> commands = new HashMap<String, TBMCCommandBase>();
|
||||||
|
|
||||||
public static HashMap<String, TBMCCommandBase> GetCommands() {
|
public static HashMap<String, TBMCCommandBase> GetCommands() {
|
||||||
return commands;
|
return commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] GetSubCommands(TBMCCommandBase command) {
|
public static String[] GetSubCommands(TBMCCommandBase command) {
|
||||||
ArrayList<String> cmds = new ArrayList<String>();
|
ArrayList<String> cmds = new ArrayList<String>();
|
||||||
cmds.add("§6---- Subcommands ----");
|
cmds.add("§6---- Subcommands ----");
|
||||||
for (TBMCCommandBase cmd : TBMCChatAPI.GetCommands().values()) {
|
for (TBMCCommandBase cmd : TBMCChatAPI.GetCommands().values()) {
|
||||||
if (cmd.GetCommandPath().startsWith(command.GetCommandPath() + "/")) {
|
if (cmd.GetCommandPath().startsWith(command.GetCommandPath() + "/")) {
|
||||||
int ind = cmd.GetCommandPath().indexOf('/', command.GetCommandPath().length() + 2);
|
int ind = cmd.GetCommandPath().indexOf('/', command.GetCommandPath().length() + 2);
|
||||||
if (ind >= 0)
|
if (ind >= 0)
|
||||||
continue;
|
continue;
|
||||||
cmds.add(cmd.GetCommandPath().replace('/', ' '));
|
cmds.add(cmd.GetCommandPath().replace('/', ' '));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return cmds.toArray(new String[cmds.size()]);
|
return cmds.toArray(new String[cmds.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* This method adds a plugin's commands to help and sets their executor.
|
* This method adds a plugin's commands to help and sets their executor.
|
||||||
* </p>
|
* </p>
|
||||||
* <p>
|
* <p>
|
||||||
* The <u>command must be registered</u> in the caller plugin's plugin.yml. Otherwise the plugin will output a messsage to console.
|
* The <u>command must be registered</u> in the caller plugin's plugin.yml. Otherwise the plugin will output a messsage to console.
|
||||||
* </p>
|
* </p>
|
||||||
* <p>
|
* <p>
|
||||||
* <i>Using this method after the server is done loading will have no effect.</i>
|
* <i>Using this method after the server is done loading will have no effect.</i>
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param plugin
|
* @param plugin
|
||||||
* The caller plugin
|
* The caller plugin
|
||||||
* @param acmdclass
|
* @param acmdclass
|
||||||
* A command's class to get the package name for commands. The provided class's package and subpackages are scanned for commands.
|
* A command's class to get the package name for commands. The provided class's package and subpackages are scanned for commands.
|
||||||
*/
|
*/
|
||||||
public static void AddCommands(JavaPlugin plugin, Class<? extends TBMCCommandBase> acmdclass) {
|
public static void AddCommands(JavaPlugin plugin, Class<? extends TBMCCommandBase> acmdclass) {
|
||||||
plugin.getLogger().info("Registering commands for " + plugin.getName());
|
plugin.getLogger().info("Registering commands for " + plugin.getName());
|
||||||
Reflections rf = new Reflections(
|
Reflections rf = new Reflections(
|
||||||
new ConfigurationBuilder().setUrls(ClasspathHelper.forClassLoader(plugin.getClass().getClassLoader()))
|
new ConfigurationBuilder().setUrls(ClasspathHelper.forClassLoader(plugin.getClass().getClassLoader()))
|
||||||
.addClassLoader(plugin.getClass().getClassLoader()).addScanners(new SubTypesScanner())
|
.addClassLoader(plugin.getClass().getClassLoader()).addScanners(new SubTypesScanner())
|
||||||
.filterInputsBy((String pkg) -> pkg.contains(acmdclass.getPackage().getName())));
|
.filterInputsBy((String pkg) -> pkg.contains(acmdclass.getPackage().getName())));
|
||||||
Set<Class<? extends TBMCCommandBase>> cmds = rf.getSubTypesOf(TBMCCommandBase.class);
|
Set<Class<? extends TBMCCommandBase>> cmds = rf.getSubTypesOf(TBMCCommandBase.class);
|
||||||
for (Class<? extends TBMCCommandBase> cmd : cmds) {
|
for (Class<? extends TBMCCommandBase> cmd : cmds) {
|
||||||
try {
|
try {
|
||||||
if (Modifier.isAbstract(cmd.getModifiers()))
|
if (Modifier.isAbstract(cmd.getModifiers()))
|
||||||
continue;
|
continue;
|
||||||
TBMCCommandBase c = cmd.newInstance();
|
TBMCCommandBase c = cmd.newInstance();
|
||||||
c.plugin = plugin;
|
c.plugin = plugin;
|
||||||
commands.put(c.GetCommandPath(), c);
|
commands.put(c.GetCommandPath(), c);
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Add player information for {@link PlayerInfoCommand}. Only mods can see the given information.
|
* Add player information for {@link PlayerInfoCommand}. Only mods can see the given information.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
* @param infoline
|
* @param infoline
|
||||||
*/
|
*/
|
||||||
public void AddPlayerInfoForMods(TBMCPlayer player, String infoline) {
|
public void AddPlayerInfoForMods(TBMCPlayer player, String infoline) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Add player information for hover text at {@link ChatProcessing}. Every online player can see the given information.
|
* Add player information for hover text at {@link ChatProcessing}. Every online player can see the given information.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
* @param infoline
|
* @param infoline
|
||||||
*/
|
*/
|
||||||
public void AddPlayerInfoForHover(TBMCPlayer player, String infoline) {
|
public void AddPlayerInfoForHover(TBMCPlayer player, String infoline) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,26 +1,26 @@
|
||||||
package buttondevteam.lib.chat;
|
package buttondevteam.lib.chat;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
public abstract class TBMCCommandBase {
|
public abstract class TBMCCommandBase {
|
||||||
|
|
||||||
public TBMCCommandBase() {
|
public TBMCCommandBase() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String[] GetHelpText(String alias);
|
public abstract String[] GetHelpText(String alias);
|
||||||
|
|
||||||
public abstract boolean OnCommand(CommandSender sender, String alias, String[] args);
|
public abstract boolean OnCommand(CommandSender sender, String alias, String[] args);
|
||||||
|
|
||||||
public abstract String GetCommandPath();
|
public abstract String GetCommandPath();
|
||||||
|
|
||||||
public abstract boolean GetPlayerOnly();
|
public abstract boolean GetPlayerOnly();
|
||||||
|
|
||||||
public abstract boolean GetModOnly();
|
public abstract boolean GetModOnly();
|
||||||
|
|
||||||
Plugin plugin; // Used By TBMCChatAPI
|
Plugin plugin; // Used By TBMCChatAPI
|
||||||
|
|
||||||
public Plugin getPlugin() { // Used by CommandCaller (ButtonChat)
|
public Plugin getPlugin() { // Used by CommandCaller (ButtonChat)
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue