first commit

This commit is contained in:
Egor 2023-04-27 23:04:42 +03:00
commit 73eb21510b
689 changed files with 15735 additions and 0 deletions

3
.idea/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

9
.idea/mcPlugins.iml Normal file
View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

8
.idea/modules.xml Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/mcPlugins.iml" filepath="$PROJECT_DIR$/.idea/mcPlugins.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View file

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

118
ArmorBlocks/.gitignore vendored Normal file
View file

@ -0,0 +1,118 @@
# User-specific stuff
.idea/
*.iml
*.ipr
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
.gradle
build/
# Ignore Gradle GUI config
gradle-app.setting
# Cache of project
.gradletasknamecache
**/build/
# Common working directory
run/
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

38
ArmorBlocks/build.gradle Normal file
View file

@ -0,0 +1,38 @@
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
id 'java'
}
group = 'ru.erius'
version = ''
def serverPath = 'C:/mc_servers/1.16.5/plugins'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
repositories {
mavenCentral()
maven {
name = 'spigotmc-repo'
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
}
maven {
name = 'sonatype'
url = 'https://oss.sonatype.org/content/groups/public/'
}
}
dependencies {
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT'
}
processResources {
from(sourceSets.main.resources.srcDirs) {
filter ReplaceTokens, tokens: [version: version]
}
}
jar {
destinationDirectory.set(file(serverPath))
}

View file

Binary file not shown.

View file

@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

188
ArmorBlocks/gradlew vendored Normal file
View file

@ -0,0 +1,188 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

100
ArmorBlocks/gradlew.bat vendored Normal file
View file

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

View file

@ -0,0 +1 @@
rootProject.name = 'ArmorBlocks'

View file

@ -0,0 +1,32 @@
#############################################
# Configuration file for ArmorBlocks plugin #
#############################################
# Possible potion effects:
# speed, slowness, fast_digging, slow_digging, increase_damage, heal, harm, jump, confusion, weakness, poison,
# regeneration, damage_resistance, fire_resistance, water_breathing, invisibility, blindness, night_vision, hunger,
# wither, health_boost, absorption, saturation, glowing, levitation, luck, unluck, slow_falling, conduit_power,
# dolphins_grace, bad_omen, hero_of_the_village
STONE=weakness
COBBLESTONE=weakness
DIRT=blindness
COAL_BLOCK=fast_digging
IRON_BLOCK=fast_digging;absorption
GOLD_BLOCK=fast_digging;absorption;saturation
LAPIS_BLOCK=luck
DIAMOND_BLOCK=fast_digging;absorption;saturation;damage_resistance
NETHERITE_BLOCK=fast_digging;absorption;saturation;damage_resistance;fire_resistance
REDSTONE_BLOCK=night_vision;glowing
EMERALD_BLOCK=hero_of_the_village;glowing;luck
SEA_LANTERN=dolphins_grace;water_breathing
OBSIDIAN=slow;damage_resistance;health_boost;absorption
WHITE_WOOL=speed;
OAK_LOG=regeneration;slow
OAK_PLANKS=slow
GLASS=invisibility
HAY_BLOCK=slow_falling
SLIME_BLOCK=jump
MAGMA_BLOCK=fire_resistance;blindness
TNT=increase_damage;blindness
SOUL_SAND=slow;hunger

View file

@ -0,0 +1,39 @@
package ru.erius.armorblocks;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
import ru.erius.armorblocks.EquipHandle.BlockEffectsInit;
public class ArmorBlocks extends JavaPlugin {
@Override
public void onEnable() {
super.onEnable();
BlockEffectsInit.initConfig();
getLogger().info("ArmorBlocks enabled");
getServer().getPluginManager().registerEvents(new PlayerEvents(), this);
}
@Override
public void onDisable() {
super.onDisable();
getLogger().info("ArmorBlocks disabled");
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
String cmd = command.getName().toLowerCase();
switch (cmd) {
case "abreset":
boolean reset = BlockEffectsInit.resetConfig();
sender.sendMessage(reset ? ChatColor.GREEN + "Config reset successful" : ChatColor.RED + "Something went wrong");
break;
case "abreload":
boolean reload = BlockEffectsInit.reloadConfig();
sender.sendMessage(reload ? ChatColor.GREEN + "Config reload successful" : ChatColor.RED + "Something went wrong");
break;
}
return super.onCommand(sender, command, label, args);
}
}

View file

@ -0,0 +1,87 @@
package ru.erius.armorblocks.EquipHandle;
import org.bukkit.Material;
import org.bukkit.plugin.Plugin;
import org.bukkit.potion.PotionEffectType;
import ru.erius.armorblocks.ArmorBlocks;
import java.io.*;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class BlockEffectsInit {
private final static Plugin plugin = ArmorBlocks.getPlugin(ArmorBlocks.class);
public static HashMap<Material, List<PotionEffectType>> blockEffects;
public static void initConfig() {
plugin.getLogger().info("Started config init");
File config = new File("ArmorBlocks.cfg");
boolean created = true;
if (!config.exists())
created = createConfig(config);
if (!created)
return;
plugin.getLogger().info("Config init successful");
plugin.getLogger().info("Reading the config");
blockEffects = readConfig(config);
plugin.getLogger().info("Config applied");
}
public static boolean resetConfig() {
File config = new File("ArmorBlocks.cfg");
config.delete();
boolean result = createConfig(config);
reloadConfig();
return result;
}
public static boolean reloadConfig() {
File config = new File("ArmorBlocks.cfg");
blockEffects = readConfig(config);
return true;
}
private static boolean createConfig(File file) {
plugin.getLogger().info("Creating config");
try (BufferedWriter writer = new BufferedWriter(new FileWriter(file));
BufferedReader reader = new BufferedReader(new InputStreamReader(plugin.getResource("ru/erius/ArmorBlocks/ArmorBlocks.cfg")))) {
while (reader.ready()) {
String line = reader.readLine();
writer.write(line);
writer.newLine();
}
file.createNewFile();
} catch (IOException e) {
plugin.getLogger().severe("Something went wrong while setting up a new configuration file");
e.printStackTrace();
return false;
}
return true;
}
private static HashMap<Material, List<PotionEffectType>> readConfig(File file) {
HashMap<Material, List<PotionEffectType>> blockEffects = new HashMap<>();
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
while (reader.ready()) {
String[] materialPotions = reader.readLine().split("[=;]");
if (materialPotions.length < 2)
continue;
Material material = Material.getMaterial(materialPotions[0]);
List<PotionEffectType> potions = Stream.of(materialPotions)
.skip(1)
.map(PotionEffectType::getByName)
.filter(Objects::nonNull)
.collect(Collectors.toList());
blockEffects.put(material, potions);
}
} catch (IOException e) {
plugin.getLogger().severe("Something went wrong while reading a configuration file");
e.printStackTrace();
}
return blockEffects;
}
}

View file

