NPC added

This commit is contained in:
Marco-Byte-1 2021-03-11 12:02:24 +05:30
parent 1bc6d53739
commit b43bf0f8a1
19 changed files with 203 additions and 105 deletions

View File

@ -2,6 +2,7 @@ import org.apache.tools.ant.filters.ReplaceTokens
plugins { plugins {
id 'java' id 'java'
id "com.github.johnrengelman.shadow" version "6.1.0"
} }
group = 'io.github.simpledev' group = 'io.github.simpledev'
@ -12,6 +13,17 @@ targetCompatibility = '1.8'
repositories { repositories {
mavenCentral() mavenCentral()
maven {
name = 'jitpack.io'
url = 'https://jitpack.io'
}
maven {
name = 'npc-lib'
url = 'https://github.com/juliarn/NPC-Lib'
}
maven { maven {
name = 'papermc-repo' name = 'papermc-repo'
url = 'https://papermc.io/repo/repository/maven-public/' url = 'https://papermc.io/repo/repository/maven-public/'
@ -26,11 +38,13 @@ repositories {
name = 'sonatype' name = 'sonatype'
url = 'https://oss.sonatype.org/content/groups/public/' url = 'https://oss.sonatype.org/content/groups/public/'
} }
} }
dependencies { dependencies {
compileOnly 'com.destroystokyo.paper:paper-api:1.16.4-R0.1-SNAPSHOT' compileOnly 'com.destroystokyo.paper:paper-api:1.16.4-R0.1-SNAPSHOT'
compile 'com.mojang:authlib:1.5.21' compileOnly 'com.mojang:authlib:1.5.21'
implementation 'com.github.juliarn:npc-lib:2.4-RELEASE'
} }
processResources { processResources {
@ -38,10 +52,3 @@ processResources {
filter ReplaceTokens, tokens: [version: version] filter ReplaceTokens, tokens: [version: version]
} }
} }
task copyJar(type: Copy) {
from jar
into "E:\\Rishi\\Codes\\Java Projects\\Minecraft Plugins\\PaperMC\\1.16.4\\Server Testing\\plugins"
}
build.finalizedBy copyJar

Binary file not shown.

View File

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

31
gradlew vendored
View File

@ -82,6 +82,7 @@ esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM. # Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@ -129,6 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"` APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"` JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath # We build the pattern for arguments to be converted via cygpath
@ -154,19 +156,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
else else
eval `echo args$i`="\"$arg\"" eval `echo args$i`="\"$arg\""
fi fi
i=$((i+1)) i=`expr $i + 1`
done done
case $i in case $i in
(0) set -- ;; 0) set -- ;;
(1) set -- "$args0" ;; 1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;; 2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;; 3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;; 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac esac
fi fi
@ -175,14 +177,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " " echo " "
} }
APP_ARGS=$(save "$@") APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules # 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" 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" "$@" exec "$JAVACMD" "$@"

25
gradlew.bat vendored
View File

@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% 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. @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" set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init if "%ERRORLEVEL%" == "0" goto execute
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@ -51,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=% set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init if exist "%JAVA_EXE%" goto execute
echo. echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@ -61,28 +64,14 @@ echo location of your Java installation.
goto fail 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 :execute
@rem Setup the command line @rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle @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% "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell

View File

@ -1 +1,3 @@
rootProject.name = 'strike' rootProject.name = 'strike'
include 'NPC-lib'

View File

