Skip to content

Commit

Permalink
Major version change. Now requires TreeboRoots (https://github.com/Tr…
Browse files Browse the repository at this point in the history
…eeboMC/TreeboRoots/releases) with minimum version 0.0.0

Homes and Deaths data will be automatically moved to the TreeboRoots data folder as part of an initiative to centralize player data for easier access and purging.

TreeboRoots integration:
Automatic update integration.
HelpBook Integration.
  • Loading branch information
ShakeforProtein committed May 24, 2021
1 parent 1530597 commit 5384c45
Show file tree
Hide file tree
Showing 42 changed files with 915 additions and 805 deletions.
14 changes: 13 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.ShakeforProtein</groupId>
<artifactId>TreeboTeleport</artifactId>
<version>1.1.1 - SpMc1.16.4</version>
<version>2.0.0</version>
<packaging>jar</packaging>

<name>TreeboTeleport</name>
Expand Down Expand Up @@ -107,5 +107,17 @@
<version>1.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>me.ShakeforProtein</groupId>
<artifactId>TreeboRoots</artifactId>
<version>0.0.0</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.vdurmont</groupId>
<artifactId>semver4j</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import me.shakeforprotein.treeboteleport.TreeboTeleport;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandMap;
import org.bukkit.command.CommandSender;
import org.bukkit.command.defaults.BukkitCommand;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public boolean execute(CommandSender sender, String label, String[] args) {

if (pl.lastLocConf.containsKey(p.getUniqueId())) {
p.sendMessage(pl.badge + "Sending you to your previous location");
p.teleport((Location) pl.lastLocConf.get(p.getUniqueId()));
p.teleport(pl.lastLocConf.get(p.getUniqueId()));
} else {
p.sendMessage(pl.err + "Could not find previous location");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
import me.shakeforprotein.treeboteleport.TreeboTeleport;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.defaults.BukkitCommand;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;

Expand All @@ -33,7 +30,7 @@ public boolean execute(CommandSender sender, String label, String[] args) {
this.setPermission("tbteleport.player.configure.homes");
if (sender.hasPermission(this.getPermission())) {

homeFile = new File(pl.getDataFolder() + File.separator + "homes", File.separator + ((Player) sender).getUniqueId().toString() + ".yml");
homeFile = new File(pl.getPlayerDataFolder() + File.separator + ((Player) sender).getUniqueId(), File.separator + "homes"+ ".yml");
homeYaml = YamlConfiguration.loadConfiguration(homeFile);
boolean found = false;

Expand Down Expand Up @@ -77,7 +74,7 @@ public boolean execute(CommandSender sender, String label, String[] args) {
sender.sendMessage(pl.err + "Insufficient arguments");
doHelp(sender);
}
pl.saveFile(homeFile, homeYaml, sender);
pl.saveFileConfigurationToFile(homeFile, homeYaml, sender);


} else {
Expand All @@ -100,7 +97,7 @@ public void notFound(String str, CommandSender s) {

public boolean setYml(String name, String selector, String newVal, CommandSender s) {
String uuid = ((Player) s).getUniqueId().toString();
homeFile = new File(pl.getDataFolder() + File.separator + "homes", File.separator + uuid + ".yml");
homeFile = new File(pl.getPlayerDataFolder() + File.separator + uuid, File.separator + "homes"+ ".yml");
homeYaml = YamlConfiguration.loadConfiguration(homeFile);
boolean found = false;
for (String menuItem : homeYaml.getConfigurationSection("homes").getKeys(false)) {
Expand All @@ -109,7 +106,7 @@ public boolean setYml(String name, String selector, String newVal, CommandSender
newVal = newVal.toUpperCase();
}
homeYaml.set("homes." + menuItem + "." + selector, newVal);
pl.saveFile(homeFile, homeYaml, s);
pl.saveFileConfigurationToFile(homeFile, homeYaml, s);
s.sendMessage(pl.badge + "Changed " + selector + " of '" + name + "' to '" + newVal + "' successfully.");
found = true;
}
Expand All @@ -124,7 +121,7 @@ public boolean setYml(String name, String selector, String newVal, CommandSender

public void doHelp(CommandSender s) {
s.sendMessage(pl.badge + ChatColor.GOLD + "Help for /configurehomes");
s.sendMessage("/configurehome set <current name> <icon | x colour> <New Value>");
s.sendMessage("/configurehome set <current name> <icon | colour> <New Value>");
s.sendMessage("/configurehome set default <CurrentName>");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import me.shakeforprotein.treeboteleport.TreeboTeleport;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.defaults.BukkitCommand;
import org.bukkit.configuration.file.YamlConfiguration;
Expand Down Expand Up @@ -81,7 +79,7 @@ public boolean execute(CommandSender sender, String label, String[] args) {
doHelp(sender);
}
}
pl.saveFile(hubFile, hubYaml, sender);
pl.saveFileConfigurationToFile(hubFile, hubYaml, sender);


} else {
Expand Down Expand Up @@ -111,7 +109,7 @@ public boolean setYml(String pos, String selector, String newVal, CommandSender
} else {
hubYaml.set("hubmenu.menuItems." + menuItem + "." + selector, newVal);
}
pl.saveFile(hubFile, hubYaml, s);
pl.saveFileConfigurationToFile(hubFile, hubYaml, s);
s.sendMessage("Changed " + selector + " to '" + newVal + "' successfully.");
found = true;
}
Expand All @@ -127,7 +125,7 @@ public boolean setRows(String newRows, CommandSender s) {
hubFile = new File(pl.getDataFolder(), "hubMenu.yml");
hubYaml = YamlConfiguration.loadConfiguration(hubFile);
hubYaml.set("hubmenu.menuRows", Integer.parseInt(newRows));
pl.saveFile(hubFile, hubYaml, s);
pl.saveFileConfigurationToFile(hubFile, hubYaml, s);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public boolean setYml(String pos, String selector, String newVal, CommandSender
for (String menuItem : hubYaml.getConfigurationSection("hubmenu.menuItems").getKeys(false)) {
if (hubYaml.getInt("hubmenu.menuItems." + menuItem + ".position") == Integer.parseInt(pos)) {
hubYaml.set("hubmenu.menuItems." + menuItem + "." + selector, newVal);
pl.saveFile(hubFile, hubYaml, s);
pl.saveFileConfigurationToFile(hubFile, hubYaml, s);
found = true;
}
}
Expand All @@ -44,7 +44,7 @@ public boolean setRows(String newRows, CommandSender s) {
hubFile = new File(pl.getDataFolder(), "hubMenu.yml");
hubYaml = YamlConfiguration.loadConfiguration(hubFile);
hubYaml.set("hubMenu.menuRows", Integer.parseInt(newRows));
pl.saveFile(hubFile, hubYaml, s);
pl.saveFileConfigurationToFile(hubFile, hubYaml, s);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
import me.shakeforprotein.treeboteleport.TreeboTeleport;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.defaults.BukkitCommand;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -48,8 +45,8 @@ public boolean execute(CommandSender sender, String label, String[] args) {
try {
warpsYaml.save(warpsFile);
sender.sendMessage("Warps file saved");
} catch (IOException err) {
pl.makeLog(err);
} catch (IOException ex) {
pl.roots.errorLogger.logError(pl, ex);
sender.sendMessage(pl.err + "Failed to save warps file");
}
} else {
Expand All @@ -66,8 +63,8 @@ public boolean execute(CommandSender sender, String label, String[] args) {
try {
warpsYaml.save(warpsFile);
sender.sendMessage("Warps file saved");
} catch (IOException err) {
pl.makeLog(err);
} catch (IOException ex) {
pl.roots.errorLogger.logError(pl, ex);
sender.sendMessage(pl.err + "Failed to save warps file");
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import me.shakeforprotein.treeboteleport.TreeboTeleport;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.defaults.BukkitCommand;
import org.bukkit.configuration.file.FileConfiguration;
Expand Down Expand Up @@ -33,7 +31,9 @@ public boolean execute(CommandSender sender, String label, String[] args) {
if(sender.hasPermission(this.getPermission())) {

Player p = (Player) sender;
File homesYml = new File(pl.getDataFolder() + File.separator + "homes", File.separator + p.getUniqueId() + ".yml");
//File homesYml = new File(pl.getDataFolder() + File.separator + "homes", File.separator + p.getUniqueId().toString() + ".yml");
File homesYml = new File(pl.getPlayerDataFolder() + File.separator + p.getUniqueId().toString(), File.separator + "homes"+ ".yml");

if (!homesYml.exists()) {
p.sendMessage(pl.err + "Homes file not found. Attempting to Recover.");
try {
Expand All @@ -42,11 +42,11 @@ public boolean execute(CommandSender sender, String label, String[] args) {
try {
homes.options().copyDefaults();
homes.save(homesYml);
} catch (FileNotFoundException e) {
pl.makeLog(e);
} catch (FileNotFoundException ex) {
pl.roots.errorLogger.logError(pl, ex);
}
} catch (IOException e) {
pl.makeLog(e);
} catch (IOException ex) {
pl.roots.errorLogger.logError(pl, ex);
p.sendMessage(pl.err + "Creating Homes file failed");
}
}
Expand All @@ -69,8 +69,8 @@ public boolean execute(CommandSender sender, String label, String[] args) {
try {
homes.save(homesYml);
p.sendMessage(pl.badge + "If a home existed with name: " + ChatColor.GOLD + args[0] + ChatColor.RESET + " it has now been deleted.");
} catch (IOException e) {
pl.makeLog(e);
} catch (IOException ex) {
pl.roots.errorLogger.logError(pl, ex);
p.sendMessage(pl.err + "Saving homes file failed");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public boolean execute(CommandSender sender, String label, String[] args) {
try {
warps.save(warpsYml);
p.sendMessage(pl.badge + "If a warp existed with name: " + ChatColor.GOLD + args[0] + ChatColor.RESET + " it has now been deleted.");
} catch (IOException e) {
pl.makeLog(e);
} catch (IOException ex) {
pl.roots.errorLogger.logError(pl, ex);
p.sendMessage(pl.err + "Saving Warps file unsuccessful");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import me.shakeforprotein.treeboteleport.TreeboTeleport;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.defaults.BukkitCommand;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -33,7 +31,7 @@ public boolean execute(CommandSender sender, String label, String[] args) {

Player p = (Player) sender;
Inventory inv = p.getInventory();
ItemStack hubItem = pl.getHubItem();
ItemStack hubItem = pl.getHubItemFromConfig();
if (!inv.contains(hubItem)) {
inv.addItem(hubItem);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ public boolean execute(CommandSender sender, String label, String[] args) {
if(sender.hasPermission(this.getPermission())) {

Player p = (Player) sender;
File homesYml = new File(pl.getDataFolder() + File.separator + "homes", File.separator + p.getUniqueId() + ".yml");
FileConfiguration homes = YamlConfiguration.loadConfiguration(homesYml);
//File homesYml = new File(pl.getDataFolder() + File.separator + "homes", File.separator + p.getUniqueId().toString() + ".yml");
File homesYml = new File(pl.getPlayerDataFolder() + File.separator + p.getUniqueId().toString(), File.separator + "homes.yml");

FileConfiguration homes = YamlConfiguration.loadConfiguration(homesYml);

if (!homesYml.exists()) {
sender.sendMessage(pl.err + "You do not appear to have any homes. Use '/sethome <home name>' to create a home at your current location.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ public boolean execute(CommandSender sender, String label, String[] args) {
Player p = (Player) sender;
String tempUUID = "0";
String tempName = "";
File homesYml = new File(pl.getDataFolder() + File.separator + "homes", File.separator + p.getUniqueId() + ".yml");
File homesYml = new File(pl.getDataFolder() + File.separator + "homes", File.separator + p.getUniqueId().toString() + ".yml");
if (args.length == 1 && !(args[0].equalsIgnoreCase("setDefault")) && sender.hasPermission("tbteleport.staff.homes.others")) {
for (OfflinePlayer offlinePlayer : Bukkit.getOfflinePlayers()) {
if (offlinePlayer.getName().equalsIgnoreCase(args[0])) {
found = true;
tempName = offlinePlayer.getName();
tempUUID = offlinePlayer.getUniqueId().toString();
File testFile = new File(pl.getDataFolder() + File.separator + "homes", File.separator + offlinePlayer.getUniqueId() + ".yml");
File testFile = new File(pl.getDataFolder() + File.separator + "homes", File.separator + offlinePlayer.getUniqueId().toString() + ".yml");
if (testFile.exists()) {
homesYml = testFile;
}
Expand Down Expand Up @@ -154,9 +154,12 @@ public boolean execute(CommandSender sender, String label, String[] args) {
if (sender.hasPermission("treeboteleport.staff.homes.other")) {
staff = true;
}
File homesYml = new File(pl.getDataFolder() + File.separator + "homes", File.separator + ((Player) sender).getUniqueId() + ".yml");
//File homesYml = new File(pl.getDataFolder() + File.separator + "homes", File.separator + ((Player) sender).getUniqueId().toString() + ".yml");
File homesYml = new File(pl.getPlayerDataFolder() + File.separator + ((Player) sender).getUniqueId().toString(), File.separator + "homes.yml");

if (args.length == 1 && staff) {
homesYml = new File(pl.getDataFolder() + File.separator + "homes", File.separator + (Bukkit.getOfflinePlayer(args[0])).getUniqueId() + ".yml");
//homesYml = new File(pl.getDataFolder() + File.separator + "homes", File.separator + (Bukkit.getOfflinePlayer(args[0])).getUniqueId().toString() + ".yml");
homesYml = new File(pl.getDataFolder() + File.separator + Bukkit.getOfflinePlayer(args[0]).getUniqueId().toString(), File.separator + "homes.yml");
owner = args[0].toLowerCase();
}

Expand Down Expand Up @@ -224,7 +227,7 @@ private void OpenHomesMenu(Player opener, String owner, YamlConfiguration yamlCo
if (yamlConfiguration.getString("homes." + home + "colour") != null) {
homeItemMeta.setDisplayName(ChatColor.valueOf(yamlConfiguration.getString("homes." + home + ".colour")) + yamlConfiguration.getString("homes." + home + ".name"));
} else {
homeItemMeta.setDisplayName(yamlConfiguration.getString("homes." + home + ".name"));
homeItemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', yamlConfiguration.getString("homes." + home + ".name")));
}
} else {
homeItemMeta.setDisplayName(home);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,15 @@ public boolean execute(CommandSender sender, String label, String[] args) {
theText = ChatColor.translateAlternateColorCodes('&', theText);

ItemStack item = ((Player) sender).getInventory().getItemInMainHand();
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(theText);
item.setItemMeta(meta);
((Player) sender).getInventory().setItemInMainHand(item);
if(item.getType() == Material.VILLAGER_SPAWN_EGG){
sender.sendMessage(pl.badge + "Sorry, you cannot rename villager spawn eggs.");
}
else {
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(theText);
item.setItemMeta(meta);
((Player) sender).getInventory().setItemInMainHand(item);
}
} else {
sender.sendMessage(ChatColor.RED + "You do not have access to this command. You require permission node " + ChatColor.GOLD + this.getPermission());
}
Expand Down
Loading

0 comments on commit 5384c45

Please sign in to comment.