@ -0,0 +1,107 @@
package ru.erius.armorblocks.EquipHandle;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import java.util.List;
import static ru.erius.armorblocks.EquipHandle.BlockEffectsInit.blockEffects;
public class InventoryClickHandle {
private final static int HELMET_SLOT = 39;
public static void clickHandle(InventoryClickEvent evt) {
Player player = (Player) evt.getWhoClicked();
ItemStack newHelmet = evt.getCursor();
newHelmet = newHelmet == null ? new ItemStack(Material.AIR) : new ItemStack(newHelmet);
ItemStack oldHelmet = player.getInventory().getHelmet();
oldHelmet = oldHelmet == null ? new ItemStack(Material.AIR) : new ItemStack(oldHelmet);
if (evt.getSlot() == HELMET_SLOT) {
switch (evt.getClick()) {
case LEFT:
clearEffects(blockEffects.get(oldHelmet.getType()), player);
int count;
if (newHelmet.getType() == oldHelmet.getType()) {
count = oldHelmet.getAmount() + newHelmet.getAmount();
if (count <= 64) {
oldHelmet.setAmount(0);
newHelmet.setAmount(count);
}
} else
count = newHelmet.getAmount();
int amplifier = Math.min(count, 4) - 1;
applyEffects(blockEffects.get(newHelmet.getType()), player, amplifier);
replaceHelmet(player, oldHelmet, newHelmet);
break;
case RIGHT:
clearEffects(blockEffects.get(oldHelmet.getType()), player);
if (oldHelmet.getType() == Material.AIR) {
oldHelmet = new ItemStack(newHelmet);
oldHelmet.setAmount(newHelmet.getAmount() - 1);
newHelmet.setAmount(1);
} else if (oldHelmet.getType() == newHelmet.getType()) {
if (oldHelmet.getAmount() >= 64)
break;
int newHelmetAmount = newHelmet.getAmount(), oldHelmetAmount = oldHelmet.getAmount();
newHelmet.setAmount(oldHelmetAmount + 1);
oldHelmet.setAmount(newHelmetAmount - 1);
}
amplifier = Math.min(newHelmet.getAmount(), 4) - 1;
applyEffects(blockEffects.get(newHelmet.getType()), player, amplifier);
if (newHelmet.getType() == Material.AIR) {
amplifier = Math.min(oldHelmet.getAmount() / 2, 4) - 1;
if (oldHelmet.getAmount() > 1)
applyEffects(blockEffects.get(oldHelmet.getType()), player, amplifier);
break;
}
replaceHelmet(player, oldHelmet, newHelmet);
break;
case DROP:
if (newHelmet.getType() == Material.AIR && blockEffects.containsKey(oldHelmet.getType())) {
clearEffects(blockEffects.get(oldHelmet.getType()), player);
if (oldHelmet.getAmount() > 1)
applyEffects(blockEffects.get(oldHelmet.getType()), player, Math.min(oldHelmet.getAmount() - 1, 4) - 1);
}
break;
case CONTROL_DROP:
case SHIFT_LEFT:
if (newHelmet.getType() == Material.AIR && blockEffects.containsKey(oldHelmet.getType()))
clearEffects(blockEffects.get(oldHelmet.getType()), player);
default:
break;
}
}
}
private static void clearEffects(List<PotionEffectType> potionEffectTypes, Player player) {
if (potionEffectTypes == null)
return;
for (PotionEffectType potionEffectType : potionEffectTypes)
player.removePotionEffect(potionEffectType);
}
private static void applyEffects(List<PotionEffectType> potionEffectTypes, Player player, int amplifier) {
if (potionEffectTypes == null)
return;
for (PotionEffectType potionEffectType : potionEffectTypes)
player.addPotionEffect(new PotionEffect(potionEffectType, Integer.MAX_VALUE, amplifier));
}
private static void replaceHelmet(Player player, ItemStack oldHelmet, ItemStack newHelmet) {
new Thread(() -> {
player.setItemOnCursor(oldHelmet);
try {
Thread.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
player.getInventory().setHelmet(newHelmet);
}).start();
}
}

View file

@ -0,0 +1,14 @@
package ru.erius.armorblocks;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import ru.erius.armorblocks.EquipHandle.InventoryClickHandle;
public class PlayerEvents implements Listener {
@EventHandler
public void onInventoryClick(InventoryClickEvent evt) {
InventoryClickHandle.clickHandle(evt);
}
}

View file

@ -0,0 +1,11 @@
name: ArmorBlocks
version: 1.0
main: ru.erius.armorblocks.ArmorBlocks
api-version: 1.16
authors: [ erius ]
description: allows the player to wear any item as helmet, such helmers will apply potion effects from ArmorBlocks.cfg file
commands:
abreset:
description: resets the config file to default settings
abreload:
description: applies changes made to the config

118
BlockShear/.gitignore vendored Normal file
View file

@ -0,0 +1,118 @@
# User-specific stuff
.idea/
*.iml
*.ipr
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
.gradle
build/
# Ignore Gradle GUI config
gradle-app.setting
# Cache of project
.gradletasknamecache
**/build/
# Common working directory
run/
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

43
BlockShear/build.gradle Normal file
View file

@ -0,0 +1,43 @@
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
id 'java'
}
group = 'ru.erius'
version = '1.0-SNAPSHOT'
def serverPath = 'C:/mc_servers/1.17.1/plugins'
def EriusLibPath = 'D:/mc_plugins/EriusLib/build/libs'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
repositories {
mavenCentral()
maven {
name = 'spigotmc-repo'
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
}
maven {
name = 'sonatype'
url = 'https://oss.sonatype.org/content/groups/public/'
}
flatDir {
dirs EriusLibPath
}
}
dependencies {
compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
compileOnly fileTree(dir: EriusLibPath, include: '*.jar')
}
processResources {
from(sourceSets.main.resources.srcDirs) {
filter ReplaceTokens, tokens: [version: version]
}
}
jar {
destinationDirectory.set(file(serverPath))
}

View file

Binary file not shown.

View file

@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

188
BlockShear/gradlew vendored Normal file
View file

@ -0,0 +1,188 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

100
BlockShear/gradlew.bat vendored Normal file
View file

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

View file

@ -0,0 +1 @@
rootProject.name = 'BlockShear'

View file

@ -0,0 +1,24 @@
package ru.erius.blockshear;
import org.bukkit.plugin.java.JavaPlugin;
import ru.erius.blockshear.items.InitItems;
public final class BlockShear extends JavaPlugin {
public static BlockShear plugin;
public BlockShear() {
plugin = this;
}
@Override
public void onEnable() {
InitItems.initItems();
getLogger().info(getName() + " enabled");
}
@Override
public void onDisable() {
getLogger().info(getName() + " disabled");
}
}

View file

