Skip to content

Commit

Permalink
Merge pull request #3 from BT-Pluginz/v1.0
Browse files Browse the repository at this point in the history
V1.0
  • Loading branch information
TubYoub authored Jul 13, 2024
2 parents 8b3d429 + f97aa50 commit c9f3968
Show file tree
Hide file tree
Showing 24 changed files with 2,722 additions and 531 deletions.
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# BT Graves
![Static Badge](https://img.shields.io/badge/MC-1.13-green)
![Static Badge](https://img.shields.io/badge/MC-1.14-green)
![Static Badge](https://img.shields.io/badge/MC-1.15-green)
![Static Badge](https://img.shields.io/badge/MC-1.16-green)
![Static Badge](https://img.shields.io/badge/MC-1.17-green)
![Static Badge](https://img.shields.io/badge/MC-1.18-green)
![Static Badge](https://img.shields.io/badge/MC-1.19-green)
![Static Badge](https://img.shields.io/badge/MC-1.20-green)
![Static Badge](https://img.shields.io/badge/MC-1.21-green)
![Modrinth Downloads](https://img.shields.io/modrinth/dt/WGgaXko0?logo=Modrinth&style=flat-square)


![forthebadge](https://forthebadge.com/images/badges/works-on-my-machine.svg)

<p align="center">
<a href="https://discord.pluginz.dev">
<img src="https://i.imgur.com/JgDt1Fl.png" width="300">
</a>
<br>
<i>Please join the Discord if you have questions!</i>
</p>
<br>

This Minecraft Plugin spawn a Grave when they die which saves their inventory and also Exp.
## Features
- When a player dies the Grave Spawns a Grave, which has a Playerhead on the ground and a name over it.
- The Grave will always search for the next option to spawn:
- always on top of Liquids
- never in the Wall always the next best location
- Graves also cant be destroyed by a player.
- Liquid proof
- Explosion proof
- piston proof
- Graves Save to a file, so they will retain themselves after a restart or server crash.
- Timer for how long should last before dropping everything on the ground.
- Grave Names are only updated when a player is in reach of the Grave to prevent unnecessary lag.
#### Config
- disable/ enable Version checking
- change the armor stand which is used by the Plugin. Big/small
- change how much of the Level should be retained in the Grave
#### Commands
- `/grave info`: gives general info from the Plugin
- `/grave reload`: reloads the Config
## Permission
- `btgraves.reload`: allows a player to reload the config of the plugin
## Stats
The Plugin also uses Bstats for basic Stats collection, I just use the basic stats which are automatically collected like player count or Minecraft Version.
You can find the Plugin page [here](https://bstats.org/plugin/bukkit/Bt%20Graves/22622).
## Installation
To install the plugin, simply download the latest release file and place it in your server's plugins folder. Then, restart your server.
## Support
For Support open an issue or join the [Discord](https://discord.pluginz.dev)
## License

This project is licensed under the [MIT License](LICENSE).

[![forthebadge](https://forthebadge.com/images/badges/powered-by-black-magic.svg)](https://forthebadge.com)
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<version>1.0</version>
<packaging>jar</packaging>

<name>BT's GravePlugin</name>
<name>BT Graves</name>

<properties>
<java.version>1.8</java.version>
Expand Down
123 changes: 117 additions & 6 deletions src/main/java/dev/pluginz/graveplugin/GravePlugin.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,139 @@
/*
* This file is part of BT's Graves, licensed under the MIT License.
*
* Copyright (c) BT Pluginz <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package dev.pluginz.graveplugin;

import dev.pluginz.graveplugin.command.GraveCommand;
import dev.pluginz.graveplugin.listener.GraveListener;
import dev.pluginz.graveplugin.manager.GraveManager;
import dev.pluginz.graveplugin.command.GraveTabCompleter;
import dev.pluginz.graveplugin.listener.*;
import dev.pluginz.graveplugin.manager.*;
import dev.pluginz.graveplugin.util.VersionChecker;
import dev.pluginz.graveplugin.util.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;

public class GravePlugin extends JavaPlugin {
private final String version = "1.0";
private final String project = "WGgaXko0";
private final int pluginId = 22622;

private GraveManager graveManager;
private GraveInventoryManager graveInventoryManager;
private GravePersistenceManager gravePersistenceManager;
private GraveTimeoutManager graveTimeoutManager;
private ConfigManager configManager;
private boolean newVersion;

@Override
public void onEnable() {
saveDefaultConfig();
this.getLogger().info("_____________________________ ");
this.getLogger().info("\\______ \\__ ___/ _____/ ");
this.getLogger().info(" | | _/ | | / \\ ___ ");
this.getLogger().info(" | | \\ | | \\ \\_\\ \\");
this.getLogger().info(" |______ / |____| \\______ /" + " BT Graves v" + version);
this.getLogger().info(" \\/ \\/ " + " Running on " + Bukkit.getServer().getName() + " using Blackmagic");

configManager = new ConfigManager(this);
configManager.loadConfig();

if (configManager.isCheckVersion()) {
newVersion = VersionChecker.isNewVersionAvailable(version, project);
if (newVersion) {
this.getLogger().warning("There is a new Version available for BT's CombatLogger");
}
}

graveManager = new GraveManager(this);
graveManager.loadGraves();
getServer().getPluginManager().registerEvents(new GraveListener(this, graveManager), this);
graveInventoryManager = new GraveInventoryManager(this);
gravePersistenceManager = new GravePersistenceManager(this);
graveTimeoutManager = new GraveTimeoutManager(this);

graveManager.setPersistenceManager(gravePersistenceManager);
gravePersistenceManager.loadGraves();
graveTimeoutManager.startGraveTimeoutTask();
getServer().getPluginManager().registerEvents(new BlockBreakListener(this), this);
getServer().getPluginManager().registerEvents(new BlockExplodeListener(this), this);
getServer().getPluginManager().registerEvents(new BlockPistonExtendListener(this), this);
getServer().getPluginManager().registerEvents(new InventoryListener(this), this);
getServer().getPluginManager().registerEvents(new LiquidFlowListener(this), this);
getServer().getPluginManager().registerEvents(new PlayerDeathListener(this), this);
getServer().getPluginManager().registerEvents(new PlayerInteractListener(this), this);
getServer().getPluginManager().registerEvents(new BlockPlaceListener(this), this);
getCommand("grave").setExecutor(new GraveCommand(this));
getCommand("grave").setTabCompleter(new GraveTabCompleter());

Metrics metrics = new Metrics(this, pluginId);
}

@Override
public void onDisable() {
gravePersistenceManager.saveGraves();
configManager.saveConfig();
this.getLogger().info("-----");
this.getLogger().info(" ");
this.getLogger().warning("If this is a reload please note that this could break the Plugin");
this.getLogger().info(" ");
this.getLogger().info("-----");
}

public String getPluginPrefix() {
return ChatColor.WHITE + "[" + ChatColor.DARK_GRAY + "BTG" + ChatColor.WHITE + "] ";
}

public void sendPluginMessages(CommandSender sender, String type) {
if ("title".equals(type)) {
sender.sendMessage(ChatColor.BLACK + "◢◤" + ChatColor.DARK_GRAY + "BT" + ChatColor.BLACK + "'"+ ChatColor.DARK_GRAY + "s" + ChatColor.DARK_PURPLE + " Graves" + ChatColor.BLACK + "◥◣");
} else if ("line".equals(type)) {
sender.sendMessage(ChatColor.BLACK + "-" + ChatColor.DARK_GRAY + "-" + ChatColor.GRAY + "-" + ChatColor.YELLOW + "-" + ChatColor.LIGHT_PURPLE + "-" + ChatColor.DARK_PURPLE + "-"
+ ChatColor.BLACK + "-" + ChatColor.DARK_GRAY + "-" + ChatColor.GRAY + "-" + ChatColor.YELLOW + "-" + ChatColor.LIGHT_PURPLE + "-" + ChatColor.DARK_PURPLE + "-"
+ ChatColor.BLACK + "-" + ChatColor.DARK_GRAY + "-" + ChatColor.GRAY + "-" + ChatColor.YELLOW + "-" + ChatColor.LIGHT_PURPLE + "-" + ChatColor.DARK_PURPLE + "-"
+ ChatColor.BLACK + "-");
}
}

public String getVersion(){
return version;
}
public boolean isNewVersion(){
return newVersion;
}
public GraveManager getGraveManager() {
return graveManager;
}
}
public ConfigManager getConfigManager(){
return configManager;
}

public GraveInventoryManager getGraveInventoryManager() {
return graveInventoryManager;
}
public GravePersistenceManager getGravePersistenceManager() {
return gravePersistenceManager;
}
public GraveTimeoutManager getGraveTimeoutManager() {
return graveTimeoutManager;
}
}
93 changes: 90 additions & 3 deletions src/main/java/dev/pluginz/graveplugin/command/GraveCommand.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,109 @@
package dev.pluginz.graveplugin.command;
/*
* This file is part of BT's Graves, licensed under the MIT License.
*
* Copyright (c) BT Pluginz <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package dev.pluginz.graveplugin.command;

import dev.pluginz.graveplugin.GravePlugin;
import dev.pluginz.graveplugin.manager.GraveManager;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

public class GraveCommand implements CommandExecutor {
private final GravePlugin plugin;
private final GraveManager graveManager;
private final String prefix;

public GraveCommand(GravePlugin plugin) {
this.plugin = plugin;
this.graveManager = plugin.getGraveManager();
this.prefix = plugin.getPluginPrefix();
}

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
//TODO: I guess, everything?
if (args.length == 0) {
sendHelp(sender);
return true;
}

switch (args[0].toLowerCase()) {
case "info":
handleInfo(sender, args);
return true;
case "reload":
return handleReload(sender);
default:
sendHelp(sender);
return true;
}
}

private void handleInfo(CommandSender sender, String[] args) {
plugin.sendPluginMessages(sender, "title");
sender.sendMessage(ChatColor.GREEN + "Author: BTPluginz");
sender.sendMessage(ChatColor.GREEN + "Version: " + plugin.getVersion());
if (plugin.getConfigManager().isCheckVersion()) {
if (plugin.isNewVersion()) {
sender.sendMessage(ChatColor.YELLOW + "A new version is available! Update at: " + ChatColor.UNDERLINE + "https://modrinth.com/project/bt-graves");
} else {
sender.sendMessage(ChatColor.GREEN + "You are using the latest version!");
}
} else {
sender.sendMessage(ChatColor.GOLD + "Version checking is disabled!");
}
TextComponent githubLink = new TextComponent(ChatColor.DARK_GRAY + "" + ChatColor.UNDERLINE + "GitHub");
githubLink.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://github.com/BT-Pluginz/GravePlugin"));
githubLink.setUnderlined(true);
sender.spigot().sendMessage(githubLink);

TextComponent discordLink = new TextComponent(ChatColor.BLUE + "" + ChatColor.UNDERLINE + "Discord");
discordLink.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://discord.pluginz.dev"));
discordLink.setUnderlined(true);
sender.spigot().sendMessage(discordLink);

sender.sendMessage("If you have any issues please report them on GitHub or on our the Discord.");
plugin.sendPluginMessages(sender, "line");
}

public boolean handleReload(CommandSender sender) {
if (sender.hasPermission("btgraves.reload")) {
plugin.getConfigManager().reloadConfig();
sender.sendMessage(prefix + "The config reloaded.");
} else {
sender.sendMessage(prefix + ChatColor.RED + "You do not have permission to reload the config.");
}
return true;
}

return false;
private void sendHelp(CommandSender sender) {
sender.sendMessage(prefix + "Grave Plugin Commands:");
sender.sendMessage(prefix + "/grave info - Show plugin information");
sender.sendMessage(prefix + "/grave list - List all active graves");
sender.sendMessage(prefix + "/grave list <player> - List graves for a specific player");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package dev.pluginz.graveplugin.command;

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.util.StringUtil;

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

public class GraveTabCompleter implements TabCompleter {

public GraveTabCompleter() {}

@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
List<String> completions = new ArrayList<>();
List<String> commands = new ArrayList<>();

if (args.length == 1) {
if (sender.hasPermission("btgraves.reload")) {
commands.add("reload");
}
commands.add("info");
StringUtil.copyPartialMatches(args[0], commands, completions);
}

Collections.sort(completions);
return completions;
}
}
Loading

0 comments on commit c9f3968

Please sign in to comment.