Initial Commit
This commit is contained in:
commit
3cea7f339a
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/run/
|
||||
/build/
|
||||
/.gradle/
|
||||
/.idea/
|
60
build.gradle
Normal file
60
build.gradle
Normal file
@ -0,0 +1,60 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id("xyz.jpenilla.run-paper") version "2.3.1"
|
||||
id("com.gradleup.shadow") version "9.0.0-beta9"
|
||||
}
|
||||
|
||||
group = 'com.s5gi'
|
||||
version = '1.0.0'
|
||||
|
||||
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.21.4-R0.1-SNAPSHOT")
|
||||
}
|
||||
|
||||
def targetJavaVersion = 21
|
||||
java {
|
||||
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
|
||||
sourceCompatibility = javaVersion
|
||||
targetCompatibility = javaVersion
|
||||
if (JavaVersion.current() < javaVersion) {
|
||||
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.encoding = 'UTF-8'
|
||||
|
||||
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
|
||||
options.release.set(targetJavaVersion)
|
||||
}
|
||||
}
|
||||
|
||||
processResources {
|
||||
def props = [version: version]
|
||||
inputs.properties props
|
||||
filteringCharset 'UTF-8'
|
||||
filesMatching('plugin.yml') {
|
||||
expand props
|
||||
}
|
||||
}
|
||||
|
||||
tasks {
|
||||
runServer {
|
||||
// Configure the Minecraft version for our task.
|
||||
// This is the only required configuration besides applying the plugin.
|
||||
// Your plugin's jar (or shadowJar if present) will be used automatically.
|
||||
minecraftVersion("1.21.4")
|
||||
}
|
||||
}
|
0
gradle.properties
Normal file
0
gradle.properties
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
252
gradlew
vendored
Normal file
252
gradlew
vendored
Normal file
@ -0,0 +1,252 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||
' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$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
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
94
gradlew.bat
vendored
Normal file
94
gradlew.bat
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
1
settings.gradle
Normal file
1
settings.gradle
Normal file
@ -0,0 +1 @@
|
||||
rootProject.name = 'giGuns'
|
57
src/main/java/com/s5gi/giGuns/giGuns.java
Normal file
57
src/main/java/com/s5gi/giGuns/giGuns.java
Normal file
@ -0,0 +1,57 @@
|
||||
package com.s5gi.giGuns;
|
||||
|
||||
import com.s5gi.giGuns.guns.BulletType;
|
||||
import com.s5gi.giGuns.guns.GunHandler;
|
||||
import com.s5gi.giGuns.guns.Guns;
|
||||
import com.s5gi.giGuns.guns.IGun;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Snowball;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public final class giGuns extends JavaPlugin {
|
||||
|
||||
public static JavaPlugin plugin;
|
||||
|
||||
public static String color(String i) {return ChatColor.translateAlternateColorCodes('&', i);}
|
||||
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Plugin startup logic
|
||||
plugin = this;
|
||||
|
||||
//CLEANUP
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
for (Entity entity : world.getEntities()) {
|
||||
if (entity instanceof Snowball snowball) {
|
||||
if (snowball.hasMetadata("isBullet")) snowball.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
///CLEANUP
|
||||
|
||||
BulletType.init();
|
||||
Guns.init();
|
||||
getServer().getPluginManager().registerEvents(new GunHandler(), this);
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, GunHandler::BulletRoutine, 0, 1);
|
||||
|
||||
getCommand("hekateII").setExecutor((commandSender, command, s, strings) -> {
|
||||
if (commandSender instanceof Player player) {
|
||||
IGun gun = GunHandler.registeredGuns.values().stream().toList().getFirst();
|
||||
player.getInventory().addItem(gun.compileGun());
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
GunHandler.physicsBullets.keySet().forEach(physbullet -> {
|
||||
physbullet.remove();
|
||||
});
|
||||
}
|
||||
}
|
103
src/main/java/com/s5gi/giGuns/guns/BulletType.java
Normal file
103
src/main/java/com/s5gi/giGuns/guns/BulletType.java
Normal file
@ -0,0 +1,103 @@
|
||||
package com.s5gi.giGuns.guns;
|
||||
|
||||
import com.s5gi.giGuns.giGuns;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public enum BulletType {
|
||||
// Penetration in blocks/entities a bullet can travel through before it stops
|
||||
PISTOL("&cPistol", BulletType.Recipes.pistol()),
|
||||
RIFLE("&eRifle", BulletType.Recipes.rifle()),
|
||||
HEAVY("&6Heavy", BulletType.Recipes.heavy()),
|
||||
EXPLOSIVE("&4Explosive", BulletType.Recipes.explosive()),
|
||||
GRENADE("&2Grenade", BulletType.Recipes.grenade()),
|
||||
ANTI_TANK("&9Anti-Tank", BulletType.Recipes.antiTank()),;
|
||||
|
||||
private final String prettyName;
|
||||
private final ShapedRecipe recipe;
|
||||
BulletType(String prettyName, ShapedRecipe recipe) {
|
||||
this.prettyName = prettyName;
|
||||
this.recipe = recipe;
|
||||
}
|
||||
|
||||
public String prettyName() {
|
||||
return prettyName;
|
||||
}
|
||||
public ShapedRecipe recipe() {
|
||||
return recipe;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return recipe.getResult();
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
for (BulletType bulletType : BulletType.values()) {
|
||||
giGuns.plugin.getServer().addRecipe(bulletType.recipe());
|
||||
}
|
||||
}
|
||||
|
||||
public static class Recipes {
|
||||
public static ItemStack makeAmmo(String prettyName) {
|
||||
ItemStack gunItem = new ItemStack(Material.BLACK_DYE);
|
||||
ItemMeta meta = gunItem.getItemMeta();
|
||||
meta.setItemName(giGuns.color(prettyName + " Ammo"));
|
||||
gunItem.setItemMeta(meta);
|
||||
return gunItem;
|
||||
}
|
||||
|
||||
public static ShapedRecipe pistol() {
|
||||
ShapedRecipe recipe = new ShapedRecipe(NamespacedKey.fromString("cancerguns:pistol_ammo"), makeAmmo("&cPistol"));
|
||||
recipe.shape(" c ", "ngn", "nnn");
|
||||
recipe.setIngredient('c', Material.COPPER_INGOT);
|
||||
recipe.setIngredient('n', Material.IRON_NUGGET);
|
||||
recipe.setIngredient('g', Material.GUNPOWDER);
|
||||
return recipe;
|
||||
}
|
||||
public static ShapedRecipe rifle() {
|
||||
ShapedRecipe recipe = new ShapedRecipe(NamespacedKey.fromString("cancerguns:rifle_ammo"), makeAmmo("&eRifle"));
|
||||
recipe.shape(" c ", "ngn", "nIn");
|
||||
recipe.setIngredient('c', Material.COPPER_INGOT);
|
||||
recipe.setIngredient('n', Material.IRON_NUGGET);
|
||||
recipe.setIngredient('g', Material.GUNPOWDER);
|
||||
recipe.setIngredient('I', Material.IRON_INGOT);
|
||||
return recipe;
|
||||
}
|
||||
public static ShapedRecipe heavy() {
|
||||
ShapedRecipe recipe = new ShapedRecipe(NamespacedKey.fromString("cancerguns:heavy_ammo"), makeAmmo("&6Heavy"));
|
||||
recipe.shape(" c ", "IgI", "InI");
|
||||
recipe.setIngredient('c', Material.COPPER_INGOT);
|
||||
recipe.setIngredient('n', Material.IRON_NUGGET);
|
||||
recipe.setIngredient('g', Material.GUNPOWDER);
|
||||
recipe.setIngredient('I', Material.IRON_INGOT);
|
||||
return recipe;
|
||||
}
|
||||
public static ShapedRecipe explosive() {
|
||||
ShapedRecipe recipe = new ShapedRecipe(NamespacedKey.fromString("cancerguns:explosive_ammo"), makeAmmo("&4Explosive"));
|
||||
recipe.shape(" c ", "ngn", "nIn");
|
||||
recipe.setIngredient('c', Material.COPPER_INGOT);
|
||||
recipe.setIngredient('n', Material.IRON_NUGGET);
|
||||
recipe.setIngredient('g', Material.GUNPOWDER);
|
||||
recipe.setIngredient('I', Material.BLAZE_POWDER);
|
||||
return recipe;
|
||||
}
|
||||
public static ShapedRecipe grenade() {
|
||||
ShapedRecipe recipe = new ShapedRecipe(NamespacedKey.fromString("cancerguns:grenade_ammo"), makeAmmo("&2Grenade"));
|
||||
recipe.shape(" I ", "ITI", "III");
|
||||
recipe.setIngredient('T', Material.TNT);
|
||||
recipe.setIngredient('I', Material.IRON_INGOT);
|
||||
return recipe;
|
||||
}
|
||||
public static ShapedRecipe antiTank() {
|
||||
ShapedRecipe recipe = new ShapedRecipe(NamespacedKey.fromString("cancerguns:antitank_ammo"), makeAmmo("&9Anti-Tank"));
|
||||
recipe.shape(" B ", "ITI", "III");
|
||||
recipe.setIngredient('T', Material.TNT);
|
||||
recipe.setIngredient('I', Material.IRON_INGOT);
|
||||
recipe.setIngredient('B', Material.IRON_BLOCK);
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
}
|
179
src/main/java/com/s5gi/giGuns/guns/GunHandler.java
Normal file
179
src/main/java/com/s5gi/giGuns/guns/GunHandler.java
Normal file
@ -0,0 +1,179 @@
|
||||
package com.s5gi.giGuns.guns;
|
||||
|
||||
import com.s5gi.giGuns.giGuns;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class GunHandler implements Listener {
|
||||
public static HashMap<String, IGun> registeredGuns = new HashMap<>();
|
||||
public static HashMap<Snowball, IBullet> physicsBullets = new HashMap<>();
|
||||
|
||||
public static void register(IGun gun) {
|
||||
registeredGuns.put(giGuns.color(gun.name()), gun);
|
||||
giGuns.plugin.getServer().addRecipe(gun.recipe());
|
||||
}
|
||||
|
||||
public static boolean isRegisteredGun(IGun gun) {
|
||||
return registeredGuns.containsValue(gun);
|
||||
}
|
||||
public static boolean isRegisteredGun(String name) {
|
||||
return registeredGuns.containsKey(giGuns.color(name));
|
||||
}
|
||||
public static IGun getRegisteredGun(String name) {
|
||||
return registeredGuns.get(giGuns.color(name));
|
||||
}
|
||||
|
||||
public static void BulletRoutine() {
|
||||
List<Snowball> toRemove = new ArrayList<>();
|
||||
for (Snowball snowball : physicsBullets.keySet()) {
|
||||
if (System.currentTimeMillis() - snowball.getMetadata("bornAt").getFirst().asLong() >= 20*1000) {
|
||||
toRemove.add(snowball);
|
||||
}
|
||||
}
|
||||
for (Snowball snowball : toRemove) {
|
||||
snowball.remove();
|
||||
physicsBullets.remove(snowball);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public static void onRightClick(PlayerInteractEvent event) {
|
||||
if (event.getPlayer().getInventory().getItemInMainHand() !=null && event.getPlayer().getInventory().getItemInMainHand().getItemMeta()!=null && GunHandler.isRegisteredGun(event.getPlayer().getInventory().getItemInMainHand().getItemMeta().getItemName())
|
||||
&& (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR)) {
|
||||
Player player = event.getPlayer();
|
||||
World world = player.getWorld();
|
||||
IGun gun = GunHandler.getRegisteredGun(player.getInventory().getItemInMainHand().getItemMeta().getItemName());
|
||||
IBullet bullet = gun.compileBullet();
|
||||
if (player.hasCooldown(player.getInventory().getItemInMainHand())) return;
|
||||
if (!Calc.decreaseMatchingItem(player, gun.bulletType().getItem())) {
|
||||
world.playSound(player.getEyeLocation(), Sound.BLOCK_DISPENSER_FAIL, SoundCategory.PLAYERS, 3f, 1f);
|
||||
return;
|
||||
}
|
||||
Snowball physbullet = player.getWorld().spawn(player.getEyeLocation().subtract(0,0.2f,0), Snowball.class);
|
||||
physbullet.setShooter(player);
|
||||
physbullet.setItem(new ItemStack(bullet.mat()));
|
||||
physbullet.setGravity(gun.gravity());
|
||||
physbullet.setVelocity(player.getEyeLocation().getDirection().multiply(gun.bulletSpeed()));
|
||||
physbullet.setMetadata("isBullet", new FixedMetadataValue(giGuns.plugin, true));
|
||||
physbullet.setMetadata("bornAt", new FixedMetadataValue(giGuns.plugin, System.currentTimeMillis()));
|
||||
for (Sound sound : gun.sound()) {
|
||||
world.playSound(player.getEyeLocation(), sound, SoundCategory.PLAYERS, 15f, gun.soundPitch());
|
||||
}
|
||||
player.setCooldown(player.getInventory().getItemInMainHand(), gun.cooldown());
|
||||
physicsBullets.put(physbullet, bullet);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public static void onBulletHit(ProjectileHitEvent event) {
|
||||
if (event.getEntity() instanceof Snowball physbullet && physicsBullets.containsKey(physbullet)) {
|
||||
Player bulletOwner = (Player) event.getEntity().getShooter();
|
||||
IBullet bullet = physicsBullets.get(physbullet);
|
||||
IGun gun = bullet.parentGun();
|
||||
if (event.getHitEntity() instanceof Player damagedPlayer) {
|
||||
if (bulletOwner == damagedPlayer) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
} else {
|
||||
double dueDamage = gun.damage()-Math.min(GunHandler.Calc.getDamageAfterArmor(damagedPlayer), gun.damage()-0.5f);
|
||||
damagedPlayer.damage(dueDamage, bulletOwner);
|
||||
gun.onHitPlayer(damagedPlayer.getLocation(), damagedPlayer);
|
||||
physicsBullets.remove(physbullet);
|
||||
|
||||
}
|
||||
} else if (event.getHitEntity() instanceof LivingEntity livingEntity) {
|
||||
livingEntity.damage(gun.damage(), bulletOwner);
|
||||
gun.onHitPlayer(livingEntity.getLocation(), livingEntity);
|
||||
physicsBullets.remove(physbullet);
|
||||
|
||||
}
|
||||
if (event.getHitBlock()!=null) {
|
||||
event.getHitBlock().getDrops().clear();
|
||||
gun.onHitBlock(event.getHitBlock().getLocation(), event.getHitBlock());
|
||||
physicsBullets.remove(physbullet);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static class Calc {
|
||||
public static double getDamageAfterArmor(Player player)
|
||||
{
|
||||
PlayerInventory inv = player.getInventory();
|
||||
|
||||
Material boots = Material.AIR;
|
||||
Material helmet = Material.AIR;
|
||||
Material chest = Material.AIR;
|
||||
Material pants = Material.AIR;
|
||||
if (inv.getBoots()!=null) boots = inv.getBoots().getType();
|
||||
if (inv.getHelmet()!=null) boots = inv.getHelmet().getType();
|
||||
if (inv.getChestplate()!=null) boots = inv.getChestplate().getType();
|
||||
if (inv.getLeggings()!=null) boots = inv.getLeggings().getType();
|
||||
|
||||
|
||||
|
||||
double red = 0.0;
|
||||
if(helmet == Material.LEATHER_HELMET)red = red + 0.04;
|
||||
else if(helmet == Material.GOLDEN_HELMET)red = red + 0.08;
|
||||
else if(helmet == Material.CHAINMAIL_HELMET)red = red + 0.08;
|
||||
else if(helmet == Material.IRON_HELMET)red = red + 0.08;
|
||||
else if(helmet == Material.DIAMOND_HELMET)red = red + 0.12;
|
||||
else if(helmet == Material.NETHERITE_HELMET)red = red + 0.16;
|
||||
//
|
||||
if(boots == Material.LEATHER_BOOTS)red = red + 0.04;
|
||||
else if(boots == Material.GOLDEN_BOOTS)red = red + 0.04;
|
||||
else if(boots == Material.CHAINMAIL_BOOTS)red = red + 0.04;
|
||||
else if(boots == Material.IRON_BOOTS)red = red + 0.08;
|
||||
else if(boots == Material.DIAMOND_BOOTS)red = red + 0.12;
|
||||
else if(boots == Material.NETHERITE_BOOTS)red = red + 0.16;
|
||||
|
||||
//
|
||||
if(pants == Material.LEATHER_LEGGINGS)red = red + 0.08;
|
||||
else if(pants == Material.GOLDEN_LEGGINGS)red = red + 0.12;
|
||||
else if(pants == Material.CHAINMAIL_LEGGINGS)red = red + 0.16;
|
||||
else if(pants == Material.IRON_LEGGINGS)red = red + 0.20;
|
||||
else if(pants == Material.DIAMOND_LEGGINGS)red = red + 0.24;
|
||||
else if(pants == Material.NETHERITE_LEGGINGS)red = red + 0.28;
|
||||
|
||||
//
|
||||
if(chest == Material.LEATHER_CHESTPLATE)red = red + 0.12;
|
||||
else if(chest == Material.GOLDEN_CHESTPLATE)red = red + 0.20;
|
||||
else if(chest == Material.CHAINMAIL_CHESTPLATE)red = red + 0.20;
|
||||
else if(chest == Material.IRON_CHESTPLATE)red = red + 0.24;
|
||||
else if(chest == Material.DIAMOND_CHESTPLATE)red = red + 0.32;
|
||||
else if(chest == Material.NETHERITE_CHESTPLATE)red = red + 0.38;
|
||||
|
||||
return red;
|
||||
}
|
||||
|
||||
public static boolean decreaseMatchingItem(Player player, ItemStack targetItem) {
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
if (!player.getGameMode().equals(GameMode.CREATIVE)) {
|
||||
for (int i = 0; i < inventory.getSize(); i++) {
|
||||
ItemStack item = inventory.getItem(i);
|
||||
if (item != null && item.isSimilar(targetItem)) {
|
||||
if (item.getAmount() > 1) {
|
||||
item.setAmount(item.getAmount() - 1); // Decrease stack size
|
||||
} else {
|
||||
inventory.setItem(i, null); // Remove item if it was the last one
|
||||
}
|
||||
return true; // Found and processed the item
|
||||
}
|
||||
}
|
||||
}
|
||||
return player.getGameMode().equals(GameMode.CREATIVE); // No matching item found
|
||||
}
|
||||
}
|
||||
}
|
157
src/main/java/com/s5gi/giGuns/guns/Guns.java
Normal file
157
src/main/java/com/s5gi/giGuns/guns/Guns.java
Normal file
@ -0,0 +1,157 @@
|
||||
package com.s5gi.giGuns.guns;
|
||||
|
||||
import com.s5gi.giGuns.guns.ind._1911;
|
||||
import com.s5gi.giGuns.guns.ind.desertDeagle;
|
||||
import com.s5gi.giGuns.guns.ind.hecateII;
|
||||
|
||||
public class Guns {
|
||||
public static void init() {
|
||||
GunHandler.register(new hecateII());
|
||||
GunHandler.register(new _1911());
|
||||
GunHandler.register(new desertDeagle());
|
||||
}
|
||||
|
||||
// public static final IGun hecateII = new IGun() {
|
||||
// @Override
|
||||
// public String name() {
|
||||
// return "&cHécate II";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<String> description() {
|
||||
// return List.of("&4French", "&7Standard heavy sniper rifle and anti-materiel rifle");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public Material getItem() {
|
||||
// return Material.IRON_HOE;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public BulletType bulletType() {
|
||||
// return BulletType.HEAVY;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<Sound> sound() {
|
||||
// return List.of(Sound.ENTITY_FIREWORK_ROCKET_BLAST);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public float soundPitch() {
|
||||
// return 0.5f;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onHitPlayer(Location location, LivingEntity entity) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onHitBlock(Location location, Block block) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public double bulletSpeed() {
|
||||
// return 4;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public double damage() {
|
||||
// return 12;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int cooldown() {
|
||||
// return 30;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public CraftingRecipe recipe() {
|
||||
// ShapedRecipe recipe = new ShapedRecipe(NamespacedKey.fromString("cancerguns:hekateii"), compileGun());
|
||||
// recipe.shape("iii", "rRd", "iis");
|
||||
// recipe.setIngredient('i', Material.IRON_INGOT);
|
||||
// recipe.setIngredient('r', Material.BREEZE_ROD);
|
||||
// recipe.setIngredient('R', Material.BLAZE_ROD);
|
||||
// recipe.setIngredient('d', Material.DISPENSER);
|
||||
// recipe.setIngredient('s', Material.STICK);
|
||||
// return recipe;
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// public static final IGun _1911 = new IGun() {
|
||||
// @Override
|
||||
// public String name() {
|
||||
// return "&cColt 1911";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<String> description() {
|
||||
// return List.of("&9U.S.A.","&7A single-action, recoil-operated, semi-automatic pistol");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public Material getItem() {
|
||||
// return Material.WOODEN_HOE;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public BulletType bulletType() {
|
||||
// return BulletType.PISTOL;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<Sound> sound() {
|
||||
// return List.of(Sound.ENTITY_FIREWORK_ROCKET_BLAST);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public float soundPitch() {
|
||||
// return 0.8f;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onHitPlayer(Location location, LivingEntity entity) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onHitBlock(Location location, Block block) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public double bulletSpeed() {
|
||||
// return 3.3;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public double damage() {
|
||||
// return 4;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int cooldown() {
|
||||
// return 3;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean gravity() {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public CraftingRecipe recipe() {
|
||||
// ShapedRecipe recipe = new ShapedRecipe(NamespacedKey.fromString("cancerguns:1911"), compileGun());
|
||||
// recipe.shape(" ii"," rd"," is");
|
||||
// recipe.setIngredient('i', Material.IRON_INGOT);
|
||||
// recipe.setIngredient('r', Material.BLAZE_ROD);
|
||||
// recipe.setIngredient('d', Material.DISPENSER);
|
||||
// recipe.setIngredient('s', Material.STICK);
|
||||
// return recipe;
|
||||
// }
|
||||
// };
|
||||
}
|
9
src/main/java/com/s5gi/giGuns/guns/IBullet.java
Normal file
9
src/main/java/com/s5gi/giGuns/guns/IBullet.java
Normal file
@ -0,0 +1,9 @@
|
||||
package com.s5gi.giGuns.guns;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
public interface IBullet {
|
||||
Material mat();
|
||||
IGun parentGun();
|
||||
|
||||
}
|
63
src/main/java/com/s5gi/giGuns/guns/IGun.java
Normal file
63
src/main/java/com/s5gi/giGuns/guns/IGun.java
Normal file
@ -0,0 +1,63 @@
|
||||
package com.s5gi.giGuns.guns;
|
||||
|
||||
import com.s5gi.giGuns.giGuns;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.CraftingRecipe;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public interface IGun {
|
||||
String name();
|
||||
List<String> description();
|
||||
Material getItem();
|
||||
BulletType bulletType();
|
||||
List<Sound> sound();
|
||||
float soundPitch();
|
||||
void onHitPlayer(Location location, LivingEntity entity);
|
||||
void onHitBlock(Location location, Block block);
|
||||
double bulletSpeed();
|
||||
double damage();
|
||||
//in ticks
|
||||
int cooldown();
|
||||
CraftingRecipe recipe();
|
||||
default List<String> getLore() {
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add(giGuns.color("&7Ammo Type: " + this.bulletType().prettyName()));
|
||||
if (!this.description().isEmpty()) {
|
||||
lore.add("");
|
||||
this.description().forEach(s -> lore.add(giGuns.color(s)));
|
||||
}
|
||||
return lore;
|
||||
}
|
||||
default ItemStack compileGun() {
|
||||
IGun gun = this;
|
||||
ItemStack gunItem = new ItemStack(gun.getItem());
|
||||
ItemMeta meta = gunItem.getItemMeta();
|
||||
meta.setItemName(giGuns.color(gun.name()));
|
||||
meta.setLore(gun.getLore());
|
||||
gunItem.setItemMeta(meta);
|
||||
return gunItem;
|
||||
}
|
||||
default boolean gravity() {return false;}
|
||||
default IBullet compileBullet() {
|
||||
IGun gun = this;
|
||||
return new IBullet() {
|
||||
@Override
|
||||
public Material mat() {
|
||||
return Material.POLISHED_BLACKSTONE_BUTTON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGun parentGun() {
|
||||
return gun;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
88
src/main/java/com/s5gi/giGuns/guns/ind/_1911.java
Normal file
88
src/main/java/com/s5gi/giGuns/guns/ind/_1911.java
Normal file
@ -0,0 +1,88 @@
|
||||
package com.s5gi.giGuns.guns.ind;
|
||||
|
||||
import com.s5gi.giGuns.guns.BulletType;
|
||||
import com.s5gi.giGuns.guns.IGun;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.CraftingRecipe;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class _1911 implements IGun {
|
||||
@Override
|
||||
public String name() {
|
||||
return "&cColt 1911";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> description() {
|
||||
return List.of("&9U.S.A.","&7A single-action, recoil-operated, semi-automatic pistol");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Material getItem() {
|
||||
return Material.WOODEN_HOE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BulletType bulletType() {
|
||||
return BulletType.PISTOL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Sound> sound() {
|
||||
return List.of(Sound.ENTITY_FIREWORK_ROCKET_BLAST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float soundPitch() {
|
||||
return 0.8f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHitPlayer(Location location, LivingEntity entity) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHitBlock(Location location, Block block) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public double bulletSpeed() {
|
||||
return 3.3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double damage() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cooldown() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean gravity() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftingRecipe recipe() {
|
||||
ShapedRecipe recipe = new ShapedRecipe(NamespacedKey.fromString("cancerguns:1911"), compileGun());
|
||||
recipe.shape(" ii"," rd"," is");
|
||||
recipe.setIngredient('i', Material.IRON_INGOT);
|
||||
recipe.setIngredient('r', Material.BLAZE_ROD);
|
||||
recipe.setIngredient('d', Material.DISPENSER);
|
||||
recipe.setIngredient('s', Material.STICK);
|
||||
return recipe;
|
||||
}
|
||||
}
|
83
src/main/java/com/s5gi/giGuns/guns/ind/desertDeagle.java
Normal file
83
src/main/java/com/s5gi/giGuns/guns/ind/desertDeagle.java
Normal file
@ -0,0 +1,83 @@
|
||||
package com.s5gi.giGuns.guns.ind;
|
||||
|
||||
import com.s5gi.giGuns.guns.BulletType;
|
||||
import com.s5gi.giGuns.guns.IGun;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.CraftingRecipe;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class desertDeagle implements IGun {
|
||||
@Override
|
||||
public String name() {
|
||||
return "&cDesert Eagle";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> description() {
|
||||
return List.of("&9U.S.A.", "&7A single-action, gas-operated, semi-automatic pistol");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getItem() {
|
||||
return Material.DIAMOND_HOE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BulletType bulletType() {
|
||||
return BulletType.HEAVY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Sound> sound() {
|
||||
return List.of(Sound.ENTITY_FIREWORK_ROCKET_BLAST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float soundPitch() {
|
||||
return 0.6f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHitPlayer(Location location, LivingEntity entity) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHitBlock(Location location, Block block) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public double bulletSpeed() {
|
||||
return 3.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double damage() {
|
||||
return 7;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cooldown() {
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftingRecipe recipe() {
|
||||
ShapedRecipe recipe = new ShapedRecipe(NamespacedKey.fromString("cancerguns:desert_eagle"), compileGun());
|
||||
recipe.shape(" II"," rd"," is");
|
||||
recipe.setIngredient('i', Material.IRON_INGOT);
|
||||
recipe.setIngredient('I', Material.IRON_BLOCK);
|
||||
recipe.setIngredient('r', Material.BLAZE_ROD);
|
||||
recipe.setIngredient('d', Material.DISPENSER);
|
||||
recipe.setIngredient('s', Material.STICK);
|
||||
return recipe;
|
||||
}
|
||||
}
|
84
src/main/java/com/s5gi/giGuns/guns/ind/hecateII.java
Normal file
84
src/main/java/com/s5gi/giGuns/guns/ind/hecateII.java
Normal file
@ -0,0 +1,84 @@
|
||||
package com.s5gi.giGuns.guns.ind;
|
||||
|
||||
import com.s5gi.giGuns.guns.BulletType;
|
||||
import com.s5gi.giGuns.guns.IGun;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.CraftingRecipe;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class hecateII implements IGun {
|
||||
@Override
|
||||
public String name() {
|
||||
return "&cHécate II";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> description() {
|
||||
return List.of("&4French", "&7Standard heavy sniper rifle and anti-materiel rifle");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Material getItem() {
|
||||
return Material.IRON_HOE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BulletType bulletType() {
|
||||
return BulletType.HEAVY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Sound> sound() {
|
||||
return List.of(Sound.ENTITY_FIREWORK_ROCKET_BLAST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float soundPitch() {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHitPlayer(Location location, LivingEntity entity) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHitBlock(Location location, Block block) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public double bulletSpeed() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double damage() {
|
||||
return 12;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cooldown() {
|
||||
return 30;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftingRecipe recipe() {
|
||||
ShapedRecipe recipe = new ShapedRecipe(NamespacedKey.fromString("cancerguns:hekateii"), compileGun());
|
||||
recipe.shape("iii", "rRd", "iis");
|
||||
recipe.setIngredient('i', Material.IRON_INGOT);
|
||||
recipe.setIngredient('r', Material.BREEZE_ROD);
|
||||
recipe.setIngredient('R', Material.BLAZE_ROD);
|
||||
recipe.setIngredient('d', Material.DISPENSER);
|
||||
recipe.setIngredient('s', Material.STICK);
|
||||
return recipe;
|
||||
}
|
||||
}
|
7
src/main/resources/plugin.yml
Normal file
7
src/main/resources/plugin.yml
Normal file
@ -0,0 +1,7 @@
|
||||
name: giGuns
|
||||
version: '1.0.0'
|
||||
main: com.s5gi.giGuns.giGuns
|
||||
api-version: '1.21'
|
||||
commands:
|
||||
hekateII:
|
||||
description: gun
|
Loading…
x
Reference in New Issue
Block a user