@ -0,0 +1,202 @@
package ru.erius.blockshear.items;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import ru.erius.blockshear.BlockShear;
import ru.erius.eriuslib.items.CustomItem;
public class BlockShears extends CustomItem {
private final static String NAME = "block_shears";
private final static Material MATERIAL = Material.SHEARS;
public BlockShears() {
super(NAME, MATERIAL);
}
@Override
public void addRecipe() {
String[][] recipeShapes = {{"_A", "A_"}, {"A_", "_A"}};
for (int i = 0; i < recipeShapes.length; i++) {
NamespacedKey key = new NamespacedKey(BlockShear.plugin, NAME + i);
ShapedRecipe newRecipe = new ShapedRecipe(key, new BlockShears());
newRecipe.shape(recipeShapes[i]);
newRecipe.setIngredient('A', Material.DIAMOND);
Bukkit.addRecipe(newRecipe);
}
}
@Override
public void onConsume(PlayerItemConsumeEvent evt) {
}
@Override
public void onRightClickAir(PlayerInteractEvent evt) {
}
@Override
public void onRightClickBlock(PlayerInteractEvent evt) {
Block block = evt.getClickedBlock();
Player player = evt.getPlayer();
if (block == null)
return;
switch (block.getType()) {
case DEEPSLATE_COAL_ORE:
ItemStack[] possibleDrops1 = {new ItemStack(Material.COAL), new InfiniteChicken(), new KnockbackSlime(),
new ItemStack(Material.COAL_BLOCK), new ItemStack(Material.TORCH), new ItemStack(Material.FURNACE),
new ItemStack(Material.COOKED_CHICKEN), new ItemStack(Material.COOKED_BEEF), new ItemStack(Material.COOKED_PORKCHOP)};
handleShear(possibleDrops1, player, block, Color.BLACK, Material.DEEPSLATE);
break;
case COAL_ORE:
ItemStack[] possibleDrops2 = {new ItemStack(Material.COAL), new InfiniteChicken(), new KnockbackSlime(),
new ItemStack(Material.COAL_BLOCK), new ItemStack(Material.TORCH), new ItemStack(Material.FURNACE),
new ItemStack(Material.COOKED_CHICKEN), new ItemStack(Material.COOKED_BEEF), new ItemStack(Material.COOKED_PORKCHOP)};
handleShear(possibleDrops2, player, block, Color.BLACK, Material.STONE);
break;
case DEEPSLATE_IRON_ORE:
ItemStack[] possibleDrops3 = {new ItemStack(Material.RAW_IRON), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.IRON_PICKAXE),
new ItemStack(Material.IRON_SWORD), new ItemStack(Material.IRON_BOOTS), new ItemStack(Material.IRON_LEGGINGS),
new ItemStack(Material.IRON_CHESTPLATE), new ItemStack(Material.IRON_HELMET)};
handleShear(possibleDrops3, player, block, Color.fromRGB(255, 174, 69), Material.DEEPSLATE);
break;
case IRON_ORE:
ItemStack[] possibleDrops4 = {new ItemStack(Material.RAW_IRON), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.IRON_PICKAXE),
new ItemStack(Material.IRON_SWORD), new ItemStack(Material.IRON_BOOTS), new ItemStack(Material.IRON_LEGGINGS),
new ItemStack(Material.IRON_CHESTPLATE), new ItemStack(Material.IRON_HELMET), new ItemStack(Material.IRON_BLOCK)};
handleShear(possibleDrops4, player, block, Color.fromRGB(255, 174, 69), Material.STONE);
break;
case DEEPSLATE_COPPER_ORE:
ItemStack[] possibleDrops5 = {new ItemStack(Material.COPPER_ORE), new ItemStack(Material.RAW_COPPER),
new ItemStack(Material.COPPER_BLOCK), new InfiniteChicken(), new KnockbackSlime()};
handleShear(possibleDrops5, player, block, Color.fromRGB(255, 124, 48), Material.DEEPSLATE);
break;
case COPPER_ORE:
ItemStack[] possibleDrops6 = {new ItemStack(Material.COPPER_ORE), new ItemStack(Material.RAW_COPPER),
new ItemStack(Material.COPPER_BLOCK), new InfiniteChicken(), new KnockbackSlime()};
handleShear(possibleDrops6, player, block, Color.fromRGB(255, 124, 48), Material.STONE);
break;
case DEEPSLATE_GOLD_ORE:
ItemStack[] possibleDrops7 = {new ItemStack(Material.GOLDEN_APPLE), new ItemStack(Material.ENCHANTED_GOLDEN_APPLE),
new ItemStack(Material.GOLD_INGOT), new ItemStack(Material.GOLD_NUGGET), new ItemStack(Material.GOLD_BLOCK),
new ItemStack(Material.GOLDEN_CARROT), new ItemStack(Material.GOLDEN_PICKAXE), new ItemStack(Material.GOLDEN_SWORD)};
handleShear(possibleDrops7, player, block, Color.YELLOW, Material.DEEPSLATE);
break;
case GOLD_ORE:
ItemStack[] possibleDrops8 = {new ItemStack(Material.GOLDEN_APPLE), new ItemStack(Material.ENCHANTED_GOLDEN_APPLE),
new ItemStack(Material.GOLD_INGOT), new ItemStack(Material.GOLD_NUGGET), new ItemStack(Material.GOLD_BLOCK),
new ItemStack(Material.GOLDEN_CARROT), new ItemStack(Material.GOLDEN_PICKAXE), new ItemStack(Material.GOLDEN_SWORD)};
handleShear(possibleDrops8, player, block, Color.YELLOW, Material.STONE);
break;
case DEEPSLATE_REDSTONE_ORE:
ItemStack[] possibleDrops9 = {new ItemStack(Material.TNT), new ItemStack(Material.REDSTONE),
new ItemStack(Material.DROPPER), new ItemStack(Material.REDSTONE_TORCH), new ItemStack(Material.REDSTONE_BLOCK),
};
handleShear(possibleDrops9, player, block, Color.RED, Material.DEEPSLATE);
break;
case REDSTONE_ORE:
ItemStack[] possibleDrops10 = {new ItemStack(Material.TNT), new ItemStack(Material.REDSTONE),
new ItemStack(Material.DROPPER), new ItemStack(Material.REDSTONE_TORCH), new ItemStack(Material.REDSTONE_BLOCK),
};
handleShear(possibleDrops10, player, block, Color.RED, Material.STONE);
break;
case DEEPSLATE_LAPIS_ORE:
ItemStack[] possibleDrops11 = {new ItemStack(Material.LAPIS_LAZULI), new ItemStack(Material.LAPIS_BLOCK),
new ItemStack(Material.ENCHANTING_TABLE)};
handleShear(possibleDrops11, player, block, Color.BLUE, Material.DEEPSLATE);
break;
case LAPIS_ORE:
ItemStack[] possibleDrops12 = {new ItemStack(Material.LAPIS_LAZULI), new ItemStack(Material.LAPIS_BLOCK),
new ItemStack(Material.ENCHANTING_TABLE)};
handleShear(possibleDrops12, player, block, Color.BLUE, Material.STONE);
break;
case DEEPSLATE_DIAMOND_ORE:
ItemStack[] possibleDrops13 = {new ItemStack(Material.DIAMOND), new ItemStack(Material.DIAMOND_BLOCK),
new ItemStack(Material.DIAMOND_BOOTS), new ItemStack(Material.DIAMOND_LEGGINGS), new ItemStack(Material.DIAMOND_CHESTPLATE),
new ItemStack(Material.DIAMOND_HELMET), new ItemStack(Material.DIAMOND_SWORD), new ItemStack(Material.DIAMOND_PICKAXE),
new UltraDiamondBoots(), new UltraDiamondLegs(), new UltraDiamondChest(), new UltraDiamondHelm(), new UltraDiamondSword(),
new DiamondApple()};
handleShear(possibleDrops13, player, block, Color.TEAL, Material.DEEPSLATE);
break;
case DIAMOND_ORE:
ItemStack[] possibleDrops14 = {new ItemStack(Material.DIAMOND), new ItemStack(Material.DIAMOND_BLOCK),
new ItemStack(Material.DIAMOND_BOOTS), new ItemStack(Material.DIAMOND_LEGGINGS), new ItemStack(Material.DIAMOND_CHESTPLATE),
new ItemStack(Material.DIAMOND_HELMET), new ItemStack(Material.DIAMOND_SWORD), new ItemStack(Material.DIAMOND_PICKAXE),
new UltraDiamondBoots(), new UltraDiamondLegs(), new UltraDiamondChest(), new UltraDiamondHelm(), new UltraDiamondSword(),
new DiamondApple()};
handleShear(possibleDrops14, player, block, Color.TEAL, Material.STONE);
break;
case DEEPSLATE_EMERALD_ORE:
ItemStack[] possibleDrops15 = {new ItemStack(Material.EMERALD), new ItemStack(Material.EMERALD_BLOCK),
new EmeraldApple(), new ItemStack(Material.TOTEM_OF_UNDYING)};
handleShear(possibleDrops15, player, block, Color.GREEN, Material.DEEPSLATE);
break;
case EMERALD_ORE:
ItemStack[] possibleDrops16 = {new ItemStack(Material.EMERALD), new ItemStack(Material.EMERALD_BLOCK),
new EmeraldApple(), new ItemStack(Material.TOTEM_OF_UNDYING)};
handleShear(possibleDrops16, player, block, Color.GREEN, Material.STONE);
break;
case ANCIENT_DEBRIS:
ItemStack[] possibleDrops17 = {new UltraNetheriteBoots(), new UltraNetheriteLegs(), new UltraNetheriteChest(),
new UltraNetheriteHelm(), new UltraNetheriteSword(), new UltraNetheritePickaxe()};
handleShear(possibleDrops17, player, block, Color.FUCHSIA, Material.OBSIDIAN);
break;
case NETHER_QUARTZ_ORE:
ItemStack[] possibleDrops18 = {new ItemStack(Material.QUARTZ), new ItemStack(Material.QUARTZ_BLOCK)};
handleShear(possibleDrops18, player, block, Color.WHITE, Material.NETHERRACK);
break;
case NETHER_GOLD_ORE:
ItemStack[] possibleDrops19 = {new ItemStack(Material.GOLDEN_APPLE), new ItemStack(Material.ENCHANTED_GOLDEN_APPLE),
new ItemStack(Material.GOLD_INGOT), new ItemStack(Material.GOLD_NUGGET), new ItemStack(Material.GOLD_BLOCK),
new ItemStack(Material.GOLDEN_CARROT), new ItemStack(Material.GOLDEN_PICKAXE), new ItemStack(Material.GOLDEN_SWORD)};
handleShear(possibleDrops19, player, block, Color.YELLOW, Material.NETHERRACK);
break;
}
}
@Override
public void onRightClickEntity(PlayerInteractEntityEvent evt) {
}
@Override
public void onLeftClickAir(PlayerInteractEvent evt) {
}
@Override
public void onLeftClickBlock(PlayerInteractEvent evt) {
}
@Override
public void onLeftClickEntity(EntityDamageByEntityEvent evt) {
}
private static void coloredParticles(Block block, Color color) {
Location particleLoc = block.getLocation();
particleLoc.setY(particleLoc.getY() + 0.5);
particleLoc.setX(particleLoc.getX() + 0.5);
particleLoc.setZ(particleLoc.getZ() + 0.5);
block.getWorld().spawnParticle(Particle.REDSTONE, particleLoc,
75, 0.4F, 0.4F, 0.4F, 1F, new Particle.DustOptions(color, 1F));
}
private static void handleShear(ItemStack[] items, Player player, Block block, Color color, Material material) {
block.setType(material);
coloredParticles(block, color);
int rnd = (int) (Math.random() * items.length);
player.getInventory().addItem(items[rnd]);
player.getWorld().playSound(player.getEyeLocation(), Sound.ENTITY_SHEEP_SHEAR, 1F, 1F);
player.getWorld().playSound(player.getEyeLocation(), Sound.ENTITY_ITEM_PICKUP, 1F, 1F);
}
}

