Initial Commit
This commit is contained in:
commit
bcbe3c01ab
46 changed files with 2465 additions and 0 deletions
15
.classpath
Normal file
15
.classpath
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="/mnt/DATA/Programming/APIs/spigot-1.15.2.jar">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
17
.project
Normal file
17
.project
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>little-minecraft-vanilla-extension</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
24
README.md
Normal file
24
README.md
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# **L**ittle **M**inecraft **V**anilla **E**xtension
|
||||
|
||||
A litte fun project of mine to add some features and
|
||||
crafting recipes to Minecraft.
|
||||
|
||||
Used API: *Spigot-1.15.2*
|
||||
|
||||
Minecraft Version: *1.15.2*
|
||||
|
||||
Plugin Version: *Beta-1.1.0*
|
||||
|
||||
#### Features:
|
||||
- Custom Crafting Recipes!
|
||||
- Player Statistics that all players can view via the chat
|
||||
- Join and Quit Messages
|
||||
- A Hardcore Mode with double damage (more Hardcore features coming soon!)
|
||||
- A Sleep Vote System, players can vote to change the time to day via going to Bed
|
||||
- Enraged Mobs, these Mobs are stronger and more resistant to damage(right now only Zombies and Zombie Pigmans but more Mobs are coming soon!)
|
||||
- Mob Griefing Prevention, to prevent creepers, withers and wither skulls destroying blocks
|
||||
- PlayerHeads, there is a small chance that a player head drops if the player dies
|
||||
- A Chat Notification sound!
|
||||
- A prevention that Nether portals are build above the Nether ceiling
|
||||
- A Global mute, to mute the whole chat if needed
|
||||
- And a BossBar that greets the player on join
|
||||
BIN
bin/ml/codenoodles/lmve/Main.class
Normal file
BIN
bin/ml/codenoodles/lmve/Main.class
Normal file
Binary file not shown.
BIN
bin/ml/codenoodles/lmve/modules/CustomRecipes.class
Normal file
BIN
bin/ml/codenoodles/lmve/modules/CustomRecipes.class
Normal file
Binary file not shown.
BIN
bin/ml/codenoodles/lmve/modules/EnragedMobs.class
Normal file
BIN
bin/ml/codenoodles/lmve/modules/EnragedMobs.class
Normal file
Binary file not shown.
BIN
bin/ml/codenoodles/lmve/modules/Hardcore.class
Normal file
BIN
bin/ml/codenoodles/lmve/modules/Hardcore.class
Normal file
Binary file not shown.
BIN
bin/ml/codenoodles/lmve/modules/Leaderboard.class
Normal file
BIN
bin/ml/codenoodles/lmve/modules/Leaderboard.class
Normal file
Binary file not shown.
BIN
bin/ml/codenoodles/lmve/modules/Messages.class
Normal file
BIN
bin/ml/codenoodles/lmve/modules/Messages.class
Normal file
Binary file not shown.
BIN
bin/ml/codenoodles/lmve/modules/NetherPortal.class
Normal file
BIN
bin/ml/codenoodles/lmve/modules/NetherPortal.class
Normal file
Binary file not shown.
BIN
bin/ml/codenoodles/lmve/modules/PlayerHeads.class
Normal file
BIN
bin/ml/codenoodles/lmve/modules/PlayerHeads.class
Normal file
Binary file not shown.
BIN
bin/ml/codenoodles/lmve/modules/PlayerList.class
Normal file
BIN
bin/ml/codenoodles/lmve/modules/PlayerList.class
Normal file
Binary file not shown.
BIN
bin/ml/codenoodles/lmve/modules/PlayerStatistics.class
Normal file
BIN
bin/ml/codenoodles/lmve/modules/PlayerStatistics.class
Normal file
Binary file not shown.
BIN
bin/ml/codenoodles/lmve/modules/PreventMobGriefing.class
Normal file
BIN
bin/ml/codenoodles/lmve/modules/PreventMobGriefing.class
Normal file
Binary file not shown.
BIN
bin/ml/codenoodles/lmve/modules/SQLHandler.class
Normal file
BIN
bin/ml/codenoodles/lmve/modules/SQLHandler.class
Normal file
Binary file not shown.
BIN
bin/ml/codenoodles/lmve/modules/SleepVoteSystem.class
Normal file
BIN
bin/ml/codenoodles/lmve/modules/SleepVoteSystem.class
Normal file
Binary file not shown.
BIN
bin/ml/codenoodles/lmve/modules/StatCounter.class
Normal file
BIN
bin/ml/codenoodles/lmve/modules/StatCounter.class
Normal file
Binary file not shown.
BIN
bin/ml/codenoodles/lmve/modules/UUIDReference.class
Normal file
BIN
bin/ml/codenoodles/lmve/modules/UUIDReference.class
Normal file
Binary file not shown.
BIN
bin/ml/codenoodles/lmve/other/ConsoleColor.class
Normal file
BIN
bin/ml/codenoodles/lmve/other/ConsoleColor.class
Normal file
Binary file not shown.
BIN
bin/ml/codenoodles/lmve/other/GlobalMute.class
Normal file
BIN
bin/ml/codenoodles/lmve/other/GlobalMute.class
Normal file
Binary file not shown.
BIN
bin/ml/codenoodles/lmve/other/RemoveVanillaRecipes.class
Normal file
BIN
bin/ml/codenoodles/lmve/other/RemoveVanillaRecipes.class
Normal file
Binary file not shown.
BIN
bin/ml/codenoodles/lmve/other/WelcomeBossBar$1.class
Normal file
BIN
bin/ml/codenoodles/lmve/other/WelcomeBossBar$1.class
Normal file
Binary file not shown.
BIN
bin/ml/codenoodles/lmve/other/WelcomeBossBar.class
Normal file
BIN
bin/ml/codenoodles/lmve/other/WelcomeBossBar.class
Normal file
Binary file not shown.
BIN
bin/ml/codenoodles/lmve/sounds/ChatNotification.class
Normal file
BIN
bin/ml/codenoodles/lmve/sounds/ChatNotification.class
Normal file
Binary file not shown.
98
config.yml
Normal file
98
config.yml
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
######################################
|
||||
# Little Minecraft Vanilla Extension #
|
||||
######################################
|
||||
|
||||
##########
|
||||
# VALUES #
|
||||
##########
|
||||
#Name of the Server
|
||||
server-name: "Minecraft Server"
|
||||
|
||||
|
||||
############
|
||||
# GAMEPLAY #
|
||||
############
|
||||
#Hardcore
|
||||
#Hardcore Mode in this plugins comes with double damage for players from everything
|
||||
Hardcore:
|
||||
enabled: false
|
||||
|
||||
#SleepVoteSystem
|
||||
#min-perc = minimum of all players that have to be in bed
|
||||
Sleep:
|
||||
min-perc: 20
|
||||
|
||||
#NetherPortal Stuff
|
||||
NetherPortal:
|
||||
prevent-portals-above-nehter-ceiling: true
|
||||
|
||||
#Enraged Mobs
|
||||
#Have Buffs but transform on Hit, with specific chance
|
||||
#chance range 1-100
|
||||
EnragedMobs:
|
||||
enabled: true
|
||||
chance: 2
|
||||
|
||||
#Prevent Mob Griefing
|
||||
#prevents that certain mobs cant destroy blocks by explosion etc.
|
||||
PreventMobGriefing:
|
||||
creeper: true
|
||||
wither: true
|
||||
|
||||
#Drop Player Heads
|
||||
#If a player died, there is a specific chance to get that players head
|
||||
#Chance range 1-100
|
||||
PlayerHeads:
|
||||
enabled: true
|
||||
chance: 5
|
||||
|
||||
############
|
||||
# MESSAGES #
|
||||
############
|
||||
#All Options for the Join and Quit messages
|
||||
JoinMessage:
|
||||
enabled: true
|
||||
QuitMessage:
|
||||
enabled: true
|
||||
|
||||
|
||||
###########
|
||||
# RECIPES #
|
||||
###########
|
||||
#Removes Minecraft Vanilla Recipes
|
||||
RemoveVanillaRecipes:
|
||||
magma-block: true
|
||||
|
||||
#Enable/Disable the Recipes that are Added by the Plugin
|
||||
#ice01 = with snowballs | ice02 = with snowblocks
|
||||
LMVE-Recipes:
|
||||
Crafting:
|
||||
magma-block: true
|
||||
mycelium: true
|
||||
cobweb: true
|
||||
ice01: true
|
||||
ice02: true
|
||||
strings: true
|
||||
elytra: true
|
||||
black-dye: true
|
||||
Stonecutter:
|
||||
wood-stairs: true
|
||||
wood-slabs: true
|
||||
Campfire:
|
||||
cooked-cod: true
|
||||
cooked-salmon: true
|
||||
|
||||
|
||||
##########
|
||||
# SOUNDS #
|
||||
##########
|
||||
#Default all enabled
|
||||
Sounds:
|
||||
chat: true
|
||||
|
||||
|
||||
########
|
||||
# CHAT #
|
||||
########
|
||||
Chat:
|
||||
global-mute: false
|
||||
9
plugin.yml
Normal file
9
plugin.yml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
name: LittleMinecraftVanillaExtension
|
||||
main: ml.codenoodles.lmve.Main
|
||||
api-version: 1.15
|
||||
author: netbenix
|
||||
version: Beta-1.1.0
|
||||
commands:
|
||||
lmve:
|
||||
usage: /<command>
|
||||
description: LMVE Main Command
|
||||
253
src/ml/codenoodles/lmve/Main.java
Normal file
253
src/ml/codenoodles/lmve/Main.java
Normal file
|
|
@ -0,0 +1,253 @@
|
|||
package ml.codenoodles.lmve;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import ml.codenoodles.lmve.modules.CustomRecipes;
|
||||
import ml.codenoodles.lmve.modules.EnragedMobs;
|
||||
import ml.codenoodles.lmve.modules.Hardcore;
|
||||
import ml.codenoodles.lmve.modules.Leaderboard;
|
||||
import ml.codenoodles.lmve.modules.Messages;
|
||||
import ml.codenoodles.lmve.modules.NetherPortal;
|
||||
import ml.codenoodles.lmve.modules.PlayerHeads;
|
||||
import ml.codenoodles.lmve.modules.PlayerList;
|
||||
import ml.codenoodles.lmve.modules.PlayerStatistics;
|
||||
import ml.codenoodles.lmve.modules.PreventMobGriefing;
|
||||
import ml.codenoodles.lmve.modules.SQLHandler;
|
||||
import ml.codenoodles.lmve.modules.SleepVoteSystem;
|
||||
import ml.codenoodles.lmve.modules.StatCounter;
|
||||
import ml.codenoodles.lmve.modules.UUIDReference;
|
||||
import ml.codenoodles.lmve.other.ConsoleColor;
|
||||
import ml.codenoodles.lmve.other.GlobalMute;
|
||||
import ml.codenoodles.lmve.other.RemoveVanillaRecipes;
|
||||
import ml.codenoodles.lmve.other.WelcomeBossBar;
|
||||
import ml.codenoodles.lmve.sounds.ChatNotification;
|
||||
|
||||
|
||||
|
||||
public class Main
|
||||
extends JavaPlugin
|
||||
implements Listener
|
||||
{
|
||||
FileConfiguration cfg = this.getConfig();
|
||||
NamespacedKey Nkey = new NamespacedKey(this, this.getDescription().getName());
|
||||
SQLHandler sql = new SQLHandler();
|
||||
public void onEnable() {
|
||||
this.saveDefaultConfig();
|
||||
registerEvents();
|
||||
File PlayerDB = new File(getDataFolder().getAbsoluteFile() + "/" + "Players.db");
|
||||
if(!PlayerDB.exists()) {
|
||||
sql.createDefaultDatabase(getDataFolder().getAbsolutePath());
|
||||
}
|
||||
System.out.println(ConsoleColor.BLUE + "[LMVE]Plugin Enabled!" + ConsoleColor.RESET);
|
||||
}
|
||||
|
||||
|
||||
public void onDisable() {
|
||||
System.out.println(ConsoleColor.BLUE + "[LMVE]Plugin Disabled!" + ConsoleColor.RESET);
|
||||
}
|
||||
|
||||
public void registerEvents() {
|
||||
//Modules
|
||||
this.getServer().getPluginManager().registerEvents(new CustomRecipes(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerStatistics(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new StatCounter(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new Messages(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new Hardcore(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerList(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new SleepVoteSystem(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new UUIDReference(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new EnragedMobs(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new PreventMobGriefing(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerHeads(this), this);
|
||||
//Sounds
|
||||
this.getServer().getPluginManager().registerEvents(new ChatNotification(this), this);
|
||||
//Other Stuff
|
||||
this.getServer().getPluginManager().registerEvents(new NetherPortal(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new GlobalMute(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new RemoveVanillaRecipes(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new WelcomeBossBar(this), this);
|
||||
}
|
||||
|
||||
//Getter
|
||||
public FileConfiguration getConfigFile() {
|
||||
return cfg;
|
||||
}
|
||||
|
||||
////////// RVC = RemoveVanillaRecipes
|
||||
// VARS //
|
||||
//////////
|
||||
public boolean RVC_magmablock = cfg.getBoolean("RemoveVanillaRecipes.magma-block");
|
||||
public boolean snd_chatnotify = cfg.getBoolean("Sounds.chat");
|
||||
//////////////
|
||||
// Commands //
|
||||
//////////////
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
|
||||
if(cmd.getName().equalsIgnoreCase("lmve")) {
|
||||
if(args.length == 0) {
|
||||
sender.sendMessage(ChatColor.GRAY + "================");
|
||||
sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "LMVE MAIN COMMANDS");
|
||||
sender.sendMessage(ChatColor.RED + "/lmve info" + ChatColor.WHITE + " - Shows the plugin information");
|
||||
sender.sendMessage(ChatColor.RED + "/lmve stats" + ChatColor.WHITE + " - Shows the Player Stats");
|
||||
sender.sendMessage(ChatColor.RED + "/lmve leaderboard" + ChatColor.WHITE + " - Shows the Leaderboard Infos");
|
||||
sender.sendMessage(ChatColor.RED + "/lmve settings" + ChatColor.WHITE + " - Shows the Player Settings");
|
||||
sender.sendMessage(ChatColor.RED + "/lmve version" + ChatColor.WHITE + " - Shows the plugin version");
|
||||
sender.sendMessage(ChatColor.GRAY + "================");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("info")) {
|
||||
sender.sendMessage(ChatColor.GRAY + "================");
|
||||
sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "LMVE INFO");
|
||||
sender.sendMessage(ChatColor.YELLOW + "Name: " +
|
||||
ChatColor.RED + "L" + ChatColor.WHITE + "ittle " +
|
||||
ChatColor.RED + "M" + ChatColor.WHITE + "inecraft " +
|
||||
ChatColor.RED + "V" + ChatColor.WHITE + "anilla " +
|
||||
ChatColor.RED + "E" + ChatColor.WHITE + "xtension"
|
||||
);
|
||||
sender.sendMessage(ChatColor.YELLOW + "Author: " + ChatColor.WHITE + "netbenix");
|
||||
sender.sendMessage(ChatColor.GRAY + "================");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("stats")) {
|
||||
if(args.length == 1) {
|
||||
sender.sendMessage(ChatColor.GRAY + "================");
|
||||
sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "LMVE STATS");
|
||||
sender.sendMessage(ChatColor.YELLOW + "Usage: " + ChatColor.AQUA + "/lmve stats <sub-command>");
|
||||
sender.sendMessage(ChatColor.YELLOW + "Sub-Commands:");
|
||||
sender.sendMessage(ChatColor.RED + "show" + ChatColor.WHITE + " - Shows your Stats");
|
||||
sender.sendMessage(ChatColor.RED + "show <player>" + ChatColor.WHITE + " - Shows another players Stats");
|
||||
|
||||
sender.sendMessage(ChatColor.GRAY + "================");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(args[1].equalsIgnoreCase("show")) {
|
||||
if(args.length >= 4) {
|
||||
sender.sendMessage(ChatColor.RED + "Too many Arguments.");
|
||||
return true;
|
||||
}
|
||||
if(args.length == 2) {
|
||||
if(!(sender instanceof Player)) {
|
||||
sender.sendMessage("Please use: /lmve stats show <player>");
|
||||
return true;
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
PlayerStatistics pStats = new PlayerStatistics(this);
|
||||
UUIDReference uuidRef = new UUIDReference(this);
|
||||
UUID uuid = uuidRef.getUUID(p.getName());
|
||||
pStats.outputStats(sender, uuid);
|
||||
}
|
||||
if(args.length == 3) {
|
||||
PlayerStatistics pStats = new PlayerStatistics(this);
|
||||
UUIDReference uuidRef = new UUIDReference(this);
|
||||
UUID uuid;
|
||||
if(uuidRef.getUUID(args[2]) == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Player was never on this Server!");
|
||||
return true;
|
||||
} else {
|
||||
uuid = uuidRef.getUUID(args[2]);
|
||||
}
|
||||
pStats.outputStats(sender, uuid);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("leaderboard")){
|
||||
if(args.length == 1){
|
||||
sender.sendMessage(ChatColor.GRAY + "================");
|
||||
sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "LMVE LEADERBOARD INFO");
|
||||
sender.sendMessage(ChatColor.YELLOW + "Usage : " + ChatColor.AQUA + "/lmve leaderboard <category>");
|
||||
sender.sendMessage(ChatColor.YELLOW + "Categorys: ");
|
||||
sender.sendMessage(ChatColor.RED + "time-played");
|
||||
sender.sendMessage(ChatColor.RED + "deaths");
|
||||
sender.sendMessage(ChatColor.RED + "damage-taken");
|
||||
return true;
|
||||
}
|
||||
if(args.length > 2){
|
||||
sender.sendMessage(ChatColor.RED + "Too many Arguments.");
|
||||
return true;
|
||||
}
|
||||
if(args.length == 2){
|
||||
PlayerList playerList = new PlayerList(this);
|
||||
int totalPlayers = 0;
|
||||
totalPlayers = playerList.getAmount();
|
||||
Leaderboard lb = new Leaderboard(this);
|
||||
lb.show(sender, totalPlayers, args);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if(args[0].equalsIgnoreCase("settings")) {
|
||||
if(!(sender instanceof Player)) {
|
||||
sender.sendMessage("Command is only for Players!");
|
||||
return true;
|
||||
}
|
||||
if(args.length == 1) {
|
||||
Player p = (Player) sender;
|
||||
File playerStat = new File(getDataFolder() + "/Players", p.getUniqueId() + ".yml");
|
||||
@SuppressWarnings("static-access")
|
||||
FileConfiguration player_stat = new YamlConfiguration().loadConfiguration(playerStat);
|
||||
sender.sendMessage(ChatColor.GRAY + "================");
|
||||
sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "LMVE SETTINGS");
|
||||
sender.sendMessage(ChatColor.YELLOW + "Usage: " + ChatColor.AQUA + "/lmve settings <config-string>");
|
||||
sender.sendMessage(ChatColor.YELLOW + "Your Settings: ");
|
||||
sender.sendMessage(ChatColor.RED+ "ChatNotify: " + ChatColor.WHITE + player_stat.getBoolean(p.getUniqueId() + ".Settings.Sounds.ChatNotify"));
|
||||
sender.sendMessage(ChatColor.GRAY + "================");
|
||||
return true;
|
||||
}
|
||||
if(args.length > 2) {
|
||||
sender.sendMessage(ChatColor.RED + "Too many Arguments.");
|
||||
return true;
|
||||
}
|
||||
if(args[1].equalsIgnoreCase("ChatNotify")) {
|
||||
Player p = (Player) sender;
|
||||
File PlayerStat = new File(getDataFolder() + "/Players", p.getUniqueId() + ".yml");
|
||||
@SuppressWarnings("static-access")
|
||||
FileConfiguration player_stat = new YamlConfiguration().loadConfiguration(PlayerStat);
|
||||
if(player_stat.getBoolean(p.getUniqueId() + ".Settings.Sounds.ChatNotify")) {
|
||||
player_stat.set(p.getUniqueId() + ".Settings.Sounds.ChatNotify", false);
|
||||
sender.sendMessage(ChatColor.YELLOW + "Setting now changed to: " + ChatColor.RED + "false");
|
||||
} else {
|
||||
player_stat.set(p.getUniqueId() + ".Settings.Sounds.ChatNotify", true);
|
||||
sender.sendMessage(ChatColor.YELLOW + "Setting now changed to: " + ChatColor.RED + "true");
|
||||
}
|
||||
try {
|
||||
player_stat.save(PlayerStat);
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("version")) {
|
||||
sender.sendMessage(ChatColor.GRAY + "Current " + ChatColor.GOLD + "" + ChatColor.BOLD + "LMVE" + ChatColor.GRAY + " version running: " + ChatColor.RED + this.getDescription().getVersion());
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
247
src/ml/codenoodles/lmve/modules/CustomRecipes.java
Normal file
247
src/ml/codenoodles/lmve/modules/CustomRecipes.java
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
package ml.codenoodles.lmve.modules;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.ServerLoadEvent;
|
||||
import org.bukkit.inventory.CampfireRecipe;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.inventory.ShapelessRecipe;
|
||||
import org.bukkit.inventory.StonecuttingRecipe;
|
||||
import org.bukkit.inventory.RecipeChoice.MaterialChoice;
|
||||
|
||||
import ml.codenoodles.lmve.Main;
|
||||
import ml.codenoodles.lmve.other.ConsoleColor;
|
||||
|
||||
public class CustomRecipes implements Listener{
|
||||
|
||||
|
||||
private Main main;
|
||||
public CustomRecipes(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
MaterialChoice wool = new MaterialChoice(Material.BLACK_WOOL, Material.BLUE_WOOL, Material.BROWN_WOOL, Material.CYAN_WOOL, Material.GRAY_WOOL, Material.GREEN_WOOL, Material.LIGHT_BLUE_WOOL,
|
||||
Material.LIGHT_GRAY_WOOL, Material.LIME_WOOL, Material.MAGENTA_WOOL, Material.ORANGE_WOOL, Material.PINK_WOOL, Material.PURPLE_WOOL, Material.RED_WOOL, Material.WHITE_WOOL, Material.YELLOW_WOOL);
|
||||
|
||||
private CampfireRecipe getCampfireRecipe(String name) {
|
||||
switch(name){
|
||||
case "COOKED_COD":{
|
||||
CampfireRecipe cookedCod = new CampfireRecipe(new NamespacedKey(main, "cfcod"), new ItemStack(Material.COOKED_COD, 1), Material.COD, 0, 400);
|
||||
return cookedCod;
|
||||
}
|
||||
case "COOKED_SALMON":{
|
||||
CampfireRecipe cookedSalmon = new CampfireRecipe(new NamespacedKey(main, "cfsalmon"), new ItemStack(Material.COOKED_SALMON, 1), Material.SALMON, 0, 400);
|
||||
return cookedSalmon;
|
||||
}
|
||||
default: {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ShapelessRecipe getShapelessRecipe(String name) {
|
||||
switch(name) {
|
||||
case "BLACK_DYE":{
|
||||
ShapelessRecipe blackinkRecipe = new ShapelessRecipe(new NamespacedKey(main, "blackink"), new ItemStack(Material.BLACK_DYE, 1))
|
||||
.addIngredient(Material.COAL);
|
||||
return blackinkRecipe;
|
||||
}
|
||||
case "STRINGS":{
|
||||
ShapelessRecipe stringsRecipe = new ShapelessRecipe(new NamespacedKey(main, "strings"), new ItemStack(Material.STRING, 4))
|
||||
.addIngredient(wool);
|
||||
return stringsRecipe;
|
||||
}
|
||||
default:{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ShapedRecipe getShapedRecipe(String name) {
|
||||
switch(name) {
|
||||
case "COBWEB":{
|
||||
ShapedRecipe cobwebRecipe = new ShapedRecipe(new NamespacedKey(main, "cobweb"), new ItemStack(Material.COBWEB, 4))
|
||||
.shape("s s", " s ", "s s")
|
||||
.setIngredient('s', Material.STRING);
|
||||
return cobwebRecipe;
|
||||
}
|
||||
case "ELYTRA":{
|
||||
ShapedRecipe elytraRecipe = new ShapedRecipe(new NamespacedKey(main, "elytra"), new ItemStack(Material.ELYTRA, 1))
|
||||
.shape("pnp", "psp", "p p")
|
||||
.setIngredient('p', Material.PHANTOM_MEMBRANE)
|
||||
.setIngredient('s', Material.STICK)
|
||||
.setIngredient('n', Material.NETHER_STAR);
|
||||
return elytraRecipe;
|
||||
}
|
||||
case "ICE01":{
|
||||
ShapedRecipe iceRecipe01 = new ShapedRecipe(new NamespacedKey(main, "ice01"), new ItemStack(Material.ICE, 4))
|
||||
.shape("sss", "sws", "sss")
|
||||
.setIngredient('s', Material.SNOWBALL)
|
||||
.setIngredient('w', Material.WATER_BUCKET);
|
||||
return iceRecipe01;
|
||||
}
|
||||
case "ICE02":{
|
||||
ShapedRecipe iceRecipe02 = new ShapedRecipe(new NamespacedKey(main, "ice02"), new ItemStack(Material.ICE, 4))
|
||||
.shape(" ", "sws", " ")
|
||||
.setIngredient('s', Material.SNOW_BLOCK)
|
||||
.setIngredient('w', Material.WATER_BUCKET);
|
||||
|
||||
return iceRecipe02;
|
||||
}
|
||||
case "MAGMA_BLOCK":{
|
||||
ShapedRecipe magmablockRecipe = new ShapedRecipe(new NamespacedKey(main, "magmablock"), new ItemStack(Material.MAGMA_BLOCK, 1))
|
||||
.shape(" m ", " c ", " l ")
|
||||
.setIngredient('m', Material.MAGMA_CREAM)
|
||||
.setIngredient('c', Material.COBBLESTONE)
|
||||
.setIngredient('l', Material.LAVA_BUCKET);
|
||||
return magmablockRecipe;
|
||||
}
|
||||
case "MYCELIUM":{
|
||||
ShapedRecipe myceliumRecipe = new ShapedRecipe(new NamespacedKey(main, "mycelium"), new ItemStack(Material.MYCELIUM, 1))
|
||||
.shape("brb", "rdr", "brb")
|
||||
.setIngredient('b', Material.BROWN_MUSHROOM)
|
||||
.setIngredient('r', Material.RED_MUSHROOM)
|
||||
.setIngredient('d', Material.DIRT);
|
||||
return myceliumRecipe;
|
||||
}
|
||||
default:{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private StonecuttingRecipe getStonecuttingRecipe(Material mat) {
|
||||
switch(mat) {
|
||||
case OAK_SLAB: {
|
||||
StonecuttingRecipe oakWoodSlabs = new StonecuttingRecipe(new NamespacedKey(main, "scoakwoodslabs"), new ItemStack(Material.OAK_SLAB, 2), Material.OAK_PLANKS);
|
||||
return oakWoodSlabs;
|
||||
}
|
||||
case BIRCH_SLAB:{
|
||||
StonecuttingRecipe birchWoodSlabs = new StonecuttingRecipe(new NamespacedKey(main, "scbirchwoodslabs"), new ItemStack(Material.BIRCH_SLAB, 2), Material.BIRCH_PLANKS);
|
||||
return birchWoodSlabs;
|
||||
}
|
||||
case JUNGLE_SLAB:{
|
||||
StonecuttingRecipe jungleWoodSlabs = new StonecuttingRecipe(new NamespacedKey(main, "scjunglewoodslabs"), new ItemStack(Material.JUNGLE_SLAB, 2), Material.JUNGLE_PLANKS);
|
||||
return jungleWoodSlabs;
|
||||
}
|
||||
case SPRUCE_SLAB:{
|
||||
StonecuttingRecipe spruceWoodSlabs = new StonecuttingRecipe(new NamespacedKey(main, "scsprucewoodslabs"), new ItemStack(Material.SPRUCE_SLAB, 2), Material.SPRUCE_PLANKS);
|
||||
return spruceWoodSlabs;
|
||||
}
|
||||
case DARK_OAK_SLAB:{
|
||||
StonecuttingRecipe darkoakWoodSlabs = new StonecuttingRecipe(new NamespacedKey(main, "scdarkoakwoodslabs"), new ItemStack(Material.DARK_OAK_SLAB, 2), Material.DARK_OAK_PLANKS);
|
||||
return darkoakWoodSlabs;
|
||||
}
|
||||
case ACACIA_SLAB:{
|
||||
StonecuttingRecipe acaciaWoodSlabs = new StonecuttingRecipe(new NamespacedKey(main, "scacaciawoodslabs"), new ItemStack(Material.ACACIA_SLAB, 2), Material.ACACIA_PLANKS);
|
||||
return acaciaWoodSlabs;
|
||||
}
|
||||
case OAK_STAIRS:{
|
||||
StonecuttingRecipe oakWoodStairs = new StonecuttingRecipe(new NamespacedKey(main, "scoakwoodstairs"), new ItemStack(Material.OAK_STAIRS), Material.OAK_PLANKS);
|
||||
return oakWoodStairs;
|
||||
}
|
||||
case BIRCH_STAIRS:{
|
||||
StonecuttingRecipe birchWoodStairs = new StonecuttingRecipe(new NamespacedKey(main, "scbirchwoodstairs"), new ItemStack(Material.BIRCH_STAIRS), Material.BIRCH_PLANKS);
|
||||
return birchWoodStairs;
|
||||
}
|
||||
case JUNGLE_STAIRS:{
|
||||
StonecuttingRecipe jungleWoodStairs = new StonecuttingRecipe(new NamespacedKey(main, "scjunglewoodstairs"), new ItemStack(Material.JUNGLE_STAIRS), Material.JUNGLE_PLANKS);
|
||||
return jungleWoodStairs;
|
||||
}
|
||||
case SPRUCE_STAIRS:{
|
||||
StonecuttingRecipe spruceWoodStairs = new StonecuttingRecipe(new NamespacedKey(main, "scsprucewoodstairs"), new ItemStack(Material.SPRUCE_STAIRS), Material.SPRUCE_PLANKS);
|
||||
return spruceWoodStairs;
|
||||
}
|
||||
case DARK_OAK_STAIRS:{
|
||||
StonecuttingRecipe darkoakWoodStairs = new StonecuttingRecipe(new NamespacedKey(main, "scdarkoakwoodstairs"), new ItemStack(Material.DARK_OAK_STAIRS), Material.DARK_OAK_PLANKS);
|
||||
return darkoakWoodStairs;
|
||||
}
|
||||
case ACACIA_STAIRS:{
|
||||
StonecuttingRecipe acaciaWoodStairs = new StonecuttingRecipe(new NamespacedKey(main, "scacaciawoodstairs"), new ItemStack(Material.ACACIA_STAIRS), Material.ACACIA_PLANKS);
|
||||
return acaciaWoodStairs;
|
||||
}
|
||||
default:{ return null; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@EventHandler
|
||||
private void RegisterCampfireRecipes(ServerLoadEvent e) {
|
||||
if(main.getConfigFile().getBoolean("LMVE-Recipes.Campfire.cooked-cod")){
|
||||
Bukkit.addRecipe(getCampfireRecipe("COOKED_COD"));
|
||||
System.out.println(ConsoleColor.BLUE + "[LMVE]Loaded " + ConsoleColor.YELLOW + "COOKED_COD" + ConsoleColor.BLUE + " CampfireRecipe." + ConsoleColor.RESET);
|
||||
}
|
||||
if(main.getConfigFile().getBoolean("LMVE-Recipes.Campfire.cooked-salmon")){
|
||||
Bukkit.addRecipe(getCampfireRecipe("COOKED_SALMON"));
|
||||
System.out.println(ConsoleColor.BLUE + "[LMVE]Loaded " + ConsoleColor.YELLOW + "COOKED_SALMON" + ConsoleColor.BLUE + " CampfireRecipe." + ConsoleColor.RESET);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void RegisterShapelessRecipes(ServerLoadEvent e) {
|
||||
if(main.getConfigFile().getBoolean("LMVE-Recipes.Crafting.black-dye")) {
|
||||
Bukkit.addRecipe(getShapelessRecipe("BLACK_DYE"));
|
||||
System.out.println(ConsoleColor.BLUE + "[LMVE]Loaded " + ConsoleColor.YELLOW + "BLACK_DYE" + ConsoleColor.BLUE + " Recipe." + ConsoleColor.RESET);
|
||||
}
|
||||
if(main.getConfigFile().getBoolean("LMVE-Recipes.Crafting.strings")) {
|
||||
Bukkit.addRecipe(getShapelessRecipe("STRINGS"));
|
||||
System.out.println(ConsoleColor.BLUE + "[LMVE]Loaded " + ConsoleColor.YELLOW + "STRINGS" + ConsoleColor.BLUE + " Recipe." + ConsoleColor.RESET);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void RegisterShapedRecipes(ServerLoadEvent e) {
|
||||
if(main.getConfigFile().getBoolean("LMVE-Recipes.Crafting.cobweb")) {
|
||||
Bukkit.addRecipe(getShapedRecipe("COBWEB"));
|
||||
System.out.println(ConsoleColor.BLUE + "[LMVE]Loaded " + ConsoleColor.YELLOW + "COBWEB" + ConsoleColor.BLUE + " Recipe." + ConsoleColor.RESET);
|
||||
}
|
||||
if(main.getConfigFile().getBoolean("LMVE-Recipes.Crafting.elytra")) {
|
||||
Bukkit.addRecipe(getShapedRecipe("ELYTRA"));
|
||||
System.out.println(ConsoleColor.BLUE + "[LMVE]Loaded " + ConsoleColor.YELLOW + "ELYTRA" + ConsoleColor.BLUE + " Recipe." + ConsoleColor.RESET);
|
||||
}
|
||||
if(main.getConfigFile().getBoolean("LMVE-Recipes.Crafting.ice01")) {
|
||||
Bukkit.addRecipe(getShapedRecipe("ICE01"));
|
||||
System.out.println(ConsoleColor.BLUE + "[LMVE]Loaded " + ConsoleColor.YELLOW + "ICE01" + ConsoleColor.BLUE + " Recipe." + ConsoleColor.RESET);
|
||||
}
|
||||
if(main.getConfigFile().getBoolean("LMVE-Recipes.Crafting.ice02")) {
|
||||
Bukkit.addRecipe(getShapedRecipe("ICE02"));
|
||||
System.out.println(ConsoleColor.BLUE + "[LMVE]Loaded " + ConsoleColor.YELLOW + "ICE02" + ConsoleColor.BLUE + " Recipe." + ConsoleColor.RESET);
|
||||
}
|
||||
if(main.getConfigFile().getBoolean("LMVE-Recipes.Crafting.magma-block")) {
|
||||
Bukkit.addRecipe(getShapedRecipe("MAGMA_BLOCK"));
|
||||
System.out.println(ConsoleColor.BLUE + "[LMVE]Loaded " + ConsoleColor.YELLOW + "MAGMA_BLOCK" + ConsoleColor.BLUE + " Recipe." + ConsoleColor.RESET);
|
||||
}
|
||||
if(main.getConfigFile().getBoolean("LMVE-Recipes.Crafting.mycelium")) {
|
||||
Bukkit.addRecipe(getShapedRecipe("MYCELIUM"));
|
||||
System.out.println(ConsoleColor.BLUE + "[LMVE]Loaded " + ConsoleColor.YELLOW + "MYCELIUM" + ConsoleColor.BLUE + " Recipe." + ConsoleColor.RESET);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void RegisterStonecuttingRecipe(ServerLoadEvent e) {
|
||||
if(main.getConfigFile().getBoolean("LMVE-Recipes.Stonecutter.wood-slabs")) {
|
||||
Bukkit.addRecipe(getStonecuttingRecipe(Material.OAK_SLAB));
|
||||
Bukkit.addRecipe(getStonecuttingRecipe(Material.BIRCH_SLAB));
|
||||
Bukkit.addRecipe(getStonecuttingRecipe(Material.JUNGLE_SLAB));
|
||||
Bukkit.addRecipe(getStonecuttingRecipe(Material.SPRUCE_SLAB));
|
||||
Bukkit.addRecipe(getStonecuttingRecipe(Material.DARK_OAK_SLAB));
|
||||
Bukkit.addRecipe(getStonecuttingRecipe(Material.ACACIA_SLAB));
|
||||
System.out.println(ConsoleColor.BLUE + "[LMVE]Loaded " + ConsoleColor.YELLOW + "WOOD_SLAB" + ConsoleColor.BLUE + " StonecuttingRecipe." + ConsoleColor.RESET);
|
||||
}
|
||||
if(main.getConfigFile().getBoolean("LMVE-Recipes.Stonecutter.wood-stairs")) {
|
||||
Bukkit.addRecipe(getStonecuttingRecipe(Material.OAK_STAIRS));
|
||||
Bukkit.addRecipe(getStonecuttingRecipe(Material.BIRCH_STAIRS));
|
||||
Bukkit.addRecipe(getStonecuttingRecipe(Material.JUNGLE_STAIRS));
|
||||
Bukkit.addRecipe(getStonecuttingRecipe(Material.SPRUCE_STAIRS));
|
||||
Bukkit.addRecipe(getStonecuttingRecipe(Material.DARK_OAK_STAIRS));
|
||||
Bukkit.addRecipe(getStonecuttingRecipe(Material.ACACIA_STAIRS));
|
||||
System.out.println(ConsoleColor.BLUE + "[LMVE]Loaded " + ConsoleColor.YELLOW + "WOOD_STAIRS" + ConsoleColor.BLUE + " StonecuttingRecipe." + ConsoleColor.RESET);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
139
src/ml/codenoodles/lmve/modules/EnragedMobs.java
Normal file
139
src/ml/codenoodles/lmve/modules/EnragedMobs.java
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
package ml.codenoodles.lmve.modules;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.PigZombie;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import ml.codenoodles.lmve.Main;
|
||||
|
||||
|
||||
public class EnragedMobs implements Listener{
|
||||
|
||||
private Main main;
|
||||
public EnragedMobs(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
private boolean checkIfTrigger() {
|
||||
int chance = main.getConfig().getInt("EnragedMobs.chance");;
|
||||
boolean trigger = false;
|
||||
Random rand = new Random();
|
||||
int n = rand.nextInt(100);
|
||||
n += 1;
|
||||
if(n < chance) {
|
||||
trigger = true;
|
||||
} else {
|
||||
trigger = false;
|
||||
}
|
||||
return trigger;
|
||||
}
|
||||
|
||||
private boolean checkCustomName(String name) {
|
||||
if(name == null) {
|
||||
return false;
|
||||
}
|
||||
if(name.startsWith("Enraged")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void ChangeExpDrop(EntityDeathEvent e) {
|
||||
if(!main.getConfig().getBoolean("EnragedMobs.enabled")) {
|
||||
return;
|
||||
}
|
||||
if(e.getEntity().getCustomName() == null) { return; }
|
||||
if(e.getEntity().getCustomName().startsWith("Enraged")) {
|
||||
e.setDroppedExp(e.getDroppedExp() * 2);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void TransformToEnraged(EntityDamageByEntityEvent e) {
|
||||
if(!main.getConfig().getBoolean("EnragedMobs.enabled")) {
|
||||
return;
|
||||
}
|
||||
if(e.getDamager().getType() != EntityType.PLAYER) {
|
||||
return;
|
||||
}
|
||||
ArrayList<Material> triggerItems = new ArrayList<Material>();
|
||||
triggerItems.add(Material.IRON_SWORD);
|
||||
triggerItems.add(Material.IRON_AXE);
|
||||
triggerItems.add(Material.DIAMOND_SWORD);
|
||||
triggerItems.add(Material.DIAMOND_AXE);
|
||||
boolean correctItem = false;
|
||||
for(int i = 0; i < triggerItems.size(); i++) {
|
||||
Player p = (Player) e.getDamager();
|
||||
if(p.getInventory().getItemInMainHand().getType() == triggerItems.get(i)) {
|
||||
correctItem = true;
|
||||
}
|
||||
}
|
||||
if(!correctItem) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean causeTrigger = false;
|
||||
switch(e.getCause()) {
|
||||
case ENTITY_ATTACK: { causeTrigger = true; break;}
|
||||
case ENTITY_SWEEP_ATTACK: { causeTrigger = true; break;}
|
||||
case PROJECTILE: { causeTrigger = true; break;}
|
||||
case THORNS: { causeTrigger = true; break;}
|
||||
default:{ causeTrigger = false; break;}
|
||||
}
|
||||
if(causeTrigger) {
|
||||
switch(e.getEntity().getType()) {
|
||||
case ZOMBIE:{
|
||||
Zombie zombie = (Zombie) e.getEntity();
|
||||
boolean trigger = checkIfTrigger();
|
||||
if(trigger) {
|
||||
if(!checkCustomName(zombie.getCustomName())) {
|
||||
World world = zombie.getWorld();
|
||||
world.strikeLightningEffect(zombie.getLocation());
|
||||
zombie.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 9999, 3));
|
||||
zombie.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 9999, 1));
|
||||
zombie.addPotionEffect(new PotionEffect(PotionEffectType.HARM, 60, 1));
|
||||
zombie.setHealth(zombie.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
||||
zombie.setCustomName("Enraged Zombie");
|
||||
zombie.setCustomNameVisible(true);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
case PIG_ZOMBIE:{
|
||||
PigZombie pigzombie = (PigZombie) e.getEntity();
|
||||
boolean trigger = checkIfTrigger();
|
||||
if(trigger) {
|
||||
if(!checkCustomName(pigzombie.getCustomName())) {
|
||||
World world = pigzombie.getWorld();
|
||||
world.strikeLightningEffect(pigzombie.getLocation());
|
||||
pigzombie.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 9999, 3));
|
||||
pigzombie.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 9999, 1));
|
||||
pigzombie.addPotionEffect(new PotionEffect(PotionEffectType.HARM, 60, 1));
|
||||
pigzombie.setHealth(pigzombie.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
||||
pigzombie.setCustomName("Enraged Zombie Pigman");
|
||||
pigzombie.setCustomNameVisible(true);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
default:{ }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
65
src/ml/codenoodles/lmve/modules/Hardcore.java
Normal file
65
src/ml/codenoodles/lmve/modules/Hardcore.java
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
package ml.codenoodles.lmve.modules;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.server.ServerLoadEvent;
|
||||
|
||||
import ml.codenoodles.lmve.Main;
|
||||
|
||||
public class Hardcore implements Listener{
|
||||
|
||||
private Main main;
|
||||
|
||||
public Hardcore(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void DisableMessage(ServerLoadEvent e) {
|
||||
if(!main.getConfigFile().getBoolean("Hardcore.enabled")) {
|
||||
for(Player players : Bukkit.getOnlinePlayers()){
|
||||
players.playSound(players.getLocation(), Sound.ENTITY_VILLAGER_CELEBRATE, 10, 0.8f);
|
||||
players.sendMessage(ChatColor.YELLOW + "ATTENTION! Hardcore Mode: Disabled.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void onPlayerDamage(EntityDamageEvent e) {
|
||||
if(main.getConfigFile().getBoolean("Hardcore.enabled")) {
|
||||
Entity entity = e.getEntity();
|
||||
if (entity instanceof Player) {
|
||||
e.setDamage(e.getDamage() * 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void WarnMessageOnJoin(PlayerJoinEvent e) {
|
||||
if(main.getConfigFile().getBoolean("Hardcore.enabled")) {
|
||||
e.getPlayer().playSound(e.getPlayer().getLocation(), Sound.ENTITY_PHANTOM_AMBIENT, 10, 0);
|
||||
e.getPlayer().sendMessage(ChatColor.RED + "WARNING! HARCORE IS ENABLED!");
|
||||
e.getPlayer().sendMessage(ChatColor.RED + "The damage you get is doubled!");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void EnableMessage(ServerLoadEvent e) {
|
||||
if(main.getConfigFile().getBoolean("Hardcore.enabled")) {
|
||||
System.out.println("[VMVE]HARDCORE MODE ACTIVATED.");
|
||||
for(Player players : Bukkit.getOnlinePlayers()){
|
||||
players.playSound(players.getLocation(), Sound.ENTITY_PHANTOM_AMBIENT, 10, 0);
|
||||
players.sendMessage(ChatColor.RED + "WARNING! HARCORE IS ENABLED!");
|
||||
players.sendMessage(ChatColor.RED + "The damage you get is doubled!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
133
src/ml/codenoodles/lmve/modules/Leaderboard.java
Normal file
133
src/ml/codenoodles/lmve/modules/Leaderboard.java
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
package ml.codenoodles.lmve.modules;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import ml.codenoodles.lmve.Main;
|
||||
import ml.codenoodles.lmve.other.ConsoleColor;
|
||||
|
||||
public class Leaderboard {
|
||||
|
||||
private Main main;
|
||||
public Leaderboard(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
|
||||
public void show(CommandSender sender, int totalPlayers, String[] args) {
|
||||
|
||||
Connection conn;
|
||||
int playerAmount = totalPlayers;
|
||||
int unknown = 0;
|
||||
String player[] = new String[playerAmount];
|
||||
UUID uuid[] = new UUID[playerAmount];
|
||||
String path = "jdbc:sqlite:" + main.getDataFolder().getAbsolutePath() + "/" + "Players.db";
|
||||
try {//Try Connection
|
||||
conn = DriverManager.getConnection(path);
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println(ConsoleColor.RED + "[LMVE]" + sqlEx.getMessage() + ConsoleColor.RESET);
|
||||
return;
|
||||
}
|
||||
for(int i = 1; i <= totalPlayers; i++) {
|
||||
try { //Get Players
|
||||
String query = "SELECT Name AS playerName, UUID AS uuid FROM tblPlayers WHERE ID = ?";
|
||||
PreparedStatement pst = conn.prepareStatement(query);
|
||||
pst.setLong(1, i);
|
||||
ResultSet rs = pst.executeQuery();
|
||||
rs.next();
|
||||
player[i-1] = rs.getString("playerName");
|
||||
uuid[i-1] = UUID.fromString(rs.getString("uuid"));
|
||||
rs.close();
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println(ConsoleColor.RED + "[LMVE]" + sqlEx.getMessage() + ConsoleColor.RESET);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
float value[] = new float[playerAmount];
|
||||
sender.sendMessage(ChatColor.GRAY + "=====[ LEADERBOARD ]=====");
|
||||
switch(args[1]){
|
||||
case "time-played":{
|
||||
sender.sendMessage(ChatColor.GRAY + "Category: " + ChatColor.AQUA + "Time Played" + ChatColor.GRAY + "(in hours)");
|
||||
for(int i = 1; i < playerAmount; i++) {
|
||||
File playerFile = new File(main.getDataFolder() + "/Players", uuid[i] + ".yml");
|
||||
FileConfiguration playerStat = YamlConfiguration.loadConfiguration(playerFile);
|
||||
value[i] = playerStat.getInt(uuid[i] + ".TimePlayed");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "deaths":{
|
||||
sender.sendMessage(ChatColor.GRAY + "Category: " + ChatColor.AQUA + "Deaths");
|
||||
for(int i = 1; i <= playerAmount; i++) {
|
||||
try {
|
||||
String query = "SELECT Deaths AS count FROM tblPlayerStats WHERE UUID = ?;";
|
||||
PreparedStatement pst = conn.prepareStatement(query);
|
||||
pst.setString(1, uuid[i-1].toString());
|
||||
ResultSet rs = pst.executeQuery();
|
||||
rs.next();
|
||||
value[i-1] = rs.getLong("count");
|
||||
rs.close();
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println(ConsoleColor.RED + "[LMVE]" + sqlEx.getMessage() + ConsoleColor.RESET);
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "damage-taken":{
|
||||
sender.sendMessage(ChatColor.GRAY + "Category: " + ChatColor.AQUA + "Damage Taken");
|
||||
for(int i = 1; i <= playerAmount; i++) {
|
||||
try {
|
||||
String query = "SELECT DamageTaken AS count FROM tblPlayerStats WHERE UUID = ?;";
|
||||
PreparedStatement pst = conn.prepareStatement(query);
|
||||
pst.setString(1, uuid[i-1].toString());
|
||||
ResultSet rs = pst.executeQuery();
|
||||
rs.next();
|
||||
value[i-1] = rs.getLong("count");
|
||||
rs.close();
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println(ConsoleColor.RED + "[LMVE]" + sqlEx.getMessage() + ConsoleColor.RESET);
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:{
|
||||
sender.sendMessage(ChatColor.RED + "Category unknown.");
|
||||
unknown = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
String temp_str;
|
||||
float temp = 0;
|
||||
if(unknown == 0) {
|
||||
for(int i=0; i < playerAmount; i++){
|
||||
for(int j=1; j < (playerAmount-i); j++){
|
||||
if(value[j-1] < value[j]){
|
||||
temp = value[j-1];
|
||||
temp_str = player[j-1];
|
||||
value[j-1] = value[j];
|
||||
player[j-1] = player[j];
|
||||
value[j] = temp;
|
||||
player[j] = temp_str;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int i = 0; i < playerAmount; i++) {
|
||||
sender.sendMessage(ChatColor.YELLOW + player[i] + ChatColor.WHITE + " - " + ChatColor.RED + value[i]);
|
||||
}
|
||||
}
|
||||
sender.sendMessage(ChatColor.GRAY + "================");
|
||||
|
||||
}
|
||||
}
|
||||
31
src/ml/codenoodles/lmve/modules/Messages.java
Normal file
31
src/ml/codenoodles/lmve/modules/Messages.java
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package ml.codenoodles.lmve.modules;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import ml.codenoodles.lmve.Main;
|
||||
|
||||
public class Messages implements Listener{
|
||||
|
||||
private Main main;
|
||||
public Messages(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void JoinMessage(PlayerJoinEvent e) {
|
||||
if(main.getConfigFile().getBoolean("JoinMessage.enabled") == true) {
|
||||
e.setJoinMessage(ChatColor.GREEN + "[+]" + ChatColor.GRAY + e.getPlayer().getDisplayName() + " joined the Server!");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void QuitMessage(PlayerQuitEvent e) {
|
||||
if(main.getConfigFile().getBoolean("QuitMessage.enabled")) {
|
||||
e.setQuitMessage(ChatColor.RED + "[-]" + ChatColor.GRAY + e.getPlayer().getDisplayName() + " left the Server!");
|
||||
}
|
||||
}
|
||||
}
|
||||
49
src/ml/codenoodles/lmve/modules/NetherPortal.java
Normal file
49
src/ml/codenoodles/lmve/modules/NetherPortal.java
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
package ml.codenoodles.lmve.modules;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.PortalCreateEvent;
|
||||
|
||||
import ml.codenoodles.lmve.Main;
|
||||
|
||||
public class NetherPortal implements Listener{
|
||||
|
||||
private Main main;
|
||||
public NetherPortal(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void PreventPortalActivate(PortalCreateEvent e) {
|
||||
if(main.getConfig().getBoolean("NetherPortal.prevent-portals-above-nehter-ceiling") == true) {
|
||||
if(e.getWorld().getEnvironment() == Environment.NETHER) {
|
||||
List<BlockState> block = e.getBlocks();
|
||||
World world = e.getWorld();
|
||||
Location loc = null;
|
||||
for(int i = 0; i < block.size(); i++) {
|
||||
BlockState state = block.get(i);
|
||||
loc = state.getLocation();
|
||||
if(state.getLocation().getBlockY() >= 128) {
|
||||
Block blockk = state.getBlock();
|
||||
blockk.setType(Material.AIR);
|
||||
world.spawnParticle(Particle.EXPLOSION_NORMAL, loc.getX(), loc.getY(), loc.getZ(), 10);
|
||||
}
|
||||
}
|
||||
if(loc.getY() > 127) {
|
||||
world.playSound(loc, Sound.ENTITY_GENERIC_EXPLODE, 100, 1);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
57
src/ml/codenoodles/lmve/modules/PlayerHeads.java
Normal file
57
src/ml/codenoodles/lmve/modules/PlayerHeads.java
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
package ml.codenoodles.lmve.modules;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import ml.codenoodles.lmve.Main;
|
||||
|
||||
public class PlayerHeads implements Listener{
|
||||
|
||||
private Main main;
|
||||
public PlayerHeads(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
private boolean checkIfTrigger() {
|
||||
int chance = main.getConfig().getInt("PlayerHeads.chance");;
|
||||
boolean trigger = false;
|
||||
Random rand = new Random();
|
||||
int n = rand.nextInt(100);
|
||||
n += 1;
|
||||
if(n < chance) {
|
||||
trigger = true;
|
||||
} else {
|
||||
trigger = false;
|
||||
}
|
||||
return trigger;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void PlayerHeadDrop(PlayerDeathEvent e) {
|
||||
if(!main.getConfig().getBoolean("PlayerHeads.enabled")) {
|
||||
return;
|
||||
}
|
||||
boolean trigger = checkIfTrigger();
|
||||
if(trigger) {
|
||||
OfflinePlayer p = e.getEntity();
|
||||
ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1);
|
||||
SkullMeta skullMeta = (SkullMeta) head.getItemMeta();
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
lore.add("Head of " + p.getName());
|
||||
skullMeta.setLore(lore);
|
||||
skullMeta.setOwningPlayer(p);
|
||||
head.setItemMeta(skullMeta);
|
||||
e.getEntity().getWorld().dropItem(e.getEntity().getLocation(), head);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
46
src/ml/codenoodles/lmve/modules/PlayerList.java
Normal file
46
src/ml/codenoodles/lmve/modules/PlayerList.java
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
package ml.codenoodles.lmve.modules;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import ml.codenoodles.lmve.Main;
|
||||
|
||||
public class PlayerList implements Listener{
|
||||
|
||||
private Main main;
|
||||
public PlayerList(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
int totalPlayers;
|
||||
Connection conn;
|
||||
String path = "jdbc:sqlite:" + main.getDataFolder().getAbsolutePath() + "\\" + "Players.db";
|
||||
try { //Try Connection
|
||||
conn = DriverManager.getConnection(path);
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println("[LMVE]" + sqlEx.getMessage());
|
||||
return 0;
|
||||
}
|
||||
|
||||
try { //Count Players
|
||||
String query = "SELECT COUNT(Name) AS totalPlayers FROM tblPlayers;";
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(query);
|
||||
rs.next();
|
||||
totalPlayers = rs.getInt("totalPlayers");
|
||||
rs.close();
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println("[LMVE]" + sqlEx.getMessage());
|
||||
return 0;
|
||||
}
|
||||
|
||||
return totalPlayers;
|
||||
}
|
||||
|
||||
}
|
||||
247
src/ml/codenoodles/lmve/modules/PlayerStatistics.java
Normal file
247
src/ml/codenoodles/lmve/modules/PlayerStatistics.java
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
package ml.codenoodles.lmve.modules;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import ml.codenoodles.lmve.Main;
|
||||
import ml.codenoodles.lmve.other.ConsoleColor;
|
||||
|
||||
public class PlayerStatistics implements Listener{
|
||||
|
||||
private Main main;
|
||||
public PlayerStatistics(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void UpdateLastJoined(PlayerJoinEvent e) {
|
||||
UUID player_uuid = e.getPlayer().getUniqueId();
|
||||
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm:ss");
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
File playerStats = new File(main.getDataFolder() + "/Players", player_uuid + ".yml");
|
||||
FileConfiguration player_stat = YamlConfiguration.loadConfiguration(playerStats);
|
||||
player_stat.set(player_uuid + ".LastJoined", dtf.format(now));
|
||||
try {
|
||||
player_stat.save(playerStats);
|
||||
} catch (IOException ex) {
|
||||
// TODO Auto-generated catch block
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void SaveOnQuit(PlayerQuitEvent e) {
|
||||
Player p = (Player) e.getPlayer();
|
||||
UUID uuid = p.getUniqueId();
|
||||
|
||||
File playerStats = new File(main.getDataFolder() + "/Players", uuid + ".yml");
|
||||
FileConfiguration player_stat = YamlConfiguration.loadConfiguration(playerStats);
|
||||
player_stat.set(uuid + ".General.DisplayName", p.getName());
|
||||
player_stat.set(uuid + ".General.Health", p.getHealth());
|
||||
player_stat.set(uuid + ".General.World", p.getWorld().getName());
|
||||
player_stat.set(uuid + ".General.Location.X", p.getLocation().getX());
|
||||
player_stat.set(uuid + ".General.Location.Y", p.getLocation().getY());
|
||||
player_stat.set(uuid + ".General.Location.Z", p.getLocation().getZ());
|
||||
float pTime = p.getStatistic(Statistic.PLAY_ONE_MINUTE);
|
||||
pTime = pTime / 20;
|
||||
pTime = pTime / 60;
|
||||
pTime = pTime / 60;
|
||||
player_stat.set(uuid + ".TimePlayed", pTime);
|
||||
try {
|
||||
player_stat.save(playerStats);
|
||||
} catch (IOException ex) {
|
||||
// TODO Auto-generated catch block
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
private void checkName(PlayerJoinEvent e) throws IOException {
|
||||
UUID uuid = e.getPlayer().getUniqueId();
|
||||
File pStatFile = new File(main.getDataFolder() + "/Players", uuid + ".yml");
|
||||
FileConfiguration pStat = YamlConfiguration.loadConfiguration(pStatFile);
|
||||
if(pStat.getString(uuid + ".DisplayName") != e.getPlayer().getName()) {
|
||||
String oldName = pStat.getString(uuid + ".DisplayName");
|
||||
String newName = e.getPlayer().getName();
|
||||
pStat.set(uuid + ".DisplayName", newName);
|
||||
|
||||
File uRefFile = new File(main.getDataFolder(), "uuid_reference.yml");
|
||||
FileConfiguration uRef = YamlConfiguration.loadConfiguration(uRefFile);
|
||||
uRef.set(oldName, null);
|
||||
uRef.set(newName, uuid.toString());
|
||||
try {
|
||||
pStat.save(pStatFile);
|
||||
uRef.save(uRefFile);
|
||||
} catch (IOException ex) {
|
||||
// TODO Auto-generated catch block
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
Path pListPath = Paths.get(main.getDataFolder() + "/playerList.txt");
|
||||
Charset charset = StandardCharsets.UTF_8;
|
||||
String content = new String(Files.readAllBytes(pListPath), charset);
|
||||
content = content.replaceAll(("\\b" + oldName + "\\b"), newName);
|
||||
Files.write(pListPath, content.getBytes(charset));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void outputStats(CommandSender sender, UUID uuid) {
|
||||
|
||||
Connection conn;
|
||||
int columnCountStats = 0;
|
||||
int columnCountStatsF = 0;
|
||||
int columnCountStatsN = 0;
|
||||
int columnCountStatsH = 0;
|
||||
try { //Try Connection
|
||||
conn = DriverManager.getConnection("jdbc:sqlite:" + main.getDataFolder().getAbsolutePath() + "/" + "Players.db");
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println(ConsoleColor.PURPLE + "[LMVE]" + sqlEx.getMessage() + ConsoleColor.RESET);
|
||||
return;
|
||||
}
|
||||
|
||||
String columnNameStats[];
|
||||
String columnNameStatsF[];
|
||||
String columnNameStatsN[];
|
||||
String columnNameStatsH[];
|
||||
|
||||
try { //Get Columncounts
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT * FROM tblPlayerStats;");
|
||||
ResultSetMetaData rsmd = rs.getMetaData();
|
||||
columnCountStats = rsmd.getColumnCount() - 2;
|
||||
columnNameStats = new String[columnCountStats];
|
||||
for(int i = 1; i <= columnCountStats; i++) {
|
||||
columnNameStats[i-1] = rsmd.getColumnName(i+2);
|
||||
}
|
||||
rs.close();
|
||||
ResultSet rsF = stmt.executeQuery("SELECT * FROM tblPlayerFKills;");
|
||||
ResultSetMetaData rsmdF = rsF.getMetaData();
|
||||
columnCountStatsF = rsmdF.getColumnCount() - 2;
|
||||
columnNameStatsF = new String[columnCountStatsF];
|
||||
for(int i = 1; i <= columnCountStatsF; i++) {
|
||||
columnNameStatsF[i-1] = rsmdF.getColumnName(i+2);
|
||||
}
|
||||
rsF.close();
|
||||
ResultSet rsN = stmt.executeQuery("SELECT * FROM tblPlayerNKills;");
|
||||
ResultSetMetaData rsmdN = rsN.getMetaData();
|
||||
columnCountStatsN = rsmdN.getColumnCount() - 2;
|
||||
columnNameStatsN = new String[columnCountStatsN];
|
||||
for(int i = 1; i <= columnCountStatsN; i++) {
|
||||
columnNameStatsN[i-1] = rsmdN.getColumnName(i+2);
|
||||
}
|
||||
rsN.close();
|
||||
ResultSet rsH = stmt.executeQuery("SELECT * FROM tblPlayerHKills;");
|
||||
ResultSetMetaData rsmdH = rsH.getMetaData();
|
||||
columnCountStatsH = rsmdH.getColumnCount() - 2;
|
||||
columnNameStatsH = new String[columnCountStatsH];
|
||||
for(int i = 1; i <= columnCountStatsH; i++) {
|
||||
columnNameStatsH[i-1] = rsmdH.getColumnName(i+2);
|
||||
}
|
||||
rsH.close();
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println(ConsoleColor.RED + "[LMVE]" + sqlEx.getMessage() + ConsoleColor.RESET);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String columnValueStats[] = new String[columnCountStats];
|
||||
String columnValueStatsF[] = new String[columnCountStatsF];
|
||||
String columnValueStatsN[] = new String[columnCountStatsN];
|
||||
String columnValueStatsH[] = new String[columnCountStatsH];
|
||||
|
||||
|
||||
try { //Get Stats
|
||||
String query = "SELECT * FROM tblPlayerStats WHERE UUID = ?;";
|
||||
PreparedStatement pst = conn.prepareStatement(query);
|
||||
pst.setString(1, uuid.toString());
|
||||
ResultSet rs = pst.executeQuery();
|
||||
rs.next();
|
||||
sender.sendMessage(ChatColor.GRAY + "================");
|
||||
sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "STATS");
|
||||
sender.sendMessage(ChatColor.RED + "=== General ===");
|
||||
for(int i = 1; i <= columnCountStats; i++) {
|
||||
columnValueStats[i-1] = rs.getString(i+2);
|
||||
sender.sendMessage(ChatColor.YELLOW + columnNameStats[i-1] + ": " + ChatColor.AQUA + columnValueStats[i-1]);
|
||||
}
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println(ConsoleColor.RED + "[LMVE]" + sqlEx.getMessage() + ConsoleColor.RESET);
|
||||
}
|
||||
|
||||
try { //Get F Kills
|
||||
String query = "SELECT * FROM tblPlayerFKills WHERE UUID = ?;";
|
||||
PreparedStatement pst = conn.prepareStatement(query);
|
||||
pst.setString(1, uuid.toString());
|
||||
ResultSet rs = pst.executeQuery();
|
||||
rs.next();
|
||||
sender.sendMessage(ChatColor.RED + "=== Kills ===");
|
||||
sender.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "[Friendly]");
|
||||
for(int i = 1; i <= columnCountStatsF; i++) {
|
||||
columnValueStatsF[i-1] = rs.getString(i+2);
|
||||
sender.sendMessage(ChatColor.YELLOW + columnNameStatsF[i-1] + ": " + ChatColor.AQUA + columnValueStatsF[i-1]);
|
||||
}
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println(ConsoleColor.RED + "[LMVE]" + sqlEx.getMessage() + ConsoleColor.RESET);
|
||||
}
|
||||
|
||||
try { //Get N Kills
|
||||
String query = "SELECT * FROM tblPlayerNKills WHERE UUID = ?;";
|
||||
PreparedStatement pst = conn.prepareStatement(query);
|
||||
pst.setString(1, uuid.toString());
|
||||
ResultSet rs = pst.executeQuery();
|
||||
rs.next();
|
||||
sender.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "[Neutral]");
|
||||
for(int i = 1; i <= columnCountStatsN; i++) {
|
||||
columnValueStatsN[i-1] = rs.getString(i + 2);
|
||||
sender.sendMessage(ChatColor.YELLOW + columnNameStatsN[i-1] + ": " + ChatColor.AQUA + columnValueStatsN[i-1]);
|
||||
}
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println(ConsoleColor.RED + "[LMVE]" + sqlEx.getMessage() + ConsoleColor.RESET);
|
||||
}
|
||||
|
||||
try { //Get H Kills
|
||||
String query = "SELECT * FROM tblPlayerHKills WHERE UUID = ?;";
|
||||
PreparedStatement pst = conn.prepareStatement(query);
|
||||
pst.setString(1, uuid.toString());
|
||||
ResultSet rs = pst.executeQuery();
|
||||
rs.next();
|
||||
sender.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "[Hostile]");
|
||||
for(int i = 1; i <= columnCountStatsH; i++) {
|
||||
columnValueStatsH[i-1] = rs.getString(i + 2);
|
||||
sender.sendMessage(ChatColor.YELLOW + columnNameStatsH[i-1] + ": " + ChatColor.AQUA + columnValueStatsH[i-1]);
|
||||
}
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println(ConsoleColor.RED + "[LMVE]" + sqlEx.getMessage() + ConsoleColor.RESET);
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GRAY + "================");
|
||||
}
|
||||
|
||||
}
|
||||
46
src/ml/codenoodles/lmve/modules/PreventMobGriefing.java
Normal file
46
src/ml/codenoodles/lmve/modules/PreventMobGriefing.java
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
package ml.codenoodles.lmve.modules;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
|
||||
import ml.codenoodles.lmve.Main;
|
||||
|
||||
public class PreventMobGriefing implements Listener{
|
||||
|
||||
private Main main;
|
||||
public PreventMobGriefing(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void PreventExplosion(ExplosionPrimeEvent e) {
|
||||
boolean change = false;
|
||||
switch(e.getEntityType()) {
|
||||
case CREEPER:{
|
||||
if(main.getConfig().getBoolean("PreventMobGriefing.creeper")) {
|
||||
change = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WITHER:{
|
||||
if(main.getConfig().getBoolean("PreventMobGriefing.wither")) {
|
||||
change = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WITHER_SKULL:{
|
||||
if(main.getConfig().getBoolean("PreventMobGriefing.wither")) {
|
||||
change = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {change = false; break;}
|
||||
}
|
||||
|
||||
if(change) {
|
||||
e.setRadius(0);
|
||||
e.setFire(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
127
src/ml/codenoodles/lmve/modules/SQLHandler.java
Normal file
127
src/ml/codenoodles/lmve/modules/SQLHandler.java
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
package ml.codenoodles.lmve.modules;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
import ml.codenoodles.lmve.other.ConsoleColor;
|
||||
|
||||
public class SQLHandler {
|
||||
|
||||
|
||||
public SQLHandler() {
|
||||
}
|
||||
|
||||
|
||||
public void createDefaultDatabase(String dbPath) {
|
||||
Connection conn;
|
||||
int successfullQuerys = 0;
|
||||
|
||||
String finalPath = "jdbc:sqlite:" + dbPath + "/" + "Players.db";
|
||||
try { //Try Connection
|
||||
conn = DriverManager.getConnection(finalPath);
|
||||
if(conn != null) {
|
||||
System.out.println(ConsoleColor.PURPLE + "[LMVE]Connected to Database!" + ConsoleColor.RESET);
|
||||
}
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println("[LMVE]" + sqlEx.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
try { //Create Playertable
|
||||
String query = "CREATE TABLE tblPlayers("
|
||||
+ "ID INTEGER PRIMARY KEY, "
|
||||
+ "Name TEXT NOT NULL,"
|
||||
+ "UUID TEXT);";
|
||||
Statement stmt = conn.createStatement();
|
||||
stmt.execute(query);
|
||||
System.out.println(ConsoleColor.PURPLE + "[LMVE]Player Table created!" + ConsoleColor.RESET);
|
||||
successfullQuerys++;
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println("[LMVE]" + sqlEx.getMessage());
|
||||
}
|
||||
|
||||
try { //Create PlayerStatsTable
|
||||
String query = "CREATE TABLE tblPlayerStats("
|
||||
+ "ID INTEGER PRIMARY KEY, " + "UUID TEXT NOT NULL,"
|
||||
+ "Displayname TEXT," + "Health REAL,"
|
||||
+ "World TEXT,"
|
||||
+ "FirstJoined TEXT," + "LastJoined TEXT,"
|
||||
+ "Deaths INTEGER," + "DamageTaken REAL);";
|
||||
Statement stmt = conn.createStatement();
|
||||
stmt.execute(query);
|
||||
System.out.println(ConsoleColor.PURPLE + "[LMVE]Player Stats Table created!" + ConsoleColor.RESET);
|
||||
successfullQuerys++;
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println("[LMVE]" + sqlEx.getMessage());
|
||||
}
|
||||
|
||||
try { //Create FriendlyKillTable
|
||||
String query = "CREATE TABLE tblPlayerFKills("
|
||||
+ "ID INTEGER PRIMARY KEY," + "UUID TEXT NOT NULL,"
|
||||
+ "Sheep INTEGER, " + "Pig INTEGER, " + "Chicken INTEGER, "
|
||||
+ "Bat INTEGER, " + "Cat INTEGER, " + "Cod INTEGER, "
|
||||
+ "Cow INTEGER, " + "Donkey INTEGER, " + "Fox INTEGER, "
|
||||
+ "Horse INTEGER, " + "Mooshroom INTEGER, " + "Mule INTEGER, "
|
||||
+ "Ocelot INTEGER, " + "Parrot INTEGER, " + "Rabbit INTEGER, "
|
||||
+ "Salmon INTEGER, " + "Skeleton_Horse INTEGER, " + "Squid INTEGER, "
|
||||
+ "Tropical_Fish INTEGER, " + "Turtle INTEGER, " + "Villager INTEGER, "
|
||||
+ "Wandering_Trager INTEGER, " + "Snowman INTEGER);";
|
||||
Statement stmt = conn.createStatement();
|
||||
stmt.execute(query);
|
||||
System.out.println(ConsoleColor.PURPLE + "[LMVE]Player KillStats F Table created!" + ConsoleColor.RESET);
|
||||
successfullQuerys++;
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println(ConsoleColor.RED + "[LMVE]" + sqlEx.getMessage() + ConsoleColor.RESET);
|
||||
}
|
||||
|
||||
try { //Create NeutralKillTable
|
||||
String query = "CREATE TABLE tblPlayerNKills("
|
||||
+ "ID INTEGER PRIMARY KEY," + "UUID TEXT NOT NULL,"
|
||||
+ "Enderman INTEGER, " + "Pufferfish INTEGER, " + "Dolphin INTEGER, "
|
||||
+ "Llama INTEGER, " + "Panda INTEGER, " + "Polar_Bear INTEGER,"
|
||||
+ "Trader_Llama INTEGER, " + "Wolf INTEGER, " + "Iron_Golem INTEGER,"
|
||||
+ "Zombie_Pigman INTEGER, " + "Bee INTEGER);";
|
||||
Statement stmt = conn.createStatement();
|
||||
stmt.execute(query);
|
||||
System.out.println(ConsoleColor.PURPLE + "[LMVE]Player KillStats N Table created!" + ConsoleColor.RESET);
|
||||
successfullQuerys++;
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println(ConsoleColor.RED + "[LMVE]" + sqlEx.getMessage() + ConsoleColor.RESET);
|
||||
}
|
||||
|
||||
try { //Create HostileKillTable
|
||||
String query = "CREATE TABLE tblPlayerHKills("
|
||||
+ "ID INTEGER PRIMARY KEY," + "UUID TEXT NOT NULL,"
|
||||
+ "Blaze INTEGER, " + "Creeper INTEGER, " + "Drowned INTEGER, "
|
||||
+ "Elder_Guardian INTEGER, " + "Endermite INTEGER, " + "Evoker INTEGER, "
|
||||
+ "Ghast INTEGER, " + "Guardian INTEGER, " + "Husk INTEGER, "
|
||||
+ "Magma_Cube INTEGER, " + "Phantom INTEGER, " + "Pillager INTEGER, "
|
||||
+ "Ravager INTEGER, " + "Shulker INTEGER, " + "Silverfish INTEGER, "
|
||||
+ "Skeleton INTEGER, " + "Slime INTEGER, " + "Stray INTEGER, "
|
||||
+ "Vex INTEGER, " + "Vindicator INTEGER, " + "Witch INTEGER, "
|
||||
+ "Wither_Skeleton INTEGER, " + "Zombie INTEGER, " + "Zombie_Villager INTEGER);";
|
||||
Statement stmt = conn.createStatement();
|
||||
stmt.execute(query);
|
||||
System.out.println(ConsoleColor.PURPLE + "[LMVE]Player KillStats H Table created!" + ConsoleColor.RESET);
|
||||
successfullQuerys++;
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println(ConsoleColor.RED + "[LMVE]" + sqlEx.getMessage() + ConsoleColor.RESET);
|
||||
}
|
||||
|
||||
try { //Close Connection
|
||||
conn.close();
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println("[LMVE]" + sqlEx.getMessage());
|
||||
}
|
||||
|
||||
if(successfullQuerys == 5) {
|
||||
System.out.println(ConsoleColor.GREEN + "[LMVE]Default Database successfully created!" + ConsoleColor.RESET);
|
||||
} else {
|
||||
System.out.println(ConsoleColor.RED + "[LMVE]Oops.. Something went wrong during the creation of the Default Database." + ConsoleColor.RESET);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
63
src/ml/codenoodles/lmve/modules/SleepVoteSystem.java
Normal file
63
src/ml/codenoodles/lmve/modules/SleepVoteSystem.java
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
package ml.codenoodles.lmve.modules;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerBedEnterEvent;
|
||||
import org.bukkit.event.player.PlayerBedLeaveEvent;
|
||||
|
||||
import ml.codenoodles.lmve.Main;
|
||||
|
||||
public class SleepVoteSystem implements Listener{
|
||||
|
||||
|
||||
private int playersInBed = 0;
|
||||
private Player players[];
|
||||
private Main main;
|
||||
public SleepVoteSystem(Main main) {
|
||||
this.main = main;
|
||||
players = new Player[main.getServer().getMaxPlayers()];
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void EnterBed(PlayerBedEnterEvent e) {
|
||||
World world = e.getPlayer().getWorld();
|
||||
if((world.getTime() > 12540) || (world.isThundering() == true)) {
|
||||
int pib = playersInBed;
|
||||
float onlinePlayers = main.getServer().getOnlinePlayers().size();
|
||||
pib = pib + 1;
|
||||
playersInBed = pib;
|
||||
main.getServer().broadcastMessage(ChatColor.GOLD + e.getPlayer().getName() + ChatColor.GRAY + " is now sleeping!");
|
||||
double calc = ((onlinePlayers / 100.0) * main.getConfig().getDouble("Sleep.min-perc"));
|
||||
int neededPlayers = (int) calc;
|
||||
players[playersInBed - 1] = e.getPlayer();
|
||||
if(playersInBed >= neededPlayers) {
|
||||
for(int i = 0; i < playersInBed; i++) {
|
||||
players[i].setBedSpawnLocation(players[i].getLocation());
|
||||
players[i].setStatistic(Statistic.TIME_SINCE_REST, 0);
|
||||
}
|
||||
main.getServer().broadcastMessage(ChatColor.GRAY + "Time was set to Day!");
|
||||
e.getPlayer().getWorld().setTime(1000);
|
||||
e.getPlayer().getWorld().setStorm(false);
|
||||
e.getPlayer().getWorld().setThundering(false);
|
||||
playersInBed = 0;
|
||||
for(int i = 0; i < main.getServer().getMaxPlayers(); i++) {
|
||||
players[i] = null;
|
||||
}
|
||||
} else {
|
||||
main.getServer().broadcastMessage(ChatColor.GOLD + "" + (neededPlayers - playersInBed) + ChatColor.GRAY + " more Players are needed to change Time to day!");
|
||||
}
|
||||
} else {
|
||||
e.getPlayer().sendMessage(ChatColor.GRAY + "You can only sleep at Night or during a Thunderstorm");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void BedLeave(PlayerBedLeaveEvent e) {
|
||||
main.getServer().broadcastMessage(ChatColor.GOLD + e.getPlayer().getName() + ChatColor.GRAY + " is no longer sleeping!");
|
||||
}
|
||||
|
||||
}
|
||||
495
src/ml/codenoodles/lmve/modules/StatCounter.java
Normal file
495
src/ml/codenoodles/lmve/modules/StatCounter.java
Normal file
|
|
@ -0,0 +1,495 @@
|
|||
package ml.codenoodles.lmve.modules;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
|
||||
import ml.codenoodles.lmve.Main;
|
||||
|
||||
public class StatCounter implements Listener{
|
||||
|
||||
private Main main;
|
||||
public StatCounter(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void BlockDestroyCounter(BlockBreakEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
UUID uuid = p.getUniqueId();
|
||||
File playerStats = new File(main.getDataFolder() + "/Players", uuid + ".yml");
|
||||
FileConfiguration player_stat = YamlConfiguration.loadConfiguration(playerStats);
|
||||
long counter = player_stat.getInt(uuid + ".Statistics.Blocks.Destroyed");
|
||||
counter++;
|
||||
player_stat.set(uuid + ".Statistics.Blocks.Destroyed", counter);
|
||||
try {
|
||||
player_stat.save(playerStats);
|
||||
} catch (IOException ex) {
|
||||
// TODO Auto-generated catch block
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void BlockPlaceCounter(BlockPlaceEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
UUID uuid = p.getUniqueId();
|
||||
File playerStats = new File(main.getDataFolder() + "/Players", uuid + ".yml");
|
||||
FileConfiguration player_stat = YamlConfiguration.loadConfiguration(playerStats);
|
||||
long counter = player_stat.getInt(uuid + ".Statistics.Blocks.Placed");
|
||||
counter++;
|
||||
player_stat.set(uuid + ".Statistics.Blocks.Placed", counter);
|
||||
try {
|
||||
player_stat.save(playerStats);
|
||||
} catch (IOException ex) {
|
||||
// TODO Auto-generated catch block
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void PlayerDamageCounter(EntityDamageEvent e) {
|
||||
Entity entity = e.getEntity();
|
||||
if (entity instanceof Player) {
|
||||
Player p = (Player) e.getEntity();
|
||||
if(p.getGameMode() == GameMode.SURVIVAL || p.getGameMode() == GameMode.ADVENTURE) {
|
||||
UUID uuid = p.getUniqueId();
|
||||
File playerStats = new File(main.getDataFolder() + "/Players", uuid + ".yml");
|
||||
FileConfiguration player_stat = YamlConfiguration.loadConfiguration(playerStats);
|
||||
double damage = player_stat.getDouble(uuid + ".Statistics.DamageTaken");
|
||||
damage = damage + e.getDamage();
|
||||
player_stat.set(uuid + ".Statistics.DamageTaken", damage);
|
||||
try {
|
||||
player_stat.save(playerStats);
|
||||
} catch (IOException ex) {
|
||||
// TODO Auto-generated catch block
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void PlayerDeathCounter(PlayerDeathEvent e) {
|
||||
Player p = (Player) e.getEntity();
|
||||
UUID uuid = p.getUniqueId();
|
||||
File playerStats = new File(main.getDataFolder() + "/Players", uuid + ".yml");
|
||||
FileConfiguration player_stat = YamlConfiguration.loadConfiguration(playerStats);
|
||||
int deaths = player_stat.getInt(uuid + ".Statistics.Deaths");
|
||||
deaths = deaths + 1;
|
||||
player_stat.set(uuid + ".Statistics.Deaths", deaths);
|
||||
try {
|
||||
player_stat.save(playerStats);
|
||||
} catch (IOException ex) {
|
||||
// TODO Auto-generated catch block
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void EntityKillCounter(EntityDeathEvent e) {
|
||||
String ent_type = e.getEntity().getType().toString();
|
||||
Player p = (Player) e.getEntity().getKiller();
|
||||
UUID player_uuid;
|
||||
if(p != null) {
|
||||
player_uuid = p.getUniqueId();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
File playerStats = new File(main.getDataFolder() + "/Players", player_uuid + ".yml");
|
||||
FileConfiguration player_stat = YamlConfiguration.loadConfiguration(playerStats);
|
||||
//Friendly
|
||||
int sheep, pig, chicken, bat, cat, cod, cow, donkey, fox, horse, mooshroom, mule,
|
||||
ocelot, parrot, rabbit,salmon, skeletonhorse, squid, tropicalfish, turtle, villager, wanderingtrader, snowgolem; //PRE 1.15
|
||||
//Neutral
|
||||
int enderman, pufferfish, dolphin, llama, panda, polarBear, traderLlama, wolf, ironGolem, zombiePigman; //PRE 1.15
|
||||
int bee; //1.15 +
|
||||
//Hostile
|
||||
int blaze, creeper, drowned, elderGuardian, endermite, evoker, ghast, guardian, husk,
|
||||
magmaCube, phantom, pillager, ravager, shulker, silverfish, skeleton, slime,
|
||||
stray, vex, vindicator, witch, witherSkeleton, zombie, zombieVillager; //PRE 1.15
|
||||
//Boss
|
||||
int enderDragon, wither;
|
||||
switch(ent_type) {
|
||||
case "SHEEP":{
|
||||
sheep = player_stat.getInt(player_uuid + ".Statistics.Kills.Friendly.Sheep");
|
||||
sheep++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Friendly.Sheep", sheep);
|
||||
break;
|
||||
}
|
||||
case "PIG":{
|
||||
pig = player_stat.getInt(player_uuid + ".Statistics.Kills.Friendly.Pig");
|
||||
pig++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Friendly.Pig", pig);
|
||||
break;
|
||||
}
|
||||
case "CHICKEN":{
|
||||
chicken = player_stat.getInt(player_uuid + "Statistics.Kills.Friendly.Chicken");
|
||||
chicken++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Friendly.Chicken", chicken);
|
||||
break;
|
||||
}
|
||||
case "BAT":{
|
||||
bat = player_stat.getInt(player_uuid + ".Statistics.Kills.Friendly.Bat");
|
||||
bat++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Friendly.Bat", bat);
|
||||
break;
|
||||
}
|
||||
case "CAT":{
|
||||
cat = player_stat.getInt(player_uuid + ".Statistics.Kills.Friendly.Cat");
|
||||
cat++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Friendly.Cat", cat);
|
||||
break;
|
||||
}
|
||||
case "COD":{
|
||||
cod = player_stat.getInt(player_uuid + ".Statistics.Kills.Friendly.Cod");
|
||||
cod++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Friendly.Cod", cod);
|
||||
break;
|
||||
}
|
||||
case "COW":{
|
||||
cow = player_stat.getInt(player_uuid + ".Statistics.Kills.Friendly.Cow");
|
||||
cow++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Friendly.Cow", cow);
|
||||
break;
|
||||
}
|
||||
case "DONKEY":{
|
||||
donkey = player_stat.getInt(player_uuid + ".Statistics.Kills.Friendly.Donkey");
|
||||
donkey++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Friendly.Donkey", donkey);
|
||||
break;
|
||||
}
|
||||
case "FOX":{
|
||||
fox = player_stat.getInt(player_uuid + ".Statistics.Kills.Friendly.Fox");
|
||||
fox++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Friendly.Fox", fox);
|
||||
break;
|
||||
}
|
||||
case "HORSE":{
|
||||
horse = player_stat.getInt(player_uuid + ".Statistics.Kills.Friendly.Horse");
|
||||
horse++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Friendly.Horse", horse);
|
||||
break;
|
||||
}
|
||||
case "MOOSHROOM":{
|
||||
mooshroom = player_stat.getInt(player_uuid + ".Statistics.Kills.Friendly.Mooshroom");
|
||||
mooshroom++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Friendly.Mooshroom", mooshroom);
|
||||
break;
|
||||
}
|
||||
case "MULE":{
|
||||
mule = player_stat.getInt(player_uuid + ".Statistics.Kills.Friendly.Mule");
|
||||
mule++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Friendly.Mule", mule);
|
||||
break;
|
||||
}
|
||||
case "OCELOT":{
|
||||
ocelot = player_stat.getInt(player_uuid + ".Statistics.Kills.Friendly.Ocelot");
|
||||
ocelot++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Friendly.Ocelot", ocelot);
|
||||
break;
|
||||
}
|
||||
case "PARROT":{
|
||||
parrot = player_stat.getInt(player_uuid + ".Statistics.Kills.Friendly.Parrot");
|
||||
parrot++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Friendly.Parrot", parrot);
|
||||
break;
|
||||
}
|
||||
case "RABBIT":{
|
||||
rabbit = player_stat.getInt(player_uuid + ".Statistics.Kills.Friendly.Rabbit");
|
||||
rabbit++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Friendly.Rabbit", rabbit);
|
||||
break;
|
||||
}
|
||||
case "SALMON":{
|
||||
salmon = player_stat.getInt(player_uuid + ".Statistics.Kills.Friendly.Salmon");
|
||||
salmon++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Friendly.Salmon", salmon);
|
||||
break;
|
||||
}
|
||||
case "SKELETON_HORSE":{
|
||||
skeletonhorse = player_stat.getInt(player_uuid + ".Statistics.Kills.Friendly.Skeleton_Horse");
|
||||
skeletonhorse++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Friendly.Skeleton_Horse", skeletonhorse);
|
||||
break;
|
||||
}
|
||||
case "SQUID":{
|
||||
squid = player_stat.getInt(player_uuid + ".Statistics.Kills.Friendly.Squid");
|
||||
squid++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Friendly.Squid",squid);
|
||||
break;
|
||||
}
|
||||
case "TROPICAL_FISH":{
|
||||
tropicalfish = player_stat.getInt(player_uuid + ".Statistics.Kills.Friendly.Tropical_Fish");
|
||||
tropicalfish++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Friendly.Tropical_Fish", tropicalfish);
|
||||
break;
|
||||
}
|
||||
case "TURTLE":{
|
||||
turtle = player_stat.getInt(player_uuid + ".Statistics.Kills.Friendly.Turtle");
|
||||
turtle++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Friendly.Turtle", turtle);
|
||||
break;
|
||||
}
|
||||
case "VILLAGER":{
|
||||
villager = player_stat.getInt(player_uuid + ".Statistics.Kills.Friendly.Villager");
|
||||
villager++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Friendly.Villager", villager);
|
||||
break;
|
||||
}
|
||||
case "WANDERING_TRADER":{
|
||||
wanderingtrader = player_stat.getInt(player_uuid + ".Statistics.Kills.Friendly.Wandering_Trader");
|
||||
wanderingtrader++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Friendly.Wandering_Trader", wanderingtrader);
|
||||
break;
|
||||
}
|
||||
case "SNOWMAN":{
|
||||
snowgolem = player_stat.getInt(player_uuid + ".Statistics.Kills.Friendly.Snowman");
|
||||
snowgolem++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Friendly.Snowman", snowgolem);
|
||||
break;
|
||||
}
|
||||
case "ENDERMAN":{
|
||||
enderman = player_stat.getInt(player_uuid + ".Statistics.Kills.Neutral.Enderman");
|
||||
enderman++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Neutral.Enderman", enderman);
|
||||
break;
|
||||
}
|
||||
case "PUFFERFISH":{
|
||||
pufferfish = player_stat.getInt(player_uuid + ".Statistics.Kills.Neutral.Pufferfish");
|
||||
pufferfish++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Neutral.Pufferfish", pufferfish);
|
||||
break;
|
||||
}
|
||||
case "DOLPHIN":{
|
||||
dolphin = player_stat.getInt(player_uuid + ".Statistics.Kills.Neutral.Dolphin");
|
||||
dolphin++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Neutral.Dolphin", dolphin);
|
||||
break;
|
||||
}
|
||||
case "LLAMA":{
|
||||
llama = player_stat.getInt(player_uuid + ".Statistics.Kills.Neutral.Llama");
|
||||
llama++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Neutral.Llama", llama);
|
||||
break;
|
||||
}
|
||||
case "PANDA":{
|
||||
panda = player_stat.getInt(player_uuid + ".Statistics.Kills.Neutral.Panda");
|
||||
panda++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Neutral.Panda", panda);
|
||||
break;
|
||||
}
|
||||
case "POLAR_BEAR":{
|
||||
polarBear = player_stat.getInt(player_uuid + ".Statistics.Kills.Neutral.Polar_Bear");
|
||||
polarBear++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Neutral.Polar_Bear", polarBear);
|
||||
break;
|
||||
}
|
||||
case "TRADER_LLAMA":{
|
||||
traderLlama = player_stat.getInt(player_uuid + ".Statistics.Kills.Neutral.Trader_Llama");
|
||||
traderLlama++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Neutral.Trader_Llama", traderLlama);
|
||||
break;
|
||||
}
|
||||
case "WOLF":{
|
||||
wolf = player_stat.getInt(player_uuid + ".Statistics.Kills.Neutral.Wolf");
|
||||
wolf++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Neutral.Wolf", wolf);
|
||||
break;
|
||||
}
|
||||
case "IRON:GOLEM":{
|
||||
ironGolem = player_stat.getInt(player_uuid + ".Statistics.Kills.Neutral.Iron_Golem");
|
||||
ironGolem++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Neutral.Iron_Golem", ironGolem);
|
||||
break;
|
||||
}
|
||||
case "PIG_ZOMBIE":{
|
||||
zombiePigman = player_stat.getInt(player_uuid + ".Statistics.Kills.Neutral.Zombie_Pigman");
|
||||
zombiePigman++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Neutral.Zombie_Pigman", zombiePigman);
|
||||
break;
|
||||
}
|
||||
case "BEE":{
|
||||
bee = player_stat.getInt(player_uuid + ".Statistics.Kills.Neutral.Bee");
|
||||
bee++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Neutral.Bee", bee);
|
||||
break;
|
||||
}
|
||||
case "BLAZE":{
|
||||
blaze = player_stat.getInt(player_uuid + ".Statistics.Kills.Hostile.Blaze");
|
||||
blaze++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Hostile.Blaze", blaze);
|
||||
break;
|
||||
}
|
||||
case "CREEPER":{
|
||||
creeper = player_stat.getInt(player_uuid + ".Statistics.Kills.Hostile.Creeper");
|
||||
creeper++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Hostile.Creeper", creeper);
|
||||
break;
|
||||
}
|
||||
case "DROWNED":{
|
||||
drowned = player_stat.getInt(player_uuid + ".Statistics.Kills.Hostile.Drowned");
|
||||
drowned++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Hostile.Drowned", drowned);
|
||||
break;
|
||||
}
|
||||
case "ELDER_GUARDIAN":{
|
||||
elderGuardian = player_stat.getInt(player_uuid + ".Statistics.Kills.Hostile.Elder_Guardian");
|
||||
elderGuardian++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Hostile.Elder_Guardian", elderGuardian);
|
||||
break;
|
||||
}
|
||||
case "ENDERMITE":{
|
||||
endermite = player_stat.getInt(player_uuid + ".Statistics.Kills.Hostile.Endermite");
|
||||
endermite++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Hostile.Endermite", endermite);
|
||||
break;
|
||||
}
|
||||
case "EVOKER":{
|
||||
evoker = player_stat.getInt(player_uuid + ".Statistics.Kills.Hostile.Evoker");
|
||||
evoker++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Hostile.Evoker", evoker);
|
||||
break;
|
||||
}
|
||||
case "GHAST":{
|
||||
ghast = player_stat.getInt(player_uuid + ".Statistics.Kills.Hostile.Ghast");
|
||||
ghast++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Hostile.Ghast", ghast);
|
||||
break;
|
||||
}
|
||||
case "GUARDIAN":{
|
||||
guardian = player_stat.getInt(player_uuid + ".Statistics.Kills.Hostile.Guardian");
|
||||
guardian++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Hostile.Guardian", guardian);
|
||||
break;
|
||||
}
|
||||
case "HUSK":{
|
||||
husk = player_stat.getInt(player_uuid + ".Statistics.Kills.Hostile.Husk");
|
||||
husk++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Hostile.Husk", husk);
|
||||
break;
|
||||
}
|
||||
case "MAGMA_CUBE":{
|
||||
magmaCube = player_stat.getInt(player_uuid + ".Statistics.Kills.Hostile.Magma_Cube");
|
||||
magmaCube++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Hostile.Magma_Cube", magmaCube);
|
||||
break;
|
||||
}
|
||||
case "PHANTOM":{
|
||||
phantom = player_stat.getInt(player_uuid + ".Statistics.Kills.Hostile.Phantom");
|
||||
phantom++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Hostile.Phantom", phantom);
|
||||
break;
|
||||
}
|
||||
case "PILLAGER":{
|
||||
pillager = player_stat.getInt(player_uuid + ".Statistics.Kills.Hostile.Pillager");
|
||||
pillager++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Hostile.Pillager", pillager);
|
||||
break;
|
||||
}
|
||||
case "RAVAGER":{
|
||||
ravager = player_stat.getInt(player_uuid + ".Statistics.Kills.Hostile.Ravager");
|
||||
ravager++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Hostile.Ravager", ravager);
|
||||
break;
|
||||
}
|
||||
case "SHULKER":{
|
||||
shulker = player_stat.getInt(player_uuid + ".Statistics.Kills.Hostile.Shulker");
|
||||
shulker++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Hostile.Shulker", shulker);
|
||||
break;
|
||||
}
|
||||
case "SILVERFISH":{
|
||||
silverfish = player_stat.getInt(player_uuid + ".Statistics.Kills.Hostile.Silverfish");
|
||||
silverfish++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Hostile.Silverfish", silverfish);
|
||||
break;
|
||||
}
|
||||
case "SKELETON":{
|
||||
skeleton = player_stat.getInt(player_uuid + ".Statistics.Kills.Hostile.Skeleton");
|
||||
skeleton++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Hostile.Skeleton", skeleton);
|
||||
break;
|
||||
}
|
||||
case "SLIME":{
|
||||
slime = player_stat.getInt(player_uuid + ".Statistics.Kills.Hostile.Slime");
|
||||
slime++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Hostile.Slime", slime);
|
||||
break;
|
||||
}
|
||||
case "STRAY":{
|
||||
stray = player_stat.getInt(player_uuid + ".Statistics.Kills.Hostile.Stray");
|
||||
stray++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Hostile.Stray", stray);
|
||||
break;
|
||||
}
|
||||
case "VEX":{
|
||||
vex = player_stat.getInt(player_uuid + ".Statistics.Kills.Hostile.Vex");
|
||||
vex++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Hostile.Vex", vex);
|
||||
break;
|
||||
}
|
||||
case "VINDICATOR":{
|
||||
vindicator = player_stat.getInt(player_uuid + ".Statistics.Kills.Hostile.Vindicator");
|
||||
vindicator++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Hostile.Vindicator", vindicator);
|
||||
break;
|
||||
}
|
||||
case "WITCH":{
|
||||
witch = player_stat.getInt(player_uuid + ".Statistics.Kills.Hostile.Witch");
|
||||
witch++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Hostile.Witch", witch);
|
||||
break;
|
||||
}
|
||||
case "WITHER_SKELETON":{
|
||||
witherSkeleton = player_stat.getInt(player_uuid + ".Statistics.Kills.Hostile.Wither_Skeleton");
|
||||
witherSkeleton++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Hostile.Wither_Skeleton", witherSkeleton);
|
||||
break;
|
||||
}
|
||||
case "ZOMBIE":{
|
||||
zombie = player_stat.getInt(player_uuid + ".Statistics.Kills.Hostile.Zombie");
|
||||
zombie++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Hostile.Zombie", zombie);
|
||||
break;
|
||||
}
|
||||
case "ZOMBIE_VILLAGER":{
|
||||
zombieVillager = player_stat.getInt(player_uuid + ".Statistics.Kills.Hostile.Zombie_Villager");
|
||||
zombieVillager++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Hostile.Zombie_Villager", zombieVillager);
|
||||
break;
|
||||
}
|
||||
case "ENDER_DRAGON":{
|
||||
enderDragon = player_stat.getInt(player_uuid + ".Statistics.Kills.Boss.Ender_Dragon");
|
||||
enderDragon++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Boss.Ender_Dragon", enderDragon);
|
||||
break;
|
||||
}
|
||||
case "WITHER":{
|
||||
wither = player_stat.getInt(player_uuid + ".Statistics.Kills.Boss.Wither");
|
||||
wither++;
|
||||
player_stat.set(player_uuid + ".Statistics.Kills.Boss.Wither", wither);
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
player_stat.save(playerStats);
|
||||
} catch (IOException ex) {
|
||||
// TODO Auto-generated catch block
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
138
src/ml/codenoodles/lmve/modules/UUIDReference.java
Normal file
138
src/ml/codenoodles/lmve/modules/UUIDReference.java
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
package ml.codenoodles.lmve.modules;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import ml.codenoodles.lmve.Main;
|
||||
|
||||
public class UUIDReference implements Listener{
|
||||
|
||||
private Main main;
|
||||
public UUIDReference(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void CreateEntry(PlayerJoinEvent e) {
|
||||
Player p = (Player) e.getPlayer();
|
||||
String dbPath = main.getDataFolder().getAbsolutePath();
|
||||
String playerName = p.getName();
|
||||
String uuid = p.getUniqueId().toString();
|
||||
|
||||
Connection conn;
|
||||
boolean entryExists = false;
|
||||
String path = "jdbc:sqlite:" + dbPath + "/" + "Players.db";
|
||||
try { //Try Connection
|
||||
conn = DriverManager.getConnection(path);
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println("[LMVE]" + sqlEx.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
try { //Check if Player is already listed
|
||||
String query = "SELECT (COUNT(*) > 0) FROM tblPlayers WHERE UUID = ?";
|
||||
PreparedStatement pst = conn.prepareStatement(query);
|
||||
pst.setString(1, uuid);
|
||||
ResultSet rs = pst.executeQuery();
|
||||
if(rs.next()) {
|
||||
boolean found = rs.getBoolean(1);
|
||||
if(found) {
|
||||
entryExists = true;
|
||||
} else {
|
||||
entryExists = false;
|
||||
}
|
||||
}
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println("[LMVE]" + sqlEx.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if(entryExists) {
|
||||
|
||||
try { //Change Existing Entry
|
||||
String query = "UPDATE tblPlayers SET Name = ? WHERE UUID = ?";
|
||||
PreparedStatement pst = conn.prepareStatement(query);
|
||||
pst.setString(1, playerName);
|
||||
pst.setString(2, uuid);
|
||||
pst.execute();
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println("[LMVE]" + sqlEx.getMessage());
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
int totalPlayers = 0;
|
||||
try { //Get Total Players
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet res = stmt.executeQuery("SELECT COUNT(*) AS rowcount FROM tblPlayers");
|
||||
|
||||
res.next();
|
||||
totalPlayers = res.getInt("rowcount");
|
||||
res.close();
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println("[LMVE]" + sqlEx.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
try { //Add Entry for new Player
|
||||
Statement stmt = conn.createStatement();
|
||||
String query = "INSERT INTO tblPlayers VALUES ("
|
||||
+ (totalPlayers + 1) + ","
|
||||
+ "'" + playerName + "',"
|
||||
+ "'" + uuid + "');";
|
||||
stmt.execute(query);
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println("[LMVE]" + sqlEx.getMessage());
|
||||
}
|
||||
|
||||
try { //Close Connection
|
||||
conn.close();
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println("[LMVE]" + sqlEx.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UUID getUUID(String username) {
|
||||
UUID uuid;
|
||||
Connection conn;
|
||||
String finalPath = "jdbc:sqlite:" + main.getDataFolder().getAbsolutePath() + "/" + "Players.db";
|
||||
try { //Try connection
|
||||
conn = DriverManager.getConnection(finalPath);
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println("[LMVE]" + sqlEx.getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
try { //Get Player
|
||||
String query = "SELECT UUID AS uuid FROM tblPlayers WHERE Name = ?";
|
||||
PreparedStatement pst = conn.prepareStatement(query);
|
||||
pst.setString(1, username);
|
||||
ResultSet res = pst.executeQuery();
|
||||
res.next();
|
||||
uuid = UUID.fromString(res.getString("uuid"));
|
||||
res.close();
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println("[LMVE]" + sqlEx.getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
try { //Close connection
|
||||
conn.close();
|
||||
}catch(SQLException sqlEx) {
|
||||
System.out.println("[LMVE]" + sqlEx);
|
||||
}
|
||||
|
||||
return uuid;
|
||||
}
|
||||
|
||||
}
|
||||
15
src/ml/codenoodles/lmve/other/ConsoleColor.java
Normal file
15
src/ml/codenoodles/lmve/other/ConsoleColor.java
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
package ml.codenoodles.lmve.other;
|
||||
|
||||
public class ConsoleColor {
|
||||
|
||||
public static String RESET = "\u001B[0m";
|
||||
public static final String BLACK = "\u001B[30m";
|
||||
public static final String RED = "\u001B[31m";
|
||||
public static final String GREEN = "\u001B[32m";
|
||||
public static final String YELLOW = "\u001B[33m";
|
||||
public static final String BLUE = "\u001B[34m";
|
||||
public static final String PURPLE = "\u001B[35m";
|
||||
public static final String CYAN = "\u001B[36m";
|
||||
public static final String WHITE = "\u001B[37m";
|
||||
|
||||
}
|
||||
24
src/ml/codenoodles/lmve/other/GlobalMute.java
Normal file
24
src/ml/codenoodles/lmve/other/GlobalMute.java
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package ml.codenoodles.lmve.other;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
import ml.codenoodles.lmve.Main;
|
||||
|
||||
public class GlobalMute implements Listener{
|
||||
|
||||
private Main main;
|
||||
public GlobalMute(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void GlobalChatMute(AsyncPlayerChatEvent e) {
|
||||
if(main.getConfigFile().getBoolean("Chat.global-mute")) {
|
||||
e.getPlayer().sendMessage(ChatColor.GOLD + "Chat is disabled on this server.");
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
34
src/ml/codenoodles/lmve/other/RemoveVanillaRecipes.java
Normal file
34
src/ml/codenoodles/lmve/other/RemoveVanillaRecipes.java
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package ml.codenoodles.lmve.other;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.PrepareItemCraftEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import ml.codenoodles.lmve.Main;
|
||||
|
||||
public class RemoveVanillaRecipes implements Listener{
|
||||
|
||||
private Main main;
|
||||
public RemoveVanillaRecipes(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
// 1 2 3 Inventory IDs
|
||||
// 4 5 6 -> 0
|
||||
// 7 8 9
|
||||
|
||||
@EventHandler
|
||||
public void removeMinecraftRecipes(PrepareItemCraftEvent e) {
|
||||
if(main.getConfigFile().getBoolean("RemoveVanillaRecipes.magma-block")) {
|
||||
if(e.getInventory().getItem(0) != null){
|
||||
if(e.getRecipe().getResult().getType().equals(Material.MAGMA_BLOCK) && (e.getView().getItem(5).getType() == Material.MAGMA_CREAM || e.getView().getItem(1).getType() == Material.MAGMA_CREAM)) {
|
||||
e.getInventory().setResult(new ItemStack(Material.AIR));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
53
src/ml/codenoodles/lmve/other/WelcomeBossBar.java
Normal file
53
src/ml/codenoodles/lmve/other/WelcomeBossBar.java
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
package ml.codenoodles.lmve.other;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import ml.codenoodles.lmve.Main;
|
||||
|
||||
public class WelcomeBossBar implements Listener{
|
||||
|
||||
private Main main;
|
||||
public WelcomeBossBar(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void PlayerWelcome(PlayerJoinEvent e) {
|
||||
NamespacedKey joinbossbar = new NamespacedKey(main, "joinbossbar_" + e.getPlayer().getUniqueId());
|
||||
Bukkit.createBossBar(joinbossbar,ChatColor.GREEN + "Welcome on " + ChatColor.GOLD + main.getConfigFile().getString("server-name"), BarColor.PURPLE, BarStyle.SEGMENTED_10).addPlayer(e.getPlayer());
|
||||
new BukkitRunnable() {
|
||||
int times = 0;
|
||||
@Override
|
||||
public void run() {
|
||||
if(times < 5) {
|
||||
Bukkit.getBossBar(joinbossbar).setProgress(Bukkit.getBossBar(joinbossbar).getProgress() + 0.19f);
|
||||
}
|
||||
if(times == 5) {
|
||||
Bukkit.getBossBar(joinbossbar).setProgress(1.0f);
|
||||
}
|
||||
if(times == 6) {
|
||||
Bukkit.getBossBar(joinbossbar).setTitle(ChatColor.GREEN + "Have Fun!");
|
||||
}
|
||||
|
||||
if(times == 8) {
|
||||
Bukkit.getBossBar(joinbossbar).removePlayer(e.getPlayer());
|
||||
Bukkit.removeBossBar(joinbossbar);
|
||||
this.cancel();
|
||||
}
|
||||
times++;
|
||||
}
|
||||
}.runTaskTimer(main, 0L, 20L);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
40
src/ml/codenoodles/lmve/sounds/ChatNotification.java
Normal file
40
src/ml/codenoodles/lmve/sounds/ChatNotification.java
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
package ml.codenoodles.lmve.sounds;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Instrument;
|
||||
import org.bukkit.Note;
|
||||
import org.bukkit.Note.Tone;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
import ml.codenoodles.lmve.Main;
|
||||
|
||||
public class ChatNotification implements Listener{
|
||||
|
||||
private Main main;
|
||||
public ChatNotification(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void ChatNotifiy(AsyncPlayerChatEvent e) {
|
||||
if(!main.getConfigFile().getBoolean("Chat.global-mute")) {
|
||||
for(Player players : Bukkit.getOnlinePlayers()){
|
||||
File playerStats = new File(main.getDataFolder() + "/Players", players.getUniqueId() + ".yml");
|
||||
FileConfiguration player_stat = YamlConfiguration.loadConfiguration(playerStats);
|
||||
if(player_stat.getBoolean(players.getUniqueId() + ".Settings.Sounds.ChatNotify")) {
|
||||
if(players.getPlayer().getName() != e.getPlayer().getName()) {
|
||||
players.playNote(players.getLocation(), Instrument.BANJO, Note.natural(1, Tone.C));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in a new issue