Merge branch 'dev'
This commit is contained in:
@@ -14,10 +14,9 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "com.github.RedstonerServer:ModuleLoader:gradle-SNAPSHOT"
|
implementation "com.github.RedstonerServer:ModuleLoader:v5.2.1"
|
||||||
implementation "com.github.RedstonerServer:CommandManager:master-SNAPSHOT"
|
implementation "com.github.RedstonerServer:CommandManager:v1"
|
||||||
implementation "com.github.RedstonerServer:ChatAPI:master-SNAPSHOT"
|
implementation "com.github.RedstonerServer:ChatAPI:v1"
|
||||||
implementation "com.github.RedstonerServer:ChestAPI:master-SNAPSHOT"
|
|
||||||
|
|
||||||
compileOnly 'org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT'
|
compileOnly 'org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT'
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
5
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
5
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
172
gradlew
vendored
Executable file
172
gradlew
vendored
Executable file
@@ -0,0 +1,172 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS=""
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="java"
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
|
if $darwin; then
|
||||||
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
|
if $cygwin ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
(0) set -- ;;
|
||||||
|
(1) set -- "$args0" ;;
|
||||||
|
(2) set -- "$args0" "$args1" ;;
|
||||||
|
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Escape application args
|
||||||
|
save () {
|
||||||
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
APP_ARGS=$(save "$@")
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||||
|
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
84
gradlew.bat
vendored
Normal file
84
gradlew.bat
vendored
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
@if "%DEBUG%" == "" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS=
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:init
|
||||||
|
@rem Get command-line arguments, handling Windows variants
|
||||||
|
|
||||||
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
|
|
||||||
|
:win9xME_args
|
||||||
|
@rem Slurp the command line arguments.
|
||||||
|
set CMD_LINE_ARGS=
|
||||||
|
set _SKIP=2
|
||||||
|
|
||||||
|
:win9xME_args_slurp
|
||||||
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
|
set CMD_LINE_ARGS=%*
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
||||||
@@ -28,7 +28,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
@Commands (CommandHolderType.File)
|
@Commands (CommandHolderType.File)
|
||||||
@AutoRegisterListener
|
@AutoRegisterListener
|
||||||
@Version (major = 5, minor = 2, revision = 0, compatible = 4)
|
@Version (major = 5, minor = 2, revision = 1, compatible = 4)
|
||||||
public class BlockPlaceMods implements Module, Listener {
|
public class BlockPlaceMods implements Module, Listener {
|
||||||
private static final Map<String, BlockPlaceMod> mods = new HashMap<>();
|
private static final Map<String, BlockPlaceMod> mods = new HashMap<>();
|
||||||
private static final List<BlockPlaceMod> enabledMods = new ArrayList<>();
|
private static final List<BlockPlaceMod> enabledMods = new ArrayList<>();
|
||||||
@@ -54,6 +54,7 @@ public class BlockPlaceMods implements Module, Listener {
|
|||||||
if (mod.onEnable()) {
|
if (mod.onEnable()) {
|
||||||
enabledMods.add(mod);
|
enabledMods.add(mod);
|
||||||
Bukkit.getPluginManager().registerEvents(mod, Main.plugin);
|
Bukkit.getPluginManager().registerEvents(mod, Main.plugin);
|
||||||
|
getLogger().info("Loaded mod, &e" + mod.name + "&7.");
|
||||||
} else {
|
} else {
|
||||||
getLogger().warn("Failed to enable the mod, &e" + mod.name + "&7!");
|
getLogger().warn("Failed to enable the mod, &e" + mod.name + "&7!");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
command friends {
|
command friends {
|
||||||
|
alias friend;
|
||||||
|
perm utils.friends;
|
||||||
|
type player;
|
||||||
|
|
||||||
add [string:name] {
|
add [string:name] {
|
||||||
run add name;
|
run add name;
|
||||||
help Adds a friend to your friendlist.;
|
help Adds a friend to your friend list.;
|
||||||
perm utils.friends;
|
|
||||||
}
|
}
|
||||||
add [string:name] [string:group] {
|
add [string:name] [string:group] {
|
||||||
run add_grouped name group;
|
run add_grouped name group;
|
||||||
@@ -11,8 +14,7 @@ command friends {
|
|||||||
}
|
}
|
||||||
remove [string:name] {
|
remove [string:name] {
|
||||||
run del name;
|
run del name;
|
||||||
help Removes a friend from your friendlist.;
|
help Removes a friend from your friend list.;
|
||||||
perm utils.friends;
|
|
||||||
}
|
}
|
||||||
remove [string:name] [string:group] {
|
remove [string:name] [string:group] {
|
||||||
run del_grouped name group;
|
run del_grouped name group;
|
||||||
@@ -22,7 +24,6 @@ command friends {
|
|||||||
list {
|
list {
|
||||||
run list;
|
run list;
|
||||||
help Shows a list of all your friends.;
|
help Shows a list of all your friends.;
|
||||||
perm utils.friends;
|
|
||||||
}
|
}
|
||||||
list [string:group] {
|
list [string:group] {
|
||||||
run list_group group;
|
run list_group group;
|
||||||
@@ -34,5 +35,14 @@ command friends {
|
|||||||
help Shows all your friend groups that have at least one person in them.;
|
help Shows all your friend groups that have at least one person in them.;
|
||||||
perm utils.friends.groups;
|
perm utils.friends.groups;
|
||||||
}
|
}
|
||||||
type player;
|
group {
|
||||||
|
[string:groupName] {
|
||||||
|
run list_group groupName;
|
||||||
|
help Shows a list of all friends in that group.;
|
||||||
|
perm utils.friends.groups;
|
||||||
|
}
|
||||||
|
run list_groups;
|
||||||
|
help Shows all your friend groups that have at least one person in them.;
|
||||||
|
perm utils.friends.groups;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.json.simple.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
@@ -27,41 +28,48 @@ import com.redstoner.modules.CoreModule;
|
|||||||
import com.redstoner.modules.Module;
|
import com.redstoner.modules.Module;
|
||||||
import com.redstoner.modules.datamanager.DataManager;
|
import com.redstoner.modules.datamanager.DataManager;
|
||||||
|
|
||||||
|
import net.nemez.chatapi.click.Message;
|
||||||
|
|
||||||
@AutoRegisterListener
|
@AutoRegisterListener
|
||||||
@Commands(CommandHolderType.File)
|
@Commands(CommandHolderType.File)
|
||||||
@Version(major = 5, minor = 0, revision = 0, compatible = 4)
|
@Version(major = 5, minor = 1, revision = 1, compatible = 4)
|
||||||
public class Friends implements CoreModule {
|
public class Friends implements CoreModule, Listener {
|
||||||
|
|
||||||
|
private static int GROUP_PREFIX_LENGETH = 6;
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||||
JSONArray friended_by = (JSONArray) DataManager.getOrDefault(e.getPlayer(), "friended_by", new JSONArray());
|
Player player = e.getPlayer();
|
||||||
|
JSONArray friended_by = (JSONArray) DataManager.getOrDefault(player, "friended_by", new JSONArray());
|
||||||
|
|
||||||
for (Object obj : friended_by) {
|
for (Object obj : friended_by) {
|
||||||
UUID uuid = UUID.fromString((String) obj);
|
UUID uuid = UUID.fromString((String) obj);
|
||||||
Player p = Bukkit.getPlayer(uuid);
|
Player p = Bukkit.getPlayer(uuid);
|
||||||
|
|
||||||
if (p != null && p.canSee(e.getPlayer())) {
|
if (p != null && p.canSee(player)) {
|
||||||
getLogger().message(p, "Your friend &e" + e.getPlayer().getDisplayName() + "&7 just joined!");
|
getLogger().message(p, "Your friend &e" + player.getDisplayName() + "&7 just joined!");
|
||||||
p.playSound(p.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1, 1);
|
p.playSound(p.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONArray notifications = (JSONArray) DataManager.getOrDefault(e.getPlayer(), "scheduled_notifications", new JSONArray());
|
JSONArray notifications = (JSONArray) DataManager.getOrDefault(player, "scheduled_notifications", new JSONArray());
|
||||||
|
for (Object obj : notifications)
|
||||||
for (Object obj : notifications) {
|
getLogger().message(player, (String) obj);
|
||||||
getLogger().message(e.getPlayer(), (String) obj);
|
DataManager.setData(player, "scheduled_notifications", new JSONArray());
|
||||||
}
|
DataManager.save(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerLeave(PlayerQuitEvent e) {
|
public void onPlayerLeave(PlayerQuitEvent e) {
|
||||||
JSONArray friended_by = (JSONArray) DataManager.getOrDefault(e.getPlayer(), "friended_by", new JSONArray());
|
Player player = e.getPlayer();
|
||||||
|
JSONArray friended_by = (JSONArray) DataManager.getOrDefault(player, "friended_by", new JSONArray());
|
||||||
|
|
||||||
for (Object obj : friended_by) {
|
for (Object obj : friended_by) {
|
||||||
UUID uuid = UUID.fromString((String) obj);
|
UUID uuid = UUID.fromString((String) obj);
|
||||||
Player p = Bukkit.getPlayer(uuid);
|
Player p = Bukkit.getPlayer(uuid);
|
||||||
|
|
||||||
if (p != null && p.canSee(e.getPlayer())) {
|
if (p != null && p.canSee(player)) {
|
||||||
getLogger().message(p, "Your friend &e" + e.getPlayer().getDisplayName() + "&7 just left!");
|
getLogger().message(p, "Your friend &e" + player.getDisplayName() + "&7 just left!");
|
||||||
p.playSound(p.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1, 1);
|
p.playSound(p.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -78,8 +86,8 @@ public class Friends implements CoreModule {
|
|||||||
OfflinePlayer p = Bukkit.getPlayer(target);
|
OfflinePlayer p = Bukkit.getPlayer(target);
|
||||||
|
|
||||||
if (p == null) p = Bukkit.getOfflinePlayer(target);
|
if (p == null) p = Bukkit.getOfflinePlayer(target);
|
||||||
if (p == null) {
|
if (p == null || !p.hasPlayedBefore()) {
|
||||||
getLogger().message(sender, true, "That player couldn't be found!");
|
getLogger().message(sender, true, "That player has never joined the server!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,21 +104,22 @@ public class Friends implements CoreModule {
|
|||||||
|
|
||||||
JSONArray friended_by = ((JSONArray) DataManager.getOrDefault(p.getUniqueId().toString(), "friended_by", new JSONArray()));
|
JSONArray friended_by = ((JSONArray) DataManager.getOrDefault(p.getUniqueId().toString(), "friended_by", new JSONArray()));
|
||||||
friended_by.add(getID(sender));
|
friended_by.add(getID(sender));
|
||||||
DataManager.setData(p.getUniqueId().toString(), "friended_by", friended_by);
|
|
||||||
|
|
||||||
|
DataManager.setData(p.getUniqueId().toString(), "friended_by", friended_by);
|
||||||
DataManager.save(p.getUniqueId().toString());
|
DataManager.save(p.getUniqueId().toString());
|
||||||
|
|
||||||
getLogger().message(sender, "You are now friends with &e" + p.getName() + "&7!");
|
getLogger().message(sender, "You are now friends with &e" + p.getName() + "&7!");
|
||||||
|
|
||||||
if (p instanceof Player) {
|
if (p instanceof Player)
|
||||||
getLogger().message((Player) p, "&e" + Utils.getName(sender) + "&7 added you as a friend!");
|
getLogger().message((Player) p, "&e" + Utils.getName(sender) + "&7 added you as a friend!");
|
||||||
} else {
|
else {
|
||||||
JSONArray notifications = (JSONArray) DataManager.getOrDefault(p.getUniqueId().toString(), "scheduled_notifications", new JSONArray());
|
JSONArray notifications = (JSONArray) DataManager.getOrDefault(p.getUniqueId().toString(), "scheduled_notifications", new JSONArray());
|
||||||
|
|
||||||
notifications.add("&e" + Utils.getName(sender) + "&7 added you as a friend!");
|
notifications.add("&e" + Utils.getName(sender) + "&7 added you as a friend!");
|
||||||
notifications.remove("&e" + Utils.getName(sender) + "&7 removed you as a friend!");
|
notifications.remove("&e" + Utils.getName(sender) + "&7 removed you as a friend!");
|
||||||
|
|
||||||
DataManager.setData(p.getUniqueId().toString(), "scheduled_notifications", notifications);
|
DataManager.setData(p.getUniqueId().toString(), "scheduled_notifications", notifications);
|
||||||
|
DataManager.save(p.getUniqueId().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -127,33 +136,34 @@ public class Friends implements CoreModule {
|
|||||||
OfflinePlayer p = Bukkit.getPlayer(target);
|
OfflinePlayer p = Bukkit.getPlayer(target);
|
||||||
|
|
||||||
if (p == null) p = Bukkit.getOfflinePlayer(target);
|
if (p == null) p = Bukkit.getOfflinePlayer(target);
|
||||||
if (p == null) {
|
if (p == null || !p.hasPlayedBefore()) {
|
||||||
getLogger().message(sender, true, "That player couldn't be found!");
|
getLogger().message(sender, true, "That player has neevr joined the server!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONArray friends = ((JSONArray) DataManager.getOrDefault(sender, "groups." + group, new JSONArray()));
|
JSONArray friends = ((JSONArray) DataManager.getOrDefault(sender, "group." + group, new JSONArray()));
|
||||||
|
|
||||||
if (friends.contains(p.getUniqueId().toString())) {
|
if (friends.contains(p.getUniqueId().toString())) {
|
||||||
getLogger().message(sender, true, "This person already is part of that friendsgroup!");
|
getLogger().message(sender, true, "This person already is part of that friendgroup!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
friends.add(p.getUniqueId().toString());
|
friends.add(p.getUniqueId().toString());
|
||||||
DataManager.setData(sender, "groups." + group, friends);
|
DataManager.setData(sender, "group." + group, friends);
|
||||||
DataManager.save(sender);
|
DataManager.save(sender);
|
||||||
|
|
||||||
getLogger().message(sender, "&e" + p.getName() + "&7 is now part of the group &e" + group + "&7!");
|
getLogger().message(sender, "&e" + p.getName() + "&7 is now part of the group &e" + group + "&7!");
|
||||||
|
|
||||||
if (p instanceof Player) {
|
if (p instanceof Player)
|
||||||
getLogger().message((Player) p, "&e" + Utils.getName(sender) + " &7added you to their friendsgroup &e" + group + "&7!");
|
getLogger().message((Player) p, "&e" + Utils.getName(sender) + " &7added you to their friendgroup &e" + group + "&7!");
|
||||||
} else {
|
else {
|
||||||
JSONArray notifications = (JSONArray) DataManager.getOrDefault(p.getUniqueId().toString(), "scheduled_notifications", new JSONArray());
|
JSONArray notifications = (JSONArray) DataManager.getOrDefault(p.getUniqueId().toString(), "scheduled_notifications", new JSONArray());
|
||||||
|
|
||||||
notifications.add("&e" + Utils.getName(sender) + " &7added you to their friendsgroup &e" + group + "&7!");
|
notifications.add("&e" + Utils.getName(sender) + " &7added you to their friendgroup &e" + group + "&7!");
|
||||||
notifications.remove("&e" + Utils.getName(sender) + " &7removed you from their friendsgroup &e" + group + "&7!");
|
notifications.remove("&e" + Utils.getName(sender) + " &7removed you from their friendgroup &e" + group + "&7!");
|
||||||
|
|
||||||
DataManager.setData(p.getUniqueId().toString(), "scheduled_notifications", notifications);
|
DataManager.setData(p.getUniqueId().toString(), "scheduled_notifications", notifications);
|
||||||
|
DataManager.save(p.getUniqueId().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -163,14 +173,14 @@ public class Friends implements CoreModule {
|
|||||||
@Command(hook = "del")
|
@Command(hook = "del")
|
||||||
public boolean del(CommandSender sender, String target) {
|
public boolean del(CommandSender sender, String target) {
|
||||||
if (target.equalsIgnoreCase("CONSOLE")) {
|
if (target.equalsIgnoreCase("CONSOLE")) {
|
||||||
getLogger().message(sender, true, "You can't add console to your friends!");
|
getLogger().message(sender, true, "You can't have console as your friends!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
OfflinePlayer p = Bukkit.getPlayer(target);
|
OfflinePlayer p = Bukkit.getPlayer(target);
|
||||||
|
|
||||||
if (p == null) p = Bukkit.getOfflinePlayer(target);
|
if (p == null) p = Bukkit.getOfflinePlayer(target);
|
||||||
if (p == null) {
|
if (p == null || !p.hasPlayedBefore()) {
|
||||||
getLogger().message(sender, true, "That player couldn't be found!");
|
getLogger().message(sender, true, "That player couldn't be found!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -187,22 +197,23 @@ public class Friends implements CoreModule {
|
|||||||
DataManager.save(sender);
|
DataManager.save(sender);
|
||||||
|
|
||||||
JSONArray friended_by = ((JSONArray) DataManager.getOrDefault(p.getUniqueId().toString(), "friended_by", new JSONArray()));
|
JSONArray friended_by = ((JSONArray) DataManager.getOrDefault(p.getUniqueId().toString(), "friended_by", new JSONArray()));
|
||||||
DataManager.setData(p.getUniqueId().toString(), "friended_by", friended_by);
|
|
||||||
friended_by.remove(getID(sender));
|
friended_by.remove(getID(sender));
|
||||||
|
|
||||||
|
DataManager.setData(p.getUniqueId().toString(), "friended_by", friended_by);
|
||||||
DataManager.save(p.getUniqueId().toString());
|
DataManager.save(p.getUniqueId().toString());
|
||||||
|
|
||||||
getLogger().message(sender, "You are no longer friends with &e" + p.getName() + "&7!");
|
getLogger().message(sender, "You are no longer friends with &e" + p.getName() + "&7!");
|
||||||
|
|
||||||
if (p instanceof Player) {
|
if (p instanceof Player)
|
||||||
getLogger().message((Player) p, "&e" + Utils.getName(sender) + "&7 removed you as a friend!");
|
getLogger().message((Player) p, "&e" + Utils.getName(sender) + "&7 removed you as a friend!");
|
||||||
} else {
|
else {
|
||||||
JSONArray notifications = (JSONArray) DataManager.getOrDefault(p.getUniqueId().toString(), "scheduled_notifications", new JSONArray());
|
JSONArray notifications = (JSONArray) DataManager.getOrDefault(p.getUniqueId().toString(), "scheduled_notifications", new JSONArray());
|
||||||
|
|
||||||
notifications.add("&e" + Utils.getName(sender) + "&7 removed you as a friend!");
|
notifications.add("&e" + Utils.getName(sender) + "&7 removed you as a friend!");
|
||||||
notifications.remove("&e" + Utils.getName(sender) + "&7 added you as a friend!");
|
notifications.remove("&e" + Utils.getName(sender) + "&7 added you as a friend!");
|
||||||
|
|
||||||
DataManager.setData(p.getUniqueId().toString(), "scheduled_notifications", notifications);
|
DataManager.setData(p.getUniqueId().toString(), "scheduled_notifications", notifications);
|
||||||
|
DataManager.save(p.getUniqueId().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -219,33 +230,34 @@ public class Friends implements CoreModule {
|
|||||||
OfflinePlayer p = Bukkit.getPlayer(target);
|
OfflinePlayer p = Bukkit.getPlayer(target);
|
||||||
|
|
||||||
if (p == null) p = Bukkit.getOfflinePlayer(target);
|
if (p == null) p = Bukkit.getOfflinePlayer(target);
|
||||||
if (p == null) {
|
if (p == null || !p.hasPlayedBefore()) {
|
||||||
getLogger().message(sender, true, "That player couldn't be found!");
|
getLogger().message(sender, true, "That player couldn't be found!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONArray friends = ((JSONArray) DataManager.getOrDefault(sender, "groups." + group, new JSONArray()));
|
JSONArray friends = ((JSONArray) DataManager.getOrDefault(sender, "group." + group, new JSONArray()));
|
||||||
|
|
||||||
if (!friends.contains(p.getUniqueId().toString())) {
|
if (!friends.contains(p.getUniqueId().toString())) {
|
||||||
getLogger().message(sender, true, "This person isn't a part of that friendsgroup!");
|
getLogger().message(sender, true, "This person isn't a part of that friendgroup!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
friends.add(p.getUniqueId().toString());
|
friends.add(p.getUniqueId().toString());
|
||||||
DataManager.setData(sender, "groups." + group, friends);
|
DataManager.setData(sender, "group." + group, friends);
|
||||||
DataManager.save(sender);
|
DataManager.save(sender);
|
||||||
|
|
||||||
getLogger().message(sender, "&e" + p.getName() + "&7 is no longer a part of the group &e" + group + "&7!");
|
getLogger().message(sender, "&e" + p.getName() + "&7 is no longer a part of the group &e" + group + "&7!");
|
||||||
|
|
||||||
if (p instanceof Player) {
|
if (p instanceof Player)
|
||||||
getLogger().message((Player) p, "&e" + Utils.getName(sender) + " &7removed you from their friendsgroup &e" + group + "&7!");
|
getLogger().message((Player) p, "&e" + Utils.getName(sender) + " &7removed you from their friendgroup &e" + group + "&7!");
|
||||||
} else {
|
else {
|
||||||
JSONArray notifications = (JSONArray) DataManager.getOrDefault(p.getUniqueId().toString(), "scheduled_notifications", new JSONArray());
|
JSONArray notifications = (JSONArray) DataManager.getOrDefault(p.getUniqueId().toString(), "scheduled_notifications", new JSONArray());
|
||||||
|
|
||||||
notifications.add("&e" + Utils.getName(sender) + " &7removed you from their friendsgroup &e" + group + "&7!");
|
notifications.add("&e" + Utils.getName(sender) + " &7removed you from their friendgroup &e" + group + "&7!");
|
||||||
notifications.remove("&e" + Utils.getName(sender) + " &7added you to their friendsgroup &e" + group + "&7!");
|
notifications.remove("&e" + Utils.getName(sender) + " &7added you to their friendgroup &e" + group + "&7!");
|
||||||
|
|
||||||
DataManager.setData(p.getUniqueId().toString(), "scheduled_notifications", notifications);
|
DataManager.setData(p.getUniqueId().toString(), "scheduled_notifications", notifications);
|
||||||
|
DataManager.save(p.getUniqueId().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -256,22 +268,28 @@ public class Friends implements CoreModule {
|
|||||||
JSONArray friends = (JSONArray) DataManager.getOrDefault(sender, "friends", new JSONArray());
|
JSONArray friends = (JSONArray) DataManager.getOrDefault(sender, "friends", new JSONArray());
|
||||||
|
|
||||||
if (friends.size() == 0) {
|
if (friends.size() == 0) {
|
||||||
getLogger().message(sender, true, "You didn't add anyone to your friends list yet.");
|
getLogger().message(sender, true, "You haven't added anyone to your friends list yet.");
|
||||||
} else {
|
return true;
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
for (Object o : friends.toArray()) {
|
|
||||||
UUID id = UUID.fromString((String) o);
|
|
||||||
Player p = Bukkit.getPlayer(id);
|
|
||||||
|
|
||||||
if (p != null) sb.append(p.getDisplayName() + "&7, ");
|
|
||||||
else sb.append("&9" + Bukkit.getOfflinePlayer(id).getName() + "&7, ");
|
|
||||||
}
|
|
||||||
|
|
||||||
String out = sb.toString().replaceAll(", $", "");
|
|
||||||
getLogger().message(sender, "You have a total of &e" + friends.size() + "&7 friends:", out);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Message msg = new Message(sender, null)
|
||||||
|
.appendText(getLogger().getHeader() + "&7You have a total of &e" + friends.size() + "&7 friends:\n");
|
||||||
|
|
||||||
|
for (int i = 0; i < friends.size(); i++) {
|
||||||
|
UUID id = UUID.fromString((String) friends.get(i));
|
||||||
|
Player p = Bukkit.getPlayer(id);
|
||||||
|
if (p != null)
|
||||||
|
msg.appendSuggestHover("&a" + p.getName(), "/msg " + p.getName() + " ", "&aONLINE\n&9"
|
||||||
|
+ p.getDisplayName() + "\n&7" + id.toString() + "\n\n&oClick to send a message.");
|
||||||
|
else {
|
||||||
|
String op = Bukkit.getOfflinePlayer(id).getName();
|
||||||
|
msg.appendSuggestHover("&c" + op, "/mail send " + op + " ", "&cOFFLINE\n&7" + id.toString() + "\n\n&oClick to send a message.");
|
||||||
|
}
|
||||||
|
if (i != friends.size() - 1)
|
||||||
|
msg.appendText("&7, ");
|
||||||
|
}
|
||||||
|
msg.send();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,43 +299,88 @@ public class Friends implements CoreModule {
|
|||||||
|
|
||||||
if (friends.size() == 0) {
|
if (friends.size() == 0) {
|
||||||
getLogger().message(sender, true, "You didn't add anyone to this group yet.");
|
getLogger().message(sender, true, "You didn't add anyone to this group yet.");
|
||||||
} else {
|
return true;
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
for (Object o : friends.toArray()) {
|
|
||||||
UUID id = UUID.fromString((String) o);
|
|
||||||
Player p = Bukkit.getPlayer(id);
|
|
||||||
|
|
||||||
if (p != null) sb.append(p.getDisplayName() + "&7, ");
|
|
||||||
else sb.append("&9" + Bukkit.getOfflinePlayer(id).getName() + "&7, ");
|
|
||||||
}
|
|
||||||
|
|
||||||
String out = sb.toString().replaceAll(", $", "");
|
|
||||||
getLogger().message(sender, "You have a total of &e" + friends.size() + "&7 friends added to this group:", out);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Message msg = new Message(sender, null)
|
||||||
|
.appendText(getLogger().getHeader() + "&7You have a total of &e" + friends.size() + "&7 friends added to this group[&e" + group + "&7]:");
|
||||||
|
|
||||||
|
for (int i = 0; i < friends.size(); i++) {
|
||||||
|
UUID id = UUID.fromString((String) friends.get(i));
|
||||||
|
Player p = Bukkit.getPlayer(id);
|
||||||
|
if (p != null)
|
||||||
|
msg.appendSuggestHover("&a" + p.getName(), "/msg " + p.getName() + " ", "&aONLINE\n&9"
|
||||||
|
+ p.getDisplayName() + "\n&7" + id.toString() + "\n\n&oClick to send a message.");
|
||||||
|
else {
|
||||||
|
String op = Bukkit.getOfflinePlayer(id).getName();
|
||||||
|
msg.appendSuggestHover("&c" + op, "/mail send " + op + " ", "&cOFFLINE\n&7" + id.toString() + "\n\n&oClick to send a message.");
|
||||||
|
}
|
||||||
|
if (i != friends.size() - 1)
|
||||||
|
msg.appendText("&7, ");
|
||||||
|
}
|
||||||
|
msg.send();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getFriendsInGroup(CommandSender sender, String group) {
|
||||||
|
JSONArray friends = (JSONArray) DataManager.getOrDefault(sender, group == null? "friends" : "group." + group, new JSONArray());
|
||||||
|
|
||||||
|
if (friends.size() == 0)
|
||||||
|
return "This group is Empty";
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
for (int i = 0; i < friends.size(); i++) {
|
||||||
|
UUID id = UUID.fromString((String) friends.get(i));
|
||||||
|
Player p = Bukkit.getPlayer(id);
|
||||||
|
if (p != null)
|
||||||
|
sb.append("&a" + p.getName());
|
||||||
|
else
|
||||||
|
sb.append("&c" + Bukkit.getOfflinePlayer(id).getName());
|
||||||
|
|
||||||
|
if (i != friends.size() - 1)
|
||||||
|
sb.append("&7, ");
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getSizeOfGroup(CommandSender sender, String group) {
|
||||||
|
return ((JSONArray) DataManager.getOrDefault(sender, group == null? "friends" : "group." + group, new JSONArray())).size();
|
||||||
|
}
|
||||||
|
|
||||||
@Command(hook = "list_groups")
|
@Command(hook = "list_groups")
|
||||||
public boolean list_groups(CommandSender sender) {
|
public boolean list_groups(CommandSender sender) {
|
||||||
JSONObject raw = (JSONObject) DataManager.getOrDefault(sender, null, new JSONObject());
|
JSONObject raw = (JSONObject) DataManager.getOrDefault(sender, null, new JSONObject());
|
||||||
Set<?> keys = raw.keySet();
|
Set<?> keys = raw.keySet();
|
||||||
|
|
||||||
if (keys.size() == 0 || (keys.contains("friends") && keys.size() == 1)) {
|
if (keys.size() == 0 || (keys.contains("friends") && keys.size() == 1)) {
|
||||||
getLogger().message(sender, true, "You don't have any custom groups made yet.");
|
getLogger().message(sender, true, "You don't haven't created any friendgroups yet.");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
for (Object o : keys) {
|
|
||||||
sb.append("&e" + ((String) o).substring(6) + "&7, ");
|
|
||||||
}
|
|
||||||
|
|
||||||
String out = sb.toString().replaceAll(", $", "");
|
|
||||||
getLogger().message(sender, "", out);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Message msg = new Message(sender, null)
|
||||||
|
.appendText(getLogger().getHeader() + "&7You have a total of &e" + keys.size() + "&7 friendgroups:\n");
|
||||||
|
|
||||||
|
if (keys.contains("friends")) {
|
||||||
|
msg.appendSendChatHover("&6friends", "/friends list",
|
||||||
|
"&7Size: " + getSizeOfGroup(sender, null) + "\n\n" + getFriendsInGroup(sender, null))
|
||||||
|
.appendText("&7, ");
|
||||||
|
keys.remove("friends");
|
||||||
|
}
|
||||||
|
|
||||||
|
Object[] keysArray= keys.toArray();
|
||||||
|
for (int i = 0; i < keysArray.length; i++) {
|
||||||
|
String group = ((String) keysArray[i]).substring(GROUP_PREFIX_LENGETH);
|
||||||
|
msg.appendSendChatHover("&e" + group, "/friends list " + group,
|
||||||
|
"&7Size: " + getSizeOfGroup(sender, group) + "\n\n" + getFriendsInGroup(sender, group));
|
||||||
|
|
||||||
|
if (i != keysArray.length - 1)
|
||||||
|
msg.appendText("&7, ");
|
||||||
|
}
|
||||||
|
|
||||||
|
msg.send();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public class List implements Module
|
|||||||
if (rank.contains("builder") || all)
|
if (rank.contains("builder") || all)
|
||||||
shownAnything |= show(sender, "&aBuilders", getPlayers(sender, "group.builder", "group.trusted"), all);
|
shownAnything |= show(sender, "&aBuilders", getPlayers(sender, "group.builder", "group.trusted"), all);
|
||||||
if (rank.contains("trusted") || all)
|
if (rank.contains("trusted") || all)
|
||||||
shownAnything |= show(sender, "&3Trusteds", getPlayers(sender, "group.trusted", "group.trainingmod"), all);
|
shownAnything |= show(sender, "&3Trusted", getPlayers(sender, "group.trusted", "group.trainingmod"), all);
|
||||||
if (rank.contains("trainingmod") || rank.contains("mit") || all)
|
if (rank.contains("trainingmod") || rank.contains("mit") || all)
|
||||||
shownAnything |= show(sender, "&cTrainingmod &e•", getPlayers(sender, "group.trainingmod", "group.mod"),
|
shownAnything |= show(sender, "&cTrainingmod &e•", getPlayers(sender, "group.trainingmod", "group.mod"),
|
||||||
all);
|
all);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import com.nemez.cmdmgr.Command;
|
|||||||
import com.redstoner.annotations.AutoRegisterListener;
|
import com.redstoner.annotations.AutoRegisterListener;
|
||||||
import com.redstoner.annotations.Commands;
|
import com.redstoner.annotations.Commands;
|
||||||
import com.redstoner.annotations.Version;
|
import com.redstoner.annotations.Version;
|
||||||
|
import com.redstoner.logging.PrivateLogManager;
|
||||||
import com.redstoner.misc.CommandHolderType;
|
import com.redstoner.misc.CommandHolderType;
|
||||||
import com.redstoner.misc.Main;
|
import com.redstoner.misc.Main;
|
||||||
import com.redstoner.misc.mysql.JSONManager;
|
import com.redstoner.misc.mysql.JSONManager;
|
||||||
@@ -36,7 +37,7 @@ import com.redstoner.modules.Module;
|
|||||||
|
|
||||||
@Commands(CommandHolderType.File)
|
@Commands(CommandHolderType.File)
|
||||||
@AutoRegisterListener
|
@AutoRegisterListener
|
||||||
@Version(major = 5, minor = 0, revision = 0, compatible = 4)
|
@Version(major = 5, minor = 1, revision = 0, compatible = 5)
|
||||||
public class LoginSecurity implements Module, Listener
|
public class LoginSecurity implements Module, Listener
|
||||||
{
|
{
|
||||||
protected static Map<UUID, Location> loggingIn;
|
protected static Map<UUID, Location> loggingIn;
|
||||||
@@ -67,6 +68,12 @@ public class LoginSecurity implements Module, Listener
|
|||||||
}
|
}
|
||||||
loggingIn = new HashMap<>();
|
loggingIn = new HashMap<>();
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new CancelledEventsHandler(this), Main.plugin);
|
Bukkit.getServer().getPluginManager().registerEvents(new CancelledEventsHandler(this), Main.plugin);
|
||||||
|
|
||||||
|
PrivateLogManager.register(this, "login", "$s issued LoginSecurity's login command");
|
||||||
|
PrivateLogManager.register(this, "register", "$s issued LoginSecurity's register command");
|
||||||
|
PrivateLogManager.register(this, "cgpass", "$s issued LoginSecurity's cgpass command");
|
||||||
|
PrivateLogManager.register(this, "rmpass", "$s issued LoginSecurity's rmpass command");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,14 +24,11 @@ import com.nemez.cmdmgr.Command;
|
|||||||
import com.redstoner.annotations.AutoRegisterListener;
|
import com.redstoner.annotations.AutoRegisterListener;
|
||||||
import com.redstoner.annotations.Commands;
|
import com.redstoner.annotations.Commands;
|
||||||
import com.redstoner.annotations.Version;
|
import com.redstoner.annotations.Version;
|
||||||
import com.redstoner.coremods.moduleLoader.ModuleLoader;
|
|
||||||
import com.redstoner.misc.CommandHolderType;
|
import com.redstoner.misc.CommandHolderType;
|
||||||
import com.redstoner.misc.JsonManager;
|
import com.redstoner.misc.JsonManager;
|
||||||
import com.redstoner.misc.Main;
|
import com.redstoner.misc.Main;
|
||||||
import com.redstoner.misc.Utils;
|
|
||||||
import com.redstoner.modules.Module;
|
import com.redstoner.modules.Module;
|
||||||
import com.redstoner.modules.datamanager.DataManager;
|
import com.redstoner.modules.datamanager.DataManager;
|
||||||
import com.redstoner.modules.ignore.Ignore;
|
|
||||||
|
|
||||||
import net.nemez.chatapi.ChatAPI;
|
import net.nemez.chatapi.ChatAPI;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import java.util.UUID;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
//import org.bukkit.entity.Player;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
import net.nemez.chatapi.ChatAPI;
|
import net.nemez.chatapi.ChatAPI;
|
||||||
@@ -162,17 +162,17 @@ public class Msg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String getPrefix(Player player)
|
// private String getPrefix(Player player)
|
||||||
{
|
// {
|
||||||
String[] teams = new String[] {"admin", "mod", "trainingmod", "helper", "trusted", "builder", "member", "visitor"};
|
// String[] teams = new String[] {"admin", "mod", "trainingmod", "helper", "trusted", "builder", "member", "visitor"};
|
||||||
String[] prefixes = new String[] {"&4", "&c", "&c", "&9", "&3", "&a", "&f", "&7"};
|
// String[] prefixes = new String[] {"&4", "&c", "&c", "&9", "&3", "&a", "&f", "&7"};
|
||||||
|
//
|
||||||
for (int i = 0; i < teams.length; i++)
|
// for (int i = 0; i < teams.length; i++)
|
||||||
if (player.hasPermission("group." + teams[i]))
|
// if (player.hasPermission("group." + teams[i]))
|
||||||
return prefixes[i];
|
// return prefixes[i];
|
||||||
return "&7";
|
// return "&7";
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public JSONObject toJSONObject() {
|
public JSONObject toJSONObject() {
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package com.redstoner.modules.naming;
|
package com.redstoner.modules.naming;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -18,23 +21,19 @@ import com.redstoner.modules.Module;
|
|||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
@Commands(CommandHolderType.File)
|
@Commands(CommandHolderType.File)
|
||||||
@Version(major = 5, minor = 2, revision = 0, compatible = 4)
|
@Version(major = 5, minor = 3, revision = 0, compatible = 4)
|
||||||
public class Naming implements Module
|
public class Naming implements Module
|
||||||
{
|
{
|
||||||
|
private final Pattern COLOR_CHECK = Pattern.compile(".*&[\\da-fk-or].*");
|
||||||
|
private final ItemStack[] COST = new ItemStack[] {new ItemStack(Material.IRON_INGOT, 1)};
|
||||||
|
|
||||||
@Command(hook = "name")
|
@Command(hook = "name")
|
||||||
public void name(CommandSender sender, String name)
|
public void name(CommandSender sender, String name)
|
||||||
{
|
{
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
if (player.getGameMode() == GameMode.SURVIVAL) {
|
if (player.getGameMode() == GameMode.SURVIVAL && !processSurvivalPlayer(player, name, "rename the item"))
|
||||||
int level = player.getLevel();
|
return;
|
||||||
if (level < 1) {
|
|
||||||
getLogger().message(sender, true, "You don't have enough levels to rename the item.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
player.setLevel(level-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
name = ChatColor.translateAlternateColorCodes('&', name);
|
name = ChatColor.translateAlternateColorCodes('&', name);
|
||||||
ItemStack item = player.getInventory().getItemInMainHand();
|
ItemStack item = player.getInventory().getItemInMainHand();
|
||||||
@@ -55,15 +54,8 @@ public class Naming implements Module
|
|||||||
{
|
{
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
if (player.getGameMode() == GameMode.SURVIVAL) {
|
if (player.getGameMode() == GameMode.SURVIVAL && !processSurvivalPlayer(player, lore, append? "append to the lore" : "add lore to the item"))
|
||||||
int level = player.getLevel();
|
return;
|
||||||
if (level < 1) {
|
|
||||||
getLogger().message(sender, true, "You don't have enough levels to rename the item.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
player.setLevel(level-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack item = player.getInventory().getItemInMainHand();
|
ItemStack item = player.getInventory().getItemInMainHand();
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
@@ -89,4 +81,25 @@ public class Naming implements Module
|
|||||||
getLogger().message(sender, "Lore set to &5&o" + lore + "&7.");
|
getLogger().message(sender, "Lore set to &5&o" + lore + "&7.");
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean processSurvivalPlayer(Player player, String str, String operation) {
|
||||||
|
|
||||||
|
int levelsNeeded = COLOR_CHECK.matcher(str).matches()? 2 : 1;
|
||||||
|
int levels = player.getLevel();
|
||||||
|
|
||||||
|
if (levels < levelsNeeded) {
|
||||||
|
getLogger().message(player, true, "You don't have enough levels. " + (levelsNeeded == 1?
|
||||||
|
"You need &e1&7 level to " + operation + "." :
|
||||||
|
"You need &e2&7 levels to " + operation + " with color/formatting."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
HashMap<Integer, ItemStack> result = player.getInventory().removeItem(COST);
|
||||||
|
if (result.size() > 0) {
|
||||||
|
getLogger().message(player, true, "You don't have enough resources. You need &e1&7 iron ingot to " + operation + ".");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
player.setLevel(levels - levelsNeeded);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,11 @@ command lol {
|
|||||||
run matchlol -i regex;
|
run matchlol -i regex;
|
||||||
perm utils.lol.match;
|
perm utils.lol.match;
|
||||||
}
|
}
|
||||||
|
page [int:num] {
|
||||||
|
help Shows you page <num>. Used in /lol search, /lol match, and /lol list.;
|
||||||
|
run page num;
|
||||||
|
perm utils.lol.page;
|
||||||
|
}
|
||||||
[empty] {
|
[empty] {
|
||||||
help Lols.;
|
help Lols.;
|
||||||
run saylol;
|
run saylol;
|
||||||
|
|||||||
@@ -1,14 +1,22 @@
|
|||||||
package com.redstoner.modules.saylol;
|
package com.redstoner.modules.saylol;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.json.simple.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
|
|
||||||
import com.nemez.cmdmgr.Command;
|
import com.nemez.cmdmgr.Command;
|
||||||
|
import com.redstoner.annotations.AutoRegisterListener;
|
||||||
import com.redstoner.annotations.Commands;
|
import com.redstoner.annotations.Commands;
|
||||||
import com.redstoner.annotations.Version;
|
import com.redstoner.annotations.Version;
|
||||||
import com.redstoner.coremods.moduleLoader.ModuleLoader;
|
import com.redstoner.coremods.moduleLoader.ModuleLoader;
|
||||||
@@ -24,14 +32,17 @@ import net.nemez.chatapi.ChatAPI;
|
|||||||
import net.nemez.chatapi.click.ClickCallback;
|
import net.nemez.chatapi.click.ClickCallback;
|
||||||
import net.nemez.chatapi.click.Message;
|
import net.nemez.chatapi.click.Message;
|
||||||
|
|
||||||
|
@AutoRegisterListener
|
||||||
@Commands(CommandHolderType.File)
|
@Commands(CommandHolderType.File)
|
||||||
@Version(major = 5, minor = 0, revision = 1, compatible = 4)
|
@Version(major = 5, minor = 1, revision = 0, compatible = 4)
|
||||||
public class Saylol implements Module
|
public class Saylol implements Module
|
||||||
{
|
{
|
||||||
private long lastLol = 0;
|
private long lastLol = 0;
|
||||||
private File lolLocation = new File(Main.plugin.getDataFolder(), "lol.json");
|
private File lolLocation = new File(Main.plugin.getDataFolder(), "lol.json");
|
||||||
private JSONArray lols, handlers;
|
private JSONArray lols, handlers;
|
||||||
private final String LOL_PREFIX = "§8[§blol§8] ";
|
private final String LOL_PREFIX = "§8[§blol§8] ";
|
||||||
|
private Map<CommandSender, List<Integer>> searchCache = new HashMap<>();
|
||||||
|
private final int PAGE_SIZE = 10;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
@@ -84,6 +95,7 @@ public class Saylol implements Module
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
saveLols();
|
saveLols();
|
||||||
|
searchCache.clear();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -104,6 +116,7 @@ public class Saylol implements Module
|
|||||||
getLogger().message(sender, "Successfully deleted the lol: " + lols.remove(id));
|
getLogger().message(sender, "Successfully deleted the lol: " + lols.remove(id));
|
||||||
handlers.remove(id);
|
handlers.remove(id);
|
||||||
saveLols();
|
saveLols();
|
||||||
|
searchCache.clear();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,6 +137,7 @@ public class Saylol implements Module
|
|||||||
getLogger().message(sender, "Successfully changed the lol: &e" + lols.get(id) + " &7to: &e" + text);
|
getLogger().message(sender, "Successfully changed the lol: &e" + lols.get(id) + " &7to: &e" + text);
|
||||||
lols.set(id, text);
|
lols.set(id, text);
|
||||||
saveLols();
|
saveLols();
|
||||||
|
searchCache.clear();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,18 +209,20 @@ public class Saylol implements Module
|
|||||||
@Command(hook = "listlols")
|
@Command(hook = "listlols")
|
||||||
public boolean listLols(CommandSender sender, int page)
|
public boolean listLols(CommandSender sender, int page)
|
||||||
{
|
{
|
||||||
|
searchCache.put(sender, Arrays.asList(-1));
|
||||||
|
|
||||||
if (lols.size() == 0)
|
if (lols.size() == 0)
|
||||||
{
|
{
|
||||||
getLogger().message(sender, true, "There are no lols yet!");
|
getLogger().message(sender, true, "There are no lols yet!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
page = page - 1;
|
page = page - 1;
|
||||||
int start = page * 10;
|
int start = page * PAGE_SIZE;
|
||||||
int end = start + 10;
|
int end = start + PAGE_SIZE;
|
||||||
int pages = (int) Math.ceil(lols.size() / 10d);
|
int pages = getMaxPage(lols.size());
|
||||||
if (start < 0)
|
if (start < 0)
|
||||||
{
|
{
|
||||||
getLogger().message(sender, true, "Page number too small, must be at least 0!");
|
getLogger().message(sender, true, "Page number too small, must be at least 1!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (start > lols.size())
|
if (start > lols.size())
|
||||||
@@ -216,7 +232,7 @@ public class Saylol implements Module
|
|||||||
}
|
}
|
||||||
Message m = new Message(sender, null);
|
Message m = new Message(sender, null);
|
||||||
m.appendText(getLogger().getHeader().replace("\n", ""));
|
m.appendText(getLogger().getHeader().replace("\n", ""));
|
||||||
m.appendText("&ePage " + (page + 1) + "/" + pages + ":");
|
m.appendText(" &ePage " + (page + 1) + "/" + pages + ":");
|
||||||
for (int i = start; i < end && i < lols.size(); i++)
|
for (int i = start; i < end && i < lols.size(); i++)
|
||||||
m.appendCallback("\n&a" + i + "&8: &e" + lols.get(i), getCallback(i));
|
m.appendCallback("\n&a" + i + "&8: &e" + lols.get(i), getCallback(i));
|
||||||
m.send();
|
m.send();
|
||||||
@@ -232,51 +248,116 @@ public class Saylol implements Module
|
|||||||
@Command(hook = "searchlol")
|
@Command(hook = "searchlol")
|
||||||
public boolean search(CommandSender sender, boolean sensitive, String text)
|
public boolean search(CommandSender sender, boolean sensitive, String text)
|
||||||
{
|
{
|
||||||
Message m = new Message(sender, null);
|
searchCache.remove(sender);
|
||||||
m.appendText(getLogger().getHeader().replace("\n", ""));
|
|
||||||
boolean found = false;
|
List<Integer> results = new ArrayList<>();
|
||||||
|
|
||||||
if (!sensitive)
|
if (!sensitive)
|
||||||
text = text.toLowerCase();
|
text = text.toLowerCase();
|
||||||
for (int i = 0; i < lols.size(); i++)
|
for (int i = 0; i < lols.size(); i++)
|
||||||
{
|
{
|
||||||
String lol = (String) lols.get(i);
|
String lol = (String) lols.get(i);
|
||||||
if ((sensitive ? lol : lol.toLowerCase()).contains(text))
|
if ((sensitive ? lol : lol.toLowerCase()).contains(text))
|
||||||
{
|
results.add(i);
|
||||||
m.appendCallback("\n&a" + i + "&8: &e" + lol, getCallback(i));
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!found)
|
if (results.isEmpty()) {
|
||||||
getLogger().message(sender, "&cCouldn't find any matching lols.");
|
getLogger().message(sender, "&cCouldn't find any matching lols.");
|
||||||
else
|
return true;
|
||||||
m.send();
|
}
|
||||||
|
|
||||||
|
searchCache.put(sender, results);
|
||||||
|
|
||||||
|
Message m = new Message(sender, null);
|
||||||
|
m.appendText(getLogger().getHeader().replace("\n", ""));
|
||||||
|
|
||||||
|
int size = results.size();
|
||||||
|
if (size > PAGE_SIZE)
|
||||||
|
m.appendText(" &ePage 1/" + getMaxPage(size) + ":");
|
||||||
|
|
||||||
|
for (int i = 0; i < size && i < PAGE_SIZE; i++)
|
||||||
|
m.appendCallback("\n&a" + i + "&8: &e" + lols.get(results.get(i)), getCallback(i));
|
||||||
|
|
||||||
|
m.appendText("\n&7Use /lol page <number> to look at other pages.");
|
||||||
|
m.send();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(hook = "matchlol")
|
@Command(hook = "matchlol")
|
||||||
public boolean match(CommandSender sender, boolean sensitive, String regex)
|
public boolean match(CommandSender sender, boolean sensitive, String regex)
|
||||||
{
|
{
|
||||||
Message m = new Message(sender, null);
|
|
||||||
m.appendText(getLogger().getHeader().replace("\n", ""));
|
searchCache.remove(sender);
|
||||||
boolean found = false;
|
|
||||||
|
List<Integer> results = new ArrayList<>();
|
||||||
|
|
||||||
if (!sensitive)
|
if (!sensitive)
|
||||||
regex = regex.toLowerCase();
|
regex = regex.toLowerCase();
|
||||||
for (int i = 0; i < lols.size(); i++)
|
for (int i = 0; i < lols.size(); i++)
|
||||||
{
|
{
|
||||||
String lol = (String) lols.get(i);
|
String lol = (String) lols.get(i);
|
||||||
if ((sensitive ? lol : lol.toLowerCase()).matches(regex))
|
if ((sensitive ? lol : lol.toLowerCase()).matches(regex))
|
||||||
{
|
results.add(i);
|
||||||
m.appendCallback("\n&a" + i + "&8: &e" + lol, getCallback(i));
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!found)
|
if (results.isEmpty()) {
|
||||||
getLogger().message(sender, "&cCouldn't find any matching lols.");
|
getLogger().message(sender, "&cCouldn't find any matching lols.");
|
||||||
else
|
return true;
|
||||||
m.send();
|
}
|
||||||
|
|
||||||
|
searchCache.put(sender, results);
|
||||||
|
|
||||||
|
Message m = new Message(sender, null);
|
||||||
|
m.appendText(getLogger().getHeader().replace("\n", ""));
|
||||||
|
|
||||||
|
int size = results.size();
|
||||||
|
if (size > PAGE_SIZE)
|
||||||
|
m.appendText(" &ePage 1/" + getMaxPage(size) + ":");
|
||||||
|
|
||||||
|
for (int i = 0; i < size && i < PAGE_SIZE; i++)
|
||||||
|
m.appendCallback("\n&a" + i + "&8: &e" + lols.get(i), getCallback(i));
|
||||||
|
|
||||||
|
m.appendText("\n&7Use /lol page <number> to look at other pages.");
|
||||||
|
m.send();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(hook = "page")
|
||||||
|
public boolean page(CommandSender sender, int page) {
|
||||||
|
List<Integer> results = searchCache.get(sender);
|
||||||
|
|
||||||
|
if (results == null || results.size() == 0) {
|
||||||
|
getLogger().message(sender, true, "There's nothing to page through. Either you haven't"
|
||||||
|
+ " done a relivent command, or the lols have changed since you have.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int pages = getMaxPage(results.size());
|
||||||
|
|
||||||
|
if (results.get(0) == -1)
|
||||||
|
listLols(sender, page);
|
||||||
|
else if (page < 1 || page > pages)
|
||||||
|
getLogger().message(sender, true, "Page number not on range. Must be between &e1&7 and &e" + pages + "&7.");
|
||||||
|
else {
|
||||||
|
Message m = new Message(sender, null);
|
||||||
|
m.appendText(getLogger().getHeader().replace("\n", " &ePage " + page + "/" + pages + ":"));
|
||||||
|
|
||||||
|
for (int i = page*PAGE_SIZE-PAGE_SIZE; i < page*PAGE_SIZE; i++)
|
||||||
|
m.appendCallback("\n&a" + i + "&8: &e" + lols.get(i), getCallback(i));
|
||||||
|
|
||||||
|
m.send();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onLeave(PlayerQuitEvent e) {
|
||||||
|
searchCache.remove(e.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxPage(int size) {
|
||||||
|
return (int) Math.ceil(size / (double) PAGE_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
public void saveLols()
|
public void saveLols()
|
||||||
{
|
{
|
||||||
JsonManager.save(lols, lolLocation);
|
JsonManager.save(lols, lolLocation);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import net.nemez.chatapi.ChatAPI;
|
|||||||
|
|
||||||
@Commands(CommandHolderType.File)
|
@Commands(CommandHolderType.File)
|
||||||
@AutoRegisterListener
|
@AutoRegisterListener
|
||||||
@Version(major = 5, minor = 0, revision = 2, compatible = 4)
|
@Version(major = 5, minor = 0, revision = 3, compatible = 4)
|
||||||
public class Teleport implements Module, Listener
|
public class Teleport implements Module, Listener
|
||||||
{
|
{
|
||||||
public static final String PERMISSION_TELEPORT = "utils.teleport.tp";
|
public static final String PERMISSION_TELEPORT = "utils.teleport.tp";
|
||||||
@@ -80,9 +80,15 @@ public class Teleport implements Module, Listener
|
|||||||
|
|
||||||
@Command(hook = "tp2")
|
@Command(hook = "tp2")
|
||||||
public void teleport(CommandSender sender, String player, String player2) {
|
public void teleport(CommandSender sender, String player, String player2) {
|
||||||
if (!sender.hasPermission(PERMISSION_TELEPORT)
|
if (!sender.hasPermission(PERMISSION_TELEPORT)) {
|
||||||
&& sender.getName().equalsIgnoreCase(player2)) {
|
if (sender.getName().equalsIgnoreCase(player)) {
|
||||||
tpahere(sender, player);
|
tpa(sender, player);
|
||||||
|
} else if (sender.getName().equalsIgnoreCase(player2)) {
|
||||||
|
tpahere(sender, player);
|
||||||
|
} else {
|
||||||
|
getLogger().message(sender, true, "You do not have the permission to teleport other players.");
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user