Skip to content

Commit

Permalink
1.2.0 incomming fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
0PandaDEV committed Aug 16, 2022
1 parent 3be1cb9 commit fc6d06b
Show file tree
Hide file tree
Showing 25 changed files with 645 additions and 50 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

<groupId>tk.pandadev</groupId>
<artifactId>EssentialsP</artifactId>
<version>1.0.5-SNAPSHOT</version>
<version>1.2.0</version>
<packaging>jar</packaging>

<name>EssentialsP</name>

<description>Similar to EssentialsX but in German</description>
<description>Ein Basis plugin was die Grundlage für jeden Server bietet</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
50 changes: 47 additions & 3 deletions src/main/java/tk/pandadev/essentialsp/Main.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package tk.pandadev.essentialsp;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
Expand All @@ -12,12 +10,14 @@
import org.bukkit.scheduler.BukkitRunnable;
import tk.pandadev.essentialsp.commands.*;
import tk.pandadev.essentialsp.listeners.ChatEditor;
import tk.pandadev.essentialsp.listeners.InventoryClickListener;
import tk.pandadev.essentialsp.listeners.JoinListener;
import tk.pandadev.essentialsp.listeners.QuitListener;
import tk.pandadev.essentialsp.tablist.TablistManager;
import tk.pandadev.essentialsp.utils.Config;
import tk.pandadev.essentialsp.utils.SettingsConfig;
import tk.pandadev.essentialsp.utils.VanishAPI;
import tk.pandadev.essentialsp.utils.VanishManager;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
Expand All @@ -26,18 +26,24 @@ public final class Main extends JavaPlugin {

private static Main instance;
private Config config;

private File settingsConfig;
private FileConfiguration settings;
private static String Prefix = "§a§lEssentialsP §8» ";
private static String NoPerm = Prefix + "§cDazu hast du keine Berechtigung";
private static String InvalidPlayer = Prefix + "§cDieser Spieler ist nicht Online";
private VanishManager vanishManager;
private VanishAPI vanishAPI;
private TablistManager tablistManager;

public static HashMap<Player, Player> tpa = new HashMap<>();

@Override
public void onEnable() {
createCustomConfig();
saveDefaultConfig();
vanishManager = new VanishManager(this);
vanishAPI = new VanishAPI(this);
tablistManager = new TablistManager();
instance = this;
Bukkit.getConsoleSender().sendMessage(Prefix + "§aAktiviert");
Expand All @@ -46,6 +52,7 @@ public void onEnable() {
registerCommands();

for (Player player : Bukkit.getOnlinePlayers()) {
SettingsConfig.checkSettings(player);
Main.getInstance().getTablistManager().setAllPlayerTeams();
run();
}
Expand Down Expand Up @@ -74,13 +81,46 @@ private void registerCommands(){
getCommand("sudo").setExecutor(new SudoCommand());
getCommand("head").setExecutor(new HeadCommand());
getCommand("rank").setExecutor(new RankCommand());
getCommand("settings").setExecutor(new SettingsCommand());
}

private void registerListeners(){
PluginManager pluginManager = Bukkit.getPluginManager();
pluginManager.registerEvents(new JoinListener(), this);
pluginManager.registerEvents(new QuitListener(), this);
pluginManager.registerEvents(new ChatEditor(), this);
pluginManager.registerEvents(new InventoryClickListener(), this);
}

private void createCustomConfig() {
settingsConfig = new File(getDataFolder(), "settings.yml");
if (!settingsConfig.exists()) {
settingsConfig.getParentFile().mkdirs();
saveResource("settings.yml", false);
}

settings = new YamlConfiguration();
try {
settings.load(settingsConfig);
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
}
/* User Edit:
Instead of the above Try/Catch, you can also use
YamlConfiguration.loadConfiguration(customConfigFile)
*/
}

public void saveSettingsConfig() {
try{
settings.save(settingsConfig);
} catch (IOException e) {
throw new RuntimeException(e);
}
}

public FileConfiguration getSettingsConfig() {
return this.settings;
}

public static Main getInstance() {
Expand Down Expand Up @@ -116,4 +156,8 @@ public void run() {
}.runTaskTimer(Main.getInstance(), 20, 20);
}

public VanishAPI getVanishAPI() {
return vanishAPI;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
if (player.hasPermission("essentialsp.fly")) {

if (player.getAllowFlight()){
player.sendMessage(Main.getPrefix() + "§7Du kannst jetzt nicht mehr fliegen");
if (Main.getInstance().getSettingsConfig().getBoolean(player.getUniqueId() + ".message")){
player.sendMessage(Main.getPrefix() + "§7Du kannst jetzt nicht mehr fliegen");
}
} else {
player.sendMessage(Main.getPrefix() + "§7Du kannst jetzt fliegen");
if (Main.getInstance().getSettingsConfig().getBoolean(player.getUniqueId() + ".message")){
player.sendMessage(Main.getPrefix() + "§7Du kannst jetzt fliegen");
}
}

player.setAllowFlight(!player.getAllowFlight());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,39 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
if (args[0].equalsIgnoreCase("1") || args[0].equalsIgnoreCase("creative")) {
if (player.getGameMode() != GameMode.CREATIVE){
player.setGameMode(GameMode.CREATIVE);
player.sendMessage(Main.getPrefix() + "§7Du hast dich in den Spielmodus §aCreative §7gesetzt");
if (Main.getInstance().getSettingsConfig().getBoolean(player.getUniqueId() + ".feedback")){
player.sendMessage(Main.getPrefix() + "§7Du hast dich in den Spielmodus §aCreative §7gesetzt");
}
}else {
player.sendMessage(Main.getPrefix() + "§cDu bist bereits im Gamemode §6Creative");
}
}
if (args[0].equalsIgnoreCase("0") || args[0].equalsIgnoreCase("survival")) {
if (player.getGameMode() != GameMode.SURVIVAL){
player.setGameMode(GameMode.SURVIVAL);
player.sendMessage(Main.getPrefix() + "§7Du hast dich in den Spielmodus §aSurvival §7gesetzt");
if (Main.getInstance().getSettingsConfig().getBoolean(player.getUniqueId() + ".feedback")){
player.sendMessage(Main.getPrefix() + "§7Du hast dich in den Spielmodus §aSurvival §7gesetzt");
}
}else {
player.sendMessage(Main.getPrefix() + "§cDu bist bereits im Gamemode §6Survival");
}
}
if (args[0].equalsIgnoreCase("2") || args[0].equalsIgnoreCase("adventure")) {
if (player.getGameMode() != GameMode.ADVENTURE){
player.setGameMode(GameMode.ADVENTURE);
player.sendMessage(Main.getPrefix() + "§7Du hast dich in den Spielmodus §aAdventure §7gesetzt");
if (Main.getInstance().getSettingsConfig().getBoolean(player.getUniqueId() + ".feedback")){
player.sendMessage(Main.getPrefix() + "§7Du hast dich in den Spielmodus §aAdventure §7gesetzt");
}
}else {
player.sendMessage(Main.getPrefix() + "§cDu bist bereits im Gamemode §6Adventure");
}
}
if (args[0].equalsIgnoreCase("3") || args[0].equalsIgnoreCase("spectator")) {
if (player.getGameMode() != GameMode.SPECTATOR){
player.setGameMode(GameMode.SPECTATOR);
player.sendMessage(Main.getPrefix() + "§7Du hast dich in den Spielmodus §aSpectator §7gesetzt");
if (Main.getInstance().getSettingsConfig().getBoolean(player.getUniqueId() + ".feedback")){
player.sendMessage(Main.getPrefix() + "§7Du hast dich in den Spielmodus §aSpectator §7gesetzt");
}
}else {
player.sendMessage(Main.getPrefix() + "§cDu bist bereits im Gamemode §6Spectator");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import sun.tools.jconsole.Tab;
import tk.pandadev.essentialsp.Main;

import java.util.ArrayList;
Expand All @@ -37,7 +36,9 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
item.setItemMeta(meta);
Inventory inventory = player.getInventory();
inventory.addItem(item);
player.sendMessage(Main.getPrefix() + "§7Du hast den kopf von §a" + args[0] + "§7 bekommen");
if (Main.getInstance().getSettingsConfig().getBoolean(player.getUniqueId() + ".feedback")){
player.sendMessage(Main.getPrefix() + "§7Du hast den kopf von §a" + args[0] + "§7 bekommen");
}

} else {
player.sendMessage(Main.getNoPerm());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
if (player.getHealth() != player.getMaxHealth()) {
player.setHealth(player.getMaxHealth());
player.setFoodLevel(20);
player.sendMessage(Main.getPrefix() + "§7Du hast dich geheilt");
if (Main.getInstance().getSettingsConfig().getBoolean(player.getUniqueId() + ".feedback")){
player.sendMessage(Main.getPrefix() + "§7Du hast dich geheilt");
}
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 1.0f);
return true;
}
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/tk/pandadev/essentialsp/commands/HomeCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ public boolean onCommand(CommandSender sender, Command command, String label, St

player.teleport((Location) Objects.requireNonNull(Main.getInstance().getConfig().get("Homes." + player.getName() + "." + args[0].toLowerCase())));
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1.0f, 1.0f);
player.sendMessage(Main.getPrefix() + "§7Du hast dich zum Home §a" + args[0].toLowerCase() + "§7 teleportiert");
if (Main.getInstance().getSettingsConfig().getBoolean(player.getUniqueId() + ".message")){
player.sendMessage(Main.getPrefix() + "§7Du hast dich zum Home §a" + args[0].toLowerCase() + "§7 teleportiert");
}
return true;

} else {
Expand All @@ -77,7 +79,9 @@ public boolean onCommand(CommandSender sender, Command command, String label, St

player.teleport((Location) Objects.requireNonNull(Main.getInstance().getConfig().get("Homes." + player.getName() + ".default")));
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1.0f, 1.0f);
player.sendMessage(Main.getPrefix() + "§7Du hast dich zu deinem §aDefault §7Home teleportiert");
if (Main.getInstance().getSettingsConfig().getBoolean(player.getUniqueId() + ".message")){
player.sendMessage(Main.getPrefix() + "§7Du hast dich zu deinem §aDefault §7Home teleportiert");
}
return true;

} else {
Expand All @@ -98,7 +102,9 @@ public List<String> onTabComplete(CommandSender sender, Command command, String
Player playert = (Player)(sender);

if (args.length == 1) {
list.addAll(Objects.requireNonNull(Main.getInstance().getConfig().getConfigurationSection("Homes." + playert.getName() + ".")).getKeys(false));
if (args[0].equals("delhome") && args[0].equals("home")){
list.addAll(Objects.requireNonNull(Main.getInstance().getConfig().getConfigurationSection("Homes." + playert.getName() + ".")).getKeys(false));
}
}

ArrayList<String> completerList = new ArrayList<String>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package tk.pandadev.essentialsp.commands;

import org.bukkit.Sound;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import tk.pandadev.essentialsp.Main;
import tk.pandadev.essentialsp.guis.MainGui;

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

public class SettingsCommand implements CommandExecutor, TabCompleter {

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

if (!(sender instanceof Player)) {
sender.sendMessage(Main.getPrefix() + "§6Du musst diesen Command als Spieler ausführen!");
return false;
}

Player player = (Player) (sender);

if (args.length == 0){
if (player.hasPermission("essentialsp.settings")){
try {
player.openInventory(MainGui.getInventory(player));
} catch (IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace();
}
player.playSound(player.getLocation(), Sound.BLOCK_BARREL_OPEN, 100, 1);
} else {
player.sendMessage(Main.getNoPerm());
}
} else {
player.sendMessage(Main.getPrefix() + "§c/settings");
}

return false;
}

@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
Player playert = (Player) (sender);
ArrayList<String> list = new ArrayList<String>();



ArrayList<String> completerList = new ArrayList<String>();
String currentarg = args[args.length - 1].toLowerCase();
for (String s : list) {
String s1 = s.toLowerCase();
if (!s1.startsWith(currentarg)) continue;
completerList.add(s);
}

return completerList;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,19 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
player.setAllowFlight(true);
player.setFlying(true);
player.setFlySpeed(speed);
player.sendMessage(Main.getPrefix() + "§7Die FlySpeed wurde auf §a" + args[0] + "§7 gesetzt");
if (Main.getInstance().getSettingsConfig().getBoolean(player.getUniqueId() + ".feedback")){
player.sendMessage(Main.getPrefix() + "§7Die FlySpeed wurde auf §a" + args[0] + "§7 gesetzt");
}
}
} else if (player.isOnGround()){
float speed = Float.parseFloat(args[0]) / 10f;
if (speed > 1){
player.sendMessage(Main.getPrefix() + "§cDer wert darf nicht höher als §610§c sein");
} else {
player.setWalkSpeed(speed);
player.sendMessage(Main.getPrefix() + "§7Die WalkSpeed wurde auf §a" + args[0] + "§7 gesetzt");
if (Main.getInstance().getSettingsConfig().getBoolean(player.getUniqueId() + ".feedback")){
player.sendMessage(Main.getPrefix() + "§7Die WalkSpeed wurde auf §a" + args[0] + "§7 gesetzt");
}
}
}
} else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ public boolean onCommand(CommandSender sender, Command command, String label, St

target.teleport(player.getLocation());

target.sendMessage(Main.getPrefix() + "§7Du wurdest zu §a" + player.getName() + "§7 Teleportiert");
player.sendMessage(Main.getPrefix() + "§a" + target.getName() + "§7 wurde zu dir Teleportiert");
if (Main.getInstance().getSettingsConfig().getBoolean(target.getUniqueId() + ".feedback")){
target.sendMessage(Main.getPrefix() + "§7Du wurdest zu §a" + player.getName() + "§7 Teleportiert");
}
if (Main.getInstance().getSettingsConfig().getBoolean(player.getUniqueId() + ".feedback")){
player.sendMessage(Main.getPrefix() + "§a" + target.getName() + "§7 wurde zu dir Teleportiert");
}

target.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1.0f, 1.0f);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
if (!Objects.equals(target.getName(), player.getName())) {
target.teleport(player.getLocation());

player.sendMessage(Main.getPrefix() + "§7Der Spieler §a" + target.getDisplayName() + "§7 wurde zu dir Teleportiert");
if (Main.getInstance().getSettingsConfig().getBoolean(player.getUniqueId() + ".feedback")){
player.sendMessage(Main.getPrefix() + "§7Der Spieler §a" + target.getName() + "§7 wurde zu dir Teleportiert");
}

} else {
player.sendMessage(Main.getPrefix() + "§cDu kannst dich nicht selbst zu dir Teleportieren");
Expand Down
Loading

0 comments on commit fc6d06b

Please sign in to comment.