Stop Game Items From Dropping
This commit is contained in:
parent
de83b7b26e
commit
ed294714ac
3 changed files with 35 additions and 2 deletions
4
pom.xml
4
pom.xml
|
@ -1,7 +1,7 @@
|
||||||
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion>
|
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>net.tylermurphy</groupId>
|
<groupId>net.tylermurphy</groupId>
|
||||||
<artifactId>KenshinsHideAndSeek</artifactId>
|
<artifactId>KenshinsHideAndSeek</artifactId>
|
||||||
<version>1.6.1</version>
|
<version>1.6.2</version>
|
||||||
<name>Hide and Seek Plugin</name>
|
<name>Hide and Seek Plugin</name>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -95,7 +95,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.13-R0.1-SNAPSHOT</version>
|
<version>1.8-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
|
|
|
@ -21,6 +21,7 @@ package net.tylermurphy.hideAndSeek.configuration;
|
||||||
|
|
||||||
import com.cryptomorin.xseries.XItemStack;
|
import com.cryptomorin.xseries.XItemStack;
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
@ -129,4 +130,23 @@ public class Items {
|
||||||
item.getBoolean("particles")
|
item.getBoolean("particles")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean matchItem(ItemStack stack){
|
||||||
|
for(ItemStack check : HIDER_ITEMS)
|
||||||
|
if(equals(stack,check)) return true;
|
||||||
|
for(ItemStack check : SEEKER_ITEMS)
|
||||||
|
if(equals(stack,check)) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean equals(ItemStack a, ItemStack b) {
|
||||||
|
if (a == null) {
|
||||||
|
return false;
|
||||||
|
} else if (a == b) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return a.getType() == b.getType() && a.hasItemMeta() == b.hasItemMeta() && (!a.hasItemMeta() || Bukkit.getItemFactory().equals(a.getItemMeta(), b.getItemMeta()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,18 @@
|
||||||
package net.tylermurphy.hideAndSeek.game.listener;
|
package net.tylermurphy.hideAndSeek.game.listener;
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
|
import net.tylermurphy.hideAndSeek.configuration.Items;
|
||||||
|
import net.tylermurphy.hideAndSeek.game.Game;
|
||||||
|
import net.tylermurphy.hideAndSeek.game.util.Status;
|
||||||
import org.bukkit.entity.Player;
|
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.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class PlayerHandler implements Listener {
|
public class PlayerHandler implements Listener {
|
||||||
|
|
||||||
|
@ -36,4 +41,12 @@ public class PlayerHandler implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
public void onItemSpawn(ItemSpawnEvent event){
|
||||||
|
if(Main.getInstance().getGame().getStatus() == Status.STANDBY) return;
|
||||||
|
ItemStack item = event.getEntity().getItemStack();
|
||||||
|
if(!Items.matchItem(item)) return;
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue