-
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 236c936
Showing
10 changed files
with
457 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,19 @@ | ||
# Kill Rewards | ||
**Kill rewards** is an easy to use plugin that allows server admins to execute certain actions when a player reaches a certain **killstreak** or **number of kills**. | ||
|
||
## Download | ||
You can download the latest version of **Kill Rewards** [here](https://github.com/TenFont/KillRewards/releases/latest). | ||
|
||
## API Usage | ||
```java | ||
// Obtaining an instance | ||
KillRewards killRewards = (KillRewards) Bukkit.getPluginManager().getPlugin("KillRewards"); | ||
|
||
// Getting the number of kills a player has | ||
Player player = ...; | ||
int kills = killRewards.getKillsManager().getKills(player); | ||
|
||
// Getting the kill streak of a player | ||
Player player = ...; | ||
int kills = killRewards.getKillsManager().getKillStreak(player); | ||
``` |
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,89 @@ | ||
<?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.thetenfont</groupId> | ||
<artifactId>killrewards</artifactId> | ||
<version>1.0</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>KillRewards</name> | ||
|
||
<properties> | ||
<java.version>17</java.version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>2.4</version> | ||
<configuration> | ||
<outputDirectory>D:/Home/server/testing/plugins</outputDirectory> | ||
<finalName>Kill-Rewards-${project.version}</finalName> | ||
</configuration> | ||
</plugin> | ||
<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://repo.papermc.io/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.20.1-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<version>1.18.28</version> | ||
<scope>compile</scope> | ||
</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,53 @@ | ||
package me.thetenfont.killrewards; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import me.thetenfont.killrewards.commands.CmdKillRewards; | ||
import me.thetenfont.killrewards.events.EvtPlayerKill; | ||
import me.thetenfont.killrewards.managers.KillsManager; | ||
import me.thetenfont.killrewards.managers.RewardsManager; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.configuration.file.FileConfiguration; | ||
import org.bukkit.configuration.file.YamlConfiguration; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
@Getter | ||
public final class KillRewards extends JavaPlugin { | ||
KillsManager killsManager; | ||
RewardsManager rewardsManager; | ||
@Getter(AccessLevel.NONE) | ||
File killsConfigFile; | ||
FileConfiguration killsConfig; | ||
|
||
public void saveKillsConfig() { | ||
try { | ||
killsConfig.save(killsConfigFile); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onEnable() { | ||
// Plugin startup logic | ||
killsConfigFile = new File(getDataFolder(), "kills_registry.yml"); | ||
killsConfig = YamlConfiguration.loadConfiguration(killsConfigFile); | ||
|
||
saveDefaultConfig(); | ||
saveKillsConfig(); | ||
|
||
killsManager = new KillsManager(this); | ||
rewardsManager = new RewardsManager(this); | ||
Objects.requireNonNull(getCommand("killrewards")).setExecutor(new CmdKillRewards(this)); | ||
Bukkit.getPluginManager().registerEvents(new EvtPlayerKill(this), this); | ||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
// Plugin shutdown logic | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/me/thetenfont/killrewards/commands/CmdKillRewards.java
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,28 @@ | ||
package me.thetenfont.killrewards.commands; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import me.thetenfont.killrewards.KillRewards; | ||
import net.kyori.adventure.key.Key; | ||
import net.kyori.adventure.sound.Sound; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
@RequiredArgsConstructor | ||
public class CmdKillRewards implements CommandExecutor { | ||
final KillRewards killRewards; | ||
|
||
@Override | ||
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] args) { | ||
if (args.length == 0) { | ||
commandSender.sendMessage("§cInvalid usage. Correct usage is §e/killrewards reload"); | ||
} | ||
else if (args[0].equals("reload")) { | ||
killRewards.reloadConfig(); | ||
commandSender.sendMessage("§aSuccessfully reloaded the configuration file."); | ||
commandSender.playSound(Sound.sound(Key.key("block.note_block.pling"), Sound.Source.BLOCK, 1f, 1f)); | ||
} | ||
return true; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/me/thetenfont/killrewards/events/EvtPlayerKill.java
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,30 @@ | ||
package me.thetenfont.killrewards.events; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import me.thetenfont.killrewards.KillRewards; | ||
import me.thetenfont.killrewards.managers.KillsManager; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.entity.PlayerDeathEvent; | ||
|
||
@RequiredArgsConstructor | ||
public class EvtPlayerKill implements Listener { | ||
final KillRewards killRewards; | ||
|
||
@EventHandler | ||
public void OnPlayerDeath(PlayerDeathEvent event) { | ||
KillsManager killsManager = killRewards.getKillsManager(); | ||
|
||
Player player = event.getPlayer(); | ||
killsManager.setKillStreak(player, 0); | ||
if (player.getKiller() != null) { | ||
Player killer = player.getKiller(); | ||
int kills = killsManager.getKills(killer) + 1; | ||
killsManager.setKills(killer, kills); | ||
int killstreak = killsManager.getKillStreak(killer) + 1; | ||
killsManager.setKillStreak(killer, killstreak); | ||
killRewards.getRewardsManager().checkRewards(killer, kills, killstreak); | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/me/thetenfont/killrewards/managers/KillsManager.java
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,28 @@ | ||
package me.thetenfont.killrewards.managers; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import me.thetenfont.killrewards.KillRewards; | ||
import org.bukkit.entity.Player; | ||
|
||
@RequiredArgsConstructor | ||
public class KillsManager { | ||
private final KillRewards killRewards; | ||
|
||
public int getKills(Player player) { | ||
return killRewards.getKillsConfig().getInt("kills." + player.getUniqueId()); | ||
} | ||
|
||
public void setKills(Player player, int newKills) { | ||
killRewards.getKillsConfig().set("kills." + player.getUniqueId(), newKills); | ||
killRewards.saveKillsConfig(); | ||
} | ||
|
||
public int getKillStreak(Player player) { | ||
return killRewards.getKillsConfig().getInt("killstreak." + player.getUniqueId()); | ||
} | ||
|
||
public void setKillStreak(Player player, int newKillStreak) { | ||
killRewards.getKillsConfig().set("killstreak." + player.getUniqueId(), newKillStreak); | ||
killRewards.saveKillsConfig(); | ||
} | ||
} |
Oops, something went wrong.