Development milestone 1 - it builds and runs

This commit is contained in:
NotAlexNoyle committed 2023-02-07 03:43:10 -05:00
1 parent 28f08d1871
commit 704ceb8857
60 files changed
+2773 -2250

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf
+6
View File
@@ -39,3 +39,9 @@ dependency-reduced-pom.xml
# Testfiles
test.sh
/bin/
# Ignore Gradle project-specific cache directory
.gradle
# Ignore Gradle build output directory
build
+17 -5
View File
@@ -1,9 +1,21 @@
# Splegg #
# Splegg-OG
Splegg plugin originally made by MrLuangamer, updated for worldedit 7.2 and spigot 1.16.4 by Hraponssi
![Icon](https://raw.githubusercontent.com/NotAlexNoyle/Splegg-OG/master/assets/splegg-logo.png)
Dependencies: worldedit, vault economy
Splegg plugin originally made by MrLuangamer, updated for worldedit 7.2 and spigot 1.16.4 by Hraponssi, updated for purpur 1.18.2 and TrueOG.net by NotAlexNoyle.
I've dropped out the BarAPI support since it is also a dead plugin and would need an NMS update for 1.16.4
Dependencies: WorldEdit, Vault-based Economy.
Original bukkit page: https://dev.bukkit.org/projects/splegg-minigame
Does NOT support the outdated BarAPI.
Original bukkit page: https://dev.bukkit.org/projects/splegg-minigame
Current Target: Purpur 1.18.2
To build:
`./gradlew build`
The resulting .jar file will be in build/libs/
**Licensed under the GPLv3.**
Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

+93
View File
@@ -0,0 +1,93 @@
plugins {
id "java" // Tell gradle this is a java project.
id "com.github.johnrengelman.shadow" version "7.1.2" // Import utility to package libraries into .jar file.
}
group = "net.trueog.splegg-og"
version = "1.0"
def apiVersion = "1.18.2" // Declare minecraft server target version.
def targetJavaVersion = 17 // Declare java compatibility minimum.
apply plugin: "eclipse" // Enable integration with Eclipse IDE for development.
processResources {
def props = [
version: version,
apiVersion: apiVersion,
]
inputs.properties props // Indicates to rerun if version changes.
filesMatching("plugin.yml") {
expand props
}
}
repositories {
mavenCentral()
maven {
url "https://repo.purpurmc.org/snapshots" // Get purpur API from purpur maven repository.
}
maven {
url "https://jitpack.io" // Get Vault API from jitpack repository.
}
maven {
url "https://maven.enginehub.org/repo" // Get WorldEdit API from enginehub repository.
}
}
dependencies {
compileOnly "org.purpurmc.purpur:purpur-api:1.18.2-R0.1-SNAPSHOT" // Declare purpur API version to be packaged.
compileOnly "com.github.MilkBowl:VaultAPI:1.7" // Declare Vault API to be packaged.
compileOnly "com.sk89q.worldedit:worldedit-bukkit:7.3.0-SNAPSHOT" // Declare WorldEdit API to be packaged.
}
shadowJar {
minimize()
}
jar.dependsOn shadowJar
tasks.jar.configure {
classifier = "part"
}
tasks.shadowJar.configure {
classifier = null
}
compileJava {
options.compilerArgs += ["-parameters"]
options.fork = true
options.forkOptions.executable = 'javac'
}
Binary file not shown.
+5
View File
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored Executable
+234
View File
@@ -0,0 +1,234 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
APP_BASE_NAME=${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='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# 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 ;; #(
MSYS* | 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" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
Vendored
+89
View File
@@ -0,0 +1,89 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@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 Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@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="-Xmx64m" "-Xms64m"
@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 execute
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 execute
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
: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 %*
: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
-8
View File
@@ -1,8 +0,0 @@
name: Splegg
main: me.mrluangamer.Splegg
version: 1.3
author: Hraponssi, MrLuangamer, > Theluangamer9416
api-version: 1.16
depend: [Vault, WorldEdit]
commands:
splegg:
+10
View File
@@ -0,0 +1,10 @@
/*
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user manual at https://docs.gradle.org/7.4.2/userguide/multi_project_builds.html
*/
rootProject.name = 'Splegg-OG'
+280
View File
@@ -0,0 +1,280 @@
package commands;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.regions.Region;
import config.Map;
import main.SpleggOG;
import managers.Game;
import managers.Status;
import utils.UtilPlayer;
public class SpleggCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String tag, String[] args) {
if (sender instanceof Player) {
Player player = (Player)sender;
UtilPlayer u = SpleggOG.getPlugin().pm.getPlayer(player);
if (args.length == 0) {
SpleggOG.getPlugin().chat.sendMessage(player, "Plugin created by MrLuangamer, > Theluangamer9416 for more information /splegg help");
} else if (args.length == 1) {
if (args[0].equalsIgnoreCase("join")) {
if (player.hasPermission("splegg.join")) {
if (u.getGame() != null && u.isAlive()) {
SpleggOG.getPlugin().chat.sendMessage(player, "&cYou are already playing.");
} else if (this.lobbyset()) {
player.teleport(SpleggOG.getPlugin().config.getLobby());
} else {
SpleggOG.getPlugin().chat.sendMessage(player, "&cSplegg is incorrectly setup! Ask an admin to set the lobby.");
}
} else {
SpleggOG.getPlugin().chat.sendMessage(player, "&cYou do not have permission.");
}
} else if (args[0].equalsIgnoreCase("leave")) {
if (u.getGame() != null && u.isAlive()) {
Game game = u.getGame();
game.leaveGame(u);
SpleggOG.getPlugin().chat.sendMessage(player, SpleggOG.getPlugin().getConfig().getString("Messages.LeaveGame").replaceAll("&", "�").replaceAll("%map%", game.getMap().getName()));
}
} else if (args[0].equalsIgnoreCase("start")) {
if (player.hasPermission("splegg.admin")) {
if (u.getGame() == null) {
SpleggOG.getPlugin().chat.sendMessage(player, "&cYou are not in a game.");
} else if (u.getGame().getStatus() == Status.LOBBY) {
SpleggOG.getPlugin().game.startGame(u.getGame());
SpleggOG.getPlugin().chat.sendMessage(player, "&eGame started!");
} else if (u.getGame().getStatus() == Status.INGAME) {
SpleggOG.getPlugin().chat.sendMessage(player, "�cGame has already begun.");
}
} else {
SpleggOG.getPlugin().chat.sendMessage(player, "&cYou do not have permission.");
}
} else if (args[0].equalsIgnoreCase("stop")) {
if (player.hasPermission("splegg.admin")) {
if (u.getGame() == null) {
SpleggOG.getPlugin().chat.sendMessage(player, "&cYou are not in a game.");
} else if (u.getGame().getStatus() == Status.LOBBY) {
SpleggOG.getPlugin().chat.sendMessage(player, "&cGame has not begun yet!");
} else if (u.getGame().getStatus() == Status.INGAME) {
SpleggOG.getPlugin().chat.bc("&5" + player.getName() + "&6 has stopped the game.", u.getGame());
SpleggOG.getPlugin().game.stopGame(u.getGame(), 1);
SpleggOG.getPlugin().chat.sendMessage(player, "�eYou have stopped the game.");
}
} else {
SpleggOG.getPlugin().chat.sendMessage(player, "&cYou do not have permission.");
}
} else if (args[0].equalsIgnoreCase("setlobby")) {
if (player.hasPermission("splegg.admin")) {
SpleggOG.getPlugin().config.setLobby(player.getLocation());
SpleggOG.getPlugin().chat.sendMessage(player, "You have set splegg lobby.");
} else {
SpleggOG.getPlugin().chat.sendMessage(player, "&cYou do not have permission.");
}
} else if (!args[0].equalsIgnoreCase("")) {
SpleggOG.getPlugin().chat.sendMessage(player, "&cIncorrect Usage: &6/" + tag + " <join,leave,stop,start,setlobby,help>");
}
} else {
Map map;
String name;
if (args.length == 2) {
if (args[0].equalsIgnoreCase("create")) {
if (player.hasPermission("splegg.admin")) {
name = args[1];
if (SpleggOG.getPlugin().maps.mapExists(name)) {
SpleggOG.getPlugin().chat.sendMessage(player, "Map already exists.");
} else {
SpleggOG.getPlugin().maps.c.addMap(name);
SpleggOG.getPlugin().maps.addMap(name);
map = SpleggOG.getPlugin().maps.getMap(name);
Game game = new Game(SpleggOG.getPlugin(), map);
SpleggOG.getPlugin().games.addGame(map.getName(), game);
if (!map.isUsable()) {
game.setStatus(Status.DISABLED);
}
SpleggOG.getPlugin().chat.sendMessage(player, "Map has been added and created &c" + name + "&6.");
}
} else {
SpleggOG.getPlugin().chat.sendMessage(player, "&cYou do not have permission.");
}
} else if (args[0].equalsIgnoreCase("delete")) {
if (player.hasPermission("splegg.admin")) {
name = args[1];
if (SpleggOG.getPlugin().maps.mapExists(name)) {
SpleggOG.getPlugin().maps.deleteMap(name);
SpleggOG.getPlugin().chat.sendMessage(player, "Map has been deleted.");
} else {
SpleggOG.getPlugin().chat.sendMessage(player, "&cMap does not exist.");
}
} else {
SpleggOG.getPlugin().chat.sendMessage(player, "&cYou do not have permission.");
}
} else {
Game game;
if (args[0].equalsIgnoreCase("start")) {
if (player.hasPermission("splegg.admin")) {
name = args[1];
if (SpleggOG.getPlugin().maps.mapExists(name)) {
game = SpleggOG.getPlugin().games.getGame(name);
if (game == null) {
SpleggOG.getPlugin().chat.sendMessage(player, "&cYou are not in a game.");
} else if (game.getStatus() == Status.LOBBY) {
SpleggOG.getPlugin().game.startGame(game);
SpleggOG.getPlugin().chat.sendMessage(player, "&eStarting " + name + ".");
} else if (game.getStatus() == Status.INGAME) {
SpleggOG.getPlugin().chat.sendMessage(player, "�cGame has already begun.");
}
} else {
SpleggOG.getPlugin().chat.sendMessage(player, "&cMap does not exist.");
}
} else {
SpleggOG.getPlugin().chat.sendMessage(player, "&cYou do not have permission.");
}
} else if (args[0].equalsIgnoreCase("stop")) {
if (player.hasPermission("splegg.admin")) {
name = args[1];
if (SpleggOG.getPlugin().maps.mapExists(name)) {
game = SpleggOG.getPlugin().games.getGame(name);
if (game == null) {
SpleggOG.getPlugin().chat.sendMessage(player, "&cYou are not in a game.");
} else if (game.getStatus() == Status.LOBBY) {
SpleggOG.getPlugin().chat.sendMessage(player, "&cGame has not begun yet!");
} else if (game.getStatus() == Status.INGAME) {
SpleggOG.getPlugin().chat.bc("&5" + player.getName() + "&6 has stopped the game.", game);
SpleggOG.getPlugin().game.stopGame(game, 1);
SpleggOG.getPlugin().chat.sendMessage(player, "�eYou have stopped the game.");
}
} else {
SpleggOG.getPlugin().chat.sendMessage(player, "&cMap does not exist.");
}
} else {
SpleggOG.getPlugin().chat.sendMessage(player, "&cYou do not have permission.");
}
} else if (args[0].equalsIgnoreCase("setlobby")) {
if (player.hasPermission("splegg.admin")) {
name = args[1];
if (SpleggOG.getPlugin().maps.mapExists(name)) {
SpleggOG.getPlugin().maps.getMap(name).setLobby(player.getLocation());
SpleggOG.getPlugin().chat.sendMessage(player, "Lobby for map &e" + name + "&6 set.");
} else {
SpleggOG.getPlugin().chat.sendMessage(player, "&cMap does not exist.");
}
} else {
SpleggOG.getPlugin().chat.sendMessage(player, "&cYou do not have permission.");
}
} else if (args[0].equalsIgnoreCase("addfloor")) {
if (player.hasPermission("splegg.admin")) {
name = args[1];
if (SpleggOG.getPlugin().maps.mapExists(name)) {
map = SpleggOG.getPlugin().maps.getMap(name);
WorldEditPlugin we = SpleggOG.getPlugin().getWorldEdit();
Region sel = null;
try {
sel = we.getSession(player).getSelection(new BukkitWorld(player.getWorld()));
} catch (IncompleteRegionException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
}
if (sel == null) {
SpleggOG.getPlugin().chat.sendMessage(player, "&5Please select an area with worldedit.");
} else {
map.addFloor(new Location(player.getWorld(), sel.getMinimumPoint().getBlockX(), sel.getMinimumPoint().getBlockY(), sel.getMinimumPoint().getBlockZ()), new Location(player.getWorld(), sel.getMaximumPoint().getBlockX(), sel.getMaximumPoint().getBlockY(), sel.getMaximumPoint().getBlockZ()));
SpleggOG.getPlugin().chat.sendMessage(player, "Floor " + map.getFloors() + " added to map " + map.getName() + ".");
}
} else {
SpleggOG.getPlugin().chat.sendMessage(player, "&cMap does not exist.");
}
} else {
SpleggOG.getPlugin().chat.sendMessage(player, "&cYou do not have permission.");
}
} else if (args[0].equalsIgnoreCase("join")) {
if (player.hasPermission("splegg.join")) {
if (u.getGame() != null && u.isAlive()) {
SpleggOG.getPlugin().chat.sendMessage(player, "&cYou are already playing.");
} else {
name = args[1];
if (SpleggOG.getPlugin().maps.mapExists(name)) {
game = SpleggOG.getPlugin().games.getGame(name);
if (game != null && SpleggOG.getPlugin().maps.getMap(name).isUsable()) {
game.joinGame(u);
} else {
SpleggOG.getPlugin().chat.sendMessage(player, "This map is incorrectly setup - See console for detailed output.");
}
} else {
SpleggOG.getPlugin().chat.sendMessage(player, "&cMap does not exist.");
}
}
} else {
SpleggOG.getPlugin().chat.sendMessage(player, "&cYou do not have permission.");
}
} else if (args[0].equalsIgnoreCase("leave")) {
SpleggOG.getPlugin().chat.sendMessage(player, "Please use &e/" + tag + " leave");
} else if (args[0].equalsIgnoreCase("") && !args[1].equalsIgnoreCase("") && !args[1].equalsIgnoreCase("") && !args[1].equalsIgnoreCase("")) {
SpleggOG.getPlugin().chat.sendMessage(player, "Usage: /" + tag + " help <player|mod|admin>");
}
}
} else if (args.length == 3) {
if (args[0].equalsIgnoreCase("setspawn")) {
if (player.hasPermission("splegg.admin")) {
name = args[1];
if (SpleggOG.getPlugin().maps.mapExists(name)) {
map = SpleggOG.getPlugin().maps.getMap(name);
if (args[2].equalsIgnoreCase("next")) {
map.addSpawn(player.getLocation());
SpleggOG.getPlugin().chat.sendMessage(player, "Spawn &a" + map.getSpawnCount() + "&6 set for map &c" + map.getName() + "&6.");
} else {
try {
int id = Integer.parseInt(args[2]);
if (this.spawnset(id, map)) {
map.setSpawn(id, player.getLocation());
SpleggOG.getPlugin().chat.sendMessage(player, "You have re-set the spawn " + id + " for map " + name + ".");
} else {
SpleggOG.getPlugin().chat.sendMessage(player, "Please set the spawn using &e/" + tag + " setspawn <mapname> next &6then try this command again.");
}
} catch (NumberFormatException var11) {
SpleggOG.getPlugin().chat.sendMessage(player, "&cPlease type a number.");
}
}
} else {
SpleggOG.getPlugin().chat.sendMessage(player, "&cMap does not exist!");
}
} else {
SpleggOG.getPlugin().chat.sendMessage(player, "&cYou do not have permission.");
}
} else {
SpleggOG.getPlugin().chat.sendMessage(player, "Usage: &a/" + tag + " setspawn <mapname> <next|spawnid>");
}
} else {
SpleggOG.getPlugin().chat.sendMessage(player, "Incorrect Usage!");
}
}
}
return false;
}
boolean lobbyset() {
try {
SpleggOG.getPlugin().config.getLobby();
return true;
} catch (Exception var2) {
return false;
}
}
boolean spawnset(int i, Map map) {
return map.getConfig().isString("Spawns." + i + ".world");
}
public void sendUsage(Player player, String tag, String usage, String def) {
SpleggOG.getPlugin().chat.sendMessage(player, "&c/" + tag + " &d" + usage + " &5- &b" + def);
}
}
+237
View File
@@ -0,0 +1,237 @@
package config;
import java.io.File;
import java.io.IOException;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import main.SpleggOG;
public class Map {
SpleggOG splegg;
String name;
File file;
private FileConfiguration config;
int spawncount;
int floorcount;
boolean usable;
public Map(SpleggOG plugin, String name) {
this.splegg = plugin;
this.name = name;
this.floorcount = 0;
this.spawncount = 0;
}
public void load() {
this.splegg.chat.log("Loading map " + this.name + ".");
this.usable = false;
this.file = new File(this.splegg.getDataFolder(), this.name + ".yml");
try {
if (!this.file.exists()) {
this.file.createNewFile();
}
} catch (IOException var2) {
}
this.setConfig(YamlConfiguration.loadConfiguration(this.file));
this.save();
this.loadSpawns();
this.loadFloors();
if (this.spawncount > 0) {
this.usable = true;
} else {
this.splegg.chat.log("Spawn count is 0");
this.usable = false;
}
if (this.floorcount > 0) {
this.usable = true;
} else {
this.splegg.chat.log("No floors are setup.");
this.usable = false;
}
if (this.usable) {
this.splegg.chat.log("Map is usable");
} else {
this.splegg.chat.log("--<>-- PLEASE SETUP MAP!! --<>--");
}
this.splegg.chat.log("Load Complete!");
}
public boolean isUsable() {
return this.usable;
}
public void delete() {
this.file.delete();
}
public void savenumbers() {
this.getConfig().set("Spawns.count", this.spawncount);
this.getConfig().set("Floors.count", this.floorcount);
}
public void save() {
try {
this.getConfig().save(this.file);
} catch (IOException var2) {
var2.printStackTrace();
}
}
public void setSpawn(int id, Location l) {
int x = l.getBlockX();
int y = l.getBlockY();
int z = l.getBlockZ();
float pitch = l.getPitch();
float yaw = l.getYaw();
String worldname = l.getWorld().getName();
this.getConfig().set("Spawns." + id + ".world", worldname);
this.getConfig().set("Spawns." + id + ".x", x);
this.getConfig().set("Spawns." + id + ".y", y);
this.getConfig().set("Spawns." + id + ".z", z);
this.getConfig().set("Spawns." + id + ".pitch", pitch);
this.getConfig().set("Spawns." + id + ".yaw", yaw);
this.save();
}
public Location getSpawn(int id) {
int x = this.getConfig().getInt("Spawns." + id + ".x");
int y = this.getConfig().getInt("Spawns." + id + ".y");
int z = this.getConfig().getInt("Spawns." + id + ".z");
float yaw = (float)this.getConfig().getInt("Spawns." + id + ".yaw");
float pitch = (float)this.getConfig().getInt("Spawns." + id + ".pitch");
// TODO: Fix config file returning null here
World world = Bukkit.getWorld(splegg.getConfig().getString("Spawns." + id + ".world"));
return new Location(world, (double)x + 0.5D, (double)y + 0.5D, (double)z + 0.5D, yaw, pitch);
}
public void setSpec(Location l) {
int x = l.getBlockX();
int y = l.getBlockY();
int z = l.getBlockZ();
float pitch = l.getPitch();
float yaw = l.getYaw();
String worldname = l.getWorld().getName();
this.getConfig().set("Spec.world", worldname);
this.getConfig().set("Spec.x", x);
this.getConfig().set("Spec.y", y);
this.getConfig().set("Spec.z", z);
this.getConfig().set("Spec.pitch", pitch);
this.getConfig().set("Spec.yaw", yaw);
}
public Location getSpawnSpec() {
int x = this.getConfig().getInt("Spec.x");
int y = this.getConfig().getInt("Spec.y");
int z = this.getConfig().getInt("Spec.z");
float yaw = (float)this.getConfig().getInt("Spec.yaw");
float pitch = (float)this.getConfig().getInt("Spec.pitch");
World world = Bukkit.getWorld(this.getConfig().getString("Spec.world"));
return new Location(world, (double)x + 0.5D, (double)y + 0.5D, (double)z + 0.5D, yaw, pitch);
}
public String getName() {
return this.name;
}
public void loadSpawns() {
for(int a = 1; a <= this.getCount(); this.spawncount = a++) {
}
}
public void loadFloors() {
for(int a = 1; a <= this.getFloors(); this.floorcount = a++) {
}
}
public void addSpawn(Location l) {
++this.spawncount;
this.savenumbers();
this.setSpawn(this.spawncount, l);
}
public void addFloor(Location p1, Location p2) {
++this.floorcount;
this.savenumbers();
this.config.set("Floors." + this.floorcount + ".p1.x", p1.getBlockX());
this.config.set("Floors." + this.floorcount + ".p1.y", p1.getBlockY());
this.config.set("Floors." + this.floorcount + ".p1.z", p1.getBlockZ());
this.config.set("Floors." + this.floorcount + ".p1.world", p1.getWorld().getName());
this.config.set("Floors." + this.floorcount + ".p2.x", p2.getBlockX());
this.config.set("Floors." + this.floorcount + ".p2.y", p2.getBlockY());
this.config.set("Floors." + this.floorcount + ".p2.z", p2.getBlockZ());
this.config.set("Floors." + this.floorcount + ".p2.world", p2.getWorld().getName());
this.save();
}
public Location getFloor(int id, String pos) {
int x = this.config.getInt("Floors." + id + ".p" + pos + ".x");
int y = this.config.getInt("Floors." + id + ".p" + pos + ".y");
int z = this.config.getInt("Floors." + id + ".p" + pos + ".z");
String world = this.config.getString("Floors." + id + ".p" + pos + ".world");
return new Location(Bukkit.getWorld(world), (double)x, (double)y, (double)z);
}
public int getCount() {
return this.getConfig().getInt("Spawns.count");
}
public int getFloors() {
return this.getConfig().getInt("Floors.count");
}
public int getSpawnCount() {
return this.spawncount;
}
public FileConfiguration getConfig() {
return this.config;
}
public void setConfig(FileConfiguration config) {
this.config = config;
}
public boolean lobbySet() {
return this.getConfig().isString("Spawns.lobby.world");
}
public void setLobby(Location l) {
int x = l.getBlockX();
int y = l.getBlockY();
int z = l.getBlockZ();
float pitch = l.getPitch();
float yaw = l.getYaw();
String worldname = l.getWorld().getName();
this.getConfig().set("Spawns.lobby.world", worldname);
this.getConfig().set("Spawns.lobby.x", x);
this.getConfig().set("Spawns.lobby.y", y);
this.getConfig().set("Spawns.lobby.z", z);
this.getConfig().set("Spawns.lobby.pitch", pitch);
this.getConfig().set("Spawns.lobby.yaw", yaw);
this.save();
}
public Location getLobby() {
int x = this.getConfig().getInt("Spawns.lobby.x");
int y = this.getConfig().getInt("Spawns.lobby.y");
int z = this.getConfig().getInt("Spawns.lobby.z");
float yaw = (float)this.getConfig().getInt("Spawns.lobby.yaw");
float pitch = (float)this.getConfig().getInt("Spawns.lobby.pitch");
World world = Bukkit.getWorld(this.getConfig().getString("Spawns.lobby.world"));
return new Location(world, (double)x + 0.5D, (double)y + 0.5D, (double)z + 0.5D, yaw, pitch);
}
}
+94
View File
@@ -0,0 +1,94 @@
package config;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import main.SpleggOG;
import managers.Game;
import managers.Status;
public class MapConfig {
public FileConfiguration maps;
public File f;
public void setup() {
// TODO: More accurate way of detecting this file.
this.f = new File(SpleggOG.getPlugin().getDataFolder(), "maps.yml");
try {
this.f.createNewFile();
}
catch (IOException e) {
SpleggOG.getPlugin().getLogger().info("Could not find maps.yml.");
}
this.loadMaps();
this.saveMaps();
SpleggOG.getPlugin().maps.MAPS.clear();
Iterator var2 = this.getEnabledMaps().iterator();
while(var2.hasNext()) {
String maps = (String)var2.next();
SpleggOG.getPlugin().maps.addMap(maps);
Map map = SpleggOG.getPlugin().maps.getMap(maps);
Game game = new Game(SpleggOG.getPlugin(), map);
SpleggOG.getPlugin().games.addGame(map.getName(), game);
if (! map.isUsable()) {
game.setStatus(Status.DISABLED);
}
}
}
private void loadMaps() {
this.maps = YamlConfiguration.loadConfiguration(this.f);
}
public void saveMaps() {
try {
this.maps.save(this.f);
} catch (IOException var2) {
}
}
public List getEnabledMaps() {
return this.maps.getStringList("maps");
}
public void addSign(String map, String loc) {
List signs = this.maps.getStringList("Signs." + map + ".lobby");
signs.add(loc);
this.maps.set("Signs." + map + ".lobby", signs);
this.saveMaps();
}
public void delSign(String map, String loc) {
List signs = this.maps.getStringList("Signs." + map + ".lobby");
signs.remove(loc);
this.maps.set("Signs." + map + ".lobby", signs);
this.saveMaps();
}
public void addMap(String name) {
List maps = this.maps.getStringList("maps");
maps.add(name);
this.maps.set("maps", maps);
this.saveMaps();
}
public void removeMap(String name) {
List maps = this.maps.getStringList("maps");
maps.remove(name);
this.maps.set("maps", maps);
this.saveMaps();
}
}
+64
View File
@@ -0,0 +1,64 @@
package config;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Random;
import main.SpleggOG;
import managers.Game;
import managers.Status;
public class MapUtilities {
public MapConfig c = new MapConfig();
public HashMap MAPS = new HashMap();
public void addMap(String name) {
Map map = new Map(SpleggOG.getPlugin(), name);
this.MAPS.put(name, map);
map.load();
}
public void deleteMap(String name) {
Map m = this.getMap(name);
Game game = SpleggOG.getPlugin().games.getGame(name);
if (game.getStatus() == Status.INGAME) {
SpleggOG.getPlugin().game.stopGame(game, 0);
}
SpleggOG.getPlugin().games.GAMES.remove(m.getName());
this.MAPS.remove(m);
this.c.removeMap(name);
m.delete();
}
public boolean mapExists(String name) {
return this.MAPS.containsKey(name);
}
public Collection getMaps() {
return this.MAPS.values();
}
public Map getMap(String name) {
return (Map)this.MAPS.get(name);
}
private Map getRandomMap() {
ArrayList all = new ArrayList();
Iterator var3 = this.MAPS.values().iterator();
while(var3.hasNext()) {
Map map = (Map)var3.next();
if (map.isUsable()) {
all.add(map);
}
}
Object[] mapsa = all.toArray();
Map randomMap = (Map)mapsa[(new Random()).nextInt(mapsa.length)];
return randomMap;
}
}
+178
View File
@@ -0,0 +1,178 @@
package events;
import java.util.ArrayList;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Egg;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import main.SpleggOG;
import net.milkbowl.vault.economy.EconomyResponse;
import utils.UtilPlayer;
import utils.Utils;
public class Listeners implements Listener {
public static ArrayList manager = new ArrayList();
public static ArrayList moneymanager = new ArrayList();
public static ArrayList shopmanager = new ArrayList();
public static ArrayList diamondspade = new ArrayList();
public static ArrayList goldspade = new ArrayList();
public static ArrayList launchEggs = new ArrayList();
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
Player player = (Player)event.getWhoClicked();
UtilPlayer u = SpleggOG.getPlugin().pm.getPlayer(player);
ItemStack stack = event.getCurrentItem();
if (event.getView().getTitle().equals(SpleggOG.getPlugin().getConfig().getString("GUI.Shop.Title"))) {
if (shopmanager.contains(player.getName())) {
EconomyResponse r;
if (stack.getType() == Material.GOLDEN_SHOVEL) {
player.closeInventory();
if (SpleggOG.getPlugin().econ.getBalance(player.getName()) >= (double)SpleggOG.getPlugin().getConfig().getInt("GUI.Shop.GoldShovel.Price")) {
r = SpleggOG.getPlugin().econ.withdrawPlayer(player.getName(), (double)SpleggOG.getPlugin().getConfig().getInt("GUI.Shop.GoldShovel.Price"));
if (r.transactionSuccess()) {
goldspade.add(player.getName());
diamondspade.remove(player.getName());
shopmanager.remove(player.getName());
manager.remove(player.getName());
SpleggOG.getPlugin().chat.sendMessage(player, SpleggOG.getPlugin().getConfig().getString("Messages.BuyGoldShovel").replaceAll("&", "�"));
} else {
player.sendMessage(String.format("An error occured: %s", r.errorMessage));
shopmanager.add(player.getName());
manager.add(player.getName());
goldspade.remove(player.getName());
diamondspade.remove(player.getName());
}
} else {
SpleggOG.getPlugin().chat.sendMessage(player, SpleggOG.getPlugin().getConfig().getString("Messages.NoEnoughMoney").replaceAll("&", "�"));
}
}
if (stack.getType() == Material.DIAMOND_SHOVEL) {
player.closeInventory();
if (SpleggOG.getPlugin().econ.getBalance(player.getName()) >= (double)SpleggOG.getPlugin().getConfig().getInt("GUI.Shop.DiamondShovel.Price")) {
r = SpleggOG.getPlugin().econ.withdrawPlayer(player.getName(), (double)SpleggOG.getPlugin().getConfig().getInt("GUI.Shop.DiamondShovel.Price"));
if (r.transactionSuccess()) {
goldspade.remove(player.getName());
diamondspade.add(player.getName());
shopmanager.remove(player.getName());
manager.remove(player.getName());
SpleggOG.getPlugin().chat.sendMessage(player, SpleggOG.getPlugin().getConfig().getString("Messages.BuyDiamondShovel").replaceAll("&", "�"));
} else {
player.sendMessage(String.format("An error occured: %s", r.errorMessage));
shopmanager.add(player.getName());
manager.add(player.getName());
goldspade.remove(player.getName());
diamondspade.remove(player.getName());
}
} else {
SpleggOG.getPlugin().chat.sendMessage(player, SpleggOG.getPlugin().getConfig().getString("Messages.NoEnoughMoney").replaceAll("&", "�"));
}
}
} else {
SpleggOG.getPlugin().chat.sendMessage(player, SpleggOG.getPlugin().getConfig().getString("Messages.Haveyoueverbought").replaceAll("&", "�"));
player.closeInventory();
}
}
if (u.getGame() != null && u.isAlive()) {
event.setCancelled(true);
}
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
ItemStack hand = player.getItemInHand();
UtilPlayer u = SpleggOG.getPlugin().pm.getPlayer(player);
if (event.getAction() == Action.RIGHT_CLICK_AIR) {
if (hand.getType() == Material.IRON_SHOVEL && u.getGame() != null && u.isAlive() && launchEggs.contains(player.getName())) {
player.launchProjectile(Egg.class);
player.playSound(player.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1.0F, 1.0F);
}
Integer i;
if (hand.getType() == Material.GOLDEN_SHOVEL && u.getGame() != null && u.isAlive() && launchEggs.contains(player.getName())) {
for(i = 0; i < 2; i = i + 1) {
player.launchProjectile(Egg.class);
}
player.playSound(player.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1.0F, 1.0F);
}
if (hand.getType() == Material.DIAMOND_SHOVEL && u.getGame() != null && u.isAlive() && launchEggs.contains(player.getName())) {
for(i = 0; i < 3; i = i + 1) {
player.launchProjectile(Egg.class);
}
player.playSound(player.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1.0F, 1.0F);
}
if (hand.getType() == Material.COMPASS && u.getGame() != null && u.isAlive()) {
player.openInventory(this.getSpecInventory());
}
if (hand.getType() == Material.MAGMA_CREAM && u.getGame() != null && u.isAlive()) {
u.getGame().leaveGame(u);
}
if (hand.getType() == Material.getMaterial(SpleggOG.getPlugin().getConfig().getString("Shop.Item")) && u.getGame() != null && u.isAlive()) {
player.openInventory(this.getShopInventory());
}
}
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
manager.remove(player.getName());
shopmanager.remove(player.getName());
goldspade.remove(player.getName());
diamondspade.remove(player.getName());
launchEggs.remove(player.getName());
moneymanager.remove(player.getName());
}
@EventHandler
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
Player player = event.getPlayer();
UtilPlayer u = SpleggOG.getPlugin().pm.getPlayer(player);
if (u.getGame() != null && u.isAlive()) {
event.setCancelled(true);
}
}
@EventHandler
public void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
}
private Inventory getShopInventory() {
Inventory shop = Bukkit.createInventory((InventoryHolder) null, SpleggOG.getPlugin().getConfig().getInt("GUI.Shop.Size"), SpleggOG.getPlugin().getConfig().getString("GUI.Shop.Title"));
shop.setItem(0, Utils.getItem(Material.GOLDEN_SHOVEL, 0, SpleggOG.getPlugin().getConfig().getString("GUI.Shop.GoldShovel.Name").replaceAll("&", "�"), SpleggOG.getPlugin().getConfig().getString("GUI.Shop.GoldShovel.Description").replaceAll("&", "�").replaceAll("%price%", String.valueOf(SpleggOG.getPlugin().getConfig().getInt("GUI.Shop.GoldShovel.Price")))));
shop.setItem(1, Utils.getItem(Material.DIAMOND_SHOVEL, 0, SpleggOG.getPlugin().getConfig().getString("GUI.Shop.DiamondShovel.Name").replaceAll("&", "�"), SpleggOG.getPlugin().getConfig().getString("GUI.Shop.DiamondShovel.Description").replaceAll("&", "�").replaceAll("%price%", String.valueOf(SpleggOG.getPlugin().getConfig().getInt("GUI.Shop.DiamondShovel.Price")))));
return shop;
}
private Inventory getSpecInventory() {
Inventory spec = Bukkit.createInventory((InventoryHolder)null, 27, "Splegg - Spectators");
return spec;
}
}
+44
View File
@@ -0,0 +1,44 @@
package events;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import main.SpleggOG;
import utils.UtilPlayer;
public class MapListener implements Listener {
@EventHandler
public void blockBreak(BlockBreakEvent e) {
Player player = e.getPlayer();
UtilPlayer u = SpleggOG.getPlugin().pm.getPlayer(player);
if (u.getGame() != null && u.isAlive()) {
e.setCancelled(true);
}
}
@EventHandler
public void blockPlace(BlockPlaceEvent e) {
Player player = e.getPlayer();
UtilPlayer u = SpleggOG.getPlugin().pm.getPlayer(player);
if (u.getGame() != null && u.isAlive()) {
e.setCancelled(true);
}
}
@EventHandler
public void hangingEntityBreak(HangingBreakByEntityEvent e) {
Player player = (Player)e.getRemover();
UtilPlayer u = SpleggOG.getPlugin().pm.getPlayer(player);
if (u.getGame() != null && u.isAlive()) {
e.setCancelled(true);
}
}
}
+85
View File
@@ -0,0 +1,85 @@
package events;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import main.SpleggOG;
import utils.UtilPlayer;
public class PlayerListener implements Listener {
String[] cmds = new String[]{""};
@EventHandler
public void onFood(FoodLevelChangeEvent e) {
if (e.getEntity() instanceof Player) {
Player player = (Player)e.getEntity();
UtilPlayer u = SpleggOG.getPlugin().pm.getPlayer(player);
if (u.getGame() != null && u.isAlive()) {
e.setCancelled(true);
e.setFoodLevel(20);
}
}
}
@EventHandler
public void entityDamage(EntityDamageEvent e) {
Entity ent = e.getEntity();
if (ent instanceof Player) {
Player player = (Player)ent;
UtilPlayer u = SpleggOG.getPlugin().pm.getPlayer(player);
if (u.getGame() != null && u.isAlive()) {
e.setCancelled(true);
}
}
}
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player player = e.getPlayer();
UtilPlayer u = new UtilPlayer(player);
SpleggOG.getPlugin().pm.PLAYERS.put(player.getName(), u);
}
@EventHandler
public void onQuit(PlayerQuitEvent e) {
Player player = e.getPlayer();
UtilPlayer u = SpleggOG.getPlugin().pm.getPlayer(player);
if (u.getGame() != null && u.isAlive()) {
u.getGame().leaveGame(u);
}
SpleggOG.getPlugin().pm.PLAYERS.remove(player.getName());
}
@EventHandler
public void dropItem(PlayerDropItemEvent e) {
Player player = e.getPlayer();
UtilPlayer u = SpleggOG.getPlugin().pm.getPlayer(player);
if (u.getGame() != null && u.isAlive()) {
e.setCancelled(true);
}
}
@EventHandler
public void onCommand(PlayerCommandPreprocessEvent e) {
Player player = e.getPlayer();
UtilPlayer u = SpleggOG.getPlugin().pm.getPlayer(player);
if (u.getGame() != null && u.isAlive() && !e.getMessage().startsWith("/splegg") && !player.isOp() && !player.hasPermission("splegg.admin")) {
e.setCancelled(true);
SpleggOG.getPlugin().chat.sendMessage(player, "&eYou cannot use commands in &bSplegg");
}
}
}
+100
View File
@@ -0,0 +1,100 @@
package events;
import java.util.ArrayList;
import java.util.Collection;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import main.SpleggOG;
import signs.LobbySign;
import signs.LobbySignUtils;
public class SignListener implements Listener {
@EventHandler(
priority = EventPriority.HIGHEST
)
public void signPlace(SignChangeEvent e) {
Player player = e.getPlayer();
if (e.getLine(0).equalsIgnoreCase("[splegg]") && e.getLine(1).equalsIgnoreCase("join") && player.hasPermission("splegg.admin")) {
String map = e.getLine(2);
if (SpleggOG.getPlugin().maps.mapExists(map)) {
LobbySign ls = new LobbySign(SpleggOG.getPlugin().maps.getMap(map), SpleggOG.getPlugin());
ls.create(e.getBlock().getLocation(), SpleggOG.getPlugin().maps.getMap(map));
SpleggOG.getPlugin().chat.sendMessage(player, SpleggOG.getPlugin().getConfig().getString("Messages.CreateSign").replaceAll("&", "�").replaceAll("%map%", map));
}
}
}
private static Collection<Material> signMaterials = new ArrayList<>();
static {
signMaterials.add(Material.ACACIA_SIGN);
signMaterials.add(Material.DARK_OAK_SIGN);
signMaterials.add(Material.OAK_SIGN);
signMaterials.add(Material.BIRCH_SIGN);
signMaterials.add(Material.SPRUCE_SIGN);
signMaterials.add(Material.JUNGLE_SIGN);
signMaterials.add(Material.CRIMSON_SIGN);
signMaterials.add(Material.WARPED_SIGN);
signMaterials.add(Material.ACACIA_WALL_SIGN);
signMaterials.add(Material.DARK_OAK_WALL_SIGN);
signMaterials.add(Material.OAK_WALL_SIGN);
signMaterials.add(Material.BIRCH_WALL_SIGN);
signMaterials.add(Material.SPRUCE_WALL_SIGN);
signMaterials.add(Material.JUNGLE_WALL_SIGN);
signMaterials.add(Material.CRIMSON_WALL_SIGN);
signMaterials.add(Material.WARPED_WALL_SIGN);
}
@EventHandler
public void onInteract(PlayerInteractEvent e) {
if (e.hasBlock() && signMaterials.contains(e.getClickedBlock().getType()) && e.getAction() == Action.RIGHT_CLICK_BLOCK) {
Sign s = (Sign)e.getClickedBlock().getState();
Player player = e.getPlayer();
if (s.getLine(0).equalsIgnoreCase(SpleggOG.getPlugin().getConfig().getString("Sings.Format.1").replaceAll("&", "�"))) {
String map = ChatColor.stripColor(s.getLine(2));
if (SpleggOG.getPlugin().maps.mapExists(map)) {
player.chat("/splegg join " + map);
player.updateInventory();
e.setCancelled(true);
} else {
SpleggOG.getPlugin().chat.sendMessage(player, SpleggOG.getPlugin().getConfig().getString("Messages.Mapnotexist").replaceAll("&", "�"));
e.setCancelled(true);
}
}
}
}
@EventHandler
public void signBreak(BlockBreakEvent e) {
Player player = e.getPlayer();
if(signMaterials.contains(e.getBlock().getType())) {
Sign s = (Sign)e.getBlock().getState();
String[] lines = s.getLines();
String map = ChatColor.stripColor(lines[1]);
if (LobbySignUtils.get().isLobbySign(e.getBlock().getLocation(), map)) {
if (player.hasPermission("splegg.admin")) {
LobbySign sign = new LobbySign(SpleggOG.getPlugin().maps.getMap(map), SpleggOG.getPlugin());
sign.delete(e.getBlock().getLocation());
SpleggOG.getPlugin().chat.sendMessage(player, SpleggOG.getPlugin().getConfig().getString("Messages.RemovedSign").replaceAll("&", "�").replaceAll("%map%", map));
} else {
e.setCancelled(true);
SpleggOG.getPlugin().chat.sendMessage(player, SpleggOG.getPlugin().getConfig().getString("Messages.NotBreakSign").replaceAll("&", "�"));
}
}
}
}
}
+93
View File
@@ -0,0 +1,93 @@
package events;
import java.util.Iterator;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Egg;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerEggThrowEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.util.BlockIterator;
import main.SpleggOG;
import managers.Game;
import managers.Status;
import utils.UtilPlayer;
public class SpleggEvents implements Listener {
@EventHandler
public void eggLand(ProjectileHitEvent e) {
if (e.getEntity().getShooter() instanceof Player && e.getEntity() instanceof Egg) {
Player player = (Player)e.getEntity().getShooter();
UtilPlayer u = SpleggOG.getPlugin().pm.getPlayer(player);
if (u.getGame() != null && u.isAlive()) {
BlockIterator bi = new BlockIterator(e.getEntity().getWorld(), e.getEntity().getLocation().toVector(), e.getEntity().getVelocity().normalize(), 0.0D, 4);
Block hit = null;
while(bi.hasNext()) {
hit = bi.next();
if (hit.getType() != Material.AIR) {
break;
}
}
if (hit.getType() == Material.TNT) {
e.getEntity().getWorld().createExplosion(e.getEntity().getLocation(), 3.0F);
Iterator var7 = e.getEntity().getWorld().getEntities().iterator();
while(var7.hasNext()) {
Entity drop = (Entity)var7.next();
if (drop.getType() == EntityType.DROPPED_ITEM) {
drop.remove();
drop.remove();
drop.remove();
drop.remove();
drop.remove();
drop.remove();
}
}
}
if (u.getGame().getFloor().contains(hit.getLocation())) {
Game game = u.getGame();
if (game.getStatus() == Status.INGAME) {
hit.setType(Material.AIR);
}
}
}
}
}
@EventHandler
public void onKnockout(PlayerMoveEvent e) {
Player player = e.getPlayer();
UtilPlayer u = SpleggOG.getPlugin().pm.getPlayer(player);
if (u.getGame() != null && u.isAlive() && ((double)player.getLocation().getBlockY() < -5.0D || player.getLocation().getBlockY() < u.getGame().getLowestPossible()) && u.getGame().getStatus() == Status.INGAME) {
SpleggOG.getPlugin().chat.bc((SpleggOG.getPlugin().special.contains(player.getName()) ? "�4" : "�e") + SpleggOG.getPlugin().getConfig().getString("Messages.KnockoutPlayer").replaceAll("&", "�").replaceAll("%player%", player.getName()), u.getGame());
SpleggOG.getPlugin().chat.bc(SpleggOG.getPlugin().getConfig().getString("Messages.PlayersRemaining").replaceAll("&", "�").replaceAll("%count%", String.valueOf(u.getGame().getPlayers().size() - 1)), u.getGame());
player.setFallDistance(0.0F);
Listeners.launchEggs.remove(player.getName());
u.getGame().leaveGame(u);
player.setFallDistance(0.0F);
}
}
@EventHandler
public void eggHatch(PlayerEggThrowEvent e) {
Player player = e.getPlayer();
UtilPlayer u = SpleggOG.getPlugin().pm.getPlayer(player);
if (u.getGame() != null && u.isAlive()) {
e.setHatching(false);
}
}
}
+143
View File
@@ -0,0 +1,143 @@
package main;
import java.io.File;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import commands.SpleggCommand;
import config.MapUtilities;
import events.Listeners;
import events.MapListener;
import events.PlayerListener;
import events.SignListener;
import events.SpleggEvents;
import managers.Game;
import managers.GameManager;
import managers.GameUtilities;
import managers.Status;
import net.milkbowl.vault.economy.Economy;
import utils.UtilPlayer;
import utils.Utils;
public class SpleggOG extends JavaPlugin {
private static SpleggOG plugin;
public Economy econ = null;
public Utils chat;
public MapUtilities maps;
public GameUtilities games;
public GameManager game;
public Utils pm;
public Utils utils;
public Utils config;
public boolean updateOut = false;
public String newVer = "";
public File updateFile = this.getFile();
public List special = Arrays.asList("Hraponssi, MrLuangamer, Theluangamer9416, NotAlexNoyle");
public boolean disabling = false;
boolean economy = true;
private boolean setupEconomy() {
if (this.getServer().getPluginManager().getPlugin("Vault") == null) {
return false;
} else {
RegisteredServiceProvider rsp = this.getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
return false;
} else {
this.econ = (Economy)rsp.getProvider();
return this.econ != null;
}
}
}
public void onEnable() {
plugin = this;
this.chat = new Utils();
if (this.getServer().getPluginManager().getPlugin("WorldEdit") == null) {
this.chat.log("WorldEdit not found! Please download it from http://dev.bukkit.org/bukkit-plugins/worldedit");
Bukkit.getPluginManager().disablePlugin(this);
} else {
this.maps = new MapUtilities();
this.games = new GameUtilities();
this.game = new GameManager(this);
this.pm = new Utils();
this.utils = new Utils();
this.config = new Utils();
this.maps.c.setup();
this.config.setup();
this.getConfig().options().copyDefaults(true);
this.saveConfig();
this.getServer().getPluginManager().registerEvents(new MapListener(), this);
this.getServer().getPluginManager().registerEvents(new PlayerListener(), this);
this.getServer().getPluginManager().registerEvents(new SpleggEvents(), this);
this.getServer().getPluginManager().registerEvents(new SignListener(), this);
this.getServer().getPluginManager().registerEvents(new Listeners(), this);
this.getCommand("splegg").setExecutor(new SpleggCommand());
if (!this.setupEconomy()) {
this.getLogger().severe(String.format("[%s] - Disabled due to no Vault dependency found!", this.getDescription().getName()));
this.getServer().getPluginManager().disablePlugin(this);
} else {
for(Player p : Bukkit.getOnlinePlayers()) {
UtilPlayer u = new UtilPlayer(p);
this.pm.PLAYERS.put(p.getName(), u);
}
}
}
}
public void onDisable() {
this.disabling = true;
HandlerList.unregisterAll(new MapListener());
HandlerList.unregisterAll(new PlayerListener());
HandlerList.unregisterAll(new SpleggEvents());
HandlerList.unregisterAll(new SignListener());
HandlerList.unregisterAll(new Listeners());
int gameCounter = 0;
try {
Iterator var2 = this.games.GAMES.values().iterator();
while(var2.hasNext()) {
Game game = (Game)var2.next();
if (game.getStatus() == Status.INGAME) {
gameCounter++;
this.game.stopGame(game, 1);
}
}
this.getLogger().info("Splegg-OG Shut Down with " + gameCounter + " games running.");
}
catch (NullPointerException error) {
this.getLogger().info("Splegg-OG Shut Down with 0 games running.");
}
}
public WorldEditPlugin getWorldEdit() {
Plugin worldEdit = this.getServer().getPluginManager().getPlugin("WorldEdit");
return worldEdit instanceof WorldEditPlugin ? (WorldEditPlugin)worldEdit : null;
}
public static SpleggOG getPlugin() {
// Pass instance of main to other classes.
return plugin;
}
}
@@ -1,23 +1,10 @@
package me.mrluangamer.managers;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
package managers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
//import me.confuser.barapi.BarAPI;
import me.mrluangamer.Splegg;
import me.mrluangamer.config.Map;
import me.mrluangamer.events.Listeners;
import me.mrluangamer.runnables.GameTime;
import me.mrluangamer.runnables.LobbyCountdown;
import me.mrluangamer.signs.LobbySign;
import me.mrluangamer.utils.InvStore;
import me.mrluangamer.utils.SpleggPlayer;
import me.mrluangamer.utils.UtilPlayer;
import me.mrluangamer.utils.Utils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
@@ -28,8 +15,23 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import config.Map;
import events.Listeners;
import main.SpleggOG;
import runnables.GameTime;
import runnables.LobbyCountdown;
import signs.LobbySign;
import utils.InvStore;
import utils.SpleggPlayer;
import utils.UtilPlayer;
import utils.Utils;
public class Game {
Splegg splegg;
SpleggOG splegg;
String name;
Map map;
Status status;
@@ -46,7 +48,7 @@ public class Game {
boolean starting;
LobbySign sign;
public Game(Splegg splegg, final Map map) {
public Game(SpleggOG splegg, final Map map) {
this.splegg = splegg;
this.map = map;
this.name = map.getName();
@@ -70,10 +72,10 @@ public class Game {
public void startGameTimer() {
int grace = this.splegg.getConfig().getInt("Options.GraceTime");
this.splegg.chat.bc(this.splegg.getConfig().getString("Messages.GraceTimeStart").replaceAll("&", "§").replaceAll("%grace%", String.valueOf(grace)), this);
this.splegg.chat.bc(this.splegg.getConfig().getString("Messages.GraceTimeStart").replaceAll("&", "�").replaceAll("%grace%", String.valueOf(grace)), this);
(new BukkitRunnable() {
public void run() {
Game.this.splegg.chat.bc(Game.this.splegg.getConfig().getString("Messages.GraceTimeFinish").replaceAll("&", "§"), Game.this);
Game.this.splegg.chat.bc(Game.this.splegg.getConfig().getString("Messages.GraceTimeFinish").replaceAll("&", "�"), Game.this);
Iterator var2 = Game.this.players.values().iterator();
while(var2.hasNext()) {
@@ -142,9 +144,9 @@ public class Game {
public void joinGame(UtilPlayer u) {
Player player = u.getPlayer();
if (u.getGame() != null) {
this.splegg.chat.sendMessage(player, this.splegg.getConfig().getString("Messages.AlreadyInGame").replaceAll("&", "§"));
this.splegg.chat.sendMessage(player, this.splegg.getConfig().getString("Messages.AlreadyInGame").replaceAll("&", "�"));
} else if (this.players.containsKey(player.getName())) {
this.splegg.chat.sendMessage(player, Splegg.getSplegg().getConfig().getString("Messages.AlreadyInLobby").replaceAll("&", "§"));
this.splegg.chat.sendMessage(player, splegg.getConfig().getString("Messages.AlreadyInLobby").replaceAll("&", "�"));
} else if (this.status == Status.LOBBY) {
int size = this.players.size();
int max = this.map.getSpawnCount();
@@ -169,17 +171,17 @@ public class Game {
Listeners.manager.add(u.getPlayer().getName());
Listeners.shopmanager.add(u.getPlayer().getName());
player.getInventory().setItem(Splegg.getSplegg().getConfig().getInt("Shop.Slot"), Utils.getItem(Material.getMaterial(Splegg.getSplegg().getConfig().getString("Shop.Item")), 0, Splegg.getSplegg().getConfig().getString("Shop.Name").replaceAll("&", "§"), Splegg.getSplegg().getConfig().getString("Shop.Lore").replaceAll("&", "§")));
this.splegg.chat.bc(this.splegg.getConfig().getString("Messages.JoinGame").replaceAll("&", "§").replaceAll("%player%", player.getName()).replaceAll("%count%", String.valueOf(this.players.size())).replaceAll("%maxcount%", String.valueOf(max)), u.getGame());
player.getInventory().setItem(splegg.getConfig().getInt("Shop.Slot"), Utils.getItem(Material.getMaterial(splegg.getConfig().getString("Shop.Item")), 0, splegg.getConfig().getString("Shop.Name").replaceAll("&", "�"), splegg.getConfig().getString("Shop.Lore").replaceAll("&", "�")));
this.splegg.chat.bc(this.splegg.getConfig().getString("Messages.JoinGame").replaceAll("&", "�").replaceAll("%player%", player.getName()).replaceAll("%count%", String.valueOf(this.players.size())).replaceAll("%maxcount%", String.valueOf(max)), u.getGame());
if (this.players.size() >= this.splegg.getConfig().getInt("Options.AutoStartPlayers") && !this.isStarting()) {
this.startCountdown();
this.setStarting(true);
}
} else if (size >= max && !player.hasPermission("splegg.joinfull")) {
this.splegg.chat.sendMessage(player, Splegg.getSplegg().getConfig().getString("Messages.VIPPrivilege").replaceAll("&", "§"));
this.splegg.chat.sendMessage(player, splegg.getConfig().getString("Messages.VIPPrivilege").replaceAll("&", "�"));
} else {
if (size >= max) {
this.splegg.chat.sendMessage(player, Splegg.getSplegg().getConfig().getString("Messages.VIPJoinGame").replaceAll("&", "§"));
this.splegg.chat.sendMessage(player, splegg.getConfig().getString("Messages.VIPJoinGame").replaceAll("&", "�"));
}
sp = new SpleggPlayer(player, u);
@@ -199,10 +201,10 @@ public class Game {
player.teleport(this.splegg.config.getLobby());
}
player.getInventory().setItem(Splegg.getSplegg().getConfig().getInt("Shop.Slot"), Utils.getItem(Material.getMaterial(Splegg.getSplegg().getConfig().getString("Shop.Item")), 0, Splegg.getSplegg().getConfig().getString("Shop.Name").replaceAll("&", "§"), Splegg.getSplegg().getConfig().getString("Shop.Lore").replaceAll("&", "§")));
player.getInventory().setItem(splegg.getConfig().getInt("Shop.Slot"), Utils.getItem(Material.getMaterial(splegg.getConfig().getString("Shop.Item")), 0, splegg.getConfig().getString("Shop.Name").replaceAll("&", "�"), splegg.getConfig().getString("Shop.Lore").replaceAll("&", "�")));
Listeners.manager.add(u.getPlayer().getName());
Listeners.shopmanager.add(u.getPlayer().getName());
this.splegg.chat.bc(this.splegg.getConfig().getString("Messages.JoinGame").replaceAll("&", "§").replaceAll("%player%", player.getName()).replaceAll("%count%", String.valueOf(this.players.size())).replaceAll("%maxcount%", String.valueOf(max)), u.getGame());
this.splegg.chat.bc(this.splegg.getConfig().getString("Messages.JoinGame").replaceAll("&", "�").replaceAll("%player%", player.getName()).replaceAll("%count%", String.valueOf(this.players.size())).replaceAll("%maxcount%", String.valueOf(max)), u.getGame());
if (this.players.size() >= this.splegg.getConfig().getInt("Options.AutoStartPlayers") && !this.isStarting()) {
this.startCountdown();
this.setStarting(true);
@@ -211,7 +213,7 @@ public class Game {
this.getSign().update(this.map, false);
} else if (this.status == Status.DISABLED) {
this.splegg.chat.sendMessage(player, Splegg.getSplegg().getConfig().getString("Messages.Mapdisabled").replaceAll("&", "§"));
this.splegg.chat.sendMessage(player, splegg.getConfig().getString("Messages.Mapdisabled").replaceAll("&", "�"));
}
}
@@ -227,7 +229,7 @@ public class Game {
sp.getPlayer().setLevel(this.getLobbyCount());
}
this.counter = Bukkit.getScheduler().scheduleSyncRepeatingTask(this.splegg, new LobbyCountdown(this, this.getLobbyCount()), 0L, 20L);
this.counter = Bukkit.getScheduler().scheduleSyncRepeatingTask(this.splegg, new LobbyCountdown(splegg, this, this.getLobbyCount()), 0L, 20L);
}
}
@@ -235,13 +237,9 @@ public class Game {
public void leaveGame(UtilPlayer u) {
SpleggPlayer sp = this.getPlayer(u.getPlayer());
if (this.status == Status.ENDING || this.status == Status.INGAME) {
this.splegg.chat.sendMessage(u.getPlayer(), Splegg.getSplegg().getConfig().getString("Messages.Youbrokeblocks").replaceAll("&", "§").replaceAll("%broke%", String.valueOf(sp.getBroken())));
this.splegg.chat.sendMessage(u.getPlayer(), splegg.getConfig().getString("Messages.Youbrokeblocks").replaceAll("&", "�").replaceAll("%broke%", String.valueOf(sp.getBroken())));
}
// if (Splegg.getSplegg().getConfig().getString("BarAPI.Enabled").equalsIgnoreCase("true")) {
// BarAPI.removeBar(sp.getPlayer());
// }
this.players.remove(u.getName());
Listeners.launchEggs.remove(sp.getPlayer().getName());
Listeners.shopmanager.remove(sp.getPlayer().getName());
@@ -259,8 +257,8 @@ public class Game {
u.getPlayer().setFallDistance(0.0F);
for(Player p : Bukkit.getOnlinePlayers()) {
if (Listeners.moneymanager.contains(p.getName())) {
p.sendMessage(ChatColor.GREEN + "!!! You received " + Splegg.getSplegg().getConfig().getInt("Money.KillPlayer") +" coins!");
Splegg.getSplegg().econ.depositPlayer(p, Splegg.getSplegg().getConfig().getInt("Money.KillPlayer"));
p.sendMessage(ChatColor.GREEN + "You received " + splegg.getConfig().getInt("Money.KillPlayer") +" coins!");
splegg.econ.depositPlayer(p, splegg.getConfig().getInt("Money.KillPlayer"));
}
}
@@ -351,4 +349,4 @@ public class Game {
public void setLobbyCount(int lobbycount) {
this.lobbycount = lobbycount;
}
}
}
+139
View File
@@ -0,0 +1,139 @@
package managers;
import java.util.HashMap;
import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
import config.Map;
import events.Listeners;
import main.SpleggOG;
import utils.SpleggPlayer;
import utils.Utils;
public class GameManager {
SpleggOG splegg;
public GameManager(SpleggOG splegg) {
this.splegg = splegg;
}
public void startGame(Game game) {
this.splegg.chat.log("New game commencing..");
game.startGameTimer();
Bukkit.getScheduler().cancelTask(game.counter);
game.status = Status.INGAME;
game.time = 901;
game.setLobbyCount(31);
int c = 1;
game.loadFloors();
Map map = game.getMap();
Iterator var5 = game.players.values().iterator();
SpleggPlayer sp;
while(var5.hasNext()) {
sp = (SpleggPlayer)var5.next();
sp.getPlayer().setLevel(0);
sp.getUtilPlayer().setAlive(true);
if (c > map.getSpawnCount()) {
c = 1;
}
sp.getPlayer().teleport(map.getSpawn(c));
++c;
sp.getPlayer().setLevel(0);
sp.getPlayer().setExp(0.0F);
sp.getPlayer().setGameMode(GameMode.ADVENTURE);
if (!Listeners.manager.contains(sp.getPlayer().getName())) {
if (Listeners.goldspade.contains(sp.getPlayer().getName())) {
sp.getPlayer().getInventory().clear();
sp.getPlayer().getInventory().setItem(0, Utils.getItem(Material.GOLDEN_SHOVEL, 0, splegg.getConfig().getString("Shovels.Gold.Name").replaceAll("&", "�"), splegg.getConfig().getString("Shovels.Gold.Lore").replaceAll("&", "�")));
sp.getPlayer().updateInventory();
Listeners.manager.remove(sp.getPlayer().getName());
Listeners.goldspade.remove(sp.getPlayer().getName());
Listeners.diamondspade.remove(sp.getPlayer().getName());
Listeners.shopmanager.remove(sp.getPlayer().getName());
Listeners.moneymanager.add(sp.getPlayer().getName());
}
if (Listeners.diamondspade.contains(sp.getPlayer().getName())) {
sp.getPlayer().getInventory().clear();
sp.getPlayer().getInventory().setItem(0, Utils.getItem(Material.DIAMOND_SHOVEL, 0, splegg.getConfig().getString("Shovels.Diamond.Name").replaceAll("&", "�"), splegg.getConfig().getString("Shovels.Diamond.Lore").replaceAll("&", "�")));
sp.getPlayer().updateInventory();
Listeners.manager.remove(sp.getPlayer().getName());
Listeners.goldspade.remove(sp.getPlayer().getName());
Listeners.diamondspade.remove(sp.getPlayer().getName());
Listeners.shopmanager.remove(sp.getPlayer().getName());
Listeners.moneymanager.add(sp.getPlayer().getName());
}
} else {
sp.getPlayer().getInventory().clear();
sp.getPlayer().getInventory().setItem(0, Utils.getItem(Material.IRON_SHOVEL, 0, splegg.getConfig().getString("Shovels.Iron.Name").replaceAll("&", "�"), splegg.getConfig().getString("Shovels.Iron.Lore").replaceAll("&", "�")));
sp.getPlayer().updateInventory();
Listeners.manager.remove(sp.getPlayer().getName());
Listeners.goldspade.remove(sp.getPlayer().getName());
Listeners.diamondspade.remove(sp.getPlayer().getName());
Listeners.shopmanager.remove(sp.getPlayer().getName());
Listeners.moneymanager.add(sp.getPlayer().getName());
}
}
game.getSign().update(map, false);
this.splegg.chat.bc(this.splegg.getConfig().getString("Messages.InstructionsGame").replaceAll("&", "�"), game);
}
public void stopGame(Game game, int r) {
this.splegg.chat.log("Commencing shutdown of " + game.getMap().getName() + ".");
Iterator var4 = game.players.values().iterator();
while(var4.hasNext()) {
SpleggPlayer sp = (SpleggPlayer)var4.next();
Listeners.launchEggs.remove(sp.getPlayer().getName());
}
game.status = Status.ENDING;
game.stopGameTimer();
game.setLobbyCount(31);
game.time = 601;
game.setStatus(Status.LOBBY);
game.resetArena();
game.data.clear();
game.floor.clear();
game.setStarting(false);
HashMap h = new HashMap(game.players);
game.players.clear();
Iterator var5 = h.values().iterator();
while(var5.hasNext()) {
SpleggPlayer sp = (SpleggPlayer)var5.next();
game.leaveGame(sp.getUtilPlayer());
}
if (!this.splegg.disabling) {
game.getSign().update(game.map, true);
}
this.splegg.chat.log("Map " + game.map.getName() + " was reset.");
}
public String getDigitTime(int count) {
int minutes = count / 60;
int seconds = count % 60;
String disMinu = (minutes < 10 ? "0" : "") + minutes;
String disSec = (seconds < 10 ? "0" : "") + seconds;
String formattedTime = disMinu + ":" + disSec;
return formattedTime;
}
public void ingameTimer(int count, HashMap players) {
Iterator var4 = players.values().iterator();
while(var4.hasNext()) {
SpleggPlayer sp = (SpleggPlayer)var4.next();
this.splegg.chat.sendMessage(sp.getPlayer(), "Splegg is ending in �5�l" + this.splegg.game.getDigitTime(count));
}
}
}
+93
View File
@@ -0,0 +1,93 @@
package managers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.bukkit.entity.Player;
import utils.SpleggPlayer;
public class GameUtilities {
public HashMap GAMES = new HashMap();
public Game getGame(String map) {
return (Game)this.GAMES.get(map);
}
public void addGame(String map, Game game) {
this.GAMES.put(map, game);
}
public SpleggPlayer getPlayer(Player player) {
if (player == null) {
return null;
} else {
SpleggPlayer sp = null;
Iterator var4 = this.GAMES.values().iterator();
while(var4.hasNext()) {
Game games = (Game)var4.next();
Iterator var6 = games.players.values().iterator();
while(var6.hasNext()) {
SpleggPlayer sps = (SpleggPlayer)var6.next();
if (sps.getPlayer().getName().equalsIgnoreCase(player.getName())) {
sp = sps;
}
}
}
return sp;
}
}
public Game getMatchedGame(Player player) {
Game game = null;
Iterator var4 = this.GAMES.values().iterator();
while(var4.hasNext()) {
Game g = (Game)var4.next();
if (g.players.containsKey(player.getName())) {
game = g;
}
}
return game;
}
public int howManyOpenGames() {
ArrayList all = new ArrayList();
Iterator var3 = this.GAMES.values().iterator();
while(var3.hasNext()) {
Game games = (Game)var3.next();
if (games.getStatus() == Status.LOBBY) {
all.add(games);
}
}
return all.size();
}
public void checkWinner(Game game) {
if (game.players.size() <= 1) {
if (game.players.size() == 0) {
game.splegg.game.stopGame(game, 0);
} else {
String w = "";
Iterator var4 = game.players.values().iterator();
while(var4.hasNext()) {
SpleggPlayer sp = (SpleggPlayer) var4.next();
w = sp.getPlayer().getName();
game.leaveGame(sp.getUtilPlayer());
}
game.splegg.game.stopGame(game, 5);
}
}
}
}
+59
View File
@@ -0,0 +1,59 @@
package managers;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
public class Rollback {
private String world;
private Material previd;
private Material newid;
private BlockData prevdata;
private BlockData newdata;
private int x;
private int y;
private int z;
public Rollback(String world, Material previd, BlockData prevdata, int x, int y, int z) {
this.world = world;
this.previd = previd;
this.prevdata = prevdata;
this.newid = Material.AIR;
this.newdata = null;
this.x = x;
this.y = y;
this.z = z;
}
public String getWorld() {
return this.world;
}
public BlockData getPrevdata() {
return this.prevdata;
}
public BlockData getNewdata() {
return this.newdata;
}
public Material getPrevid() {
return this.previd;
}
public Material getNewid() {
return this.newid;
}
public int getX() {
return this.x;
}
public int getY() {
return this.y;
}
public int getZ() {
return this.z;
}
}
+8
View File
@@ -0,0 +1,8 @@
package managers;
public enum Status {
DISABLED,
LOBBY,
INGAME,
ENDING;
}
+36
View File
@@ -0,0 +1,36 @@
package runnables;
import main.SpleggOG;
import managers.Game;
public class GameTime implements Runnable {
SpleggOG splegg;
Game game;
public GameTime(SpleggOG splegg, Game game) {
this.splegg = splegg;
this.game = game;
}
public void run() {
if (this.game.getCount() > 0) {
this.splegg.games.checkWinner(this.game);
if (this.game.getCount() % 300 == 0) {
this.splegg.game.ingameTimer(this.game.getCount(), this.game.getPlayers());
}
if (this.game.getCount() % 30 == 0 && this.game.getCount() < 60) {
this.splegg.game.ingameTimer(this.game.getCount(), this.game.getPlayers());
}
if (this.game.getCount() <= 5 && this.game.getCount() >= 1) {
this.splegg.chat.bc(splegg.getConfig().getString("Messages.EndingTimer").replaceAll("&", "�").replaceAll("%timer%", String.valueOf(this.game.getCount())), this.game);
}
} else {
this.game.stopGameTimer();
this.splegg.chat.bc(splegg.getConfig().getString("Messages.Timelimitreached"), this.game);
this.splegg.game.stopGame(this.game, 1);
}
}
}
@@ -0,0 +1,70 @@
package runnables;
import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import main.SpleggOG;
import managers.Game;
import utils.SpleggPlayer;
public class LobbyCountdown implements Runnable {
int lobbycount;
Game game;
public LobbyCountdown(SpleggOG splegg, Game game, int lobbycount) {
this.game = game;
this.lobbycount = lobbycount;
}
public void run() {
if (this.lobbycount >= 1) {
--this.lobbycount;
this.game.setLobbyCount(this.lobbycount);
Iterator var2 = this.game.getPlayers().values().iterator();
SpleggPlayer sp;
while(var2.hasNext()) {
sp = (SpleggPlayer)var2.next();
sp.getPlayer().setLevel(this.lobbycount);
sp.getPlayer().setExp((float)((double)this.game.getLobbyCount() * 0.008D));
}
this.game.getSign().update(this.game.getMap(), false);
if (this.lobbycount % 25 == 0) {
SpleggOG.getPlugin().chat.bc(SpleggOG.getPlugin().getConfig().getString("Messages.LobbyTimer").replaceAll("&", "�").replaceAll("%timer%", String.valueOf(this.lobbycount)), this.game);
}
if (this.lobbycount <= 10 && this.lobbycount >= 1) {
SpleggOG.getPlugin().chat.bc(SpleggOG.getPlugin().getConfig().getString("Messages.LobbyTimer").replaceAll("&", "�").replaceAll("%timer%", String.valueOf(this.lobbycount)), this.game);
var2 = this.game.getPlayers().values().iterator();
while(var2.hasNext()) {
sp = (SpleggPlayer)var2.next();
sp.getPlayer().playSound(sp.getPlayer().getLocation(), Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0F, 1.0F);
}
}
if (this.lobbycount <= 0) {
var2 = this.game.getPlayers().values().iterator();
while(var2.hasNext()) {
sp = (SpleggPlayer)var2.next();
}
}
} else if (this.game.getPlayers().size() > 1) {
Bukkit.getScheduler().cancelTask(this.game.getCounterID());
SpleggOG.getPlugin().game.startGame(this.game);
} else {
SpleggOG.getPlugin().chat.bc(SpleggOG.getPlugin().getConfig().getString("Messages.NoEnoughPlayers").replaceAll("&", "�"), this.game);
Bukkit.getScheduler().cancelTask(this.game.getCounterID());
this.game.setLobbyCount(31);
this.game.setStarting(false);
this.game.getSign().update(this.game.getMap(), false);
this.game.startCountdown();
}
}
}
+148
View File
@@ -0,0 +1,148 @@
package signs;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Sign;
import config.Map;
import main.SpleggOG;
import managers.Game;
import managers.Status;
public class LobbySign {
SpleggOG splegg;
Map map;
public LobbySign(Map map, SpleggOG s) {
this.splegg = s;
this.map = map;
}
private static Collection<Material> signMaterials = new ArrayList<>();
static {
signMaterials.add(Material.ACACIA_SIGN);
signMaterials.add(Material.DARK_OAK_SIGN);
signMaterials.add(Material.OAK_SIGN);
signMaterials.add(Material.BIRCH_SIGN);
signMaterials.add(Material.SPRUCE_SIGN);
signMaterials.add(Material.JUNGLE_SIGN);
signMaterials.add(Material.CRIMSON_SIGN);
signMaterials.add(Material.WARPED_SIGN);
signMaterials.add(Material.ACACIA_WALL_SIGN);
signMaterials.add(Material.DARK_OAK_WALL_SIGN);
signMaterials.add(Material.OAK_WALL_SIGN);
signMaterials.add(Material.BIRCH_WALL_SIGN);
signMaterials.add(Material.SPRUCE_WALL_SIGN);
signMaterials.add(Material.JUNGLE_WALL_SIGN);
signMaterials.add(Material.CRIMSON_WALL_SIGN);
signMaterials.add(Material.WARPED_WALL_SIGN);
}
public void create(Location location, final Map map) {
String loc = LobbySignUtils.get().locationToString(location);
this.splegg.maps.c.addSign(map.getName(), loc);
if (this.map == null) {
this.map = map;
}
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this.splegg, new Runnable() {
public void run() {
LobbySign.this.update(map, true);
}
}, 5L);
}
public void delete(Location location) {
String loc = LobbySignUtils.get().locationToString(location);
this.splegg.maps.c.delSign(this.map.getName(), loc);
this.splegg.maps.c.saveMaps();
this.map = null;
}
public void update(Map map, boolean force) {
Iterator var4 = this.splegg.maps.c.maps.getStringList("Signs." + map.getName() + ".lobby").iterator();
while(var4.hasNext()) {
String loc = (String)var4.next();
Location location = LobbySignUtils.get().stringToLocation(loc);
if (!signMaterials.contains(location.getBlock().getType())) {
location.getBlock().setType(Material.OAK_WALL_SIGN);
}
Sign s = (Sign)location.getBlock().getState();
String[] sign;
if (force) {
String[] array = new String[]{splegg.getConfig().getString("Sings.Restarting.1").replaceAll("&", "�").replaceAll("#", "█"), splegg.getConfig().getString("Sings.Restarting.2").replaceAll("&", "�"), splegg.getConfig().getString("Sings.Restarting.3").replaceAll("&", "�").replaceAll("%map%", map.getName()), splegg.getConfig().getString("Sings.Restarting.4").replaceAll("&", "�").replaceAll("#", "█")};
this.setSign(array, s);
sign = new String[4];
Game game = this.splegg.games.getGame(map.getName());
if (game == null) {
sign[0] = "";
sign[1] = ChatColor.DARK_RED + "Please remove";
sign[2] = ChatColor.DARK_RED + "this sign";
sign[3] = "";
} else {
sign[0] = splegg.getConfig().getString("Sings.Format.1").replaceAll("&", "�").replaceAll("%status%", this.getFancyStatus(game)).replaceAll("%map%", map.getName()).replaceAll("%count%/%maxcount%", this.getPlayers(game));
sign[1] = splegg.getConfig().getString("Sings.Format.2").replaceAll("&", "�").replaceAll("%status%", this.getFancyStatus(game)).replaceAll("%map%", map.getName()).replaceAll("%count%/%maxcount%", this.getPlayers(game));
sign[2] = splegg.getConfig().getString("Sings.Format.3").replaceAll("&", "�").replaceAll("%map%", map.getName()).replaceAll("%status%", this.getFancyStatus(game)).replaceAll("%count%/%maxcount%", this.getPlayers(game));
sign[3] = splegg.getConfig().getString("Sings.Format.4").replaceAll("&", "�").replaceAll("%count%/%maxcount%", this.getPlayers(game)).replaceAll("%status%", this.getFancyStatus(game)).replaceAll("%map%", map.getName());
}
Bukkit.getScheduler().scheduleSyncDelayedTask(this.splegg, new SignDelay(sign, s), 40L);
} else {
Game game = this.splegg.games.getGame(map.getName());
sign = new String[]{splegg.getConfig().getString("Sings.Format.1").replaceAll("&", "�").replaceAll("%status%", this.getFancyStatus(game)).replaceAll("%map%", map.getName()).replaceAll("%count%/%maxcount%", this.getPlayers(game)), splegg.getConfig().getString("Sings.Format.2").replaceAll("&", "�").replaceAll("%status%", this.getFancyStatus(game)).replaceAll("%map%", map.getName()).replaceAll("%count%/%maxcount%", this.getPlayers(game)), splegg.getConfig().getString("Sings.Format.3").replaceAll("&", "�").replaceAll("%map%", map.getName()).replaceAll("%status%", this.getFancyStatus(game)).replaceAll("%count%/%maxcount%", this.getPlayers(game)), splegg.getConfig().getString("Sings.Format.4").replaceAll("&", "�").replaceAll("%count%/%maxcount%", this.getPlayers(game)).replaceAll("%status%", this.getFancyStatus(game)).replaceAll("%map%", map.getName())};
this.setSign(sign, s);
}
}
}
private String getPlayers(Game game) {
String players = "";
if (game.getStatus() == Status.DISABLED) {
players = "";
} else if (game.getMap().getSpawnCount() <= 1) {
players = "Players: " + game.getPlayers().size();
} else {
players = game.getPlayers().size() + "/" + game.getMap().getSpawnCount();
}
return players;
}
private void setSign(String[] lines, Sign s) {
for(int i = 0; i < lines.length; ++i) {
s.setLine(i, lines[i]);
}
s.update();
}
private String getFancyStatus(Game game) {
String status = "";
Status st = game.getStatus();
if (st == Status.LOBBY) {
if (game.isStarting()) {
status = splegg.getConfig().getString("Sings.Status.Join").replaceAll("&", "�");
} else {
status = splegg.getConfig().getString("Sings.Status.Join").replaceAll("&", "�");
}
} else if (st == Status.DISABLED) {
status = splegg.getConfig().getString("Sings.Status.Disabled").replaceAll("&", "�");
} else if (st == Status.INGAME) {
status = splegg.getConfig().getString("Sings.Status.Started").replaceAll("&", "�");
} else {
status = ChatColor.DARK_GREEN + st.toString().toLowerCase();
}
return status;
}
}
+56
View File
@@ -0,0 +1,56 @@
package signs;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import main.SpleggOG;
public class LobbySignUtils {
public static LobbySignUtils lsu = new LobbySignUtils();
public static LobbySignUtils get() {
return lsu;
}
public boolean isLobbySign(Location location, String name) {
String locString = this.locationToString(location);
List signLocs = SpleggOG.getPlugin().maps.c.maps.getStringList("Signs." + name + ".lobby");
return signLocs.contains(locString);
}
public String locationToString(Location l) {
String w = l.getWorld().getName();
int x = l.getBlockX();
int y = l.getBlockY();
int z = l.getBlockZ();
return w + "." + x + "." + y + "." + z;
}
public Location stringToLocation(String s) {
String[] str = s.split("\\.");
World w = Bukkit.getServer().getWorld(str[0]);
int x = Integer.parseInt(str[1]);
int y = Integer.parseInt(str[2]);
int z = Integer.parseInt(str[3]);
return new Location(w, (double)x, (double)y, (double)z);
}
public boolean compareLocations(Location one, Location two) {
String w = one.getWorld().getName();
int x = one.getBlockX();
int y = one.getBlockY();
int z = one.getBlockZ();
String checkw = two.getWorld().getName();
int checkx = two.getBlockX();
int checky = two.getBlockY();
int checkz = two.getBlockZ();
return w.equalsIgnoreCase(checkw) && x == checkx && y == checky && z == checkz;
}
}
+23
View File
@@ -0,0 +1,23 @@
package signs;
import org.bukkit.block.Sign;
public class SignDelay implements Runnable {
String[] data;
Sign sign;
public SignDelay(String[] data, Sign sign) {
this.data = data;
this.sign = sign;
}
public void run() {
for(int i = 0; i < this.data.length; ++i) {
this.sign.setLine(i, this.data[i]);
}
this.sign.update();
}
}
+66
View File
@@ -0,0 +1,66 @@
package utils;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class InvStore {
public Player player;
public ItemStack[] inv;
public ItemStack[] armour;
public double health;
public int fire;
public int food;
public int level;
public float exp;
public GameMode gamemode;
public InvStore(Player player) {
this.player = player;
this.exp = 0.0F;
this.level = 0;
this.health = 0.0D;
this.food = 0;
this.fire = 0;
this.armour = null;
this.inv = null;
}
public void load() {
this.player.getInventory().setContents(this.inv);
this.player.getInventory().setArmorContents(this.armour);
this.player.setExp(this.exp);
this.player.setLevel(this.level);
this.player.setHealthScale(this.health);
this.player.setFoodLevel(this.food);
this.player.setFireTicks(this.fire);
this.player.setGameMode(this.gamemode);
this.player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
this.player.updateInventory();
}
public void save() {
this.inv = this.player.getInventory().getContents();
this.armour = this.player.getInventory().getArmorContents();
this.exp = this.player.getExp();
this.level = this.player.getLevel();
this.food = this.player.getFoodLevel();
this.fire = this.player.getFireTicks();
this.health = this.player.getHealthScale();
this.gamemode = this.player.getGameMode();
this.player.updateInventory();
}
public void reset() {
this.exp = 0.0F;
this.level = 0;
this.health = 0.0D;
this.food = 0;
this.fire = 0;
this.gamemode = null;
this.armour = null;
this.inv = null;
}
}
+39
View File
@@ -0,0 +1,39 @@
package utils;
import org.bukkit.entity.Player;
public class SpleggPlayer {
Player player;
UtilPlayer u;
int kills;
int broken;
public SpleggPlayer(Player player, UtilPlayer u) {
this.player = player;
this.u = u;
this.kills = 0;
this.broken = 0;
}
public UtilPlayer getUtilPlayer() {
return this.u;
}
public Player getPlayer() {
return this.player;
}
public int getKills() {
return this.kills;
}
public void setKills(int i) {
this.kills = i;
}
public int getBroken() {
return this.broken;
}
}
+51
View File
@@ -0,0 +1,51 @@
package utils;
import org.bukkit.entity.Player;
import managers.Game;
public class UtilPlayer {
Player player;
String name;
boolean alive;
Game game;
InvStore store;
public UtilPlayer(Player player) {
this.player = player;
this.game = null;
this.name = player.getName();
this.alive = false;
this.store = new InvStore(player);
}
public InvStore getStore() {
return this.store;
}
public Player getPlayer() {
return this.player;
}
public String getName() {
return this.name;
}
public boolean isAlive() {
return this.alive;
}
public void setAlive(boolean a) {
this.alive = a;
}
public Game getGame() {
return this.game;
}
public void setGame(Game game) {
this.game = game;
}
}
+164
View File
@@ -0,0 +1,164 @@
package utils;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.potion.PotionEffect;
import main.SpleggOG;
import managers.Game;
public class Utils {
// Enable the conversion of text from config.yml to objects.
public FileConfiguration config = SpleggOG.getPlugin().getConfig();
private String prefix = config.getString("Messages.Prefix").replaceAll("&", "�");
public HashMap PLAYERS = new HashMap();
public FileConfiguration spawns;
private File f;
public String getPrefix() {
return this.prefix;
}
public void log(String s) {
Bukkit.getConsoleSender().sendMessage(this.prefix + s);
}
public void sendMessage(Player player, String s) {
player.sendMessage(this.prefix + ChatColor.translateAlternateColorCodes('&', s));
}
public void bc(String s) {
Bukkit.broadcastMessage(this.prefix + ChatColor.translateAlternateColorCodes('&', s));
}
public void bc(String string, Game game) {
Iterator var4 = SpleggOG.getPlugin().pm.PLAYERS.values().iterator();
while(var4.hasNext()) {
UtilPlayer u = (UtilPlayer)var4.next();
if (u.getGame() == game && u.isAlive()) {
this.sendMessage(u.getPlayer(), string);
}
}
}
public void bcNotForPlayer(Player player, String string, Game game) {
Iterator var5 = SpleggOG.getPlugin().pm.PLAYERS.values().iterator();
while(var5.hasNext()) {
UtilPlayer u = (UtilPlayer)var5.next();
if (u.getGame() == game && u.isAlive() && u.getPlayer() != player) {
this.sendMessage(u.getPlayer(), string);
}
}
}
public void setup() {
this.f = new File(SpleggOG.getPlugin().getDataFolder(), "spawns.yml");
try {
if (!this.f.exists()) {
this.f.createNewFile();
}
} catch (Exception var2) {
}
this.reloadSpawns();
this.saveSpawns();
this.reloadSpawns();
}
private void reloadSpawns() {
this.spawns = YamlConfiguration.loadConfiguration(this.f);
}
private void saveSpawns() {
try {
this.spawns.save(this.f);
} catch (IOException var2) {
}
}
public void setLobby(Location l) {
int x = l.getBlockX();
int y = l.getBlockY();
int z = l.getBlockZ();
float yaw = l.getYaw();
float pitch = l.getPitch();
String worldName = l.getWorld().getName();
this.spawns.set("Spawns.lobby.world", worldName);
this.spawns.set("Spawns.lobby.x", x);
this.spawns.set("Spawns.lobby.y", y);
this.spawns.set("Spawns.lobby.z", z);
this.spawns.set("Spawns.lobby.pitch", pitch);
this.spawns.set("Spawns.lobby.yaw", yaw);
this.saveSpawns();
}
public Location getLobby() {
int x = this.spawns.getInt("Spawns.lobby.x");
int y = this.spawns.getInt("Spawns.lobby.y");
int z = this.spawns.getInt("Spawns.lobby.z");
float yaw = (float)this.spawns.getInt("Spawns.lobby.yaw");
float pitch = (float)this.spawns.getInt("Spawns.lobby.pitch");
World worldName = Bukkit.getWorld(this.spawns.getString("Spawns.lobby.world"));
return new Location(worldName, (double)x + 0.5D, (double)y + 0.5D, (double)z + 0.5D, yaw, pitch);
}
public UtilPlayer getPlayer(String name) {
return (UtilPlayer)this.PLAYERS.get(name);
}
public UtilPlayer getPlayer(Player player) {
return (UtilPlayer)this.PLAYERS.get(player.getName());
}
public void clearInventory(Player player) {
PlayerInventory pInv = player.getInventory();
pInv.setArmorContents((ItemStack[])null);
pInv.clear();
player.setFireTicks(0);
this.clearPotions(player);
}
public void clearPotions(Player player) {
Iterator var3 = player.getActivePotionEffects().iterator();
while(var3.hasNext()) {
PotionEffect effect = (PotionEffect)var3.next();
player.removePotionEffect(effect.getType());
}
}
public static ItemStack getItem(Material material, int id, String name, String lore) {
ItemStack stack = new ItemStack(material, 1, (short)id);
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(name);
meta.setLore(Arrays.asList(lore));
stack.setItemMeta(meta);
return stack;
}
}
File renamed without changes.
+8
View File
@@ -0,0 +1,8 @@
name: Splegg-OG
main: main.SpleggOG
version: 1.0
authors: [Hraponssi, MrLuangamer, Theluangamer9416, NotAlexNoyle]
api-version: 1.18
depend: [Vault, WorldEdit]
commands:
splegg:
-119
View File
@@ -1,119 +0,0 @@
package me.mrluangamer;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import java.io.File;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import me.mrluangamer.commands.SpleggCommand;
import me.mrluangamer.config.MapUtilities;
import me.mrluangamer.events.Listeners;
import me.mrluangamer.events.MapListener;
import me.mrluangamer.events.PlayerListener;
import me.mrluangamer.events.SignListener;
import me.mrluangamer.events.SpleggEvents;
import me.mrluangamer.managers.Game;
import me.mrluangamer.managers.GameManager;
import me.mrluangamer.managers.GameUtilities;
import me.mrluangamer.managers.Status;
import me.mrluangamer.utils.UtilPlayer;
import me.mrluangamer.utils.Utils;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
public class Splegg extends JavaPlugin {
public Economy econ = null;
public Utils chat;
public MapUtilities maps;
public GameUtilities games;
public GameManager game;
public Utils pm;
public Utils utils;
public Utils config;
public boolean updateOut = false;
public String newVer = "";
public File updateFile = this.getFile();
public List special = Arrays.asList("Hraponssi, MrLuangamer, > Theluangamer9416");
public boolean disabling = false;
boolean economy = true;
public static Splegg getSplegg() {
return (Splegg)Bukkit.getPluginManager().getPlugin("Splegg");
}
private boolean setupEconomy() {
if (this.getServer().getPluginManager().getPlugin("Vault") == null) {
return false;
} else {
RegisteredServiceProvider rsp = this.getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
return false;
} else {
this.econ = (Economy)rsp.getProvider();
return this.econ != null;
}
}
}
public void onEnable() {
this.chat = new Utils(this);
if (this.getServer().getPluginManager().getPlugin("WorldEdit") == null) {
this.chat.log("WorldEdit not found! Please download it from http://dev.bukkit.org/bukkit-plugins/worldedit");
Bukkit.getPluginManager().disablePlugin(this);
} else {
this.maps = new MapUtilities();
this.games = new GameUtilities();
this.game = new GameManager(this);
this.pm = new Utils(this);
this.utils = new Utils(this);
this.config = new Utils(this);
this.maps.c.setup();
this.config.setup();
this.getConfig().options().copyDefaults(true);
this.saveConfig();
this.getServer().getPluginManager().registerEvents(new MapListener(this), this);
this.getServer().getPluginManager().registerEvents(new PlayerListener(), this);
this.getServer().getPluginManager().registerEvents(new SpleggEvents(), this);
this.getServer().getPluginManager().registerEvents(new SignListener(), this);
this.getServer().getPluginManager().registerEvents(new Listeners(), this);
this.getCommand("splegg").setExecutor(new SpleggCommand());
if (!this.setupEconomy()) {
this.getLogger().severe(String.format("[%s] - Disabled due to no Vault dependency found!", this.getDescription().getName()));
this.getServer().getPluginManager().disablePlugin(this);
} else {
for(Player p : Bukkit.getOnlinePlayers()) {
UtilPlayer u = new UtilPlayer(p);
this.pm.PLAYERS.put(p.getName(), u);
}
}
}
}
public void onDisable() {
this.disabling = true;
HandlerList.unregisterAll(new MapListener(this));
HandlerList.unregisterAll(new PlayerListener());
HandlerList.unregisterAll(new SpleggEvents());
HandlerList.unregisterAll(new SignListener());
HandlerList.unregisterAll(new Listeners());
Iterator var2 = this.games.GAMES.values().iterator();
while(var2.hasNext()) {
Game game = (Game)var2.next();
if (game.getStatus() == Status.INGAME) {
this.game.stopGame(game, 1);
}
}
}
public WorldEditPlugin getWorldEdit() {
Plugin worldEdit = this.getServer().getPluginManager().getPlugin("WorldEdit");
return worldEdit instanceof WorldEditPlugin ? (WorldEditPlugin)worldEdit : null;
}
}
@@ -1,280 +0,0 @@
package me.mrluangamer.commands;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.World;
import me.mrluangamer.Splegg;
import me.mrluangamer.config.Map;
import me.mrluangamer.managers.Game;
import me.mrluangamer.managers.Status;
import me.mrluangamer.utils.UtilPlayer;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class SpleggCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String tag, String[] args) {
if (sender instanceof Player) {
Player player = (Player)sender;
UtilPlayer u = Splegg.getSplegg().pm.getPlayer(player);
if (args.length == 0) {
Splegg.getSplegg().chat.sendMessage(player, "Plugin created by MrLuangamer, > Theluangamer9416 for more information /splegg help");
} else if (args.length == 1) {
if (args[0].equalsIgnoreCase("join")) {
if (player.hasPermission("splegg.join")) {
if (u.getGame() != null && u.isAlive()) {
Splegg.getSplegg().chat.sendMessage(player, "&cYou are already playing.");
} else if (this.lobbyset()) {
player.teleport(Splegg.getSplegg().config.getLobby());
} else {
Splegg.getSplegg().chat.sendMessage(player, "&cSplegg is incorrectly setup! Ask an admin to set the lobby.");
}
} else {
Splegg.getSplegg().chat.sendMessage(player, "&cYou do not have permission.");
}
} else if (args[0].equalsIgnoreCase("leave")) {
if (u.getGame() != null && u.isAlive()) {
Game game = u.getGame();
game.leaveGame(u);
Splegg.getSplegg().chat.sendMessage(player, Splegg.getSplegg().getConfig().getString("Messages.LeaveGame").replaceAll("&", "§").replaceAll("%map%", game.getMap().getName()));
}
} else if (args[0].equalsIgnoreCase("start")) {
if (player.hasPermission("splegg.admin")) {
if (u.getGame() == null) {
Splegg.getSplegg().chat.sendMessage(player, "&cYou are not in a game.");
} else if (u.getGame().getStatus() == Status.LOBBY) {
Splegg.getSplegg().game.startGame(u.getGame());
Splegg.getSplegg().chat.sendMessage(player, "&eGame started!");
} else if (u.getGame().getStatus() == Status.INGAME) {
Splegg.getSplegg().chat.sendMessage(player, "§cGame has already begun.");
}
} else {
Splegg.getSplegg().chat.sendMessage(player, "&cYou do not have permission.");
}
} else if (args[0].equalsIgnoreCase("stop")) {
if (player.hasPermission("splegg.admin")) {
if (u.getGame() == null) {
Splegg.getSplegg().chat.sendMessage(player, "&cYou are not in a game.");
} else if (u.getGame().getStatus() == Status.LOBBY) {
Splegg.getSplegg().chat.sendMessage(player, "&cGame has not begun yet!");
} else if (u.getGame().getStatus() == Status.INGAME) {
Splegg.getSplegg().chat.bc("&5" + player.getName() + "&6 has stopped the game.", u.getGame());
Splegg.getSplegg().game.stopGame(u.getGame(), 1);
Splegg.getSplegg().chat.sendMessage(player, "§eYou have stopped the game.");
}
} else {
Splegg.getSplegg().chat.sendMessage(player, "&cYou do not have permission.");
}
} else if (args[0].equalsIgnoreCase("setlobby")) {
if (player.hasPermission("splegg.admin")) {
Splegg.getSplegg().config.setLobby(player.getLocation());
Splegg.getSplegg().chat.sendMessage(player, "You have set splegg lobby.");
} else {
Splegg.getSplegg().chat.sendMessage(player, "&cYou do not have permission.");
}
} else if (!args[0].equalsIgnoreCase("")) {
Splegg.getSplegg().chat.sendMessage(player, "&cIncorrect Usage: &6/" + tag + " <join,leave,stop,start,setlobby,help>");
}
} else {
Map map;
String name;
if (args.length == 2) {
if (args[0].equalsIgnoreCase("create")) {
if (player.hasPermission("splegg.admin")) {
name = args[1];
if (Splegg.getSplegg().maps.mapExists(name)) {
Splegg.getSplegg().chat.sendMessage(player, "Map already exists.");
} else {
Splegg.getSplegg().maps.c.addMap(name);
Splegg.getSplegg().maps.addMap(name);
map = Splegg.getSplegg().maps.getMap(name);
Game game = new Game(Splegg.getSplegg(), map);
Splegg.getSplegg().games.addGame(map.getName(), game);
if (!map.isUsable()) {
game.setStatus(Status.DISABLED);
}
Splegg.getSplegg().chat.sendMessage(player, "Map has been added and created &c" + name + "&6.");
}
} else {
Splegg.getSplegg().chat.sendMessage(player, "&cYou do not have permission.");
}
} else if (args[0].equalsIgnoreCase("delete")) {
if (player.hasPermission("splegg.admin")) {
name = args[1];
if (Splegg.getSplegg().maps.mapExists(name)) {
Splegg.getSplegg().maps.deleteMap(name);
Splegg.getSplegg().chat.sendMessage(player, "Map has been deleted.");
} else {
Splegg.getSplegg().chat.sendMessage(player, "&cMap does not exist.");
}
} else {
Splegg.getSplegg().chat.sendMessage(player, "&cYou do not have permission.");
}
} else {
Game game;
if (args[0].equalsIgnoreCase("start")) {
if (player.hasPermission("splegg.admin")) {
name = args[1];
if (Splegg.getSplegg().maps.mapExists(name)) {
game = Splegg.getSplegg().games.getGame(name);
if (game == null) {
Splegg.getSplegg().chat.sendMessage(player, "&cYou are not in a game.");
} else if (game.getStatus() == Status.LOBBY) {
Splegg.getSplegg().game.startGame(game);
Splegg.getSplegg().chat.sendMessage(player, "&eStarting " + name + ".");
} else if (game.getStatus() == Status.INGAME) {
Splegg.getSplegg().chat.sendMessage(player, "§cGame has already begun.");
}
} else {
Splegg.getSplegg().chat.sendMessage(player, "&cMap does not exist.");
}
} else {
Splegg.getSplegg().chat.sendMessage(player, "&cYou do not have permission.");
}
} else if (args[0].equalsIgnoreCase("stop")) {
if (player.hasPermission("splegg.admin")) {
name = args[1];
if (Splegg.getSplegg().maps.mapExists(name)) {
game = Splegg.getSplegg().games.getGame(name);
if (game == null) {
Splegg.getSplegg().chat.sendMessage(player, "&cYou are not in a game.");
} else if (game.getStatus() == Status.LOBBY) {
Splegg.getSplegg().chat.sendMessage(player, "&cGame has not begun yet!");
} else if (game.getStatus() == Status.INGAME) {
Splegg.getSplegg().chat.bc("&5" + player.getName() + "&6 has stopped the game.", game);
Splegg.getSplegg().game.stopGame(game, 1);
Splegg.getSplegg().chat.sendMessage(player, "§eYou have stopped the game.");
}
} else {
Splegg.getSplegg().chat.sendMessage(player, "&cMap does not exist.");
}
} else {
Splegg.getSplegg().chat.sendMessage(player, "&cYou do not have permission.");
}
} else if (args[0].equalsIgnoreCase("setlobby")) {
if (player.hasPermission("splegg.admin")) {
name = args[1];
if (Splegg.getSplegg().maps.mapExists(name)) {
Splegg.getSplegg().maps.getMap(name).setLobby(player.getLocation());
Splegg.getSplegg().chat.sendMessage(player, "Lobby for map &e" + name + "&6 set.");
} else {
Splegg.getSplegg().chat.sendMessage(player, "&cMap does not exist.");
}
} else {
Splegg.getSplegg().chat.sendMessage(player, "&cYou do not have permission.");
}
} else if (args[0].equalsIgnoreCase("addfloor")) {
if (player.hasPermission("splegg.admin")) {
name = args[1];
if (Splegg.getSplegg().maps.mapExists(name)) {
map = Splegg.getSplegg().maps.getMap(name);
WorldEditPlugin we = Splegg.getSplegg().getWorldEdit();
Region sel = null;
try {
sel = we.getSession(player).getSelection(new BukkitWorld(player.getWorld()));
} catch (IncompleteRegionException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
}
if (sel == null) {
Splegg.getSplegg().chat.sendMessage(player, "&5Please select an area with worldedit.");
} else {
map.addFloor(new Location(player.getWorld(), sel.getMinimumPoint().getBlockX(), sel.getMinimumPoint().getBlockY(), sel.getMinimumPoint().getBlockZ()), new Location(player.getWorld(), sel.getMaximumPoint().getBlockX(), sel.getMaximumPoint().getBlockY(), sel.getMaximumPoint().getBlockZ()));
Splegg.getSplegg().chat.sendMessage(player, "Floor " + map.getFloors() + " added to map " + map.getName() + ".");
}
} else {
Splegg.getSplegg().chat.sendMessage(player, "&cMap does not exist.");
}
} else {
Splegg.getSplegg().chat.sendMessage(player, "&cYou do not have permission.");
}
} else if (args[0].equalsIgnoreCase("join")) {
if (player.hasPermission("splegg.join")) {
if (u.getGame() != null && u.isAlive()) {
Splegg.getSplegg().chat.sendMessage(player, "&cYou are already playing.");
} else {
name = args[1];
if (Splegg.getSplegg().maps.mapExists(name)) {
game = Splegg.getSplegg().games.getGame(name);
if (game != null && Splegg.getSplegg().maps.getMap(name).isUsable()) {
game.joinGame(u);
} else {
Splegg.getSplegg().chat.sendMessage(player, "This map is incorrectly setup - See console for detailed output.");
}
} else {
Splegg.getSplegg().chat.sendMessage(player, "&cMap does not exist.");
}
}
} else {
Splegg.getSplegg().chat.sendMessage(player, "&cYou do not have permission.");
}
} else if (args[0].equalsIgnoreCase("leave")) {
Splegg.getSplegg().chat.sendMessage(player, "Please use &e/" + tag + " leave");
} else if (args[0].equalsIgnoreCase("") && !args[1].equalsIgnoreCase("") && !args[1].equalsIgnoreCase("") && !args[1].equalsIgnoreCase("")) {
Splegg.getSplegg().chat.sendMessage(player, "Usage: /" + tag + " help <player|mod|admin>");
}
}
} else if (args.length == 3) {
if (args[0].equalsIgnoreCase("setspawn")) {
if (player.hasPermission("splegg.admin")) {
name = args[1];
if (Splegg.getSplegg().maps.mapExists(name)) {
map = Splegg.getSplegg().maps.getMap(name);
if (args[2].equalsIgnoreCase("next")) {
map.addSpawn(player.getLocation());
Splegg.getSplegg().chat.sendMessage(player, "Spawn &a" + map.getSpawnCount() + "&6 set for map &c" + map.getName() + "&6.");
} else {
try {
int id = Integer.parseInt(args[2]);
if (this.spawnset(id, map)) {
map.setSpawn(id, player.getLocation());
Splegg.getSplegg().chat.sendMessage(player, "You have re-set the spawn " + id + " for map " + name + ".");
} else {
Splegg.getSplegg().chat.sendMessage(player, "Please set the spawn using &e/" + tag + " setspawn <mapname> next &6then try this command again.");
}
} catch (NumberFormatException var11) {
Splegg.getSplegg().chat.sendMessage(player, "&cPlease type a number.");
}
}
} else {
Splegg.getSplegg().chat.sendMessage(player, "&cMap does not exist!");
}
} else {
Splegg.getSplegg().chat.sendMessage(player, "&cYou do not have permission.");
}
} else {
Splegg.getSplegg().chat.sendMessage(player, "Usage: &a/" + tag + " setspawn <mapname> <next|spawnid>");
}
} else {
Splegg.getSplegg().chat.sendMessage(player, "Incorrect Usage!");
}
}
}
return false;
}
boolean lobbyset() {
try {
Splegg.getSplegg().config.getLobby();
return true;
} catch (Exception var2) {
return false;
}
}
boolean spawnset(int i, Map map) {
return map.getConfig().isString("Spawns." + i + ".world");
}
public void sendUsage(Player player, String tag, String usage, String def) {
Splegg.getSplegg().chat.sendMessage(player, "&c/" + tag + " &d" + usage + " &5- &b" + def);
}
}
-233
View File
@@ -1,233 +0,0 @@
package me.mrluangamer.config;
import java.io.File;
import java.io.IOException;
import me.mrluangamer.Splegg;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
public class Map {
Splegg splegg;
String name;
File file;
private FileConfiguration config;
int spawncount;
int floorcount;
boolean usable;
public Map(Splegg plugin, String name) {
this.splegg = plugin;
this.name = name;
this.floorcount = 0;
this.spawncount = 0;
}
public void load() {
this.splegg.chat.log("Loading map " + this.name + ".");
this.usable = false;
this.file = new File(this.splegg.getDataFolder(), this.name + ".yml");
try {
if (!this.file.exists()) {
this.file.createNewFile();
}
} catch (IOException var2) {
}
this.setConfig(YamlConfiguration.loadConfiguration(this.file));
this.save();
this.loadSpawns();
this.loadFloors();
if (this.spawncount > 0) {
this.usable = true;
} else {
this.splegg.chat.log("Spawn count is 0");
this.usable = false;
}
if (this.floorcount > 0) {
this.usable = true;
} else {
this.splegg.chat.log("No floors are setup.");
this.usable = false;
}
if (this.usable) {
this.splegg.chat.log("Map is usable");
} else {
this.splegg.chat.log("--<>-- PLEASE SETUP MAP!! --<>--");
}
this.splegg.chat.log("Load Complete!");
}
public boolean isUsable() {
return this.usable;
}
public void delete() {
this.file.delete();
}
public void savenumbers() {
this.getConfig().set("Spawns.count", this.spawncount);
this.getConfig().set("Floors.count", this.floorcount);
}
public void save() {
try {
this.getConfig().save(this.file);
} catch (IOException var2) {
var2.printStackTrace();
}
}
public void setSpawn(int id, Location l) {
int x = l.getBlockX();
int y = l.getBlockY();
int z = l.getBlockZ();
float pitch = l.getPitch();
float yaw = l.getYaw();
String worldname = l.getWorld().getName();
this.getConfig().set("Spawns." + id + ".world", worldname);
this.getConfig().set("Spawns." + id + ".x", x);
this.getConfig().set("Spawns." + id + ".y", y);
this.getConfig().set("Spawns." + id + ".z", z);
this.getConfig().set("Spawns." + id + ".pitch", pitch);
this.getConfig().set("Spawns." + id + ".yaw", yaw);
this.save();
}
public Location getSpawn(int id) {
int x = this.getConfig().getInt("Spawns." + id + ".x");
int y = this.getConfig().getInt("Spawns." + id + ".y");
int z = this.getConfig().getInt("Spawns." + id + ".z");
float yaw = (float)this.getConfig().getInt("Spawns." + id + ".yaw");
float pitch = (float)this.getConfig().getInt("Spawns." + id + ".pitch");
World world = Bukkit.getWorld(this.getConfig().getString("Spawns." + id + ".world"));
return new Location(world, (double)x + 0.5D, (double)y + 0.5D, (double)z + 0.5D, yaw, pitch);
}
public void setSpec(Location l) {
int x = l.getBlockX();
int y = l.getBlockY();
int z = l.getBlockZ();
float pitch = l.getPitch();
float yaw = l.getYaw();
String worldname = l.getWorld().getName();
this.getConfig().set("Spec.world", worldname);
this.getConfig().set("Spec.x", x);
this.getConfig().set("Spec.y", y);
this.getConfig().set("Spec.z", z);
this.getConfig().set("Spec.pitch", pitch);
this.getConfig().set("Spec.yaw", yaw);
}
public Location getSpawnSpec() {
int x = this.getConfig().getInt("Spec.x");
int y = this.getConfig().getInt("Spec.y");
int z = this.getConfig().getInt("Spec.z");
float yaw = (float)this.getConfig().getInt("Spec.yaw");
float pitch = (float)this.getConfig().getInt("Spec.pitch");
World world = Bukkit.getWorld(this.getConfig().getString("Spec.world"));
return new Location(world, (double)x + 0.5D, (double)y + 0.5D, (double)z + 0.5D, yaw, pitch);
}
public String getName() {
return this.name;
}
public void loadSpawns() {
for(int a = 1; a <= this.getCount(); this.spawncount = a++) {
}
}
public void loadFloors() {
for(int a = 1; a <= this.getFloors(); this.floorcount = a++) {
}
}
public void addSpawn(Location l) {
++this.spawncount;
this.savenumbers();
this.setSpawn(this.spawncount, l);
}
public void addFloor(Location p1, Location p2) {
++this.floorcount;
this.savenumbers();
this.config.set("Floors." + this.floorcount + ".p1.x", p1.getBlockX());
this.config.set("Floors." + this.floorcount + ".p1.y", p1.getBlockY());
this.config.set("Floors." + this.floorcount + ".p1.z", p1.getBlockZ());
this.config.set("Floors." + this.floorcount + ".p1.world", p1.getWorld().getName());
this.config.set("Floors." + this.floorcount + ".p2.x", p2.getBlockX());
this.config.set("Floors." + this.floorcount + ".p2.y", p2.getBlockY());
this.config.set("Floors." + this.floorcount + ".p2.z", p2.getBlockZ());
this.config.set("Floors." + this.floorcount + ".p2.world", p2.getWorld().getName());
this.save();
}
public Location getFloor(int id, String pos) {
int x = this.config.getInt("Floors." + id + ".p" + pos + ".x");
int y = this.config.getInt("Floors." + id + ".p" + pos + ".y");
int z = this.config.getInt("Floors." + id + ".p" + pos + ".z");
String world = this.config.getString("Floors." + id + ".p" + pos + ".world");
return new Location(Bukkit.getWorld(world), (double)x, (double)y, (double)z);
}
public int getCount() {
return this.getConfig().getInt("Spawns.count");
}
public int getFloors() {
return this.getConfig().getInt("Floors.count");
}
public int getSpawnCount() {
return this.spawncount;
}
public FileConfiguration getConfig() {
return this.config;
}
public void setConfig(FileConfiguration config) {
this.config = config;
}
public boolean lobbySet() {
return this.getConfig().isString("Spawns.lobby.world");
}
public void setLobby(Location l) {
int x = l.getBlockX();
int y = l.getBlockY();
int z = l.getBlockZ();
float pitch = l.getPitch();
float yaw = l.getYaw();
String worldname = l.getWorld().getName();
this.getConfig().set("Spawns.lobby.world", worldname);
this.getConfig().set("Spawns.lobby.x", x);
this.getConfig().set("Spawns.lobby.y", y);
this.getConfig().set("Spawns.lobby.z", z);
this.getConfig().set("Spawns.lobby.pitch", pitch);
this.getConfig().set("Spawns.lobby.yaw", yaw);
this.save();
}
public Location getLobby() {
int x = this.getConfig().getInt("Spawns.lobby.x");
int y = this.getConfig().getInt("Spawns.lobby.y");
int z = this.getConfig().getInt("Spawns.lobby.z");
float yaw = (float)this.getConfig().getInt("Spawns.lobby.yaw");
float pitch = (float)this.getConfig().getInt("Spawns.lobby.pitch");
World world = Bukkit.getWorld(this.getConfig().getString("Spawns.lobby.world"));
return new Location(world, (double)x + 0.5D, (double)y + 0.5D, (double)z + 0.5D, yaw, pitch);
}
}
-89
View File
@@ -1,89 +0,0 @@
package me.mrluangamer.config;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import me.mrluangamer.Splegg;
import me.mrluangamer.managers.Game;
import me.mrluangamer.managers.Status;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
public class MapConfig {
public FileConfiguration maps;
public File f;
public void setup() {
this.f = new File(Splegg.getSplegg().getDataFolder(), "maps.yml");
try {
if (!this.f.exists()) {
this.f.createNewFile();
}
} catch (IOException var5) {
var5.printStackTrace();
}
this.loadMaps();
this.saveMaps();
Splegg.getSplegg().maps.MAPS.clear();
Iterator var2 = this.getEnabledMaps().iterator();
while(var2.hasNext()) {
String maps = (String)var2.next();
Splegg.getSplegg().maps.addMap(maps);
Map map = Splegg.getSplegg().maps.getMap(maps);
Game game = new Game(Splegg.getSplegg(), map);
Splegg.getSplegg().games.addGame(map.getName(), game);
if (!map.isUsable()) {
game.setStatus(Status.DISABLED);
}
}
}
private void loadMaps() {
this.maps = YamlConfiguration.loadConfiguration(this.f);
}
public void saveMaps() {
try {
this.maps.save(this.f);
} catch (IOException var2) {
}
}
public List getEnabledMaps() {
return this.maps.getStringList("maps");
}
public void addSign(String map, String loc) {
List signs = this.maps.getStringList("Signs." + map + ".lobby");
signs.add(loc);
this.maps.set("Signs." + map + ".lobby", signs);
this.saveMaps();
}
public void delSign(String map, String loc) {
List signs = this.maps.getStringList("Signs." + map + ".lobby");
signs.remove(loc);
this.maps.set("Signs." + map + ".lobby", signs);
this.saveMaps();
}
public void addMap(String name) {
List maps = this.maps.getStringList("maps");
maps.add(name);
this.maps.set("maps", maps);
this.saveMaps();
}
public void removeMap(String name) {
List maps = this.maps.getStringList("maps");
maps.remove(name);
this.maps.set("maps", maps);
this.saveMaps();
}
}
@@ -1,62 +0,0 @@
package me.mrluangamer.config;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Random;
import me.mrluangamer.Splegg;
import me.mrluangamer.managers.Game;
import me.mrluangamer.managers.Status;
public class MapUtilities {
public MapConfig c = new MapConfig();
public HashMap MAPS = new HashMap();
public void addMap(String name) {
Map map = new Map(Splegg.getSplegg(), name);
this.MAPS.put(name, map);
map.load();
}
public void deleteMap(String name) {
Map m = this.getMap(name);
Game game = Splegg.getSplegg().games.getGame(name);
if (game.getStatus() == Status.INGAME) {
Splegg.getSplegg().game.stopGame(game, 0);
}
Splegg.getSplegg().games.GAMES.remove(m.getName());
this.MAPS.remove(m);
this.c.removeMap(name);
m.delete();
}
public boolean mapExists(String name) {
return this.MAPS.containsKey(name);
}
public Collection getMaps() {
return this.MAPS.values();
}
public Map getMap(String name) {
return (Map)this.MAPS.get(name);
}
private Map getRandomMap() {
ArrayList all = new ArrayList();
Iterator var3 = this.MAPS.values().iterator();
while(var3.hasNext()) {
Map map = (Map)var3.next();
if (map.isUsable()) {
all.add(map);
}
}
Object[] mapsa = all.toArray();
Map randomMap = (Map)mapsa[(new Random()).nextInt(mapsa.length)];
return randomMap;
}
}
-175
View File
@@ -1,175 +0,0 @@
package me.mrluangamer.events;
import java.util.ArrayList;
import me.mrluangamer.Splegg;
import me.mrluangamer.utils.UtilPlayer;
import me.mrluangamer.utils.Utils;
import net.milkbowl.vault.economy.EconomyResponse;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Egg;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
public class Listeners implements Listener {
public static ArrayList manager = new ArrayList();
public static ArrayList moneymanager = new ArrayList();
public static ArrayList shopmanager = new ArrayList();
public static ArrayList diamondspade = new ArrayList();
public static ArrayList goldspade = new ArrayList();
public static ArrayList launchEggs = new ArrayList();
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
Player player = (Player)event.getWhoClicked();
UtilPlayer u = Splegg.getSplegg().pm.getPlayer(player);
ItemStack stack = event.getCurrentItem();
if (event.getView().getTitle().equals(Splegg.getSplegg().getConfig().getString("GUI.Shop.Title"))) {
if (shopmanager.contains(player.getName())) {
EconomyResponse r;
if (stack.getType() == Material.GOLDEN_SHOVEL) {
player.closeInventory();
if (Splegg.getSplegg().econ.getBalance(player.getName()) >= (double)Splegg.getSplegg().getConfig().getInt("GUI.Shop.GoldShovel.Price")) {
r = Splegg.getSplegg().econ.withdrawPlayer(player.getName(), (double)Splegg.getSplegg().getConfig().getInt("GUI.Shop.GoldShovel.Price"));
if (r.transactionSuccess()) {
goldspade.add(player.getName());
diamondspade.remove(player.getName());
shopmanager.remove(player.getName());
manager.remove(player.getName());
Splegg.getSplegg().chat.sendMessage(player, Splegg.getSplegg().getConfig().getString("Messages.BuyGoldShovel").replaceAll("&", "§"));
} else {
player.sendMessage(String.format("An error occured: %s", r.errorMessage));
shopmanager.add(player.getName());
manager.add(player.getName());
goldspade.remove(player.getName());
diamondspade.remove(player.getName());
}
} else {
Splegg.getSplegg().chat.sendMessage(player, Splegg.getSplegg().getConfig().getString("Messages.NoEnoughMoney").replaceAll("&", "§"));
}
}
if (stack.getType() == Material.DIAMOND_SHOVEL) {
player.closeInventory();
if (Splegg.getSplegg().econ.getBalance(player.getName()) >= (double)Splegg.getSplegg().getConfig().getInt("GUI.Shop.DiamondShovel.Price")) {
r = Splegg.getSplegg().econ.withdrawPlayer(player.getName(), (double)Splegg.getSplegg().getConfig().getInt("GUI.Shop.DiamondShovel.Price"));
if (r.transactionSuccess()) {
goldspade.remove(player.getName());
diamondspade.add(player.getName());
shopmanager.remove(player.getName());
manager.remove(player.getName());
Splegg.getSplegg().chat.sendMessage(player, Splegg.getSplegg().getConfig().getString("Messages.BuyDiamondShovel").replaceAll("&", "§"));
} else {
player.sendMessage(String.format("An error occured: %s", r.errorMessage));
shopmanager.add(player.getName());
manager.add(player.getName());
goldspade.remove(player.getName());
diamondspade.remove(player.getName());
}
} else {
Splegg.getSplegg().chat.sendMessage(player, Splegg.getSplegg().getConfig().getString("Messages.NoEnoughMoney").replaceAll("&", "§"));
}
}
} else {
Splegg.getSplegg().chat.sendMessage(player, Splegg.getSplegg().getConfig().getString("Messages.Haveyoueverbought").replaceAll("&", "§"));
player.closeInventory();
}
}
if (u.getGame() != null && u.isAlive()) {
event.setCancelled(true);
}
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
ItemStack hand = player.getItemInHand();
UtilPlayer u = Splegg.getSplegg().pm.getPlayer(player);
if (event.getAction() == Action.RIGHT_CLICK_AIR) {
if (hand.getType() == Material.IRON_SHOVEL && u.getGame() != null && u.isAlive() && launchEggs.contains(player.getName())) {
player.launchProjectile(Egg.class);
player.playSound(player.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1.0F, 1.0F);
}
Integer i;
if (hand.getType() == Material.GOLDEN_SHOVEL && u.getGame() != null && u.isAlive() && launchEggs.contains(player.getName())) {
for(i = 0; i < 2; i = i + 1) {
player.launchProjectile(Egg.class);
}
player.playSound(player.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1.0F, 1.0F);
}
if (hand.getType() == Material.DIAMOND_SHOVEL && u.getGame() != null && u.isAlive() && launchEggs.contains(player.getName())) {
for(i = 0; i < 3; i = i + 1) {
player.launchProjectile(Egg.class);
}
player.playSound(player.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1.0F, 1.0F);
}
if (hand.getType() == Material.COMPASS && u.getGame() != null && u.isAlive()) {
player.openInventory(this.getSpecInventory());
}
if (hand.getType() == Material.MAGMA_CREAM && u.getGame() != null && u.isAlive()) {
u.getGame().leaveGame(u);
}
if (hand.getType() == Material.getMaterial(Splegg.getSplegg().getConfig().getString("Shop.Item")) && u.getGame() != null && u.isAlive()) {
player.openInventory(this.getShopInventory());
}
}
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
manager.remove(player.getName());
shopmanager.remove(player.getName());
goldspade.remove(player.getName());
diamondspade.remove(player.getName());
launchEggs.remove(player.getName());
moneymanager.remove(player.getName());
}
@EventHandler
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
Player player = event.getPlayer();
UtilPlayer u = Splegg.getSplegg().pm.getPlayer(player);
if (u.getGame() != null && u.isAlive()) {
event.setCancelled(true);
}
}
@EventHandler
public void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
}
private Inventory getShopInventory() {
Inventory shop = Bukkit.createInventory((InventoryHolder)null, Splegg.getSplegg().getConfig().getInt("GUI.Shop.Size"), Splegg.getSplegg().getConfig().getString("GUI.Shop.Title"));
shop.setItem(0, Utils.getItem(Material.GOLDEN_SHOVEL, 0, Splegg.getSplegg().getConfig().getString("GUI.Shop.GoldShovel.Name").replaceAll("&", "§"), Splegg.getSplegg().getConfig().getString("GUI.Shop.GoldShovel.Description").replaceAll("&", "§").replaceAll("%price%", String.valueOf(Splegg.getSplegg().getConfig().getInt("GUI.Shop.GoldShovel.Price")))));
shop.setItem(1, Utils.getItem(Material.DIAMOND_SHOVEL, 0, Splegg.getSplegg().getConfig().getString("GUI.Shop.DiamondShovel.Name").replaceAll("&", "§"), Splegg.getSplegg().getConfig().getString("GUI.Shop.DiamondShovel.Description").replaceAll("&", "§").replaceAll("%price%", String.valueOf(Splegg.getSplegg().getConfig().getInt("GUI.Shop.DiamondShovel.Price")))));
return shop;
}
private Inventory getSpecInventory() {
Inventory spec = Bukkit.createInventory((InventoryHolder)null, 27, "Splegg - Spectators");
return spec;
}
}
@@ -1,48 +0,0 @@
package me.mrluangamer.events;
import me.mrluangamer.Splegg;
import me.mrluangamer.utils.UtilPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
public class MapListener implements Listener {
public Splegg splegg;
public MapListener(Splegg s) {
this.splegg = s;
}
@EventHandler
public void blockBreak(BlockBreakEvent e) {
Player player = e.getPlayer();
UtilPlayer u = this.splegg.pm.getPlayer(player);
if (u.getGame() != null && u.isAlive()) {
e.setCancelled(true);
}
}
@EventHandler
public void blockPlace(BlockPlaceEvent e) {
Player player = e.getPlayer();
UtilPlayer u = this.splegg.pm.getPlayer(player);
if (u.getGame() != null && u.isAlive()) {
e.setCancelled(true);
}
}
@EventHandler
public void hangingEntityBreak(HangingBreakByEntityEvent e) {
Player player = (Player)e.getRemover();
UtilPlayer u = this.splegg.pm.getPlayer(player);
if (u.getGame() != null && u.isAlive()) {
e.setCancelled(true);
}
}
}
@@ -1,83 +0,0 @@
package me.mrluangamer.events;
import me.mrluangamer.Splegg;
import me.mrluangamer.utils.UtilPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerListener implements Listener {
String[] cmds = new String[]{""};
@EventHandler
public void onFood(FoodLevelChangeEvent e) {
if (e.getEntity() instanceof Player) {
Player player = (Player)e.getEntity();
UtilPlayer u = Splegg.getSplegg().pm.getPlayer(player);
if (u.getGame() != null && u.isAlive()) {
e.setCancelled(true);
e.setFoodLevel(20);
}
}
}
@EventHandler
public void entityDamage(EntityDamageEvent e) {
Entity ent = e.getEntity();
if (ent instanceof Player) {
Player player = (Player)ent;
UtilPlayer u = Splegg.getSplegg().pm.getPlayer(player);
if (u.getGame() != null && u.isAlive()) {
e.setCancelled(true);
}
}
}
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player player = e.getPlayer();
UtilPlayer u = new UtilPlayer(player);
Splegg.getSplegg().pm.PLAYERS.put(player.getName(), u);
}
@EventHandler
public void onQuit(PlayerQuitEvent e) {
Player player = e.getPlayer();
UtilPlayer u = Splegg.getSplegg().pm.getPlayer(player);
if (u.getGame() != null && u.isAlive()) {
u.getGame().leaveGame(u);
}
Splegg.getSplegg().pm.PLAYERS.remove(player.getName());
}
@EventHandler
public void dropItem(PlayerDropItemEvent e) {
Player player = e.getPlayer();
UtilPlayer u = Splegg.getSplegg().pm.getPlayer(player);
if (u.getGame() != null && u.isAlive()) {
e.setCancelled(true);
}
}
@EventHandler
public void onCommand(PlayerCommandPreprocessEvent e) {
Player player = e.getPlayer();
UtilPlayer u = Splegg.getSplegg().pm.getPlayer(player);
if (u.getGame() != null && u.isAlive() && !e.getMessage().startsWith("/splegg") && !player.isOp() && !player.hasPermission("splegg.admin")) {
e.setCancelled(true);
Splegg.getSplegg().chat.sendMessage(player, "&eYou cannot use commands in &bSplegg");
}
}
}
@@ -1,99 +0,0 @@
package me.mrluangamer.events;
import me.mrluangamer.Splegg;
import me.mrluangamer.signs.LobbySign;
import me.mrluangamer.signs.LobbySignUtils;
import java.util.ArrayList;
import java.util.Collection;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
public class SignListener implements Listener {
@EventHandler(
priority = EventPriority.HIGHEST
)
public void signPlace(SignChangeEvent e) {
Player player = e.getPlayer();
if (e.getLine(0).equalsIgnoreCase("[splegg]") && e.getLine(1).equalsIgnoreCase("join") && player.hasPermission("splegg.admin")) {
String map = e.getLine(2);
if (Splegg.getSplegg().maps.mapExists(map)) {
LobbySign ls = new LobbySign(Splegg.getSplegg().maps.getMap(map), Splegg.getSplegg());
ls.create(e.getBlock().getLocation(), Splegg.getSplegg().maps.getMap(map));
Splegg.getSplegg().chat.sendMessage(player, Splegg.getSplegg().getConfig().getString("Messages.CreateSign").replaceAll("&", "§").replaceAll("%map%", map));
}
}
}
private static Collection<Material> signMaterials = new ArrayList<>();
static {
signMaterials.add(Material.ACACIA_SIGN);
signMaterials.add(Material.DARK_OAK_SIGN);
signMaterials.add(Material.OAK_SIGN);
signMaterials.add(Material.BIRCH_SIGN);
signMaterials.add(Material.SPRUCE_SIGN);
signMaterials.add(Material.JUNGLE_SIGN);
signMaterials.add(Material.CRIMSON_SIGN);
signMaterials.add(Material.WARPED_SIGN);
signMaterials.add(Material.ACACIA_WALL_SIGN);
signMaterials.add(Material.DARK_OAK_WALL_SIGN);
signMaterials.add(Material.OAK_WALL_SIGN);
signMaterials.add(Material.BIRCH_WALL_SIGN);
signMaterials.add(Material.SPRUCE_WALL_SIGN);
signMaterials.add(Material.JUNGLE_WALL_SIGN);
signMaterials.add(Material.CRIMSON_WALL_SIGN);
signMaterials.add(Material.WARPED_WALL_SIGN);
}
@EventHandler
public void onInteract(PlayerInteractEvent e) {
if (e.hasBlock() && signMaterials.contains(e.getClickedBlock().getType()) && e.getAction() == Action.RIGHT_CLICK_BLOCK) {
Sign s = (Sign)e.getClickedBlock().getState();
Player player = e.getPlayer();
if (s.getLine(0).equalsIgnoreCase(Splegg.getSplegg().getConfig().getString("Sings.Format.1").replaceAll("&", "§"))) {
String map = ChatColor.stripColor(s.getLine(2));
if (Splegg.getSplegg().maps.mapExists(map)) {
player.chat("/splegg join " + map);
player.updateInventory();
e.setCancelled(true);
} else {
Splegg.getSplegg().chat.sendMessage(player, Splegg.getSplegg().getConfig().getString("Messages.Mapnotexist").replaceAll("&", "§"));
e.setCancelled(true);
}
}
}
}
@EventHandler
public void signBreak(BlockBreakEvent e) {
Player player = e.getPlayer();
if(signMaterials.contains(e.getBlock().getType())) {
Sign s = (Sign)e.getBlock().getState();
String[] lines = s.getLines();
String map = ChatColor.stripColor(lines[1]);
if (LobbySignUtils.get().isLobbySign(e.getBlock().getLocation(), map)) {
if (player.hasPermission("splegg.admin")) {
LobbySign sign = new LobbySign(Splegg.getSplegg().maps.getMap(map), Splegg.getSplegg());
sign.delete(e.getBlock().getLocation());
Splegg.getSplegg().chat.sendMessage(player, Splegg.getSplegg().getConfig().getString("Messages.RemovedSign").replaceAll("&", "§").replaceAll("%map%", map));
} else {
e.setCancelled(true);
Splegg.getSplegg().chat.sendMessage(player, Splegg.getSplegg().getConfig().getString("Messages.NotBreakSign").replaceAll("&", "§"));
}
}
}
}
}
@@ -1,90 +0,0 @@
package me.mrluangamer.events;
import java.util.Iterator;
import me.mrluangamer.Splegg;
import me.mrluangamer.managers.Game;
import me.mrluangamer.managers.Status;
import me.mrluangamer.utils.UtilPlayer;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Egg;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerEggThrowEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.util.BlockIterator;
public class SpleggEvents implements Listener {
@EventHandler
public void eggLand(ProjectileHitEvent e) {
if (e.getEntity().getShooter() instanceof Player && e.getEntity() instanceof Egg) {
Player player = (Player)e.getEntity().getShooter();
UtilPlayer u = Splegg.getSplegg().pm.getPlayer(player);
if (u.getGame() != null && u.isAlive()) {
BlockIterator bi = new BlockIterator(e.getEntity().getWorld(), e.getEntity().getLocation().toVector(), e.getEntity().getVelocity().normalize(), 0.0D, 4);
Block hit = null;
while(bi.hasNext()) {
hit = bi.next();
if (hit.getType() != Material.AIR) {
break;
}
}
if (hit.getType() == Material.TNT) {
e.getEntity().getWorld().createExplosion(e.getEntity().getLocation(), 3.0F);
Iterator var7 = e.getEntity().getWorld().getEntities().iterator();
while(var7.hasNext()) {
Entity drop = (Entity)var7.next();
if (drop.getType() == EntityType.DROPPED_ITEM) {
drop.remove();
drop.remove();
drop.remove();
drop.remove();
drop.remove();
drop.remove();
}
}
}
if (u.getGame().getFloor().contains(hit.getLocation())) {
Game game = u.getGame();
if (game.getStatus() == Status.INGAME) {
hit.setType(Material.AIR);
}
}
}
}
}
@EventHandler
public void onKnockout(PlayerMoveEvent e) {
Player player = e.getPlayer();
UtilPlayer u = Splegg.getSplegg().pm.getPlayer(player);
if (u.getGame() != null && u.isAlive() && ((double)player.getLocation().getBlockY() < -5.0D || player.getLocation().getBlockY() < u.getGame().getLowestPossible()) && u.getGame().getStatus() == Status.INGAME) {
Splegg.getSplegg().chat.bc((Splegg.getSplegg().special.contains(player.getName()) ? "§4" : "§e") + Splegg.getSplegg().getConfig().getString("Messages.KnockoutPlayer").replaceAll("&", "§").replaceAll("%player%", player.getName()), u.getGame());
Splegg.getSplegg().chat.bc(Splegg.getSplegg().getConfig().getString("Messages.PlayersRemaining").replaceAll("&", "§").replaceAll("%count%", String.valueOf(u.getGame().getPlayers().size() - 1)), u.getGame());
player.setFallDistance(0.0F);
Listeners.launchEggs.remove(player.getName());
u.getGame().leaveGame(u);
player.setFallDistance(0.0F);
}
}
@EventHandler
public void eggHatch(PlayerEggThrowEvent e) {
Player player = e.getPlayer();
UtilPlayer u = Splegg.getSplegg().pm.getPlayer(player);
if (u.getGame() != null && u.isAlive()) {
e.setHatching(false);
}
}
}
@@ -1,136 +0,0 @@
package me.mrluangamer.managers;
import java.util.HashMap;
import java.util.Iterator;
import me.mrluangamer.Splegg;
import me.mrluangamer.config.Map;
import me.mrluangamer.events.Listeners;
import me.mrluangamer.utils.SpleggPlayer;
import me.mrluangamer.utils.Utils;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
public class GameManager {
Splegg splegg;
public GameManager(Splegg splegg) {
this.splegg = splegg;
}
public void startGame(Game game) {
this.splegg.chat.log("New game commencing..");
game.startGameTimer();
Bukkit.getScheduler().cancelTask(game.counter);
game.status = Status.INGAME;
game.time = 901;
game.setLobbyCount(31);
int c = 1;
game.loadFloors();
Map map = game.getMap();
Iterator var5 = game.players.values().iterator();
SpleggPlayer sp;
while(var5.hasNext()) {
sp = (SpleggPlayer)var5.next();
sp.getPlayer().setLevel(0);
sp.getUtilPlayer().setAlive(true);
if (c > map.getSpawnCount()) {
c = 1;
}
sp.getPlayer().teleport(map.getSpawn(c));
++c;
sp.getPlayer().setLevel(0);
sp.getPlayer().setExp(0.0F);
sp.getPlayer().setGameMode(GameMode.ADVENTURE);
if (!Listeners.manager.contains(sp.getPlayer().getName())) {
if (Listeners.goldspade.contains(sp.getPlayer().getName())) {
sp.getPlayer().getInventory().clear();
sp.getPlayer().getInventory().setItem(0, Utils.getItem(Material.GOLDEN_SHOVEL, 0, Splegg.getSplegg().getConfig().getString("Shovels.Gold.Name").replaceAll("&", "§"), Splegg.getSplegg().getConfig().getString("Shovels.Gold.Lore").replaceAll("&", "§")));
sp.getPlayer().updateInventory();
Listeners.manager.remove(sp.getPlayer().getName());
Listeners.goldspade.remove(sp.getPlayer().getName());
Listeners.diamondspade.remove(sp.getPlayer().getName());
Listeners.shopmanager.remove(sp.getPlayer().getName());
Listeners.moneymanager.add(sp.getPlayer().getName());
}
if (Listeners.diamondspade.contains(sp.getPlayer().getName())) {
sp.getPlayer().getInventory().clear();
sp.getPlayer().getInventory().setItem(0, Utils.getItem(Material.DIAMOND_SHOVEL, 0, Splegg.getSplegg().getConfig().getString("Shovels.Diamond.Name").replaceAll("&", "§"), Splegg.getSplegg().getConfig().getString("Shovels.Diamond.Lore").replaceAll("&", "§")));
sp.getPlayer().updateInventory();
Listeners.manager.remove(sp.getPlayer().getName());
Listeners.goldspade.remove(sp.getPlayer().getName());
Listeners.diamondspade.remove(sp.getPlayer().getName());
Listeners.shopmanager.remove(sp.getPlayer().getName());
Listeners.moneymanager.add(sp.getPlayer().getName());
}
} else {
sp.getPlayer().getInventory().clear();
sp.getPlayer().getInventory().setItem(0, Utils.getItem(Material.IRON_SHOVEL, 0, Splegg.getSplegg().getConfig().getString("Shovels.Iron.Name").replaceAll("&", "§"), Splegg.getSplegg().getConfig().getString("Shovels.Iron.Lore").replaceAll("&", "§")));
sp.getPlayer().updateInventory();
Listeners.manager.remove(sp.getPlayer().getName());
Listeners.goldspade.remove(sp.getPlayer().getName());
Listeners.diamondspade.remove(sp.getPlayer().getName());
Listeners.shopmanager.remove(sp.getPlayer().getName());
Listeners.moneymanager.add(sp.getPlayer().getName());
}
}
game.getSign().update(map, false);
this.splegg.chat.bc(this.splegg.getConfig().getString("Messages.InstructionsGame").replaceAll("&", "§"), game);
}
public void stopGame(Game game, int r) {
this.splegg.chat.log("Commencing shutdown of " + game.getMap().getName() + ".");
Iterator var4 = game.players.values().iterator();
while(var4.hasNext()) {
SpleggPlayer sp = (SpleggPlayer)var4.next();
Listeners.launchEggs.remove(sp.getPlayer().getName());
}
game.status = Status.ENDING;
game.stopGameTimer();
game.setLobbyCount(31);
game.time = 601;
game.setStatus(Status.LOBBY);
game.resetArena();
game.data.clear();
game.floor.clear();
game.setStarting(false);
HashMap h = new HashMap(game.players);
game.players.clear();
Iterator var5 = h.values().iterator();
while(var5.hasNext()) {
SpleggPlayer sp = (SpleggPlayer)var5.next();
game.leaveGame(sp.getUtilPlayer());
}
if (!this.splegg.disabling) {
game.getSign().update(game.map, true);
}
this.splegg.chat.log("Map " + game.map.getName() + " was reset.");
}
public String getDigitTime(int count) {
int minutes = count / 60;
int seconds = count % 60;
String disMinu = (minutes < 10 ? "0" : "") + minutes;
String disSec = (seconds < 10 ? "0" : "") + seconds;
String formattedTime = disMinu + ":" + disSec;
return formattedTime;
}
public void ingameTimer(int count, HashMap players) {
Iterator var4 = players.values().iterator();
while(var4.hasNext()) {
SpleggPlayer sp = (SpleggPlayer)var4.next();
this.splegg.chat.sendMessage(sp.getPlayer(), "Splegg is ending in §5§l" + this.splegg.game.getDigitTime(count));
}
}
}
@@ -1,90 +0,0 @@
package me.mrluangamer.managers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import me.mrluangamer.utils.SpleggPlayer;
import org.bukkit.entity.Player;
public class GameUtilities {
public HashMap GAMES = new HashMap();
public Game getGame(String map) {
return (Game)this.GAMES.get(map);
}
public void addGame(String map, Game game) {
this.GAMES.put(map, game);
}
public SpleggPlayer getPlayer(Player player) {
if (player == null) {
return null;
} else {
SpleggPlayer sp = null;
Iterator var4 = this.GAMES.values().iterator();
while(var4.hasNext()) {
Game games = (Game)var4.next();
Iterator var6 = games.players.values().iterator();
while(var6.hasNext()) {
SpleggPlayer sps = (SpleggPlayer)var6.next();
if (sps.getPlayer().getName().equalsIgnoreCase(player.getName())) {
sp = sps;
}
}
}
return sp;
}
}
public Game getMatchedGame(Player player) {
Game game = null;
Iterator var4 = this.GAMES.values().iterator();
while(var4.hasNext()) {
Game g = (Game)var4.next();
if (g.players.containsKey(player.getName())) {
game = g;
}
}
return game;
}
public int howManyOpenGames() {
ArrayList all = new ArrayList();
Iterator var3 = this.GAMES.values().iterator();
while(var3.hasNext()) {
Game games = (Game)var3.next();
if (games.getStatus() == Status.LOBBY) {
all.add(games);
}
}
return all.size();
}
public void checkWinner(Game game) {
if (game.players.size() <= 1) {
if (game.players.size() == 0) {
game.splegg.game.stopGame(game, 0);
} else {
String w = "";
Iterator var4 = game.players.values().iterator();
while(var4.hasNext()) {
SpleggPlayer sp = (SpleggPlayer)var4.next();
w = sp.getPlayer().getName();
game.leaveGame(sp.getUtilPlayer());
}
game.splegg.game.stopGame(game, 5);
}
}
}
}
-58
View File
@@ -1,58 +0,0 @@
package me.mrluangamer.managers;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
public class Rollback {
private String world;
private Material previd;
private Material newid;
private BlockData prevdata;
private BlockData newdata;
private int x;
private int y;
private int z;
public Rollback(String world, Material previd, BlockData prevdata, int x, int y, int z) {
this.world = world;
this.previd = previd;
this.prevdata = prevdata;
this.newid = Material.AIR;
this.newdata = null;
this.x = x;
this.y = y;
this.z = z;
}
public String getWorld() {
return this.world;
}
public BlockData getPrevdata() {
return this.prevdata;
}
public BlockData getNewdata() {
return this.newdata;
}
public Material getPrevid() {
return this.previd;
}
public Material getNewid() {
return this.newid;
}
public int getX() {
return this.x;
}
public int getY() {
return this.y;
}
public int getZ() {
return this.z;
}
}
-8
View File
@@ -1,8 +0,0 @@
package me.mrluangamer.managers;
public enum Status {
DISABLED,
LOBBY,
INGAME,
ENDING;
}
@@ -1,36 +0,0 @@
package me.mrluangamer.runnables;
import me.mrluangamer.Splegg;
import me.mrluangamer.managers.Game;
public class GameTime implements Runnable {
Splegg splegg;
Game game;
public GameTime(Splegg splegg, Game game) {
this.splegg = splegg;
this.game = game;
}
public void run() {
if (this.game.getCount() > 0) {
this.splegg.games.checkWinner(this.game);
if (this.game.getCount() % 300 == 0) {
this.splegg.game.ingameTimer(this.game.getCount(), this.game.getPlayers());
}
if (this.game.getCount() % 30 == 0 && this.game.getCount() < 60) {
this.splegg.game.ingameTimer(this.game.getCount(), this.game.getPlayers());
}
if (this.game.getCount() <= 5 && this.game.getCount() >= 1) {
this.splegg.chat.bc(Splegg.getSplegg().getConfig().getString("Messages.EndingTimer").replaceAll("&", "§").replaceAll("%timer%", String.valueOf(this.game.getCount())), this.game);
}
} else {
this.game.stopGameTimer();
this.splegg.chat.bc(Splegg.getSplegg().getConfig().getString("Messages.Timelimitreached"), this.game);
this.splegg.game.stopGame(this.game, 1);
}
}
}
@@ -1,67 +0,0 @@
package me.mrluangamer.runnables;
import java.util.Iterator;
import me.mrluangamer.Splegg;
import me.mrluangamer.managers.Game;
import me.mrluangamer.utils.SpleggPlayer;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
public class LobbyCountdown implements Runnable {
int lobbycount;
Game game;
public LobbyCountdown(Game game, int lobbycount) {
this.game = game;
this.lobbycount = lobbycount;
}
public void run() {
if (this.lobbycount >= 1) {
--this.lobbycount;
this.game.setLobbyCount(this.lobbycount);
Iterator var2 = this.game.getPlayers().values().iterator();
SpleggPlayer sp;
while(var2.hasNext()) {
sp = (SpleggPlayer)var2.next();
sp.getPlayer().setLevel(this.lobbycount);
sp.getPlayer().setExp((float)((double)this.game.getLobbyCount() * 0.008D));
}
this.game.getSign().update(this.game.getMap(), false);
if (this.lobbycount % 25 == 0) {
Splegg.getSplegg().chat.bc(Splegg.getSplegg().getConfig().getString("Messages.LobbyTimer").replaceAll("&", "§").replaceAll("%timer%", String.valueOf(this.lobbycount)), this.game);
}
if (this.lobbycount <= 10 && this.lobbycount >= 1) {
Splegg.getSplegg().chat.bc(Splegg.getSplegg().getConfig().getString("Messages.LobbyTimer").replaceAll("&", "§").replaceAll("%timer%", String.valueOf(this.lobbycount)), this.game);
var2 = this.game.getPlayers().values().iterator();
while(var2.hasNext()) {
sp = (SpleggPlayer)var2.next();
sp.getPlayer().playSound(sp.getPlayer().getLocation(), Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0F, 1.0F);
}
}
if (this.lobbycount <= 0) {
var2 = this.game.getPlayers().values().iterator();
while(var2.hasNext()) {
sp = (SpleggPlayer)var2.next();
}
}
} else if (this.game.getPlayers().size() > 1) {
Bukkit.getScheduler().cancelTask(this.game.getCounterID());
Splegg.getSplegg().game.startGame(this.game);
} else {
Splegg.getSplegg().chat.bc(Splegg.getSplegg().getConfig().getString("Messages.NoEnoughPlayers").replaceAll("&", "§"), this.game);
Bukkit.getScheduler().cancelTask(this.game.getCounterID());
this.game.setLobbyCount(31);
this.game.setStarting(false);
this.game.getSign().update(this.game.getMap(), false);
this.game.startCountdown();
}
}
}
-145
View File
@@ -1,145 +0,0 @@
package me.mrluangamer.signs;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import me.mrluangamer.Splegg;
import me.mrluangamer.config.Map;
import me.mrluangamer.managers.Game;
import me.mrluangamer.managers.Status;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Sign;
public class LobbySign {
Splegg splegg;
Map map;
public LobbySign(Map map, Splegg s) {
this.splegg = s;
this.map = map;
}
private static Collection<Material> signMaterials = new ArrayList<>();
static {
signMaterials.add(Material.ACACIA_SIGN);
signMaterials.add(Material.DARK_OAK_SIGN);
signMaterials.add(Material.OAK_SIGN);
signMaterials.add(Material.BIRCH_SIGN);
signMaterials.add(Material.SPRUCE_SIGN);
signMaterials.add(Material.JUNGLE_SIGN);
signMaterials.add(Material.CRIMSON_SIGN);
signMaterials.add(Material.WARPED_SIGN);
signMaterials.add(Material.ACACIA_WALL_SIGN);
signMaterials.add(Material.DARK_OAK_WALL_SIGN);
signMaterials.add(Material.OAK_WALL_SIGN);
signMaterials.add(Material.BIRCH_WALL_SIGN);
signMaterials.add(Material.SPRUCE_WALL_SIGN);
signMaterials.add(Material.JUNGLE_WALL_SIGN);
signMaterials.add(Material.CRIMSON_WALL_SIGN);
signMaterials.add(Material.WARPED_WALL_SIGN);
}
public void create(Location location, final Map map) {
String loc = LobbySignUtils.get().locationToString(location);
this.splegg.maps.c.addSign(map.getName(), loc);
if (this.map == null) {
this.map = map;
}
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this.splegg, new Runnable() {
public void run() {
LobbySign.this.update(map, true);
}
}, 5L);
}
public void delete(Location location) {
String loc = LobbySignUtils.get().locationToString(location);
this.splegg.maps.c.delSign(this.map.getName(), loc);
this.splegg.maps.c.saveMaps();
this.map = null;
}
public void update(Map map, boolean force) {
Iterator var4 = this.splegg.maps.c.maps.getStringList("Signs." + map.getName() + ".lobby").iterator();
while(var4.hasNext()) {
String loc = (String)var4.next();
Location location = LobbySignUtils.get().stringToLocation(loc);
if (!signMaterials.contains(location.getBlock().getType())) {
location.getBlock().setType(Material.OAK_WALL_SIGN);
}
Sign s = (Sign)location.getBlock().getState();
String[] sign;
if (force) {
String[] array = new String[]{Splegg.getSplegg().getConfig().getString("Sings.Restarting.1").replaceAll("&", "§").replaceAll("#", "â–ˆ"), Splegg.getSplegg().getConfig().getString("Sings.Restarting.2").replaceAll("&", "§"), Splegg.getSplegg().getConfig().getString("Sings.Restarting.3").replaceAll("&", "§").replaceAll("%map%", map.getName()), Splegg.getSplegg().getConfig().getString("Sings.Restarting.4").replaceAll("&", "§").replaceAll("#", "â–ˆ")};
this.setSign(array, s);
sign = new String[4];
Game game = this.splegg.games.getGame(map.getName());
if (game == null) {
sign[0] = "";
sign[1] = ChatColor.DARK_RED + "Please remove";
sign[2] = ChatColor.DARK_RED + "this sign";
sign[3] = "";
} else {
sign[0] = Splegg.getSplegg().getConfig().getString("Sings.Format.1").replaceAll("&", "§").replaceAll("%status%", this.getFancyStatus(game)).replaceAll("%map%", map.getName()).replaceAll("%count%/%maxcount%", this.getPlayers(game));
sign[1] = Splegg.getSplegg().getConfig().getString("Sings.Format.2").replaceAll("&", "§").replaceAll("%status%", this.getFancyStatus(game)).replaceAll("%map%", map.getName()).replaceAll("%count%/%maxcount%", this.getPlayers(game));
sign[2] = Splegg.getSplegg().getConfig().getString("Sings.Format.3").replaceAll("&", "§").replaceAll("%map%", map.getName()).replaceAll("%status%", this.getFancyStatus(game)).replaceAll("%count%/%maxcount%", this.getPlayers(game));
sign[3] = Splegg.getSplegg().getConfig().getString("Sings.Format.4").replaceAll("&", "§").replaceAll("%count%/%maxcount%", this.getPlayers(game)).replaceAll("%status%", this.getFancyStatus(game)).replaceAll("%map%", map.getName());
}
Bukkit.getScheduler().scheduleSyncDelayedTask(this.splegg, new SignDelay(sign, s), 40L);
} else {
Game game = this.splegg.games.getGame(map.getName());
sign = new String[]{Splegg.getSplegg().getConfig().getString("Sings.Format.1").replaceAll("&", "§").replaceAll("%status%", this.getFancyStatus(game)).replaceAll("%map%", map.getName()).replaceAll("%count%/%maxcount%", this.getPlayers(game)), Splegg.getSplegg().getConfig().getString("Sings.Format.2").replaceAll("&", "§").replaceAll("%status%", this.getFancyStatus(game)).replaceAll("%map%", map.getName()).replaceAll("%count%/%maxcount%", this.getPlayers(game)), Splegg.getSplegg().getConfig().getString("Sings.Format.3").replaceAll("&", "§").replaceAll("%map%", map.getName()).replaceAll("%status%", this.getFancyStatus(game)).replaceAll("%count%/%maxcount%", this.getPlayers(game)), Splegg.getSplegg().getConfig().getString("Sings.Format.4").replaceAll("&", "§").replaceAll("%count%/%maxcount%", this.getPlayers(game)).replaceAll("%status%", this.getFancyStatus(game)).replaceAll("%map%", map.getName())};
this.setSign(sign, s);
}
}
}
private String getPlayers(Game game) {
String players = "";
if (game.getStatus() == Status.DISABLED) {
players = "";
} else if (game.getMap().getSpawnCount() <= 1) {
players = "Players: " + game.getPlayers().size();
} else {
players = game.getPlayers().size() + "/" + game.getMap().getSpawnCount();
}
return players;
}
private void setSign(String[] lines, Sign s) {
for(int i = 0; i < lines.length; ++i) {
s.setLine(i, lines[i]);
}
s.update();
}
private String getFancyStatus(Game game) {
String status = "";
Status st = game.getStatus();
if (st == Status.LOBBY) {
if (game.isStarting()) {
status = Splegg.getSplegg().getConfig().getString("Sings.Status.Join").replaceAll("&", "§");
} else {
status = Splegg.getSplegg().getConfig().getString("Sings.Status.Join").replaceAll("&", "§");
}
} else if (st == Status.DISABLED) {
status = Splegg.getSplegg().getConfig().getString("Sings.Status.Disabled").replaceAll("&", "§");
} else if (st == Status.INGAME) {
status = Splegg.getSplegg().getConfig().getString("Sings.Status.Started").replaceAll("&", "§");
} else {
status = ChatColor.DARK_GREEN + st.toString().toLowerCase();
}
return status;
}
}
@@ -1,50 +0,0 @@
package me.mrluangamer.signs;
import java.util.List;
import me.mrluangamer.Splegg;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
public class LobbySignUtils {
public static LobbySignUtils lsu = new LobbySignUtils();
public static LobbySignUtils get() {
return lsu;
}
public boolean isLobbySign(Location location, String name) {
String locString = this.locationToString(location);
List signLocs = Splegg.getSplegg().maps.c.maps.getStringList("Signs." + name + ".lobby");
return signLocs.contains(locString);
}
public String locationToString(Location l) {
String w = l.getWorld().getName();
int x = l.getBlockX();
int y = l.getBlockY();
int z = l.getBlockZ();
return w + "." + x + "." + y + "." + z;
}
public Location stringToLocation(String s) {
String[] str = s.split("\\.");
World w = Bukkit.getServer().getWorld(str[0]);
int x = Integer.parseInt(str[1]);
int y = Integer.parseInt(str[2]);
int z = Integer.parseInt(str[3]);
return new Location(w, (double)x, (double)y, (double)z);
}
public boolean compareLocations(Location one, Location two) {
String w = one.getWorld().getName();
int x = one.getBlockX();
int y = one.getBlockY();
int z = one.getBlockZ();
String checkw = two.getWorld().getName();
int checkx = two.getBlockX();
int checky = two.getBlockY();
int checkz = two.getBlockZ();
return w.equalsIgnoreCase(checkw) && x == checkx && y == checky && z == checkz;
}
}
-21
View File
@@ -1,21 +0,0 @@
package me.mrluangamer.signs;
import org.bukkit.block.Sign;
public class SignDelay implements Runnable {
String[] data;
Sign sign;
public SignDelay(String[] data, Sign sign) {
this.data = data;
this.sign = sign;
}
public void run() {
for(int i = 0; i < this.data.length; ++i) {
this.sign.setLine(i, this.data[i]);
}
this.sign.update();
}
}
-65
View File
@@ -1,65 +0,0 @@
package me.mrluangamer.utils;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class InvStore {
public Player player;
public ItemStack[] inv;
public ItemStack[] armour;
public double health;
public int fire;
public int food;
public int level;
public float exp;
public GameMode gamemode;
public InvStore(Player player) {
this.player = player;
this.exp = 0.0F;
this.level = 0;
this.health = 0.0D;
this.food = 0;
this.fire = 0;
this.armour = null;
this.inv = null;
}
public void load() {
this.player.getInventory().setContents(this.inv);
this.player.getInventory().setArmorContents(this.armour);
this.player.setExp(this.exp);
this.player.setLevel(this.level);
this.player.setHealthScale(this.health);
this.player.setFoodLevel(this.food);
this.player.setFireTicks(this.fire);
this.player.setGameMode(this.gamemode);
this.player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
this.player.updateInventory();
}
public void save() {
this.inv = this.player.getInventory().getContents();
this.armour = this.player.getInventory().getArmorContents();
this.exp = this.player.getExp();
this.level = this.player.getLevel();
this.food = this.player.getFoodLevel();
this.fire = this.player.getFireTicks();
this.health = this.player.getHealthScale();
this.gamemode = this.player.getGameMode();
this.player.updateInventory();
}
public void reset() {
this.exp = 0.0F;
this.level = 0;
this.health = 0.0D;
this.food = 0;
this.fire = 0;
this.gamemode = null;
this.armour = null;
this.inv = null;
}
}
@@ -1,37 +0,0 @@
package me.mrluangamer.utils;
import org.bukkit.entity.Player;
public class SpleggPlayer {
Player player;
UtilPlayer u;
int kills;
int broken;
public SpleggPlayer(Player player, UtilPlayer u) {
this.player = player;
this.u = u;
this.kills = 0;
this.broken = 0;
}
public UtilPlayer getUtilPlayer() {
return this.u;
}
public Player getPlayer() {
return this.player;
}
public int getKills() {
return this.kills;
}
public void setKills(int i) {
this.kills = i;
}
public int getBroken() {
return this.broken;
}
}
-48
View File
@@ -1,48 +0,0 @@
package me.mrluangamer.utils;
import me.mrluangamer.managers.Game;
import org.bukkit.entity.Player;
public class UtilPlayer {
Player player;
String name;
boolean alive;
Game game;
InvStore store;
public UtilPlayer(Player player) {
this.player = player;
this.game = null;
this.name = player.getName();
this.alive = false;
this.store = new InvStore(player);
}
public InvStore getStore() {
return this.store;
}
public Player getPlayer() {
return this.player;
}
public String getName() {
return this.name;
}
public boolean isAlive() {
return this.alive;
}
public void setAlive(boolean a) {
this.alive = a;
}
public Game getGame() {
return this.game;
}
public void setGame(Game game) {
this.game = game;
}
}
-161
View File
@@ -1,161 +0,0 @@
package me.mrluangamer.utils;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import me.mrluangamer.Splegg;
import me.mrluangamer.managers.Game;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.potion.PotionEffect;
public class Utils {
Splegg splegg;
private String prefix = Splegg.getSplegg().getConfig().getString("Messages.Prefix").replaceAll("&", "§");
public HashMap PLAYERS = new HashMap();
public FileConfiguration spawns;
private File f;
public String getPrefix() {
return this.prefix;
}
public void log(String s) {
Bukkit.getConsoleSender().sendMessage(this.prefix + s);
}
public void sendMessage(Player player, String s) {
player.sendMessage(this.prefix + ChatColor.translateAlternateColorCodes('&', s));
}
public void bc(String s) {
Bukkit.broadcastMessage(this.prefix + ChatColor.translateAlternateColorCodes('&', s));
}
public void bc(String string, Game game) {
Iterator var4 = Splegg.getSplegg().pm.PLAYERS.values().iterator();
while(var4.hasNext()) {
UtilPlayer u = (UtilPlayer)var4.next();
if (u.getGame() == game && u.isAlive()) {
this.sendMessage(u.getPlayer(), string);
}
}
}
public void bcNotForPlayer(Player player, String string, Game game) {
Iterator var5 = Splegg.getSplegg().pm.PLAYERS.values().iterator();
while(var5.hasNext()) {
UtilPlayer u = (UtilPlayer)var5.next();
if (u.getGame() == game && u.isAlive() && u.getPlayer() != player) {
this.sendMessage(u.getPlayer(), string);
}
}
}
public Utils(Splegg s) {
this.splegg = s;
}
public void setup() {
this.f = new File(this.splegg.getDataFolder(), "spawns.yml");
try {
if (!this.f.exists()) {
this.f.createNewFile();
}
} catch (Exception var2) {
}
this.reloadSpawns();
this.saveSpawns();
this.reloadSpawns();
}
private void reloadSpawns() {
this.spawns = YamlConfiguration.loadConfiguration(this.f);
}
private void saveSpawns() {
try {
this.spawns.save(this.f);
} catch (IOException var2) {
}
}
public void setLobby(Location l) {
int x = l.getBlockX();
int y = l.getBlockY();
int z = l.getBlockZ();
float yaw = l.getYaw();
float pitch = l.getPitch();
String worldName = l.getWorld().getName();
this.spawns.set("Spawns.lobby.world", worldName);
this.spawns.set("Spawns.lobby.x", x);
this.spawns.set("Spawns.lobby.y", y);
this.spawns.set("Spawns.lobby.z", z);
this.spawns.set("Spawns.lobby.pitch", pitch);
this.spawns.set("Spawns.lobby.yaw", yaw);
this.saveSpawns();
}
public Location getLobby() {
int x = this.spawns.getInt("Spawns.lobby.x");
int y = this.spawns.getInt("Spawns.lobby.y");
int z = this.spawns.getInt("Spawns.lobby.z");
float yaw = (float)this.spawns.getInt("Spawns.lobby.yaw");
float pitch = (float)this.spawns.getInt("Spawns.lobby.pitch");
World worldName = Bukkit.getWorld(this.spawns.getString("Spawns.lobby.world"));
return new Location(worldName, (double)x + 0.5D, (double)y + 0.5D, (double)z + 0.5D, yaw, pitch);
}
public UtilPlayer getPlayer(String name) {
return (UtilPlayer)this.PLAYERS.get(name);
}
public UtilPlayer getPlayer(Player player) {
return (UtilPlayer)this.PLAYERS.get(player.getName());
}
public void clearInventory(Player player) {
PlayerInventory pInv = player.getInventory();
pInv.setArmorContents((ItemStack[])null);
pInv.clear();
player.setFireTicks(0);
this.clearPotions(player);
}
public void clearPotions(Player player) {
Iterator var3 = player.getActivePotionEffects().iterator();
while(var3.hasNext()) {
PotionEffect effect = (PotionEffect)var3.next();
player.removePotionEffect(effect.getType());
}
}
public static ItemStack getItem(Material material, int id, String name, String lore) {
ItemStack stack = new ItemStack(material, 1, (short)id);
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(name);
meta.setLore(Arrays.asList(lore));
stack.setItemMeta(meta);
return stack;
}
}