initial commit

This commit is contained in:
2022-03-05 11:36:59 +01:00
commit 864113e604
5 changed files with 266 additions and 0 deletions
+113
View File
@@ -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/
+76
View File
@@ -0,0 +1,76 @@
<?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>me.youhavetrouble</groupId>
<artifactId>GameDesignTweaks</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>GameDesignTweaks</name>
<description>Tweak some game design stuff</description>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<url>youhavetrouble.me</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</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>
</repositories>
<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,14 @@
package me.youhavetrouble.gamedesigntweaks;
import org.bukkit.plugin.java.JavaPlugin;
public final class GameDesignTweaks extends JavaPlugin {
public static GameDesignTweaks instance;
@Override
public void onEnable() {
instance = this;
getServer().getPluginManager().registerEvents(new SecondWindListener(), this);
}
}
@@ -0,0 +1,56 @@
package me.youhavetrouble.gamedesigntweaks;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import java.util.HashSet;
public class SecondWindListener implements Listener {
HashSet<EntityDamageEvent.DamageCause> dots = new HashSet<>();
public SecondWindListener() {
dots.add(EntityDamageEvent.DamageCause.POISON);
dots.add(EntityDamageEvent.DamageCause.WITHER);
dots.add(EntityDamageEvent.DamageCause.DROWNING);
dots.add(EntityDamageEvent.DamageCause.SUFFOCATION);
dots.add(EntityDamageEvent.DamageCause.VOID);
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerDamage(EntityDamageEvent event) {
if (!(event.getEntity() instanceof Player player)) return;
if (player.isDead()) return;
EntityDamageEvent.DamageCause cause = event.getCause();
if (dots.contains(cause)) return;
double maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
double currentHealth = player.getHealth();
double hpPercentage = (currentHealth * 100.0) / maxHealth;
double damage = event.getFinalDamage();
if (hpPercentage >= 75) {
// Prevent oneshots from 75%+ hp
if (currentHealth - damage <= 0 && !event.getCause().equals(EntityDamageEvent.DamageCause.FALL)) {
event.setDamage(0.0000001);
player.setHealth(1);
}
return;
}
if (hpPercentage >= 50) {
event.setDamage(0.00001);
player.setHealth(Math.max(currentHealth - (damage * 0.8), 0));
return;
}
if (hpPercentage >= 25) {
event.setDamage(0.00001);
player.setHealth(Math.max(currentHealth - (damage * 0.65), 0));
return;
}
event.setDamage(0.00001);
player.setHealth(Math.max(currentHealth - (damage * 0.5), 0));
}
}
+7
View File
@@ -0,0 +1,7 @@
name: GameDesignTweaks
version: '${project.version}'
main: me.youhavetrouble.gamedesigntweaks.GameDesignTweaks
api-version: 1.17
authors: [ YouHaveTrouble ]
description: Tweak some game design stuff
website: youhavetrouble.me