Skip to content

Commit

Permalink
Added lang file
Browse files Browse the repository at this point in the history
  • Loading branch information
bzigus committed Sep 2, 2020
1 parent 8a19c06 commit 31da5ea
Show file tree
Hide file tree
Showing 16 changed files with 84 additions and 75 deletions.
8 changes: 8 additions & 0 deletions out/production/DisplayShopAddon/lang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
LinkShop:
incorrectID: "&4That is not a proper ID"
notChest: "&4The block you are looking at is not a chest"
incorrectUsage: "&4Incorrect Usage: /linkshop (1-5) (ShopID)"
success: "&aSuccessfully linked"
UnlinkShop:
incorrectUsage: "&4Incorrect Usage: /linkshop (1-5) (ShopID)"
success: "&aSuccessfully unlinked"
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion out/production/DisplayShopAddon/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: DisplayShopAddon
version: 1.2.0
version: 1.3.0
description: Addon to the DisplayShop Plugin
author: bugzigus
depend: [DisplayShops]
Expand Down
8 changes: 8 additions & 0 deletions src/lang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
LinkShop:
incorrectID: "&4That is not a proper ID"
notChest: "&4The block you are looking at is not a chest"
incorrectUsage: "&4Incorrect Usage: /linkshop (1-5) (ShopID)"
success: "&aSuccessfully linked"
UnlinkShop:
incorrectUsage: "&4Incorrect Usage: /linkshop (1-5) (ShopID)"
success: "&aSuccessfully unlinked"
17 changes: 10 additions & 7 deletions src/me/bugzigus/DisplayShopAddon/Commands/LinkCommand.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.bugzigus.DisplayShopAddon.Commands;

import me.bugzigus.DisplayShopAddon.ReadLang;
import me.bugzigus.DisplayShopAddon.YmlFIle;
import org.bukkit.ChatColor;
import org.bukkit.Material;
Expand All @@ -23,6 +24,8 @@ public class LinkCommand implements CommandExecutor {

UUID key;

ReadLang rl = new ReadLang();

Block block = null;
int x, y, z;

Expand Down Expand Up @@ -63,36 +66,36 @@ public boolean onCommand(CommandSender sender, Command command, String s, String
//Write it to the .yml file
YmlFIle.fileWrite(player, block, selectedShop, number);

player.sendMessage(rl.readFiles("LinkShop.success"));

//All of messages you could receive

} else {

player.sendMessage(ChatColor.DARK_RED + "That ID is not in the system");
player.sendMessage(rl.readFiles("LinkShop.incorrectID"));

}
} else {

player.sendMessage(ChatColor.DARK_RED + "The block you are looking at is not a chest!");
player.sendMessage(rl.readFiles("LinkShop.notChest"));

}

} else {

player.sendMessage(ChatColor.DARK_RED + "Are you sure you add a number");
sender.sendMessage(ChatColor.DARK_RED + "Command Usage: /linkshop (1-5) (ShopID)");
player.sendMessage(rl.readFiles("LinkShop.incorrectUsage"));

}

} else {

player.sendMessage(ChatColor.DARK_RED + "That is not a correct UUID");
player.sendMessage(rl.readFiles("LinkShop.incorrectUsage"));
}

}
} else {

sender.sendMessage(ChatColor.DARK_RED + "You did not add a shop ID to link too. Do /displayshops copy");
sender.sendMessage(ChatColor.DARK_RED + "Command Usage: /linkshop (1-5) (ShopID)");
sender.sendMessage(rl.readFiles("LinkShop.incorrectUsage"));

}
return true;
Expand Down
9 changes: 6 additions & 3 deletions src/me/bugzigus/DisplayShopAddon/Commands/RemoveCommand.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.bugzigus.DisplayShopAddon.Commands;

