-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
13 changed files
with
654 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,127 @@ | ||
<?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>space.devport.wertik.firstdeathrewards</groupId> | ||
<artifactId>FirstDeathRewards</artifactId> | ||
<version>1.0.0</version> | ||
|
||
<name>FirstDeathRewards</name> | ||
|
||
<build> | ||
<defaultGoal>clean install</defaultGoal> | ||
<finalName>${project.name}-${project.version}</finalName> | ||
<resources> | ||
<resource> | ||
<filtering>true</filtering> | ||
<directory>src/main/resources/</directory> | ||
</resource> | ||
</resources> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.1</version> | ||
<configuration> | ||
<compilerVersion>1.8</compilerVersion> | ||
<source>8</source> | ||
<target>8</target> | ||
<release>8</release> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>3.2.1</version> | ||
<configuration> | ||
<minimizeJar>true</minimizeJar> | ||
<relocations> | ||
<relocation> | ||
<pattern>space.devport.utils</pattern> | ||
<shadedPattern>${project.groupId}.utils</shadedPattern> | ||
</relocation> | ||
</relocations> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<repositories> | ||
<repository> | ||
<id>spigot-repo</id> | ||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> | ||
</repository> | ||
<repository> | ||
<id>devport</id> | ||
<url>http://play.pvpcraft.cz:8081/repository/devport/</url> | ||
</repository> | ||
<repository> | ||
<id>placeholderapi</id> | ||
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url> | ||
</repository> | ||
<repository> | ||
<id>jitpack.io</id> | ||
<url>https://jitpack.io</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.spigotmc</groupId> | ||
<artifactId>spigot-api</artifactId> | ||
<version>1.16.1-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jetbrains</groupId> | ||
<artifactId>annotations</artifactId> | ||
<version>15.0</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<version>1.18.10</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>space.devport.utils</groupId> | ||
<artifactId>DevportUtils</artifactId> | ||
<version>LATEST</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.github.MilkBowl</groupId> | ||
<artifactId>VaultAPI</artifactId> | ||
<version>1.7</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>me.realized.tokenmanager</groupId> | ||
<artifactId>TokenManager</artifactId> | ||
<version>3.2.5</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>me.clip</groupId> | ||
<artifactId>placeholderapi</artifactId> | ||
<version>2.10.6</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.code.gson</groupId> | ||
<artifactId>gson</artifactId> | ||
<version>2.8.5</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
19 changes: 19 additions & 0 deletions
19
src/main/java/space/devport/wertik/firstdeathrewards/FirstDeathLanguage.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,19 @@ | ||
package space.devport.wertik.firstdeathrewards; | ||
|
||
import space.devport.utils.text.language.LanguageDefaults; | ||
|
||
public class FirstDeathLanguage extends LanguageDefaults { | ||
|
||
@Override | ||
public void setDefaults() { | ||
addDefault("Commands.Invalid-Player", "&cPlayer &f%param% &cdoes not exist."); | ||
|
||
addDefault("Commands.Reset.Done", "&7Reset for &f%player% &7successful."); | ||
addDefault("Commands.Reset.Done-All", "&7Reset for all players successful."); | ||
|
||
addDefault("Commands.Info.Message", "&8&m &7 First Death of &f%player%", "&7Available: %available%"); | ||
addDefault("Commands.Info.You", "&6You"); | ||
addDefault("Commands.Info.Available", "&ayes &7(means he has not died yet)"); | ||
addDefault("Commands.Info.Not-Available", "&cno &7(means he's lame and died already)"); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
src/main/java/space/devport/wertik/firstdeathrewards/FirstDeathPlugin.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,70 @@ | ||
package space.devport.wertik.firstdeathrewards; | ||
|
||
import lombok.Getter; | ||
import space.devport.utils.DevportPlugin; | ||
import space.devport.wertik.firstdeathrewards.commands.FirstDeathCommand; | ||
import space.devport.wertik.firstdeathrewards.commands.subcommands.InfoSubCommand; | ||
import space.devport.wertik.firstdeathrewards.commands.subcommands.ReloadSubCommand; | ||
import space.devport.wertik.firstdeathrewards.commands.subcommands.ResetSubCommand; | ||
import space.devport.wertik.firstdeathrewards.listeners.PlayerListener; | ||
import space.devport.wertik.firstdeathrewards.system.DataManager; | ||
|
||
public class FirstDeathPlugin extends DevportPlugin { | ||
|
||
@Getter | ||
private static FirstDeathPlugin instance; | ||
|
||
@Getter | ||
private DataManager dataManager; | ||
|
||
@Override | ||
public void onPluginEnable() { | ||
instance = this; | ||
|
||
consoleOutput.setColors(true); | ||
|
||
new FirstDeathLanguage(); | ||
|
||
dataManager = new DataManager(); | ||
dataManager.loadData(); | ||
|
||
dataManager.load(); | ||
|
||
dataManager.createSaveTask(); | ||
if (getConfig().getBoolean("auto-save.enabled", false)) | ||
dataManager.getAutoSave().start(); | ||
|
||
getServer().getPluginManager().registerEvents(new PlayerListener(this), this); | ||
|
||
addMainCommand(new FirstDeathCommand() | ||
.addSubCommand(new InfoSubCommand()) | ||
.addSubCommand(new ResetSubCommand()) | ||
.addSubCommand(new ReloadSubCommand())); | ||
} | ||
|
||
@Override | ||
public void onPluginDisable() { | ||
dataManager.save(); | ||
} | ||
|
||
@Override | ||
public void onReload() { | ||
dataManager.loadData(); | ||
dataManager.reloadAutoSave(); | ||
} | ||
|
||
@Override | ||
public boolean useLanguage() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean useHolograms() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean useMenus() { | ||
return false; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/space/devport/wertik/firstdeathrewards/commands/CommandUtils.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,23 @@ | ||
package space.devport.wertik.firstdeathrewards.commands; | ||
|
||
import lombok.experimental.UtilityClass; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.OfflinePlayer; | ||
import org.bukkit.command.CommandSender; | ||
import space.devport.wertik.firstdeathrewards.FirstDeathPlugin; | ||
|
||
@UtilityClass | ||
public class CommandUtils { | ||
|
||
public OfflinePlayer getOfflineTarget(CommandSender sender, String name) { | ||
OfflinePlayer offlinePlayer = Bukkit.getPlayer(name); | ||
|
||
if (offlinePlayer == null) { | ||
FirstDeathPlugin.getInstance().getLanguageManager().getPrefixed("Commands.Invalid-Player") | ||
.replace("%param%", name) | ||
.send(sender); | ||
return null; | ||
} | ||
return offlinePlayer; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/space/devport/wertik/firstdeathrewards/commands/FirstDeathCommand.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,27 @@ | ||
package space.devport.wertik.firstdeathrewards.commands; | ||
|
||
import org.bukkit.command.CommandSender; | ||
import space.devport.utils.commands.MainCommand; | ||
import space.devport.utils.commands.struct.CommandResult; | ||
|
||
public class FirstDeathCommand extends MainCommand { | ||
|
||
public FirstDeathCommand() { | ||
super("firstdeathrewards"); | ||
} | ||
|
||
@Override | ||
protected CommandResult perform(CommandSender sender, String label, String[] args) { | ||
return CommandResult.SUCCESS; | ||
} | ||
|
||
@Override | ||
public String getDefaultUsage() { | ||
return "/%label%"; | ||
} | ||
|
||
@Override | ||
public String getDefaultDescription() { | ||
return "Displays this."; | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...main/java/space/devport/wertik/firstdeathrewards/commands/subcommands/InfoSubCommand.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,61 @@ | ||
package space.devport.wertik.firstdeathrewards.commands.subcommands; | ||
|
||
import org.bukkit.OfflinePlayer; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
import space.devport.utils.commands.SubCommand; | ||
import space.devport.utils.commands.struct.ArgumentRange; | ||
import space.devport.utils.commands.struct.CommandResult; | ||
import space.devport.utils.commands.struct.Preconditions; | ||
import space.devport.wertik.firstdeathrewards.FirstDeathPlugin; | ||
import space.devport.wertik.firstdeathrewards.commands.CommandUtils; | ||
|
||
public class InfoSubCommand extends SubCommand { | ||
|
||
public InfoSubCommand() { | ||
super("info"); | ||
this.preconditions = new Preconditions() | ||
.permissions("firstdeathrewards.info"); | ||
} | ||
|
||
@Override | ||
protected CommandResult perform(CommandSender sender, String label, String[] args) { | ||
|
||
boolean me = false; | ||
|
||
OfflinePlayer target; | ||
if (args.length > 0) { | ||
target = CommandUtils.getOfflineTarget(sender, args[0]); | ||
|
||
if (target == null) return CommandResult.FAILURE; | ||
} else { | ||
if (!(sender instanceof Player)) return CommandResult.NO_CONSOLE; | ||
|
||
target = (Player) sender; | ||
me = true; | ||
} | ||
|
||
boolean dead = FirstDeathPlugin.getInstance().getDataManager().hasFirstDeath(target); | ||
language.get("Commands.Info.Message") | ||
.replace("%player%", me ? language.get("Commands.Info.You").color().toString() : target.getName()) | ||
.replace("%available%", dead ? language.get("Commands.Info.Not-Available").color().toString() : language.get("Commands.Info.Available").color().toString()) | ||
.send(sender); | ||
return CommandResult.SUCCESS; | ||
} | ||
|
||
@Override | ||
public @NotNull String getDefaultUsage() { | ||
return "/%label% info (player)"; | ||
} | ||
|
||
@Override | ||
public @NotNull String getDefaultDescription() { | ||
return "Get info about you or target."; | ||
} | ||
|
||
@Override | ||
public @NotNull ArgumentRange getRange() { | ||
return new ArgumentRange(0, 1); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...in/java/space/devport/wertik/firstdeathrewards/commands/subcommands/ReloadSubCommand.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,39 @@ | ||
package space.devport.wertik.firstdeathrewards.commands.subcommands; | ||
|
||
import org.bukkit.command.CommandSender; | ||
import org.jetbrains.annotations.NotNull; | ||
import space.devport.utils.commands.SubCommand; | ||
import space.devport.utils.commands.struct.ArgumentRange; | ||
import space.devport.utils.commands.struct.CommandResult; | ||
import space.devport.utils.commands.struct.Preconditions; | ||
import space.devport.wertik.firstdeathrewards.FirstDeathPlugin; | ||
|
||
public class ReloadSubCommand extends SubCommand { | ||
|
||
public ReloadSubCommand() { | ||
super("reload"); | ||
this.preconditions = new Preconditions() | ||
.permissions("firstdeathrewards.reload"); | ||
} | ||
|
||
@Override | ||
protected CommandResult perform(CommandSender sender, String label, String[] args) { | ||
FirstDeathPlugin.getInstance().reload(sender); | ||
return CommandResult.SUCCESS; | ||
} | ||
|
||
@Override | ||
public @NotNull String getDefaultUsage() { | ||
return "/%label% reload"; | ||
} | ||
|
||
@Override | ||
public @NotNull String getDefaultDescription() { | ||
return "Reloads the configuration."; | ||
} | ||
|
||
@Override | ||
public @NotNull ArgumentRange getRange() { | ||
return new ArgumentRange(0); | ||
} | ||
} |
Oops, something went wrong.