mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-30 09:06:46 +01:00
Fixing a java.io.FileNotFoundException when using SQL
This commit is contained in:
parent
06df8e7f7b
commit
664239c567
@ -319,6 +319,8 @@ public class mcMMO extends JavaPlugin {
|
||||
catch (IOException e) {
|
||||
getLogger().severe(e.toString());
|
||||
}
|
||||
Anniversary anniversary = new Anniversary();
|
||||
anniversary.saveAnniversaryFiles();
|
||||
|
||||
getLogger().info("Was disabled."); //How informative!
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
@ -21,6 +23,7 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Firework;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.meta.FireworkMeta;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class Anniversary {
|
||||
@ -40,12 +43,11 @@ public class Anniversary {
|
||||
System.out.println(ex);
|
||||
}
|
||||
}
|
||||
|
||||
hasCelebrated = new ArrayList<String>();
|
||||
|
||||
try {
|
||||
hasCelebrated.clear();
|
||||
BufferedReader reader = new BufferedReader(new FileReader(mcMMO.p.getDataFolder().getAbsolutePath() + File.separator + "players"));
|
||||
BufferedReader reader = new BufferedReader(new FileReader(mcMMO.p.getDataFolder().getAbsolutePath() + File.separator + "anniversary"));
|
||||
String line = reader.readLine();
|
||||
|
||||
while (line != null) {
|
||||
@ -59,20 +61,31 @@ public class Anniversary {
|
||||
}
|
||||
}
|
||||
|
||||
//This gets called onDisable
|
||||
public void saveAnniversaryFiles() {
|
||||
try {
|
||||
BufferedWriter writer = new BufferedWriter(new FileWriter(mcMMO.p.getDataFolder().getAbsolutePath() + File.separator + "anniversary"));
|
||||
for (String player : hasCelebrated) {
|
||||
writer.write(player);
|
||||
writer.newLine();
|
||||
}
|
||||
writer.close();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.out.println(ex);
|
||||
}
|
||||
}
|
||||
|
||||
//This gets called from /mcmmo command
|
||||
public void anniversaryCheck(final CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
GregorianCalendar anniversaryStart = new GregorianCalendar(2013, Calendar.FEBRUARY, 3);
|
||||
GregorianCalendar anniversaryEnd = new GregorianCalendar(2013, Calendar.FEBRUARY, 6);
|
||||
GregorianCalendar day = new GregorianCalendar();
|
||||
int celebrationCheck = 0;
|
||||
|
||||
for (String celebrated : hasCelebrated) {
|
||||
if (sender.getName().equalsIgnoreCase(celebrated)) {
|
||||
celebrationCheck = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (celebrationCheck == 0) {
|
||||
if (hasCelebrated.contains(sender.getName())) {
|
||||
return;
|
||||
} else {
|
||||
if (getDateRange(day.getTime(), anniversaryStart.getTime(), anniversaryEnd.getTime())) {
|
||||
sender.sendMessage(ChatColor.BLUE + "Happy 2 Year Anniversary! In honor of all of");
|
||||
sender.sendMessage(ChatColor.BLUE + "nossr50's work and all the devs, here's a firework show!");
|
||||
@ -90,6 +103,7 @@ public class Anniversary {
|
||||
hasCelebrated.add(sender.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean getDateRange(Date date, Date start, Date end) {
|
||||
return !(date.before(start) || date.after(end));
|
||||
|
Loading…
Reference in New Issue
Block a user