mirror of
https://github.com/JamesPeters98/ChestsPlusPlus.git
synced 2024-11-14 22:56:27 +01:00
Language File
Language File implementation almost complete
This commit is contained in:
parent
767e162c84
commit
b477ee1ed6
@ -5,6 +5,7 @@ import com.jamesdpeters.minecraft.chests.commands.AutoCraftCommand;
|
||||
import com.jamesdpeters.minecraft.chests.commands.ChestLinkCommand;
|
||||
import com.jamesdpeters.minecraft.chests.commands.ChestsPlusPlusCommand;
|
||||
import com.jamesdpeters.minecraft.chests.crafting.Crafting;
|
||||
import com.jamesdpeters.minecraft.chests.lang.LangFileProperties;
|
||||
import com.jamesdpeters.minecraft.chests.listeners.StorageListener;
|
||||
import com.jamesdpeters.minecraft.chests.listeners.HopperListener;
|
||||
import com.jamesdpeters.minecraft.chests.listeners.InventoryListener;
|
||||
@ -38,9 +39,6 @@ import org.bukkit.plugin.java.annotation.plugin.Description;
|
||||
import org.bukkit.plugin.java.annotation.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.annotation.plugin.author.Author;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
@Plugin(name = "ChestsPlusPlus", version = BuildConstants.VERSION)
|
||||
@ApiVersion(ApiVersion.Target.v1_14)
|
||||
@Description(value = "Minecraft Spigot mod that enhances chests and hoppers, with ChestLinks and Hopper filters!")
|
||||
@ -85,9 +83,9 @@ public class ChestsPlusPlus extends JavaPlugin {
|
||||
Stats.addCharts(metrics);
|
||||
|
||||
PLUGIN = this;
|
||||
// LangFile.createTemplateLangFile();
|
||||
LangFileProperties.createTemplateLangFile();
|
||||
Settings.initConfig(this);
|
||||
// LangFile.loadLangFile(Settings.getLangFileName());
|
||||
LangFileProperties.loadLangFile(Settings.getLangFileName());
|
||||
|
||||
//API initialisation
|
||||
API.register(this);
|
||||
|
@ -0,0 +1,125 @@
|
||||
package com.jamesdpeters.minecraft.chests.lang;
|
||||
|
||||
import com.jamesdpeters.minecraft.chests.ChestsPlusPlus;
|
||||
import com.jamesdpeters.minecraft.chests.maventemplates.BuildConstants;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Properties;
|
||||
|
||||
public class LangFileProperties {
|
||||
|
||||
private static File currentFile;
|
||||
|
||||
public static void serialize(Properties properties) {
|
||||
for (Message value : Message.values()) {
|
||||
properties.setProperty(value.toString(),value.getTaggedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static void deserialize(Properties properties){
|
||||
properties.forEach((key, value) -> {
|
||||
try {
|
||||
Message.valueOf((String) key).setMessage((String) value);
|
||||
} catch (IllegalArgumentException e) {
|
||||
ChestsPlusPlus.PLUGIN.getLogger().warning(MessageFormat.format("Language file contained invalid messages. Invalid message {0}:{1} has been removed and missing messages have been replaced", key, value));
|
||||
}
|
||||
});
|
||||
try {
|
||||
//Save the language file after reading to insert any missing values.
|
||||
Properties savedProperties = new Properties();
|
||||
serialize(savedProperties);
|
||||
if(currentFile != null) saveLangFile(savedProperties,currentFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadLangFile(String fileName){
|
||||
if(fileName.equals("default")){
|
||||
ChestsPlusPlus.PLUGIN.getLogger().info("Loaded default language file");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
currentFile = getLangFile(fileName,false);
|
||||
Properties properties = loadProperties(currentFile);
|
||||
deserialize(properties);
|
||||
ChestsPlusPlus.PLUGIN.getLogger().info("Loaded '"+fileName+"' language file");
|
||||
} catch (IOException e) {
|
||||
ChestsPlusPlus.PLUGIN.getLogger().warning("Failed to load language file: "+fileName+". It should be located in "+ChestsPlusPlus.PLUGIN.getDataFolder().getPath()+"/lang/");
|
||||
}
|
||||
}
|
||||
|
||||
private static Properties loadProperties(File file) throws IOException {
|
||||
Properties properties = new Properties();
|
||||
properties.load(new FileInputStream(file));
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This must be called before {@link #loadLangFile(String)} since @{@link Message} is static.
|
||||
*/
|
||||
public static void createTemplateLangFile() {
|
||||
try {
|
||||
Properties properties = new Properties();
|
||||
String comment =
|
||||
"#########################################\n" +
|
||||
"This is a template file for creating a new lang file!\n" +
|
||||
"To create a new language file simply create a copy of this file and rename it to your desired choice for example 'español.yml'\n" +
|
||||
"It should be located in the 'lang' folder, next to template.yml'\n" +
|
||||
"Then in config.yml 'language-file: default' would be renamed to 'language-file: español'\n" +
|
||||
"To help contribute to the plugin and provide new language files you can create a pull-request at https://github.com/JamesPeters98/ChestsPlusPlus or join our Discord!\n" +
|
||||
"\n" +
|
||||
"##########################################";
|
||||
serialize(properties);
|
||||
properties.store(new FileOutputStream(getLangFile("template", true)), comment);
|
||||
} catch (IOException ignored){
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveLangFile(Properties properties, File file) throws IOException {
|
||||
properties.store(new FileOutputStream(file),"Chests++ Language File (Version "+ BuildConstants.VERSION+")");
|
||||
}
|
||||
|
||||
private static File getLangFile(String fileName, boolean create) throws IOException {
|
||||
File pluginDataFolder = ChestsPlusPlus.PLUGIN.getDataFolder();
|
||||
File file = new File(pluginDataFolder, "lang/"+fileName+".properties");
|
||||
file.getParentFile().mkdirs();
|
||||
if(create && !file.exists()) file.createNewFile();
|
||||
return file;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException, URISyntaxException {
|
||||
LangFileProperties fileProperties = new LangFileProperties();
|
||||
fileProperties.generateEnglishLanguageFile();
|
||||
}
|
||||
|
||||
private LangFileProperties(){
|
||||
|
||||
}
|
||||
|
||||
private void generateEnglishLanguageFile() throws IOException, URISyntaxException {
|
||||
System.out.println("Generating English Language File: ");
|
||||
Path projectRoot = Paths.get(getClass().getClassLoader().getResource("").toURI()).getParent().getParent();
|
||||
File langFolder = new File(projectRoot.toString());
|
||||
File langFile = new File(langFolder, "src/main/resources/lang/english.properties");
|
||||
Properties properties = new Properties();
|
||||
serialize(properties);
|
||||
saveLangFile(properties, langFile);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package com.jamesdpeters.minecraft.chests.lang;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
public enum Message {
|
||||
//Messages.java
|
||||
CHEST_HAD_OVERFLOW("Chest item's wouldn't all fit into ChestLink!"),
|
||||
MUST_HOLD_SIGN("You must be holding a sign to do that!"),
|
||||
NO_PERMISSION("You don't have permission to do that!"),
|
||||
SORT("Sort method for {0} has been set to {1}", Tag.STORAGE_IDENTIFIER, Tag.SORT_METHOD),
|
||||
CANNOT_RENAME_GROUP_ALREADY_EXISTS("Error renaming group! {0} already exists!", Tag.STORAGE_IDENTIFIER),
|
||||
CANNOT_RENAME_GROUP_DOESNT_EXIST("Error renaming group! {0} doesn't exist!", Tag.STORAGE_IDENTIFIER),
|
||||
OWNER_HAS_TOO_MANY_CHESTS("Owner: {0} has reached the limit of groups allowed!", Tag.PLAYER_NAME),
|
||||
ALREADY_PART_OF_GROUP("This {0} is already a part of a group!", Tag.STORAGE_TYPE),
|
||||
|
||||
//StorageMessages.java
|
||||
STORAGE_ADDED("Successfully added {0} to group: {1} for {2}", Tag.STORAGE_TYPE, Tag.STORAGE_GROUP, Tag.PLAYER_NAME),
|
||||
STORAGE_REMOVED("Successfully removed {0} from group: {1} for {2}", Tag.STORAGE_TYPE, Tag.STORAGE_GROUP, Tag.PLAYER_NAME),
|
||||
REMOVED_GROUP("Successfully removed group {0} from your {1}'s!", Tag.STORAGE_GROUP, Tag.STORAGE_TYPE),
|
||||
GROUP_DOESNT_EXIST("{0} isn't a valid {1} group to remove!", Tag.STORAGE_GROUP, Tag.STORAGE_TYPE),
|
||||
FOUND_UNLINKED_STORAGE("This {0} wasn't linked to your system! It has been added under the {1} group!", Tag.STORAGE_TYPE, Tag.STORAGE_IDENTIFIER),
|
||||
ADDED_MEMBER("Successfully added {0} to {1} group {2}", Tag.PLAYER_NAME, Tag.STORAGE_TYPE, Tag.STORAGE_IDENTIFIER),
|
||||
REMOVED_MEMBER("Successfully removed {0} from {1} group {2}", Tag.PLAYER_NAME, Tag.STORAGE_TYPE, Tag.STORAGE_IDENTIFIER),
|
||||
CURRENT_MEMBERS("Current Members: {0}", Tag.PLAYER_LIST),
|
||||
ADDED_MEMBER_TO_ALL("Successfully added {0} to all {1} groups", Tag.PLAYER_NAME, Tag.STORAGE_TYPE),
|
||||
REMOVE_MEMBER_FROM_ALL("Successfully removed {0} from all {1} groups", Tag.PLAYER_NAME, Tag.STORAGE_TYPE),
|
||||
UNABLE_TO_ADD_MEMBER_TO_ALL("Unable to add player {0} to {1}!", Tag.PLAYER_NAME, Tag.STORAGE_TYPE),
|
||||
UNABLE_TO_REMOVE_MEMBER("Unable to remove player {0} from {1}! Were they already removed?", Tag.PLAYER_NAME, Tag.STORAGE_TYPE),
|
||||
LIST_MEMBERS_OF_GROUP("Members of {0} group {1}: {2}", Tag.STORAGE_TYPE, Tag.STORAGE_IDENTIFIER, Tag.PLAYER_LIST),
|
||||
NO_ADDITIONAL_MEMBERS("There are no additional members in the group: {0}", Tag.STORAGE_IDENTIFIER),
|
||||
SET_PUBLICITY("There are no additional members in the group: {0}", Tag.STORAGE_IDENTIFIER),
|
||||
INVALID_ID("Invalid {0} ID! Must not contain a colon ':' unless you are referencing another players group that you are a member of", Tag.STORAGE_TYPE),
|
||||
|
||||
//ChestLinkMessages
|
||||
LIST_OF_CHESTLINK("List of your ChestLinks:"),
|
||||
MUST_LOOK_AT_CHEST("You must be looking at the chest you want to ChestLink!"),
|
||||
INVALID_CHESTLINK("Invalid ChestLink - You must place a sign on the front of a chest / you should ensure there is space for a sign on front of the chest!"),
|
||||
|
||||
//AutoCraftMessages
|
||||
LIST_OF_AUTOCRAFTERS("List of your AutoCraft Stations:"),
|
||||
MUST_LOOK_AT_CRAFTING_TABLE("You must be looking at the Crafting Table you want to AutoCraft with!"),
|
||||
INVALID_AUTOCRAFTER("Invalid AutoCrafter - You must place a sign on any side of a Crafting Table, and it must not already by apart of a group!");
|
||||
|
||||
String message;
|
||||
Message(String defaultMessage){
|
||||
this(defaultMessage, new Tag[]{});
|
||||
}
|
||||
|
||||
Tag[] tags;
|
||||
Message(String defaultMessage, Tag... tags){
|
||||
message = defaultMessage;
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* This can be used to set different messages for different languages.
|
||||
* @param message - the template string for the message.
|
||||
*/
|
||||
public void setMessage(String message) {
|
||||
this.message = detagMessage(message, tags);
|
||||
}
|
||||
|
||||
public String getTaggedMessage(){
|
||||
return tagMessage(message, tags);
|
||||
}
|
||||
|
||||
private static String detagMessage(String string, Tag[] tags){
|
||||
for (int i = 0; i < tags.length; i++) {
|
||||
string = string.replaceAll("\\{"+tags[i]+"}", "{"+i+"}");
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
private static String tagMessage(String string, Tag[] tags){
|
||||
for (int i = 0; i < tags.length; i++) {
|
||||
String replace = "\\{"+i+"}";
|
||||
string = string.replaceAll(replace, "{"+tags[i]+"}");
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
public String getString(Object... args){
|
||||
return MessageFormat.format(message, args);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.jamesdpeters.minecraft.chests.lang;
|
||||
|
||||
public enum Tag {
|
||||
STORAGE_IDENTIFIER,
|
||||
SORT_METHOD,
|
||||
PLAYER_NAME,
|
||||
STORAGE_TYPE,
|
||||
STORAGE_GROUP,
|
||||
PLAYER_LIST,
|
||||
INVALID;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString().toLowerCase();
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.jamesdpeters.minecraft.chests.misc;
|
||||
|
||||
import com.jamesdpeters.minecraft.chests.lang.Message;
|
||||
import com.jamesdpeters.minecraft.chests.storage.chestlink.ChestLinkStorage;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -10,34 +11,34 @@ public class Messages {
|
||||
private static String TAG = "[Chests++]";
|
||||
|
||||
public static void CHEST_HAD_OVERFLOW(Player target){
|
||||
target.sendMessage(ChatColor.GOLD+TAG+" Chest item's wouldn't all fit into ChestLink!");
|
||||
target.sendMessage(ChatColor.GOLD+TAG+" "+ Message.CHEST_HAD_OVERFLOW.getString());
|
||||
}
|
||||
|
||||
public static void MUST_HOLD_SIGN(Player target){
|
||||
target.sendMessage(ChatColor.RED+TAG+" You must be hold a sign to do that!");
|
||||
target.sendMessage(ChatColor.RED+TAG+" "+Message.MUST_HOLD_SIGN.getString());
|
||||
}
|
||||
|
||||
public static void NO_PERMISSION(Player target){
|
||||
target.sendMessage(ChatColor.RED+""+ChatColor.BOLD+TAG+" You don't have permission to do that!");
|
||||
target.sendMessage(ChatColor.RED+""+ChatColor.BOLD+TAG+" "+Message.NO_PERMISSION.getString());
|
||||
}
|
||||
|
||||
public static void SORT(Player target, ChestLinkStorage storage){
|
||||
target.sendMessage(ChatColor.GREEN+"Sort method for "+ChatColor.WHITE+storage.getIdentifier()+ChatColor.GREEN+" has been set to "+ChatColor.WHITE+storage.getSortMethod().toString());
|
||||
target.sendMessage(ChatColor.GREEN+Message.SORT.getString(ChatColor.WHITE+storage.getIdentifier()+ChatColor.GREEN, ChatColor.WHITE+storage.getSortMethod().toString()));
|
||||
}
|
||||
|
||||
public static void CANNOT_RENAME_ALREADY_EXISTS(Player target, String newidentifier){
|
||||
target.sendMessage(ChatColor.RED+"Error renaming group! "+ChatColor.WHITE+newidentifier+ChatColor.RED+" already exists!");
|
||||
public static void CANNOT_RENAME_GROUP_ALREADY_EXISTS(Player target, String newidentifier){
|
||||
target.sendMessage(ChatColor.RED+Message.CANNOT_RENAME_GROUP_ALREADY_EXISTS.getString(ChatColor.WHITE+newidentifier+ChatColor.RED));
|
||||
}
|
||||
|
||||
public static void CANNOT_RENAME_GROUP_DOESNT_EXIST(Player target, String oldidentifier){
|
||||
target.sendMessage(ChatColor.RED+"Error renaming group! "+ChatColor.WHITE+oldidentifier+ChatColor.RED+" doesn't exist!");
|
||||
target.sendMessage(ChatColor.RED+Message.CANNOT_RENAME_GROUP_DOESNT_EXIST.getString(ChatColor.WHITE+oldidentifier+ChatColor.RED));
|
||||
}
|
||||
|
||||
public static void OWNER_HAS_TOO_MANY_CHESTS(Player target, OfflinePlayer owner){
|
||||
target.sendMessage(ChatColor.RED+"Owner: "+ChatColor.WHITE+owner.getName()+ChatColor.RED+" has reached the limit of groups allowed!");
|
||||
target.sendMessage(ChatColor.RED+Message.OWNER_HAS_TOO_MANY_CHESTS.getString(ChatColor.WHITE+owner.getName()+ChatColor.RED));
|
||||
}
|
||||
|
||||
public static void ALREADY_PART_OF_GROUP(Player target, String type){
|
||||
target.sendMessage(ChatColor.RED+""+ChatColor.BOLD+TAG+" This "+type+" is already apart of a group!");
|
||||
target.sendMessage(ChatColor.RED+""+ChatColor.BOLD+TAG+" "+Message.ALREADY_PART_OF_GROUP);
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ public class Settings {
|
||||
private static String SHOULD_AUTOCRAFT_ARMOUR_STAND = "display_autocraft_armour_stands";
|
||||
private static String INVISIBLE_FILTER_ITEM_FRAMES = "set-filter-itemframe-invisible";
|
||||
private static String WORLD_BLACKLIST = "world-blacklist";
|
||||
private static String LANG_FILE = "language-file";
|
||||
|
||||
private static Settings cf;
|
||||
private FileConfiguration configuration;
|
||||
@ -36,6 +37,7 @@ public class Settings {
|
||||
private static boolean shouldDisplayAutoCraftStand;
|
||||
private static boolean filterItemFrameInvisible;
|
||||
private static List<String> worldBlacklist;
|
||||
private static String langFileName;
|
||||
|
||||
public static void initConfig(Plugin plugin){
|
||||
cf = new Settings();
|
||||
@ -53,6 +55,7 @@ public class Settings {
|
||||
cf.configuration.addDefault(SHOULD_AUTOCRAFT_ARMOUR_STAND,true);
|
||||
cf.configuration.addDefault(INVISIBLE_FILTER_ITEM_FRAMES, false);
|
||||
cf.configuration.addDefault(WORLD_BLACKLIST, Collections.singletonList(""));
|
||||
cf.configuration.addDefault(LANG_FILE, "default");
|
||||
|
||||
cf.configuration.options().copyDefaults(true);
|
||||
cf.plugin.saveConfig();
|
||||
@ -77,6 +80,7 @@ public class Settings {
|
||||
shouldDisplayAutoCraftStand = cf.configuration.getBoolean(SHOULD_AUTOCRAFT_ARMOUR_STAND);
|
||||
filterItemFrameInvisible = cf.configuration.getBoolean(INVISIBLE_FILTER_ITEM_FRAMES);
|
||||
worldBlacklist = cf.configuration.getStringList(WORLD_BLACKLIST);
|
||||
langFileName = cf.configuration.getString(LANG_FILE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -104,6 +108,7 @@ public class Settings {
|
||||
return filterItemFrameInvisible;
|
||||
}
|
||||
public static List<String> getWorldBlacklist(){ return worldBlacklist; }
|
||||
public static String getLangFileName(){ return langFileName; }
|
||||
|
||||
public static boolean isBlacklistedWorld(World world){
|
||||
return worldBlacklist.contains(world.getName());
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.jamesdpeters.minecraft.chests.storage.abstracts;
|
||||
|
||||
import com.jamesdpeters.minecraft.chests.lang.Message;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Utils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -12,61 +13,61 @@ public abstract class StorageMessages {
|
||||
public abstract String getStorageName();
|
||||
|
||||
public void storageAdded(Player target, String group, String player){
|
||||
target.sendMessage(ChatColor.GREEN+TAG+" Succesfully added "+getStorageName()+" to group: "+ChatColor.WHITE+group+ChatColor.RED+" for "+ChatColor.WHITE+player);
|
||||
target.sendMessage(ChatColor.GREEN+TAG+" "+ Message.STORAGE_ADDED.getString(getStorageName(), ChatColor.WHITE+group+ChatColor.GREEN, ChatColor.WHITE+player));
|
||||
}
|
||||
|
||||
public void storageRemoved(Player target, String group, String player){
|
||||
target.sendMessage(ChatColor.RED+TAG+" Succesfully removed "+getStorageName()+" from group: "+ChatColor.WHITE+group+ChatColor.RED+" for "+ChatColor.WHITE+player);
|
||||
target.sendMessage(ChatColor.RED+TAG+" "+Message.STORAGE_REMOVED.getString(getStorageName(), ChatColor.WHITE+group+ChatColor.RED, ChatColor.WHITE+player));
|
||||
}
|
||||
|
||||
public void removedGroup(Player target, String toRemove){
|
||||
target.sendMessage(ChatColor.RED+""+ChatColor.BOLD+TAG+" Succesfully removed group "+toRemove+" from your "+getStorageName()+"'s!");
|
||||
target.sendMessage(ChatColor.RED+""+ChatColor.BOLD+TAG+" "+Message.REMOVED_GROUP.getString(toRemove, getStorageName()));
|
||||
}
|
||||
|
||||
public void groupDoesntExist(Player target, String toRemove){
|
||||
target.sendMessage(ChatColor.RED+""+ChatColor.BOLD+TAG+" "+toRemove+" isn't a valid "+getStorageName()+" group to remove!");
|
||||
target.sendMessage(ChatColor.RED+""+ChatColor.BOLD+TAG+" "+Message.GROUP_DOESNT_EXIST.getString(toRemove, getStorageName()));
|
||||
}
|
||||
|
||||
public void foundUnlinkedStorage(Player target, String group){
|
||||
target.sendMessage(ChatColor.GOLD+TAG+" This "+getStorageName()+" wasn't linked to your system! It has been added under the "+group+" group!");
|
||||
target.sendMessage(ChatColor.GOLD+TAG+" "+Message.FOUND_UNLINKED_STORAGE.getString(getStorageName(), group));
|
||||
}
|
||||
|
||||
public void addedMember(Player target, AbstractStorage storage, String added){
|
||||
target.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+TAG+" Succesfully added "+ChatColor.WHITE+added+ChatColor.GREEN+" to "+getStorageName()+" group "+ChatColor.WHITE+storage.getIdentifier());
|
||||
target.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+TAG+" Current Members: "+ Utils.prettyPrintPlayers(ChatColor.GREEN,storage.getMembers()));
|
||||
target.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+TAG+" "+Message.ADDED_MEMBER.getString(ChatColor.WHITE+added+ChatColor.GREEN, getStorageName(), ChatColor.WHITE+storage.getIdentifier()));
|
||||
target.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+TAG+" "+Message.CURRENT_MEMBERS.getString(Utils.prettyPrintPlayers(ChatColor.GREEN,storage.getMembers())));
|
||||
}
|
||||
|
||||
public void addMemberToAll(Player target, OfflinePlayer added){
|
||||
target.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+TAG+" Succesfully added "+ChatColor.WHITE+added.getName()+ChatColor.GREEN+" to all "+getStorageName()+" groups ");
|
||||
target.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+TAG+" "+Message.ADDED_MEMBER_TO_ALL.getString(ChatColor.WHITE+added.getName()+ChatColor.GREEN, getStorageName()));
|
||||
}
|
||||
|
||||
public void unableToAddMember(Player target, String toAdd){
|
||||
target.sendMessage(ChatColor.RED+""+ChatColor.BOLD+TAG+" Unable to add player "+toAdd+" to "+getStorageName()+"!");
|
||||
target.sendMessage(ChatColor.RED+""+ChatColor.BOLD+TAG+" "+Message.UNABLE_TO_ADD_MEMBER_TO_ALL.getString(toAdd, getStorageName()));
|
||||
}
|
||||
|
||||
public void removedMember(Player target, AbstractStorage storage, String added){
|
||||
target.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+TAG+" Succesfully removed "+ChatColor.WHITE+added+ChatColor.GREEN+" from "+getStorageName()+" group "+ChatColor.WHITE+storage.getIdentifier());
|
||||
target.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+TAG+" Current Members: "+ Utils.prettyPrintPlayers(ChatColor.GREEN,storage.getMembers()));
|
||||
target.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+TAG+" "+Message.REMOVED_MEMBER.getString(ChatColor.WHITE+added+ChatColor.GREEN, getStorageName(), ChatColor.WHITE+storage.getIdentifier()));
|
||||
target.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+TAG+" "+Message.CURRENT_MEMBERS.getString(Utils.prettyPrintPlayers(ChatColor.GREEN,storage.getMembers())));
|
||||
}
|
||||
|
||||
public void removeMemberFromAll(Player target, OfflinePlayer added){
|
||||
target.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+TAG+" Succesfully removed "+ChatColor.WHITE+added.getName()+ChatColor.GREEN+" from all "+getStorageName()+" groups ");
|
||||
target.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+TAG+" "+Message.REMOVE_MEMBER_FROM_ALL.getString(ChatColor.WHITE+added.getName()+ChatColor.GREEN, getStorageName()));
|
||||
}
|
||||
|
||||
public void unableToRemoveMember(Player target, String toAdd){
|
||||
target.sendMessage(ChatColor.RED+""+ChatColor.BOLD+TAG+" Unable to remove player "+toAdd+" from "+getStorageName()+"! Were they already removed?");
|
||||
target.sendMessage(ChatColor.RED+""+ChatColor.BOLD+TAG+" "+Message.UNABLE_TO_REMOVE_MEMBER.getString(toAdd, getStorageName()));
|
||||
}
|
||||
|
||||
public void listMembers(Player target, AbstractStorage storage){
|
||||
if(storage.getMembers() != null){
|
||||
target.sendMessage(ChatColor.GREEN+"Members of "+getStorageName()+" group "+ChatColor.WHITE+storage.getIdentifier()+": "+Utils.prettyPrintPlayers(ChatColor.GREEN,storage.getMembers()));
|
||||
target.sendMessage(ChatColor.GREEN+Message.LIST_MEMBERS_OF_GROUP.getString(getStorageName(), ChatColor.WHITE+storage.getIdentifier(), Utils.prettyPrintPlayers(ChatColor.GREEN,storage.getMembers())));
|
||||
} else {
|
||||
target.sendMessage(ChatColor.YELLOW+"There are no additional members in the group: "+ChatColor.WHITE+storage.getIdentifier());
|
||||
target.sendMessage(ChatColor.YELLOW+Message.NO_ADDITIONAL_MEMBERS.getString(ChatColor.WHITE+storage.getIdentifier()));
|
||||
}
|
||||
}
|
||||
|
||||
public void setPublic(Player target, AbstractStorage storage){
|
||||
target.sendMessage(ChatColor.GREEN+"Publicity for "+getStorageName()+" group "+storage.getIdentifier()+" is set to: "+ChatColor.WHITE+storage.isPublic());
|
||||
target.sendMessage(ChatColor.GREEN+Message.SET_PUBLICITY.getString(getStorageName(), storage.getIdentifier(), ChatColor.WHITE+""+storage.isPublic()));
|
||||
}
|
||||
|
||||
public abstract void invalidID(Player target);
|
||||
|
@ -10,7 +10,6 @@ import com.jamesdpeters.minecraft.chests.serialize.Config;
|
||||
import com.jamesdpeters.minecraft.chests.serialize.ConfigStorage;
|
||||
import com.jamesdpeters.minecraft.chests.serialize.LocationInfo;
|
||||
import com.jamesdpeters.minecraft.chests.storage.StorageUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
@ -22,7 +21,6 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.type.WallSign;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
@ -278,7 +276,7 @@ public abstract class StorageType<T extends AbstractStorage> {
|
||||
return false;
|
||||
}
|
||||
if (map.containsKey(newIdentifier)) {
|
||||
Messages.CANNOT_RENAME_ALREADY_EXISTS(player, newIdentifier);
|
||||
Messages.CANNOT_RENAME_GROUP_ALREADY_EXISTS(player, newIdentifier);
|
||||
return false;
|
||||
}
|
||||
T storage = map.get(oldIdentifier);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.jamesdpeters.minecraft.chests.storage.autocraft;
|
||||
|
||||
import com.jamesdpeters.minecraft.chests.lang.Message;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Messages;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Permissions;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Settings;
|
||||
@ -127,13 +128,13 @@ public class AutoCraftingStorageType extends StorageType<AutoCraftingStorage> {
|
||||
|
||||
@Override
|
||||
public void invalidID(Player target) {
|
||||
target.sendMessage(ChatColor.RED+"Invalid AutoCrafter ID! Must not contain a colon ':' unless you are referencing another players group that you are a member off");
|
||||
target.sendMessage(ChatColor.RED+ Message.INVALID_ID.getString(getStorageName()));
|
||||
target.sendMessage(ChatColor.RED+"/autocraft add <owner>:<group>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void listStorageGroups(Player target) {
|
||||
target.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+"List of your AutoCraft Stations:");
|
||||
target.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+Message.LIST_OF_AUTOCRAFTERS);
|
||||
for(AutoCraftingStorage storage : Config.getAutoCraft().getStorageMap(target.getUniqueId()).values()){
|
||||
if(storage != null){
|
||||
target.sendMessage(ChatColor.GREEN+storage.getIdentifier()+ChatColor.WHITE);
|
||||
@ -143,12 +144,12 @@ public class AutoCraftingStorageType extends StorageType<AutoCraftingStorage> {
|
||||
|
||||
@Override
|
||||
public void mustLookAtBlock(Player player) {
|
||||
player.sendMessage(ChatColor.RED+TAG+" You must be looking at the Crafting Table you want to AutoCraft with!");
|
||||
player.sendMessage(ChatColor.RED+TAG+" "+Message.MUST_LOOK_AT_CRAFTING_TABLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidSignPlacement(Player player) {
|
||||
player.sendMessage(ChatColor.GOLD+""+ChatColor.BOLD+TAG+" Invalid AutoCrafter - You must place a sign on any side of a Crafting Table, and it must not already by apart of a group!");
|
||||
player.sendMessage(ChatColor.GOLD+""+ChatColor.BOLD+TAG+" "+Message.INVALID_AUTOCRAFTER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.jamesdpeters.minecraft.chests.storage.chestlink;
|
||||
|
||||
import com.jamesdpeters.minecraft.chests.lang.Message;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Permissions;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Settings;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Values;
|
||||
@ -128,13 +129,13 @@ public class ChestLinkStorageType extends StorageType<ChestLinkStorage> {
|
||||
|
||||
@Override
|
||||
public void invalidID(Player target) {
|
||||
target.sendMessage(ChatColor.RED+"Invalid ChestLink ID! Must not contain a colon ':' unless you are referencing another players group that you are a member off");
|
||||
target.sendMessage(ChatColor.RED+ Message.INVALID_ID.getString(getStorageName()));
|
||||
target.sendMessage(ChatColor.RED+"/chestlink add <owner>:<group>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void listStorageGroups(Player target) {
|
||||
target.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+"List of your ChestLinks:");
|
||||
target.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+Message.LIST_OF_CHESTLINK);
|
||||
for(ChestLinkStorage storage : Config.getChestLink().getStorageMap(target.getUniqueId()).values()){
|
||||
if(storage != null){
|
||||
target.sendMessage(ChatColor.GREEN+storage.getIdentifier()+ChatColor.WHITE+" - "+storage.getTotalItems()+" items");
|
||||
@ -144,12 +145,12 @@ public class ChestLinkStorageType extends StorageType<ChestLinkStorage> {
|
||||
|
||||
@Override
|
||||
public void mustLookAtBlock(Player player) {
|
||||
player.sendMessage(ChatColor.RED+TAG+" You must be looking at the chest you want to ChestLink!");
|
||||
player.sendMessage(ChatColor.RED+TAG+" "+Message.MUST_LOOK_AT_CHEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidSignPlacement(Player player) {
|
||||
player.sendMessage(ChatColor.GOLD+""+ChatColor.BOLD+TAG+" Invalid ChestLink - You must place a sign on the front of a chest / you should ensure there is space for a sign on front of the chest!");
|
||||
player.sendMessage(ChatColor.GOLD+""+ChatColor.BOLD+TAG+" "+Message.INVALID_CHESTLINK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
#Chests++ Language File (Version 2.2.1-Release)
|
||||
#Tue Jul 28 19:30:22 BST 2020
|
||||
STORAGE_REMOVED=Successfully removed {storage_type} from group\: {storage_group} for {player_name}
|
||||
CANNOT_RENAME_GROUP_DOESNT_EXIST=Error renaming group\! {storage_identifier} doesn't exist\!
|
||||
LIST_MEMBERS_OF_GROUP=Members of {storage_type} group {storage_identifier}\: {player_list}
|
||||
SORT=Sort method for {storage_identifier} has been set to {sort_method}
|
||||
LIST_OF_CHESTLINK=List of your ChestLinks\:
|
||||
LIST_OF_AUTOCRAFTERS=List of your AutoCraft Stations\:
|
||||
OWNER_HAS_TOO_MANY_CHESTS=Owner\: {player_name} has reached the limit of groups allowed\!
|
||||
MUST_LOOK_AT_CRAFTING_TABLE=You must be looking at the Crafting Table you want to AutoCraft with\!
|
||||
CHEST_HAD_OVERFLOW=Chest item's wouldn't all fit into ChestLink\!
|
||||
GROUP_DOESNT_EXIST={storage_group} isn't a valid {storage_type} group to remove\!
|
||||
INVALID_ID=Invalid {storage_type} ID\! Must not contain a colon '\:' unless you are referencing another players group that you are a member of
|
||||
UNABLE_TO_ADD_MEMBER_TO_ALL=Unable to add player {player_name} to {storage_type}\!
|
||||
REMOVED_MEMBER=Successfully removed {player_name} from {storage_type} group {storage_identifier}
|
||||
STORAGE_ADDED=Successfully added {storage_type} to group\: {storage_group} for {player_name}
|
||||
NO_ADDITIONAL_MEMBERS=There are no additional members in the group\: {storage_identifier}
|
||||
REMOVE_MEMBER_FROM_ALL=Successfully removed {player_name} from all {storage_type} groups
|
||||
CURRENT_MEMBERS=Current Members\: {player_list}
|
||||
CANNOT_RENAME_GROUP_ALREADY_EXISTS=Error renaming group\! {storage_identifier} already exists\!
|
||||
ADDED_MEMBER=Successfully added {player_name} to {storage_type} group {storage_identifier}
|
||||
UNABLE_TO_REMOVE_MEMBER=Unable to remove player {player_name} from {storage_type}\! Were they already removed?
|
||||
INVALID_AUTOCRAFTER=Invalid AutoCrafter - You must place a sign on any side of a Crafting Table, and it must not already by apart of a group\!
|
||||
NO_PERMISSION=You don't have permission to do that\!
|
||||
MUST_LOOK_AT_CHEST=You must be looking at the chest you want to ChestLink\!
|
||||
FOUND_UNLINKED_STORAGE=This {storage_type} wasn't linked to your system\! It has been added under the {storage_identifier} group\!
|
||||
INVALID_CHESTLINK=Invalid ChestLink - You must place a sign on the front of a chest / you should ensure there is space for a sign on front of the chest\!
|
||||
ADDED_MEMBER_TO_ALL=Successfully added {player_name} to all {storage_type} groups
|
||||
SET_PUBLICITY=There are no additional members in the group\: {storage_identifier}
|
||||
REMOVED_GROUP=Successfully removed group {storage_group} from your {storage_type}'s\!
|
||||
MUST_HOLD_SIGN=You must be holding a sign to do that\!
|
||||
ALREADY_PART_OF_GROUP=This {storage_type} is already a part of a group\!
|
Loading…
Reference in New Issue
Block a user