-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4b367b4
Showing
22 changed files
with
1,400 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
# User-specific stuff | ||
.idea/ | ||
|
||
*.iml | ||
*.ipr | ||
*.iws | ||
|
||
# IntelliJ | ||
out/ | ||
|
||
# Compiled class file | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
|
||
*~ | ||
|
||
# temporary files which can be created if a process still has a handle open of a deleted file | ||
.fuse_hidden* | ||
|
||
# KDE directory preferences | ||
.directory | ||
|
||
# Linux trash folder which might appear on any partition or disk | ||
.Trash-* | ||
|
||
# .nfs files are created when an open file is removed but is still being accessed | ||
.nfs* | ||
|
||
# General | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Icon must end with two \r | ||
Icon | ||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
# Windows thumbnail cache files | ||
Thumbs.db | ||
Thumbs.db:encryptable | ||
ehthumbs.db | ||
ehthumbs_vista.db | ||
|
||
# Dump file | ||
*.stackdump | ||
|
||
# Folder config file | ||
[Dd]esktop.ini | ||
|
||
# Recycle Bin used on file shares | ||
$RECYCLE.BIN/ | ||
|
||
# Windows Installer files | ||
*.cab | ||
*.msi | ||
*.msix | ||
*.msm | ||
*.msp | ||
|
||
# Windows shortcuts | ||
*.lnk | ||
|
||
target/ | ||
|
||
pom.xml.tag | ||
pom.xml.releaseBackup | ||
pom.xml.versionsBackup | ||
pom.xml.next | ||
|
||
release.properties | ||
dependency-reduced-pom.xml | ||
buildNumber.properties | ||
.mvn/timing.properties | ||
.mvn/wrapper/maven-wrapper.jar | ||
.flattened-pom.xml | ||
|
||
# Common working directory | ||
run/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
<?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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>xyz.cosmicity</groupId> | ||
<artifactId>PersonalPvP</artifactId> | ||
<version>1.0</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>PersonalPVP</name> | ||
|
||
<properties> | ||
<java.version>1.8</java.version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.1</version> | ||
<configuration> | ||
<source>11</source> | ||
<target>11</target> | ||
<annotationProcessorPaths> | ||
<path> | ||
<groupId>dev.jorel</groupId> | ||
<artifactId>commandapi-annotations</artifactId> | ||
<version>5.8</version> | ||
</path> | ||
</annotationProcessorPaths> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>3.2.4</version> | ||
<executions> | ||
<execution> | ||
<id>shade</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<createDependencyReducedPom>false</createDependencyReducedPom> | ||
<relocations> | ||
<relocation> | ||
<pattern>dev.jorel.commandapi-shade</pattern> | ||
</relocation> | ||
</relocations> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
</build> | ||
|
||
<repositories> | ||
<repository> | ||
<id>papermc-repo</id> | ||
<url>https://papermc.io/repo/repository/maven-public/</url> | ||
</repository> | ||
<repository> | ||
<id>sonatype</id> | ||
<url>https://oss.sonatype.org/content/groups/public/</url> | ||
</repository> | ||
<repository> <!-- for development builds --> | ||
<id>sonatype-oss</id> | ||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url> | ||
</repository> | ||
<repository> | ||
<id>commandapi</id> | ||
<url>https://raw.githubusercontent.com/JorelAli/CommandAPI/mvn-repo/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.destroystokyo.paper</groupId> | ||
<artifactId>paper-api</artifactId> | ||
<version>1.16.5-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<!-- https://commandapi.jorel.dev/ --> | ||
<dependency> | ||
<groupId>dev.jorel</groupId> | ||
<artifactId>commandapi-shade</artifactId> | ||
<version>5.8</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>dev.jorel</groupId> | ||
<artifactId>commandapi-core</artifactId> | ||
<version>5.8</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>net.kyori</groupId> | ||
<artifactId>adventure-api</artifactId> | ||
<version>4.4.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>net.kyori</groupId> | ||
<artifactId>adventure-platform-bukkit</artifactId> | ||
<version>4.0.0-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>net.kyori</groupId> | ||
<artifactId>adventure-text-minimessage</artifactId> | ||
<version>4.0.0-SNAPSHOT</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
package xyz.cosmicity.personalpvp; | ||
|
||
import org.bukkit.GameMode; | ||
import org.bukkit.enchantments.Enchantment; | ||
import org.bukkit.entity.*; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.EventPriority; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.entity.EntityCombustByEntityEvent; | ||
import org.bukkit.event.entity.EntityDamageByEntityEvent; | ||
import org.bukkit.event.entity.PotionSplashEvent; | ||
import org.bukkit.event.entity.ProjectileHitEvent; | ||
import org.bukkit.event.player.PlayerFishEvent; | ||
import org.bukkit.event.player.PlayerJoinEvent; | ||
import org.bukkit.event.player.PlayerQuitEvent; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.potion.PotionEffect; | ||
import org.bukkit.potion.PotionEffectType; | ||
import org.bukkit.potion.PotionType; | ||
import org.jetbrains.annotations.NotNull; | ||
import xyz.cosmicity.personalpvp.managers.PVPManager; | ||
import xyz.cosmicity.personalpvp.managers.TaskManager; | ||
|
||
import java.util.Arrays; | ||
|
||
public class Listeners implements Listener { | ||
|
||
public Listeners(final PPVPPlugin pl) { | ||
if(pl.prevent_player_damage()) { | ||
pl.getServer().getPluginManager().registerEvents(new DamageByEntityListener(), pl); | ||
} | ||
if(pl.prevent_fishing_rods()) { | ||
pl.getServer().getPluginManager().registerEvents(new FishingListener(), pl); | ||
} | ||
if(pl.prevent_projectiles()) { | ||
pl.getServer().getPluginManager().registerEvents(new ProjectileListener(), pl); | ||
} | ||
if(pl.prevent_potions()) { | ||
pl.getServer().getPluginManager().registerEvents(new PotionListener(), pl); | ||
} | ||
if(pl.prevent_combustion()) { | ||
pl.getServer().getPluginManager().registerEvents(new CombustionListener(), pl); | ||
} | ||
if(pl.getConfig().getBoolean("actionbar.enable")) { | ||
pl.getServer().getPluginManager().registerEvents(this, pl); | ||
} | ||
} | ||
@EventHandler(priority = EventPriority.MONITOR) | ||
public void onJoin(final PlayerJoinEvent e) { | ||
TaskManager.addUuid(e.getPlayer().getUniqueId()); | ||
} | ||
@EventHandler(priority = EventPriority.MONITOR) | ||
public void onQuit(final PlayerQuitEvent e) { | ||
TaskManager.remUuid(e.getPlayer().getUniqueId()); | ||
} | ||
} | ||
class QuitListener implements Listener { | ||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) | ||
public void onQuit(final PlayerQuitEvent e) { | ||
PVPManager.reset(e.getPlayer().getUniqueId()); | ||
} | ||
} | ||
class DamageByEntityListener implements Listener { | ||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) | ||
public void onDamage(@NotNull EntityDamageByEntityEvent e) { | ||
if(!(e.getEntity() instanceof Player) || !(e.getDamager() instanceof Player)) return; | ||
if(PVPManager.pvpNegative(e.getEntity().getUniqueId())||PVPManager.pvpNegative(e.getDamager().getUniqueId())) { | ||
e.setCancelled(true); | ||
} | ||
} | ||
} | ||
class PotionListener implements Listener { | ||
private final PotionEffectType[] BAD_EFFECTS = new PotionEffectType[]{ | ||
PotionEffectType.BLINDNESS, | ||
PotionEffectType.CONFUSION, | ||
PotionEffectType.HARM, | ||
PotionEffectType.HUNGER, | ||
PotionEffectType.POISON, | ||
PotionEffectType.SLOW, | ||
PotionEffectType.SLOW_DIGGING, | ||
PotionEffectType.WEAKNESS | ||
}; | ||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) | ||
public void onSplash(final PotionSplashEvent e){ | ||
if((!(e.getEntity().getShooter() instanceof Player) || | ||
e.getAffectedEntities().stream().noneMatch(entity -> entity instanceof Player))) return; | ||
if(e.getPotion().getEffects().stream().map(PotionEffect::getType).noneMatch(Arrays.asList(this.BAD_EFFECTS)::contains)) return; | ||
if(PVPManager.pvpNegative((((Player) e.getEntity().getShooter()).getUniqueId())) | ||
|| e.getAffectedEntities().stream().filter(livingEntity -> livingEntity instanceof Player).map(LivingEntity::getUniqueId).noneMatch(PVPManager::pvpPositive)) { | ||
e.setCancelled(true); | ||
((Player) e.getEntity().getShooter()).getInventory().addItem(e.getEntity().getItem()); | ||
} | ||
} | ||
} | ||
class ProjectileListener implements Listener { | ||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) | ||
public void onHit(final ProjectileHitEvent e){ | ||
Entity projectile = e.getEntity(); | ||
Player shooter = (Player) e.getEntity().getShooter(); | ||
if(e.getHitEntity()==null || | ||
shooter == null || | ||
!(e.getHitEntity() instanceof Player)) return; | ||
if(PVPManager.pvpNegative((shooter.getUniqueId())) | ||
|| PVPManager.pvpNegative((((e.getHitEntity()).getUniqueId())))) { | ||
e.setCancelled(true); | ||
if((shooter).getGameMode().equals(GameMode.CREATIVE)) return; | ||
if(projectile instanceof Trident) { | ||
ItemStack is = ((Trident) projectile).getItemStack(); | ||
projectile.remove(); | ||
shooter.getInventory().addItem(is); | ||
} | ||
else if(projectile instanceof AbstractArrow) { | ||
projectile.remove(); | ||
if(projectile instanceof Arrow) | ||
if ((((Arrow)projectile).hasCustomEffects()&&((Arrow)projectile).getBasePotionData().getType().equals(PotionType.UNCRAFTABLE)) && | ||
(shooter.getInventory().getItemInMainHand().containsEnchantment(Enchantment.ARROW_INFINITE) | ||
||shooter.getInventory().getItemInOffHand().containsEnchantment(Enchantment.ARROW_INFINITE))) | ||
return; | ||
shooter.getInventory().addItem(((AbstractArrow) projectile).getItemStack()); | ||
} | ||
} | ||
} | ||
} | ||
class FishingListener implements Listener { | ||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) | ||
public void onFish(@NotNull PlayerFishEvent e) { | ||
if(!(e.getCaught() instanceof Player)) return; | ||
if(PVPManager.pvpNegative(e.getCaught().getUniqueId())||PVPManager.pvpNegative(e.getPlayer().getUniqueId())) { | ||
e.setCancelled(true); | ||
PPVPPlugin pl = PPVPPlugin.inst(); | ||
if(!pl.pvp_on_reminder().isEmpty()&&PVPManager.pvpNegative(e.getPlayer().getUniqueId())) Utils.send(e.getPlayer(),Utils.parse(pl.pvp_on_reminder()),false,true); | ||
} | ||
} | ||
} | ||
class CombustionListener implements Listener { | ||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) | ||
public void onCombust(final EntityCombustByEntityEvent e) { | ||
if(!(e.getCombuster() instanceof Player) || | ||
!(e.getEntity() instanceof Player)) return; | ||
if(PVPManager.pvpNegative(e.getCombuster().getUniqueId()) | ||
|| PVPManager.pvpNegative(((e.getEntity().getUniqueId())))) { | ||
e.setCancelled(true); | ||
} | ||
} | ||
} |
Oops, something went wrong.