View file

@ -0,0 +1,65 @@
package ru.erius.blockshear.items;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import ru.erius.eriuslib.items.CustomItem;
public class DiamondApple extends CustomItem {
private final static String NAME = "diamond_apple";
private final static Material MATERIAL = Material.GOLDEN_APPLE;
public DiamondApple() {
super(NAME, MATERIAL);
}
@Override
public void addRecipe() {
}
@Override
public void onConsume(PlayerItemConsumeEvent playerItemConsumeEvent) {
Player player = playerItemConsumeEvent.getPlayer();
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 800, 2));
player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 12000, 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 12000, 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 12000, 1));
}
@Override
public void onRightClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickEntity(PlayerInteractEntityEvent playerInteractEntityEvent) {
}
@Override
public void onLeftClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
}
}

View file

@ -0,0 +1,66 @@
package ru.erius.blockshear.items;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import ru.erius.eriuslib.items.CustomItem;
public class EmeraldApple extends CustomItem {
private final static String NAME = "emerald_apple";
private final static Material MATERIAL = Material.GOLDEN_APPLE;
public EmeraldApple() {
super(NAME, MATERIAL);
}
@Override
public void addRecipe() {
}
@Override
public void onConsume(PlayerItemConsumeEvent playerItemConsumeEvent) {
Player player = playerItemConsumeEvent.getPlayer();
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 1600, 3));
player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 24000, 2));
player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 24000, 2));
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 24000, 2));
player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 24000, 2));
}
@Override
public void onRightClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickEntity(PlayerInteractEntityEvent playerInteractEntityEvent) {
}
@Override
public void onLeftClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
}
}

View file

@ -0,0 +1,63 @@
package ru.erius.blockshear.items;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import ru.erius.blockshear.BlockShear;
import ru.erius.eriuslib.items.CustomItem;
public class InfiniteChicken extends CustomItem {
private final static String NAME = "infinite_chicken";
private final static Material MATERIAL = Material.COOKED_CHICKEN;
public InfiniteChicken() {
super(NAME, MATERIAL);
this.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1);
}
@Override
public void addRecipe() {
}
@Override
public void onConsume(PlayerItemConsumeEvent evt) {
Bukkit.getScheduler().runTaskLater(BlockShear.plugin, () ->
evt.getPlayer().getInventory().addItem(new InfiniteChicken()), 1);
}
@Override
public void onRightClickAir(PlayerInteractEvent evt) {
}
@Override
public void onRightClickBlock(PlayerInteractEvent evt) {
}
@Override
public void onRightClickEntity(PlayerInteractEntityEvent evt) {
}
@Override
public void onLeftClickAir(PlayerInteractEvent evt) {
}
@Override
public void onLeftClickBlock(PlayerInteractEvent evt) {
}
@Override
public void onLeftClickEntity(EntityDamageByEntityEvent evt) {
}
}

View file

@ -0,0 +1,22 @@
package ru.erius.blockshear.items;
import ru.erius.blockshear.BlockShear;
import ru.erius.eriuslib.items.CustomItem;
import java.util.Set;
public class InitItems {
private static final Set<Class<? extends CustomItem>> ITEMS_INIT = Set.of(BlockShears.class, InfiniteChicken.class, KnockbackSlime.class,
DiamondApple.class, EmeraldApple.class, UltraDiamondBoots.class, UltraDiamondLegs.class, UltraDiamondChest.class,
UltraDiamondHelm.class, UltraDiamondSword.class, UltraDiamondPickaxe.class, UltraNetheriteSword.class,
UltraNetheritePickaxe.class, UltraNetheriteBoots.class, UltraNetheriteLegs.class, UltraNetheriteChest.class,
UltraNetheriteHelm.class);
private final static String packURL = "https://drive.google.com/u/0/uc?id=1sAe93zBaI0hzynvcNUtJwT7oncIG4xoM&export=download";
public static void initItems() {
CustomItem.initItems(BlockShear.plugin, ITEMS_INIT);
CustomItem.setPackURL(packURL);
}
}

View file

@ -0,0 +1,60 @@
package ru.erius.blockshear.items;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import ru.erius.eriuslib.items.CustomItem;
public class KnockbackSlime extends CustomItem {
private final static String NAME = "knockback_slime";
private final static Material MATERIAL = Material.SLIME_BALL;
public KnockbackSlime() {
super(NAME, MATERIAL);
this.addUnsafeEnchantment(Enchantment.KNOCKBACK, 10);
}
@Override
public void addRecipe() {
}
@Override
public void onConsume(PlayerItemConsumeEvent evt) {
}
@Override
public void onRightClickAir(PlayerInteractEvent evt) {
}
@Override
public void onRightClickBlock(PlayerInteractEvent evt) {
}
@Override
public void onRightClickEntity(PlayerInteractEntityEvent evt) {
}
@Override
public void onLeftClickAir(PlayerInteractEvent evt) {
}
@Override
public void onLeftClickBlock(PlayerInteractEvent evt) {
}
@Override
public void onLeftClickEntity(EntityDamageByEntityEvent evt) {
}
}

View file

@ -0,0 +1,64 @@
package ru.erius.blockshear.items;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import ru.erius.eriuslib.items.CustomItem;
public class UltraDiamondBoots extends CustomItem {
private final static String NAME = "ultra_diamond_boots";
private final static Material MATERIAL = Material.DIAMOND_BOOTS;
public UltraDiamondBoots() {
super(NAME, MATERIAL);
this.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
this.addEnchantment(Enchantment.PROTECTION_FIRE, 4);
this.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
this.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 4);
this.addEnchantment(Enchantment.PROTECTION_FALL, 4);
}
@Override
public void addRecipe() {
}
@Override
public void onConsume(PlayerItemConsumeEvent playerItemConsumeEvent) {
}
@Override
public void onRightClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickEntity(PlayerInteractEntityEvent playerInteractEntityEvent) {
}
@Override
public void onLeftClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
}
}

View file

@ -0,0 +1,63 @@
package ru.erius.blockshear.items;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import ru.erius.eriuslib.items.CustomItem;
public class UltraDiamondChest extends CustomItem {
private final static String NAME = "ultra_diamond_chestplate";
private final static Material MATERIAL = Material.DIAMOND_CHESTPLATE;
public UltraDiamondChest() {
super(NAME, MATERIAL);
this.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
this.addEnchantment(Enchantment.PROTECTION_FIRE, 4);
this.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
this.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 4);
}
@Override
public void addRecipe() {
}
@Override
public void onConsume(PlayerItemConsumeEvent playerItemConsumeEvent) {
}
@Override
public void onRightClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickEntity(PlayerInteractEntityEvent playerInteractEntityEvent) {
}
@Override
public void onLeftClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
}
}

View file