@ -1,25 +1,33 @@
package io.github.simplexdev.strike; package io.github.simplexdev.strike;
import com.github.juliarn.npc.NPC;
import com.github.juliarn.npc.NPCPool;
import com.github.juliarn.npc.profile.Profile;
import io.github.simplexdev.strike.api.ConfigUser; import io.github.simplexdev.strike.api.ConfigUser;
import java.util.Arrays;
import io.github.simplexdev.strike.api.utils.InventoryEditConfigManager; import io.github.simplexdev.strike.api.utils.InventoryEditConfigManager;
import io.github.simplexdev.strike.listeners.InventoryEditGUI; import io.github.simplexdev.strike.listeners.InventoryEditGUI;
import io.github.simplexdev.strike.listeners.SpawnController; import io.github.simplexdev.strike.listeners.SpawnController;
import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import java.util.*;
public class StrikeCommand implements CommandExecutor { public class StrikeCommand implements CommandExecutor {
private static Map<Integer, NPC> npcMap = new HashMap<>();
private static ConfigUser[] configUsers; private static ConfigUser[] configUsers;
private final JavaPlugin plugin; private final JavaPlugin plugin;
private final NPCPool npcPool;
public StrikeCommand(JavaPlugin plugin) { public StrikeCommand(JavaPlugin plugin) {
this.plugin = plugin; this.plugin = plugin;
this.npcPool = new NPCPool(plugin);
} }
public static void loadInstances(ConfigUser... configUsers) { public static void loadInstances(ConfigUser... configUsers) {
@ -34,24 +42,55 @@ public class StrikeCommand implements CommandExecutor {
if ("reload".equalsIgnoreCase(args[0])) { if ("reload".equalsIgnoreCase(args[0])) {
this.plugin.reloadConfig(); this.plugin.reloadConfig();
Arrays.stream(configUsers).forEach(configUser -> configUser.refresh()); Arrays.stream(configUsers).forEach(configUser -> configUser.refresh());
} sender.sendMessage(ChatColor.GREEN + "[Strike] Plugin Config Reloaded");
} else if ("edit".equalsIgnoreCase(args[0]) && sender instanceof Player) {
else if ("edit".equalsIgnoreCase(args[0]) && sender instanceof Player) {
new InventoryEditGUI(plugin).openInventory((Player) sender); new InventoryEditGUI(plugin).openInventory((Player) sender);
} } else if ("get".equalsIgnoreCase(args[0]) && sender instanceof Player) {
else if ("get".equalsIgnoreCase(args[0]) && sender instanceof Player) {
Player player = (Player) sender; Player player = (Player) sender;
player.getInventory().setContents(new InventoryEditConfigManager(plugin).getInventoryItems(player)); player.getInventory().setContents(new InventoryEditConfigManager(plugin).getInventoryItems(player));
} } else if ("set-spawn".equalsIgnoreCase(args[0]) && sender instanceof Player) {
else if ("set-spawn".equalsIgnoreCase(args[0]) && sender instanceof Player) {
Player player = ((Player) sender); Player player = ((Player) sender);
new SpawnController(plugin).setSpawn(player.getLocation()); new SpawnController(plugin).setSpawn(player.getLocation());
} }
else if ("spawn-npc".equalsIgnoreCase(args[0]) && sender instanceof Player) {
NPC.Builder zHenna = new NPC.Builder(new Profile(UUID.randomUUID(), "zHenna", null));
NPC npc = zHenna.build(npcPool);
npc.getLocation().set(((Player) sender).getLocation().getX(), ((Player) sender).getLocation().getY(), ((Player) sender).getLocation().getZ());
int random;
do {
random = new Random().nextInt(200000);
}
while (npcMap.containsKey(random));
npcMap.put(random, npc);
}
else if ("remove-npc".equalsIgnoreCase(args[0]) && sender instanceof Player) {
if (npcMap.isEmpty() || args.length > 3)
return true;
Integer integer;
try {
integer = Integer.parseInt(args[1]);
} catch (NumberFormatException e) {
e.printStackTrace();
return true;
}
if (!npcMap.containsKey(integer))
return true;
npcPool.removeNPC(npcMap.get(integer).getEntityId());
}
return true; return true;
} }
public static Map<Integer, NPC> getNpcMap() {
return npcMap;
}
} }

View File

@ -7,6 +7,7 @@ import org.bukkit.plugin.java.JavaPlugin;
public final class StrikePlugin extends JavaPlugin { public final class StrikePlugin extends JavaPlugin {
//TODO //TODO
// Custom Explosion
// NPC Edit // NPC Edit
// LaunchPad // LaunchPad

View File

@ -1,4 +1,4 @@
package io.github.simplexdev.strike.events; package io.github.simplexdev.strike.api.events;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;

View File

@ -1,4 +1,4 @@
package io.github.simplexdev.strike.events; package io.github.simplexdev.strike.api.events;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -0,0 +1,30 @@
package io.github.simplexdev.strike.api.events;
import com.destroystokyo.paper.event.player.PlayerJumpEvent;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.util.Vector;
public class PlayerDoubleJumpEvent extends PlayerJumpEvent {
private static HandlerList handlerList = new HandlerList();
private final World world;
public PlayerDoubleJumpEvent(Player player, Vector vector) {
super(player, player.getLocation(), player.getLocation().clone().add(vector));
this.world = player.getWorld();
}
public World getWorld() {
return world;
}
@Override
public HandlerList getHandlers() {
return handlerList;
}
public static HandlerList getHandlerList() {
return handlerList;
}
}

View File

@ -3,7 +3,6 @@ package io.github.simplexdev.strike.api.utils;
import io.github.simplexdev.strike.listeners.Grenade; import io.github.simplexdev.strike.listeners.Grenade;
import io.github.simplexdev.strike.listeners.Gun; import io.github.simplexdev.strike.listeners.Gun;
import io.github.simplexdev.strike.listeners.HealthPackage; import io.github.simplexdev.strike.listeners.HealthPackage;
import io.github.simplexdev.strike.listeners.ItemManager;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
@ -16,7 +15,6 @@ import org.bukkit.plugin.java.JavaPlugin;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.Set; import java.util.Set;
public class InventoryEditConfigManager { public class InventoryEditConfigManager {
@ -30,9 +28,10 @@ public class InventoryEditConfigManager {
dataFile = new File("plugins\\Strike\\inventories.yml"); dataFile = new File("plugins\\Strike\\inventories.yml");
try { try {
if (!dataFile.isFile()) { if (!dataFile.exists()) {
plugin.getDataFolder().mkdirs();
dataFile.createNewFile(); dataFile.createNewFile();
plugin.saveResource("inventories.yml", false);
} }
dataConfig = new YamlConfiguration(); dataConfig = new YamlConfiguration();

View File

@ -2,7 +2,7 @@ package io.github.simplexdev.strike.listeners;
import io.github.simplexdev.strike.api.ConfigUser; import io.github.simplexdev.strike.api.ConfigUser;
import io.github.simplexdev.strike.api.Spawn; import io.github.simplexdev.strike.api.Spawn;
import io.github.simplexdev.strike.events.GrenadeKillEvent; import io.github.simplexdev.strike.api.events.GrenadeKillEvent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -65,7 +65,7 @@ public class Grenade implements ConfigUser {
} }
final Item item = player.getWorld().dropItem(player.getEyeLocation(), new ItemStack(Material.MAGMA_CREAM)); final Item item = player.getWorld().dropItem(player.getEyeLocation(), new ItemStack(Material.MAGMA_CREAM));
item.setVelocity(player.getEyeLocation().getDirection().multiply(0.75D)); item.setVelocity(player.getEyeLocation().getDirection().multiply(1.5));
(new BukkitRunnable() { (new BukkitRunnable() {
public void run() { public void run() {

View File

@ -2,10 +2,11 @@ package io.github.simplexdev.strike.listeners;
import io.github.simplexdev.strike.api.ConfigUser; import io.github.simplexdev.strike.api.ConfigUser;
import io.github.simplexdev.strike.api.Spawn; import io.github.simplexdev.strike.api.Spawn;
import io.github.simplexdev.strike.events.GunKillEvent; import io.github.simplexdev.strike.api.events.GunKillEvent;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.NPC;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -27,6 +28,7 @@ import java.util.List;
public class Gun implements ConfigUser { public class Gun implements ConfigUser {
private static final HashMap<Player, Integer> ammoMap = new HashMap<>(); private static final HashMap<Player, Integer> ammoMap = new HashMap<>();
private static final List<Material> passThroughBlocks = setPassThroughBlocks(); private static final List<Material> passThroughBlocks = setPassThroughBlocks();
private static List<Player> delay = new ArrayList<>();
private final ItemStack gunItemStack; private final ItemStack gunItemStack;
@ -37,46 +39,36 @@ public class Gun implements ConfigUser {
private int maxDistance; private int maxDistance;
private static List<Material> setPassThroughBlocks() { private static List<Material> setPassThroughBlocks() {
ArrayList<Material> blocks = new ArrayList<>(); ArrayList<Material> blocks = new ArrayList<>();
blocks.add(Material.TALL_GRASS); blocks.add(Material.TALL_GRASS);
blocks.add(Material.IRON_BARS); blocks.add(Material.IRON_BARS);
blocks.add(Material.ACACIA_FENCE);
blocks.add(Material.BIRCH_FENCE);
blocks.add(Material.CRIMSON_FENCE);
blocks.add(Material.JUNGLE_FENCE);
blocks.add(Material.OAK_FENCE);
blocks.add(Material.SPRUCE_FENCE);
blocks.add(Material.WARPED_FENCE);
blocks.add(Material.DARK_OAK_FENCE);
blocks.add(Material.NETHER_BRICK_FENCE);
blocks.add(Material.WALL_TORCH);
blocks.add(Material.TORCH);
blocks.add(Material.REDSTONE_TORCH);
blocks.add(Material.REDSTONE_WALL_TORCH);
blocks.add(Material.SOUL_TORCH);
blocks.add(Material.ACACIA_FENCE_GATE);
blocks.add(Material.BIRCH_FENCE_GATE);
blocks.add(Material.CRIMSON_FENCE_GATE);
blocks.add(Material.JUNGLE_FENCE_GATE);
blocks.add(Material.OAK_FENCE_GATE);
blocks.add(Material.SPRUCE_FENCE_GATE);
blocks.add(Material.WARPED_FENCE_GATE);
blocks.add(Material.DARK_OAK_FENCE_GATE);
blocks.add(Material.WATER); blocks.add(Material.WATER);
blocks.add(Material.LAVA); blocks.add(Material.LAVA);
blocks.add(Material.AIR); blocks.add(Material.AIR);
blocks.add(Material.COBWEB); blocks.add(Material.COBWEB);
blocks.add(Material.ACACIA_LEAVES);
blocks.add(Material.BIRCH_LEAVES); for (Material material : Material.values()) {
blocks.add(Material.OAK_LEAVES); if (
blocks.add(Material.DARK_OAK_LEAVES); material.toString().endsWith("FENCE")
blocks.add(Material.SPRUCE_LEAVES); || material.toString().endsWith("TORCH")
|| material.toString().endsWith("GATE")
|| material.toString().endsWith("LEAVES")
|| material.toString().endsWith("PRESSURE_PLATE")
|| material.toString().endsWith("BUTTON")
|| material.toString().endsWith("GLASS")
|| material.toString().endsWith("GLASS_PANE")
|| material.toString().endsWith("TRAPDOOR")
)
blocks.add(material);
}
return blocks; return blocks;
} }
public Gun(JavaPlugin plugin) { public Gun(JavaPlugin plugin) {
this.plugin = plugin; this.plugin = plugin;
this.gunItemStack = createItem(); this.gunItemStack = createItem();
this.maxAmmo = plugin.getConfig().getInt("gun.ammo"); this.maxAmmo = plugin.getConfig().getInt("gun.ammo");
@ -110,11 +102,11 @@ public class Gun implements ConfigUser {
return; return;
} }
String ammoText = (Gun.ammoMap.containsKey(player) ? ((Integer) Gun.ammoMap.get(player)).intValue() : Gun.this.maxAmmo) + " | " + Gun.this.maxAmmo; String ammoText = (Gun.ammoMap.containsKey(player) ? Gun.ammoMap.get(player).intValue() : Gun.this.maxAmmo) + " | " + Gun.this.maxAmmo;
player.sendActionBar(ammoText); player.sendActionBar(ammoText);
} }
}).runTaskTimer((Plugin) this.plugin, 0L, 7L); }).runTaskTimer(this.plugin, 0L, 7L);
} }
@EventHandler @EventHandler
@ -130,7 +122,7 @@ public class Gun implements ConfigUser {
Player player = e.getPlayer(); Player player = e.getPlayer();
Action action = e.getAction(); Action action = e.getAction();
if (!player.getWorld().equals(Spawn.getWorld()) || itemStack == null || !itemStack.equals(this.gunItemStack) || !action.toString().startsWith("RIGHT_CLICK")) { if (!player.getWorld().equals(Spawn.getWorld()) || itemStack == null || !itemStack.equals(this.gunItemStack) || delay.contains(player) || !action.toString().startsWith("RIGHT_CLICK")) {
return; return;
} }
int ammo = this.maxAmmo; int ammo = this.maxAmmo;
@ -139,23 +131,31 @@ public class Gun implements ConfigUser {
ammoMap.put(player, Integer.valueOf(this.maxAmmo - 1)); ammoMap.put(player, Integer.valueOf(this.maxAmmo - 1));
} else { } else {
ammo = ((Integer) ammoMap.get(player)).intValue(); ammo = ammoMap.get(player).intValue();
if (ammo == 1) { if (ammo == 1) {
(new BukkitRunnable() { (new BukkitRunnable() {
public void run() { public void run() {
Gun.ammoMap.replace(player, Integer.valueOf(Gun.this.maxAmmo)); Gun.ammoMap.replace(player, Integer.valueOf(Gun.this.maxAmmo));
} }
}).runTaskLater((Plugin) this.plugin, 20L * this.plugin.getConfig().getInt("gun.reload-time")); }).runTaskLater(this.plugin, 20L * this.plugin.getConfig().getInt("gun.reload-time"));
} }
if (((Integer) ammoMap.get(player)).intValue() != 0) { if (ammoMap.get(player).intValue() != 0) {
ammoMap.replace(player, Integer.valueOf(ammo - 1)); ammoMap.replace(player, Integer.valueOf(ammo - 1));
} }
} }
if (ammo <= 0) { if (ammo <= 0) {
return; return;
} }
delay.add(player);
new BukkitRunnable() {
@Override
public void run() {
delay.remove(player);
}
}.runTaskLater(plugin, 2);
Entity entity = getEntity(player, player.getEyeLocation().clone(), 0.0D); Entity entity = getEntity(player, player.getEyeLocation().clone(), 0.0D);

View File

@ -1,5 +1,7 @@
package io.github.simplexdev.strike.listeners; package io.github.simplexdev.strike.listeners;
import com.github.juliarn.npc.event.PlayerNPCInteractEvent;
import io.github.simplexdev.strike.StrikeCommand;
import io.github.simplexdev.strike.api.utils.InventoryEditConfigManager; import io.github.simplexdev.strike.api.utils.InventoryEditConfigManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -57,4 +59,12 @@ public class InventoryEditGUI implements Listener {
} }
@EventHandler
private void openGUI(PlayerNPCInteractEvent e) {
if (!StrikeCommand.getNpcMap().containsValue(e.getNPC()))
return;
openInventory(e.getPlayer());
}
} }

View File

@ -2,9 +2,9 @@ package io.github.simplexdev.strike.listeners;
import io.github.simplexdev.strike.api.ConfigUser; import io.github.simplexdev.strike.api.ConfigUser;
import io.github.simplexdev.strike.api.Spawn; import io.github.simplexdev.strike.api.Spawn;
import io.github.simplexdev.strike.api.events.GrenadeKillEvent;
import io.github.simplexdev.strike.api.events.GunKillEvent;
import io.github.simplexdev.strike.api.utils.InventoryEditConfigManager; import io.github.simplexdev.strike.api.utils.InventoryEditConfigManager;
import io.github.simplexdev.strike.events.GrenadeKillEvent;
import io.github.simplexdev.strike.events.GunKillEvent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;

View File

@ -3,9 +3,8 @@ package io.github.simplexdev.strike.listeners;
import com.destroystokyo.paper.event.player.PlayerJumpEvent; import com.destroystokyo.paper.event.player.PlayerJumpEvent;
import io.github.simplexdev.strike.api.ConfigUser; import io.github.simplexdev.strike.api.ConfigUser;
import io.github.simplexdev.strike.api.Spawn; import io.github.simplexdev.strike.api.Spawn;
import org.bukkit.ChatColor; import io.github.simplexdev.strike.api.events.PlayerDoubleJumpEvent;
import org.bukkit.GameMode; import org.bukkit.*;
import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
@ -14,6 +13,7 @@ import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -55,7 +55,6 @@ public class Jumper implements ConfigUser {
} }
@EventHandler @EventHandler
private void onFlightAccessChange(PlayerToggleFlightEvent e) { private void onFlightAccessChange(PlayerToggleFlightEvent e) {
final Player player = e.getPlayer(); final Player player = e.getPlayer();
@ -67,7 +66,15 @@ public class Jumper implements ConfigUser {
player.setAllowFlight(false); player.setAllowFlight(false);
e.setCancelled(true); e.setCancelled(true);
player.setVelocity(player.getLocation().getDirection().multiply(0.5D).setY(0.5D));
double multiplier = plugin.getConfig().getDouble("double-jump.forward-distance");
double yMultiplier = plugin.getConfig().getDouble("double-jump.upward-distance");
Vector vector = player.getLocation().getDirection().multiply(multiplier).setY(yMultiplier);
player.setVelocity(vector);
Bukkit.getPluginManager().callEvent(new PlayerDoubleJumpEvent(player, vector));
playersOnCoolDown.put(player.getPlayer().getUniqueId(), Long.valueOf((this.coolDownTime.intValue() * 1000) + System.currentTimeMillis())); playersOnCoolDown.put(player.getPlayer().getUniqueId(), Long.valueOf((this.coolDownTime.intValue() * 1000) + System.currentTimeMillis()));
@ -78,7 +85,13 @@ public class Jumper implements ConfigUser {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', Jumper.this.plugin.getConfig().getString("double-jump.cooldown-finish-message"))); player.sendMessage(ChatColor.translateAlternateColorCodes('&', Jumper.this.plugin.getConfig().getString("double-jump.cooldown-finish-message")));
} }
}).runTaskLater((Plugin) this.plugin, 20L * this.coolDownTime.intValue()); }).runTaskLater(this.plugin, 20L * this.coolDownTime.intValue());
}
@EventHandler
private void onDoubleJump(PlayerDoubleJumpEvent e) {
e.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, e.getPlayer().getLocation(), 1);
e.getWorld().playSound(e.getPlayer().getLocation(), Sound.ENTITY_BAT_TAKEOFF, 1 , 1);
} }

View File

@ -9,6 +9,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent; import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerRespawnEvent;
@ -24,6 +25,14 @@ public class SpawnController implements ConfigUser {
} }
@EventHandler
private void onItemClick(InventoryClickEvent e) {
if (e.getWhoClicked().getWorld().equals(Spawn.getWorld()) &&
(e.getClickedInventory() != null
&& e.getClickedInventory().equals(e.getWhoClicked().getOpenInventory().getBottomInventory())))
e.setCancelled(true);
}
@EventHandler @EventHandler
private void onPlayerWorldChange(PlayerChangedWorldEvent e) { private void onPlayerWorldChange(PlayerChangedWorldEvent e) {
if (e.getPlayer().getWorld().equals(Spawn.getWorld())) if (e.getPlayer().getWorld().equals(Spawn.getWorld()))

View File

@ -1,5 +1,7 @@
double-jump: double-jump:
cooldown: 10 #Time in Seconds cooldown: 10 #Time in Seconds
forward-distance: 0.5 #This is had to config up, U can use decimal number here
upward-distance: 0.75 #This is had to config up, U can use decimal number here
cooldown-finish-message: "Done" cooldown-finish-message: "Done"
message-enabled: true message-enabled: true