Compare commits
27 Commits
7ced598bfd
...
develop-ha
Author | SHA1 | Date | |
---|---|---|---|
13cc6c30b5 | |||
3dd41979f7 | |||
a4c46bc298 | |||
aaad777f9b | |||
c62c7cfd1a | |||
4575164e80 | |||
edf26785a3 | |||
4d90f5fc28 | |||
343decb05a | |||
36c6c93edb | |||
24af27f2e3 | |||
13132eace6 | |||
8d479b69e3 | |||
5ca8ad8bd7 | |||
3f2ba1e428 | |||
5bab1a1ac7 | |||
8fdd0487bf | |||
e0ee1e66c9 | |||
5acb44b0e1 | |||
7cd849946b | |||
a71aca5d6c | |||
ea08ac7a81 | |||
ee192c1035 | |||
81dbf16d3f | |||
f03011e4f1 | |||
9069ead9e9 | |||
cc371a9c12 |
@ -10,8 +10,6 @@ group 'eu.mhsl.minenet'
|
|||||||
version '1.0-SNAPSHOT'
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
//maven 'https://repo.unnamed.team/repository/unnamed-public/'
|
|
||||||
|
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
google()
|
google()
|
||||||
|
|
||||||
@ -46,7 +44,7 @@ dependencies {
|
|||||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
|
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
|
||||||
|
|
||||||
//https://jitpack.io/#Minestom/Minestom
|
//https://jitpack.io/#Minestom/Minestom
|
||||||
implementation 'net.minestom:minestom-snapshots:d707b0674f'
|
implementation 'net.minestom:minestom-snapshots:fd51c8d17a'
|
||||||
|
|
||||||
//Tools
|
//Tools
|
||||||
implementation 'de.articdive:jnoise:3.0.2'
|
implementation 'de.articdive:jnoise:3.0.2'
|
||||||
@ -55,11 +53,11 @@ dependencies {
|
|||||||
implementation 'org.spongepowered:configurate-yaml:4.1.2'
|
implementation 'org.spongepowered:configurate-yaml:4.1.2'
|
||||||
implementation 'com.sparkjava:spark-core:2.9.4'
|
implementation 'com.sparkjava:spark-core:2.9.4'
|
||||||
implementation 'com.google.code.gson:gson:2.10.1'
|
implementation 'com.google.code.gson:gson:2.10.1'
|
||||||
implementation 'com.google.guava:guava:32.0.0-android'
|
implementation 'com.google.guava:guava:32.0.1-android'
|
||||||
|
|
||||||
|
|
||||||
//PvP
|
//PvP
|
||||||
implementation 'com.github.TogAr2:MinestomPvP:04180ddf9a'
|
implementation 'io.github.TogAr2:MinestomPvP:PR62-SNAPSHOT'
|
||||||
|
|
||||||
// Hephaestus engine
|
// Hephaestus engine
|
||||||
implementation("team.unnamed:hephaestus-api:0.2.1-SNAPSHOT")
|
implementation("team.unnamed:hephaestus-api:0.2.1-SNAPSHOT")
|
||||||
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,7 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
56
gradlew
vendored
Normal file → Executable file
56
gradlew
vendored
Normal file → Executable file
@ -15,6 +15,8 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
@ -25,7 +27,7 @@
|
|||||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
# (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
|
# 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
|
# bash, then to run this script, type that shell name before the whole
|
||||||
# eu.mhsl.minenet.minigames.command line, like:
|
# command line, like:
|
||||||
#
|
#
|
||||||
# ksh Gradle
|
# ksh Gradle
|
||||||
#
|
#
|
||||||
@ -35,7 +37,7 @@
|
|||||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
# * compound commands having a testable exit status, especially «case»;
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
# * various built-in commands including «eu.mhsl.minenet.minigames.command», «set», and «ulimit».
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
#
|
#
|
||||||
# Important for patching:
|
# Important for patching:
|
||||||
#
|
#
|
||||||
@ -55,7 +57,7 @@
|
|||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (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
|
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
# within the Gradle project.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
@ -80,13 +82,12 @@ do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
APP_NAME="Gradle"
|
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
' "$PWD" ) || exit
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
@ -117,7 +118,7 @@ esac
|
|||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java eu.mhsl.minenet.minigames.command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
@ -133,29 +134,36 @@ location of your Java installation."
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD=java
|
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.
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
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
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
max*)
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
warn "Could not query maximum file descriptor limit"
|
warn "Could not query maximum file descriptor limit"
|
||||||
esac
|
esac
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
'' | soft) :;; #(
|
'' | soft) :;; #(
|
||||||
*)
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
ulimit -n "$MAX_FD" ||
|
ulimit -n "$MAX_FD" ||
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect all arguments for the java eu.mhsl.minenet.minigames.command, stacking in reverse order:
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
# * args from the eu.mhsl.minenet.minigames.command line
|
# * args from the command line
|
||||||
# * the main class name
|
# * the main class name
|
||||||
# * -classpath
|
# * -classpath
|
||||||
# * -D...appname settings
|
# * -D...appname settings
|
||||||
@ -193,11 +201,15 @@ if "$cygwin" || "$msys" ; then
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect all arguments for the java eu.mhsl.minenet.minigames.command;
|
|
||||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
# shell script including quotes and variable substitutions, so put them in
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
# double quotes to make sure that they get re-expanded; and
|
|
||||||
# * put everything else in single quotes, so that it's not re-expanded.
|
# Collect all arguments for the java command:
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
|
# and any embedded shellness will be escaped.
|
||||||
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
@ -205,6 +217,12 @@ set -- \
|
|||||||
org.gradle.wrapper.GradleWrapperMain \
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
# Use "xargs" to parse quoted args.
|
||||||
#
|
#
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
@ -214,7 +232,7 @@ set -- \
|
|||||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
# set -- "${ARGS[@]}" "$@"
|
# set -- "${ARGS[@]}" "$@"
|
||||||
#
|
#
|
||||||
# but POSIX shell has neither arrays nor eu.mhsl.minenet.minigames.command substitution, so instead we
|
# 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
|
# 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
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
# that process (while maintaining the separation between arguments), and wrap
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
39
gradlew.bat
vendored
39
gradlew.bat
vendored
@ -13,8 +13,10 @@
|
|||||||
@rem See the License for the specific language governing permissions and
|
@rem See the License for the specific language governing permissions and
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
@rem SPDX-License-Identifier: Apache-2.0
|
||||||
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
@ -25,7 +27,8 @@
|
|||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@ -40,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' eu.mhsl.minenet.gameList.command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
@ -56,16 +59,16 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the eu.mhsl.minenet.gameList.command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
@ -75,13 +78,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package eu.mhsl.minenet.minigames.command;
|
package eu.mhsl.minenet.minigames.command;
|
||||||
|
|
||||||
import eu.mhsl.minenet.minigames.command.anonymous.SkinCommand;
|
import eu.mhsl.minenet.minigames.command.privileged.SkinCommand;
|
||||||
import eu.mhsl.minenet.minigames.command.privileged.*;
|
import eu.mhsl.minenet.minigames.command.privileged.*;
|
||||||
import eu.mhsl.minenet.minigames.command.anonymous.HubCommand;
|
import eu.mhsl.minenet.minigames.command.anonymous.HubCommand;
|
||||||
import eu.mhsl.minenet.minigames.command.anonymous.LeaveCommand;
|
import eu.mhsl.minenet.minigames.command.anonymous.LeaveCommand;
|
||||||
@ -41,7 +41,7 @@ public enum Commands {
|
|||||||
static {
|
static {
|
||||||
MinecraftServer.getCommandManager().setUnknownCommandCallback((sender, command) -> {
|
MinecraftServer.getCommandManager().setUnknownCommandCallback((sender, command) -> {
|
||||||
if(command.isBlank()) return;
|
if(command.isBlank()) return;
|
||||||
new ChatMessage(Icon.ERROR).appendStatic("Unknown command").quote(command).send(sender);
|
new ChatMessage(Icon.ERROR).appendStatic("Unknown command: ").quote(command).send(sender);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,13 @@ public class HubCommand extends Command {
|
|||||||
public HubCommand() {
|
public HubCommand() {
|
||||||
super("hub");
|
super("hub");
|
||||||
|
|
||||||
setCondition((sender, commandString) -> ((Player) sender).getInstance() instanceof Room);
|
setCondition(
|
||||||
|
(sender, commandString) ->
|
||||||
|
((Player) sender).getInstance() instanceof Room room && !room.apiDriven
|
||||||
|
);
|
||||||
|
|
||||||
setDefaultExecutor((sender, context) -> {
|
setDefaultExecutor((sender, context) -> {
|
||||||
|
if(Room.getRoom((Player) sender).orElseThrow().apiDriven) return;
|
||||||
Room.unsetRoom((Player) sender);
|
Room.unsetRoom((Player) sender);
|
||||||
MoveInstance.move((Player) sender, Hub.INSTANCE);
|
MoveInstance.move((Player) sender, Hub.INSTANCE);
|
||||||
});
|
});
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package eu.mhsl.minenet.minigames.command.anonymous;
|
package eu.mhsl.minenet.minigames.command.privileged;
|
||||||
|
|
||||||
import net.minestom.server.command.builder.Command;
|
import eu.mhsl.minenet.minigames.command.PrivilegedCommand;
|
||||||
import net.minestom.server.command.builder.arguments.ArgumentType;
|
import net.minestom.server.command.builder.arguments.ArgumentType;
|
||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
import net.minestom.server.entity.PlayerSkin;
|
import net.minestom.server.entity.PlayerSkin;
|
||||||
|
|
||||||
public class SkinCommand extends Command {
|
public class SkinCommand extends PrivilegedCommand {
|
||||||
public SkinCommand() {
|
public SkinCommand() {
|
||||||
super("skin");
|
super("skin");
|
||||||
|
|
@ -11,6 +11,8 @@ import net.minestom.server.entity.Player;
|
|||||||
import eu.mhsl.minenet.minigames.instance.hub.Hub;
|
import eu.mhsl.minenet.minigames.instance.hub.Hub;
|
||||||
import net.minestom.server.event.EventListener;
|
import net.minestom.server.event.EventListener;
|
||||||
import net.minestom.server.event.player.AsyncPlayerConfigurationEvent;
|
import net.minestom.server.event.player.AsyncPlayerConfigurationEvent;
|
||||||
|
import net.minestom.server.network.packet.server.play.TeamsPacket;
|
||||||
|
import net.minestom.server.scoreboard.Team;
|
||||||
import net.minestom.server.timer.TaskSchedule;
|
import net.minestom.server.timer.TaskSchedule;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.serialize.SerializationException;
|
import org.spongepowered.configurate.serialize.SerializationException;
|
||||||
@ -20,6 +22,11 @@ import java.util.UUID;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class PlayerLoginHandler implements EventListener<AsyncPlayerConfigurationEvent> {
|
public class PlayerLoginHandler implements EventListener<AsyncPlayerConfigurationEvent> {
|
||||||
|
public static final Team globalTeam = MinecraftServer.getTeamManager()
|
||||||
|
.createBuilder("global")
|
||||||
|
.collisionRule(TeamsPacket.CollisionRule.NEVER)
|
||||||
|
.build();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Class<AsyncPlayerConfigurationEvent> eventType() {
|
public @NotNull Class<AsyncPlayerConfigurationEvent> eventType() {
|
||||||
return AsyncPlayerConfigurationEvent.class;
|
return AsyncPlayerConfigurationEvent.class;
|
||||||
@ -37,13 +44,14 @@ public class PlayerLoginHandler implements EventListener<AsyncPlayerConfiguratio
|
|||||||
|
|
||||||
MinecraftServer.getSchedulerManager().scheduleTask(
|
MinecraftServer.getSchedulerManager().scheduleTask(
|
||||||
() -> {
|
() -> {
|
||||||
|
p.setTeam(globalTeam);
|
||||||
if(pushQueue != null) {
|
if(pushQueue != null) {
|
||||||
Room.setRoom(p, Room.getRoom(pushQueue).orElseThrow());
|
Room.setRoom(p, Room.getRoom(pushQueue).orElseThrow());
|
||||||
} else {
|
} else {
|
||||||
MoveInstance.move(p, Hub.INSTANCE);
|
MoveInstance.move(p, Hub.INSTANCE);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
TaskSchedule.seconds(5),
|
TaskSchedule.seconds(1),
|
||||||
TaskSchedule.stop()
|
TaskSchedule.stop()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ import eu.mhsl.minenet.minigames.instance.Spawnable;
|
|||||||
import eu.mhsl.minenet.minigames.instance.room.Room;
|
import eu.mhsl.minenet.minigames.instance.room.Room;
|
||||||
import net.minestom.server.MinecraftServer;
|
import net.minestom.server.MinecraftServer;
|
||||||
import net.minestom.server.coordinate.Pos;
|
import net.minestom.server.coordinate.Pos;
|
||||||
import net.minestom.server.entity.GameMode;
|
|
||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
import net.minestom.server.event.item.ItemDropEvent;
|
import net.minestom.server.event.item.ItemDropEvent;
|
||||||
import net.minestom.server.event.player.PlayerBlockBreakEvent;
|
import net.minestom.server.event.player.PlayerBlockBreakEvent;
|
||||||
@ -43,7 +42,7 @@ public abstract class Game extends MineNetInstance implements Spawnable {
|
|||||||
|
|
||||||
MinecraftServer.getInstanceManager().registerInstance(this);
|
MinecraftServer.getInstanceManager().registerInstance(this);
|
||||||
|
|
||||||
logger = Logger.getLogger("Game:" + getUniqueId());
|
logger = Logger.getLogger("Game:" + getUuid());
|
||||||
|
|
||||||
eventNode()
|
eventNode()
|
||||||
.addListener(PlayerMoveEvent.class, this::onPlayerMove)
|
.addListener(PlayerMoveEvent.class, this::onPlayerMove)
|
||||||
@ -64,6 +63,17 @@ public abstract class Game extends MineNetInstance implements Spawnable {
|
|||||||
game.load();
|
game.load();
|
||||||
Room.getRoom(owner).orElseThrow().moveMembersToInstance(game);
|
Room.getRoom(owner).orElseThrow().moveMembersToInstance(game);
|
||||||
|
|
||||||
|
MinecraftServer.getSchedulerManager().scheduleTask(() -> {
|
||||||
|
game.getPlayers().forEach(player -> new ChatMessage(Icon.SCIENCE)
|
||||||
|
.appendStatic(factory.name().getAssembled(player).asComponent())
|
||||||
|
.newLine()
|
||||||
|
.appendStatic(factory.description().getAssembled(player).asComponent())
|
||||||
|
.send(player));
|
||||||
|
|
||||||
|
return TaskSchedule.stop();
|
||||||
|
}, TaskSchedule.seconds(3));
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
new ChatMessage(Icon.ERROR).appendStatic("Instance crashed: " + e.getMessage()).send(owner);
|
new ChatMessage(Icon.ERROR).appendStatic("Instance crashed: " + e.getMessage()).send(owner);
|
||||||
MinecraftServer.getSchedulerManager().scheduleNextTick(() -> Room.getRoom(owner).orElseThrow().moveMembersToRoomLobby());
|
MinecraftServer.getSchedulerManager().scheduleNextTick(() -> Room.getRoom(owner).orElseThrow().moveMembersToRoomLobby());
|
||||||
@ -99,15 +109,11 @@ public abstract class Game extends MineNetInstance implements Spawnable {
|
|||||||
public void unload() {
|
public void unload() {
|
||||||
this.onUnload();
|
this.onUnload();
|
||||||
|
|
||||||
getPlayers().forEach(player -> {
|
getPlayers().forEach(Room::setOwnRoom);
|
||||||
Room.setOwnRoom(player);
|
|
||||||
player.setGameMode(GameMode.SURVIVAL);
|
|
||||||
player.setInvisible(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
scheduler().scheduleTask(() -> {
|
scheduler().scheduleTask(() -> {
|
||||||
|
|
||||||
logger.info("stopping game instance " + this.uniqueId);
|
logger.info("stopping game instance " + this.uuid);
|
||||||
getPlayers().forEach(player -> player.kick("timeout"));
|
getPlayers().forEach(player -> player.kick("timeout"));
|
||||||
|
|
||||||
MinecraftServer.getInstanceManager().unregisterInstance(this);
|
MinecraftServer.getInstanceManager().unregisterInstance(this);
|
||||||
|
@ -8,29 +8,35 @@ import eu.mhsl.minenet.minigames.instance.game.stateless.types.backrooms.Backroo
|
|||||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.bedwars.BedwarsFactory;
|
import eu.mhsl.minenet.minigames.instance.game.stateless.types.bedwars.BedwarsFactory;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.acidRain.AcidRainFactory;
|
import eu.mhsl.minenet.minigames.instance.game.stateless.types.acidRain.AcidRainFactory;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.deathcube.DeathcubeFactory;
|
import eu.mhsl.minenet.minigames.instance.game.stateless.types.deathcube.DeathcubeFactory;
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.stateless.types.highGround.HighGroundFactory;
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.stateless.types.jumpDive.JumpDiveFactory;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.minerun.MinerunFactory;
|
import eu.mhsl.minenet.minigames.instance.game.stateless.types.minerun.MinerunFactory;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.spleef.SpleefFactory;
|
import eu.mhsl.minenet.minigames.instance.game.stateless.types.spleef.SpleefFactory;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.stickfight.StickFightFactory;
|
import eu.mhsl.minenet.minigames.instance.game.stateless.types.stickfight.StickFightFactory;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.tetris.TetrisFactory;
|
import eu.mhsl.minenet.minigames.instance.game.stateless.types.tetris.TetrisFactory;
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.stateless.types.sumo.SumoFactory;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.tntrun.TntRunFactory;
|
import eu.mhsl.minenet.minigames.instance.game.stateless.types.tntrun.TntRunFactory;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.towerdefense.TowerdefenseFactory;
|
import eu.mhsl.minenet.minigames.instance.game.stateless.types.towerdefense.TowerdefenseFactory;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.trafficlightrace.TrafficLightRaceFactory;
|
import eu.mhsl.minenet.minigames.instance.game.stateless.types.trafficlightrace.TrafficLightRaceFactory;
|
||||||
|
|
||||||
public enum GameList {
|
public enum GameList {
|
||||||
DEATHCUBE(new DeathcubeFactory(), GameType.JUMPNRUN),
|
DEATHCUBE(new DeathcubeFactory(), GameType.JUMPNRUN),
|
||||||
STICKFIGHT(new StickFightFactory(), GameType.PVP),
|
|
||||||
MINERUN(new MinerunFactory(), GameType.JUMPNRUN),
|
MINERUN(new MinerunFactory(), GameType.JUMPNRUN),
|
||||||
TRAFFICLIGHTRACE(new TrafficLightRaceFactory(), GameType.OTHER),
|
TRAFFICLIGHTRACE(new TrafficLightRaceFactory(), GameType.OTHER),
|
||||||
|
STICKFIGHT(new StickFightFactory(), GameType.PROTOTYPE),
|
||||||
TOWERDEFENSE(new TowerdefenseFactory(), GameType.PROTOTYPE),
|
TOWERDEFENSE(new TowerdefenseFactory(), GameType.PROTOTYPE),
|
||||||
BEDWARS(new BedwarsFactory(), GameType.PROTOTYPE),
|
BEDWARS(new BedwarsFactory(), GameType.PROTOTYPE),
|
||||||
BACKROOMS(new BackroomsFactory(), GameType.PROTOTYPE),
|
BACKROOMS(new BackroomsFactory(), GameType.PROTOTYPE),
|
||||||
ANVILRUN(new AnvilRunFactory(), GameType.PROTOTYPE),
|
BOWSPLEEF(new BowSpleefFactory(), GameType.PROTOTYPE),
|
||||||
TETRIS(new TetrisFactory(), GameType.OTHER),
|
TETRIS(new TetrisFactory(), GameType.OTHER),
|
||||||
TNTRUN(new TntRunFactory(), GameType.OTHER),
|
TNTRUN(new TntRunFactory(), GameType.OTHER),
|
||||||
|
ANVILRUN(new AnvilRunFactory(), GameType.PVE),
|
||||||
ACIDRAIN(new AcidRainFactory(), GameType.PVE),
|
ACIDRAIN(new AcidRainFactory(), GameType.PVE),
|
||||||
ELYTRARACE(new ElytraRaceFactory(), GameType.PVP),
|
ELYTRARACE(new ElytraRaceFactory(), GameType.PVP),
|
||||||
SPLEEF(new SpleefFactory(), GameType.PVP),
|
SPLEEF(new SpleefFactory(), GameType.PVP),
|
||||||
BOWSPLEEF(new BowSpleefFactory(), GameType.PVP);
|
JUMPDIVE(new JumpDiveFactory(), GameType.JUMPNRUN),
|
||||||
|
SUMO(new SumoFactory(), GameType.PVP),
|
||||||
|
HIGHGROUND(new HighGroundFactory(), GameType.PVP);
|
||||||
|
|
||||||
private final GameFactory factory;
|
private final GameFactory factory;
|
||||||
private final GameType type;
|
private final GameType type;
|
||||||
@ -43,6 +49,6 @@ public enum GameList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public GameType getType() {
|
public GameType getType() {
|
||||||
return type;
|
return this.type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import net.kyori.adventure.text.Component;
|
|||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.minestom.server.registry.DynamicRegistry;
|
import net.minestom.server.registry.DynamicRegistry;
|
||||||
import net.minestom.server.timer.ExecutionType;
|
import net.minestom.server.timer.ExecutionType;
|
||||||
|
import net.minestom.server.timer.Task;
|
||||||
import net.minestom.server.timer.TaskSchedule;
|
import net.minestom.server.timer.TaskSchedule;
|
||||||
import net.minestom.server.world.DimensionType;
|
import net.minestom.server.world.DimensionType;
|
||||||
|
|
||||||
@ -20,6 +21,7 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
public class StatelessGame extends Game {
|
public class StatelessGame extends Game {
|
||||||
private final String name;
|
private final String name;
|
||||||
private final Score score;
|
private final Score score;
|
||||||
|
private Task timeLimitTask;
|
||||||
|
|
||||||
private int timeLimit = 0;
|
private int timeLimit = 0;
|
||||||
private int timePlayed = 0;
|
private int timePlayed = 0;
|
||||||
@ -40,8 +42,12 @@ public class StatelessGame extends Game {
|
|||||||
|
|
||||||
public void setTimeLimit(int limit) {
|
public void setTimeLimit(int limit) {
|
||||||
this.timeLimit = limit;
|
this.timeLimit = limit;
|
||||||
if(timeLimit > 0) {
|
if(this.timeLimitTask != null) {
|
||||||
scheduler().submitTask(() -> {
|
this.timeLimitTask.cancel();
|
||||||
|
this.timePlayed = 0;
|
||||||
|
}
|
||||||
|
if(this.timeLimit > 0) {
|
||||||
|
this.timeLimitTask = scheduler().submitTask(() -> {
|
||||||
if(!isRunning || timeLimit == 0) return TaskSchedule.stop();
|
if(!isRunning || timeLimit == 0) return TaskSchedule.stop();
|
||||||
if(timeLimit <= timePlayed) {
|
if(timeLimit <= timePlayed) {
|
||||||
stop();
|
stop();
|
||||||
|
@ -15,6 +15,11 @@ public class AcidRainFactory implements GameFactory {
|
|||||||
return TranslatedComponent.byId("game_AcidRain#name");
|
return TranslatedComponent.byId("game_AcidRain#name");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TranslatedComponent description() {
|
||||||
|
return TranslatedComponent.byId("game_AcidRain#description");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Material symbol() {
|
public Material symbol() {
|
||||||
return Material.SLIME_BALL;
|
return Material.SLIME_BALL;
|
||||||
|
@ -26,7 +26,7 @@ public class AnvilRunFactory implements GameFactory {
|
|||||||
public ConfigManager configuration() {
|
public ConfigManager configuration() {
|
||||||
return new ConfigManager()
|
return new ConfigManager()
|
||||||
.addOption(new NumericOption("radius", Material.HEART_OF_THE_SEA, TranslatedComponent.byId("optionCommon#radius"), 5, 10, 15, 20, 25, 30))
|
.addOption(new NumericOption("radius", Material.HEART_OF_THE_SEA, TranslatedComponent.byId("optionCommon#radius"), 5, 10, 15, 20, 25, 30))
|
||||||
.addOption(new NumericOption("seconds", Material.STICK, TranslatedComponent.byId("optionCommon#seconds"), 10, 30, 60, 90, 120));
|
.addOption(new NumericOption("seconds", Material.CLOCK, TranslatedComponent.byId("optionCommon#seconds"), 10, 30, 60, 90, 120));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -12,7 +12,12 @@ import java.util.Map;
|
|||||||
public class BowSpleefFactory implements GameFactory {
|
public class BowSpleefFactory implements GameFactory {
|
||||||
@Override
|
@Override
|
||||||
public TranslatedComponent name() {
|
public TranslatedComponent name() {
|
||||||
return TranslatedComponent.byId("");
|
return TranslatedComponent.byId("game_BowSpleef#name");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TranslatedComponent description() {
|
||||||
|
return TranslatedComponent.byId("game_BowSpleef#description");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -8,6 +8,7 @@ import eu.mhsl.minenet.minigames.world.BlockPallet;
|
|||||||
import eu.mhsl.minenet.minigames.world.generator.terrain.CircularPlateTerrainGenerator;
|
import eu.mhsl.minenet.minigames.world.generator.terrain.CircularPlateTerrainGenerator;
|
||||||
import io.github.togar2.pvp.feature.CombatFeatures;
|
import io.github.togar2.pvp.feature.CombatFeatures;
|
||||||
import net.minestom.server.coordinate.Pos;
|
import net.minestom.server.coordinate.Pos;
|
||||||
|
import net.minestom.server.entity.Player;
|
||||||
import net.minestom.server.event.player.PlayerMoveEvent;
|
import net.minestom.server.event.player.PlayerMoveEvent;
|
||||||
import net.minestom.server.instance.batch.AbsoluteBlockBatch;
|
import net.minestom.server.instance.batch.AbsoluteBlockBatch;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
@ -169,6 +169,7 @@ public class ElytraRace extends StatelessGame {
|
|||||||
if(newPos.z() > ringCount * ringSpacing) {
|
if(newPos.z() > ringCount * ringSpacing) {
|
||||||
getScore().insertResult(player);
|
getScore().insertResult(player);
|
||||||
player.setGameMode(GameMode.SPECTATOR);
|
player.setGameMode(GameMode.SPECTATOR);
|
||||||
|
player.setFlyingWithElytra(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,12 @@ import java.util.Map;
|
|||||||
public class ElytraRaceFactory implements GameFactory {
|
public class ElytraRaceFactory implements GameFactory {
|
||||||
@Override
|
@Override
|
||||||
public TranslatedComponent name() {
|
public TranslatedComponent name() {
|
||||||
return TranslatedComponent.byId("");
|
return TranslatedComponent.byId("game_ElytraRace#name");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TranslatedComponent description() {
|
||||||
|
return TranslatedComponent.byId("game_ElytraRace#description");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -25,7 +30,7 @@ public class ElytraRaceFactory implements GameFactory {
|
|||||||
@Override
|
@Override
|
||||||
public ConfigManager configuration() {
|
public ConfigManager configuration() {
|
||||||
return new ConfigManager()
|
return new ConfigManager()
|
||||||
.addOption(new NumericOption("ringCount", Material.DIAMOND_BLOCK, TranslatedComponent.byId("ringCount"), 5, 10, 20, 30, 40, 50));
|
.addOption(new NumericOption("ringCount", Material.DIAMOND_BLOCK, TranslatedComponent.byId("game_ElytraRace#ringCount"), 5, 10, 20, 30, 40, 50));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,126 @@
|
|||||||
|
package eu.mhsl.minenet.minigames.instance.game.stateless.types.highGround;
|
||||||
|
|
||||||
|
import eu.mhsl.minenet.minigames.instance.Dimension;
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame;
|
||||||
|
import eu.mhsl.minenet.minigames.score.PointsWinScore;
|
||||||
|
import eu.mhsl.minenet.minigames.world.BlockPallet;
|
||||||
|
import io.github.togar2.pvp.events.EntityKnockbackEvent;
|
||||||
|
import io.github.togar2.pvp.events.FinalAttackEvent;
|
||||||
|
import io.github.togar2.pvp.events.PrepareAttackEvent;
|
||||||
|
import io.github.togar2.pvp.feature.CombatFeatures;
|
||||||
|
import net.minestom.server.coordinate.Pos;
|
||||||
|
import net.minestom.server.entity.Player;
|
||||||
|
import net.minestom.server.event.instance.InstanceTickEvent;
|
||||||
|
import net.minestom.server.event.player.PlayerMoveEvent;
|
||||||
|
import net.minestom.server.instance.block.Block;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.WeakHashMap;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
class HighGround extends StatelessGame {
|
||||||
|
private final int radius;
|
||||||
|
private final int seconds;
|
||||||
|
private final WeakHashMap<Player, Integer> scoreMap = new WeakHashMap<>();
|
||||||
|
|
||||||
|
HighGround(int radius, int seconds) {
|
||||||
|
super(Dimension.THE_END.key, "highground", new PointsWinScore());
|
||||||
|
this.radius = radius;
|
||||||
|
this.seconds = seconds;
|
||||||
|
|
||||||
|
this.eventNode().addChild(
|
||||||
|
CombatFeatures.empty()
|
||||||
|
.add(CombatFeatures.VANILLA_ATTACK)
|
||||||
|
.add(CombatFeatures.VANILLA_DAMAGE)
|
||||||
|
.add(CombatFeatures.VANILLA_KNOCKBACK)
|
||||||
|
.build()
|
||||||
|
.createNode()
|
||||||
|
);
|
||||||
|
|
||||||
|
this.eventNode().addListener(
|
||||||
|
FinalAttackEvent.class,
|
||||||
|
finalAttackEvent -> finalAttackEvent.setBaseDamage(0)
|
||||||
|
);
|
||||||
|
|
||||||
|
this.eventNode().addListener(PrepareAttackEvent.class, prepareAttackEvent -> {
|
||||||
|
if(this.isBeforeBeginning){
|
||||||
|
prepareAttackEvent.setCancelled(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.eventNode().addListener(
|
||||||
|
EntityKnockbackEvent.class,
|
||||||
|
entityKnockbackEvent -> entityKnockbackEvent.setStrength(1.1f)
|
||||||
|
);
|
||||||
|
|
||||||
|
this.eventNode().addListener(InstanceTickEvent.class, instanceTickEvent -> {
|
||||||
|
if (this.isBeforeBeginning || !this.isRunning) return;
|
||||||
|
this.getPlayers().forEach(player -> {
|
||||||
|
if((player.isOnGround() && player.getPosition().y() >= 1) || (!player.isOnGround() && player.getPosition().y() >= 1.5)){
|
||||||
|
this.scoreMap.put(player, this.scoreMap.get(player) + 1);
|
||||||
|
player.setLevel(this.scoreMap.get(player) / 20);
|
||||||
|
player.setExp((this.scoreMap.get(player) % 20) / 20.0f);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onLoad(@NotNull CompletableFuture<Void> callback) {
|
||||||
|
for (int y = 0; y >= -3; y--) {
|
||||||
|
int radius = (Math.abs(y) * 5) + this.radius;
|
||||||
|
for (int x = -radius; x <= radius; x++) {
|
||||||
|
for (int z = -radius; z <= radius; z++) {
|
||||||
|
double distance = new Pos(x, 0, z).distance(0, 0, 0);
|
||||||
|
if (distance <= radius) {
|
||||||
|
this.setBlock(x, y, z, y == 0 ? Block.DIAMOND_BLOCK : Block.GRASS_BLOCK);
|
||||||
|
Pos featurePosition = new Pos(x, y + 1, z);
|
||||||
|
|
||||||
|
if(y >= 0 || this.getBlock(featurePosition).isSolid()) continue;
|
||||||
|
if (this.rnd.nextDouble() < 0.1){
|
||||||
|
this.setBlock(featurePosition, Block.SHORT_GRASS);
|
||||||
|
}
|
||||||
|
if (this.rnd.nextDouble() < 0.01){
|
||||||
|
this.setBlock(featurePosition, BlockPallet.FLOWER.rnd());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPlayerMove(@NotNull PlayerMoveEvent playerMoveEvent) {
|
||||||
|
Player player = playerMoveEvent.getPlayer();
|
||||||
|
if(playerMoveEvent.getNewPosition().y() < -10){
|
||||||
|
player.teleport(this.getSpawn());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void start() {
|
||||||
|
this.getPlayers().forEach(player -> this.scoreMap.put(player, 0));
|
||||||
|
super.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart() {
|
||||||
|
this.setTimeLimit(this.seconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop() {
|
||||||
|
this.getPlayers().forEach(player -> this.getScore().insertResult(player, this.scoreMap.get(player)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Pos getSpawn() {
|
||||||
|
double theta = this.rnd.nextDouble() * 2 * Math.PI;
|
||||||
|
|
||||||
|
double spawnRadius = this.radius + 5;
|
||||||
|
double x = spawnRadius * Math.cos(theta);
|
||||||
|
double z = spawnRadius * Math.sin(theta);
|
||||||
|
|
||||||
|
return new Pos(x, 0, z).withLookAt(new Pos(0, 0, 0));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package eu.mhsl.minenet.minigames.instance.game.stateless.types.highGround;
|
||||||
|
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.Game;
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.stateless.config.ConfigManager;
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.stateless.config.GameFactory;
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.stateless.config.Option;
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.stateless.config.common.NumericOption;
|
||||||
|
import eu.mhsl.minenet.minigames.instance.room.Room;
|
||||||
|
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
||||||
|
import net.minestom.server.item.Material;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class HighGroundFactory implements GameFactory {
|
||||||
|
@Override
|
||||||
|
public TranslatedComponent name() {
|
||||||
|
return TranslatedComponent.byId("game_Highground#name");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TranslatedComponent description() {
|
||||||
|
return TranslatedComponent.byId("game_Highground#description");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ConfigManager configuration() {
|
||||||
|
return new ConfigManager()
|
||||||
|
.addOption(new NumericOption("radius", Material.HEART_OF_THE_SEA, TranslatedComponent.byId("optionCommon#radius"), 3, 5, 7, 10))
|
||||||
|
.addOption(new NumericOption("seconds", Material.CLOCK, TranslatedComponent.byId("optionCommon#seconds"), 30, 60, 90, 120));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Game manufacture(Room parent, Map<String, Option<?>> configuration) throws Exception {
|
||||||
|
return new HighGround(configuration.get("radius").getAsInt(), configuration.get("seconds").getAsInt()).setParent(parent);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,99 @@
|
|||||||
|
package eu.mhsl.minenet.minigames.instance.game.stateless.types.jumpDive;
|
||||||
|
|
||||||
|
import eu.mhsl.minenet.minigames.instance.Dimension;
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame;
|
||||||
|
import eu.mhsl.minenet.minigames.score.PointsWinScore;
|
||||||
|
import eu.mhsl.minenet.minigames.util.BatchUtil;
|
||||||
|
import eu.mhsl.minenet.minigames.world.BlockPallet;
|
||||||
|
import net.kyori.adventure.sound.Sound;
|
||||||
|
import net.minestom.server.coordinate.Pos;
|
||||||
|
import net.minestom.server.entity.Player;
|
||||||
|
import net.minestom.server.event.player.PlayerMoveEvent;
|
||||||
|
import net.minestom.server.instance.batch.AbsoluteBlockBatch;
|
||||||
|
import net.minestom.server.instance.block.Block;
|
||||||
|
import net.minestom.server.sound.SoundEvent;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.WeakHashMap;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
public class JumpDive extends StatelessGame {
|
||||||
|
private final int radius;
|
||||||
|
private final int height;
|
||||||
|
private final int timeLimit;
|
||||||
|
|
||||||
|
private final WeakHashMap<Player, Integer> scores = new WeakHashMap<>();
|
||||||
|
|
||||||
|
public JumpDive(int radius, int height, int timeLimit) {
|
||||||
|
super(Dimension.OVERWORLD.key, "jumpDive", new PointsWinScore());
|
||||||
|
this.radius = radius;
|
||||||
|
this.height = height;
|
||||||
|
this.timeLimit = timeLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onLoad(@NotNull CompletableFuture<Void> callback) {
|
||||||
|
AbsoluteBlockBatch batch = new AbsoluteBlockBatch();
|
||||||
|
|
||||||
|
for(int x = -radius*2; x <= radius*2; x++) {
|
||||||
|
for(int z = -radius*2; z <= radius*2; z++) {
|
||||||
|
if(new Pos(x, 0, z).distance(new Pos(0, 0, 0)) > radius) {
|
||||||
|
batch.setBlock(x, height, z, BlockPallet.STONE.rnd());
|
||||||
|
} else {
|
||||||
|
batch.setBlock(x, 0, z, BlockPallet.GROUND.rnd());
|
||||||
|
batch.setBlock(x, 1, z, Block.WATER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BatchUtil.loadAndApplyBatch(batch, this, () -> callback.complete(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart() {
|
||||||
|
setTimeLimit(timeLimit);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPlayerMove(@NotNull PlayerMoveEvent playerMoveEvent) {
|
||||||
|
Player p = playerMoveEvent.getPlayer();
|
||||||
|
|
||||||
|
if(
|
||||||
|
p.isOnGround() && playerMoveEvent.getNewPosition().y() < height
|
||||||
|
|| playerMoveEvent.getNewPosition().y() < 0
|
||||||
|
|| isBeforeBeginning && playerMoveEvent.getNewPosition().y() < height
|
||||||
|
) {
|
||||||
|
p.teleport(getSpawn());
|
||||||
|
playerMoveEvent.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(
|
||||||
|
playerMoveEvent.getNewPosition().y() <= 1
|
||||||
|
&& playerMoveEvent.getNewPosition().distance(0, 1, 0) < radius + 0.5
|
||||||
|
&& !(!isBeforeBeginning && !isRunning)
|
||||||
|
) {
|
||||||
|
setBlock(playerMoveEvent.getNewPosition().withY(1), Block.REDSTONE_BLOCK);
|
||||||
|
scores.merge(p, 1, Integer::sum);
|
||||||
|
p.teleport(getSpawn());
|
||||||
|
playerMoveEvent.setCancelled(true);
|
||||||
|
p.playSound(Sound.sound(SoundEvent.ENTITY_EXPERIENCE_ORB_PICKUP, Sound.Source.PLAYER, 2f, 2f));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop() {
|
||||||
|
getPlayers().forEach(player -> getScore().insertResult(player, scores.getOrDefault(player, 0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Pos getSpawn() {
|
||||||
|
double theta = rnd.nextDouble() * 2 * Math.PI;
|
||||||
|
|
||||||
|
double spawnRadius = radius + 2;
|
||||||
|
double x = spawnRadius * Math.cos(theta);
|
||||||
|
double z = spawnRadius * Math.sin(theta);
|
||||||
|
|
||||||
|
return new Pos(x, height + 2, z).withLookAt(new Pos(0, height, 0));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package eu.mhsl.minenet.minigames.instance.game.stateless.types.jumpDive;
|
||||||
|
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.Game;
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.stateless.config.ConfigManager;
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.stateless.config.GameFactory;
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.stateless.config.Option;
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.stateless.config.common.NumericOption;
|
||||||
|
import eu.mhsl.minenet.minigames.instance.room.Room;
|
||||||
|
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
||||||
|
import net.minestom.server.item.Material;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class JumpDiveFactory implements GameFactory {
|
||||||
|
@Override
|
||||||
|
public TranslatedComponent name() {
|
||||||
|
return TranslatedComponent.byId("game_jumpDive#name");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TranslatedComponent description() {
|
||||||
|
return TranslatedComponent.byId("game_jumpDive#description");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ConfigManager configuration() {
|
||||||
|
return new ConfigManager()
|
||||||
|
.addOption(new NumericOption("radius", Material.HEART_OF_THE_SEA, TranslatedComponent.byId("optionCommon#radius"), 5, 8, 10, 12, 14, 16))
|
||||||
|
.addOption(new NumericOption("height", Material.SCAFFOLDING, TranslatedComponent.byId("optionCommon#height"), 30, 60, 90))
|
||||||
|
.addOption(new NumericOption("timeLimit", Material.CLOCK, TranslatedComponent.byId("optionCommon#seconds"), 60, 120, 180, 240, 300));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Game manufacture(Room parent, Map<String, Option<?>> configuration) throws Exception {
|
||||||
|
return new JumpDive(configuration.get("radius").getAsInt(), configuration.get("height").getAsInt(), configuration.get("timeLimit").getAsInt()).setParent(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Material symbol() {
|
||||||
|
return Material.WATER_BUCKET;
|
||||||
|
}
|
||||||
|
}
|
@ -22,7 +22,7 @@ public class MinerunFactory implements GameFactory {
|
|||||||
return new ConfigManager()
|
return new ConfigManager()
|
||||||
.addOption(new NumericOption("width", Material.OAK_FENCE, TranslatedComponent.byId("optionCommon#width"), 10, 30, 50, 100))
|
.addOption(new NumericOption("width", Material.OAK_FENCE, TranslatedComponent.byId("optionCommon#width"), 10, 30, 50, 100))
|
||||||
.addOption(new NumericOption("length", Material.ZOMBIE_HEAD, TranslatedComponent.byId("optionCommon#length"), 50, 100, 150, 200))
|
.addOption(new NumericOption("length", Material.ZOMBIE_HEAD, TranslatedComponent.byId("optionCommon#length"), 50, 100, 150, 200))
|
||||||
.addOption(new NumericOption("percentage", Material.LIGHT_WEIGHTED_PRESSURE_PLATE, TranslatedComponent.byId("game_Minerun#optionPercentageMiens"), 30, 40, 50, 60, 70));
|
.addOption(new NumericOption("percentage", Material.LIGHT_WEIGHTED_PRESSURE_PLATE, TranslatedComponent.byId("game_Minerun#optionPercentageMines"), 30, 40, 50, 60, 70));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -78,6 +78,7 @@ public class Spleef extends StatelessGame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void destroyBlock(PlayerStartDiggingEvent event) {
|
private void destroyBlock(PlayerStartDiggingEvent event) {
|
||||||
|
if(!isRunning) return;
|
||||||
setBlock(event.getBlockPosition(), Block.AIR);
|
setBlock(event.getBlockPosition(), Block.AIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public class SpleefFactory implements GameFactory {
|
|||||||
@Override
|
@Override
|
||||||
public ConfigManager configuration() {
|
public ConfigManager configuration() {
|
||||||
return new ConfigManager()
|
return new ConfigManager()
|
||||||
.addOption(new NumericOption("radius", Material.HEART_OF_THE_SEA, TranslatedComponent.byId("game_Spleef#radius"), 10, 20, 30))
|
.addOption(new NumericOption("radius", Material.HEART_OF_THE_SEA, TranslatedComponent.byId("optionCommon#radius"), 10, 20, 30))
|
||||||
.addOption(new NumericOption("stackCount", Material.SCAFFOLDING, TranslatedComponent.byId("game_Spleef#stackCount"), 1, 2, 3, 4, 5));
|
.addOption(new NumericOption("stackCount", Material.SCAFFOLDING, TranslatedComponent.byId("game_Spleef#stackCount"), 1, 2, 3, 4, 5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,20 +3,23 @@ package eu.mhsl.minenet.minigames.instance.game.stateless.types.stickfight;
|
|||||||
import eu.mhsl.minenet.minigames.instance.Dimension;
|
import eu.mhsl.minenet.minigames.instance.Dimension;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame;
|
import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame;
|
||||||
import eu.mhsl.minenet.minigames.score.LastWinsScore;
|
import eu.mhsl.minenet.minigames.score.LastWinsScore;
|
||||||
import eu.mhsl.minenet.minigames.util.BatchUtil;
|
|
||||||
import eu.mhsl.minenet.minigames.world.generator.terrain.CircularPlateTerrainGenerator;
|
import eu.mhsl.minenet.minigames.world.generator.terrain.CircularPlateTerrainGenerator;
|
||||||
import io.github.togar2.pvp.events.FinalAttackEvent;
|
import io.github.togar2.pvp.events.FinalAttackEvent;
|
||||||
import io.github.togar2.pvp.feature.CombatFeatures;
|
import io.github.togar2.pvp.feature.CombatFeatures;
|
||||||
import net.minestom.server.coordinate.Pos;
|
import net.minestom.server.coordinate.Pos;
|
||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
import net.minestom.server.event.player.PlayerMoveEvent;
|
import net.minestom.server.event.player.PlayerMoveEvent;
|
||||||
import net.minestom.server.instance.batch.AbsoluteBlockBatch;
|
|
||||||
import net.minestom.server.instance.block.Block;
|
import net.minestom.server.instance.block.Block;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.WeakHashMap;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class Stickfight extends StatelessGame {
|
public class Stickfight extends StatelessGame {
|
||||||
|
private final double radius = 20;
|
||||||
|
private final WeakHashMap<Player, Pos> spawnPoints = new WeakHashMap<>();
|
||||||
|
|
||||||
public Stickfight() {
|
public Stickfight() {
|
||||||
super(Dimension.OVERWORLD.key, "Stickfight", new LastWinsScore());
|
super(Dimension.OVERWORLD.key, "Stickfight", new LastWinsScore());
|
||||||
|
|
||||||
@ -38,21 +41,56 @@ public class Stickfight extends StatelessGame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onLoad(@NotNull CompletableFuture<Void> callback) {
|
protected void onLoad(@NotNull CompletableFuture<Void> callback) {
|
||||||
AbsoluteBlockBatch batch = new AbsoluteBlockBatch();
|
setBlock(0, 50, 0, Block.DIAMOND_BLOCK);
|
||||||
for (int z = -10; z <= 10; z++) {
|
|
||||||
batch.setBlock(0, 50, z, Block.SANDSTONE);
|
|
||||||
}
|
}
|
||||||
batch.setBlock(0, 50, 0, Block.GOLD_BLOCK);
|
|
||||||
|
|
||||||
BatchUtil.loadAndApplyBatch(batch, this, () -> callback.complete(null));
|
@Override
|
||||||
|
protected void start() {
|
||||||
|
List<Player> players = getPlayers().stream().toList();
|
||||||
|
int numPlayers = players.size();
|
||||||
|
|
||||||
|
for (int i = 0; i < numPlayers; i++) {
|
||||||
|
double angle = (2 * Math.PI / numPlayers) * i;
|
||||||
|
int spawnX = (int) (radius * Math.cos(angle));
|
||||||
|
int spawnZ = (int) (radius * Math.sin(angle));
|
||||||
|
int spawnY = 50;
|
||||||
|
|
||||||
|
Pos spawnpoint = new Pos(spawnX, spawnY + 1, spawnZ).add(0.5);
|
||||||
|
spawnPoints.put(players.get(i), spawnpoint.withLookAt(getSpawn()));
|
||||||
|
players.get(i).teleport(spawnpoint);
|
||||||
|
|
||||||
|
generateBridge(spawnX, spawnY, spawnZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
setBlock(0, 50, 0, Block.GOLD_BLOCK);
|
||||||
|
super.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generateBridge(int startX, int startY, int startZ) {
|
||||||
|
int steps = (int) (radius * 1.5);
|
||||||
|
for (int i = 0; i < steps; i++) {
|
||||||
|
double t = (double) i / steps;
|
||||||
|
int x = (int) (startX * (1 - t));
|
||||||
|
int z = (int) (startZ * (1 - t));
|
||||||
|
setBlock(x, startY, z, Block.SANDSTONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPlayerMove(@NotNull PlayerMoveEvent playerMoveEvent) {
|
protected void onPlayerMove(@NotNull PlayerMoveEvent playerMoveEvent) {
|
||||||
if(isBeforeBeginning) playerMoveEvent.setCancelled(true);
|
if(!spawnPoints.containsKey(playerMoveEvent.getPlayer())) {
|
||||||
|
playerMoveEvent.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isBeforeBeginning) {
|
||||||
|
if(spawnPoints.get(playerMoveEvent.getPlayer()).distance(playerMoveEvent.getNewPosition()) < 1) return;
|
||||||
|
playerMoveEvent.setCancelled(true);
|
||||||
|
playerMoveEvent.getPlayer().teleport(spawnPoints.get(playerMoveEvent.getPlayer()));
|
||||||
|
}
|
||||||
|
|
||||||
if(playerMoveEvent.getNewPosition().y() < 40) {
|
if(playerMoveEvent.getNewPosition().y() < 40) {
|
||||||
playerMoveEvent.getPlayer().teleport(new Pos(0, 51, 0));
|
playerMoveEvent.getPlayer().teleport(spawnPoints.get(playerMoveEvent.getPlayer()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,129 @@
|
|||||||
|
package eu.mhsl.minenet.minigames.instance.game.stateless.types.sumo;
|
||||||
|
|
||||||
|
import eu.mhsl.minenet.minigames.instance.Dimension;
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame;
|
||||||
|
import eu.mhsl.minenet.minigames.score.LastWinsScore;
|
||||||
|
import io.github.togar2.pvp.events.FinalAttackEvent;
|
||||||
|
import io.github.togar2.pvp.events.PrepareAttackEvent;
|
||||||
|
import io.github.togar2.pvp.feature.CombatFeatures;
|
||||||
|
import net.minestom.server.MinecraftServer;
|
||||||
|
import net.minestom.server.coordinate.Pos;
|
||||||
|
import net.minestom.server.entity.GameMode;
|
||||||
|
import net.minestom.server.entity.Player;
|
||||||
|
import net.minestom.server.event.player.PlayerMoveEvent;
|
||||||
|
import net.minestom.server.instance.block.Block;
|
||||||
|
import net.minestom.server.timer.TaskSchedule;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.WeakHashMap;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
public class Sumo extends StatelessGame {
|
||||||
|
int radius;
|
||||||
|
int health;
|
||||||
|
int seconds;
|
||||||
|
|
||||||
|
int originalRadius;
|
||||||
|
int timer;
|
||||||
|
|
||||||
|
WeakHashMap<Player, Integer> healthMap = new WeakHashMap<>();
|
||||||
|
|
||||||
|
public Sumo(int radius, int health, int seconds) {
|
||||||
|
super(Dimension.OVERWORLD.key, "Sumo", new LastWinsScore());
|
||||||
|
this.getScore().setIgnoreLastPlayers(1);
|
||||||
|
this.setTime(6000);
|
||||||
|
this.setTimeRate(0);
|
||||||
|
|
||||||
|
this.radius = radius;
|
||||||
|
this.health = health;
|
||||||
|
this.seconds = seconds;
|
||||||
|
|
||||||
|
this.originalRadius = radius;
|
||||||
|
this.timer = seconds;
|
||||||
|
|
||||||
|
this.eventNode().addChild(
|
||||||
|
CombatFeatures.empty()
|
||||||
|
.add(CombatFeatures.VANILLA_ATTACK)
|
||||||
|
.add(CombatFeatures.VANILLA_DAMAGE)
|
||||||
|
.add(CombatFeatures.VANILLA_KNOCKBACK)
|
||||||
|
.build()
|
||||||
|
.createNode()
|
||||||
|
);
|
||||||
|
|
||||||
|
this.eventNode().addListener(PrepareAttackEvent.class, prepareAttackEvent -> {
|
||||||
|
if (this.isBeforeBeginning)
|
||||||
|
prepareAttackEvent.setCancelled(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.eventNode().addListener(FinalAttackEvent.class, finalAttackEvent -> {
|
||||||
|
finalAttackEvent.setBaseDamage(0);
|
||||||
|
((Player) finalAttackEvent.getTarget()).setHealth(20);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void start() {
|
||||||
|
this.getPlayers().forEach(player -> {
|
||||||
|
this.healthMap.put(player, this.health);
|
||||||
|
player.setLevel(this.healthMap.get(player));
|
||||||
|
});
|
||||||
|
|
||||||
|
MinecraftServer.getSchedulerManager().scheduleTask(
|
||||||
|
() -> {
|
||||||
|
if(this.isBeforeBeginning) return TaskSchedule.seconds(1);
|
||||||
|
this.timer--;
|
||||||
|
double percent = (double) this.timer / this.seconds;
|
||||||
|
int radius = (int) (this.originalRadius * percent);
|
||||||
|
if (this.radius >= 5) {
|
||||||
|
this.radius = radius;
|
||||||
|
this.generatePlatform();
|
||||||
|
return TaskSchedule.seconds(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TaskSchedule.stop();
|
||||||
|
},
|
||||||
|
TaskSchedule.seconds(1)
|
||||||
|
);
|
||||||
|
|
||||||
|
super.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onLoad(@NotNull CompletableFuture<Void> callback) {
|
||||||
|
this.generatePlatform();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generatePlatform() {
|
||||||
|
int buffer = 5;
|
||||||
|
for(int x = -this.radius - buffer; x <= this.radius + buffer; x++) {
|
||||||
|
for(int z = -this.radius - buffer; z <= this.radius + buffer; z++) {
|
||||||
|
double distance = new Pos(x, 0, z).distance(new Pos(0, 0, 0));
|
||||||
|
if(distance <= this.radius) {
|
||||||
|
boolean isEdge = this.radius - 1 < distance;
|
||||||
|
this.setBlock(x, 0, z, isEdge ? Block.RED_CONCRETE : Block.WHITE_CONCRETE);
|
||||||
|
} else {
|
||||||
|
this.setBlock(x, 0, z, Block.AIR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPlayerMove(@NotNull PlayerMoveEvent playerMoveEvent) {
|
||||||
|
Player player = playerMoveEvent.getPlayer();
|
||||||
|
if(playerMoveEvent.getNewPosition().y() < -10) {
|
||||||
|
player.teleport(this.getSpawn());
|
||||||
|
this.healthMap.put(player, this.healthMap.get(player) - 1);
|
||||||
|
player.setLevel(this.healthMap.get(player));
|
||||||
|
if (this.healthMap.get(player) == 0) {
|
||||||
|
this.getScore().insertResult(player);
|
||||||
|
player.setGameMode(GameMode.SPECTATOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Pos getSpawn() {
|
||||||
|
return new Pos(0, 2, 0);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package eu.mhsl.minenet.minigames.instance.game.stateless.types.sumo;
|
||||||
|
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.Game;
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.stateless.config.ConfigManager;
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.stateless.config.GameFactory;
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.stateless.config.Option;
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.stateless.config.common.NumericOption;
|
||||||
|
import eu.mhsl.minenet.minigames.instance.room.Room;
|
||||||
|
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
||||||
|
import net.minestom.server.item.Material;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class SumoFactory implements GameFactory {
|
||||||
|
@Override
|
||||||
|
public TranslatedComponent name() {
|
||||||
|
return TranslatedComponent.byId("game_Sumo#name");
|
||||||
|
}
|
||||||
|
|
||||||
|
public TranslatedComponent description() {
|
||||||
|
return TranslatedComponent.byId("game_Sumo#description");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ConfigManager configuration() {
|
||||||
|
return new ConfigManager()
|
||||||
|
.addOption(new NumericOption("radius", Material.HEART_OF_THE_SEA, TranslatedComponent.byId("optionCommon#radius"), 10, 20, 30))
|
||||||
|
.addOption(new NumericOption("health", Material.GOLDEN_APPLE, TranslatedComponent.byId("game_Sumo#lives"), 1, 2, 3, 4, 5))
|
||||||
|
.addOption(new NumericOption("seconds", Material.CLOCK, TranslatedComponent.byId("optionCommon#seconds"), 30, 60, 90, 120));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Game manufacture(Room parent, Map<String, Option<?>> configuration) throws Exception {
|
||||||
|
return new Sumo(configuration.get("radius").getAsInt(), configuration.get("health").getAsInt(), configuration.get("seconds").getAsInt()).setParent(parent);
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,6 @@ import eu.mhsl.minenet.minigames.instance.game.stateless.types.tetris.game.Tetro
|
|||||||
import eu.mhsl.minenet.minigames.score.PointsWinScore;
|
import eu.mhsl.minenet.minigames.score.PointsWinScore;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minestom.server.coordinate.Pos;
|
import net.minestom.server.coordinate.Pos;
|
||||||
import net.minestom.server.coordinate.Vec;
|
|
||||||
import net.minestom.server.entity.Entity;
|
import net.minestom.server.entity.Entity;
|
||||||
import net.minestom.server.entity.GameMode;
|
import net.minestom.server.entity.GameMode;
|
||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
@ -29,7 +28,7 @@ class Tetris extends StatelessGame {
|
|||||||
public Tetris(int nextTetrominoesCount, boolean isFast, boolean hasCombat) {
|
public Tetris(int nextTetrominoesCount, boolean isFast, boolean hasCombat) {
|
||||||
super(Dimension.THE_END.key, "Tetris", new PointsWinScore());
|
super(Dimension.THE_END.key, "Tetris", new PointsWinScore());
|
||||||
|
|
||||||
eventNode()
|
this.eventNode()
|
||||||
.addListener(PlayerUseItemEvent.class, this::onPlayerInteract)
|
.addListener(PlayerUseItemEvent.class, this::onPlayerInteract)
|
||||||
.addListener(PlayerHandAnimationEvent.class, this::onPlayerAttack)
|
.addListener(PlayerHandAnimationEvent.class, this::onPlayerAttack)
|
||||||
.addListener(PlayerTickEvent.class, this::onPlayerTick);
|
.addListener(PlayerTickEvent.class, this::onPlayerTick);
|
||||||
@ -59,7 +58,7 @@ class Tetris extends StatelessGame {
|
|||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
this.tetrisGames.forEach((player, tetrisGame) -> {
|
this.tetrisGames.forEach((player, tetrisGame) -> {
|
||||||
tetrisGame.loose();
|
tetrisGame.loose();
|
||||||
getScore().insertResult(player, tetrisGame.getScore());
|
this.getScore().insertResult(player, tetrisGame.getScore());
|
||||||
tetrisGame.sidebar.removeViewer(player);
|
tetrisGame.sidebar.removeViewer(player);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -73,7 +72,6 @@ class Tetris extends StatelessGame {
|
|||||||
@Override
|
@Override
|
||||||
protected void onPlayerMove(@NotNull PlayerMoveEvent event) {
|
protected void onPlayerMove(@NotNull PlayerMoveEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Pos previousPosition = event.getPlayer().getPosition();
|
|
||||||
Pos currentPosition = event.getNewPosition();
|
Pos currentPosition = event.getNewPosition();
|
||||||
|
|
||||||
TetrisGame tetrisGame = this.tetrisGames.get(player);
|
TetrisGame tetrisGame = this.tetrisGames.get(player);
|
||||||
@ -85,37 +83,14 @@ class Tetris extends StatelessGame {
|
|||||||
if(tetrisGame.lost) return;
|
if(tetrisGame.lost) return;
|
||||||
if(player.getGameMode() == GameMode.SPECTATOR) return;
|
if(player.getGameMode() == GameMode.SPECTATOR) return;
|
||||||
|
|
||||||
|
if(player.inputs().forward()) tetrisGame.pressedButton(TetrisGame.Button.W);
|
||||||
|
if(player.inputs().backward()) tetrisGame.pressedButton(TetrisGame.Button.S);
|
||||||
|
if(player.inputs().right()) tetrisGame.pressedButton(TetrisGame.Button.D);
|
||||||
|
if(player.inputs().left()) tetrisGame.pressedButton(TetrisGame.Button.A);
|
||||||
|
if(player.inputs().jump()) tetrisGame.pressedButton(TetrisGame.Button.space);
|
||||||
|
|
||||||
event.setNewPosition(tetrisGame.getPlayerSpawnPosition().withView(currentPosition));
|
event.setNewPosition(tetrisGame.getPlayerSpawnPosition().withView(currentPosition));
|
||||||
player.setSprinting(false);
|
player.setSprinting(false);
|
||||||
|
|
||||||
Vec movementVector = currentPosition.asVec().sub(previousPosition.asVec());
|
|
||||||
|
|
||||||
float yaw = player.getPosition().yaw();
|
|
||||||
|
|
||||||
double yawRadians = Math.toRadians(yaw);
|
|
||||||
double forwardX = -Math.sin(yawRadians);
|
|
||||||
double forwardZ = Math.cos(yawRadians);
|
|
||||||
|
|
||||||
Vec forward = new Vec(forwardX, 0, forwardZ).normalize();
|
|
||||||
Vec left = forward.cross(new Vec(0, 1, 0)).normalize();
|
|
||||||
|
|
||||||
double forwardAmount = movementVector.dot(forward);
|
|
||||||
double leftAmount = movementVector.dot(left);
|
|
||||||
|
|
||||||
double buttonPressAmount = 0.05;
|
|
||||||
if (forwardAmount > buttonPressAmount) {
|
|
||||||
tetrisGame.pressedButton(TetrisGame.Button.W);
|
|
||||||
} else if (forwardAmount < -buttonPressAmount) {
|
|
||||||
tetrisGame.pressedButton(TetrisGame.Button.S);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (leftAmount > buttonPressAmount) {
|
|
||||||
tetrisGame.pressedButton(TetrisGame.Button.D);
|
|
||||||
} else if (leftAmount < -buttonPressAmount) {
|
|
||||||
tetrisGame.pressedButton(TetrisGame.Button.A);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(previousPosition.y() < currentPosition.y()) tetrisGame.pressedButton(TetrisGame.Button.space);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onPlayerInteract(@NotNull PlayerUseItemEvent event) {
|
protected void onPlayerInteract(@NotNull PlayerUseItemEvent event) {
|
||||||
@ -131,7 +106,7 @@ class Tetris extends StatelessGame {
|
|||||||
TetrisGame tetrisGame = this.tetrisGames.get(player);
|
TetrisGame tetrisGame = this.tetrisGames.get(player);
|
||||||
if(tetrisGame == null) return;
|
if(tetrisGame == null) return;
|
||||||
if(tetrisGame.lost && player.getGameMode() != GameMode.SPECTATOR) {
|
if(tetrisGame.lost && player.getGameMode() != GameMode.SPECTATOR) {
|
||||||
letPlayerLoose(player);
|
this.letPlayerLoose(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,15 +114,15 @@ class Tetris extends StatelessGame {
|
|||||||
TetrisGame tetrisGame = this.tetrisGames.get(player);
|
TetrisGame tetrisGame = this.tetrisGames.get(player);
|
||||||
player.setGameMode(GameMode.SPECTATOR);
|
player.setGameMode(GameMode.SPECTATOR);
|
||||||
player.setInvisible(true);
|
player.setInvisible(true);
|
||||||
getScore().insertResult(player, tetrisGame.getScore());
|
this.getScore().insertResult(player, tetrisGame.getScore());
|
||||||
|
|
||||||
boolean allGamesLost = this.tetrisGames.values().stream()
|
boolean allGamesLost = this.tetrisGames.values().stream()
|
||||||
.filter(game -> !game.lost)
|
.filter(game -> !game.lost)
|
||||||
.toList()
|
.toList()
|
||||||
.isEmpty();
|
.isEmpty();
|
||||||
if(!setTimeLimit && !allGamesLost) {
|
if(!this.setTimeLimit && !allGamesLost) {
|
||||||
this.setTimeLimit(90);
|
this.setTimeLimit(90);
|
||||||
setTimeLimit = true;
|
this.setTimeLimit = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +134,7 @@ class Tetris extends StatelessGame {
|
|||||||
if(this.tetrisGames.get(p) == null) {
|
if(this.tetrisGames.get(p) == null) {
|
||||||
this.tetrisGames.put(p, new TetrisGame(
|
this.tetrisGames.put(p, new TetrisGame(
|
||||||
this,
|
this,
|
||||||
getSpawn().sub(6, 8, 15).add(this.tetrisGames.size()*30, 0, 0),
|
this.getSpawn().sub(6, 8, 15).add(this.tetrisGames.size()*30, 0, 0),
|
||||||
Tetromino.Shape.J,
|
Tetromino.Shape.J,
|
||||||
this.nextTetrominoesCount,
|
this.nextTetrominoesCount,
|
||||||
this.isFast,
|
this.isFast,
|
||||||
|
@ -74,10 +74,10 @@ public class Playfield {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
batch.setBlock(getPlayerSpawnPosition().sub(0, 1, 0), Block.STONE);
|
batch.setBlock(this.getPlayerSpawnPosition().sub(0, 1, 0), Block.STONE);
|
||||||
batch.setBlock(getPlayerSpawnPosition().sub(1, 1, 0), Block.STONE);
|
batch.setBlock(this.getPlayerSpawnPosition().sub(1, 1, 0), Block.STONE);
|
||||||
batch.setBlock(getPlayerSpawnPosition().sub(1, 1, 1), Block.STONE);
|
batch.setBlock(this.getPlayerSpawnPosition().sub(1, 1, 1), Block.STONE);
|
||||||
batch.setBlock(getPlayerSpawnPosition().sub(0, 1, 1), Block.STONE);
|
batch.setBlock(this.getPlayerSpawnPosition().sub(0, 1, 1), Block.STONE);
|
||||||
|
|
||||||
BatchUtil.loadAndApplyBatch(batch, this.instance, () -> {});
|
BatchUtil.loadAndApplyBatch(batch, this.instance, () -> {});
|
||||||
}
|
}
|
||||||
@ -90,7 +90,7 @@ public class Playfield {
|
|||||||
if(this.instance.getBlock(this.lowerLeftCorner.add(x, y, 1)) == Block.AIR) isFullLine = false;
|
if(this.instance.getBlock(this.lowerLeftCorner.add(x, y, 1)) == Block.AIR) isFullLine = false;
|
||||||
}
|
}
|
||||||
if(isFullLine) {
|
if(isFullLine) {
|
||||||
removeFullLine(y);
|
this.removeFullLine(y);
|
||||||
removedLinesCounter += 1;
|
removedLinesCounter += 1;
|
||||||
y -= 1;
|
y -= 1;
|
||||||
}
|
}
|
||||||
@ -99,10 +99,10 @@ public class Playfield {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addLines(int lines) {
|
public void addLines(int lines) {
|
||||||
int xPosMissing = random.nextInt(1, 10);
|
int xPosMissing = this.random.nextInt(1, 10);
|
||||||
|
|
||||||
for (int i = 0; i < lines; i++) {
|
for (int i = 0; i < lines; i++) {
|
||||||
moveAllLinesUp();
|
this.moveAllLinesUp();
|
||||||
for (int x = 1; x < 11; x++) {
|
for (int x = 1; x < 11; x++) {
|
||||||
if(x != xPosMissing) {
|
if(x != xPosMissing) {
|
||||||
this.instance.setBlock(this.lowerLeftCorner.add(x, 1, 1), Block.LIGHT_GRAY_CONCRETE);
|
this.instance.setBlock(this.lowerLeftCorner.add(x, 1, 1), Block.LIGHT_GRAY_CONCRETE);
|
||||||
|
@ -121,8 +121,8 @@ public class TetrisGame {
|
|||||||
|
|
||||||
public void tick() {
|
public void tick() {
|
||||||
if(this.lost || this.paused) return;
|
if(this.lost || this.paused) return;
|
||||||
if(!currentTetromino.moveDown()) {
|
if(!this.currentTetromino.moveDown()) {
|
||||||
setActiveTetrominoDown();
|
this.setActiveTetrominoDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ public class TetrisGame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean switchHold() {
|
private boolean switchHold() {
|
||||||
if(!holdPossible) return false;
|
if(!this.holdPossible) return false;
|
||||||
|
|
||||||
Tetromino newCurrentTetromino;
|
Tetromino newCurrentTetromino;
|
||||||
if(this.holdTetromino == null) {
|
if(this.holdTetromino == null) {
|
||||||
@ -194,7 +194,7 @@ public class TetrisGame {
|
|||||||
|
|
||||||
this.currentTetromino.setPosition(this.tetrominoSpawnPosition);
|
this.currentTetromino.setPosition(this.tetrominoSpawnPosition);
|
||||||
this.currentTetromino.draw();
|
this.currentTetromino.draw();
|
||||||
if(!this.currentTetromino.moveDown()) loose();
|
if(!this.currentTetromino.moveDown()) this.loose();
|
||||||
|
|
||||||
double xChange = this.holdTetromino.getXChange();
|
double xChange = this.holdTetromino.getXChange();
|
||||||
this.holdTetromino.setPosition(this.holdPosition.add(xChange, 0, 0));
|
this.holdTetromino.setPosition(this.holdPosition.add(xChange, 0, 0));
|
||||||
@ -312,7 +312,7 @@ public class TetrisGame {
|
|||||||
this.currentTetromino.setPosition(this.tetrominoSpawnPosition);
|
this.currentTetromino.setPosition(this.tetrominoSpawnPosition);
|
||||||
this.currentTetromino.draw();
|
this.currentTetromino.draw();
|
||||||
if(!this.currentTetromino.moveDown()) {
|
if(!this.currentTetromino.moveDown()) {
|
||||||
loose();
|
this.loose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,13 +38,13 @@ public class Tetromino {
|
|||||||
this.uuid = UUID.randomUUID();
|
this.uuid = UUID.randomUUID();
|
||||||
|
|
||||||
switch (this.shape) {
|
switch (this.shape) {
|
||||||
case I -> shapeArray = new int[][]{{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}};
|
case I -> this.shapeArray = new int[][]{{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}};
|
||||||
case J -> shapeArray = new int[][]{{1,0,0}, {1,1,1}, {0,0,0}};
|
case J -> this.shapeArray = new int[][]{{1,0,0}, {1,1,1}, {0,0,0}};
|
||||||
case L -> shapeArray = new int[][]{{0,0,1}, {1,1,1}, {0,0,0}};
|
case L -> this.shapeArray = new int[][]{{0,0,1}, {1,1,1}, {0,0,0}};
|
||||||
case O -> shapeArray = new int[][]{{1,1}, {1,1}};
|
case O -> this.shapeArray = new int[][]{{1,1}, {1,1}};
|
||||||
case S -> shapeArray = new int[][]{{0,1,1}, {1,1,0}, {0,0,0}};
|
case S -> this.shapeArray = new int[][]{{0,1,1}, {1,1,0}, {0,0,0}};
|
||||||
case T -> shapeArray = new int[][]{{0,1,0}, {1,1,1}, {0,0,0}};
|
case T -> this.shapeArray = new int[][]{{0,1,0}, {1,1,1}, {0,0,0}};
|
||||||
case Z -> shapeArray = new int[][]{{1,1,0}, {0,1,1}, {0,0,0}};
|
case Z -> this.shapeArray = new int[][]{{1,1,0}, {0,1,1}, {0,0,0}};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,22 +58,22 @@ public class Tetromino {
|
|||||||
|
|
||||||
public boolean rotate(boolean clockwise) {
|
public boolean rotate(boolean clockwise) {
|
||||||
int[][] newShapeArray = this.getTurnedShapeArray(clockwise);
|
int[][] newShapeArray = this.getTurnedShapeArray(clockwise);
|
||||||
return checkCollisionAndMove(this.position, newShapeArray);
|
return this.checkCollisionAndMove(this.position, newShapeArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean moveDown() {
|
public boolean moveDown() {
|
||||||
Pos newPosition = this.position.sub(0, 1, 0);
|
Pos newPosition = this.position.sub(0, 1, 0);
|
||||||
return checkCollisionAndMove(newPosition, this.shapeArray);
|
return this.checkCollisionAndMove(newPosition, this.shapeArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean moveLeft() {
|
public boolean moveLeft() {
|
||||||
Pos newPosition = this.position.sub(1, 0, 0);
|
Pos newPosition = this.position.sub(1, 0, 0);
|
||||||
return checkCollisionAndMove(newPosition, this.shapeArray);
|
return this.checkCollisionAndMove(newPosition, this.shapeArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean moveRight() {
|
public boolean moveRight() {
|
||||||
Pos newPosition = this.position.add(1, 0, 0);
|
Pos newPosition = this.position.add(1, 0, 0);
|
||||||
return checkCollisionAndMove(newPosition, this.shapeArray);
|
return this.checkCollisionAndMove(newPosition, this.shapeArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw() {
|
public void draw() {
|
||||||
@ -83,11 +83,11 @@ public class Tetromino {
|
|||||||
public void draw(boolean withGhost) {
|
public void draw(boolean withGhost) {
|
||||||
if(withGhost) {
|
if(withGhost) {
|
||||||
Pos ghostPos = this.position;
|
Pos ghostPos = this.position;
|
||||||
while (!checkCollision(ghostPos.sub(0, 1, 0), this.shapeArray)) {
|
while (!this.checkCollision(ghostPos.sub(0, 1, 0), this.shapeArray)) {
|
||||||
ghostPos = ghostPos.sub(0, 1, 0);
|
ghostPos = ghostPos.sub(0, 1, 0);
|
||||||
}
|
}
|
||||||
Pos positionChange = this.position.sub(ghostPos);
|
Pos positionChange = this.position.sub(ghostPos);
|
||||||
getBlockPositions().forEach(pos -> {
|
this.getBlockPositions().forEach(pos -> {
|
||||||
Entity ghostBlock = new Entity(ghostEntityType);
|
Entity ghostBlock = new Entity(ghostEntityType);
|
||||||
((FallingBlockMeta) ghostBlock.getEntityMeta()).setBlock(this.getGhostBlock());
|
((FallingBlockMeta) ghostBlock.getEntityMeta()).setBlock(this.getGhostBlock());
|
||||||
ghostBlock.setNoGravity(true);
|
ghostBlock.setNoGravity(true);
|
||||||
@ -97,11 +97,11 @@ public class Tetromino {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getBlockPositions().forEach(pos -> this.instance.setBlock(pos, this.getColoredBlock()));
|
this.getBlockPositions().forEach(pos -> this.instance.setBlock(pos, this.getColoredBlock()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawAsEntities() {
|
public void drawAsEntities() {
|
||||||
getBlockPositions().forEach(pos -> {
|
this.getBlockPositions().forEach(pos -> {
|
||||||
Entity ghostBlock = new Entity(ghostEntityType);
|
Entity ghostBlock = new Entity(ghostEntityType);
|
||||||
((FallingBlockMeta) ghostBlock.getEntityMeta()).setBlock(this.getColoredBlock());
|
((FallingBlockMeta) ghostBlock.getEntityMeta()).setBlock(this.getColoredBlock());
|
||||||
ghostBlock.setNoGravity(true);
|
ghostBlock.setNoGravity(true);
|
||||||
@ -222,10 +222,10 @@ public class Tetromino {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkCollision(Pos newPosition, int[][] newShapeArray) {
|
private boolean checkCollision(Pos newPosition, int[][] newShapeArray) {
|
||||||
List<Pos> newBlockPositions = getBlockPositions(newPosition, newShapeArray);
|
List<Pos> newBlockPositions = this.getBlockPositions(newPosition, newShapeArray);
|
||||||
|
|
||||||
for(Pos pos : newBlockPositions) {
|
for(Pos pos : newBlockPositions) {
|
||||||
if(isPartOfTetromino(pos)) continue;
|
if(this.isPartOfTetromino(pos)) continue;
|
||||||
if(this.instance.getBlock(pos) == this.getGhostBlock()) continue;
|
if(this.instance.getBlock(pos) == this.getGhostBlock()) continue;
|
||||||
if(this.instance.getBlock(pos) != Block.AIR) return true;
|
if(this.instance.getBlock(pos) != Block.AIR) return true;
|
||||||
}
|
}
|
||||||
@ -234,7 +234,7 @@ public class Tetromino {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkCollisionAndMove(Pos newPosition, int[][] newShapeArray) {
|
private boolean checkCollisionAndMove(Pos newPosition, int[][] newShapeArray) {
|
||||||
if(!checkCollision(newPosition, newShapeArray)) {
|
if(!this.checkCollision(newPosition, newShapeArray)) {
|
||||||
this.remove();
|
this.remove();
|
||||||
this.shapeArray = Arrays.stream(newShapeArray).map(int[]::clone).toArray(int[][]::new);
|
this.shapeArray = Arrays.stream(newShapeArray).map(int[]::clone).toArray(int[][]::new);
|
||||||
this.setPosition(newPosition);
|
this.setPosition(newPosition);
|
||||||
|
@ -7,10 +7,7 @@ import eu.mhsl.minenet.minigames.util.BatchUtil;
|
|||||||
import eu.mhsl.minenet.minigames.world.generator.terrain.CircularPlateTerrainGenerator;
|
import eu.mhsl.minenet.minigames.world.generator.terrain.CircularPlateTerrainGenerator;
|
||||||
import net.minestom.server.MinecraftServer;
|
import net.minestom.server.MinecraftServer;
|
||||||
import net.minestom.server.coordinate.Pos;
|
import net.minestom.server.coordinate.Pos;
|
||||||
import net.minestom.server.entity.Entity;
|
|
||||||
import net.minestom.server.entity.EntityType;
|
|
||||||
import net.minestom.server.entity.GameMode;
|
import net.minestom.server.entity.GameMode;
|
||||||
import net.minestom.server.entity.metadata.other.PrimedTntMeta;
|
|
||||||
import net.minestom.server.event.player.PlayerMoveEvent;
|
import net.minestom.server.event.player.PlayerMoveEvent;
|
||||||
import net.minestom.server.instance.batch.AbsoluteBlockBatch;
|
import net.minestom.server.instance.batch.AbsoluteBlockBatch;
|
||||||
import net.minestom.server.instance.block.Block;
|
import net.minestom.server.instance.block.Block;
|
||||||
@ -51,7 +48,13 @@ public class TntRun extends StatelessGame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPlayerMove(@NotNull PlayerMoveEvent playerMoveEvent) {
|
protected void onPlayerMove(@NotNull PlayerMoveEvent playerMoveEvent) {
|
||||||
|
|
||||||
|
|
||||||
if(playerMoveEvent.getNewPosition().y() < totalElevation) {
|
if(playerMoveEvent.getNewPosition().y() < totalElevation) {
|
||||||
|
if(isBeforeBeginning) {
|
||||||
|
playerMoveEvent.getPlayer().teleport(getSpawn());
|
||||||
|
return;
|
||||||
|
}
|
||||||
playerMoveEvent.getPlayer().setGameMode(GameMode.SPECTATOR);
|
playerMoveEvent.getPlayer().setGameMode(GameMode.SPECTATOR);
|
||||||
getScore().insertResult(playerMoveEvent.getPlayer());
|
getScore().insertResult(playerMoveEvent.getPlayer());
|
||||||
}
|
}
|
||||||
@ -67,10 +70,10 @@ public class TntRun extends StatelessGame {
|
|||||||
setBlock(firstLocation, Block.AIR);
|
setBlock(firstLocation, Block.AIR);
|
||||||
setBlock(secondLocation, Block.AIR);
|
setBlock(secondLocation, Block.AIR);
|
||||||
|
|
||||||
Entity fallingTnt = new Entity(EntityType.TNT);
|
// Entity fallingTnt = new Entity(EntityType.TNT);
|
||||||
PrimedTntMeta fallingTntMeta = (PrimedTntMeta) fallingTnt.getEntityMeta();
|
// PrimedTntMeta fallingTntMeta = (PrimedTntMeta) fallingTnt.getEntityMeta();
|
||||||
fallingTntMeta.setFuseTime(20);
|
// fallingTntMeta.setFuseTime(20);
|
||||||
fallingTnt.setInstance(this, secondLocation);
|
// fallingTnt.setInstance(this, secondLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,12 @@ import java.util.Map;
|
|||||||
public class TntRunFactory implements GameFactory {
|
public class TntRunFactory implements GameFactory {
|
||||||
@Override
|
@Override
|
||||||
public TranslatedComponent name() {
|
public TranslatedComponent name() {
|
||||||
return TranslatedComponent.byId("game_tntRun#name");
|
return TranslatedComponent.byId("game_TntRun#name");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TranslatedComponent description() {
|
||||||
|
return TranslatedComponent.byId("game_TntRun#description");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -25,8 +30,8 @@ public class TntRunFactory implements GameFactory {
|
|||||||
@Override
|
@Override
|
||||||
public ConfigManager configuration() {
|
public ConfigManager configuration() {
|
||||||
return new ConfigManager()
|
return new ConfigManager()
|
||||||
.addOption(new NumericOption("radius", Material.STICK, TranslatedComponent.byId("game_tntRun#radius"), 20, 30, 50, 60))
|
.addOption(new NumericOption("radius", Material.STICK, TranslatedComponent.byId("optionCommon#radius"), 20, 30, 50, 60))
|
||||||
.addOption(new NumericOption("levels", Material.SCAFFOLDING, TranslatedComponent.byId("game_tntRun#levels"), 1, 2, 3, 4, 5));
|
.addOption(new NumericOption("levels", Material.SCAFFOLDING, TranslatedComponent.byId("game_TntRun#levels"), 1, 2, 3, 4, 5));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,23 +3,74 @@ package eu.mhsl.minenet.minigames.instance.game.stateless.types.towerdefense;
|
|||||||
import eu.mhsl.minenet.minigames.instance.Dimension;
|
import eu.mhsl.minenet.minigames.instance.Dimension;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame;
|
import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.towerdefense.generator.MazeGenerator;
|
import eu.mhsl.minenet.minigames.instance.game.stateless.types.towerdefense.generator.MazeGenerator;
|
||||||
import eu.mhsl.minenet.minigames.score.NoScore;
|
import eu.mhsl.minenet.minigames.score.LastWinsScore;
|
||||||
|
import net.minestom.server.coordinate.Pos;
|
||||||
|
import net.minestom.server.entity.EntityType;
|
||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
import net.minestom.server.item.ItemStack;
|
import net.minestom.server.instance.batch.AbsoluteBlockBatch;
|
||||||
import net.minestom.server.item.Material;
|
import net.minestom.server.instance.block.Block;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class Towerdefense extends StatelessGame {
|
public class Towerdefense extends StatelessGame {
|
||||||
|
private final Random random = new Random();
|
||||||
|
private final AbsoluteBlockBatch mazeBatch = new AbsoluteBlockBatch();
|
||||||
|
private final List<Pos> mazePath = new ArrayList<>();
|
||||||
|
private List<TowerdefenseRoom> instances = new ArrayList<>();
|
||||||
|
|
||||||
public Towerdefense() {
|
public Towerdefense() {
|
||||||
super(Dimension.NETHER.key, "Towerdefense", new NoScore());
|
super(Dimension.NETHER.key, "Towerdefense", new LastWinsScore());
|
||||||
|
|
||||||
setGenerator(new MazeGenerator());
|
setGenerator(new MazeGenerator());
|
||||||
|
this.generateMaze();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generateMaze() {
|
||||||
|
Pos position = new Pos(0, 0, 0);
|
||||||
|
this.addMazePosition(position, Block.GREEN_WOOL);
|
||||||
|
|
||||||
|
List<Integer> previousDirections = new ArrayList<>();
|
||||||
|
int direction = 1; // 0 -> right; 1 -> straight; 2 -> left
|
||||||
|
for (int i = 0; i < 9; i++) {
|
||||||
|
for (int j = 0; j < 3; j++) {
|
||||||
|
position = position.add(direction-1,0,direction%2);
|
||||||
|
this.addMazePosition(position, Block.WHITE_WOOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
int origin = 0;
|
||||||
|
int bound = 3;
|
||||||
|
long rightLeftDifference = previousDirections.stream().filter(integer -> integer == 0).count() - previousDirections.stream().filter(integer -> integer == 2).count();
|
||||||
|
if(rightLeftDifference >= 2 || direction == 2) origin = 1;
|
||||||
|
if(rightLeftDifference <= -2 || direction == 0) bound = 2;
|
||||||
|
direction = this.random.nextInt(origin, bound);
|
||||||
|
previousDirections.add(direction);
|
||||||
|
}
|
||||||
|
this.addMazePosition(position, Block.WHITE_WOOL);
|
||||||
|
this.addMazePosition(position.add(0,0,1), Block.WHITE_WOOL);
|
||||||
|
this.addMazePosition(position.add(0,0,2), Block.RED_WOOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addMazePosition(Pos position, Block pathBlock) {
|
||||||
|
this.mazeBatch.setBlock(position, pathBlock);
|
||||||
|
this.mazePath.add(position.add(0.5,1,0.5));
|
||||||
|
}
|
||||||
|
|
||||||
|
public AbsoluteBlockBatch getMazeBatch() {
|
||||||
|
return this.mazeBatch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Pos> getMazePath() {
|
||||||
|
return this.mazePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onPlayerJoin(Player p) {
|
protected boolean onPlayerJoin(Player p) {
|
||||||
p.getInventory().setItemStack(1, ItemStack.of(Material.ARMOR_STAND));
|
TowerdefenseRoom newRoom = new TowerdefenseRoom(p, this);
|
||||||
|
this.instances.add(newRoom);
|
||||||
|
p.setInstance(newRoom);
|
||||||
|
newRoom.startWave(List.of(EntityType.ENDERMAN, EntityType.BLAZE, EntityType.PLAYER, EntityType.HORSE, EntityType.ARMOR_STAND, EntityType.SKELETON));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,58 @@
|
|||||||
|
package eu.mhsl.minenet.minigames.instance.game.stateless.types.towerdefense;
|
||||||
|
|
||||||
|
import eu.mhsl.minenet.minigames.instance.Dimension;
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.stateless.types.towerdefense.generator.MazeGenerator;
|
||||||
|
import eu.mhsl.minenet.minigames.util.BatchUtil;
|
||||||
|
import net.minestom.server.MinecraftServer;
|
||||||
|
import net.minestom.server.entity.*;
|
||||||
|
import net.minestom.server.entity.attribute.Attribute;
|
||||||
|
import net.minestom.server.instance.InstanceContainer;
|
||||||
|
import net.minestom.server.item.ItemStack;
|
||||||
|
import net.minestom.server.item.Material;
|
||||||
|
import net.minestom.server.timer.TaskSchedule;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class TowerdefenseRoom extends InstanceContainer {
|
||||||
|
private final Player player;
|
||||||
|
private final Towerdefense game;
|
||||||
|
|
||||||
|
public TowerdefenseRoom(Player player, Towerdefense game) {
|
||||||
|
super(UUID.randomUUID(), Dimension.OVERWORLD.key);
|
||||||
|
MinecraftServer.getInstanceManager().registerInstance(this);
|
||||||
|
this.player = player;
|
||||||
|
this.game = game;
|
||||||
|
this.player.setGameMode(GameMode.ADVENTURE);
|
||||||
|
this.player.setAllowFlying(true);
|
||||||
|
this.player.getInventory().setItemStack(0, ItemStack.of(Material.ARMOR_STAND));
|
||||||
|
|
||||||
|
setGenerator(new MazeGenerator());
|
||||||
|
BatchUtil.loadAndApplyBatch(this.game.getMazeBatch(), this, () -> {});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startWave(List<EntityType> entities) {
|
||||||
|
int counter = 0;
|
||||||
|
for(EntityType entityType : entities) {
|
||||||
|
MinecraftServer.getSchedulerManager().scheduleTask(() -> {
|
||||||
|
this.addEntity(new EntityCreature(entityType));
|
||||||
|
return TaskSchedule.stop();
|
||||||
|
}, TaskSchedule.millis(800L*counter));
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addEntity(EntityCreature entity) {
|
||||||
|
entity.setInstance(this, this.game.getMazePath().getFirst());
|
||||||
|
entity.getAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.15);
|
||||||
|
entity.getNavigator().setPathTo(this.game.getMazePath().get(1), 0.7, () -> changeEntityGoal(entity, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void changeEntityGoal(EntityCreature entity, int positionIndex) {
|
||||||
|
if(positionIndex == this.game.getMazePath().size()-1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
entity.getNavigator().setPathTo(this.game.getMazePath().get(positionIndex+1), 0.7, () -> changeEntityGoal(entity, positionIndex+1));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -17,6 +17,11 @@ public class TrafficLightRaceFactory implements GameFactory {
|
|||||||
return TranslatedComponent.byId("game_TrafficlightRace#name");
|
return TranslatedComponent.byId("game_TrafficlightRace#name");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TranslatedComponent description() {
|
||||||
|
return TranslatedComponent.byId("game_TrafficlightRace#description");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConfigManager configuration() {
|
public ConfigManager configuration() {
|
||||||
return new ConfigManager()
|
return new ConfigManager()
|
||||||
|
@ -41,7 +41,7 @@ public class Room extends MineNetInstance implements Spawnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteRoom(Room room) {
|
public static void deleteRoom(Room room) {
|
||||||
logger.info("Deleting room " + room.uniqueId);
|
logger.info("Deleting room " + room.uuid);
|
||||||
rooms.remove(room);
|
rooms.remove(room);
|
||||||
players.values().removeAll(Collections.singleton(room));
|
players.values().removeAll(Collections.singleton(room));
|
||||||
room.getAllMembers().forEach(player -> MoveInstance.move(player, Hub.INSTANCE));
|
room.getAllMembers().forEach(player -> MoveInstance.move(player, Hub.INSTANCE));
|
||||||
@ -65,6 +65,9 @@ public class Room extends MineNetInstance implements Spawnable {
|
|||||||
p.clearTitle();
|
p.clearTitle();
|
||||||
p.getInventory().clear();
|
p.getInventory().clear();
|
||||||
p.setGameMode(GameMode.ADVENTURE);
|
p.setGameMode(GameMode.ADVENTURE);
|
||||||
|
p.setInvisible(false);
|
||||||
|
p.setExp(0);
|
||||||
|
p.setLevel(0);
|
||||||
rooms.add(room);
|
rooms.add(room);
|
||||||
players.put(p, room);
|
players.put(p, room);
|
||||||
MoveInstance.move(p, room);
|
MoveInstance.move(p, room);
|
||||||
@ -87,29 +90,29 @@ public class Room extends MineNetInstance implements Spawnable {
|
|||||||
private Room(Player owner) {
|
private Room(Player owner) {
|
||||||
super(Dimension.THE_END.key);
|
super(Dimension.THE_END.key);
|
||||||
this.apiDriven = false;
|
this.apiDriven = false;
|
||||||
construct();
|
this.construct();
|
||||||
setOwner(owner);
|
this.setOwner(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Room() {
|
protected Room() {
|
||||||
super(Dimension.THE_END.key);
|
super(Dimension.THE_END.key);
|
||||||
this.apiDriven = true;
|
this.apiDriven = true;
|
||||||
construct();
|
this.construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void construct() {
|
private void construct() {
|
||||||
MinecraftServer.getInstanceManager().registerInstance(this);
|
MinecraftServer.getInstanceManager().registerInstance(this);
|
||||||
setChunkLoader(new AnvilLoader(Resource.LOBBY_MAP.getPath()));
|
this.setChunkLoader(new AnvilLoader(Resource.LOBBY_MAP.getPath()));
|
||||||
|
|
||||||
this.gameSelector = new GameSelector();
|
this.gameSelector = new GameSelector();
|
||||||
this.gameSelector.setInstance(this, new Pos(0.5, 50, 19.5));
|
this.gameSelector.setInstance(this, new Pos(0.5, 50, 19.5));
|
||||||
|
|
||||||
eventNode().addListener(PlayerBlockBreakEvent.class, CommonEventHandles::cancel);
|
this.eventNode().addListener(PlayerBlockBreakEvent.class, CommonEventHandles::cancel);
|
||||||
eventNode().addListener(PlayerDisconnectEvent.class, playerDisconnectEvent -> unsetRoom(playerDisconnectEvent.getPlayer()));
|
this.eventNode().addListener(PlayerDisconnectEvent.class, playerDisconnectEvent -> unsetRoom(playerDisconnectEvent.getPlayer()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getOwner() {
|
public Player getOwner() {
|
||||||
return owner;
|
return this.owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOwner(Player newOwner) {
|
public void setOwner(Player newOwner) {
|
||||||
@ -122,7 +125,7 @@ public class Room extends MineNetInstance implements Spawnable {
|
|||||||
|
|
||||||
if(p != this.owner) return;
|
if(p != this.owner) return;
|
||||||
|
|
||||||
getAllMembers().stream()
|
this.getAllMembers().stream()
|
||||||
.filter(player -> player != p) // exclude the current leaving owner
|
.filter(player -> player != p) // exclude the current leaving owner
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.ifPresentOrElse(
|
.ifPresentOrElse(
|
||||||
@ -132,8 +135,8 @@ public class Room extends MineNetInstance implements Spawnable {
|
|||||||
|
|
||||||
Room.unsetRoom(p);
|
Room.unsetRoom(p);
|
||||||
|
|
||||||
new ChatMessage(Icon.ERROR).appendStatic("The room leader left!").send(getAllMembers());
|
new ChatMessage(Icon.ERROR).appendStatic("The room leader left!").send(this.getAllMembers());
|
||||||
new ChatMessage(Icon.SCIENCE).appendStatic(this.owner.getUsername()).appendStatic(" is the new Leader!").send(getAllMembers().stream().filter(player -> player != this.owner).collect(Collectors.toSet()));
|
new ChatMessage(Icon.SCIENCE).appendStatic(this.owner.getUsername()).appendStatic(" is the new Leader!").send(this.getAllMembers().stream().filter(player -> player != this.owner).collect(Collectors.toSet()));
|
||||||
new ChatMessage(Icon.SUCCESS).appendStatic("You are now the leader.").send(this.owner);
|
new ChatMessage(Icon.SUCCESS).appendStatic("You are now the leader.").send(this.owner);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class Languages {
|
|||||||
return getLanguage(p.getSettings().locale().toString()); // TODO funktioniert die locale noch?
|
return getLanguage(p.getSettings().locale().toString()); // TODO funktioniert die locale noch?
|
||||||
}
|
}
|
||||||
public Lang getLanguage(String mapId) {
|
public Lang getLanguage(String mapId) {
|
||||||
return languages.computeIfAbsent(mapId, unused -> languages.computeIfAbsent(defaultLanguage, (key) -> new DummyLang()));
|
return languages.computeIfAbsent(mapId.toLowerCase(), unused -> languages.computeIfAbsent(defaultLanguage, (key) -> new DummyLang()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readAll() {
|
private void readAll() {
|
||||||
|
@ -28,10 +28,6 @@ public class InteractableEntity extends EntityCreature {
|
|||||||
.addListener(PlayerEntityInteractEvent.class, this::onInteract) //TODO Why are some of these listeners not working?
|
.addListener(PlayerEntityInteractEvent.class, this::onInteract) //TODO Why are some of these listeners not working?
|
||||||
|
|
||||||
.addListener(EntityAttackEvent.class, this::onAttack);
|
.addListener(EntityAttackEvent.class, this::onAttack);
|
||||||
|
|
||||||
System.out.println(eventNode().getChildren());
|
|
||||||
|
|
||||||
System.out.println(eventNode().getParent().getChildren());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setInstanceEvent(@NotNull AddEntityToInstanceEvent addEntityToInstanceEvent) {
|
private void setInstanceEvent(@NotNull AddEntityToInstanceEvent addEntityToInstanceEvent) {
|
||||||
|
@ -3,7 +3,6 @@ package eu.mhsl.minenet.minigames.skin;
|
|||||||
import net.minestom.server.MinecraftServer;
|
import net.minestom.server.MinecraftServer;
|
||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
import net.minestom.server.entity.PlayerSkin;
|
import net.minestom.server.entity.PlayerSkin;
|
||||||
import net.minestom.server.timer.ExecutionType;
|
|
||||||
import net.minestom.server.timer.TaskSchedule;
|
import net.minestom.server.timer.TaskSchedule;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -12,19 +11,15 @@ import java.util.Map;
|
|||||||
public class SkinCache {
|
public class SkinCache {
|
||||||
private static final Map<String, PlayerSkin> skins = new HashMap<>();
|
private static final Map<String, PlayerSkin> skins = new HashMap<>();
|
||||||
|
|
||||||
public static PlayerSkin getSkin(Player p) {
|
|
||||||
return SkinCache.getSkin(p.getUsername());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PlayerSkin getSkin(String p) {
|
public static PlayerSkin getSkin(String p) {
|
||||||
if(!skins.containsKey(p)) skins.put(p, PlayerSkin.fromUsername(p));
|
if(!skins.containsKey(p)) skins.put(p, PlayerSkin.fromUsername(p));
|
||||||
return skins.get(p);
|
return skins.get(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void applySkin(Player p) {
|
public static void applySkin(Player p) {
|
||||||
MinecraftServer.getSchedulerManager().submitTask(() -> {
|
MinecraftServer.getSchedulerManager().scheduleTask(() -> {
|
||||||
p.setSkin(SkinCache.getSkin(p.getUsername()));
|
p.setSkin(SkinCache.getSkin(p.getUsername()));
|
||||||
return TaskSchedule.stop();
|
return TaskSchedule.stop();
|
||||||
}, ExecutionType.TICK_END);
|
}, TaskSchedule.millis(500));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ public enum BlockPallet {
|
|||||||
STONE(new Block[] {Block.CHISELED_STONE_BRICKS, Block.STONE_BRICKS, Block.POLISHED_ANDESITE, Block.POLISHED_BLACKSTONE, Block.POLISHED_DIORITE}),
|
STONE(new Block[] {Block.CHISELED_STONE_BRICKS, Block.STONE_BRICKS, Block.POLISHED_ANDESITE, Block.POLISHED_BLACKSTONE, Block.POLISHED_DIORITE}),
|
||||||
WINTER(new Block[] {Block.SNOW_BLOCK, Block.ICE, Block.PACKED_ICE, Block.BLUE_CONCRETE, Block.SEA_LANTERN}),
|
WINTER(new Block[] {Block.SNOW_BLOCK, Block.ICE, Block.PACKED_ICE, Block.BLUE_CONCRETE, Block.SEA_LANTERN}),
|
||||||
STREET(new Block[] {Block.BLACK_CONCRETE_POWDER, Block.GRAY_CONCRETE_POWDER, Block.GRAVEL, Block.BLACK_CONCRETE, Block.GRAY_CONCRETE}),
|
STREET(new Block[] {Block.BLACK_CONCRETE_POWDER, Block.GRAY_CONCRETE_POWDER, Block.GRAVEL, Block.BLACK_CONCRETE, Block.GRAY_CONCRETE}),
|
||||||
|
FLOWER(new Block[] {Block.ORANGE_TULIP, Block.PINK_TULIP, Block.RED_TULIP, Block.WHITE_TULIP}),
|
||||||
PRESSURE_PLATES(new Block[] {Block.ACACIA_PRESSURE_PLATE, Block.BIRCH_PRESSURE_PLATE, Block.CRIMSON_PRESSURE_PLATE, Block.JUNGLE_PRESSURE_PLATE, Block.OAK_PRESSURE_PLATE, Block.DARK_OAK_PRESSURE_PLATE, Block.HEAVY_WEIGHTED_PRESSURE_PLATE, Block.HEAVY_WEIGHTED_PRESSURE_PLATE, Block.POLISHED_BLACKSTONE_PRESSURE_PLATE, Block.SPRUCE_PRESSURE_PLATE, Block.STONE_PRESSURE_PLATE, Block.WARPED_PRESSURE_PLATE});
|
PRESSURE_PLATES(new Block[] {Block.ACACIA_PRESSURE_PLATE, Block.BIRCH_PRESSURE_PLATE, Block.CRIMSON_PRESSURE_PLATE, Block.JUNGLE_PRESSURE_PLATE, Block.OAK_PRESSURE_PLATE, Block.DARK_OAK_PRESSURE_PLATE, Block.HEAVY_WEIGHTED_PRESSURE_PLATE, Block.HEAVY_WEIGHTED_PRESSURE_PLATE, Block.POLISHED_BLACKSTONE_PRESSURE_PLATE, Block.SPRUCE_PRESSURE_PLATE, Block.STONE_PRESSURE_PLATE, Block.WARPED_PRESSURE_PLATE});
|
||||||
|
|
||||||
final List<Block> list;
|
final List<Block> list;
|
||||||
|
@ -67,7 +67,7 @@ public class SquarePlateTerrainGenerator extends PlateTerrainGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(generateBorders) {
|
if(generateBorders) {
|
||||||
Runnable generateBorder = () -> unit.modifier().fill(bottom, bottom.add(1, 0, 1), Block.BARRIER); // TODO DimensionType.OVERWORLD.getMaxY() is now hardcoded 0, might break behaviour
|
Runnable generateBorder = () -> unit.modifier().fill(bottom, bottom.add(1, DimensionType.VANILLA_MAX_Y, 1), Block.BARRIER);
|
||||||
|
|
||||||
if(bottom.z() <= length+1 && bottom.z() >= -1 && bottom.x() >= -1 && bottom.x() <= width+1) {
|
if(bottom.z() <= length+1 && bottom.z() >= -1 && bottom.x() >= -1 && bottom.x() <= width+1) {
|
||||||
if(bottom.x() == -1 || bottom.x() == width+1) {
|
if(bottom.x() == -1 || bottom.x() == width+1) {
|
||||||
|
@ -23,7 +23,11 @@ other_description;Games which does not fit into other Categories;Spiele welche n
|
|||||||
pvp;Player vs Player;Spieler gegen Spieler
|
pvp;Player vs Player;Spieler gegen Spieler
|
||||||
pvp_description;Fight against other Players;Kämpfe gegen andere Spieler
|
pvp_description;Fight against other Players;Kämpfe gegen andere Spieler
|
||||||
pve;Player vs Enviroment;Spieler gegen Umwelt
|
pve;Player vs Enviroment;Spieler gegen Umwelt
|
||||||
pve_description;Surivie the world or fight entities;Überlebe die Welt oder kämpfe gegen Mobs
|
pve_description;Survive the world or fight entities;Überlebe die Welt oder kämpfe gegen Mobs
|
||||||
|
jumpnrun;jump and run;jump and run
|
||||||
|
jumpnrun_description;Proof your jump-and-run skills;Stelle deine jump-and-run Fähigkeiten unter Beweis
|
||||||
|
prototype;Prototype;Prototyp
|
||||||
|
prototype_description;Prototype games;Prototyp Spiele
|
||||||
;;
|
;;
|
||||||
ns:hub#;;
|
ns:hub#;;
|
||||||
invTitle;MineNet Servernetwork;MineNet Servernetzwerk
|
invTitle;MineNet Servernetwork;MineNet Servernetzwerk
|
||||||
@ -36,7 +40,7 @@ join_notFound;Lobby not found: ;Lobby konnte nicht gefunden werden:
|
|||||||
;;
|
;;
|
||||||
ns:score#;;
|
ns:score#;;
|
||||||
result;Results;Ergebnisse
|
result;Results;Ergebnisse
|
||||||
thanks;Thank you for Playing;Danke für's spielen
|
thanks;Thank you for Playing;Danke für's Spielen
|
||||||
finish;You did it;Du hast es geschafft
|
finish;You did it;Du hast es geschafft
|
||||||
death;You are out;Du hast verloren
|
death;You are out;Du hast verloren
|
||||||
done;Finish;Fertig
|
done;Finish;Fertig
|
||||||
@ -65,15 +69,26 @@ noOptionDescription;There are no options for this Game;Es gibt keine Einstellung
|
|||||||
ns:GameFactory#;;
|
ns:GameFactory#;;
|
||||||
missingDescription;No description;Keine Beschreibung
|
missingDescription;No description;Keine Beschreibung
|
||||||
;;
|
;;
|
||||||
|
ns:game_TntRun#;;
|
||||||
|
name;TNT run;TNT Rennen
|
||||||
|
description;The tnt at the ground disappears, don't fall;Das TNT am Boden verschwindet, falle nicht herunter
|
||||||
|
levels;levels;Ebenen
|
||||||
|
;;
|
||||||
|
ns:game_ElytraRace#;;
|
||||||
|
name;Elytra race;Elytra Rennen
|
||||||
|
description;Be fast while flying through the rings;Sei schnell während du durch die Ringe fliegst
|
||||||
|
ringCount;ring count;Anzahl der Ringe
|
||||||
|
;;
|
||||||
ns:game_Minerun#;;
|
ns:game_Minerun#;;
|
||||||
name;Minerun;Minenrennen
|
name;Minerun;Minenrennen
|
||||||
description;Ditch deadly Mines in the ground an be the first in the goal;Weiche den tödlichen Bodenmienen aus und sei der erste im Ziel
|
description;Ditch deadly Mines in the ground an be the first in the goal;Weiche den tödlichen Bodenmienen aus und sei der erste im Ziel
|
||||||
optionPercentageMines;Percentage of Miens;Prozentsatz der Minen
|
optionPercentageMines;Percentage of mines;Prozentsatz der Minen
|
||||||
;;
|
;;
|
||||||
ns:game_Deathcube#;;
|
ns:game_Deathcube#;;
|
||||||
name;Deathcube;Todeswürfel
|
name;Deathcube;Todeswürfel
|
||||||
description;Find a way to jump higher and be the first on the top;Finde einen weg nach oben und sei der erste im Ziel
|
description;Find a way to jump higher and be the first on the top;Finde einen weg nach oben und sei der erste im Ziel
|
||||||
optionPercentageBlocks;Percentage of Blocks;Prozentsatz der Blöcke
|
optionPercentageBlocks;Percentage of Blocks;Prozentsatz der Blöcke
|
||||||
|
optionPvpEnabled;pvp enabled;PvP aktiviert
|
||||||
;;
|
;;
|
||||||
ns:game_Stickfight#;;
|
ns:game_Stickfight#;;
|
||||||
name;Stickfight;Stockschlacht
|
name;Stickfight;Stockschlacht
|
||||||
@ -83,6 +98,14 @@ ns:game_TrafficlightRace#;;
|
|||||||
name;Red light green light;Rotes licht, Grünes licht
|
name;Red light green light;Rotes licht, Grünes licht
|
||||||
description;Only go forward if the Trafficlights show green;Gehe nur bei Grün vorran
|
description;Only go forward if the Trafficlights show green;Gehe nur bei Grün vorran
|
||||||
;;
|
;;
|
||||||
|
ns:game_AcidRain#;;
|
||||||
|
name;Acid rain;Säureregen
|
||||||
|
description;Stay under the holey roof to dodge acid rain;Bleib unter dem löchrigen Dach um dem sauren Regen auszuweichen
|
||||||
|
;;
|
||||||
|
ns:game_BowSpleef#;;
|
||||||
|
name;Bow spleef;Bogen Spleef
|
||||||
|
description;Spleef other players and be the last survivor;Zerstöre Blöcke unter anderen Spielern und sei der letzte im Feld
|
||||||
|
;;
|
||||||
ns:game_Towerdefense#;;
|
ns:game_Towerdefense#;;
|
||||||
name;Towerdefense;Towerdefense
|
name;Towerdefense;Towerdefense
|
||||||
description;Protect the path ????;??????
|
description;Protect the path ????;??????
|
||||||
@ -91,6 +114,7 @@ ns:game_Spleef#;;
|
|||||||
name;Spleef;Spleef;
|
name;Spleef;Spleef;
|
||||||
description;Spleef other players and be the last survivor;Zerstöre Blöcke unter anderen Spielern und sei der letzte im Feld
|
description;Spleef other players and be the last survivor;Zerstöre Blöcke unter anderen Spielern und sei der letzte im Feld
|
||||||
shovelName;Snow thrower;Schneeflug
|
shovelName;Snow thrower;Schneeflug
|
||||||
|
stackCount;levels;Ebenen
|
||||||
;;
|
;;
|
||||||
ns:game_Tetris#;;
|
ns:game_Tetris#;;
|
||||||
name;Tetris;Tetris
|
name;Tetris;Tetris
|
||||||
@ -100,5 +124,18 @@ isFast;Fast mode;Schneller Modus
|
|||||||
hasCombat;Competitive mode;Kompetitiver Modus
|
hasCombat;Competitive mode;Kompetitiver Modus
|
||||||
;;
|
;;
|
||||||
ns:game_AnvilRun#;;
|
ns:game_AnvilRun#;;
|
||||||
name;Anvil Run;Anvil Run
|
name;Anvil run;Anvil run
|
||||||
description;Run away from falling anvils;Renne von fallenden Ambossen davon
|
description;Run away from falling anvils;Renne von fallenden Ambossen davon
|
||||||
|
;;
|
||||||
|
ns:game_jumpDive#;;
|
||||||
|
name;Jump dive;Wassersprung
|
||||||
|
description;Jump into the water, avoiding already used spots!;Springe ins wasser an stellen, in denen noch niemand zuvor gelandet ist!
|
||||||
|
;;
|
||||||
|
ns:game_Sumo#;;
|
||||||
|
name;Sumo;Sumo
|
||||||
|
lives;Lives;Leben
|
||||||
|
description;Knock your enemies off and stay on top!;Versuche deinen Gegner von der Plattform zu schubsen!
|
||||||
|
;;
|
||||||
|
ns:game_Highground#;;
|
||||||
|
name;Highground;Hochburg
|
||||||
|
description;Stay on the high ground to win!;Bleibe solange wie möglich auf der Hochburg, um zu gewinnen!
|
||||||
|
Can't render this file because it has a wrong number of fields in line 114.
|
Reference in New Issue
Block a user