@ -0,0 +1,63 @@
package ru.erius.blockshear.items;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import ru.erius.eriuslib.items.CustomItem;
public class UltraDiamondHelm extends CustomItem {
private final static String NAME = "ultra_diamond_helmet";
private final static Material MATERIAL = Material.DIAMOND_HELMET;
public UltraDiamondHelm() {
super(NAME, MATERIAL);
this.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
this.addEnchantment(Enchantment.PROTECTION_FIRE, 4);
this.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
this.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 4);
}
@Override
public void addRecipe() {
}
@Override
public void onConsume(PlayerItemConsumeEvent playerItemConsumeEvent) {
}
@Override
public void onRightClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickEntity(PlayerInteractEntityEvent playerInteractEntityEvent) {
}
@Override
public void onLeftClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
}
}

View file

@ -0,0 +1,63 @@
package ru.erius.blockshear.items;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import ru.erius.eriuslib.items.CustomItem;
public class UltraDiamondLegs extends CustomItem {
private final static String NAME = "ultra_diamond_leggings";
private final static Material MATERIAL = Material.DIAMOND_LEGGINGS;
public UltraDiamondLegs() {
super(NAME, MATERIAL);
this.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
this.addEnchantment(Enchantment.PROTECTION_FIRE, 4);
this.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
this.addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 4);
}
@Override
public void addRecipe() {
}
@Override
public void onConsume(PlayerItemConsumeEvent playerItemConsumeEvent) {
}
@Override
public void onRightClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickEntity(PlayerInteractEntityEvent playerInteractEntityEvent) {
}
@Override
public void onLeftClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
}
}

View file

@ -0,0 +1,61 @@
package ru.erius.blockshear.items;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import ru.erius.eriuslib.items.CustomItem;
public class UltraDiamondPickaxe extends CustomItem {
private final static String NAME = "ultra_diamond_pickaxe";
private final static Material MATERIAL = Material.DIAMOND_PICKAXE;
public UltraDiamondPickaxe() {
super(NAME, MATERIAL);
this.addEnchantment(Enchantment.DIG_SPEED, 5);
this.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
}
@Override
public void addRecipe() {
}
@Override
public void onConsume(PlayerItemConsumeEvent playerItemConsumeEvent) {
}
@Override
public void onRightClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickEntity(PlayerInteractEntityEvent playerInteractEntityEvent) {
}
@Override
public void onLeftClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
}
}

View file

@ -0,0 +1,59 @@
package ru.erius.blockshear.items;
import org.bukkit.Material;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import ru.erius.eriuslib.items.CustomItem;
public class UltraDiamondSword extends CustomItem {
private final static String NAME = "ultra_diamond_sword";
private final static Material MATERIAL = Material.DIAMOND_SWORD;
public UltraDiamondSword() {
super(NAME, MATERIAL);
}
@Override
public void addRecipe() {
}
@Override
public void onConsume(PlayerItemConsumeEvent playerItemConsumeEvent) {
}
@Override
public void onRightClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickEntity(PlayerInteractEntityEvent playerInteractEntityEvent) {
}
@Override
public void onLeftClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
}
}

View file

@ -0,0 +1,63 @@
package ru.erius.blockshear.items;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import ru.erius.eriuslib.items.CustomItem;
public class UltraNetheriteBoots extends CustomItem {
private final static String NAME = "ultra_netherite_boots";
private final static Material MATERIAL = Material.NETHERITE_BOOTS;
public UltraNetheriteBoots() {
super(NAME, MATERIAL);
this.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10);
this.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10);
this.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10);
this.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10);
}
@Override
public void addRecipe() {
}
@Override
public void onConsume(PlayerItemConsumeEvent playerItemConsumeEvent) {
}
@Override
public void onRightClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickEntity(PlayerInteractEntityEvent playerInteractEntityEvent) {
}
@Override
public void onLeftClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
}
}

View file

@ -0,0 +1,63 @@
package ru.erius.blockshear.items;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import ru.erius.eriuslib.items.CustomItem;
public class UltraNetheriteChest extends CustomItem {
private final static String NAME = "ultra_netherite_chestplate";
private final static Material MATERIAL = Material.NETHERITE_CHESTPLATE;
public UltraNetheriteChest() {
super(NAME, MATERIAL);
this.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10);
this.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10);
this.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10);
this.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10);
}
@Override
public void addRecipe() {
}
@Override
public void onConsume(PlayerItemConsumeEvent playerItemConsumeEvent) {
}
@Override
public void onRightClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickEntity(PlayerInteractEntityEvent playerInteractEntityEvent) {
}
@Override
public void onLeftClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
}
}

View file

@ -0,0 +1,63 @@
package ru.erius.blockshear.items;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import ru.erius.eriuslib.items.CustomItem;
public class UltraNetheriteHelm extends CustomItem {
private final static String NAME = "ultra_netherite_helmet";
private final static Material MATERIAL = Material.NETHERITE_HELMET;
public UltraNetheriteHelm() {
super(NAME, MATERIAL);
this.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10);
this.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10);
this.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10);
this.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10);
}
@Override
public void addRecipe() {
}
@Override
public void onConsume(PlayerItemConsumeEvent playerItemConsumeEvent) {
}
@Override
public void onRightClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickEntity(PlayerInteractEntityEvent playerInteractEntityEvent) {
}
@Override
public void onLeftClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
}
}

View file

@ -0,0 +1,63 @@
package ru.erius.blockshear.items;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import ru.erius.eriuslib.items.CustomItem;
public class UltraNetheriteLegs extends CustomItem {
private final static String NAME = "ultra_netherite_leggings";
private final static Material MATERIAL = Material.NETHERITE_LEGGINGS;
public UltraNetheriteLegs() {
super(NAME, MATERIAL);
this.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10);
this.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10);
this.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10);
this.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10);
}
@Override
public void addRecipe() {
}
@Override
public void onConsume(PlayerItemConsumeEvent playerItemConsumeEvent) {
}
@Override
public void onRightClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickEntity(PlayerInteractEntityEvent playerInteractEntityEvent) {
}
@Override
public void onLeftClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
}
}

View file

@ -0,0 +1,61 @@
package ru.erius.blockshear.items;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import ru.erius.eriuslib.items.CustomItem;
public class UltraNetheritePickaxe extends CustomItem {
private final static String NAME = "ultra_netherite_pickaxe";
private final static Material MATERIAL = Material.NETHERITE_PICKAXE;
public UltraNetheritePickaxe() {
super(NAME, MATERIAL);
this.addUnsafeEnchantment(Enchantment.DIG_SPEED, 10);
this.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 10);
}
@Override
public void addRecipe() {
}
@Override
public void onConsume(PlayerItemConsumeEvent playerItemConsumeEvent) {
}
@Override
public void onRightClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickEntity(PlayerInteractEntityEvent playerInteractEntityEvent) {
}
@Override
public void onLeftClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
}
}

View file

@ -0,0 +1,64 @@
package ru.erius.blockshear.items;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import ru.erius.eriuslib.items.CustomItem;
public class UltraNetheriteSword extends CustomItem {
private final static String NAME = "ultra_netherite_sword";
private final static Material MATERIAL = Material.NETHERITE_SWORD;
public UltraNetheriteSword() {
super(NAME, MATERIAL);
this.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10);
this.addUnsafeEnchantment(Enchantment.DAMAGE_ARTHROPODS, 10);
this.addUnsafeEnchantment(Enchantment.DAMAGE_UNDEAD, 10);
this.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, 10);
this.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 10);
}
@Override
public void addRecipe() {
}
@Override
public void onConsume(PlayerItemConsumeEvent playerItemConsumeEvent) {
}
@Override
public void onRightClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onRightClickEntity(PlayerInteractEntityEvent playerInteractEntityEvent) {
}
@Override
public void onLeftClickAir(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickBlock(PlayerInteractEvent playerInteractEvent) {
}
@Override
public void onLeftClickEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
}
}

View file

@ -0,0 +1,9 @@
name: BlockShear
version: @version@
main: ru.erius.blockshear.BlockShear
api-version: 1.17
authors: [ erius ]
depend: [EriusLib]
description: you can shear blocks (amazing)
commands:

