Skip to content

Commit

Permalink
Strings from config!
Browse files Browse the repository at this point in the history
- Allow user translations!
  • Loading branch information
BuildTools committed May 25, 2021
1 parent 7c61806 commit 0a78dca
Show file tree
Hide file tree
Showing 18 changed files with 900 additions and 351 deletions.
19 changes: 16 additions & 3 deletions src/main/java/io/github/sefiraat/danktech/DankTech.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import co.aikar.commands.PaperCommandManager;
import io.github.sefiraat.danktech.commands.Commands;
import io.github.sefiraat.danktech.configuration.Config;
import io.github.sefiraat.danktech.configuration.ConfigStrings;
import io.github.sefiraat.danktech.finals.Recipes;
import io.github.sefiraat.danktech.listeners.CraftListener;
import io.github.sefiraat.danktech.listeners.ItemPickupListener;
Expand Down Expand Up @@ -32,6 +34,8 @@ public class DankTech extends JavaPlugin {
private PaperCommandManager commandManager;
private final Timer repeater = new Timer();
private Protection protection;
private Config configClass;

private boolean isUnitTest = false;

private boolean mcMMO = false;
Expand Down Expand Up @@ -59,6 +63,9 @@ public DankTech getInstance() {
public Protection getProtection() {
return protection;
}
public Config getConfigClass() {
return configClass;
}

public boolean isMcMMO() {
return mcMMO;
Expand Down Expand Up @@ -93,12 +100,11 @@ public void onEnable() {

instance = this;

saveDefaultConfig();
createDankStorageConfig();
createItemBlacklistConfig();
sortConfigs();
registerCommands();

protection = new Protection(this);
configClass = new Config(this);

new ItemPickupListener(this.getInstance());
new ItemRightClickListener(this.getInstance());
Expand Down Expand Up @@ -133,6 +139,13 @@ private void registerCommands() {
commandManager.registerCommand(new Commands(this.getInstance()));
}

private void sortConfigs() {
getConfig().options().copyDefaults(true);
saveConfig();
createDankStorageConfig();
createItemBlacklistConfig();
}

private void createDankStorageConfig() {
dankStorageConfigFile = new File(getDataFolder(), "DankStorages.yml");
if (!dankStorageConfigFile.exists()) {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/io/github/sefiraat/danktech/commands/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public Commands(DankTech parent) {
@Default
public void onDefault(CommandSender sender) {
if (sender instanceof Player) {
sender.sendMessage(Messages.MESSAGE_COMMAND_SUBCOMMAND);
sender.sendMessage(Messages.messageCommandSubcommand(parent));
}
}

Expand All @@ -41,7 +41,7 @@ public class GiveItem extends BaseCommand {
@Default
public void onDefault(CommandSender sender) {
if (sender instanceof Player) {
sender.sendMessage(Messages.MESSAGE_COMMAND_SELECT_ITEM);
sender.sendMessage(Messages.messageCommandSelectItem(parent));
}
}

Expand Down Expand Up @@ -81,7 +81,7 @@ public class RecoverPack extends BaseCommand {
@Default
public void onDefault(CommandSender sender) {
if (sender instanceof Player) {
sender.sendMessage(Messages.MESSAGE_COMMAND_SELECT_ITEM);
sender.sendMessage(Messages.messageCommandSelectItem(parent));
}
}

Expand Down Expand Up @@ -127,9 +127,9 @@ public void onDefault(CommandSender sender) {
c.createSection("BLACKLISTED_ITEMS" + "." + nextItem);
c.set("BLACKLISTED_ITEMS." + nextItem, stackToSave);
parent.saveItemBlacklistConfig();
p.sendMessage(Messages.MESSAGE_COMMAND_BLACKLIST_ITEM_SAVED);
p.sendMessage(Messages.messageCommandBlacklistItemSaved(parent));
} else {
p.sendMessage(Messages.MESSAGE_COMMAND_BLACKLIST_ITEM_MUST_HOLD);
p.sendMessage(Messages.messageCommandBlacklistMustHold(parent));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,13 @@

public class Config {

private final DankTech parent;
private ConfigStrings strings;
private final ConfigStrings strings;

public ConfigStrings getStrings() {
return strings;
}





public Config(DankTech parent) {
this.parent = parent;
strings = new ConfigStrings(parent);
}
public Config(DankTech parent) {
strings = new ConfigStrings(parent);
}
}
Loading

0 comments on commit 0a78dca

Please sign in to comment.