Compare commits

7 Commits

138 changed files with 3099 additions and 903 deletions

View File

@@ -12,7 +12,12 @@
<attribute name="gradle_used_by_scope" value="main,test"/> <attribute name="gradle_used_by_scope" value="main,test"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17/"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/> <classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="src" path="bin/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin/default"/> <classpathentry kind="output" path="bin/default"/>
</classpath> </classpath>

3
.factorypath Normal file
View File

@@ -0,0 +1,3 @@
<factorypath>
<factorypathentry kind="EXTJAR" id="/home/hadvart/.gradle/caches/modules-2/files-2.1/org.projectlombok/lombok/1.18.42/8365263844ebb62398e0dc33057ba10ba472d3b8/lombok-1.18.42.jar" enabled="true" runInBatchMode="false"/>
</factorypath>

5
.idea/.gitignore generated vendored
View File

@@ -1,5 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Environment-dependent path to Maven home directory
/mavenHomeManager.xml

1
.idea/.name generated
View File

@@ -1 +0,0 @@
BlockAndSeek

6
.idea/ant.xml generated
View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AntConfiguration">
<buildFile url="file://$PROJECT_DIR$/build.xml" />
</component>
</project>

3
.idea/compiler.xml generated
View File

@@ -7,9 +7,8 @@
<processorPath useClasspath="false"> <processorPath useClasspath="false">
<entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.projectlombok/lombok/1.18.42/8365263844ebb62398e0dc33057ba10ba472d3b8/lombok-1.18.42.jar" /> <entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.projectlombok/lombok/1.18.42/8365263844ebb62398e0dc33057ba10ba472d3b8/lombok-1.18.42.jar" />
</processorPath> </processorPath>
<module name="BlockAndSeek.main" /> <module name="hdvtdev.BlockAndSeek.main" />
</profile> </profile>
</annotationProcessing> </annotationProcessing>
<bytecodeTargetLevel target="17" />
</component> </component>
</project> </project>

2
.idea/gradle.xml generated
View File

@@ -4,9 +4,7 @@
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="/usr/share/java/gradle" />
<option name="modules"> <option name="modules">
<set> <set>
<option value="$PROJECT_DIR$" /> <option value="$PROJECT_DIR$" />

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="HotSwapAgentPluginSettingsProvider">
<option name="agentPath" value="$APPLICATION_PLUGINS_DIR$/hotswap-agent-intellij-plugin/lib/agent/hotswap-agent-2.0.0 (2024-09-03).jar" />
</component>
</project>

4
.idea/misc.xml generated
View File

@@ -1,7 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" project-jdk-name="21" project-jdk-type="JavaSDK" />
<output url="file://$PROJECT_DIR$/out" />
</component>
</project> </project>

5
.idea/modules.xml generated
View File

@@ -2,9 +2,8 @@
<project version="4"> <project version="4">
<component name="ProjectModuleManager"> <component name="ProjectModuleManager">
<modules> <modules>
<module fileurl="file://$PROJECT_DIR$/.idea/modules/BlockAndSeek.iml" filepath="$PROJECT_DIR$/.idea/modules/BlockAndSeek.iml" /> <module fileurl="file://$PROJECT_DIR$/.idea/modules/hdvtdev.BlockAndSeek.iml" filepath="$PROJECT_DIR$/.idea/modules/hdvtdev.BlockAndSeek.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/BlockAndSeek.main.iml" filepath="$PROJECT_DIR$/.idea/modules/BlockAndSeek.main.iml" /> <module fileurl="file://$PROJECT_DIR$/.idea/modules/hdvtdev.BlockAndSeek.main.iml" filepath="$PROJECT_DIR$/.idea/modules/hdvtdev.BlockAndSeek.main.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/BlockAndSeek.test.iml" filepath="$PROJECT_DIR$/.idea/modules/BlockAndSeek.test.iml" />
</modules> </modules>
</component> </component>
</project> </project>

View File

@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="AdditionalModuleElements">
<content url="file://$MODULE_DIR$/../.." dumb="true">
<excludeFolder url="file://$MODULE_DIR$/../../bin" />
</content>
</component>
</module>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="AdditionalModuleElements">
<content url="file://$MODULE_DIR$/../../build/generated/sources/annotationProcessor/java/main">
<sourceFolder url="file://$MODULE_DIR$/../../build/generated/sources/annotationProcessor/java/main" isTestSource="false" generated="true" />
</content>
</component>
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>PAPER</platformType>
<platformType>ADVENTURE</platformType>
</autoDetectTypes>
<projectReimportVersion>1</projectReimportVersion>
</configuration>
</facet>
</component>
</module>

View File

@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SaveActionSettings">
<option name="actions">
<set>
<option value="activate" />
<option value="activateOnShortcut" />
<option value="noActionIfCompileErrors" />
<option value="organizeImports" />
<option value="reformat" />
<option value="reload" />
</set>
</option>
<option name="configurationPath" value="" />
</component>
</project>

2
.idea/vcs.xml generated
View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" /> <mapping directory="" vcs="Git" />
</component> </component>
</project> </project>

130
.idea/workspace.xml generated Normal file
View File

@@ -0,0 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="46146984-f46a-4efa-a29f-c0632c66dbea" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/build.gradle" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/hdvtdev/blockandseek/items/FreezeItem.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/hdvtdev/blockandseek/items/FreezeItem.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/hdvtdev/blockandseek/managers/CommandManager.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/hdvtdev/blockandseek/managers/CommandManager.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/hdvtdev/blockandseek/managers/PropManager.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/hdvtdev/blockandseek/managers/PropManager.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/hdvtdev/blockandseek/managers/TranslationManager.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/hdvtdev/blockandseek/managers/TranslationManager.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/hdvtdev/blockandseek/objects/BlockAndSeekGame.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/hdvtdev/blockandseek/objects/BlockAndSeekGame.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/hdvtdev/blockandseek/objects/LazyLocation.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/hdvtdev/blockandseek/objects/LazyLocation.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/hdvtdev/blockandseek/objects/TranslationKey.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/hdvtdev/blockandseek/objects/TranslationKey.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ExternalProjectsData">
<projectState path="$PROJECT_DIR$">
<ProjectState />
</projectState>
</component>
<component name="ExternalProjectsManager">
<system id="GRADLE">
<state>
<task path="$PROJECT_DIR$">
<activation />
</task>
<projects_view>
<tree_state>
<expand>
<path>
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
<item name="BlockAndSeek" type="f1a62948:ProjectNode" />
</path>
</expand>
<select />
</tree_state>
</projects_view>
</state>
</system>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Enum" />
<option value="Record" />
<option value="Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProblemsViewState">
<option name="selectedTabId" value="CurrentFile" />
</component>
<component name="ProjectColorInfo">{
&quot;customColor&quot;: &quot;&quot;,
&quot;associatedIndex&quot;: 0
}</component>
<component name="ProjectId" id="36CrhqYuC8ehIkzjvB8mlSuYUBP" />
<component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="2" id="Add" />
</component>
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;Gradle.Download Sources.executor&quot;: &quot;Run&quot;,
&quot;Gradle.blockandseek [deploy].executor&quot;: &quot;Run&quot;,
&quot;ModuleVcsDetector.initialDetectionPerformed&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252&quot;: &quot;true&quot;,
&quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
&quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;SHELLCHECK.PATH&quot;: &quot;/home/hadvart/.local/share/JetBrains/IdeaIC2025.2/Shell Script/shellcheck&quot;,
&quot;git-widget-placeholder&quot;: &quot;dev-1.20.6&quot;,
&quot;kotlin-language-version-configured&quot;: &quot;true&quot;,
&quot;last_opened_file_path&quot;: &quot;/home/hadvart/IdeaProjects/blockandseek/BlockAndSeekPack/assets/minecraft/textures/misc&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.lookFeel&quot;
}
}</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/BlockAndSeekPack/assets/minecraft/textures/misc" />
</key>
</component>
<component name="RunManager">
<configuration name="blockandseek [deploy]" type="GradleRunConfiguration" factoryName="Gradle" nameIsGenerated="true">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="deploy" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="46146984-f46a-4efa-a29f-c0632c66dbea" name="Changes" comment="" />
<created>1764521517232</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1764521517232</updated>
</task>
<servers />
</component>
</project>