118
BlocksAreLava/.gitignore vendored Normal file
View file

@ -0,0 +1,118 @@
# User-specific stuff
.idea/
*.iml
*.ipr
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
.gradle
build/
# Ignore Gradle GUI config
gradle-app.setting
# Cache of project
.gradletasknamecache
**/build/
# Common working directory
run/
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

View file

@ -0,0 +1,38 @@
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
id 'java'
}
group = 'ru.erius'
version = '1.0'
def serverPath = 'C:/mc_servers/1.17.1/plugins'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
repositories {
mavenCentral()
maven {
name = 'spigotmc-repo'
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
}
maven {
name = 'sonatype'
url = 'https://oss.sonatype.org/content/groups/public/'
}
}
dependencies {
compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
}
processResources {
from(sourceSets.main.resources.srcDirs) {
filter ReplaceTokens, tokens: [version: version]
}
}
jar {
destinationDirectory.set(file(serverPath))
}

View file

Binary file not shown.

View file

@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

188
BlocksAreLava/gradlew vendored Normal file
View file

@ -0,0 +1,188 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

100
BlocksAreLava/gradlew.bat vendored Normal file
View file

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

View file

@ -0,0 +1 @@
rootProject.name = 'BlocksAreLava'

View file

@ -0,0 +1,39 @@
package ru.erius.blocksarelava;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
public final class BlocksAreLava extends JavaPlugin {
public static BlocksAreLava plugin;
@Override
public void onEnable() {
super.onEnable();
plugin = this;
getLogger().info(getName() + " enabled");
ConfigHandler.reloadConfig(false);
SpecialBoots.addCraftingRecipe(this);
getServer().getPluginManager().registerEvents(new ServerEvents(), this);
}
@Override
public void onDisable() {
super.onDisable();
getLogger().info(getName() + " disabled");
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
String cmd = command.getName().toLowerCase();
if (cmd.equals("blocks"))
BlocksHandler.onCommand(sender);
if (cmd.equals("giveboots"))
SpecialBoots.onCommand(sender, args);
if (cmd.equals("resetconfig"))
ConfigHandler.reloadConfig(true);
return super.onCommand(sender, command, label, args);
}
}

View file

@ -0,0 +1,57 @@
package ru.erius.blocksarelava;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import java.util.List;
import java.util.stream.Collectors;
public class BlocksHandler {
private static FileConfiguration config = ConfigHandler.getConfig();
private final static List<Material> blocks = config.getStringList("blocks")
.stream()
.map(Material::valueOf)
.collect(Collectors.toList());
private static boolean pluginOn = false;
public static void checkBlock(Player player) {
if (!pluginOn || player.getGameMode() == GameMode.CREATIVE)
return;
Location blockLocation = player.getLocation();
blockLocation.setY(blockLocation.getY() - 0.1);
Block block = player.getWorld().getBlockAt(blockLocation);
Bukkit.getScheduler().scheduleSyncDelayedTask(BlocksAreLava.plugin, () -> {
if (blocks.contains(block.getType()) && !checkId(player.getInventory().getBoots()))
player.setHealth(0);
}, 1);
}
public static void onCommand(CommandSender sender) {
if (pluginOn) {
pluginOn = false;
sender.sendMessage(ChatColor.RED + "Blocks no longer kill players");
} else {
pluginOn = true;
sender.sendMessage(ChatColor.GOLD + "Blocks can kill players now");
}
}
private static boolean checkId(ItemStack item) {
if (item != null) {
ItemMeta meta = item.getItemMeta();
if (meta != null) {
NamespacedKey key = new NamespacedKey(BlocksAreLava.plugin, "item-id");
String itemId = meta.getPersistentDataContainer().get(key, PersistentDataType.STRING);
return SpecialBoots.ID.equals(itemId);
}
}
return false;
}
}

View file

@ -0,0 +1,25 @@
package ru.erius.blocksarelava;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
public class ConfigHandler {
private final static BlocksAreLava plugin = BlocksAreLava.plugin;
private final static String fileName = "blocks.yml";
private final static File file = new File(plugin.getDataFolder(), fileName);
private static FileConfiguration config = null;
public static FileConfiguration getConfig() {
return config;
}
public static void reloadConfig(boolean replace) {
plugin.saveResource(fileName, replace);
config = YamlConfiguration.loadConfiguration(file);
plugin.getLogger().info("loaded the config");
}
}

View file

@ -0,0 +1,19 @@
package ru.erius.blocksarelava;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerMoveEvent;
public class ServerEvents implements Listener {
@EventHandler
private void onPlayerMove(PlayerMoveEvent evt) {
BlocksHandler.checkBlock(evt.getPlayer());
}
@EventHandler
private void onInventoryClick(InventoryClickEvent evt) {
BlocksHandler.checkBlock((Player) evt.getWhoClicked());
}
}

View file

@ -0,0 +1,90 @@
package ru.erius.blocksarelava;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.Plugin;
import java.util.ArrayList;
import java.util.List;
public class SpecialBoots extends ItemStack {
private final static Material MATERIAL = Material.NETHERITE_BOOTS;
private final static FileConfiguration CONFIG = ConfigHandler.getConfig();
private final static List<String> LORE = new ArrayList<>();
private static String name;
public final static String ID = "special_boots";
static {
setNameAndLore();
}
public SpecialBoots() {
this.setType(MATERIAL);
this.setAmount(1);
ItemMeta meta = new ItemStack(MATERIAL).getItemMeta();
meta.setDisplayName(name);
meta.setLore(LORE);
NamespacedKey key = new NamespacedKey(BlocksAreLava.plugin, "item-id");
meta.getPersistentDataContainer().set(key, PersistentDataType.STRING, ID);
this.setItemMeta(meta);
this.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10);
this.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10);
this.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10);
this.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10);
this.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10);
}
public static void addCraftingRecipe(Plugin plugin) {
NamespacedKey key = new NamespacedKey(plugin, "special_boots");
ShapedRecipe recipe = new ShapedRecipe(key, new SpecialBoots());
recipe.shape(".S.", "IDG", "L.W");
recipe.setIngredient('L', Material.LAVA_BUCKET);
recipe.setIngredient('I', Material.IRON_BOOTS);
recipe.setIngredient('D', Material.DIAMOND_BOOTS);
recipe.setIngredient('G', Material.GOLDEN_BOOTS);
recipe.setIngredient('W', Material.WATER_BUCKET);
recipe.setIngredient('S', Material.NETHER_STAR);
Bukkit.addRecipe(recipe);
}
private static void setNameAndLore() {
String nameString = CONFIG.getString("name"), loreString = CONFIG.getString("lore");
if (loreString != null)
LORE.add(ChatColor.translateAlternateColorCodes('&', loreString));
else
LORE.add(ChatColor.RED + "Missing lore");
if (nameString != null)
name = ChatColor.translateAlternateColorCodes('&', nameString);
else
name = ChatColor.RED + "Missing name";
}
public static void onCommand(CommandSender sender, String[] args) {
if (args.length < 1) {
if (sender instanceof Player) {
((Player) sender).getInventory().addItem(new SpecialBoots());
sender.sendMessage(ChatColor.GREEN + "boots");
} else
sender.sendMessage(ChatColor.RED + "You are not a player");
} else {
String name = args[0];
Player player = BlocksAreLava.plugin.getServer().getPlayer(name);
if (player != null) {
player.getInventory().addItem(new SpecialBoots());
sender.sendMessage(ChatColor.GREEN + "boots");
} else
sender.sendMessage(ChatColor.RED + "The player " + name + " is offline or doesn't exist");
}
}
}

View file

@ -0,0 +1,34 @@
# Configuration file for BlocksAreLava plugin
# Add or remove blocks that will instantly kill you when you step on them under section "blocks"
# Change the name and the lore of the special boots
# Color codes:
# &1 - Dark blue
# &2 - Dark green
# &3 - Dark aqua
# &4 - Dark red
# &5 - Dark purple
# &6 - Gold
# &7 - Gray
# &8 - Dark gray
# &9 - Blue
# &0 - Black
# &a - Green
# &b - Aqua
# &c - Red
# &d - Light purple
# &e - Yellow
# &f - White
# &k - Obfuscated (хуита которая меняется каждую секунду)
#
# Other special formatting:
# &l - Bold
# &m - Strikethrough (перечекрнутый)
# &n - Underline
# &o - Italic
# &r - Reset
name: "&d&l&k___ &6&lгавнастопы &5&lхуй &d&l&k___"
lore: "&2Супер крутые ультра супер &mгавно&r &2ботинки"
blocks:
- GRASS_BLOCK
- NETHERRACK

