Skip to content

Commit

Permalink
Refactor to make ready for release
Browse files Browse the repository at this point in the history
  • Loading branch information
Bestem0r committed Jan 27, 2023
1 parent 85af0b2 commit 9f148d3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
<dependency>
<groupId>com.github.Bestem0r</groupId>
<artifactId>BestemorCore</artifactId>
<version>58279fde88</version>
<version>b2ac48137e</version>
<scope>compile</scope>
</dependency>

Expand Down
33 changes: 19 additions & 14 deletions src/main/java/net/bestemor/villagermarket/VMPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected void onPluginEnable() {
this.playerListener = new PlayerListener(this);
registerEvents();

Bukkit.getLogger().warning("[VillagerMarket] §cYou are running a §aBETA 1.11.5-#8 of VillagerMarket! Please expect and report all bugs in my discord server");
//Bukkit.getLogger().warning("[VillagerMarket] §cYou are running a §aBETA 1.11.5-#8 of VillagerMarket! Please expect and report all bugs in my discord server");

Bukkit.getScheduler().runTaskLater(this, () -> {
if (Bukkit.getPluginManager().getPlugin("VillagerBank") != null) {
Expand All @@ -63,17 +63,7 @@ protected void onPluginEnable() {
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null){
new PlaceholderManager(this).register();
}

File materials = new File(getDataFolder(), "materials.yml");
if (materials.exists()) {
FileConfiguration config = YamlConfiguration.loadConfiguration(materials);
ConfigurationSection section = config.getConfigurationSection("materials");
if (section != null) {
for (String key : section.getKeys(false)) {
localizedMaterials.put(key, section.getString(key));
}
}
}
loadMappings();

VillagerMarketAPI.init(this);
}
Expand All @@ -95,6 +85,20 @@ protected void onPluginDisable() {
if (getConfig().getBoolean("auto_log")) saveLog();
}

private void loadMappings() {
localizedMaterials.clear();
File materials = new File(getDataFolder(), "materials.yml");
if (materials.exists()) {
FileConfiguration config = YamlConfiguration.loadConfiguration(materials);
ConfigurationSection section = config.getConfigurationSection("materials");
if (section != null) {
for (String key : section.getKeys(false)) {
localizedMaterials.put(key, section.getString(key));
}
}
}
}

private void setupCommands() {
CommandModule module = new CommandModule.Builder(this)
.addSubCommand("create", new CreateCommand(this))
Expand All @@ -118,6 +122,7 @@ private void setupCommands() {

public void reloadConfiguration() {
reloadConfig();
loadMappings();
}

/** Setup Vault integration */
Expand All @@ -137,11 +142,11 @@ private void registerEvents() {
pluginManager.registerEvents(playerListener, this);
pluginManager.registerEvents(chatListener, this);
}
/*

@Override
protected int getSpigotResourceID() {
return 82965;
}*/
}

/** Saves log to /log/ folder and clears log */
public void saveLog() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import de.tr7zw.nbtapi.NBTItem;
import net.bestemor.core.config.ConfigManager;
import net.bestemor.core.config.VersionUtils;
import net.bestemor.core.utils.UpdateChecker;
import net.bestemor.villagermarket.VMPlugin;
import net.bestemor.villagermarket.event.PlaceShopEggEvent;
import net.bestemor.villagermarket.menu.Shopfront;
Expand Down Expand Up @@ -256,7 +257,7 @@ public void onItemClick(PlayerInteractEvent event) {
public void onJoin(PlayerJoinEvent event) {

Player player = event.getPlayer();
/*if (player.hasPermission("villagermarket.admin") && !ConfigManager.getBoolean("disable_update_announce")) {
if (player.hasPermission("villagermarket.admin") && !ConfigManager.getBoolean("disable_update_announce")) {
new UpdateChecker(plugin, 82965).getVersion(version -> {
String currentVersion = plugin.getDescription().getVersion();
if (!currentVersion.equalsIgnoreCase(version)) {
Expand All @@ -267,7 +268,7 @@ public void onJoin(PlayerJoinEvent event) {
player.sendMessage(ConfigManager.getString("plugin_prefix") + " " + downloadVersion);
}
});
}*/
}
if (plugin.getShopManager().getExpiredStorages().containsKey(player.getUniqueId())) {
player.sendMessage(ConfigManager.getMessage("messages.expired"));
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ auto_discount:
min: 10
max: 20
#Duration of discount
duration: 1m
duration: 1h
#How often new discounts should be added
interval: 2m
interval: 12h
#Amount of items which should have discounts
item_amount: 3
#Amount of random shops which should have discounts applied
Expand Down

0 comments on commit 9f148d3

Please sign in to comment.