import me.bugzigus.DisplayShopAddon.ReadLang;
import me.bugzigus.DisplayShopAddon.YmlFIle;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
Expand All @@ -10,6 +11,8 @@
public class RemoveCommand implements CommandExecutor {


ReadLang rl = new ReadLang();

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

Expand All @@ -23,19 +26,19 @@ public boolean onCommand(CommandSender sender, Command command, String s, String

YmlFIle.fileClear(player, number);

player.sendMessage(rl.readFiles("UnlinkShop.success"));

}

else {

player.sendMessage(ChatColor.DARK_RED + "That isn't a number!");

player.sendMessage(rl.readFiles("UnlinkShop.incorrectUsage"));

}

} else {

player.sendMessage(ChatColor.DARK_RED + "Make sure you add the shop number!");
player.sendMessage(rl.readFiles("UnlinkShop.incorrectUsage"));

}
return true;
Expand Down
4 changes: 4 additions & 0 deletions src/me/bugzigus/DisplayShopAddon/DisplayShopAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public final void onEnable() {
config.options().copyDefaults(true);
saveConfig();

ReadLang rl = new ReadLang();

rl.saveDefault();

readLocations = new ReadLocations();

readLocations.readFiles();
Expand Down
45 changes: 45 additions & 0 deletions src/me/bugzigus/DisplayShopAddon/ReadLang.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package me.bugzigus.DisplayShopAddon;

import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class ReadLang {
private Map<String, String> langMap = new HashMap<String, String>();
Plugin plugin = DisplayShopAddon.pluginInstance();

File directory = new File(plugin.getDataFolder().getPath());
File f = new File(directory + File.separator +"lang.yml");

String[] langOptions;

public void saveDefault(){

if (!f.exists()) {

FileConfiguration langFile = YamlConfiguration.loadConfiguration(f);

plugin.saveResource("lang.yml", false);

}

}

public String readFiles(String name) {

FileConfiguration langFile = YamlConfiguration.loadConfiguration(f);

String lang = langFile.getString(name);

lang = ChatColor.translateAlternateColorCodes('&', lang);

return lang;
}

}
4 changes: 1 addition & 3 deletions src/me/bugzigus/DisplayShopAddon/ReadLocations.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@
public class ReadLocations {

private Map<Location, Shop> storage = new HashMap<Location, Shop>();
Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("DisplayShopAddon");
Plugin plugin = DisplayShopAddon.pluginInstance();
File directory = new File(plugin.getDataFolder() + File.separator + "PlayerDatabase");
private final File[] files = directory.listFiles();



public void readFiles() {

for (File f : files) {
Expand Down
60 changes: 0 additions & 60 deletions src/me/bugzigus/DisplayShopAddon/YmlFIle.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public static void fileClear(Player player, int number) {

try {
playerData.save(f);
player.sendMessage("Successfully unlinked: " + playerData.getString("Shop" + number + ".UUID"));
} catch (IOException exception) {
exception.printStackTrace();
}
Expand Down Expand Up @@ -120,7 +119,6 @@ public static boolean fileWrite(Player player, Block block, Shop shop, int numbe
playerData.set("Shop"+ number + ".BlockWorld", blockWorld);


player.sendMessage(ChatColor.GREEN + "Successfully linked this chest to " + shop.getShopId());
playerData.save(f);

} catch (IOException exception) {
Expand All @@ -139,8 +137,6 @@ public static boolean fileWrite(Player player, Block block, Shop shop, int numbe
playerData.createSection("Shop1");
} else {

player.sendMessage("Successfully set shop link " + number);

}
playerData.set("Shop1.Enabled", true);
playerData.set("Shop1.UUID", shopUUID);
Expand All @@ -154,16 +150,12 @@ public static boolean fileWrite(Player player, Block block, Shop shop, int numbe
playerData.set("Shop1.BlockWorld", blockWorld);

playerData.save(f);
player.sendMessage(ChatColor.GREEN + "Successfully linked this chest to " + shop.getShopId());

} else if (number == 2) {

if (!playerData.isConfigurationSection("Shop2")) {
playerData.createSection("Shop2");
} else {

player.sendMessage("Successfully set shop link " + number);

}
playerData.set("Shop2.Enabled", true);

Expand All @@ -178,16 +170,11 @@ public static boolean fileWrite(Player player, Block block, Shop shop, int numbe
playerData.set("Shop2.BlockWorld", blockWorld);
playerData.save(f);

player.sendMessage(ChatColor.GREEN + "Successfully linked this chest to " + shop.getShopId());

} else if (number == 3) {

if (!playerData.isConfigurationSection("Shop3")) {
playerData.createSection("Shop3");
} else {

player.sendMessage("Successfully set shop link " + number);

}
playerData.set("Shop3.Enabled", true);

Expand All @@ -202,16 +189,12 @@ public static boolean fileWrite(Player player, Block block, Shop shop, int numbe
playerData.set("Shop3.BlockWorld", blockWorld);
playerData.save(f);

player.sendMessage(ChatColor.GREEN + "Successfully linked this chest to " + shop.getShopId());

} else if (number == 4) {

if (!playerData.isConfigurationSection("Shop4")) {
playerData.createSection("Shop4");
} else {

player.sendMessage("Successfully set shop link " + number);

}
playerData.set("Shop4.Enabled", true);

Expand All @@ -226,16 +209,12 @@ public static boolean fileWrite(Player player, Block block, Shop shop, int numbe
playerData.set("Shop4.BlockWorld", blockWorld);
playerData.save(f);

player.sendMessage(ChatColor.GREEN + "Successfully linked this chest to " + shop.getShopId());

} else if (number == 5) {

if (!playerData.isConfigurationSection("Shop5")) {
playerData.createSection("Shop5");
} else {

player.sendMessage("Successfully set shop link " + number);

}
playerData.set("Shop5.Enabled", true);

Expand All @@ -250,8 +229,6 @@ public static boolean fileWrite(Player player, Block block, Shop shop, int numbe
playerData.set("Shop5.BlockWorld", blockWorld);
playerData.save(f);

player.sendMessage(ChatColor.GREEN + "Successfully linked this chest to " + shop.getShopId());

}
}
catch (IOException e){
Expand All @@ -265,43 +242,6 @@ public static boolean fileWrite(Player player, Block block, Shop shop, int numbe
return true;
}

public static void fileRead(Player player) {

String playerUUID = player.getUniqueId().toString();

Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("DisplayShopAddon");
File f = new File(plugin.getDataFolder() + File.separator + "PlayerDatabase" + File.separator + playerUUID + ".yml");

//File userdata = new File(Bukkit.getServer().getPluginManager().getPlugin("DisplayShopAddon").getDataFolder() + File.separator + "PlayerDatabase");


FileConfiguration playerData = YamlConfiguration.loadConfiguration(f);

if (f.exists()) {

String shopUUID = playerData.getString("Shop.UUID");
Double shopX = playerData.getDouble("Shop.ShopX");
Double shopY = playerData.getDouble("Shop.ShopY");
Double shopZ = playerData.getDouble("Shop.ShopZ");
Double blockX = playerData.getDouble("Shop.BlockX");
Double blockY = playerData.getDouble("Shop.BlockY");
Double blockZ = playerData.getDouble("Shop.BlockZ");

player.sendMessage(ChatColor.GREEN + "Success!");
player.sendMessage("Shop UUID: " + shopUUID);
player.sendMessage("Shop XYZ: " + shopX + ", " + shopY + ", " + shopZ);
player.sendMessage("Block XYZ: " + blockX + ", " + blockY + ", " + blockZ);

} else {

player.sendMessage("No info Found :( (Does the file Exist?)" + f.exists());

}


}


public static boolean isNumeric(String strNum) {
if (strNum == null) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: DisplayShopAddon
version: 1.2.0
version: 1.3.0
description: Addon to the DisplayShop Plugin
author: bugzigus
depend: [DisplayShops]
Expand Down

0 comments on commit 31da5ea

Please sign in to comment.