mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-22 10:22:29 +00:00
Simplified saving of item_names.txt file
This commit is contained in:
parent
543da0682b
commit
f9f5068f6d
@ -48,23 +48,6 @@ public class ShopChest extends JavaPlugin {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void copy(InputStream in, File file) {
|
|
||||||
try {
|
|
||||||
OutputStream out = new FileOutputStream(file);
|
|
||||||
byte[] buf = new byte[1024];
|
|
||||||
int len;
|
|
||||||
|
|
||||||
while ((len = in.read(buf)) > 0) {
|
|
||||||
out.write(buf, 0, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
out.close();
|
|
||||||
in.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean setupEconomy() {
|
private boolean setupEconomy() {
|
||||||
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
|
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
|
||||||
if (rsp == null) {
|
if (rsp == null) {
|
||||||
@ -149,6 +132,7 @@ public class ShopChest extends JavaPlugin {
|
|||||||
logger.severe("Could not submit stats.");
|
logger.severe("Could not submit stats.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
saveResource("item_names.txt", true);
|
||||||
reloadConfig();
|
reloadConfig();
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
|
|
||||||
@ -261,18 +245,6 @@ public class ShopChest extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File itemNamesFile = new File(getDataFolder(), "item_names.txt");
|
|
||||||
|
|
||||||
if (!itemNamesFile.exists())
|
|
||||||
try {
|
|
||||||
itemNamesFile.createNewFile();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
copy(getResource("item_names.txt"), itemNamesFile);
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Commands.registerCommand(new Commands(this, Config.main_command_name(), "Manage Shops.", "", new ArrayList<String>()), this);
|
Commands.registerCommand(new Commands(this, Config.main_command_name(), "Manage Shops.", "", new ArrayList<String>()), this);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user