-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes some issues + menu can now be renamed
Fixes #14 Closes #11
- Loading branch information
Showing
6 changed files
with
36 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name: EnchantGUI | ||
version: 1.0 | ||
version: 1.1 | ||
main: me.tychsen.enchantgui.Main | ||
|
||
author: Dentych | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,50 @@ | ||
package me.tychsen.enchantgui; | ||
|
||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.configuration.file.FileConfiguration; | ||
import org.bukkit.configuration.file.FileConfigurationOptions; | ||
import org.bukkit.enchantments.Enchantment; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
public class EshopConfig { | ||
private static EshopConfig instance; | ||
private JavaPlugin plugin; | ||
private FileConfiguration config; | ||
|
||
public EshopConfig() { | ||
instance = this; | ||
this.plugin = Main.getInstance(); | ||
config = plugin.getConfig(); | ||
} | ||
|
||
public int getPrice(Enchantment ench, int level) { | ||
return config.getInt(ench.getName().toLowerCase() + ".level" + level); | ||
String path = ench.getName().toLowerCase() + ".level" + level; | ||
return config.getInt(path); | ||
} | ||
|
||
public void reloadConfig() { | ||
plugin.reloadConfig(); | ||
config = plugin.getConfig(); | ||
public String getMenuName() { | ||
String path = "menu-name"; | ||
if (config.contains(path) && config.isSet(path) && config.isString(path)) { | ||
if (config.getString(path).length() > 32) { | ||
return config.getString(path).substring(0, 32); | ||
} else { | ||
return config.getString(path); | ||
} | ||
} else { | ||
return "EnchantGUI"; | ||
} | ||
} | ||
|
||
public void reloadConfig(CommandSender sender) { | ||
if (sender.isOp() || sender.hasPermission("eshop.admin")) { | ||
plugin.reloadConfig(); | ||
config = plugin.getConfig(); | ||
sender.sendMessage(EshopSystem.start + "Configuration file has been reloaded!"); | ||
} | ||
} | ||
|
||
public static EshopConfig getInstance() { | ||
return instance; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters