Skip to content

Commit

Permalink
4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kadotcom committed Jan 14, 2024
1 parent 4551a90 commit db7d908
Show file tree
Hide file tree
Showing 13 changed files with 172 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.kadotcom</groupId>
<artifactId>LifeStolen</artifactId>
<version>4.0Tested-2</version>
<version>4.0</version>
<packaging>jar</packaging>

<name>LifeStolen</name>
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/me/kadotcom/lifestolen/Commands/AddHealth.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
}else{
p.sendMessage("Player not found!");
}
}else{
p.sendMessage(plugin.getConfig().getString("permissions.sethealth.permission-message").replace("&", "§"));
}


Expand Down
2 changes: 0 additions & 2 deletions src/main/java/me/kadotcom/lifestolen/Commands/GiveHeart.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
p.sendMessage(plugin.getConfig().getString("heart.disabledMessage").replace("&", "§"));
}
return true;
}else{
p.sendMessage(plugin.getConfig().getString("permissions.giveheart.permission-message").replace("&", "§"));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
if(p.isOp() || p.hasPermission(plugin.getCommand("reloadls").getPermission()) || p.hasPermission(plugin.getConfig().getString("permissions.permissionToDoEverything"))){
plugin.reloadConfig();
p.sendMessage("[" + ChatColor.RED + "LifeStolen" + ChatColor.WHITE + "] Reloaded!");
}else{
p.sendMessage(plugin.getConfig().getString("permissions.reload.permission-message").replace("&", "§"));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
}else{
p.sendMessage("Player not found!");
}
}else{
p.sendMessage(plugin.getConfig().getString("permissions.sethealth.permission-message").replace("&", "§"));
}


Expand Down
2 changes: 0 additions & 2 deletions src/main/java/me/kadotcom/lifestolen/Commands/ResetHP.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
target.sendMessage(ChatColor.RED + "Your hearts has been resetted.");

}
}else{
p.sendMessage(plugin.getConfig().getString("permissions.resethp.permission-message").replace("&", "§"));
}


Expand Down
2 changes: 0 additions & 2 deletions src/main/java/me/kadotcom/lifestolen/Commands/SetHealth.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
}else{
p.sendMessage("Player not found!");
}
}else{
p.sendMessage(plugin.getConfig().getString("permissions.sethealth.permission-message").replace("&", "§"));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
}

if(plugin.getConfig().getBoolean("permissions.vercheck.bePermissionBased") && p.hasPermission(plugin.getConfig().getString("permissions.vercheck.permission"))){
if (!HTTP.get("https://api.spigotmc.org/legacy/update.php?resource=99220").equalsIgnoreCase(plugin.getDescription().getVersion()) && !plugin.getDescription().getVersion().contains("Tested")) {
if (!HTTP.get("https://api.spigotmc.org/legacy/update.php?resource=99220").equalsIgnoreCase(plugin.getDescription().getVersion()) && !plugin.getDescription().getVersion().contains("Tested") && plugin.getConfig().getBoolean("disableVersionMessage")) {
p.sendMessage("&7You are currently using LifeStolen version " + ver + ", you are using an outdated version of LifeStolen.");
} else {
p.sendMessage("&7You are currently using LifeStolen version " + ver);
Expand Down
136 changes: 135 additions & 1 deletion src/main/java/me/kadotcom/lifestolen/Commands/ViewRecipes.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,138 @@
package me.kadotcom.lifestolen.Commands;

public class ViewRecipes {
import me.kadotcom.lifestolen.LifeStolen;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;

import java.util.ArrayList;
import java.util.List;

public class ViewRecipes implements CommandExecutor {
LifeStolen plugin;
public ViewRecipes(LifeStolen ls){
plugin = ls;
}

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

if(sender instanceof Player){
Player p = (Player) sender;

Inventory gui = Bukkit.createInventory(p,45, "LifeStolen Crafting View");
if(args[0].equalsIgnoreCase("heart")){
ItemStack[] menu = {
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.valueOf(plugin.getConfig().getString("HeartRecipe.Slot1"))),
new ItemStack(Material.valueOf(plugin.getConfig().getString("HeartRecipe.Slot2"))),
new ItemStack(Material.valueOf(plugin.getConfig().getString("HeartRecipe.Slot3"))),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.valueOf(plugin.getConfig().getString("HeartRecipe.Slot4"))),
new ItemStack(Material.valueOf(plugin.getConfig().getString("HeartRecipe.Slot5"))),
new ItemStack(Material.valueOf(plugin.getConfig().getString("HeartRecipe.Slot6"))),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.valueOf(plugin.getConfig().getString("HeartRecipe.Slot7"))),
new ItemStack(Material.valueOf(plugin.getConfig().getString("HeartRecipe.Slot8"))),
new ItemStack(Material.valueOf(plugin.getConfig().getString("HeartRecipe.Slot9"))),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
};
gui.setContents(menu);
}else if(args[0].equalsIgnoreCase("reviver")){
ItemStack[] menu = {
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.valueOf(plugin.getConfig().getString("ReviverRecipe.Slot1"))),
new ItemStack(Material.valueOf(plugin.getConfig().getString("ReviverRecipe.Slot2"))),
new ItemStack(Material.valueOf(plugin.getConfig().getString("ReviverRecipe.Slot3"))),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.valueOf(plugin.getConfig().getString("ReviverRecipe.Slot4"))),
new ItemStack(Material.valueOf(plugin.getConfig().getString("ReviverRecipe.Slot5"))),
new ItemStack(Material.valueOf(plugin.getConfig().getString("ReviverRecipe.Slot6"))),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.valueOf(plugin.getConfig().getString("ReviverRecipe.Slot7"))),
new ItemStack(Material.valueOf(plugin.getConfig().getString("ReviverRecipe.Slot8"))),
new ItemStack(Material.valueOf(plugin.getConfig().getString("ReviverRecipe.Slot9"))),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
new ItemStack(Material.GRAY_STAINED_GLASS_PANE),
};
gui.setContents(menu);
}else{
p.sendMessage("§f[§cLifeStolen§f] " + args[0] + " isn't a valid item in LifeStolen.");
gui = null;
return true;
}