View File

@@ -0,0 +1,13 @@
arguments=--init-script /home/hadvart/.eclipse/2139989682_linux_gtk_x86_64/configuration/org.eclipse.osgi/58/0/.cp/gradle/init/init.gradle
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=
java.home=/usr/lib/jvm/java-21-openjdk
jvm.arguments=
offline.mode=false
override.workspace.settings=true
show.console.view=true
show.executions.view=true

View File

@@ -0,0 +1,4 @@
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=true
org.eclipse.jdt.apt.genSrcDir=bin/generated-sources/annotations
org.eclipse.jdt.apt.genTestSrcDir=bin/generated-test-sources/annotations

View File

@@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.processAnnotations=enabled

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 KiB

View File

@@ -0,0 +1,6 @@
{
"pack": {
"pack_format": 15,
"description": "BlockAndSeekPack"
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,2 @@
Place your translations in language folder. Translation file name must be a language tag and file extension must be .yml.
Use en_US.yml as example.

View File

@@ -0,0 +1,26 @@
messages:
UNKNOWN_COMMAND: "<gold>Unknown command: <red>%command%</red>."
SEEKER_TEMPLATE: "<gradient:#8B0000:#B22222:#DC143C><bold>%template%</bold></gradient>"
UNKNOWN_MAP: "<gold>Unknown map: <red>%map%</red>. Available maps: </gold><dark_aqua><b>%maps%</b></dark_aqua>"
SUCCESSFUL_MAP_CREATION: "<gold>Map <dark_aqua><b>%map%</b></dark_aqua> was <green>successfully</green> created. Use <b>/blockandseek map <dark_aqua>%map%</dark_aqua> to edit</b>"
MENU: <yellow>menu</yellow>
GAMES_MENU: "<gold>games</gold>"
MAPS_MENU: "<gold>maps</gold>"
GAME: "<gradient:#52e555:#20962d>%name%</gradient>"
CREATE_GAME: "<gold><b>Create game</b></gold>"
MAP: "<gradient:#20e3b2:#29ffc6>%name%</gradient>"
TIME_LEFT: "<gold>Time left %time%</gold>"
PLAYER_JOINED: "<gold><b>%player%</b></gold><yellow> joined. <b>%count%/%max%<b>"
PLAYER_LEFT: "<gold><b>%player%</b></gold><yellow> <red>left</red>. <b>%count%/%max%<b>"
SEEKERS_WIN: "<b><red>Seekers won this game!</red></b>"
HIDERS_WIN: "<b><gold>Hiders won this game!</gold></b>"
HIDER_SOLO_WIN: "<b><gold><aqua>%player%</aqua> won this game!</gold></b>"
FREEZE_ITEM: "<gradient:#00c6fb:#005bea>Freezer 3000</gradient>"
SOUND_ITEM: "<gradient:#f3e6ff:#dcb3ff>Sounder 3000</gradient>"
LEAVE_ITEM: "<red><b>Leave</red></b>"
DASH_ITEM: "<gradient:#43cea2:#185a9d>Dash</gradient>"
ROULETTE: "<b><gold>Blocks roulette</b></gold>"
TIME_TO_START: "<gold>Game starts in <b>%time%</b></gold>"
GAME_IS_FULL: "<yellow><red>failed></red> to join %game%. Game is full."
FACE_CHANGING_ITEM: "FACE_CHANGING_ITEM: todo"
WAITING_FOR_PLAYERS: "<gold>Waiting for players</gold>"

View File

@@ -0,0 +1,23 @@
messages:
UNKNOWN_COMMAND: "<gold>Неизвестная команда: <red>%command%</red>."
SEEKER_TEMPLATE: <gradient:#8B0000:#B22222:#DC143C><bold>%template%</bold></gradient>
UNKNOWN_MAP: "<gold>Неизвестная карта: <red>%map%</red>. Доступные карты: </gold><dark_aqua><b>%maps%</b></dark_aqua>"
SUCCESSFUL_MAP_CREATION: <gold>Карта <dark_aqua><b>%map%</b></dark_aqua> была <green>успешно</green> создана. Используйте <b>/blockandseek map <dark_aqua>%map%</dark_aqua>, чтобы редактировать</b>
MENU: <yellow>меню</yellow>
GAMES_MENU: <gold>игры</gold>
MAPS_MENU: <gold>карты</gold>
GAME: <gradient:#52e555:#20962d>%name%</gradient>
CREATE_GAME: <gold><b>Создать игру</b></gold>
MAP: <gradient:#20e3b2:#29ffc6>%name%</gradient>
TIME_LEFT: "<gold>Осталось времени: %time%</gold>"
PLAYER_JOINED: <gold><b>%player%</b></gold><yellow> присоединился. <b>%count%/%max%<b>
PLAYER_LEFT: <gold><b>%player%</b></gold><yellow> <red>вышел</red>. <b>%count%/%max%<b>
SEEKERS_WIN: <b><red>Искатели победили!</red></b>
HIDERS_WIN: <b><gold>Прячущиеся победили!</gold></b>
HIDER_SOLO_WIN: <b><gold><aqua>%player%</aqua> победил!</gold></b>
FREEZE_ITEM: <gradient:#00c6fb:#005bea>Замораживатель 3000</gradient>
SOUND_ITEM: <gradient:#f3e6ff:#dcb3ff>Шумелка 3000</gradient>
LEAVE_ITEM: <red><b>Выйти</red></b>
DASH_ITEM: <gradient:#43cea2:#185a9d>Рывок</gradient>
ROULETTE: <b><gold>Рулетка блоков</b></gold>
TIME_TO_START: <gold>Игра начнется через <b>%time%</b></gold>

19
bin/main/plugin.yml Normal file
View File

@@ -0,0 +1,19 @@
name: BlockAndSeek
version: '0.0.1-a'
main: hdvtdev.blockandseek.BlockAndSeek
api-version: '1.20'
load: POSTWORLD
depend:
- LibsDisguises
permissions:
blockandseek.manage:
description: "Permission to use this subcommands: reload, map"
default: op
commands:
blockandseek:
aliases:
- bs
usage: "Usage: /blockandseek [subcommand]"

View File

@@ -3,7 +3,7 @@ import java.nio.ByteOrder
plugins { plugins {
id 'java' id 'java'
id "com.gradleup.shadow" version "9.2.2" id("com.gradleup.shadow") version "8.3.9"
} }
group = 'hdvtdev' group = 'hdvtdev'
@@ -14,6 +14,7 @@ repositories {
maven { url 'https://storehouse.okaeri.eu/repository/maven-releases/'} maven { url 'https://storehouse.okaeri.eu/repository/maven-releases/'}
maven { url 'https://repo.md-5.net/content/groups/public/' } maven { url 'https://repo.md-5.net/content/groups/public/' }
maven { url 'https://jitpack.io' } maven { url 'https://jitpack.io' }
maven {url 'https://repo.codemc.io/repository/maven-releases'}
maven { maven {
name = "papermc-repo" name = "papermc-repo"
url = "https://repo.papermc.io/repository/maven-public/" url = "https://repo.papermc.io/repository/maven-public/"
@@ -28,8 +29,9 @@ repositories {
def okaeriConfigsVersion = '5.0.13' def okaeriConfigsVersion = '5.0.13'
dependencies { dependencies {
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT") compileOnly("io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT")
compileOnly group: 'me.libraryaddict.disguises', name: 'libsdisguises', version: '11.0.6' compileOnly group: 'me.libraryaddict.disguises', name: 'libsdisguises', version: '11.0.6'
compileOnly 'com.github.retrooper:packetevents-spigot:2.10.1'
compileOnly 'org.projectlombok:lombok:1.18.42' compileOnly 'org.projectlombok:lombok:1.18.42'
annotationProcessor 'org.projectlombok:lombok:1.18.42' annotationProcessor 'org.projectlombok:lombok:1.18.42'
@@ -39,10 +41,11 @@ dependencies {
implementation "eu.okaeri:okaeri-configs-serdes-commons:$okaeriConfigsVersion" implementation "eu.okaeri:okaeri-configs-serdes-commons:$okaeriConfigsVersion"
implementation "org.incendo:cloud-paper:2.0.0-beta.13" implementation "org.incendo:cloud-paper:2.0.0-beta.13"
implementation "org.incendo:cloud-annotations:2.0.0"
} }
def targetJavaVersion = 17 def targetJavaVersion = 21
java { java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion) def javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion sourceCompatibility = javaVersion

View File

@@ -1,14 +1,10 @@
<?xml version="1.0" ?> <?xml version="1.0" ?>
<!DOCTYPE xml> <!DOCTYPE xml>
<project name="BlockAndSeek" default="Build"> <project name="BlockAndSeek" default="Build">
<target name="Build"> <target name="Build">
<jar jarfile="/home/hadvart/Documents/Minecraft/Pufferfish 1.20.4/plugins/${ant.project.name}-ant.jar"> <jar jarfile="/home/hadvart/Documents/Minecraft/Pufferfish 1.20.4/plugins/${ant.project.name}-ant.jar">
<fileset dir="./build/classes/java/main" includes="**/*"/> <fileset dir="./build/classes/java/main" includes="**/*"/>
<fileset dir="./build/resources/main" includes="**/*"/> <fileset dir="./build/resources/main" includes="**/*"/>
</jar> </jar>
</target> </target>
</project> </project>

3
deploy.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/bash
gradle deploy
scp -P 8841 ~/Documents/minecraft/Pufferfish/1.21.8/plugins/BlockAndSeek-0.0.1-a.jar hdvt@sasha.hdvtdev.tech:~/pryatki/1.21.8/plugins

View File

@@ -1 +1,7 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

251
gradlew vendored Executable file
View File

@@ -0,0 +1,251 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH="\\\"\\\""
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
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
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
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 ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | 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" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_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 -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# 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.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

94
gradlew.bat vendored Normal file
View File

@@ -0,0 +1,94 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

BIN
pack.zip Normal file

Binary file not shown.

View File

@@ -1,44 +1,58 @@
package hdvtdev.blockandseek; package hdvtdev.blockandseek;
import hdvtdev.blockandseek.eventListeners.RequiredEventListener;
import hdvtdev.blockandseek.eventListeners.EventListener; import hdvtdev.blockandseek.eventListeners.EventListener;
import hdvtdev.blockandseek.eventListeners.ForceControlEventListener; import hdvtdev.blockandseek.eventListeners.ForceControlEventListener;
import hdvtdev.blockandseek.eventListeners.RequiredEventListener;
import hdvtdev.blockandseek.items.Pistol;
import hdvtdev.blockandseek.managers.*; import hdvtdev.blockandseek.managers.*;
import hdvtdev.blockandseek.objects.*; import hdvtdev.blockandseek.objects.*;
import hdvtdev.blockandseek.roulette.RouletteCreator; import hdvtdev.blockandseek.roulette.RouletteCreator;
import java.io.File;
import java.time.Duration;
import java.util.*;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.disguisetypes.MiscDisguise;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand; import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.RayTraceResult;
import org.incendo.cloud.bukkit.CloudBukkitCapabilities; import org.incendo.cloud.bukkit.CloudBukkitCapabilities;
import org.incendo.cloud.bukkit.parser.PlayerParser;
import org.incendo.cloud.bukkit.parser.location.LocationParser; import org.incendo.cloud.bukkit.parser.location.LocationParser;
import org.incendo.cloud.execution.ExecutionCoordinator; import org.incendo.cloud.execution.ExecutionCoordinator;
import org.incendo.cloud.paper.LegacyPaperCommandManager; import org.incendo.cloud.paper.LegacyPaperCommandManager;
import org.incendo.cloud.parser.standard.StringParser; import org.incendo.cloud.parser.standard.StringParser;
import org.incendo.cloud.suggestion.Suggestion;
import java.io.File; import org.incendo.cloud.suggestion.SuggestionProvider;
import java.util.*;
import java.util.logging.Logger;
import java.util.stream.Collectors;
public class BlockAndSeek extends JavaPlugin { public class BlockAndSeek extends JavaPlugin {
private static JavaPlugin javaPlugin; private static JavaPlugin javaPlugin;
private static LegacyPaperCommandManager<CommandSender> commandManager;
private static final String perm = "blockandseek.manage"; private static final String perm = "blockandseek.manage";
public static Plugin getInstance() { public static Plugin getInstance() {
@@ -61,32 +75,41 @@ public class BlockAndSeek extends JavaPlugin {
return javaPlugin.getLogger(); return javaPlugin.getLogger();
} }
@Override @Override
public void onEnable() { public void onEnable() {
javaPlugin = this; javaPlugin = this;
LibsDisguises libsDisguises = (LibsDisguises) Bukkit.getPluginManager().getPlugin("LibsDisguises"); LibsDisguises libsDisguises =
(LibsDisguises) Bukkit.getPluginManager().getPlugin(
"LibsDisguises"
);
if (libsDisguises == null) { if (libsDisguises == null) {
getLogger().severe("LibsDisguises not found! It's required for the plugin to work!"); getLogger().severe(
"LibsDisguises not found! It's required for the plugin to work!"
);
super.onDisable(); super.onDisable();
} }
this.init(); this.init();
PluginCommand command = Objects.requireNonNull(getCommand("blockandseek")); PluginCommand command = Objects.requireNonNull(
getCommand("blockandseek")
);
PluginManager manager = getServer().getPluginManager(); PluginManager manager = getServer().getPluginManager();
boolean forceControl = Config.forceControl(); boolean forceControl = Config.forceControl();
if (forceControl) getLogger().info("Using force control"); if (forceControl) getLogger().info("Using force control");
manager.registerEvents(forceControl ? new ForceControlEventListener() : new EventListener(), this); manager.registerEvents(
forceControl
? new ForceControlEventListener()
: new EventListener(),
this
);
manager.registerEvents(new RequiredEventListener(), this); manager.registerEvents(new RequiredEventListener(), this);
} }
private void init() { private void init() {
try { try {
File dataFolder = getDataFolder(); File dataFolder = getDataFolder();
if (!dataFolder.exists()) { if (!dataFolder.exists()) {
@@ -109,254 +132,15 @@ public class BlockAndSeek extends JavaPlugin {
saveResource("languages/en_US.yml", false); saveResource("languages/en_US.yml", false);
} }
MapsManager.loadMaps();
TranslationManager.loadLanguages(); TranslationManager.loadLanguages();
MapsManager.loadMaps();
commandManager = LegacyPaperCommandManager.createNative( CommandManager.registerCommands();
this,
ExecutionCoordinator.simpleCoordinator()
);
if (commandManager.hasCapability(CloudBukkitCapabilities.NATIVE_BRIGADIER)) {
try {
commandManager.registerBrigadier();
} catch (IllegalStateException ignored) {
}
}
this.registerCommands();
} catch (Exception e) { } catch (Exception e) {
getLogger().severe("Cloud err: " + e.getMessage()); getLogger().severe("Cloud err: " + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
} }
private final PropManager propManager = new PropManager();
private void registerCommands() {
var root = commandManager.commandBuilder("blockandseek");
var editBase = root
.literal("editMap")
.required("map_name", StringParser.stringParser(), MapsManager.mapSuggestions);
//edit commands
commandManager.command(
editBase.literal("setLobby") // Это наш <parameter> как литерал
.required("location", LocationParser.locationParser())
.handler(ctx -> {
})
);
commandManager.command(
editBase.literal("setLocation")
.required("location", LocationParser.locationParser()) // Это <value>
.handler(ctx -> {
String configName = ctx.get("config_name");
Location location = ctx.get("location");
ctx.sender().sendMessage("В конфиге " + configName + " точка установлена: " + location.toString());
})
);
commandManager.command(root
.literal("maps")
.handler(ctx -> {
ctx.sender().sendMessage(MapsManager.getMaps().stream().map(BlockAndSeekMap::getWorld).collect(Collectors.joining(", ")));
})
);
commandManager.command(root
.literal("testMessage")
.handler(ctx -> {
ctx.sender().sendMessage(MiniMessage.miniMessage().deserialize(" <gradient:#FFAA00:#FFD700><bold>System</bold></gradient> <dark_gray>»</dark_gray> <yellow>Ваш игровой режим изменен.</yellow>\n"));
})
);
commandManager.command(root
.literal("menuTest")
.handler(ctx -> {
if (ctx.sender() instanceof Player player) {
player.getInventory().addItem(ItemManager.getMenuItem());
}
})
);
commandManager.command(root
.literal("localeTest")
.handler(ctx -> {
if (ctx.sender() instanceof Player player) {
player.sendMessage("Locale is: " + player.locale());
player.sendMessage(TranslationManager.get(player, TranslationKey.FREEZE_ITEM));
}
})
);
commandManager.command(root
.literal("createGame")
.permission(perm)
.required("map_name", StringParser.stringParser(), MapsManager.mapSuggestions)
.handler(context -> {
String name = context.get("map_name");
GamesManager.createGame(name);
if (context.sender() instanceof Player player) {
GamesManager.get(name).addPlayer(player);
}
})
);
commandManager.command(root
.literal("createMap")
.permission(perm)
.required("map_name", StringParser.stringParser(), MapsManager.worldSuggestions)
.handler(context -> {
String name = context.get("map_name");
MapsManager.createMap(name);
context.sender().sendMessage("Map probably created");
})
);
commandManager.command(root
.literal("joinGame")
.permission(perm)
.required("name", StringParser.stringParser())
.handler(context -> {
String name = context.get("name");
if (context.sender() instanceof Player player) {
BlockAndSeekGame game = GamesManager.get(name);
if (game != null) game.addPlayer(player);
}
})
);
commandManager.command(
editBase.literal("generateBlocks")
.handler(ctx -> {
if (ctx.sender() instanceof Player player) {
String mapName = ctx.get("map_name");
BlockAndSeekMap map = MapsManager.getMap(mapName);
var cached = BlocksGenerator.get(map.getSpawn().getWorld().getName());
if (cached != null) {
new RouletteCreator(player, cached);
} else {
BlocksGenerator.getSortedBlockStats(player.getLocation(), 32, (var list) -> {
List<Map.Entry<Material, Long>> selectedBlocks = new ArrayList<>(list);
// 2. Перемешиваем и берем 30 случайных (или меньше, если всего блоков меньше 30)
Collections.shuffle(selectedBlocks);
if (selectedBlocks.size() > 30) {
selectedBlocks = selectedBlocks.subList(0, 30);
}
selectedBlocks.sort((a, b) -> Long.compare(b.getValue(), a.getValue()));
List<Map.Entry<Material, Rarity>> result = new ArrayList<>();
// 4. Считаем общий вес редкостей (100 + 50 + 25 + ...) = 189
int totalWeight = Arrays.stream(Rarity.values()).mapToInt(Rarity::getChance).sum();
// Шаг веса на один блок.
// Представь длинную полоску длиной 189 единиц. Мы режем её на 30 равных частей.
// Куда попадает разрез — такая и редкость.
double weightStep = (double) totalWeight / selectedBlocks.size();
double currentWeightPosition = 0; // Текущая позиция на шкале весов
// Идем по отсортированному списку (от самых частых к самым редким)
for (Map.Entry<Material, Long> entry : selectedBlocks) {
// Определяем, в какой диапазон редкости попадает текущий блок
Rarity assignedRarity = Rarity.COMMON; // Дефолт
int weightCursor = 0;
for (Rarity r : Rarity.values()) {
weightCursor += r.getChance();
// Если текущая позиция веса меньше границы этой редкости — мы нашли её
// (Добавляем половину шага, чтобы брать "центр" диапазона блока для точности)
if ((currentWeightPosition + weightStep / 2) <= weightCursor) {
assignedRarity = r;
break;
}
}
result.add(new AbstractMap.SimpleEntry<>(entry.getKey(), assignedRarity));
// Сдвигаемся дальше по шкале
currentWeightPosition += weightStep;
}
var r = result.stream().map(e -> new PropBlock(new ItemStack(e.getKey()), e.getValue())).toList();
map.setBlocks(r);
map.save();
BlocksGenerator.addCache(player.getLocation().getWorld().getName(), r);
});
}
}
})
);
}
private void spawnSmokeCloud(Location center) {
new BukkitRunnable() {
int ticksPassed = 0;
final int maxIterations = (10 * 20) / 5;
@Override
public void run() {
if (ticksPassed >= maxIterations) {
this.cancel();
return;
}
World world = center.getWorld();
if (world == null) return;
world.spawnParticle(Particle.EXPLOSION_HUGE, center, 15, 1.2, 1.2, 1.2, 0.05);
for (var entity : world.getNearbyEntities(center, 2.5, 2.5, 2.5)) {
if (entity instanceof Player player && player.getLocation().distanceSquared(center) <= 9) {
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 40, 1));
}
}
ticksPassed++;
}
}.runTaskTimer(this, 0L, 5L);
}
} }

View File

@@ -1,6 +1,8 @@
package hdvtdev.blockandseek; package hdvtdev.blockandseek;
import hdvtdev.blockandseek.managers.MapsManager;
import hdvtdev.blockandseek.objects.PropBlock; import hdvtdev.blockandseek.objects.PropBlock;
import hdvtdev.blockandseek.objects.Rarity;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.block.Banner; import org.bukkit.block.Banner;
import org.bukkit.block.Comparator; import org.bukkit.block.Comparator;
@@ -8,6 +10,7 @@ import org.bukkit.block.data.*;
import org.bukkit.block.data.type.Observer; import org.bukkit.block.data.type.Observer;
import org.bukkit.block.data.type.Piston; import org.bukkit.block.data.type.Piston;
import org.bukkit.block.data.type.RedstoneWire; import org.bukkit.block.data.type.RedstoneWire;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.ApiStatus;
@@ -24,7 +27,7 @@ public class BlocksGenerator {
private static final Map<String, List<PropBlock>> cached = new HashMap<>(); private static final Map<String, List<PropBlock>> cached = new HashMap<>();
static { static {
// --- 1. ГРАВИТАЦИЯ (Сыпучие) ---
BLACKLIST.add(Material.SAND); BLACKLIST.add(Material.SAND);
BLACKLIST.add(Material.RED_SAND); BLACKLIST.add(Material.RED_SAND);
BLACKLIST.add(Material.GRAVEL); BLACKLIST.add(Material.GRAVEL);
@@ -32,20 +35,19 @@ public class BlocksGenerator {
BLACKLIST.add(Material.ANVIL); BLACKLIST.add(Material.ANVIL);
BLACKLIST.add(Material.CHIPPED_ANVIL); BLACKLIST.add(Material.CHIPPED_ANVIL);
BLACKLIST.add(Material.DAMAGED_ANVIL); BLACKLIST.add(Material.DAMAGED_ANVIL);
BLACKLIST.add(Material.POINTED_DRIPSTONE); // Сталактит (может упасть) BLACKLIST.add(Material.POINTED_DRIPSTONE);
BLACKLIST.add(Material.SCAFFOLDING); // Строительные леса BLACKLIST.add(Material.SCAFFOLDING);
// --- 2. РЕДСТОУН И МЕХАНИЗМЫ --- BLACKLIST.addAll(Tag.BUTTONS.getValues());
BLACKLIST.addAll(Tag.BUTTONS.getValues()); // Все кнопки BLACKLIST.addAll(Tag.PRESSURE_PLATES.getValues());
BLACKLIST.addAll(Tag.PRESSURE_PLATES.getValues()); // Все нажимные плиты BLACKLIST.addAll(Tag.DOORS.getValues());
BLACKLIST.addAll(Tag.DOORS.getValues()); // Двери BLACKLIST.addAll(Tag.TRAPDOORS.getValues());
BLACKLIST.addAll(Tag.TRAPDOORS.getValues()); // Люки BLACKLIST.addAll(Tag.FENCE_GATES.getValues());
BLACKLIST.addAll(Tag.FENCE_GATES.getValues()); // Калитки BLACKLIST.addAll(Tag.RAILS.getValues());
BLACKLIST.addAll(Tag.RAILS.getValues()); // Рельсы
BLACKLIST.add(Material.REDSTONE_WIRE); BLACKLIST.add(Material.REDSTONE_WIRE);
BLACKLIST.add(Material.REDSTONE_TORCH); BLACKLIST.add(Material.REDSTONE_TORCH);
BLACKLIST.add(Material.REDSTONE_BLOCK); // Если не нужен блок редстоуна BLACKLIST.add(Material.REDSTONE_BLOCK);
BLACKLIST.add(Material.REPEATER); BLACKLIST.add(Material.REPEATER);
BLACKLIST.add(Material.COMPARATOR); BLACKLIST.add(Material.COMPARATOR);
BLACKLIST.add(Material.OBSERVER); BLACKLIST.add(Material.OBSERVER);
@@ -70,20 +72,19 @@ public class BlocksGenerator {
BLACKLIST.add(Material.REPEATING_COMMAND_BLOCK); BLACKLIST.add(Material.REPEATING_COMMAND_BLOCK);
BLACKLIST.add(Material.CHAIN_COMMAND_BLOCK); BLACKLIST.add(Material.CHAIN_COMMAND_BLOCK);
BLACKLIST.add(Material.LIGHTNING_ROD); BLACKLIST.add(Material.LIGHTNING_ROD);
BLACKLIST.add(Material.BELL); // Колокол BLACKLIST.add(Material.BELL);
// --- 3. ХРУПКИЕ / ЗАВИСЯЩИЕ ОТ ОПОРЫ (Растения, декор) --- BLACKLIST.addAll(Tag.SAPLINGS.getValues());
BLACKLIST.addAll(Tag.SAPLINGS.getValues()); // Саженцы BLACKLIST.addAll(Tag.FLOWERS.getValues());
BLACKLIST.addAll(Tag.FLOWERS.getValues()); // Цветы BLACKLIST.addAll(Tag.CROPS.getValues());
BLACKLIST.addAll(Tag.CROPS.getValues()); // Пшеница, картошка и т.д. BLACKLIST.addAll(Tag.BANNERS.getValues());
BLACKLIST.addAll(Tag.BANNERS.getValues()); // Флаги (стоячие и настенные) BLACKLIST.addAll(Tag.SIGNS.getValues());
BLACKLIST.addAll(Tag.SIGNS.getValues()); // Таблички BLACKLIST.addAll(Tag.BEDS.getValues());
BLACKLIST.addAll(Tag.BEDS.getValues()); // Кровати BLACKLIST.addAll(Tag.CANDLES.getValues());
BLACKLIST.addAll(Tag.CANDLES.getValues()); // Свечи BLACKLIST.addAll(Tag.CAMPFIRES.getValues());
BLACKLIST.addAll(Tag.CAMPFIRES.getValues()); // Костры BLACKLIST.addAll(Tag.CAULDRONS.getValues());
BLACKLIST.addAll(Tag.CAULDRONS.getValues()); // Котлы BLACKLIST.addAll(Tag.WOOL_CARPETS.getValues());
BLACKLIST.addAll(Tag.WOOL_CARPETS.getValues()); // Ковры BLACKLIST.addAll(Tag.FLOWER_POTS.getValues());
BLACKLIST.addAll(Tag.FLOWER_POTS.getValues()); // Горшки
BLACKLIST.add(Material.BROWN_MUSHROOM); BLACKLIST.add(Material.BROWN_MUSHROOM);
BLACKLIST.add(Material.RED_MUSHROOM); BLACKLIST.add(Material.RED_MUSHROOM);
@@ -126,13 +127,12 @@ public class BlocksGenerator {
BLACKLIST.add(Material.SOUL_LANTERN); BLACKLIST.add(Material.SOUL_LANTERN);
BLACKLIST.add(Material.CHAIN); BLACKLIST.add(Material.CHAIN);
BLACKLIST.add(Material.END_ROD); BLACKLIST.add(Material.END_ROD);
BLACKLIST.add(Material.IRON_BARS); // Обычно некрасиво в топах BLACKLIST.add(Material.IRON_BARS);
BLACKLIST.add(Material.LADDER); BLACKLIST.add(Material.LADDER);
BLACKLIST.add(Material.SNOW); // Снежный покров (тонкий) BLACKLIST.add(Material.SNOW);
BLACKLIST.add(Material.TURTLE_EGG); BLACKLIST.add(Material.TURTLE_EGG);
BLACKLIST.add(Material.CAKE); BLACKLIST.add(Material.CAKE);
// --- 4. КОНТЕЙНЕРЫ (Если не хочешь, чтобы выпадали сундуки) ---
BLACKLIST.add(Material.CHEST); BLACKLIST.add(Material.CHEST);
BLACKLIST.add(Material.TRAPPED_CHEST); BLACKLIST.add(Material.TRAPPED_CHEST);
BLACKLIST.add(Material.ENDER_CHEST); BLACKLIST.add(Material.ENDER_CHEST);
@@ -146,7 +146,6 @@ public class BlocksGenerator {
BLACKLIST.add(Material.BEEHIVE); BLACKLIST.add(Material.BEEHIVE);
BLACKLIST.add(Material.BEE_NEST); BLACKLIST.add(Material.BEE_NEST);
// --- 5. ТЕХНИЧЕСКИЕ И ПРОЗРАЧНЫЕ ---
BLACKLIST.add(Material.BARRIER); BLACKLIST.add(Material.BARRIER);
BLACKLIST.add(Material.STRUCTURE_VOID); BLACKLIST.add(Material.STRUCTURE_VOID);
BLACKLIST.add(Material.STRUCTURE_BLOCK); BLACKLIST.add(Material.STRUCTURE_BLOCK);
@@ -154,40 +153,78 @@ public class BlocksGenerator {
BLACKLIST.add(Material.LIGHT); BLACKLIST.add(Material.LIGHT);
BLACKLIST.add(Material.SPAWNER); BLACKLIST.add(Material.SPAWNER);
BLACKLIST.add(Material.COBWEB); BLACKLIST.add(Material.COBWEB);
BLACKLIST.add(Material.SLIME_BLOCK); // Спорно, но липкий BLACKLIST.add(Material.SLIME_BLOCK);
BLACKLIST.add(Material.HONEY_BLOCK); BLACKLIST.add(Material.HONEY_BLOCK);
// --- 6. ЗАЧИСТКА ПО ИМЕНАМ (На всякий случай) ---
// Добавляем все, что мы могли забыть, но что имеет общие корни
for (Material m : Material.values()) { for (Material m : Material.values()) {
String name = m.name(); String name = m.name();
if (name.contains("POTTED") || // Горшки с цветами if (name.contains("POTTED") ||
name.contains("WALL_") || // Настенные варианты (факелы, знаки) name.contains("WALL_") ||
name.contains("HEAD") || // Головы name.contains("HEAD") ||
name.contains("SKULL") || // Черепа name.contains("SKULL") ||
name.contains("BANNER") || // Флаги (дублируем для надежности) name.contains("BANNER") ||
name.contains("CORAL") // Кораллы (дохнут без воды) name.contains("CORAL")
) { ) {
BLACKLIST.add(m); BLACKLIST.add(m);
} }
} }
} }
// Твой метод проверки стал очень простым public static boolean isSupported(Material type) {
private static boolean isSupported(Material type) {
// 1. Воздух
if (type.isAir()) return false; if (type.isAir()) return false;
// 2. Черный список (самая надежная проверка)
if (BLACKLIST.contains(type)) { if (BLACKLIST.contains(type)) {
return false; return false;
} }
// 3. Дополнительная защита: блок должен быть твердым
// (Это отсечет то, что мы могли случайно забыть в списке, типа нитки/String)
return type.isSolid(); return type.isSolid();
} }
public static void applyBlocks(String mapName) {
var map = MapsManager.getMap(mapName);
getSortedBlockStats(map.getSpawn().getLocation(), 16, list -> {
// 1. Находим экстремумы (минимум и максимум кол-ва предметов)
long minCount = list.stream().mapToLong(Map.Entry::getValue).min().orElse(0);
long maxCount = list.stream().mapToLong(Map.Entry::getValue).max().orElse(0);
// 2. Находим "Центр" (Median Point)
// Все, что близко к этому числу -> COMMON. Все, что далеко -> LEGENDARY.
double midPoint = (minCount + maxCount) / 2.0;
// Максимально возможное расстояние от центра до края
double maxDistance = Math.max(maxCount - midPoint, midPoint - minCount);
List<Map.Entry<Material, Rarity>> result = new ArrayList<>();
for (Map.Entry<Material, Long> entry : list) {
long count = entry.getValue();
// 3. Считаем дистанцию от центра (по модулю, чтобы и мало, и много давали плюс)
double distance = Math.abs(count - midPoint);
// 4. Нормализуем в значение от 0.0 до 1.0
// 0.0 = ровно середина
// 1.0 = это либо minCount, либо maxCount
double deviationPercent = distance / maxDistance;
// 5. Определяем редкость
Rarity rarity = Rarity.getByDeviation(deviationPercent);
result.add(Map.entry(entry.getKey(), rarity));
}
map.setBlocks(result.stream().map(e -> new PropBlock(new ItemStack(e.getKey()), e.getValue())).toList());
map.save();
});
}
@ApiStatus.Experimental
public static void getSortedBlockStats(Location center, int chunkRadius, Consumer<List<Map.Entry<Material, Long>>> callback) { public static void getSortedBlockStats(Location center, int chunkRadius, Consumer<List<Map.Entry<Material, Long>>> callback) {
World world = center.getWorld(); World world = center.getWorld();
if (world == null) return; if (world == null) return;

View File

@@ -1,58 +0,0 @@
package hdvtdev.blockandseek;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
public class CommandBuilder {
private final List<Node> forest = new ArrayList<>();
public Node addNode(String name) {
Node node = new Node(name);
forest.add(node);
return node;
}
@Nullable
public String tryGet(String fullPath) {
return null;
}
public static void printTree(Node node, String indent) {
System.out.println(indent + "- " + node.getName());
for (Node child : node.getChildren()) {
printTree(child, indent + " ");
}
}
public static class Node {
private final String name;
private final List<Node> children;
public Node(String name) {
this.name = name;
this.children = new ArrayList<>();
}
public void addChild(Node child) {
this.children.add(child);
}
public List<Node> getChildren() {
return children;
}
public String getName() {
return name;
}
@Override
public String toString() {
return name;
}
}
}

View File

@@ -4,26 +4,40 @@ import eu.okaeri.configs.ConfigManager;
import eu.okaeri.configs.OkaeriConfig; import eu.okaeri.configs.OkaeriConfig;
import eu.okaeri.configs.annotation.Comment; import eu.okaeri.configs.annotation.Comment;
import eu.okaeri.configs.annotation.Exclude; import eu.okaeri.configs.annotation.Exclude;
import eu.okaeri.configs.exception.OkaeriException;
import eu.okaeri.configs.serdes.commons.SerdesCommons; import eu.okaeri.configs.serdes.commons.SerdesCommons;
import eu.okaeri.configs.yaml.bukkit.YamlBukkitConfigurer; import eu.okaeri.configs.yaml.bukkit.YamlBukkitConfigurer;
import eu.okaeri.configs.yaml.bukkit.serdes.SerdesBukkit; import eu.okaeri.configs.yaml.bukkit.serdes.SerdesBukkit;
import hdvtdev.blockandseek.objects.LazyLocation;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.WorldCreator; import org.bukkit.WorldCreator;
import org.bukkit.entity.Player;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.Objects; import java.util.Objects;
public class Config extends OkaeriConfig { public class Config extends OkaeriConfig {
static {
loadConfig();
}
@Exclude @Exclude
private static Config config; private static Config config;
static { @Comment("Server options.")
private ServerSettings serverSettings = new ServerSettings();
@Comment("Spawn location. Useless if the Server.forceControl is false.")
private LazyLocation spawn;
@Comment("Show hidden BlockAndSeek commands.")
private boolean enableDebugCommands = false;
public static boolean loadConfig() {
try { try {
File configFile = new File(BlockAndSeek.getPluginDataFolder(), "config.yml"); File configFile = new File(BlockAndSeek.getPluginDataFolder(), "config.yml");
if (!configFile.exists()) configFile.createNewFile();
config = ConfigManager.create(Config.class, (it) -> { config = ConfigManager.create(Config.class, (it) -> {
it.withConfigurer( it.withConfigurer(
new YamlBukkitConfigurer(), new YamlBukkitConfigurer(),
@@ -33,23 +47,16 @@ public class Config extends OkaeriConfig {
it.withBindFile(configFile); it.withBindFile(configFile);
it.withLogger(BlockAndSeek.getPluginLogger()); it.withLogger(BlockAndSeek.getPluginLogger());
it.saveDefaults(); it.saveDefaults();
it.load(true);
}); });
return true;
config.load(); } catch (OkaeriException e) {
config.save();
} catch (Exception e) {
BlockAndSeek.getPluginLogger().severe("Failed to load config.yml: " + e.getMessage()); BlockAndSeek.getPluginLogger().severe("Failed to load config.yml: " + e.getMessage());
e.printStackTrace(); e.printStackTrace();
return false;
} }
} }
@Comment("Server options.")
private ServerSettings serverSettings = new ServerSettings();
@Comment("Spawn location. Useless if the Server.forceControl is false.")
private Location spawn = Objects.requireNonNull(Bukkit.createWorld(new WorldCreator("world"))).getSpawnLocation();
@Comment("Show hidden BlockAndSeek commands.")
private boolean enableDebugCommands = false;
public static boolean debugEnabled() { public static boolean debugEnabled() {
return config.enableDebugCommands; return config.enableDebugCommands;
@@ -60,7 +67,11 @@ public class Config extends OkaeriConfig {
} }
public static Location spawn() { public static Location spawn() {
return config.spawn; return config.spawn.getLocation();
}
public static void teleportToSpawn(Player player) {
config.spawn.teleport(player);
} }
public static String toStaticString() { public static String toStaticString() {

View File

@@ -0,0 +1,83 @@
package hdvtdev.blockandseek;
import com.github.retrooper.packetevents.PacketEvents;
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
import com.github.retrooper.packetevents.util.Vector3d;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerDestroyEntities;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityMetadata;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerSpawnEntity;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
public class GlowUtil {
public static int highlightBlock(Player viewer, Location blockLoc) {
int entityId = -ThreadLocalRandom.current().nextInt(10000, Integer.MAX_VALUE);
UUID uuid = UUID.randomUUID();
Vector3d position = new Vector3d(
blockLoc.getX(),
blockLoc.getY(),
blockLoc.getZ()
);
WrapperPlayServerSpawnEntity spawnPacket = new WrapperPlayServerSpawnEntity(
entityId,
Optional.of(uuid),
EntityTypes.INTERACTION,
position,
0f, 0f, 0f,
0,
Optional.empty()
);
List<EntityData<?>> metaDataList = new ArrayList<>();
byte flags = (byte) 0x40;
metaDataList.add(new EntityData<>(0, EntityDataTypes.BYTE, flags));
metaDataList.add(new EntityData<>(8, EntityDataTypes.FLOAT, 1.0f));
metaDataList.add(new EntityData<>(9, EntityDataTypes.FLOAT, 1.0f));
WrapperPlayServerEntityMetadata metadataPacket = new WrapperPlayServerEntityMetadata(entityId, metaDataList);
PacketEvents.getAPI().getPlayerManager().sendPacket(viewer, spawnPacket);
PacketEvents.getAPI().getPlayerManager().sendPacket(viewer, metadataPacket);
return entityId;
}
public static void removeGlow(Player viewer, int entityId) {
WrapperPlayServerDestroyEntities destroyPacket = new WrapperPlayServerDestroyEntities(new int[]{entityId});
PacketEvents.getAPI().getPlayerManager().sendPacket(viewer, destroyPacket);
}
public static void setPlayerGlowing(Player viewer, Player target, boolean glowing) {
List<EntityData<?>> metaDataList = new ArrayList<>();
byte flags = 0;
if (target.getFireTicks() > 0) flags |= 0x01;
if (target.isSneaking()) flags |= 0x02;
if (target.isSprinting()) flags |= 0x08;
if (target.isSwimming()) flags |= 0x10;
if (target.isInvisible()) flags |= 0x20;
if (glowing) {
flags |= 0x40;
} else {
if (target.isGlowing()) flags |= 0x40;
}
if (target.isGliding()) flags |= (byte) 0x80;
metaDataList.add(new EntityData<>(0, EntityDataTypes.BYTE, flags));
WrapperPlayServerEntityMetadata metadataPacket = new WrapperPlayServerEntityMetadata(target.getEntityId(), metaDataList);
PacketEvents.getAPI().getPlayerManager().sendPacket(viewer, metadataPacket);
}
}

View File

@@ -13,6 +13,7 @@ public class Keys {
public static final NamespacedKey FACE_CHANGING_ITEM = new NamespacedKey(BlockAndSeek.getInstance(), "BlockAndSeekFaceChangingItem"); public static final NamespacedKey FACE_CHANGING_ITEM = new NamespacedKey(BlockAndSeek.getInstance(), "BlockAndSeekFaceChangingItem");
public static final NamespacedKey MENU_ITEM = new NamespacedKey(BlockAndSeek.getInstance(), "BlockAndSeekMenuItem"); public static final NamespacedKey MENU_ITEM = new NamespacedKey(BlockAndSeek.getInstance(), "BlockAndSeekMenuItem");
public static final NamespacedKey LEAVE_ITEM = new NamespacedKey(BlockAndSeek.getInstance(), "BlockAndSeekLeaveItem"); public static final NamespacedKey LEAVE_ITEM = new NamespacedKey(BlockAndSeek.getInstance(), "BlockAndSeekLeaveItem");
public static final NamespacedKey PISTOL = new NamespacedKey(BlockAndSeek.getInstance(), "BlockAndSeekPistol");
public static final Team NO_COLLIDE_TEAM; public static final Team NO_COLLIDE_TEAM;

View File

@@ -1,12 +1,13 @@
package hdvtdev.blockandseek; package hdvtdev.blockandseek;
import hdvtdev.blockandseek.managers.PropManager;
import hdvtdev.blockandseek.objects.BlockAndSeekItem;
import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.DisguiseAPI;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.potion.PotionEffect;
public final class Utils { public final class Utils {
@@ -18,6 +19,20 @@ public final class Utils {
p.setExp(0.9998f * ((float) level / 100)); p.setExp(0.9998f * ((float) level / 100));
} }
public static void damageSeeker(Player seeker, int damage) {
seeker.damage(damage);
setLevelWithBar(seeker, (int) (seeker.getHealth() * 5));
}
public static void healSeeker(Player player, double heal) {
double currentHealth = player.getHealth();
if (currentHealth < 20) {
double newHealth = Math.min(currentHealth + heal, 20);
player.setHealth(newHealth);
setLevelWithBar(player, (int) Math.round(player.getHealth() * 5));
}
}
public static void clearPlayer(Player player) { public static void clearPlayer(Player player) {
DisguiseAPI.undisguiseToAll(player); DisguiseAPI.undisguiseToAll(player);
@@ -25,7 +40,8 @@ public final class Utils {
player.getInventory().clear(); player.getInventory().clear();
player.getInventory().setArmorContents(null); player.getInventory().setArmorContents(null);
player.getInventory().setExtraContents(null); player.getInventory().setExtraContents(null);
PropManager.removePlayer(player);
BlockAndSeekItem.removeCooldownImune(player.getUniqueId());
player.setGameMode(GameMode.SURVIVAL); player.setGameMode(GameMode.SURVIVAL);
@@ -33,11 +49,13 @@ public final class Utils {
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(20.0); player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(20.0);
} }
player.setHealth(20.0); player.setHealth(20.0);
player.clearActivePotionEffects();
player.setFoodLevel(20); player.setFoodLevel(20);
player.setSaturation(5.0f); player.setSaturation(5.0f);
player.setExhaustion(0f); player.setExhaustion(0f);
player.setInvulnerable(false); player.setInvulnerable(false);
player.setInvisible(false);
player.setVisibleByDefault(true);
player.setLevel(0); player.setLevel(0);
player.setExp(0f); player.setExp(0f);
player.setFireTicks(0); player.setFireTicks(0);
@@ -53,4 +71,28 @@ public final class Utils {
} }
private static final String serverVersion = org.bukkit.Bukkit.getBukkitVersion().split("-")[0];
public static boolean isVersionAtLeast(String ver) {
String[] serverParts = serverVersion.split("\\.");
String[] targetParts = ver.split("\\.");
boolean isHighEnough = true;
int length = Math.max(serverParts.length, targetParts.length);
for (int i = 0; i < length; i++) {
int sPart = i < serverParts.length ? Integer.parseInt(serverParts[i]) : 0;
int tPart = i < targetParts.length ? Integer.parseInt(targetParts[i]) : 0;
if (sPart != tPart) {
isHighEnough = sPart > tPart;
break;
}
}
return isHighEnough;
}
} }

Some files were not shown because too many files have changed in this diff Show More