View file

@ -0,0 +1,13 @@
name: BlocksAreLava
version: @version@
main: ru.erius.blocksarelava.BlocksAreLava
api-version: 1.17
authors: [ erius ]
description: use the configuration file to choose which blocks the player can't step on
commands:
blocks:
description: toggles the functionality of this plugin on or off
giveboots:
description: gives special boots to a player
resetconfig:
description: resets the config

118
CobbleDiamonds/.gitignore vendored Normal file
View file

@ -0,0 +1,118 @@
# User-specific stuff
.idea/
*.iml
*.ipr
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
.gradle
build/
# Ignore Gradle GUI config
gradle-app.setting
# Cache of project
.gradletasknamecache
**/build/
# Common working directory
run/
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

View file

@ -0,0 +1,49 @@
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
id 'java'
}
group = 'ru.erius'
version = '1.0-SNAPSHOT'
def serverPath = 'C:/mc_servers/1.17.1/plugins'
def EriusLibPath = 'D:/mc_plugins/EriusLib/build/libs'
def devPath = 'D:/spigot_dev'
def spigotJar = 'spigot-1.17.1'
def citizensJar = 'Citizens-2.0.28-b2359';
sourceCompatibility = "16"
targetCompatibility = "16"
repositories {
mavenCentral()
flatDir {
dirs devPath
}
maven {
name = 'sonatype'
url = 'https://oss.sonatype.org/content/groups/public/'
}
}
dependencies {
compileOnly name: spigotJar
compileOnly name: citizensJar
compileOnly fileTree(dir: EriusLibPath, include: '*.jar')
}
processResources {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
from(sourceSets.main.resources.srcDirs) {
filter ReplaceTokens, tokens: [version: version]
}
}
build {
doLast {
copy {
from libsDirectory
into serverPath
}
}
}

View file

Binary file not shown.

View file

@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

188
CobbleDiamonds/gradlew vendored Normal file
View file

@ -0,0 +1,188 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

100
CobbleDiamonds/gradlew.bat vendored Normal file
View file

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

View file

@ -0,0 +1 @@
rootProject.name = 'CobbleDiamonds'

View file

@ -0,0 +1,32 @@
package ru.erius.cobblediamonds;
import org.bukkit.plugin.java.JavaPlugin;
import ru.erius.eriuslib.Registry;
import java.util.List;
public final class CobbleDiamonds extends JavaPlugin {
private static CobbleDiamonds instance;
{
instance = this;
}
@Override
public void onEnable() {
Registry.registerAll(this, List.of(), List.of(SpawnNPC.class, DestroyNPCs.class),
List.of(), List.of(KillEvilWalrus.class), List.of(DiamondFromCobble.class));
getServer().getPluginManager().registerEvents(new SpawnWalrusListener(), this);
getLogger().info(getName() + " enabled");
}
@Override
public void onDisable() {
getLogger().info(getName() + " disabled");
}
public static CobbleDiamonds getInstance() {
return instance;
}
}

View file

@ -0,0 +1,29 @@
package ru.erius.cobblediamonds;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPCRegistry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import ru.erius.eriuslib.commands.CustomCommand;
import java.util.List;
public class DestroyNPCs extends CustomCommand {
private final static String NAME = "destroynpcs";
public DestroyNPCs() {
super(NAME);
}
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
CitizensAPI.getNPCRegistries().forEach(NPCRegistry::deregisterAll);
return true;
}
@Override
public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] strings) {
return null;
}
}

View file

@ -0,0 +1,38 @@
package ru.erius.cobblediamonds;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.RecipeChoice;
import ru.erius.eriuslib.EriusLib;
import ru.erius.eriuslib.Registry;
import ru.erius.eriuslib.quests.CustomQuest;
import ru.erius.eriuslib.recipes.shaped.CustomShapedRecipe;
import java.util.Map;
public class DiamondFromCobble extends CustomShapedRecipe {
private final static String NAME = "diamond_from_cobblestone";
private final static NamespacedKey KEY = new NamespacedKey(EriusLib.getInstance(), NAME);
private final static ItemStack RESULT = new ItemStack(Material.DIAMOND);
private final static String[] SHAPE = {"AAA", "AAA", "AAA"};
private final static Map<Character, RecipeChoice> MAP = Map.of('A', new RecipeChoice.MaterialChoice(Material.COBBLESTONE));
private final static CustomQuest QUEST = Registry.QuestsRegistry.getQuests().get("kill_evil_walrus");
public DiamondFromCobble() {
super(KEY, RESULT, SHAPE, MAP, QUEST);
}
@EventHandler
private void onCraft(CraftItemEvent evt) {
Player player = (Player) evt.getWhoClicked();
player.getWorld().playSound(player.getEyeLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 0.5F);
}
}

View file

