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) {
|
catch (IOException e) {
|
||||||
getLogger().severe(e.toString());
|
getLogger().severe(e.toString());
|
||||||
}
|
}
|
||||||
|
Anniversary anniversary = new Anniversary();
|
||||||
|
anniversary.saveAnniversaryFiles();
|
||||||
|
|
||||||
getLogger().info("Was disabled."); //How informative!
|
getLogger().info("Was disabled."); //How informative!
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package com.gmail.nossr50.util;
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
@ -21,6 +23,7 @@ import org.bukkit.entity.EntityType;
|
|||||||
import org.bukkit.entity.Firework;
|
import org.bukkit.entity.Firework;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.meta.FireworkMeta;
|
import org.bukkit.inventory.meta.FireworkMeta;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
|
||||||
public class Anniversary {
|
public class Anniversary {
|
||||||
@ -40,12 +43,11 @@ public class Anniversary {
|
|||||||
System.out.println(ex);
|
System.out.println(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hasCelebrated = new ArrayList<String>();
|
hasCelebrated = new ArrayList<String>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
hasCelebrated.clear();
|
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();
|
String line = reader.readLine();
|
||||||
|
|
||||||
while (line != null) {
|
while (line != null) {
|
||||||
@ -59,35 +61,47 @@ 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
|
//This gets called from /mcmmo command
|
||||||
public void anniversaryCheck(final CommandSender sender) {
|
public void anniversaryCheck(final CommandSender sender) {
|
||||||
GregorianCalendar anniversaryStart = new GregorianCalendar(2013, Calendar.FEBRUARY, 3);
|
if (sender instanceof Player) {
|
||||||
GregorianCalendar anniversaryEnd = new GregorianCalendar(2013, Calendar.FEBRUARY, 6);
|
GregorianCalendar anniversaryStart = new GregorianCalendar(2013, Calendar.FEBRUARY, 3);
|
||||||
GregorianCalendar day = new GregorianCalendar();
|
GregorianCalendar anniversaryEnd = new GregorianCalendar(2013, Calendar.FEBRUARY, 6);
|
||||||
int celebrationCheck = 0;
|
GregorianCalendar day = new GregorianCalendar();
|
||||||
|
|
||||||
for (String celebrated : hasCelebrated) {
|
if (hasCelebrated.contains(sender.getName())) {
|
||||||
if (sender.getName().equalsIgnoreCase(celebrated)) {
|
return;
|
||||||
celebrationCheck = 1;
|
} 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!");
|
||||||
if (celebrationCheck == 0) {
|
final int firework_amount = 10;
|
||||||
if (getDateRange(day.getTime(), anniversaryStart.getTime(), anniversaryEnd.getTime())) {
|
for (int i = 0; i < firework_amount; i++) {
|
||||||
sender.sendMessage(ChatColor.BLUE + "Happy 2 Year Anniversary! In honor of all of");
|
int delay = (int) (Math.random() * 3) + 4;
|
||||||
sender.sendMessage(ChatColor.BLUE + "nossr50's work and all the devs, here's a firework show!");
|
Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() {
|
||||||
final int firework_amount = 10;
|
@Override
|
||||||
for (int i = 0; i < firework_amount; i++) {
|
public void run() {
|
||||||
int delay = (int) (Math.random() * 3) + 4;
|
spawnFireworks((Player) sender);
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() {
|
}
|
||||||
@Override
|
}, 20 * delay);
|
||||||
public void run() {
|
}
|
||||||
spawnFireworks((Player) sender);
|
|
||||||
}
|
|
||||||
}, 20 * delay);
|
|
||||||
}
|
}
|
||||||
|
hasCelebrated.add(sender.getName());
|
||||||
}
|
}
|
||||||
hasCelebrated.add(sender.getName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user