p.openInventory(gui);
}

return true;
}
}
21 changes: 21 additions & 0 deletions src/main/java/me/kadotcom/lifestolen/Events/GUIEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package me.kadotcom.lifestolen.Events;

import me.kadotcom.lifestolen.LifeStolen;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;

public class GUIEvent implements Listener {

LifeStolen plugin;
public GUIEvent(LifeStolen ls){
plugin = ls;
}

@EventHandler
public void ClickEvent(InventoryClickEvent e){
if(e.getView().getTitle().equalsIgnoreCase("LifeStolen Crafting View")){
e.setCancelled(true);
}
}
}
8 changes: 6 additions & 2 deletions src/main/java/me/kadotcom/lifestolen/LifeStolen.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import me.kadotcom.lifestolen.Commands.*;
import me.kadotcom.lifestolen.Events.ChatEvent;
import me.kadotcom.lifestolen.Events.GUIEvent;
import me.kadotcom.lifestolen.Events.ItemEvent;
import me.kadotcom.lifestolen.Events.LifeStealEvent;
import me.kadotcom.lifestolen.Managers.ItemManager;
import net.md_5.bungee.api.chat.ClickEvent;
import org.bukkit.plugin.java.JavaPlugin;
import me.kadotcom.lifestolen.Utils.HTTP;

Expand All @@ -20,6 +22,7 @@ public void onEnable() {
// Events
getServer().getPluginManager().registerEvents(new ItemEvent(this), this);
getServer().getPluginManager().registerEvents(new ChatEvent(this), this);
getServer().getPluginManager().registerEvents(new GUIEvent(this), this);
getServer().getPluginManager().registerEvents(new LifeStealEvent(this), this);
// Commands
getCommand("giveheart").setExecutor(new GiveHeart(this));
Expand All @@ -32,11 +35,12 @@ public void onEnable() {
getCommand("reloadls").setExecutor(new ReloadLifeStolen(this));
getCommand("lshelp").setExecutor(new LifeStolenHelp(this));
getCommand("vercheck").setExecutor(new VerCheck(this));
getCommand("viewrecipes").setExecutor(new ViewRecipes(this));

// Plugin startup logic
if(!HTTP.get("https://api.spigotmc.org/legacy/update.php?resource=99220").equalsIgnoreCase(this.getDescription().getVersion()) && !this.getDescription().getVersion().contains("Tested")){
if(!HTTP.get("https://api.spigotmc.org/legacy/update.php?resource=99220").equalsIgnoreCase(this.getDescription().getVersion()) && !this.getDescription().getVersion().contains("Tested") && !this.getConfig().getBoolean("disableVersionMessage")){
log.info("♡ LifeStolen ♡ \nVersion: " + this.getDescription().getVersion() + " \nPlugin by: KadotCom\n\n(NOTE: This version is outdated)");
}else{
}else {
log.info("♡ LifeStolen ♡ \nVersion: " + this.getDescription().getVersion() + " \nPlugin by: KadotCom");
}
getConfig().options().copyDefaults();
Expand Down
8 changes: 5 additions & 3 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

# General

disableVersionMessage: false # Indicates whether the version message should be enabled.

HP:
startHP: 20 # When a player first joins a server, the health will be set to this.
returnHP: 20 # When a player is unbanned, their health will reset
Expand Down Expand Up @@ -66,13 +68,13 @@ reviver:

# Death Punishments

banning:
banning: # Category for banning a player on full death (if banOnDeath is enabled).
banTime: 86400 # Ban duration in seconds.
permBan: false # Will override the ban time and permanently ban the player.
banReason: "&4You ran out of hearts." # The ban message.
kickMessage: "&4You ran out of hearts..." # Kick message for when you get banned.

teleporting: # All for if teleportOnDeath is enabled.
teleporting: # Category for teleporting a player on full death (if teleportOnDeath is enabled).
xCord: 0.0 # X cord of location you want player to be teleported to
yCord: 0.0 # Y cord of location you want player to be teleported to
zCord: 0.0 # Z cord of location you want player to be teleported to
Expand All @@ -83,7 +85,7 @@ teleporting: # All for if teleportOnDeath is enabled.
# 3 = Spectator
giveDefaultHP: true # If enabled, the player will be given the default HP once teleported.

commands:
commands: # Category for running commands when a player gets a full death (if runCommandsOnDeath is enabled).
commandsToRun: ["say Hello.","say World!"] # The commands that will run on full death. (Do not include the / at the beginning.)

# Crafting
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,7 @@ commands:
vercheck:
description: Checks the version of LifeStolen you are using.
usage: /<command>
viewrecipes:
description: Allows you to view the plugin's item recipes.
usage: /<command> [heart/reviver]

0 comments on commit db7d908

Please sign in to comment.