commit
a7afca02a2
|
@ -1,6 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src/main/java"/>
|
||||||
|
<classpathentry kind="src" path="src/main/resources"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<artifactSet>
|
<artifactSet>
|
||||||
<includes>
|
<includes>
|
||||||
<include>me.ghotimayo*:*</include>
|
<include>com.fpghoti*:*</include>
|
||||||
<include>de.tr7zw*:*</include>
|
<include>de.tr7zw*:*</include>
|
||||||
</includes>
|
</includes>
|
||||||
</artifactSet>
|
</artifactSet>
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.13.2-R0.1-SNAPSHOT</version>
|
<version>1.15.1-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
|
@ -58,13 +58,13 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>craftbukkit</artifactId>
|
<artifactId>craftbukkit</artifactId>
|
||||||
<version>1.13.2-R0.1-SNAPSHOT</version>
|
<version>1.15.1-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>1.13.2-R0.1-SNAPSHOT</version>
|
<version>1.15.1-R0.1-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
31
pom.xml
31
pom.xml
|
@ -1,9 +1,11 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>me.ghotimayo</groupId>
|
<groupId>me.ghotimayo</groupId>
|
||||||
<artifactId>ClassicSwords</artifactId>
|
<artifactId>ClassicSwords</artifactId>
|
||||||
<version>BETA-1.0</version>
|
<version>BETA-1.0.1</version>
|
||||||
<name>ClassicSwords</name>
|
<name>ClassicSwords</name>
|
||||||
<description>Old combat for new minecraft</description>
|
<description>Old combat for new minecraft</description>
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -25,19 +27,19 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.15.1-R0.1-SNAPSHOT</version>
|
<version>1.15.2-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>craftbukkit</artifactId>
|
<artifactId>craftbukkit</artifactId>
|
||||||
<version>1.15.1-R0.1-SNAPSHOT</version>
|
<version>1.15.2-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>1.15.1-R0.1-SNAPSHOT</version>
|
<version>1.15.2-R0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.tr7zw</groupId>
|
<groupId>de.tr7zw</groupId>
|
||||||
|
@ -51,7 +53,23 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
|
<sourceDirectory>src/main/java</sourceDirectory>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.0</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
@ -60,8 +78,7 @@
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<artifactSet>
|
<artifactSet>
|
||||||
<includes>
|
<includes>
|
||||||
<include>me.ghotimayo*:*</include>
|
<include>com.fpghoti*:*</include>
|
||||||
<include>de.tr7zw*:*</include>
|
|
||||||
</includes>
|
</includes>
|
||||||
</artifactSet>
|
</artifactSet>
|
||||||
<relocations />
|
<relocations />
|
||||||
|
|
|
@ -10,15 +10,18 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.fpghoti.classicswords.commands.CSwordCommand;
|
import com.fpghoti.classicswords.commands.CSwordCommand;
|
||||||
import com.fpghoti.classicswords.event.BlockingListener;
|
|
||||||
import com.fpghoti.classicswords.event.InventoryListener;
|
|
||||||
import com.fpghoti.classicswords.event.RegenListener;
|
|
||||||
import com.fpghoti.classicswords.event.SwingListener;
|
|
||||||
import com.fpghoti.classicswords.item.CItemType;
|
import com.fpghoti.classicswords.item.CItemType;
|
||||||
import com.fpghoti.classicswords.item.ClassicSword;
|
import com.fpghoti.classicswords.item.ClassicSword;
|
||||||
import com.fpghoti.classicswords.item.SetAttributes;
|
import com.fpghoti.classicswords.item.SetAttributes;
|
||||||
|
import com.fpghoti.classicswords.listener.BlockingListener;
|
||||||
|
import com.fpghoti.classicswords.listener.InventoryListener;
|
||||||
|
import com.fpghoti.classicswords.listener.PlayerListener;
|
||||||
|
import com.fpghoti.classicswords.listener.RegenListener;
|
||||||
|
import com.fpghoti.classicswords.listener.SwingListener;
|
||||||
import com.fpghoti.classicswords.util.Storage;
|
import com.fpghoti.classicswords.util.Storage;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
/** For 1.13 */
|
/** For 1.13 */
|
||||||
|
|
||||||
public class ClassicSwordsMain extends JavaPlugin{
|
public class ClassicSwordsMain extends JavaPlugin{
|
||||||
|
@ -63,6 +66,7 @@ public class ClassicSwordsMain extends JavaPlugin{
|
||||||
pm.registerEvents(ie, this);
|
pm.registerEvents(ie, this);
|
||||||
pm.registerEvents(new BlockingListener(), this);
|
pm.registerEvents(new BlockingListener(), this);
|
||||||
pm.registerEvents(new RegenListener(this), this);
|
pm.registerEvents(new RegenListener(this), this);
|
||||||
|
pm.registerEvents(new PlayerListener(), this);
|
||||||
}
|
}
|
||||||
FileConfiguration config = this.getConfig();
|
FileConfiguration config = this.getConfig();
|
||||||
|
|
||||||
|
@ -91,7 +95,7 @@ public class ClassicSwordsMain extends JavaPlugin{
|
||||||
ItemStack newitem = ClassicSword.toShield(p.getInventory().getItemInMainHand(), CItemType.getSwordType(p.getInventory().getItemInMainHand().getType()));
|
ItemStack newitem = ClassicSword.toShield(p.getInventory().getItemInMainHand(), CItemType.getSwordType(p.getInventory().getItemInMainHand().getType()));
|
||||||
Integer dur = ClassicSword.getCShieldDurability(newitem);
|
Integer dur = ClassicSword.getCShieldDurability(newitem);
|
||||||
p.getInventory().setItemInMainHand(newitem);
|
p.getInventory().setItemInMainHand(newitem);
|
||||||
ClassicSword.sendActionbar(p, "§eDurability: " + dur);
|
ClassicSword.sendActionbar(p, ChatColor.YELLOW + "Durability: " + dur);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fpghoti.classicswords.item;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
|
||||||
|
@ -430,11 +431,11 @@ public class ClassicSword {
|
||||||
int dur = ClassicSword.getCShieldDurability(item);
|
int dur = ClassicSword.getCShieldDurability(item);
|
||||||
dur = dur - amount;
|
dur = dur - amount;
|
||||||
if(dur <= 0) {
|
if(dur <= 0) {
|
||||||
sendActionbar(p, "§eDurability: 0");
|
sendActionbar(p, ChatColor.YELLOW + "Durability: 0");
|
||||||
breakHeldItem(p);
|
breakHeldItem(p);
|
||||||
}else {
|
}else {
|
||||||
if(isCItem(item)) {
|
if(isCItem(item)) {
|
||||||
sendActionbar(p, "§eDurability: " + dur);
|
sendActionbar(p, ChatColor.YELLOW + "Durability: " + dur);
|
||||||
setCShieldDurability(p, item, dur);
|
setCShieldDurability(p, item, dur);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.fpghoti.classicswords.event;
|
package com.fpghoti.classicswords.listener;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -8,6 +8,8 @@ import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||||
|
|
||||||
|
import com.fpghoti.classicswords.util.Util;
|
||||||
|
|
||||||
public class BlockingListener implements Listener{
|
public class BlockingListener implements Listener{
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
|
@ -16,6 +18,9 @@ public class BlockingListener implements Listener{
|
||||||
if(event.getEntity() instanceof Player) {
|
if(event.getEntity() instanceof Player) {
|
||||||
|
|
||||||
Player p = (Player) event.getEntity();
|
Player p = (Player) event.getEntity();
|
||||||
|
if(!Util.usingPack(p)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(p.isHandRaised() || p.isBlocking()){
|
if(p.isHandRaised() || p.isBlocking()){
|
||||||
double newdamage = event.getDamage() * 0.5;
|
double newdamage = event.getDamage() * 0.5;
|
||||||
if(newdamage < 0) {
|
if(newdamage < 0) {
|
|
@ -1,4 +1,4 @@
|
||||||
package com.fpghoti.classicswords.event;
|
package com.fpghoti.classicswords.listener;
|
||||||
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -17,6 +17,7 @@ import org.bukkit.inventory.ItemStack;
|
||||||
import com.fpghoti.classicswords.item.CItemType;
|
import com.fpghoti.classicswords.item.CItemType;
|
||||||
import com.fpghoti.classicswords.item.ClassicSword;
|
import com.fpghoti.classicswords.item.ClassicSword;
|
||||||
import com.fpghoti.classicswords.util.Storage;
|
import com.fpghoti.classicswords.util.Storage;
|
||||||
|
import com.fpghoti.classicswords.util.Util;
|
||||||
|
|
||||||
public class InventoryListener implements Listener{
|
public class InventoryListener implements Listener{
|
||||||
|
|
||||||
|
@ -30,7 +31,10 @@ public class InventoryListener implements Listener{
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInvClose(InventoryCloseEvent event){
|
public void onInvClose(InventoryCloseEvent event){
|
||||||
if(event.getPlayer() != null){
|
if(event.getPlayer() != null && event.getPlayer() instanceof Player){
|
||||||
|
if(!Util.usingPack((Player)event.getPlayer())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Storage.inInv.remove((Player)event.getPlayer());
|
Storage.inInv.remove((Player)event.getPlayer());
|
||||||
ClassicSword.toShieldInv(((Player)event.getPlayer()).getInventory());
|
ClassicSword.toShieldInv(((Player)event.getPlayer()).getInventory());
|
||||||
ClassicSword.blockToShieldInv(((Player)event.getPlayer()).getInventory());
|
ClassicSword.blockToShieldInv(((Player)event.getPlayer()).getInventory());
|
||||||
|
@ -41,6 +45,9 @@ public class InventoryListener implements Listener{
|
||||||
public void onExp(PlayerExpChangeEvent event){
|
public void onExp(PlayerExpChangeEvent event){
|
||||||
if(event.getPlayer() != null){
|
if(event.getPlayer() != null){
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
|
if(!Util.usingPack(p)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(ClassicSword.isCShield(p.getInventory().getItemInMainHand())) {
|
if(ClassicSword.isCShield(p.getInventory().getItemInMainHand())) {
|
||||||
ItemStack csword = p.getInventory().getItemInMainHand();
|
ItemStack csword = p.getInventory().getItemInMainHand();
|
||||||
if(csword.containsEnchantment(Enchantment.MENDING)) {
|
if(csword.containsEnchantment(Enchantment.MENDING)) {
|
||||||
|
@ -67,6 +74,9 @@ public class InventoryListener implements Listener{
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInvClick(InventoryClickEvent event){
|
public void onInvClick(InventoryClickEvent event){
|
||||||
Player p = (Player) event.getWhoClicked();
|
Player p = (Player) event.getWhoClicked();
|
||||||
|
if(!Util.usingPack(p)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(event.getInventory() != null && p != null){
|
if(event.getInventory() != null && p != null){
|
||||||
if(!event.isShiftClick()) {
|
if(!event.isShiftClick()) {
|
||||||
ClassicSword.toSwordInv(p.getInventory());
|
ClassicSword.toSwordInv(p.getInventory());
|
||||||
|
@ -85,12 +95,21 @@ public class InventoryListener implements Listener{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleDisconnect(Player p) {
|
public static void handleDisconnect(Player p) {
|
||||||
|
if(!Util.usingPack(p)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Storage.inInv.remove(p);
|
Storage.inInv.remove(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onItemClick(InventoryDragEvent event){
|
public void onItemClick(InventoryDragEvent event){
|
||||||
|
if(event.getWhoClicked() instanceof Player) {
|
||||||
|
Player p = (Player)event.getWhoClicked();
|
||||||
|
if(!Util.usingPack(p)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(event.getClass() != null){
|
if(event.getClass() != null){
|
||||||
if(ClassicSword.isCShield(event.getCursor())) {
|
if(ClassicSword.isCShield(event.getCursor())) {
|
||||||
ItemStack newsword = ClassicSword.toSword(event.getCursor(), CItemType.getType(ClassicSword.getCShieldShortName(event.getCursor())));
|
ItemStack newsword = ClassicSword.toSword(event.getCursor(), CItemType.getType(ClassicSword.getCShieldShortName(event.getCursor())));
|
||||||
|
@ -102,6 +121,9 @@ public class InventoryListener implements Listener{
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onHold(PlayerItemHeldEvent event){
|
public void onHold(PlayerItemHeldEvent event){
|
||||||
|
if(!Util.usingPack(event.getPlayer())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(event.getPlayer() != null && ClassicSword.isCShield(event.getPlayer().getInventory().getItem(event.getNewSlot()))){
|
if(event.getPlayer() != null && ClassicSword.isCShield(event.getPlayer().getInventory().getItem(event.getNewSlot()))){
|
||||||
Integer dur = ClassicSword.getCShieldDurability(event.getPlayer().getInventory().getItem(event.getNewSlot()));
|
Integer dur = ClassicSword.getCShieldDurability(event.getPlayer().getInventory().getItem(event.getNewSlot()));
|
||||||
ClassicSword.sendActionbar(event.getPlayer(), "§eDurability: " + dur);
|
ClassicSword.sendActionbar(event.getPlayer(), "§eDurability: " + dur);
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.fpghoti.classicswords.listener;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerKickEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.event.player.PlayerResourcePackStatusEvent;
|
||||||
|
|
||||||
|
import com.fpghoti.classicswords.util.Storage;
|
||||||
|
|
||||||
|
public class PlayerListener implements Listener{
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onResourcePack(PlayerResourcePackStatusEvent event){
|
||||||
|
if(event.getPlayer() != null){
|
||||||
|
Player p = event.getPlayer();
|
||||||
|
if(event.getStatus() == PlayerResourcePackStatusEvent.Status.ACCEPTED) {
|
||||||
|
Storage.usingPack.add(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler (priority = EventPriority.NORMAL)
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
|
handleQuit(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler (priority = EventPriority.NORMAL)
|
||||||
|
public void onPlayerKick(PlayerKickEvent event) {
|
||||||
|
handleQuit(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void handleQuit(Player p) {
|
||||||
|
Storage.usingPack.remove(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.fpghoti.classicswords.event;
|
package com.fpghoti.classicswords.listener;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
|
@ -11,6 +11,7 @@ import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||||
|
|
||||||
import com.fpghoti.classicswords.ClassicSwordsMain;
|
import com.fpghoti.classicswords.ClassicSwordsMain;
|
||||||
import com.fpghoti.classicswords.util.Storage;
|
import com.fpghoti.classicswords.util.Storage;
|
||||||
|
import com.fpghoti.classicswords.util.Util;
|
||||||
|
|
||||||
public class RegenListener implements Listener{
|
public class RegenListener implements Listener{
|
||||||
|
|
||||||
|
@ -23,6 +24,9 @@ public class RegenListener implements Listener{
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onRegen(EntityRegainHealthEvent event){
|
public void onRegen(EntityRegainHealthEvent event){
|
||||||
if(event.getEntityType() == EntityType.PLAYER || event.getRegainReason() == EntityRegainHealthEvent.RegainReason.SATIATED) {
|
if(event.getEntityType() == EntityType.PLAYER || event.getRegainReason() == EntityRegainHealthEvent.RegainReason.SATIATED) {
|
||||||
|
if(!Util.usingPack((Player) event.getEntity())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
Player p = (Player) event.getEntity();
|
Player p = (Player) event.getEntity();
|
||||||
double max = p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
|
double max = p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
|
|
@ -1,4 +1,4 @@
|
||||||
package com.fpghoti.classicswords.event;
|
package com.fpghoti.classicswords.listener;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
@ -18,6 +18,9 @@ import com.fpghoti.classicswords.ClassicSwordsMain;
|
||||||
import com.fpghoti.classicswords.item.CItemType;
|
import com.fpghoti.classicswords.item.CItemType;
|
||||||
import com.fpghoti.classicswords.item.ClassicSword;
|
import com.fpghoti.classicswords.item.ClassicSword;
|
||||||
import com.fpghoti.classicswords.util.Storage;
|
import com.fpghoti.classicswords.util.Storage;
|
||||||
|
import com.fpghoti.classicswords.util.Util;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
public class SwingListener implements Listener{
|
public class SwingListener implements Listener{
|
||||||
|
|
||||||
|
@ -29,6 +32,9 @@ public class SwingListener implements Listener{
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onSwingAtBlock(BlockDamageEvent event){
|
public void onSwingAtBlock(BlockDamageEvent event){
|
||||||
|
if(!Util.usingPack(event.getPlayer())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(event.getBlock() != null){
|
if(event.getBlock() != null){
|
||||||
if(event.getPlayer().getGameMode() != GameMode.CREATIVE && event.getInstaBreak()) {
|
if(event.getPlayer().getGameMode() != GameMode.CREATIVE && event.getInstaBreak()) {
|
||||||
Storage.instabreaks.add(event.getBlock().getType());
|
Storage.instabreaks.add(event.getBlock().getType());
|
||||||
|
@ -40,6 +46,9 @@ public class SwingListener implements Listener{
|
||||||
public void onSwingAtBlock(BlockBreakEvent event){
|
public void onSwingAtBlock(BlockBreakEvent event){
|
||||||
if(event.getPlayer() != null){
|
if(event.getPlayer() != null){
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
|
if(!Util.usingPack(p)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(p.getInventory().getItemInMainHand() != null){
|
if(p.getInventory().getItemInMainHand() != null){
|
||||||
if(p.getInventory().getItemInMainHand().hasItemMeta()){
|
if(p.getInventory().getItemInMainHand().hasItemMeta()){
|
||||||
if(ClassicSword.isCShield(p.getInventory().getItemInMainHand())){
|
if(ClassicSword.isCShield(p.getInventory().getItemInMainHand())){
|
||||||
|
@ -62,6 +71,9 @@ public class SwingListener implements Listener{
|
||||||
if(event.getEntity() != null){
|
if(event.getEntity() != null){
|
||||||
if(event.getDamager() instanceof Player) {
|
if(event.getDamager() instanceof Player) {
|
||||||
Player p = (Player)event.getDamager();
|
Player p = (Player)event.getDamager();
|
||||||
|
if(!Util.usingPack(p)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(event.getEntity() instanceof Player) {
|
if(event.getEntity() instanceof Player) {
|
||||||
Player damaged = (Player) event.getEntity();
|
Player damaged = (Player) event.getEntity();
|
||||||
|
@ -70,11 +82,6 @@ public class SwingListener implements Listener{
|
||||||
ClassicSwordsMain.runRecent(p, damaged);
|
ClassicSwordsMain.runRecent(p, damaged);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if(Storage.blockers.contains(p)) {
|
|
||||||
// System.out.println("B");
|
|
||||||
// p.playSound(p.getLocation(), Sound.BLOCK_NOTE_CHIME, 10.0F, 1.0F);
|
|
||||||
// }
|
|
||||||
|
|
||||||
ItemStack csword = p.getInventory().getItemInMainHand();
|
ItemStack csword = p.getInventory().getItemInMainHand();
|
||||||
if(ClassicSword.isCShield(csword) && p.getGameMode() != GameMode.CREATIVE) {
|
if(ClassicSword.isCShield(csword) && p.getGameMode() != GameMode.CREATIVE) {
|
||||||
ClassicSword.damageCItem(p, csword, 1);
|
ClassicSword.damageCItem(p, csword, 1);
|
||||||
|
@ -87,6 +94,9 @@ public class SwingListener implements Listener{
|
||||||
public void onHit(PlayerInteractEvent event){
|
public void onHit(PlayerInteractEvent event){
|
||||||
if(event.getPlayer() != null){
|
if(event.getPlayer() != null){
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
|
if(!Util.usingPack(p)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if((event.getAction() == Action.LEFT_CLICK_BLOCK) || (event.getAction() == Action.LEFT_CLICK_AIR)) {
|
if((event.getAction() == Action.LEFT_CLICK_BLOCK) || (event.getAction() == Action.LEFT_CLICK_AIR)) {
|
||||||
if(ClassicSword.isCShield(event.getPlayer().getInventory().getItemInMainHand())) {
|
if(ClassicSword.isCShield(event.getPlayer().getInventory().getItemInMainHand())) {
|
||||||
Storage.swingers.add(event.getPlayer());
|
Storage.swingers.add(event.getPlayer());
|
||||||
|
@ -101,16 +111,12 @@ public class SwingListener implements Listener{
|
||||||
|
|
||||||
if(Storage.swingers.contains(p) && ClassicSword.isCShield(p.getInventory().getItemInMainHand())) {
|
if(Storage.swingers.contains(p) && ClassicSword.isCShield(p.getInventory().getItemInMainHand())) {
|
||||||
p.getInventory().setItemInMainHand(ClassicSword.toBlockShield(p.getInventory().getItemInMainHand(), CItemType.getType(ClassicSword.getCShieldShortName(p.getInventory().getItemInMainHand()))));
|
p.getInventory().setItemInMainHand(ClassicSword.toBlockShield(p.getInventory().getItemInMainHand(), CItemType.getType(ClassicSword.getCShieldShortName(p.getInventory().getItemInMainHand()))));
|
||||||
//p.playSound(p.getLocation(), Sound.ENTITY_IRONGOLEM_STEP, 10.0F, 1.0F);
|
|
||||||
p.playSound(p.getLocation(), Sound.ENTITY_IRON_GOLEM_STEP, 10.0F, 1.0F);
|
p.playSound(p.getLocation(), Sound.ENTITY_IRON_GOLEM_STEP, 10.0F, 1.0F);
|
||||||
|
|
||||||
if(Storage.recent.containsKey(p)) {
|
if(Storage.recent.containsKey(p)) {
|
||||||
final Player damaged = Storage.recent.get(p);
|
final Player damaged = Storage.recent.get(p);
|
||||||
Double health = Storage.recenthealth.get(damaged);
|
Double health = Storage.recenthealth.get(damaged);
|
||||||
if(damaged != null && damaged.getHealth() != health && !Storage.kb.contains(damaged)) {
|
if(damaged != null && damaged.getHealth() != health && !Storage.kb.contains(damaged)) {
|
||||||
//damaged.getLocation().getY() + 0.5
|
|
||||||
|
|
||||||
//damaged.setVelocity(p.getEyeLocation().getDirection().setY(p.getEyeLocation().getDirection().getY() + 0.5).multiply(1.005));
|
|
||||||
|
|
||||||
|
|
||||||
double kb = p.getEyeLocation().getDirection().getY();
|
double kb = p.getEyeLocation().getDirection().getY();
|
||||||
|
@ -124,19 +130,18 @@ public class SwingListener implements Listener{
|
||||||
kb = kb/2;
|
kb = kb/2;
|
||||||
damaged.setVelocity(p.getEyeLocation().getDirection().setY(kb).multiply(0.25));
|
damaged.setVelocity(p.getEyeLocation().getDirection().setY(kb).multiply(0.25));
|
||||||
}else {
|
}else {
|
||||||
//damaged.setVelocity(p.getEyeLocation().getDirection().setY(kb).multiply(1.001));
|
|
||||||
damaged.setVelocity(p.getEyeLocation().getDirection().setY(kb).multiply(0.75));
|
damaged.setVelocity(p.getEyeLocation().getDirection().setY(kb).multiply(0.75));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(Storage.perfect.contains(p)) {
|
if(Storage.perfect.contains(p)) {
|
||||||
ClassicSword.sendActionbar(p, "§aPerfect!");
|
ClassicSword.sendActionbar(p, ChatColor.GREEN + "Perfect!");
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
ClassicSword.sendActionbar(p, "§fPe§arfe§act!");
|
ClassicSword.sendActionbar(p, ChatColor.WHITE + "Pe" + ChatColor.GREEN + "rfe" + ChatColor.GREEN + "ct!");
|
||||||
}
|
}
|
||||||
}, 3L);
|
}, 3L);
|
||||||
|
|
||||||
|
@ -144,7 +149,7 @@ public class SwingListener implements Listener{
|
||||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
ClassicSword.sendActionbar(p, "§aPe§frfe§act!");
|
ClassicSword.sendActionbar(p, ChatColor.GREEN + "Pe" + ChatColor.WHITE + "rfe" + ChatColor.GREEN + "ct!");
|
||||||
}
|
}
|
||||||
}, 6L);
|
}, 6L);
|
||||||
|
|
||||||
|
@ -152,7 +157,7 @@ public class SwingListener implements Listener{
|
||||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
ClassicSword.sendActionbar(p, "§aPe§arfe§fct!");
|
ClassicSword.sendActionbar(p, ChatColor.GREEN + "Pe" + ChatColor.GREEN + "rfe" + ChatColor.WHITE + "ct!");
|
||||||
}
|
}
|
||||||
}, 9L);
|
}, 9L);
|
||||||
|
|
||||||
|
@ -160,13 +165,13 @@ public class SwingListener implements Listener{
|
||||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
ClassicSword.sendActionbar(p, "§aPerfect!");
|
ClassicSword.sendActionbar(p, ChatColor.GREEN + "Perfect!");
|
||||||
}
|
}
|
||||||
}, 12L);
|
}, 12L);
|
||||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
ClassicSword.sendActionbar(p, "§a§lPerfect!");
|
ClassicSword.sendActionbar(p, ChatColor.GREEN + "" + ChatColor.BOLD + "Perfect!");
|
||||||
}
|
}
|
||||||
}, 14L);
|
}, 14L);
|
||||||
|
|
||||||
|
@ -177,13 +182,13 @@ public class SwingListener implements Listener{
|
||||||
Storage.kb.add(damaged);
|
Storage.kb.add(damaged);
|
||||||
ClassicSwordsMain.runKB(damaged);
|
ClassicSwordsMain.runKB(damaged);
|
||||||
}else if(Storage.great.contains(p)) {
|
}else if(Storage.great.contains(p)) {
|
||||||
ClassicSword.sendActionbar(p, "§eGreat!");
|
ClassicSword.sendActionbar(p, ChatColor.GREEN + "Great!");
|
||||||
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_BELL, 1.0F, 1.2F);
|
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_BELL, 1.0F, 1.2F);
|
||||||
Storage.perfect.add(p);
|
Storage.perfect.add(p);
|
||||||
Storage.kb.add(damaged);
|
Storage.kb.add(damaged);
|
||||||
ClassicSwordsMain.runKB(damaged);
|
ClassicSwordsMain.runKB(damaged);
|
||||||
}else {
|
}else {
|
||||||
ClassicSword.sendActionbar(p, "§cGood!");
|
ClassicSword.sendActionbar(p, ChatColor.YELLOW + "Good!");
|
||||||
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_BELL, 1.0F, 1.0F);
|
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_BELL, 1.0F, 1.0F);
|
||||||
ClassicSwordsMain.streakTimer(p);
|
ClassicSwordsMain.streakTimer(p);
|
||||||
Storage.great.add(p);
|
Storage.great.add(p);
|
||||||
|
@ -198,14 +203,14 @@ public class SwingListener implements Listener{
|
||||||
|
|
||||||
ClassicSwordsMain.blockToShieldTimer(p);
|
ClassicSwordsMain.blockToShieldTimer(p);
|
||||||
}else {
|
}else {
|
||||||
//ClassicSword.sendActionbar(p, "§aBlock hit!");
|
//ClassicSword.sendActionbar(p, ChatColor.GREEN + "Block hit!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// System.out.println("A");
|
// System.out.println("A");
|
||||||
// Storage.blockers.add(p);
|
// Storage.blockers.add(p);
|
||||||
// ClassicSwordsMain.runBlock(p);
|
// ClassicSwordsMain.runBlock(p);
|
||||||
}else {
|
}else {
|
||||||
//ClassicSword.sendActionbar(p, "§aBlock hit!");
|
//ClassicSword.sendActionbar(p, ChatColor.GREEN + "Block hit!");
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
|
@ -14,6 +14,8 @@ import org.bukkit.entity.Player;
|
||||||
import io.netty.util.internal.ConcurrentSet;
|
import io.netty.util.internal.ConcurrentSet;
|
||||||
import net.minecraft.server.v1_15_R1.NBTTagCompound;
|
import net.minecraft.server.v1_15_R1.NBTTagCompound;
|
||||||
|
|
||||||
|
// TODO rework plugin to get rid of this mess
|
||||||
|
|
||||||
public class Storage {
|
public class Storage {
|
||||||
public static ConcurrentHashMap<String, Boolean> bools = new ConcurrentHashMap<>();
|
public static ConcurrentHashMap<String, Boolean> bools = new ConcurrentHashMap<>();
|
||||||
public static HashMap<String, NBTTagCompound> damagetag = new HashMap<>();
|
public static HashMap<String, NBTTagCompound> damagetag = new HashMap<>();
|
||||||
|
@ -29,4 +31,5 @@ public class Storage {
|
||||||
public static ConcurrentSet<Player> kb = new ConcurrentSet<>();
|
public static ConcurrentSet<Player> kb = new ConcurrentSet<>();
|
||||||
public static ConcurrentSet<Player> great = new ConcurrentSet<>();
|
public static ConcurrentSet<Player> great = new ConcurrentSet<>();
|
||||||
public static ConcurrentSet<Player> perfect = new ConcurrentSet<>();
|
public static ConcurrentSet<Player> perfect = new ConcurrentSet<>();
|
||||||
|
public static ConcurrentSet<Player> usingPack = new ConcurrentSet<>();
|
||||||
}
|
}
|
|
@ -5,18 +5,18 @@ import java.util.UUID;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class Functions {
|
public class Util {
|
||||||
|
|
||||||
public Player playerGet(String uuid){
|
|
||||||
|
|
||||||
|
public static Player playerGet(String uuid){
|
||||||
UUID id = UUID.fromString(uuid);
|
UUID id = UUID.fromString(uuid);
|
||||||
Player p = Bukkit.getPlayer(id);
|
Player p = Bukkit.getPlayer(id);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean cModeEnabled(Player p) {
|
public static Boolean usingPack(Player p) {
|
||||||
Boolean enabled = false;
|
return Storage.usingPack.contains(p);
|
||||||
//TO DO Work on resource pack detection
|
|
||||||
return enabled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Player getEP(String playername){
|
public static Player getEP(String playername){
|
|
@ -1,6 +1,6 @@
|
||||||
main: com.fpghoti.classicswords.ClassicSwordsMain
|
main: com.fpghoti.classicswords.ClassicSwordsMain
|
||||||
version: BETA-1.0
|
version: ${project.version}
|
||||||
api-version: 1.13
|
api-version: 1.15
|
||||||
name: ClassicSwords
|
name: ClassicSwords
|
||||||
descripion: Bring back the old combat!
|
descripion: Bring back the old combat!
|
||||||
commands:
|
commands:
|
Loading…
Reference in New Issue