@ -0,0 +1,133 @@
package ru.erius.cobblediamonds;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.ai.tree.Behavior;
import net.citizensnpcs.api.ai.tree.BehaviorStatus;
import net.citizensnpcs.api.event.NPCDamageByBlockEvent;
import net.citizensnpcs.api.event.NPCDamageByEntityEvent;
import net.citizensnpcs.api.event.NPCDeathEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.trait.TraitInfo;
import net.citizensnpcs.api.trait.trait.*;
import net.citizensnpcs.trait.HologramTrait;
import net.citizensnpcs.trait.SkinTrait;
import org.bukkit.*;
import org.bukkit.attribute.Attribute;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
public class EvilWalrus implements Listener {
private final static List<NPC> NPCS = new ArrayList<>();
private final NPC npc = CitizensAPI.getNPCRegistry().createNPC(EntityType.PLAYER, "");
private final BossBar bossBar = Bukkit.createBossBar(ChatColor.RED + "" + ChatColor.BOLD + "Evil Walrus",
BarColor.RED, BarStyle.SOLID);
private final static int HEALTH = 100;
public EvilWalrus() {
NPCS.add(npc);
npc.setName("Evil Walrus");
npc.setProtected(false);
npc.getOrAddTrait(Equipment.class).set(Equipment.EquipmentSlot.HAND, new ItemStack(Material.NETHERITE_SWORD));
npc.getOrAddTrait(SkinTrait.class).setSkinPersistent("evil_walrus",
"UdL23fFUl28pHbSUy0VVGpNE8uPJEJwT3U4pn90O3xke+je1Ij8mM1rHRRudTMP1eH+JvFVgc110rYFTyWY6a8BHDPOxN6NmTuk4v+ZCfcpUzUU6N3W2fD1vVMlEEghSP/OeN9RixV5GJR3+orAmOgJEGw2kYJsv33BdJxlCEUL982eMHHs0LJXkuXXrzkCVHaGJuQ9Q4uG9rjVXupbheEhVr2c2ueeqmW3/+ho9pfxkCE0hhA7o+X7AIOy3EmopFG8G06aatnxW74Ac8+hFHZILs33pGLRY+3SKQ2bdFvgNP5Uk23B7TpaBEkeA8uAfpMebnKIWJGKtrESBXCf10YmpbI6dtzNqqVAQl/jdOn0Agy8P9Y9OLcXJh7yIyZJY4Lk59SB2uGEuVKc3QLRRFW8w+h4b0Pugl6nfrqX6NlrxcDAgg2KsaVg4d3Z799wfqRRI0ZizrN6xKLBXlVrJTO2fI2yItOodnXWcHI+yDlncMhAQTHC7SdYVRULXmiYQ1A6Un8f/7OqT+dxEi+sIxenV8X9ChEpIKXctjb4zIEMHxrUL0TyMS8jZMWPq9BwyyYNek31HFKNXPMJv5fwlyExidor6gR3zOXWh4fOXj48V92AQwMJEB3hPpsHmaD6UP/GFLYNtQ4KCXTQoCGgiCVwOghkwpVFtYMZHEaLFDSI=",
"ewogICJ0aW1lc3RhbXAiIDogMTYyODcyNjU5MDM5NywKICAicHJvZmlsZUlkIiA6ICJmMTA0NzMxZjljYTU0NmI0OTkzNjM4NTlkZWY5N2NjNiIsCiAgInByb2ZpbGVOYW1lIiA6ICJ6aWFkODciLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGJiOGUyYzY0YjExMWU2ODk0ODA3ZThhNGU1YTVlNjIxZjJlMDI4ZGJmZGZhNGEwZDliMmQ4YTUxYjk0Mjg4MiIKICAgIH0KICB9Cn0=");
Bukkit.getOnlinePlayers().forEach(bossBar::addPlayer);
}
public void spawn(Location location) {
Behavior behavior = new EvilWalrusBehaviour();
npc.getDefaultGoalController().addBehavior(behavior, 1);
Bukkit.getPluginManager().registerEvents((Listener) behavior, CobbleDiamonds.getInstance());
npc.spawn(location);
((Player) npc.getEntity()).getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(HEALTH);
((Player) npc.getEntity()).getAttribute(Attribute.GENERIC_ATTACK_DAMAGE).setBaseValue(30);
((Player) npc.getEntity()).setHealth(HEALTH);
}
private final class EvilWalrusBehaviour implements Behavior, Listener {
private BehaviorStatus state = BehaviorStatus.RUNNING;
@Override
public void reset() {
state = null;
}
@Override
public BehaviorStatus run() {
checkIfDead();
switch (state) {
case FAILURE:
break;
case RUNNING:
break;
case SUCCESS:
break;
case RESET_AND_REMOVE:
break;
}
return state;
}
@Override
public boolean shouldExecute() {
return lockOnTarget();
}
private boolean lockOnTarget() {
Optional<Entity> optional = npc.getEntity().getWorld().getNearbyEntities(npc.getEntity().getLocation(),
30, 30, 30, e -> e.getType() == EntityType.PLAYER).stream().findFirst();
if (optional.isPresent() && optional.get() != npc.getEntity()) {
npc.getNavigator().setTarget(optional.get(), true);
return true;
}
return false;
}
private void onKill() {
Bukkit.getServer().broadcastMessage("u dead");
npc.getNavigator().setTarget(null, false);
state = BehaviorStatus.RUNNING;
}
private void checkIfDead() {
if (npc.getEntity().isDead())
state = BehaviorStatus.RESET_AND_REMOVE;
}
@EventHandler
private void onNPCDeath(NPCDeathEvent evt) {
bossBar.removeAll();
npc.destroy();
evt.getDrops().add(new ItemStack(Material.NETHERITE_SWORD));
evt.getNPC().getEntity().getWorld().createExplosion(evt.getNPC().getEntity().getLocation(), 2);
SpawnWalrusListener.isAlive = false;
}
@EventHandler
private void onNPCDamage(NPCDamageByEntityEvent evt) {
updateBossBar();
}
@EventHandler
private void onNpcDamage(NPCDamageByBlockEvent evt) {
updateBossBar();
}
private void updateBossBar() {
bossBar.setProgress(((Player) npc.getEntity()).getHealth() / HEALTH);
}
}
}

View file

@ -0,0 +1,32 @@
package ru.erius.cobblediamonds;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import ru.erius.eriuslib.quests.CustomQuest;
public class KillEvilWalrus extends CustomQuest {
private final static String NAME = "kill_evil_walrus";
private final static String DEFAULT_QUEST_NAME = "Kill the Evil Walrus";
private final static String DEFAULT_DESCRIPTION = "You must kill the Evil Walrus";
private final static String DEFAULT_TITLE = ChatColor.GREEN + "Quest completed";
private final static String DEFAULT_SUBTITLE = ChatColor.GOLD + "New recipe unlocked";
public KillEvilWalrus() {
super(NAME, DEFAULT_QUEST_NAME, DEFAULT_DESCRIPTION, DEFAULT_TITLE, DEFAULT_SUBTITLE);
}
@EventHandler
private void progressQuest(EntityDamageByEntityEvent evt) {
if (!(evt.getDamager() instanceof Player player) || player.hasMetadata("NPC") || this.getCompleted(player))
return;
if (evt.getEntity() instanceof Player npc) {
if (npc.getHealth() - evt.getFinalDamage() <= 0 && npc.hasMetadata("NPC")) {
this.onCompletion(player);
this.setCompeted(player, true);
}
}
}
}

View file

@ -0,0 +1,33 @@
package ru.erius.cobblediamonds;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import ru.erius.eriuslib.commands.CustomCommand;
import java.util.List;
public class SpawnNPC extends CustomCommand {
private final static String NAME = "spawnnpc";
public SpawnNPC() {
super(NAME);
}
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if (commandSender instanceof Player player) {
EvilWalrus evilWalrus = new EvilWalrus();
Bukkit.getPluginManager().registerEvents(evilWalrus, CobbleDiamonds.getInstance());
evilWalrus.spawn(player.getLocation());
}
return true;
}
@Override
public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] strings) {
return null;
}
}

View file

@ -0,0 +1,24 @@
package ru.erius.cobblediamonds;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerItemConsumeEvent;
public class SpawnWalrusListener implements Listener {
public static boolean isAlive = false;
@EventHandler
private void test(PlayerItemConsumeEvent evt) {
if (evt.getItem().getType() == Material.ROTTEN_FLESH && !isAlive) {
EvilWalrus evilWalrus = new EvilWalrus();
Bukkit.getPluginManager().registerEvents(evilWalrus, CobbleDiamonds.getInstance());
evilWalrus.spawn(evt.getPlayer().getLocation());
evt.getPlayer().getWorld().playSound(evt.getPlayer().getEyeLocation(), Sound.ENTITY_WITHER_SPAWN, 1F, 0.5F);
isAlive = true;
}
}
}

View file

@ -0,0 +1,12 @@
name: CobbleDiamonds
version: @version@
main: ru.erius.cobblediamonds.CobbleDiamonds
api-version: 1.17
authors: [ erius ]
depend: [ EriusLib, Citizens ]
description: new recipe for diamonds which is unlocked by completing a quest
commands:
spawnnpc:
description: spawns NPC
destroynpcs:
description: destroys all NPCs

1
EriusLib Submodule

@ -0,0 +1 @@
Subproject commit 1c224806a7a42a5537a1b32742b9b67e0a599f06

118
EriusLibPaper/.gitignore vendored Normal file
View file

@ -0,0 +1,118 @@
# User-specific stuff
.idea/
*.iml
*.ipr
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
.gradle
build/
# Ignore Gradle GUI config
gradle-app.setting
# Cache of project
.gradletasknamecache
**/build/
# Common working directory
run/
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

View file

@ -0,0 +1,43 @@
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
id 'java'
}
group = 'ru.erius'
version = '1.0'
def serverPath = 'C:/mc_servers/1.17.1-paper/plugins'
sourceCompatibility = '11'
targetCompatibility = '11'
repositories {
mavenCentral()
maven {
name = 'papermc-repo'
url = 'https://papermc.io/repo/repository/maven-public/'
}
maven {
name = 'sonatype'
url = 'https://oss.sonatype.org/content/groups/public/'
}
}
dependencies {
compileOnly 'io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT'
}
processResources {
from(sourceSets.main.resources.srcDirs) {
filter ReplaceTokens, tokens: [version: version]
}
}
build {
doLast {
copy {
from libsDir
into serverPath
}
}
}

View file

Binary file not shown.

View file

@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

188
EriusLibPaper/gradlew vendored Normal file
View file

@ -0,0 +1,188 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

100
EriusLibPaper/gradlew.bat vendored Normal file
View file

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

View file

@ -0,0 +1 @@
rootProject.name = 'EriusLibPaper'

View file

@ -0,0 +1,6 @@
name: EriusLibPaper
version: @version@
main: ru.erius.eriuslibpaper.EriusLibPaper
api-version: 1.17
authors: [ erius ]
description: library plugin for custom items, recipes, quests and more

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

Binary file not shown.

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