diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b83d222
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..cc5c502
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# デフォルトの無視対象ファイル
+/shelf/
+/workspace.xml
+# エディターベースの HTTP クライアントリクエスト
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..841c400
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..aa00ffa
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..d027cb1
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..9e0563e
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..e183065
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 0000000..2b63946
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/foofledrive.iml b/foofledrive.iml
index 2304e1f..a1c210c 100644
--- a/foofledrive.iml
+++ b/foofledrive.iml
@@ -1,36 +1,14 @@
-
+
SPIGOT
+ BUKKIT
+ 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index f2ed865..330351c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,13 +6,13 @@
ga.ganma
foofledrive
- 0.7.9β
+ 1.0.0
jar
foofledrive
- 1.8
+ 1.16
UTF-8
@@ -24,8 +24,8 @@
maven-compiler-plugin
3.7.0
- 8
- 8
+ 16
+ 16
@@ -72,7 +72,7 @@
org.spigotmc
spigot-api
- 1.14.4-R0.1-SNAPSHOT
+ 1.20.2-R0.1-SNAPSHOT
provided
diff --git a/src/main/java/ga/ganma/ender/Endercloud.java b/src/main/java/ga/ganma/ender/Endercloud.java
deleted file mode 100644
index 821f689..0000000
--- a/src/main/java/ga/ganma/ender/Endercloud.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package ga.ganma.ender;
-
-import ga.ganma.ender.Listener.GetEvent;
-import ga.ganma.ender.command.CommandMain;
-import net.milkbowl.vault.economy.Economy;
-import org.bukkit.Bukkit;
-import org.bukkit.plugin.Plugin;
-import org.bukkit.plugin.RegisteredServiceProvider;
-import org.bukkit.plugin.java.JavaPlugin;
-
-import java.util.logging.Logger;
-
-public final class Endercloud extends JavaPlugin {
-
- private static final Logger log = Logger.getLogger("Minecraft");
- public static Economy econ = null;
- public static int[] configamout = new int[4];
-
- public static Plugin ender;
-
- @Override
- public void onEnable() {
- getDataFolder().mkdir();
- ender = this;
- new GetEvent(this);
- this.getCommand("ec").setExecutor(new CommandMain(this));
- saveDefaultConfig();
- configamout[0] = this.getConfig().getInt("amout.FREE");
- configamout[1] = this.getConfig().getInt("amout.LIGHT");
- configamout[2] = this.getConfig().getInt("amout.MIDDLE");
- configamout[3] = this.getConfig().getInt("amout.LARGE");
- this.setupEconomy();
- }
-
- @Override
- public void onDisable() {
- // Plugin shutdown logic
- }
-
- private boolean setupEconomy() {
- if (getServer().getPluginManager().getPlugin("Vault") == null) {
- return false;
- }
- RegisteredServiceProvider rsp = getServer().getServicesManager().getRegistration(Economy.class);
- if (rsp == null) {
- return false;
- }
- econ = rsp.getProvider();
- return econ != null;
- }
-}
diff --git a/src/main/java/ga/ganma/ender/Filerelation.java b/src/main/java/ga/ganma/ender/Filerelation.java
deleted file mode 100644
index f88aa10..0000000
--- a/src/main/java/ga/ganma/ender/Filerelation.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package ga.ganma.ender;
-
-import ga.ganma.ender.playerdata.Playerdata;
-import org.bukkit.entity.Player;
-
-import java.io.*;
-import java.util.logging.Level;
-
-public class Filerelation {
-
- public static boolean namecheck(Player p){
- String FS = File.separator;
- File file = new File(Endercloud.ender.getDataFolder() + FS + "playerdata" + FS + p.getUniqueId().toString() + ".dat");
- return file.exists();
- }
-
- public static void createFile(Playerdata e){
- try {
- String FS = File.separator;
- File folder = new File(Endercloud.ender.getDataFolder() + FS + "playerdata");
- folder.mkdir();
- File file = new File(Endercloud.ender.getDataFolder() + FS + "playerdata" + FS + e.getMcid().toString() + ".dat");
-
- if(file.exists()) {
- file.delete();
- }
- FileOutputStream fos = new FileOutputStream(file);
- ObjectOutputStream oos = new ObjectOutputStream(fos);
- oos.writeObject(e);
- oos.close();
-
- }
- catch (IOException io){
- Endercloud.ender.getLogger().log(Level.SEVERE, "ファイルの作成に失敗しました。");
- }
- }
-
- public static Playerdata readFile(Player p) {
- Playerdata pd = null;
- if(!namecheck(p)){
- return null;
- }
- try {
- String FS = File.separator;
- File file = new File(Endercloud.ender.getDataFolder() + FS + "playerdata" + FS + p.getUniqueId().toString() + ".dat");
- FileInputStream fis = new FileInputStream(file);
- ObjectInputStream ois = new ObjectInputStream(fis);
- pd = (Playerdata) ois.readObject();
- ois.close();
- }
- catch (IOException e){
- Endercloud.ender.getLogger().log(Level.SEVERE, "ファイルの読み取りに失敗しました。");
- }
- catch (ClassNotFoundException e){
- Endercloud.ender.getLogger().log(Level.SEVERE, "内部エラーが発生しました。製作者に次のエラーコードを伝えてください。");
- Endercloud.ender.getLogger().log(Level.SEVERE, "File error:01");
- }
- return pd;
- }
-}
diff --git a/src/main/java/ga/ganma/ender/Listener/GUIEvent.java b/src/main/java/ga/ganma/ender/Listener/GUIEvent.java
deleted file mode 100644
index 4f7f9c4..0000000
--- a/src/main/java/ga/ganma/ender/Listener/GUIEvent.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package ga.ganma.ender.Listener;
-
-import org.bukkit.Bukkit;
-import org.bukkit.event.Listener;
-import org.bukkit.plugin.Plugin;
-
-public class GUIEvent implements Listener {
- public GUIEvent(Plugin pl){
- Bukkit.getPluginManager().registerEvents(this,pl);
- }
-}
diff --git a/src/main/java/ga/ganma/ender/Listener/GetEvent.java b/src/main/java/ga/ganma/ender/Listener/GetEvent.java
deleted file mode 100644
index 0fbe8e7..0000000
--- a/src/main/java/ga/ganma/ender/Listener/GetEvent.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package ga.ganma.ender.Listener;
-
-import ga.ganma.ender.Endercloud;
-import ga.ganma.ender.Filerelation;
-import ga.ganma.ender.inventoryRelation.InventoryAPI;
-import ga.ganma.ender.plan;
-import ga.ganma.ender.playerdata.Playerdata;
-import jdk.internal.ref.Cleaner;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.inventory.InventoryCloseEvent;
-import org.bukkit.event.player.PlayerJoinEvent;
-import org.bukkit.plugin.Plugin;
-
-import java.io.File;
-import java.util.Calendar;
-import java.util.HashMap;
-
-public class GetEvent implements Listener {
-
- public static HashMap isinventoryopen = new HashMap<>();
-
- public GetEvent(Plugin pl) {
- Bukkit.getPluginManager().registerEvents(this, pl);
- }
-
- @EventHandler
- public void getplayerloginEvent(PlayerJoinEvent e) {
- Player p = e.getPlayer();
- if (Filerelation.namecheck(p)) {
- if (Filerelation.readFile(p).getPlan() == plan.FREE) {
- p.sendMessage("[foofle drive]あなたは現在" + Filerelation.readFile(p).getPlan() + "プランに加入しています。");
- return;
- }
- else {
- Playerdata pd = Filerelation.readFile(p);
- double bal = Endercloud.econ.getBalance(p);
- if (pd.getFinish() != null) {
- if (pd.getFinish().before(Calendar.getInstance())) {
- int[] amout = Endercloud.configamout;
- switch (pd.getPlan()) {
- case LIGHT:
- if (bal >= amout[1]) {
- Endercloud.econ.depositPlayer(p, -amout[1]);
- p.sendMessage("[foofle drive]LIGHTプランの料金を支払いました。");
- } else {
- InventoryAPI.planchange(p, plan.FREE);
- p.sendMessage("[foofle drive]お金が足りないため自動的にfreeプランへ移行しました。");
- p.sendMessage("[foofle drive]その際、2段目以降にあるアイテムを全消去しました。");
- }
- break;
- case MIDDLE:
- if (bal >= amout[2]) {
- Endercloud.econ.depositPlayer(p, -amout[2]);
- p.sendMessage("[foofle drive]MIDDLEプランの料金を支払いました。");
- } else {
- InventoryAPI.planchange(p, plan.FREE);
- p.sendMessage("[foofle drive]お金が足りないため自動的にfreeプランへ移行しました。");
- p.sendMessage("[foofle drive]その際、2段目以降にあるアイテムを全消去しました。");
- }
- break;
- case LARGE:
- if (bal >= amout[3]) {
- Endercloud.econ.depositPlayer(p, -amout[3]);
- p.sendMessage("[foofle drive]LARGEプランの料金を支払いました。");
- } else {
- InventoryAPI.planchange(p, plan.FREE);
- p.sendMessage("[foofle drive]お金が足りないため自動的にfreeプランへ移行しました。");
- p.sendMessage("[foofle drive]その際、2段目以降にあるアイテムを全消去しました。");
- }
- break;
- }
- return;
- }
- else {
- long diffTime = pd.getFinish().getTimeInMillis() - Calendar.getInstance().getTimeInMillis();//[3]
- int diffDayMillis = 1000 * 60 * 60 * 24;//[4]
- int diffDays = (int) (diffTime / diffDayMillis);
- p.sendMessage("[foofle drive]支払日まであと" + diffDays + "日です。");//[5]
- }
- }
- else {
- pd.setFinish(Calendar.getInstance());
- Filerelation.createFile(pd);
- p.sendMessage("デバッグ:1");
- }
- }
- }
- else {
- Playerdata pd = new Playerdata(p, Bukkit.getServer().createInventory(null, 9, "foofle Drive"), plan.FREE);
- Filerelation.createFile(pd);
- p.sendMessage("[foofle drive]あなたは自動的に" + Filerelation.readFile(p).getPlan() + "プランに加入しました。");
- }
- }
-
- @EventHandler
- public void getPlayerInventoryCloseEvent(InventoryCloseEvent e) {
- Player pl = (Player) e.getPlayer();
- if(e.getView().getTitle().equals("foofle drive")){
- Playerdata pd = new Playerdata(pl,e.getView().getTopInventory(),Filerelation.readFile(pl).getPlan());
- Filerelation.createFile(pd);
- }
- }
-}
diff --git a/src/main/java/ga/ganma/ender/command/CommandMain.java b/src/main/java/ga/ganma/ender/command/CommandMain.java
deleted file mode 100644
index 3eff878..0000000
--- a/src/main/java/ga/ganma/ender/command/CommandMain.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package ga.ganma.ender.command;
-
-import ga.ganma.ender.Filerelation;
-import ga.ganma.ender.plan;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandExecutor;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-import org.bukkit.plugin.Plugin;
-
-import java.util.Calendar;
-import java.util.TimeZone;
-import java.util.logging.Level;
-
-public class CommandMain implements CommandExecutor {
- private Plugin pl;
-
- public CommandMain(Plugin pl) {
- this.pl = pl;
- }
-
- @Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- if (sender instanceof Player) {
- Player p = (Player) sender;
- if (label.equalsIgnoreCase("ec")) {
- if (args.length != 0) {
- if (args[0].equalsIgnoreCase("open")) {
- new Subopen(this.pl, (Player) sender);
- } else if (args[0].equalsIgnoreCase("plan")) {
- if (args.length > 1) {
- if (args[1].equalsIgnoreCase("LIGHT")) {
- new Subplan(this.pl, p, plan.LIGHT);
- Filerelation.readFile(p).setFinish(Calendar.getInstance());
- } else if (args[1].equalsIgnoreCase("FREE")) {
- new Subplan(this.pl, p, plan.FREE);
- }else if (args[1].equalsIgnoreCase("MIDDLE")) {
- new Subplan(this.pl, p, plan.MIDDLE);
- }else if (args[1].equalsIgnoreCase("LARGE")) {
- new Subplan(this.pl, p, plan.LARGE);
- }
- } else {
- p.sendMessage("[foofle drive]プラン名を入力してください。");
- p.sendMessage("[foofle drive]FREE,LIGHT,MIDDLE,LARGE");
- }
- }
- }
- else {
- p.sendMessage("[free drive] /ec open でfoofle driveを開くことができます。");
- p.sendMessage("[free drive] /ec plan で好きなプランに加入することができます。");
- }
- }
- }
- else {
- pl.getLogger().log(Level.FINE, "このコマンドはコンソールからではなくプレイヤーが入力するものです。");
- }
- return false;
- }
-}
diff --git a/src/main/java/ga/ganma/ender/command/Subopen.java b/src/main/java/ga/ganma/ender/command/Subopen.java
deleted file mode 100644
index 4323d49..0000000
--- a/src/main/java/ga/ganma/ender/command/Subopen.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package ga.ganma.ender.command;
-
-import ga.ganma.ender.Filerelation;
-import ga.ganma.ender.Listener.GetEvent;
-import org.bukkit.entity.Player;
-import org.bukkit.plugin.Plugin;
-
-public class Subopen {
- Plugin pl;
- public Subopen(Plugin pl, Player p){
- this.pl = pl;
- p.openInventory(Filerelation.readFile(p).getInv());
- GetEvent.isinventoryopen.put(p,true);
- }
-}
diff --git a/src/main/java/ga/ganma/ender/command/Subplan.java b/src/main/java/ga/ganma/ender/command/Subplan.java
deleted file mode 100644
index 26388ce..0000000
--- a/src/main/java/ga/ganma/ender/command/Subplan.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package ga.ganma.ender.command;
-
-import ga.ganma.ender.Filerelation;
-import ga.ganma.ender.inventoryRelation.InventoryAPI;
-import ga.ganma.ender.playerdata.Playerdata;
-import org.bukkit.entity.Player;
-import org.bukkit.plugin.Plugin;
-
-import java.util.Calendar;
-
-public class Subplan {
- Plugin pl;
- Player p;
- public Subplan(Plugin pl, Player player, ga.ganma.ender.plan plan){
- this.pl = pl;
- p = player;
- InventoryAPI.planchange(player,plan);
- Playerdata pd = Filerelation.readFile(p);
- pd.setFinish(Calendar.getInstance());
- Filerelation.createFile(pd);
- p.sendMessage("[foorle drive]プランを" + plan + "プランに変更しました。");
- }
-}
diff --git a/src/main/java/ga/ganma/ender/inventoryRelation/InventoryAPI.java b/src/main/java/ga/ganma/ender/inventoryRelation/InventoryAPI.java
deleted file mode 100644
index 2589f21..0000000
--- a/src/main/java/ga/ganma/ender/inventoryRelation/InventoryAPI.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package ga.ganma.ender.inventoryRelation;
-
-import ga.ganma.ender.Filerelation;
-import ga.ganma.ender.plan;
-import ga.ganma.ender.playerdata.Playerdata;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.ItemStack;
-
-import java.util.*;
-
-public class InventoryAPI {
- public static Inventory Inventorysizechange(Inventory oldInv, int setsize){
- Inventory inv = Bukkit.createInventory(null,setsize,"foofle drive");
- inv.setStorageContents(oldInv.getStorageContents());
- return inv;
- }
-
- public static void planchange(Player player, plan plan){
- Inventory inv = null;
- ItemStack[] is = null;
- switch (plan){
- case FREE:
- inv = Bukkit.createInventory(null,9,"foofle drive");
- is = Filerelation.readFile(player).getInv().getStorageContents();
- if(is.length > 9){
- int a = is.length;
- List isl = new ArrayList<>(Arrays.asList(is));
- isl.subList(9,a).clear();
- ItemStack[] array = new ItemStack[isl.size()];
- int i = 0;
- for (ItemStack ist : isl){
- array[i] = ist;
- i += 1;
- }
- is = array;
- }
- break;
-
- case LIGHT:
- inv = Bukkit.createInventory(null,18,"foofle drive");
- is = Filerelation.readFile(player).getInv().getStorageContents();
- if(is.length >= 19){
- int a = is.length;
- List isl = new ArrayList<>(Arrays.asList(is));
- isl.subList(18,a).clear();
- ItemStack[] array = new ItemStack[isl.size()];
- int i = 0;
- for (ItemStack ist : isl){
- array[i] = ist;
- i += 1;
- }
- is = array;
- }
- break;
- case MIDDLE:
- inv = Bukkit.createInventory(null,27,"foofle drive");
- is = Filerelation.readFile(player).getInv().getStorageContents();
- if(is.length >= 28){
- int a = is.length;
- List isl = new ArrayList<>(Arrays.asList(is));
- isl.subList(27,a).clear();
- ItemStack[] array = new ItemStack[isl.size()];
- int i = 0;
- for (ItemStack ist : isl){
- array[i] = ist;
- i += 1;
- }
- is = array;
- }
- break;
-
- case LARGE:
- inv = Bukkit.createInventory(null,54,"foofle drive");
- is = Filerelation.readFile(player).getInv().getStorageContents();
- break;
- }
- inv.setStorageContents(is);
- Playerdata pd = new Playerdata(player,inv,plan);
- Filerelation.createFile(pd);
- }
-}
diff --git a/src/main/java/ga/ganma/ender/inventoryRelation/InventoryEncoder.java b/src/main/java/ga/ganma/ender/inventoryRelation/InventoryEncoder.java
deleted file mode 100644
index 581f077..0000000
--- a/src/main/java/ga/ganma/ender/inventoryRelation/InventoryEncoder.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package ga.ganma.ender.inventoryRelation;
-
-import org.bukkit.Bukkit;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.util.io.BukkitObjectInputStream;
-import org.bukkit.util.io.BukkitObjectOutputStream;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.util.Base64;
-
-public class InventoryEncoder {
- public static String inventoryToString(Inventory inventory) {
- try {
- ByteArrayOutputStream str = new ByteArrayOutputStream();
- BukkitObjectOutputStream data = new BukkitObjectOutputStream(str);
- data.writeInt(inventory.getSize());
- for (int i = 0; i < inventory.getSize(); i++) {
- data.writeObject(inventory.getItem(i));
- }
- data.close();
- return Base64.getEncoder().encodeToString(str.toByteArray());
- } catch (Exception e) {
- e.printStackTrace();
- }
- return "";
- }
-
- public static Inventory stringToInventory(String inventoryData) {
- try {
- ByteArrayInputStream stream = new ByteArrayInputStream(Base64.getDecoder().decode(inventoryData));
- BukkitObjectInputStream data = new BukkitObjectInputStream(stream);
- Inventory inventory = Bukkit.createInventory(null, data.readInt(), "foofle drive");
- for (int i = 0; i < inventory.getSize(); i++) {
- inventory.setItem(i, (ItemStack) data.readObject());
- }
- data.close();
- return inventory;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-}
diff --git a/src/main/java/ga/ganma/ender/plan.java b/src/main/java/ga/ganma/ender/plan.java
deleted file mode 100644
index 07b6c51..0000000
--- a/src/main/java/ga/ganma/ender/plan.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package ga.ganma.ender;
-
-import java.io.Serializable;
-
-public enum plan implements Serializable {
- FREE,LIGHT,MIDDLE,LARGE
-}
diff --git a/src/main/java/ga/ganma/ender/playerdata/Playerdata.java b/src/main/java/ga/ganma/ender/playerdata/Playerdata.java
deleted file mode 100644
index 7990d4e..0000000
--- a/src/main/java/ga/ganma/ender/playerdata/Playerdata.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package ga.ganma.ender.playerdata;
-
-import ga.ganma.ender.inventoryRelation.InventoryEncoder;
-import ga.ganma.ender.plan;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-
-import java.io.Serializable;
-import java.util.Calendar;
-import java.util.UUID;
-
-public class Playerdata implements Serializable {
- private UUID mcid;
- private plan plan;
- private String inventorySt;
- private Calendar finish;
-
- public Playerdata(Player pl, Inventory inv, plan plan) {
- this.mcid = pl.getUniqueId();
- this.plan = plan;
- this.inventorySt = InventoryEncoder.inventoryToString(inv);
- }
-
- public ga.ganma.ender.plan getPlan() {
- return plan;
- }
-
- public UUID getMcid() {
- return mcid;
- }
-
- public Inventory getInv() {
- return InventoryEncoder.stringToInventory(inventorySt);
- }
-
- public void setFinish(Calendar cl){
- cl.add(Calendar.DAY_OF_MONTH,+7);
- finish = cl;
- }
-
- public Calendar getFinish(){
- return finish;
- }
-}
diff --git a/src/main/java/ga/ganma/foofledrive/FileRelationUtils.java b/src/main/java/ga/ganma/foofledrive/FileRelationUtils.java
new file mode 100644
index 0000000..ce1694e
--- /dev/null
+++ b/src/main/java/ga/ganma/foofledrive/FileRelationUtils.java
@@ -0,0 +1,113 @@
+package ga.ganma.foofledrive;
+
+import ga.ganma.foofledrive.playerdata.Playerdata;
+import org.bukkit.OfflinePlayer;
+import org.bukkit.entity.Player;
+
+import java.io.*;
+import java.nio.file.Path;
+import java.util.UUID;
+import java.util.logging.Level;
+
+/**
+ * Filerelationクラスは、プレイヤーデータのファイル操作を行うためのユーティリティクラスです。
+ * プレイヤーデータの読み書きや存在確認を行います。
+ */
+public final class FileRelationUtils {
+
+ public static final Path PLAYERDATA_FOLDER = new File(Foofledrive.ender.getDataFolder() + File.separator + "playerdata").toPath();
+ public static final String DATA_FILE_EXTENTION = ".dat";
+
+ /**
+ * インスタンス化を禁止するためのプライベートコンストラクタ。
+ */
+ private FileRelationUtils() {}
+ /**
+ * 指定されたプレイヤーのデータファイルが存在するかを確認します。
+ *
+ * @param p チェックするプレイヤー
+ * @return データファイルが存在する場合はtrue、存在しない場合はfalse
+ */
+ public static boolean nameCheck(Player p) {
+ return nameCheck(p.getUniqueId());
+ }
+
+ /**
+ * 指定されたオフラインプレイヤーのデータファイルが存在するかを確認します。
+ *
+ * @param offp チェックするオフラインプレイヤー
+ * @return データファイルが存在する場合はtrue、存在しない場合はfalse
+ */
+ public static boolean nameCheck(OfflinePlayer offp) {
+ return nameCheck(offp.getUniqueId());
+ }
+
+ public static boolean nameCheck(UUID uuid) {
+ return new File(PLAYERDATA_FOLDER.toString() + uuid + ".dat").exists();
+ }
+
+ /**
+ * 指定されたプレイヤーデータをファイルに書き込みます。
+ * @deprecated このメソッドの新規の使用は推奨しません。
+ * @param e 書き込むプレイヤーデータ
+ */
+ public static void createFile(Playerdata e) {
+ try {
+ File folder = PLAYERDATA_FOLDER.toFile();
+ folder.mkdir();
+ File file = new File(PLAYERDATA_FOLDER + e.getMcid().toString() + ".dat");
+
+ if (file.exists()) {
+ file.delete();
+ }
+ try (FileOutputStream fos = new FileOutputStream(file);
+ ObjectOutputStream oos = new ObjectOutputStream(fos)) {
+ oos.writeObject(e);
+ }
+ } catch (IOException io) {
+ Foofledrive.ender.getLogger().log(Level.SEVERE, "ファイルの作成に失敗しました。");
+ }
+ }
+
+ /**
+ * 指定されたプレイヤーのデータファイルを読み込みます。
+ *
+ * @param p 読み込むプレイヤー
+ * @return 読み込んだプレイヤーデータ、存在しない場合はnull
+ */
+ public static Playerdata readFile(Player p) {
+ return readFileInternal(p.getUniqueId());
+ }
+
+ /**
+ * 指定されたオフラインプレイヤーのデータファイルを読み込みます。
+ *
+ * @param offp 読み込むオフラインプレイヤー
+ * @return 読み込んだプレイヤーデータ、存在しない場合はnull
+ */
+ public static Playerdata readFile(OfflinePlayer offp) {
+ return readFileInternal(offp.getUniqueId());
+ }
+
+ /**
+ * 内部的にプレイヤーデータファイルを読み込みます。
+ *
+ * @param uniqueId 読み込むプレイヤーのUUID
+ * @return 読み込んだプレイヤーデータ、存在しない場合はnull
+ */
+ private static Playerdata readFileInternal(UUID uniqueId) {
+ Playerdata pd = null;
+ if (!nameCheck(uniqueId)) {
+ return null;
+ }
+ try (FileInputStream fis = new FileInputStream(PLAYERDATA_FOLDER.toString() + uniqueId + ".dat");
+ ObjectInputStream ois = new ObjectInputStream(fis)) {
+ pd = (Playerdata) ois.readObject();
+ } catch (IOException e) {
+ Foofledrive.ender.getLogger().log(Level.SEVERE, "ファイルの読み取りに失敗しました。");
+ } catch (ClassNotFoundException e) {
+ Foofledrive.ender.getLogger().log(Level.SEVERE, "内部エラーが発生しました。");
+ }
+ return pd;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/ga/ganma/foofledrive/Filerelation.java b/src/main/java/ga/ganma/foofledrive/Filerelation.java
deleted file mode 100644
index c23368c..0000000
--- a/src/main/java/ga/ganma/foofledrive/Filerelation.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package ga.ganma.foofledrive;
-
-import ga.ganma.foofledrive.playerdata.Playerdata;
-import org.bukkit.OfflinePlayer;
-import org.bukkit.entity.Player;
-
-import java.io.*;
-import java.util.logging.Level;
-
-public class Filerelation {
-
- public static boolean namecheck(Player p){
- String FS = File.separator;
- File file = new File(Foofledrive.ender.getDataFolder() + FS + "playerdata" + FS + p.getUniqueId().toString() + ".dat");
- return file.exists();
- }
-
- public static boolean namecheck(OfflinePlayer offp){
- String FS = File.separator;
- File file = new File(Foofledrive.ender.getDataFolder() + FS + "playerdata" + FS + offp.getUniqueId().toString() + ".dat");
- return file.exists();
- }
-
- public static void createFile(Playerdata e){
- try {
- String FS = File.separator;
- File folder = new File(Foofledrive.ender.getDataFolder() + FS + "playerdata");
- folder.mkdir();
- File file = new File(Foofledrive.ender.getDataFolder() + FS + "playerdata" + FS + e.getMcid().toString() + ".dat");
-
- if(file.exists()) {
- file.delete();
- }
- FileOutputStream fos = new FileOutputStream(file);
- ObjectOutputStream oos = new ObjectOutputStream(fos);
- oos.writeObject(e);
- oos.close();
-
- }
- catch (IOException io){
- Foofledrive.ender.getLogger().log(Level.SEVERE, "ファイルの作成に失敗しました。");
- }
- }
-
- public static Playerdata readFile(Player p) {
- Playerdata pd = null;
- if(!namecheck(p)){
- return null;
- }
- try {
- String FS = File.separator;
- File file = new File(Foofledrive.ender.getDataFolder() + FS + "playerdata" + FS + p.getUniqueId().toString() + ".dat");
- FileInputStream fis = new FileInputStream(file);
- ObjectInputStream ois = new ObjectInputStream(fis);
- pd = (Playerdata) ois.readObject();
- ois.close();
- }
- catch (IOException e){
- Foofledrive.ender.getLogger().log(Level.SEVERE, "ファイルの読み取りに失敗しました。");
- }
- catch (ClassNotFoundException e){
- Foofledrive.ender.getLogger().log(Level.SEVERE, "内部エラーが発生しました。製作者に次のエラーコードを伝えてください。");
- Foofledrive.ender.getLogger().log(Level.SEVERE, "File error:01");
- }
- return pd;
- }
-
- public static Playerdata readFile(OfflinePlayer offp) {
- Playerdata pd = null;
- if(!namecheck(offp)){
- return null;
- }
- try {
- String FS = File.separator;
- File file = new File(Foofledrive.ender.getDataFolder() + FS + "playerdata" + FS + offp.getUniqueId().toString() + ".dat");
- FileInputStream fis = new FileInputStream(file);
- ObjectInputStream ois = new ObjectInputStream(fis);
- pd = (Playerdata) ois.readObject();
- ois.close();
- }
- catch (IOException e){
- Foofledrive.ender.getLogger().log(Level.SEVERE, "ファイルの読み取りに失敗しました。");
- }
- catch (ClassNotFoundException e){
- Foofledrive.ender.getLogger().log(Level.SEVERE, "内部エラーが発生しました。製作者に次のエラーコードを伝えてください。");
- Foofledrive.ender.getLogger().log(Level.SEVERE, "File error:01");
- }
- return pd;
- }
-}
diff --git a/src/main/java/ga/ganma/foofledrive/FoofleDrivePlan.java b/src/main/java/ga/ganma/foofledrive/FoofleDrivePlan.java
new file mode 100644
index 0000000..534409a
--- /dev/null
+++ b/src/main/java/ga/ganma/foofledrive/FoofleDrivePlan.java
@@ -0,0 +1,15 @@
+package ga.ganma.foofledrive;
+
+public enum FoofleDrivePlan {
+ FREE(0), LIGHT(1), MIDDLE(2), LARGE(3);
+
+ private final int id;
+
+ private FoofleDrivePlan(int id) {
+ this.id = id;
+ }
+
+ public int getId() {
+ return id;
+ }
+}
diff --git a/src/main/java/ga/ganma/foofledrive/Foofledrive.java b/src/main/java/ga/ganma/foofledrive/Foofledrive.java
index f58ee9e..63f7c80 100644
--- a/src/main/java/ga/ganma/foofledrive/Foofledrive.java
+++ b/src/main/java/ga/ganma/foofledrive/Foofledrive.java
@@ -14,45 +14,49 @@
public final class Foofledrive extends JavaPlugin {
- private static final Logger log = Logger.getLogger("Minecraft");
- public static Economy econ = null;
- public static int[] configamout = new int[4];
- public static String unit;
- public static Plugin ender;
- public Foofledrive fl;
-
- @Override
- public void onEnable() {
- getDataFolder().mkdir();
- ender = this;
- new GetEvent(this);
- new GUIEvent(this);
- this.getCommand("fl").setExecutor(new CommandMain(this));
- this.getCommand("foofledrive").setExecutor(new CommandMain(this));
- saveDefaultConfig();
- configamout[0] = this.getConfig().getInt("amout.FREE");
- configamout[1] = this.getConfig().getInt("amout.LIGHT");
- configamout[2] = this.getConfig().getInt("amout.MIDDLE");
- configamout[3] = this.getConfig().getInt("amout.LARGE");
- unit = this.getConfig().getString("unit");
- if(!this.setupEconomy()){
- Bukkit.getPluginManager().disablePlugin(this);
- Bukkit.getLogger().warning("[foofle drive]Vaultが存在しません!");
- return;
- }
- new Runnable(this).runTaskTimer(this,0,20);
- }
-
- @Override
- public void onDisable() {
- // Plugin shutdown logic
- }
-
- private boolean setupEconomy() {
- RegisteredServiceProvider economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
- if (economyProvider != null) {
- econ = economyProvider.getProvider();
- }
- return (econ != null);
- }
-}
+ private static final Logger log = Logger.getLogger("Minecraft");
+ public static Economy econ = null;
+ public static int[] configValues = new int[4];
+ public static String unit;
+ public static Plugin ender;
+
+ @Override
+ public void onEnable() {
+ getDataFolder().mkdir();
+ ender = this;
+ new GetEvent(this);
+ new GUIEvent(this);
+ CommandMain commandMain = new CommandMain(this);
+ this.getCommand("fl").setExecutor(commandMain);
+ this.getCommand("foofledrive").setExecutor(commandMain);
+ saveDefaultConfig();
+ loadConfigValues();
+ if (!setupEconomy()) {
+ Bukkit.getPluginManager().disablePlugin(this);
+ log.warning("[foofle drive]Vaultが存在しません!");
+ return;
+ }
+ new Runnable(this).runTaskTimer(this, 0, 20);
+ }
+
+ @Override
+ public void onDisable() {
+ // Plugin shutdown logic
+ }
+
+ private boolean setupEconomy() {
+ RegisteredServiceProvider economyProvider = getServer().getServicesManager().getRegistration(Economy.class);
+ if (economyProvider != null) {
+ econ = economyProvider.getProvider();
+ }
+ return (econ != null);
+ }
+
+ private void loadConfigValues() {
+ configValues[0] = getConfig().getInt("amout.FREE");
+ configValues[1] = getConfig().getInt("amout.LIGHT");
+ configValues[2] = getConfig().getInt("amout.MIDDLE");
+ configValues[3] = getConfig().getInt("amout.LARGE");
+ unit = getConfig().getString("unit");
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/ga/ganma/foofledrive/Listener/GUIEvent.java b/src/main/java/ga/ganma/foofledrive/Listener/GUIEvent.java
index ba74f82..c77398d 100644
--- a/src/main/java/ga/ganma/foofledrive/Listener/GUIEvent.java
+++ b/src/main/java/ga/ganma/foofledrive/Listener/GUIEvent.java
@@ -1,6 +1,6 @@
package ga.ganma.foofledrive.Listener;
-import ga.ganma.foofledrive.Filerelation;
+import ga.ganma.foofledrive.FileRelationUtils;
import ga.ganma.foofledrive.command.CommandMain;
import ga.ganma.foofledrive.inventoryRelation.InventoryAPI;
import ga.ganma.foofledrive.plan;
@@ -22,137 +22,120 @@
public class GUIEvent implements Listener {
- private static HashMap ProvisionalPlan = new HashMap<>();
-
- public GUIEvent(Plugin pl) {
- Bukkit.getPluginManager().registerEvents(this, pl);
- }
-
- @EventHandler
- public void getInventoryclickEvent(InventoryClickEvent e) {
- if (e.getWhoClicked() != null) {
- Player pl = (Player) e.getWhoClicked();
- if (CommandMain.isopenInventory.containsKey(pl)) {
- if (CommandMain.isopenInventory.get(pl)) {
- ItemStack clickedItem = e.getCurrentItem();
- Inventory clickedInventory = e.getClickedInventory();
- if (clickedItem == null || clickedInventory == null) {
- return;
- }
- if (! clickedItem.hasItemMeta()) {
- return;
- }
- if (e.getView().getType() != InventoryType.CREATIVE && e.getView().getTitle().contains("プラン選択画面")) {
- if (e.getSlot() == 10) {
- e.setCancelled(true);
- pl.openInventory(yesornoInv());
- ProvisionalPlan.put(pl, plan.FREE);
- } else if (e.getSlot() == 12) {
- e.setCancelled(true);
- pl.openInventory(yesornoInv());
- ProvisionalPlan.put(pl, plan.LIGHT);
- } else if (e.getSlot() == 14) {
- e.setCancelled(true);
- pl.openInventory(yesornoInv());
- ProvisionalPlan.put(pl, plan.MIDDLE);
- } else if (e.getSlot() == 16) {
- e.setCancelled(true);
- pl.openInventory(yesornoInv());
- ProvisionalPlan.put(pl, plan.LARGE);
- } else if (clickedItem.getType() == Material.LIGHT_GRAY_STAINED_GLASS_PANE) {
- e.setCancelled(true);
- }
- } else if (e.getView().getTitle().contains("契約してよろしいですか?")) {
- if (e.getSlot() == 15) {
- e.setCancelled(true);
- Playerdata pd;
- switch (ProvisionalPlan.get(pl)) {
- case FREE:
- InventoryAPI.planchange(pl, plan.FREE);
- pd = Filerelation.readFile(pl);
- if (pd.getFinish() == null) {
- pd.setFinish(Calendar.getInstance());
- Filerelation.createFile(pd);
- }
- pl.sendMessage("[foofle drive]プランを" + plan.FREE + "プランに変更しました。");
- break;
-
- case LIGHT:
- boolean is = InventoryAPI.planchange(pl, plan.LIGHT);
- pd = Filerelation.readFile(pl);
- if (pd.getFinish() == null) {
- pd.setFinish(Calendar.getInstance());
- Filerelation.createFile(pd);
- }
- if (is) {
- pl.sendMessage("[foofle drive]プランを" + plan.LIGHT + "プランに変更しました。");
- }
- break;
-
- case MIDDLE:
- boolean is1 = InventoryAPI.planchange(pl, plan.MIDDLE);
- pd = Filerelation.readFile(pl);
- if (pd.getFinish() == null) {
- pd.setFinish(Calendar.getInstance());
- Filerelation.createFile(pd);
- }
- if (is1) {
- pl.sendMessage("[foofle drive]プランを" + plan.MIDDLE + "プランに変更しました。");
- }
- break;
-
- case LARGE:
- boolean is2 = InventoryAPI.planchange(pl, plan.LARGE);
- pd = Filerelation.readFile(pl);
- if (pd.getFinish() == null) {
- pd.setFinish(Calendar.getInstance());
- Filerelation.createFile(pd);
- }
- if (is2) {
- pl.sendMessage("[foofle drive]プランを" + plan.LARGE + "プランに変更しました。");
- }
- break;
- }
- pl.closeInventory();
- } else if (e.getSlot() == 11) {
- e.setCancelled(true);
- e.getWhoClicked().closeInventory();
- } else if (clickedItem.getType() == Material.LIGHT_GRAY_STAINED_GLASS_PANE) {
- e.setCancelled(true);
- }
- }
- }
- }
- }
- }
-
- private Inventory yesornoInv(){
- Inventory inv = Bukkit.createInventory(null,27,"契約してよろしいですか?");
- ItemStack is = new ItemStack(Material.LIGHT_GRAY_STAINED_GLASS_PANE,1);
- ItemMeta im0 = is.getItemMeta();
- im0.setDisplayName(" ");
- ItemStack is1 = new ItemStack(Material.GREEN_STAINED_GLASS_PANE,1);
- ItemMeta im1 = is1.getItemMeta();
- im1.setDisplayName("はい");
- ItemStack is2 = new ItemStack(Material.RED_STAINED_GLASS_PANE,1);
- ItemMeta im2 = is1.getItemMeta();
- im2.setDisplayName("いいえ");
-
- is.setItemMeta(im0);
- is1.setItemMeta(im1);
- is2.setItemMeta(im2);
-
- for(int a = 0 ; a<= 26 ; a++){
- if(a == 11){
- inv.setItem(a,is2);
- }
- else if(a == 15){
- inv.setItem(a,is1);
- }
- else {
- inv.setItem(a,is);
- }
- }
- return inv;
- }
+ private static final HashMap provisionalPlan = new HashMap<>();
+
+ public GUIEvent(Plugin pl) {
+ Bukkit.getPluginManager().registerEvents(this, pl);
+ }
+
+ @EventHandler
+ public void onInventoryClickEvent(InventoryClickEvent e) {
+ if(!(e.getWhoClicked() instanceof Player player)) {
+ return;
+ }
+ if ((CommandMain.isopenInventory.containsKey(player) && CommandMain.isopenInventory.get(player)) == false) {
+ return;
+ }
+
+ ItemStack clickedItem = e.getCurrentItem();
+ Inventory clickedInventory = e.getClickedInventory();
+ if (clickedItem == null || clickedInventory == null || !clickedItem.hasItemMeta()) {
+ return;
+ }
+
+ if (e.getView().getType() != InventoryType.CREATIVE && e.getView().getTitle().contains("プラン選択画面")) {
+ handlePlanSelection(e, player);
+ } else if (e.getView().getTitle().contains("契約してよろしいですか?")) {
+ handleContractConfirmation(e, player);
+ }
+ }
+
+ private void handlePlanSelection(InventoryClickEvent e, Player player) {
+ switch (e.getSlot()) {
+ case 10:
+ openConfirmationInventory(e, player, plan.FREE);
+ break;
+ case 12:
+ openConfirmationInventory(e, player, plan.LIGHT);
+ break;
+ case 14:
+ openConfirmationInventory(e, player, plan.MIDDLE);
+ break;
+ case 16:
+ openConfirmationInventory(e, player, plan.LARGE);
+ break;
+ default:
+ if (e.getCurrentItem().getType() == Material.LIGHT_GRAY_STAINED_GLASS_PANE) {
+ e.setCancelled(true);
+ }
+ break;
+ }
+ }
+
+ private void openConfirmationInventory(InventoryClickEvent e, Player player, plan selectedPlan) {
+ e.setCancelled(true);
+ player.openInventory(createConfirmationInventory());
+ provisionalPlan.put(player, selectedPlan);
+ }
+
+ private void handleContractConfirmation(InventoryClickEvent e, Player player) {
+ switch (e.getSlot()) {
+ case 15:
+ confirmPlanChange(e, player);
+ break;
+ case 11:
+ e.setCancelled(true);
+ player.closeInventory();
+ break;
+ default:
+ if (e.getCurrentItem().getType() == Material.LIGHT_GRAY_STAINED_GLASS_PANE) {
+ e.setCancelled(true);
+ }
+ break;
+ }
+ }
+
+ private void confirmPlanChange(InventoryClickEvent e, Player player) {
+ e.setCancelled(true);
+ plan selectedPlan = provisionalPlan.get(player);
+ boolean planChanged = InventoryAPI.changePlan(player, selectedPlan);
+ Playerdata playerData = FileRelationUtils.readFile(player);
+
+ if (playerData.getFinish() == null) {
+ playerData.setFinish(Calendar.getInstance());
+ FileRelationUtils.createFile(playerData);
+ }
+
+ if (planChanged) {
+ player.sendMessage("[foofle drive]プランを" + selectedPlan + "プランに変更しました。");
+ }
+
+ player.closeInventory();
+ }
+
+ private Inventory createConfirmationInventory() {
+ Inventory inv = Bukkit.createInventory(null, 27, "契約してよろしいですか?");
+ ItemStack grayPane = createItemStack(Material.LIGHT_GRAY_STAINED_GLASS_PANE, " ");
+ ItemStack greenPane = createItemStack(Material.GREEN_STAINED_GLASS_PANE, "はい");
+ ItemStack redPane = createItemStack(Material.RED_STAINED_GLASS_PANE, "いいえ");
+
+ for (int i = 0; i <= 26; i++) {
+ if (i == 11) {
+ inv.setItem(i, redPane);
+ } else if (i == 15) {
+ inv.setItem(i, greenPane);
+ } else {
+ inv.setItem(i, grayPane);
+ }
+ }
+ return inv;
+ }
+
+ private ItemStack createItemStack(Material material, String displayName) {
+ ItemStack itemStack = new ItemStack(material, 1);
+ ItemMeta itemMeta = itemStack.getItemMeta();
+ itemMeta.setDisplayName(displayName);
+ itemStack.setItemMeta(itemMeta);
+ return itemStack;
+ }
}
diff --git a/src/main/java/ga/ganma/foofledrive/Listener/GetEvent.java b/src/main/java/ga/ganma/foofledrive/Listener/GetEvent.java
index 48d1bee..7ba8c92 100644
--- a/src/main/java/ga/ganma/foofledrive/Listener/GetEvent.java
+++ b/src/main/java/ga/ganma/foofledrive/Listener/GetEvent.java
@@ -1,7 +1,6 @@
package ga.ganma.foofledrive.Listener;
-import ga.ganma.foofledrive.Foofledrive;
-import ga.ganma.foofledrive.Filerelation;
+import ga.ganma.foofledrive.FileRelationUtils;
import ga.ganma.foofledrive.plan;
import ga.ganma.foofledrive.playerdata.Playerdata;
import org.bukkit.Bukkit;
@@ -17,58 +16,67 @@
import java.util.HashMap;
public class GetEvent implements Listener {
- private Player p;
- private Plugin pl;
+ public static final HashMap isInventoryOpen = new HashMap<>();
+ private final Plugin plugin;
- public static HashMap isinventoryopen = new HashMap<>();
+ public GetEvent(Plugin plugin) {
+ Bukkit.getPluginManager().registerEvents(this, plugin);
+ this.plugin = plugin;
+ }
- public GetEvent(Plugin pl) {
- Bukkit.getPluginManager().registerEvents(this, pl);
- this.pl = pl;
- }
+ @EventHandler
+ public void onPlayerJoinEvent(PlayerJoinEvent event) {
+ Player player = event.getPlayer();
+ Playerdata playerData = FileRelationUtils.readFile(player);
- @EventHandler
- public void getplayerloginEvent(PlayerJoinEvent e) {
- p = e.getPlayer();
- if (Filerelation.namecheck(p)) {
- if (Filerelation.readFile(p).getPlan() == plan.FREE) {
- p.sendMessage("[foofle drive]あなたは現在" + Filerelation.readFile(p).getPlan() + "プランに加入しています。");
- return;
- }
- else {
- Playerdata pd = Filerelation.readFile(p);
- double bal = Foofledrive.econ.getBalance(p);
- if (pd.getFinish() != null) {
- new BukkitRunnable() {
- @Override
- public void run() {
- long diffTime = pd.getFinish().getTimeInMillis() - Calendar.getInstance().getTimeInMillis();//[3]
- int diffDayMillis = 1000 * 60 * 60 * 24;//[4]
- int diffDays = (int) (diffTime / diffDayMillis);
- p.sendMessage("[foofle drive]あなたは現在"+Filerelation.readFile(p).getPlan() +"プランに加入しています。");
- p.sendMessage("[foofle drive]支払日まであと"+ diffDays +"日です。");//[5]
- }
- }.runTaskLater(pl,60);
- }
- else {
- pd.setFinish(Calendar.getInstance());
- Filerelation.createFile(pd);
- }
- }
- }
- else {
- Playerdata pd = new Playerdata(p, Bukkit.getServer().createInventory(null, 9, "foofle Drive"), plan.FREE);
- Filerelation.createFile(pd);
- p.sendMessage("[foofle drive]あなたは自動的に" + Filerelation.readFile(p).getPlan() + "プランに加入しました。");
- }
- }
+ if (FileRelationUtils.nameCheck(player)) {
+ handleExistingPlayer(player, playerData);
+ } else {
+ handleNewPlayer(player);
+ }
+ }
- @EventHandler
- public void getPlayerInventoryCloseEvent(InventoryCloseEvent e) {
- Player pl = (Player) e.getPlayer();
- if(e.getView().getTitle().equals("foofle drive")){
- Playerdata pd = new Playerdata(pl,e.getView().getTopInventory(),Filerelation.readFile(pl).getPlan());
- Filerelation.createFile(pd);
- }
- }
-}
+ private void handleExistingPlayer(Player player, Playerdata playerData) {
+ if (playerData.getPlan() == plan.FREE) {
+ player.sendMessage("[foofle drive]あなたは現在" + playerData.getPlan() + "プランに加入しています。");
+ } else {
+ handlePaidPlanPlayer(player, playerData);
+ }
+ }
+
+ private void handlePaidPlanPlayer(Player player, Playerdata playerData) {
+ if (playerData.getFinish() != null) {
+ sendPaymentReminder(player, playerData);
+ } else {
+ playerData.setFinish(Calendar.getInstance());
+ FileRelationUtils.createFile(playerData);
+ }
+ }
+
+ private void sendPaymentReminder(Player player, Playerdata playerData) {
+ new BukkitRunnable() {
+ @Override
+ public void run() {
+ long diffTime = playerData.getFinish().getTimeInMillis() - Calendar.getInstance().getTimeInMillis();
+ int diffDays = (int) (diffTime / (1000 * 60 * 60 * 24));
+ player.sendMessage("[foofle drive]あなたは現在" + playerData.getPlan() + "プランに加入しています。");
+ player.sendMessage("[foofle drive]支払日まであと" + diffDays + "日です。");
+ }
+ }.runTaskLater(plugin, 60);
+ }
+
+ private void handleNewPlayer(Player player) {
+ Playerdata newPlayerData = new Playerdata(player, Bukkit.getServer().createInventory(null, 9, "foofle Drive"), plan.FREE);
+ FileRelationUtils.createFile(newPlayerData);
+ player.sendMessage("[foofle drive]あなたは自動的に" + newPlayerData.getPlan() + "プランに加入しました。");
+ }
+
+ @EventHandler
+ public void onInventoryCloseEvent(InventoryCloseEvent event) {
+ Player player = (Player) event.getPlayer();
+ if ("foofle drive".equals(event.getView().getTitle())) {
+ Playerdata playerData = new Playerdata(player, event.getView().getTopInventory(), FileRelationUtils.readFile(player).getPlan());
+ FileRelationUtils.createFile(playerData);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/ga/ganma/foofledrive/bizlogic/convert/ConvertPlayerData.java b/src/main/java/ga/ganma/foofledrive/bizlogic/convert/ConvertPlayerData.java
new file mode 100644
index 0000000..c13d329
--- /dev/null
+++ b/src/main/java/ga/ganma/foofledrive/bizlogic/convert/ConvertPlayerData.java
@@ -0,0 +1,22 @@
+package ga.ganma.foofledrive.bizlogic.convert;
+
+import ga.ganma.foofledrive.FoofleDrivePlan;
+import ga.ganma.foofledrive.plan;
+import ga.ganma.foofledrive.playerdata.PlayerDriveData;
+import ga.ganma.foofledrive.playerdata.Playerdata;
+
+public class ConvertPlayerData {
+
+ public PlayerDriveData fromPlayerData(Playerdata playerdata) {
+ return new PlayerDriveData(playerdata.getMcid(), playerdata.getInv(), ConvertPlan(playerdata.getPlan()));
+ }
+
+ private FoofleDrivePlan ConvertPlan(plan plan) {
+ return switch (plan) {
+ case FREE -> FoofleDrivePlan.FREE;
+ case LIGHT -> FoofleDrivePlan.LIGHT;
+ case MIDDLE -> FoofleDrivePlan.MIDDLE;
+ case LARGE -> FoofleDrivePlan.LARGE;
+ };
+ }
+}
diff --git a/src/main/java/ga/ganma/foofledrive/bukkitRunnable/Runnable.java b/src/main/java/ga/ganma/foofledrive/bukkitRunnable/Runnable.java
index 67254df..13ed072 100644
--- a/src/main/java/ga/ganma/foofledrive/bukkitRunnable/Runnable.java
+++ b/src/main/java/ga/ganma/foofledrive/bukkitRunnable/Runnable.java
@@ -1,5 +1,9 @@
+/**
+ * このクラスはBukkitのRunnableを拡張し、定期的にプレイヤーデータを処理するタスクを実行します。
+ */
package ga.ganma.foofledrive.bukkitRunnable;
+import ga.ganma.foofledrive.FileRelationUtils;
import ga.ganma.foofledrive.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
@@ -9,29 +13,51 @@
import java.io.File;
import java.util.UUID;
+/**
+ * BukkitのRunnableを拡張したクラス。
+ * プラグインのインスタンスとプレイヤーデータフォルダを保持し、定期的にプレイヤーデータを処理します。
+ */
public class Runnable extends BukkitRunnable {
- private Plugin plugin;
+ private final Plugin plugin;
+ private final File playerDataFolder;
- public Runnable(Plugin pl) {
- plugin = pl;
- }
+ /**
+ * コンストラクタ。
+ *
+ * @param plugin プラグインのインスタンス
+ */
+ public Runnable(Plugin plugin) {
+ this.plugin = plugin;
+ this.playerDataFolder = FileRelationUtils.PLAYERDATA_FOLDER.toFile();
+ }
- @Override
- public void run() {
- String FS = File.separator;
- File folder = new File(plugin.getDataFolder() + FS + "playerdata");
- if (folder.exists()) {
- File[] list = folder.listFiles();
- if (list != null) {
- for (File f : list) {
- String name = f.getName();
- name = name.substring(0, name.lastIndexOf('.'));
- UUID id = UUID.fromString(name);
- OfflinePlayer pl = Bukkit.getOfflinePlayer(id);
- Economy.paymoney(pl);
- }
+ /**
+ * 定期的に実行されるタスク。
+ * プレイヤーデータフォルダが存在する場合、その中のファイルを処理します。
+ */
+ @Override
+ public void run() {
+ if (playerDataFolder.exists()) {
+ File[] playerDataFiles = playerDataFolder.listFiles();
+ if (playerDataFiles != null) {
+ for (File playerDataFile : playerDataFiles) {
+ processPlayerDataFile(playerDataFile);
+ }
+ }
+ }
+ }
- }
- }
- }
-}
+ /**
+ * プレイヤーデータファイルを処理します。
+ * ファイル名からUUIDを取得し、対応するオフラインプレイヤーに対して支払い処理を行います。
+ *
+ * @param playerDataFile プレイヤーデータファイル
+ */
+ private void processPlayerDataFile(File playerDataFile) {
+ String fileName = playerDataFile.getName();
+ String uuidString = fileName.replace(FileRelationUtils.DATA_FILE_EXTENTION, "");
+ UUID playerUUID = UUID.fromString(uuidString);
+ OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(playerUUID);
+ Economy.paymoney(offlinePlayer);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/ga/ganma/foofledrive/command/CommandMain.java b/src/main/java/ga/ganma/foofledrive/command/CommandMain.java
index 40d09fa..2164d37 100644
--- a/src/main/java/ga/ganma/foofledrive/command/CommandMain.java
+++ b/src/main/java/ga/ganma/foofledrive/command/CommandMain.java
@@ -1,6 +1,6 @@
package ga.ganma.foofledrive.command;
-import ga.ganma.foofledrive.Filerelation;
+import ga.ganma.foofledrive.FileRelationUtils;
import ga.ganma.foofledrive.Foofledrive;
import ga.ganma.foofledrive.economy.Economy;
import ga.ganma.foofledrive.plan;
@@ -21,119 +21,204 @@
import java.util.List;
import java.util.logging.Level;
+/**
+ * CommandMainクラスは、/flまたは/foofledriveコマンドの実行を処理するクラスです。
+ * このクラスは、プレイヤーがコマンドを入力した際に適切なアクションを実行します。
+ */
public class CommandMain implements CommandExecutor {
- public static HashMap isopenInventory = new HashMap<>();
- private Plugin pl;
-
- public CommandMain(Plugin pl) {
- this.pl = pl;
- }
-
- @Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- if (sender instanceof Player) {
- Player p = (Player) sender;
- if (label.equalsIgnoreCase("fl") || label.equalsIgnoreCase("foofledrive")) {
- if (args.length != 0) {
- if (args[0].equalsIgnoreCase("open")) {
- new Subopen(this.pl, (Player) sender);
- } else if (args[0].equalsIgnoreCase("plan")) {
- if (args.length > 1) {
- if (args[1].equalsIgnoreCase("LIGHT")) {
- new Subplan(this.pl, p, plan.LIGHT);
- Filerelation.readFile(p).setFinish(Calendar.getInstance());
- } else if (args[1].equalsIgnoreCase("FREE")) {
- new Subplan(this.pl, p, plan.FREE);
- }else if (args[1].equalsIgnoreCase("MIDDLE")) {
- new Subplan(this.pl, p, plan.MIDDLE);
- }else if (args[1].equalsIgnoreCase("LARGE")) {
- new Subplan(this.pl, p, plan.LARGE);
- }
- } else {
- Inventory inv = Bukkit.createInventory(null,27,"プラン選択画面");
- ItemStack is = new ItemStack(Material.LIGHT_GRAY_STAINED_GLASS_PANE,1);
- ItemMeta im0 = is.getItemMeta();
- im0.setDisplayName(" ");
- ItemStack free = new ItemStack(Material.PAPER,1);
- ItemMeta im1 = free.getItemMeta();
- im1.setDisplayName("FREEプラン");
- List freeprice = new ArrayList<>();
- freeprice.add(Economy.getplanmoney(plan.FREE) + Foofledrive.unit);
- im1.setLore(freeprice);
- ItemStack light = new ItemStack(Material.IRON_INGOT,1);
- ItemMeta im2 = light.getItemMeta();
- im2.setDisplayName("LIGHTプラン");
- List lightprice = new ArrayList<>();
- lightprice.add(Economy.getplanmoney(plan.LIGHT) + Foofledrive.unit);
- im2.setLore(lightprice);
- ItemStack middle = new ItemStack(Material.GOLD_INGOT,1);
- ItemMeta im3 = middle.getItemMeta();
- im3.setDisplayName("MIDDLEプラン");
- List middleprice = new ArrayList<>();
- middleprice.add(Economy.getplanmoney(plan.MIDDLE) + Foofledrive.unit);
- im3.setLore(middleprice);
- ItemStack large = new ItemStack(Material.DIAMOND,1);
- ItemMeta im4 = middle.getItemMeta();
- im4.setDisplayName("LARGEプラン");
- List largeprice = new ArrayList<>();
- largeprice.add(Economy.getplanmoney(plan.LARGE) + Foofledrive.unit);
- im4.setLore(largeprice);
-
- is.setItemMeta(im0);
- free.setItemMeta(im1);
- light.setItemMeta(im2);
- middle.setItemMeta(im3);
- large.setItemMeta(im4);
-
- for(int a = 0;a <= 26;a++) {
- if(a == 10){
- inv.setItem(a,free);
- }
- else if (a == 12){
- inv.setItem(a,light);
- }
- else if(a == 14){
- inv.setItem(a,middle);
- }
- else if(a == 16){
- inv.setItem(a,large);
- }
- else {
- inv.setItem(a,is);
- }
- }
- isopenInventory.put(p,true);
- p.openInventory(inv);
- }
- }
- else if(args[0].equalsIgnoreCase("reload")) {
- if (p.isOp()) {
- pl.reloadConfig();
- Foofledrive.configamout[0] = pl.getConfig().getInt("amout.FREE");
- Foofledrive.configamout[1] = pl.getConfig().getInt("amout.LIGHT");
- Foofledrive.configamout[2] = pl.getConfig().getInt("amout.MIDDLE");
- Foofledrive.configamout[3] = pl.getConfig().getInt("amout.LARGE");
- Foofledrive.unit = pl.getConfig().getString("unit");
- p.sendMessage("[foofle drive]コンフィグをリロードしました。");
- }
- else {
- p.sendMessage("[foofle drive]このコマンドは管理者専用です。");
- }
- }
- else if(args[0].equalsIgnoreCase("help")){
- p.sendMessage("[free drive] /fl open でfoofle driveを開くことができます。");
- p.sendMessage("[free drive] /fl plan で好きなプランに加入することができます。");
- }
- }
- else {
- p.sendMessage("[free drive] /fl open でfoofle driveを開くことができます。");
- p.sendMessage("[free drive] /fl plan で好きなプランに加入することができます。");
- }
- }
- }
- else {
- pl.getLogger().log(Level.INFO, "このコマンドはコンソールからではなくプレイヤーが入力するものです。");
- }
- return false;
- }
-}
+ public static final HashMap isopenInventory = new HashMap<>();
+ private final Plugin plugin;
+
+ public CommandMain(Plugin plugin) {
+ this.plugin = plugin;
+ }
+
+ /**
+ * コマンドが実行されたときに呼び出されるメソッドです。
+ *
+ * @param sender コマンドを実行したエンティティ
+ * @param command 実行されたコマンド
+ * @param label コマンドのラベル
+ * @param args コマンドの引数
+ * @return コマンドが正常に処理された場合はtrue、そうでない場合はfalse
+ */
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ if (sender instanceof Player) {
+ Player player = (Player) sender;
+ if (label.equalsIgnoreCase("fl") || label.equalsIgnoreCase("foofledrive")) {
+ handleCommand(player, args);
+ }
+ } else {
+ plugin.getLogger().log(Level.INFO, "このコマンドはコンソールからではなくプレイヤーが入力するものです。");
+ }
+ return false;
+ }
+
+ /**
+ * コマンドの引数に基づいて適切なアクションを実行します。
+ *
+ * @param player コマンドを実行したプレイヤー
+ * @param args コマンドの引数
+ */
+ private void handleCommand(Player player, String[] args) {
+ if (args.length == 0) {
+ sendHelpMessage(player);
+ return;
+ }
+
+ switch (args[0].toLowerCase()) {
+ case "open":
+ new SubmitOpen(plugin, player);
+ break;
+ case "plan":
+ handlePlanCommand(player, args);
+ break;
+ case "reload":
+ handleReloadCommand(player);
+ break;
+ case "help":
+ sendHelpMessage(player);
+ break;
+ default:
+ sendHelpMessage(player);
+ break;
+ }
+ }
+
+ /**
+ * /fl planコマンドの処理を行います。
+ *
+ * @param player コマンドを実行したプレイヤー
+ * @param args コマンドの引数
+ */
+ private void handlePlanCommand(Player player, String[] args) {
+ if (args.length > 1) {
+ plan selectedPlan = getPlanFromString(args[1]);
+ if (selectedPlan != null) {
+ new SubmitPlan(plugin, player, selectedPlan);
+ if (selectedPlan == plan.LIGHT) {
+ FileRelationUtils.readFile(player).setFinish(Calendar.getInstance());
+ }
+ } else {
+ sendPlanSelectionInventory(player);
+ }
+ } else {
+ sendPlanSelectionInventory(player);
+ }
+ }
+
+ /**
+ * 文字列からplan列挙型を取得します。
+ *
+ * @param planString プランを表す文字列
+ * @return 対応するplan列挙型、無効な場合はnull
+ */
+ private plan getPlanFromString(String planString) {
+ try {
+ return plan.valueOf(planString.toUpperCase());
+ } catch (IllegalArgumentException e) {
+ return null;
+ }
+ }
+
+ /**
+ * /fl reloadコマンドの処理を行います。
+ *
+ * @param player コマンドを実行したプレイヤー
+ */
+ private void handleReloadCommand(Player player) {
+ if (player.isOp()) {
+ plugin.reloadConfig();
+ Foofledrive.configValues[0] = plugin.getConfig().getInt("amout.FREE");
+ Foofledrive.configValues[1] = plugin.getConfig().getInt("amout.LIGHT");
+ Foofledrive.configValues[2] = plugin.getConfig().getInt("amout.MIDDLE");
+ Foofledrive.configValues[3] = plugin.getConfig().getInt("amout.LARGE");
+ Foofledrive.unit = plugin.getConfig().getString("unit");
+ player.sendMessage("[foofle drive]コンフィグをリロードしました。");
+ } else {
+ player.sendMessage("[foofle drive]このコマンドは管理者専用です。");
+ }
+ }
+
+ /**
+ * プレイヤーにヘルプメッセージを送信します。
+ *
+ * @param player メッセージを受け取るプレイヤー
+ */
+ private void sendHelpMessage(Player player) {
+ player.sendMessage("[foofle drive] /fl open でfoofle driveを開くことができます。");
+ player.sendMessage("[foofle drive] /fl plan で好きなプランに加入することができます。");
+ }
+
+ /**
+ * プレイヤーにプラン選択インベントリを表示します。
+ *
+ * @param player インベントリを表示するプレイヤー
+ */
+ private void sendPlanSelectionInventory(Player player) {
+ Inventory inventory = Bukkit.createInventory(null, 27, "プラン選択画面");
+ ItemStack glassPane = createItemStack(Material.LIGHT_GRAY_STAINED_GLASS_PANE, " ");
+ ItemStack freePlan = createPlanItemStack(Material.PAPER, "FREEプラン", plan.FREE);
+ ItemStack lightPlan = createPlanItemStack(Material.IRON_INGOT, "LIGHTプラン", plan.LIGHT);
+ ItemStack middlePlan = createPlanItemStack(Material.GOLD_INGOT, "MIDDLEプラン", plan.MIDDLE);
+ ItemStack largePlan = createPlanItemStack(Material.DIAMOND, "LARGEプラン", plan.LARGE);
+
+ for (int i = 0; i <= 26; i++) {
+ switch (i) {
+ case 10:
+ inventory.setItem(i, freePlan);
+ break;
+ case 12:
+ inventory.setItem(i, lightPlan);
+ break;
+ case 14:
+ inventory.setItem(i, middlePlan);
+ break;
+ case 16:
+ inventory.setItem(i, largePlan);
+ break;
+ default:
+ inventory.setItem(i, glassPane);
+ break;
+ }
+ }
+
+ isopenInventory.put(player, true);
+ player.openInventory(inventory);
+ }
+
+ /**
+ * 指定された素材と表示名でItemStackを作成します。
+ *
+ * @param material アイテムの素材
+ * @param displayName アイテムの表示名
+ * @return 作成されたItemStack
+ */
+ private ItemStack createItemStack(Material material, String displayName) {
+ ItemStack itemStack = new ItemStack(material, 1);
+ ItemMeta itemMeta = itemStack.getItemMeta();
+ itemMeta.setDisplayName(displayName);
+ itemStack.setItemMeta(itemMeta);
+ return itemStack;
+ }
+
+ /**
+ * 指定されたプランの情報を含むItemStackを作成します。
+ *
+ * @param material アイテムの素材
+ * @param displayName アイテムの表示名
+ * @param planType プランの種類
+ * @return 作成されたItemStack
+ */
+ private ItemStack createPlanItemStack(Material material, String displayName, plan planType) {
+ ItemStack itemStack = new ItemStack(material, 1);
+ ItemMeta itemMeta = itemStack.getItemMeta();
+ itemMeta.setDisplayName(displayName);
+ List lore = new ArrayList<>();
+ lore.add(Economy.getPlanCost(planType) + Foofledrive.unit);
+ itemMeta.setLore(lore);
+ itemStack.setItemMeta(itemMeta);
+ return itemStack;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/ga/ganma/foofledrive/command/SubmitOpen.java b/src/main/java/ga/ganma/foofledrive/command/SubmitOpen.java
new file mode 100644
index 0000000..a666e87
--- /dev/null
+++ b/src/main/java/ga/ganma/foofledrive/command/SubmitOpen.java
@@ -0,0 +1,16 @@
+package ga.ganma.foofledrive.command;
+
+import ga.ganma.foofledrive.FileRelationUtils;
+import ga.ganma.foofledrive.Listener.GetEvent;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
+
+public class SubmitOpen {
+ Plugin pl;
+
+ public SubmitOpen(Plugin pl, Player p) {
+ this.pl = pl;
+ p.openInventory(FileRelationUtils.readFile(p).getInv());
+ GetEvent.isInventoryOpen.put(p, true);
+ }
+}
diff --git a/src/main/java/ga/ganma/foofledrive/command/SubmitPlan.java b/src/main/java/ga/ganma/foofledrive/command/SubmitPlan.java
new file mode 100644
index 0000000..684ed7d
--- /dev/null
+++ b/src/main/java/ga/ganma/foofledrive/command/SubmitPlan.java
@@ -0,0 +1,31 @@
+package ga.ganma.foofledrive.command;
+
+import ga.ganma.foofledrive.FileRelationUtils;
+import ga.ganma.foofledrive.inventoryRelation.InventoryAPI;
+import ga.ganma.foofledrive.plan;
+import ga.ganma.foofledrive.playerdata.Playerdata;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
+
+import java.util.Calendar;
+
+public class SubmitPlan {
+ Plugin pl;
+ Player p;
+
+ public SubmitPlan(Plugin pl, Player player, plan plan) {
+ this.pl = pl;
+ p = player;
+ boolean isSuccess;
+ isSuccess = InventoryAPI.changePlan(player, plan);
+ Playerdata pd = FileRelationUtils.readFile(p);
+ if (pd.getFinish() == null) {
+ pd.setFinish(Calendar.getInstance());
+ FileRelationUtils.createFile(pd);
+ }
+
+ if (isSuccess) {
+ p.sendMessage("[foofle drive]プランを" + plan + "プランに変更しました。");
+ }
+ }
+}
diff --git a/src/main/java/ga/ganma/foofledrive/command/Subopen.java b/src/main/java/ga/ganma/foofledrive/command/Subopen.java
deleted file mode 100644
index 5cd48a5..0000000
--- a/src/main/java/ga/ganma/foofledrive/command/Subopen.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package ga.ganma.foofledrive.command;
-
-import ga.ganma.foofledrive.Filerelation;
-import ga.ganma.foofledrive.Listener.GetEvent;
-import org.bukkit.entity.Player;
-import org.bukkit.plugin.Plugin;
-
-public class Subopen {
- Plugin pl;
- public Subopen(Plugin pl, Player p){
- this.pl = pl;
- p.openInventory(Filerelation.readFile(p).getInv());
- GetEvent.isinventoryopen.put(p,true);
- }
-}
diff --git a/src/main/java/ga/ganma/foofledrive/command/Subplan.java b/src/main/java/ga/ganma/foofledrive/command/Subplan.java
deleted file mode 100644
index b4dc827..0000000
--- a/src/main/java/ga/ganma/foofledrive/command/Subplan.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package ga.ganma.foofledrive.command;
-
-import ga.ganma.foofledrive.Filerelation;
-import ga.ganma.foofledrive.inventoryRelation.InventoryAPI;
-import ga.ganma.foofledrive.plan;
-import ga.ganma.foofledrive.playerdata.Playerdata;
-import org.bukkit.entity.Player;
-import org.bukkit.plugin.Plugin;
-
-import java.util.Calendar;
-
-public class Subplan {
- Plugin pl;
- Player p;
- public Subplan(Plugin pl, Player player, plan plan){
- this.pl = pl;
- p = player;
- boolean issuccess;
- issuccess = InventoryAPI.planchange(player,plan);
- Playerdata pd = Filerelation.readFile(p);
- if(pd.getFinish() == null) {
- pd.setFinish(Calendar.getInstance());
- Filerelation.createFile(pd);
- }
-
- if(issuccess) {
- p.sendMessage("[foofle drive]プランを" + plan + "プランに変更しました。");
- }
- }
-}
diff --git a/src/main/java/ga/ganma/foofledrive/economy/Economy.java b/src/main/java/ga/ganma/foofledrive/economy/Economy.java
index ac15e4a..e27c4bc 100644
--- a/src/main/java/ga/ganma/foofledrive/economy/Economy.java
+++ b/src/main/java/ga/ganma/foofledrive/economy/Economy.java
@@ -1,7 +1,7 @@
package ga.ganma.foofledrive.economy;
+import ga.ganma.foofledrive.FileRelationUtils;
import ga.ganma.foofledrive.Foofledrive;
-import ga.ganma.foofledrive.Filerelation;
import ga.ganma.foofledrive.inventoryRelation.InventoryAPI;
import ga.ganma.foofledrive.plan;
import ga.ganma.foofledrive.playerdata.Playerdata;
@@ -13,165 +13,50 @@
import java.util.logging.Level;
public class Economy {
- public static void paymoney(Player p) {
- Playerdata pd = Filerelation.readFile(p);
- if (Foofledrive.econ.hasAccount(p)) {
- double bal = Foofledrive.econ.getBalance(p);
- if (pd.getFinish() != null) {
- if (pd.getFinish().before(Calendar.getInstance())) {
- switch (pd.getPlan()) {
- case LIGHT:
- if (bal >= getplanmoney(plan.LIGHT)) {
- Foofledrive.econ.withdrawPlayer(p, getplanmoney(plan.LIGHT));
- Bukkit.getLogger().log(Level.INFO, "[foofle drive]" + p.getName() + "のLIGHTプランの料金を支払いました。");
- if (p.isOnline()) {
- p.sendMessage("[foofle drive]料金の支払いをしました。");
- }
- pd.setFinish(Calendar.getInstance());
- Filerelation.createFile(pd);
- } else {
- InventoryAPI.planchange(p, plan.FREE);
- Bukkit.getLogger().log(Level.INFO, "[foofle drive]" + p.getName() + "のお金が足りないため、自動的にfreeプランへ移行しました。");
- Bukkit.getLogger().log(Level.INFO, "[foofle drive]その際、2段目以降にあるアイテムを全消去しました。");
- if (p.isOnline()) {
- p.sendMessage("[foofle drive]お金が足りないため、自動的にfreeプランへ移行しました。");
- p.sendMessage("[foofle drive]その際、2段目以降にあるアイテムを全消去しました。");
- }
- }
- break;
- case MIDDLE:
- if (bal >= getplanmoney(plan.MIDDLE)) {
- Foofledrive.econ.withdrawPlayer(p, getplanmoney(plan.MIDDLE));
- Bukkit.getLogger().log(Level.INFO, "[foofle drive]" + p.getName() + "のMIDDLEプランの料金を支払いました。");
- if (p.isOnline()) {
- p.sendMessage("[foofle drive]料金の支払いをしました。");
- }
- pd.setFinish(Calendar.getInstance());
- Filerelation.createFile(pd);
- } else {
- InventoryAPI.planchange(p, plan.FREE);
- Bukkit.getLogger().log(Level.INFO, "[foofle drive]" + p.getName() + "のお金が足りないため、自動的にfreeプランへ移行しました。");
- Bukkit.getLogger().log(Level.INFO, "[foofle drive]その際、2段目以降にあるアイテムを全消去しました。");
- if (p.isOnline()) {
- p.sendMessage("[foofle drive]お金が足りないため、自動的にfreeプランへ移行しました。");
- p.sendMessage("[foofle drive]その際、2段目以降にあるアイテムを全消去しました。");
- }
- }
- break;
- case LARGE:
- if (bal >= getplanmoney(plan.LARGE)) {
- Foofledrive.econ.withdrawPlayer(p, getplanmoney(plan.LARGE));
- Bukkit.getLogger().log(Level.INFO, "[foofle drive]" + p.getName() + "のLARGEプランの料金を支払いました。");
- if (p.isOnline()) {
- p.sendMessage("[foofle drive]料金の支払いをしました。");
- }
- pd.setFinish(Calendar.getInstance());
- Filerelation.createFile(pd);
- } else {
- InventoryAPI.planchange(p, plan.FREE);
- Bukkit.getLogger().log(Level.INFO, "[foofle drive]" + p.getName() + "のお金が足りないため、自動的にfreeプランへ移行しました。");
- Bukkit.getLogger().log(Level.INFO, "[foofle drive]その際、2段目以降にあるアイテムを全消去しました。");
- if (p.isOnline()) {
- p.sendMessage("[foofle drive]お金が足りないため、自動的にfreeプランへ移行しました。");
- p.sendMessage("[foofle drive]その際、2段目以降にあるアイテムを全消去しました。");
- }
- }
- break;
- }
- }
- }
- }
- }
- public static void paymoney(OfflinePlayer p) {
- Playerdata pd = Filerelation.readFile(p);
- if (p != null){
- double bal = Foofledrive.econ.getBalance(p);
- if (pd.getFinish() != null) {
- if (pd.getFinish().before(Calendar.getInstance())) {
- int[] amout = Foofledrive.configamout;
- switch (pd.getPlan()) {
- case LIGHT:
- if (bal >= amout[1]) {
- Foofledrive.econ.withdrawPlayer(p, amout[1]);
- Bukkit.getLogger().log(Level.INFO, "[foofle drive]" + p.getName() + "のLIGHTプランの料金を支払いました。");
- if (p.isOnline()) {
- Player pl = (Player) p;
- pl.sendMessage("[foofle drive]料金の支払いをしました。");
- }
- pd.setFinish(Calendar.getInstance());
- Filerelation.createFile(pd);
- } else {
- InventoryAPI.planchange(p, plan.FREE);
- Bukkit.getLogger().log(Level.INFO, "[foofle drive]" + p.getName() + "のお金が足りないため、自動的にfreeプランへ移行しました。");
- Bukkit.getLogger().log(Level.INFO, "[foofle drive]その際、2段目以降にあるアイテムを全消去しました。");
- if (p.isOnline()) {
- Player pl = (Player) p;
- pl.sendMessage("[foofle drive]お金が足りないため、自動的にfreeプランへ移行しました。");
- pl.sendMessage("[foofle drive]その際、2段目以降にあるアイテムを全消去しました。");
- }
- }
- break;
- case MIDDLE:
- if (bal >= amout[2]) {
- Foofledrive.econ.withdrawPlayer(p, amout[2]);
- Bukkit.getLogger().log(Level.INFO, "[foofle drive]" + p.getName() + "のMIDDLEプランの料金を支払いました。");
- if (p.isOnline()) {
- Player pl = (Player) p;
- pl.sendMessage("[foofle drive]料金の支払いをしました。");
- }
- pd.setFinish(Calendar.getInstance());
- Filerelation.createFile(pd);
- } else {
- InventoryAPI.planchange(p, plan.FREE);
- Bukkit.getLogger().log(Level.INFO, "[foofle drive]" + p.getName() + "のお金が足りないため、自動的にfreeプランへ移行しました。");
- Bukkit.getLogger().log(Level.INFO, "[foofle drive]その際、2段目以降にあるアイテムを全消去しました。");
- if (p.isOnline()) {
- Player pl = (Player) p;
- pl.sendMessage("[foofle drive]お金が足りないため、自動的にfreeプランへ移行しました。");
- pl.sendMessage("[foofle drive]その際、2段目以降にあるアイテムを全消去しました。");
- }
- }
- break;
- case LARGE:
- if (bal >= amout[3]) {
- Foofledrive.econ.withdrawPlayer(p, amout[3]);
- Bukkit.getLogger().log(Level.INFO, "[foofle drive]" + p.getName() + "のLARGEプランの料金を支払いました。");
- if (p.isOnline()) {
- Player pl = (Player) p;
- pl.sendMessage("[foofle drive]料金の支払いをしました。");
- }
- pd.setFinish(Calendar.getInstance());
- Filerelation.createFile(pd);
- } else {
- InventoryAPI.planchange(p, plan.FREE);
- Bukkit.getLogger().log(Level.INFO, "[foofle drive]" + p.getName() + "のお金が足りないため、自動的にfreeプランへ移行しました。");
- Bukkit.getLogger().log(Level.INFO, "[foofle drive]その際、2段目以降にあるアイテムを全消去しました。");
- if (p.isOnline()) {
- Player pl = (Player) p;
- pl.sendMessage("[foofle drive]お金が足りないため、自動的にfreeプランへ移行しました。");
- pl.sendMessage("[foofle drive]その際、2段目以降にあるアイテムを全消去しました。");
- }
- }
- break;
- }
- }
- }
- }
- }
+ public static void paymoney(Player p) {
+ processPayment(p, FileRelationUtils.readFile(p), Foofledrive.econ.getBalance(p));
+ }
- public static int getplanmoney(plan plan){
- switch (plan){
- case FREE:
- return Foofledrive.configamout[0];
- case LIGHT:
- return Foofledrive.configamout[1];
- case MIDDLE:
- return Foofledrive.configamout[2];
- case LARGE:
- return Foofledrive.configamout[3];
- }
+ public static void paymoney(OfflinePlayer p) {
+ processPayment(p, FileRelationUtils.readFile(p), Foofledrive.econ.getBalance(p));
+ }
- return 0;
- }
+ private static void processPayment(OfflinePlayer p, Playerdata pd, double bal) {
+ if (pd.getFinish() != null && pd.getFinish().before(Calendar.getInstance())) {
+ int planCost = getPlanCost(pd.getPlan());
+ if (bal >= planCost) {
+ Foofledrive.econ.withdrawPlayer(p, planCost);
+ logAndNotify(p, pd.getPlan() + "プランの料金を支払いました。", "[foofle drive]料金の支払いをしました。");
+ pd.setFinish(Calendar.getInstance());
+ FileRelationUtils.createFile(pd);
+ } else {
+ InventoryAPI.changePlan(p, plan.FREE);
+ logAndNotify(p, "お金が足りないため、自動的にfreeプランへ移行しました。", "[foofle drive]お金が足りないため、自動的にfreeプランへ移行しました。");
+ logAndNotify(p, "その際、2段目以降にあるアイテムを全消去しました。", "[foofle drive]その際、2段目以降にあるアイテムを全消去しました。");
+ }
+ }
+ }
+
+ private static void logAndNotify(OfflinePlayer p, String logMessage, String notifyMessage) {
+ Bukkit.getLogger().log(Level.INFO, "[foofle drive]" + p.getName() + logMessage);
+ if (p.isOnline()) {
+ ((Player) p).sendMessage(notifyMessage);
+ }
+ }
+
+ public static int getPlanCost(plan plan) {
+ switch (plan) {
+ case FREE:
+ return Foofledrive.configValues[0];
+ case LIGHT:
+ return Foofledrive.configValues[1];
+ case MIDDLE:
+ return Foofledrive.configValues[2];
+ case LARGE:
+ return Foofledrive.configValues[3];
+ default:
+ return 0;
+ }
+ }
}
\ No newline at end of file
diff --git a/src/main/java/ga/ganma/foofledrive/inventoryRelation/InventoryAPI.java b/src/main/java/ga/ganma/foofledrive/inventoryRelation/InventoryAPI.java
index a30a484..49bf142 100644
--- a/src/main/java/ga/ganma/foofledrive/inventoryRelation/InventoryAPI.java
+++ b/src/main/java/ga/ganma/foofledrive/inventoryRelation/InventoryAPI.java
@@ -1,6 +1,6 @@
package ga.ganma.foofledrive.inventoryRelation;
-import ga.ganma.foofledrive.Filerelation;
+import ga.ganma.foofledrive.FileRelationUtils;
import ga.ganma.foofledrive.Foofledrive;
import ga.ganma.foofledrive.economy.Economy;
import ga.ganma.foofledrive.plan;
@@ -17,149 +17,78 @@
import java.util.List;
public class InventoryAPI {
- public static Inventory Inventorysizechange(Inventory oldInv, int setsize){
- Inventory inv = Bukkit.createInventory(null,setsize,"foofle drive");
- inv.setStorageContents(oldInv.getStorageContents());
- return inv;
- }
+ public static void changePlan(OfflinePlayer player, plan plan) {
+ Inventory inv = createInventoryForPlan(plan);
+ ItemStack[] is = trimInventoryItems(FileRelationUtils.readFile(player).getInv().getStorageContents(), plan);
- public static boolean planchange(Player player, plan plan){
- Inventory inv = null;
- ItemStack[] is = null;
- switch (plan){
- case FREE:
- inv = Bukkit.createInventory(null,9,"foofle drive");
- is = Filerelation.readFile(player).getInv().getStorageContents();
- if(is.length > 9){
- int a = is.length;
- List isl = new ArrayList<>(Arrays.asList(is));
- isl.subList(9,a).clear();
- ItemStack[] array = new ItemStack[isl.size()];
- int i = 0;
- for (ItemStack ist : isl){
- array[i] = ist;
- i += 1;
- }
- is = array;
- }
- break;
+ inv.setStorageContents(is);
+ Foofledrive.econ.withdrawPlayer(player, Economy.getPlanCost(FileRelationUtils.readFile(player).getPlan()));
+ Playerdata pd = new Playerdata(player, inv, plan);
+ pd.setFinish(Calendar.getInstance());
+ FileRelationUtils.createFile(pd);
+ }
- case LIGHT:
- inv = Bukkit.createInventory(null,18,"foofle drive");
- is = Filerelation.readFile(player).getInv().getStorageContents();
- if(is.length >= 19){
- int a = is.length;
- List isl = new ArrayList<>(Arrays.asList(is));
- isl.subList(18,a).clear();
- ItemStack[] array = new ItemStack[isl.size()];
- int i = 0;
- for (ItemStack ist : isl){
- array[i] = ist;
- i += 1;
- }
- is = array;
- }
- break;
- case MIDDLE:
- inv = Bukkit.createInventory(null,27,"foofle drive");
- is = Filerelation.readFile(player).getInv().getStorageContents();
- if(is.length >= 28){
- int a = is.length;
- List isl = new ArrayList<>(Arrays.asList(is));
- isl.subList(27,a).clear();
- ItemStack[] array = new ItemStack[isl.size()];
- int i = 0;
- for (ItemStack ist : isl){
- array[i] = ist;
- i += 1;
- }
- is = array;
- }
- break;
+ public static boolean changePlan(Player player, plan plan) {
+ Inventory inv = createInventoryForPlan(plan);
+ ItemStack[] is = trimInventoryItems(FileRelationUtils.readFile(player).getInv().getStorageContents(), plan);
- case LARGE:
- inv = Bukkit.createInventory(null,54,"foofle drive");
- is = Filerelation.readFile(player).getInv().getStorageContents();
- break;
- }
- if(Foofledrive.econ.getBalance(player) >= Economy.getplanmoney(plan)) {
- inv.setStorageContents(is);
- Playerdata pd = new Playerdata(player, inv, plan);
- pd.setFinish(Calendar.getInstance());
- Foofledrive.econ.withdrawPlayer(player, Economy.getplanmoney(plan));
- player.sendMessage("[foofle drive]このプランの一週間の利用料金を払いました。");
- Filerelation.createFile(pd);
- return true;
- }
- else {
- player.sendMessage("[foofle drive]お金が足りないため、" + plan + "プランの契約ができませんでした。");
- }
- return false;
- }
+ if (Foofledrive.econ.getBalance(player) >= Economy.getPlanCost(plan)) {
+ inv.setStorageContents(is);
+ Playerdata pd = new Playerdata(player, inv, plan);
+ pd.setFinish(Calendar.getInstance());
+ Foofledrive.econ.withdrawPlayer(player, Economy.getPlanCost(plan));
+ player.sendMessage("[foofle drive]このプランの一週間の利用料金を払いました。");
+ FileRelationUtils.createFile(pd);
+ return true;
+ } else {
+ player.sendMessage("[foofle drive]お金が足りないため、" + plan + "プランの契約ができませんでした。");
+ }
+ return false;
+ }
- public static void planchange(OfflinePlayer player, plan plan){
- Inventory inv = null;
- ItemStack[] is = null;
- switch (plan){
- case FREE:
- inv = Bukkit.createInventory(null,9,"foofle drive");
- is = Filerelation.readFile(player).getInv().getStorageContents();
- if(is.length > 9){
- int a = is.length;
- List isl = new ArrayList<>(Arrays.asList(is));
- isl.subList(9,a).clear();
- ItemStack[] array = new ItemStack[isl.size()];
- int i = 0;
- for (ItemStack ist : isl){
- array[i] = ist;
- i += 1;
- }
- is = array;
- }
- break;
+ public static Inventory createInventoryForPlan(plan plan) {
+ switch (plan) {
+ case FREE:
+ return Bukkit.createInventory(null, 9, "foofle drive");
+ case LIGHT:
+ return Bukkit.createInventory(null, 18, "foofle drive");
+ case MIDDLE:
+ return Bukkit.createInventory(null, 27, "foofle drive");
+ case LARGE:
+ return Bukkit.createInventory(null, 54, "foofle drive");
+ default:
+ throw new IllegalArgumentException("Unknown plan: " + plan);
+ }
+ }
- case LIGHT:
- inv = Bukkit.createInventory(null,18,"foofle drive");
- is = Filerelation.readFile(player).getInv().getStorageContents();
- if(is.length >= 19){
- int a = is.length;
- List isl = new ArrayList<>(Arrays.asList(is));
- isl.subList(18,a).clear();
- ItemStack[] array = new ItemStack[isl.size()];
- int i = 0;
- for (ItemStack ist : isl){
- array[i] = ist;
- i += 1;
- }
- is = array;
- }
- break;
- case MIDDLE:
- inv = Bukkit.createInventory(null,27,"foofle drive");
- is = Filerelation.readFile(player).getInv().getStorageContents();
- if(is.length >= 28){
- int a = is.length;
- List isl = new ArrayList<>(Arrays.asList(is));
- isl.subList(27,a).clear();
- ItemStack[] array = new ItemStack[isl.size()];
- int i = 0;
- for (ItemStack ist : isl){
- array[i] = ist;
- i += 1;
- }
- is = array;
- }
- break;
+ public static ItemStack[] trimInventoryItems(ItemStack[] items, plan plan) {
+ int maxSize = getMaxSizeForPlan(plan);
+ if (items.length > maxSize) {
+ List itemList = new ArrayList<>(Arrays.asList(items));
+ itemList.subList(maxSize, items.length).clear();
+ return itemList.toArray(new ItemStack[0]);
+ }
+ return items;
+ }
- case LARGE:
- inv = Bukkit.createInventory(null,54,"foofle drive");
- is = Filerelation.readFile(player).getInv().getStorageContents();
- break;
- }
- inv.setStorageContents(is);
- Foofledrive.econ.withdrawPlayer(player,Economy.getplanmoney(Filerelation.readFile(player).getPlan()));
- Playerdata pd = new Playerdata(player,inv,plan);
- pd.setFinish(Calendar.getInstance());
- Filerelation.createFile(pd);
- }
-}
+ public static int getMaxSizeForPlan(plan plan) {
+ switch (plan) {
+ case FREE:
+ return 9;
+ case LIGHT:
+ return 18;
+ case MIDDLE:
+ return 27;
+ case LARGE:
+ return 54;
+ default:
+ throw new IllegalArgumentException("Unknown plan: " + plan);
+ }
+ }
+
+ public Inventory inventorySizeChange(Inventory oldInv, int setsize) {
+ Inventory inv = Bukkit.createInventory(null, setsize, "foofle drive");
+ inv.setStorageContents(oldInv.getStorageContents());
+ return inv;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/ga/ganma/foofledrive/inventoryRelation/InventoryEncoder.java b/src/main/java/ga/ganma/foofledrive/inventoryRelation/InventoryEncoder.java
index e35f704..6dc85c5 100644
--- a/src/main/java/ga/ganma/foofledrive/inventoryRelation/InventoryEncoder.java
+++ b/src/main/java/ga/ganma/foofledrive/inventoryRelation/InventoryEncoder.java
@@ -11,35 +11,35 @@
import java.util.Base64;
public class InventoryEncoder {
- public static String inventoryToString(Inventory inventory) {
- try {
- ByteArrayOutputStream str = new ByteArrayOutputStream();
- BukkitObjectOutputStream data = new BukkitObjectOutputStream(str);
- data.writeInt(inventory.getSize());
- for (int i = 0; i < inventory.getSize(); i++) {
- data.writeObject(inventory.getItem(i));
- }
- data.close();
- return Base64.getEncoder().encodeToString(str.toByteArray());
- } catch (Exception e) {
- e.printStackTrace();
- }
- return "";
- }
+ public static String inventoryToString(Inventory inventory) {
+ try {
+ ByteArrayOutputStream str = new ByteArrayOutputStream();
+ BukkitObjectOutputStream data = new BukkitObjectOutputStream(str);
+ data.writeInt(inventory.getSize());
+ for (int i = 0; i < inventory.getSize(); i++) {
+ data.writeObject(inventory.getItem(i));
+ }
+ data.close();
+ return Base64.getEncoder().encodeToString(str.toByteArray());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return "";
+ }
- public static Inventory stringToInventory(String inventoryData) {
- try {
- ByteArrayInputStream stream = new ByteArrayInputStream(Base64.getDecoder().decode(inventoryData));
- BukkitObjectInputStream data = new BukkitObjectInputStream(stream);
- Inventory inventory = Bukkit.createInventory(null, data.readInt(), "foofle drive");
- for (int i = 0; i < inventory.getSize(); i++) {
- inventory.setItem(i, (ItemStack) data.readObject());
- }
- data.close();
- return inventory;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
+ public static Inventory stringToInventory(String inventoryData) {
+ try {
+ ByteArrayInputStream stream = new ByteArrayInputStream(Base64.getDecoder().decode(inventoryData));
+ BukkitObjectInputStream data = new BukkitObjectInputStream(stream);
+ Inventory inventory = Bukkit.createInventory(null, data.readInt(), "foofle drive");
+ for (int i = 0; i < inventory.getSize(); i++) {
+ inventory.setItem(i, (ItemStack) data.readObject());
+ }
+ data.close();
+ return inventory;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
}
diff --git a/src/main/java/ga/ganma/foofledrive/plan.java b/src/main/java/ga/ganma/foofledrive/plan.java
index cae0bf5..6cfaf83 100644
--- a/src/main/java/ga/ganma/foofledrive/plan.java
+++ b/src/main/java/ga/ganma/foofledrive/plan.java
@@ -2,6 +2,10 @@
import java.io.Serializable;
+/**
+ * @deprecated planクラスは旧プランクラスのため、新規には使用しないでください。
+ */
+@Deprecated(since = "0.8.0", forRemoval = false)
public enum plan implements Serializable {
- FREE,LIGHT,MIDDLE,LARGE
+ FREE, LIGHT, MIDDLE, LARGE
}
diff --git a/src/main/java/ga/ganma/foofledrive/playerdata/PlayerDriveData.java b/src/main/java/ga/ganma/foofledrive/playerdata/PlayerDriveData.java
new file mode 100644
index 0000000..ccda635
--- /dev/null
+++ b/src/main/java/ga/ganma/foofledrive/playerdata/PlayerDriveData.java
@@ -0,0 +1,63 @@
+package ga.ganma.foofledrive.playerdata;
+
+
+import ga.ganma.foofledrive.FoofleDrivePlan;
+import ga.ganma.foofledrive.inventoryRelation.InventoryEncoder;
+import org.bukkit.OfflinePlayer;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.Inventory;
+
+import java.util.Calendar;
+import java.util.UUID;
+
+public class PlayerDriveData {
+ private final UUID mcid;
+ private final FoofleDrivePlan plan;
+ private final String inventorySt;
+ private Calendar finish;
+
+ public PlayerDriveData(Player pl, Inventory inv, FoofleDrivePlan plan) {
+ this.mcid = pl.getUniqueId();
+ this.plan = plan;
+ this.inventorySt = InventoryEncoder.inventoryToString(inv);
+ }
+
+ public PlayerDriveData(OfflinePlayer pl, Inventory inv, FoofleDrivePlan plan) {
+ this.mcid = pl.getUniqueId();
+ this.plan = plan;
+ this.inventorySt = InventoryEncoder.inventoryToString(inv);
+ }
+
+ public PlayerDriveData(UUID uuid, Inventory inv, FoofleDrivePlan plan) {
+ this.mcid = uuid;
+ this.plan = plan;
+ this.inventorySt = InventoryEncoder.inventoryToString(inv);
+ }
+
+ public FoofleDrivePlan getPlan() {
+ return plan;
+ }
+
+ public UUID getMcid() {
+ return mcid;
+ }
+
+ public Inventory getInv() {
+ return InventoryEncoder.stringToInventory(inventorySt);
+ }
+
+ public Calendar getFinish() {
+ if (finish != null) {
+ return finish;
+ } else {
+ Calendar cl = Calendar.getInstance();
+ setFinish(cl);
+ }
+ return finish;
+ }
+
+ public void setFinish(Calendar cl) {
+ cl.add(Calendar.DAY_OF_MONTH, +7);
+ finish = cl;
+ }
+}
diff --git a/src/main/java/ga/ganma/foofledrive/playerdata/Playerdata.java b/src/main/java/ga/ganma/foofledrive/playerdata/Playerdata.java
index 08d61cf..139597f 100644
--- a/src/main/java/ga/ganma/foofledrive/playerdata/Playerdata.java
+++ b/src/main/java/ga/ganma/foofledrive/playerdata/Playerdata.java
@@ -10,49 +10,53 @@
import java.util.Calendar;
import java.util.UUID;
+/**
+ * @deprecated Playerdataクラスは旧データクラスのため、新規には使用しないでください。
+ * @see ga.ganma.foofledrive.bizlogic.convert.ConvertPlayerData
+ */
+@Deprecated(since = "0.8.0", forRemoval = false)
public class Playerdata implements Serializable {
- private UUID mcid;
- private plan plan;
- private String inventorySt;
- private Calendar finish;
-
- public Playerdata(Player pl, Inventory inv, plan plan) {
- this.mcid = pl.getUniqueId();
- this.plan = plan;
- this.inventorySt = InventoryEncoder.inventoryToString(inv);
- }
-
- public Playerdata(OfflinePlayer pl, Inventory inv, plan plan) {
- this.mcid = pl.getUniqueId();
- this.plan = plan;
- this.inventorySt = InventoryEncoder.inventoryToString(inv);
- }
-
- public ga.ganma.foofledrive.plan getPlan() {
- return plan;
- }
-
- public UUID getMcid() {
- return mcid;
- }
-
- public Inventory getInv() {
- return InventoryEncoder.stringToInventory(inventorySt);
- }
-
- public void setFinish(Calendar cl){
- cl.add(Calendar.DAY_OF_MONTH,+7);
- finish = cl;
- }
-
- public Calendar getFinish(){
- if(finish != null) {
- return finish;
- }
- else {
- Calendar cl = Calendar.getInstance();
- setFinish(cl);
- }
- return finish;
- }
+ private final UUID mcid;
+ private final plan plan;
+ private final String inventorySt;
+ private Calendar finish;
+
+ public Playerdata(Player pl, Inventory inv, plan plan) {
+ this.mcid = pl.getUniqueId();
+ this.plan = plan;
+ this.inventorySt = InventoryEncoder.inventoryToString(inv);
+ }
+
+ public Playerdata(OfflinePlayer pl, Inventory inv, plan plan) {
+ this.mcid = pl.getUniqueId();
+ this.plan = plan;
+ this.inventorySt = InventoryEncoder.inventoryToString(inv);
+ }
+
+ public ga.ganma.foofledrive.plan getPlan() {
+ return plan;
+ }
+
+ public UUID getMcid() {
+ return mcid;
+ }
+
+ public Inventory getInv() {
+ return InventoryEncoder.stringToInventory(inventorySt);
+ }
+
+ public Calendar getFinish() {
+ if (finish != null) {
+ return finish;
+ } else {
+ Calendar cl = Calendar.getInstance();
+ setFinish(cl);
+ }
+ return finish;
+ }
+
+ public void setFinish(Calendar cl) {
+ cl.add(Calendar.DAY_OF_MONTH, +7);
+ finish = cl;
+ }
}
diff --git a/target/classes/ga/ganma/foofledrive/Filerelation.class b/target/classes/ga/ganma/foofledrive/Filerelation.class
index 2886bc0..b568963 100644
Binary files a/target/classes/ga/ganma/foofledrive/Filerelation.class and b/target/classes/ga/ganma/foofledrive/Filerelation.class differ
diff --git a/target/classes/ga/ganma/foofledrive/Foofledrive.class b/target/classes/ga/ganma/foofledrive/Foofledrive.class
index fb34d68..6a424a1 100644
Binary files a/target/classes/ga/ganma/foofledrive/Foofledrive.class and b/target/classes/ga/ganma/foofledrive/Foofledrive.class differ
diff --git a/target/classes/ga/ganma/foofledrive/Listener/GUIEvent$1.class b/target/classes/ga/ganma/foofledrive/Listener/GUIEvent$1.class
deleted file mode 100644
index c04fbf3..0000000
Binary files a/target/classes/ga/ganma/foofledrive/Listener/GUIEvent$1.class and /dev/null differ
diff --git a/target/classes/ga/ganma/foofledrive/Listener/GUIEvent.class b/target/classes/ga/ganma/foofledrive/Listener/GUIEvent.class
index 66e7f46..e1f3332 100644
Binary files a/target/classes/ga/ganma/foofledrive/Listener/GUIEvent.class and b/target/classes/ga/ganma/foofledrive/Listener/GUIEvent.class differ
diff --git a/target/classes/ga/ganma/foofledrive/Listener/GetEvent$1.class b/target/classes/ga/ganma/foofledrive/Listener/GetEvent$1.class
index 230a68b..4b683af 100644
Binary files a/target/classes/ga/ganma/foofledrive/Listener/GetEvent$1.class and b/target/classes/ga/ganma/foofledrive/Listener/GetEvent$1.class differ
diff --git a/target/classes/ga/ganma/foofledrive/Listener/GetEvent.class b/target/classes/ga/ganma/foofledrive/Listener/GetEvent.class
index a533507..402929c 100644
Binary files a/target/classes/ga/ganma/foofledrive/Listener/GetEvent.class and b/target/classes/ga/ganma/foofledrive/Listener/GetEvent.class differ
diff --git a/target/classes/ga/ganma/foofledrive/bukkitRunnable/Runnable.class b/target/classes/ga/ganma/foofledrive/bukkitRunnable/Runnable.class
index bdb13db..80dbbf4 100644
Binary files a/target/classes/ga/ganma/foofledrive/bukkitRunnable/Runnable.class and b/target/classes/ga/ganma/foofledrive/bukkitRunnable/Runnable.class differ
diff --git a/target/classes/ga/ganma/foofledrive/command/CommandMain.class b/target/classes/ga/ganma/foofledrive/command/CommandMain.class
index 8a11cdf..b8fed10 100644
Binary files a/target/classes/ga/ganma/foofledrive/command/CommandMain.class and b/target/classes/ga/ganma/foofledrive/command/CommandMain.class differ
diff --git a/target/classes/ga/ganma/foofledrive/command/Subopen.class b/target/classes/ga/ganma/foofledrive/command/Subopen.class
index 2c87ed8..08a1f80 100644
Binary files a/target/classes/ga/ganma/foofledrive/command/Subopen.class and b/target/classes/ga/ganma/foofledrive/command/Subopen.class differ
diff --git a/target/classes/ga/ganma/foofledrive/command/Subplan.class b/target/classes/ga/ganma/foofledrive/command/Subplan.class
index 0bd3029..a09c119 100644
Binary files a/target/classes/ga/ganma/foofledrive/command/Subplan.class and b/target/classes/ga/ganma/foofledrive/command/Subplan.class differ
diff --git a/target/classes/ga/ganma/foofledrive/economy/Economy$1.class b/target/classes/ga/ganma/foofledrive/economy/Economy$1.class
index 2be0470..9794e55 100644
Binary files a/target/classes/ga/ganma/foofledrive/economy/Economy$1.class and b/target/classes/ga/ganma/foofledrive/economy/Economy$1.class differ
diff --git a/target/classes/ga/ganma/foofledrive/economy/Economy.class b/target/classes/ga/ganma/foofledrive/economy/Economy.class
index bb47666..f7eb53d 100644
Binary files a/target/classes/ga/ganma/foofledrive/economy/Economy.class and b/target/classes/ga/ganma/foofledrive/economy/Economy.class differ
diff --git a/target/classes/ga/ganma/foofledrive/inventoryRelation/InventoryAPI$1.class b/target/classes/ga/ganma/foofledrive/inventoryRelation/InventoryAPI$1.class
index f851db4..e57497f 100644
Binary files a/target/classes/ga/ganma/foofledrive/inventoryRelation/InventoryAPI$1.class and b/target/classes/ga/ganma/foofledrive/inventoryRelation/InventoryAPI$1.class differ
diff --git a/target/classes/ga/ganma/foofledrive/inventoryRelation/InventoryAPI.class b/target/classes/ga/ganma/foofledrive/inventoryRelation/InventoryAPI.class
index 75ec84f..245a44f 100644
Binary files a/target/classes/ga/ganma/foofledrive/inventoryRelation/InventoryAPI.class and b/target/classes/ga/ganma/foofledrive/inventoryRelation/InventoryAPI.class differ
diff --git a/target/classes/ga/ganma/foofledrive/inventoryRelation/InventoryEncoder.class b/target/classes/ga/ganma/foofledrive/inventoryRelation/InventoryEncoder.class
index 4470db9..db8e31e 100644
Binary files a/target/classes/ga/ganma/foofledrive/inventoryRelation/InventoryEncoder.class and b/target/classes/ga/ganma/foofledrive/inventoryRelation/InventoryEncoder.class differ
diff --git a/target/classes/ga/ganma/foofledrive/plan.class b/target/classes/ga/ganma/foofledrive/plan.class
index 2a7f530..5ddbe3d 100644
Binary files a/target/classes/ga/ganma/foofledrive/plan.class and b/target/classes/ga/ganma/foofledrive/plan.class differ
diff --git a/target/classes/ga/ganma/foofledrive/playerdata/Playerdata.class b/target/classes/ga/ganma/foofledrive/playerdata/Playerdata.class
index a1df16e..1621c84 100644
Binary files a/target/classes/ga/ganma/foofledrive/playerdata/Playerdata.class and b/target/classes/ga/ganma/foofledrive/playerdata/Playerdata.class differ
diff --git a/target/classes/plugin.yml b/target/classes/plugin.yml
index 656f953..51fef91 100644
--- a/target/classes/plugin.yml
+++ b/target/classes/plugin.yml
@@ -1,5 +1,5 @@
name: foofledrive
-version: 0.7.9β
+version: 1.0.0
main: ga.ganma.foofledrive.Foofledrive
api-version: 1.13
commands:
diff --git "a/target/foofledrive-0.7.9\316\262.jar" "b/target/foofledrive-0.7.9\316\262.jar"
index 874b986..c83910a 100644
Binary files "a/target/foofledrive-0.7.9\316\262.jar" and "b/target/foofledrive-0.7.9\316\262.jar" differ
diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties
index ea93cfa..9b3938a 100644
--- a/target/maven-archiver/pom.properties
+++ b/target/maven-archiver/pom.properties
@@ -1,5 +1,3 @@
-#Generated by Maven
-#Sat Oct 05 22:36:13 JST 2019
-groupId=ga.ganma
artifactId=foofledrive
-version=0.7.9\u03B2
+groupId=ga.ganma
+version=1.0.0
diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
index bae6fb4..b652f55 100644
--- a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
+++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
@@ -1,17 +1,20 @@
-ga\ganma\foofledrive\playerdata\Playerdata.class
+ga\ganma\foofledrive\FoofleDrivePlan.class
ga\ganma\foofledrive\economy\Economy$1.class
ga\ganma\foofledrive\Listener\GetEvent$1.class
ga\ganma\foofledrive\Filerelation.class
ga\ganma\foofledrive\command\CommandMain.class
ga\ganma\foofledrive\command\Subopen.class
+ga\ganma\foofledrive\bizlogic\convert\ConvertPlayerData.class
+ga\ganma\foofledrive\Listener\GUIEvent.class
+ga\ganma\foofledrive\bizlogic\convert\ConvertPlayerData$1.class
+ga\ganma\foofledrive\bukkitRunnable\Runnable.class
+ga\ganma\foofledrive\command\Subplan.class
+ga\ganma\foofledrive\Listener\GetEvent.class
+ga\ganma\foofledrive\playerdata\Playerdata.class
+ga\ganma\foofledrive\playerdata\PlayerDriveData.class
ga\ganma\foofledrive\inventoryRelation\InventoryEncoder.class
ga\ganma\foofledrive\Foofledrive.class
ga\ganma\foofledrive\inventoryRelation\InventoryAPI$1.class
ga\ganma\foofledrive\economy\Economy.class
-ga\ganma\foofledrive\Listener\GUIEvent.class
ga\ganma\foofledrive\inventoryRelation\InventoryAPI.class
-ga\ganma\foofledrive\Listener\GUIEvent$1.class
-ga\ganma\foofledrive\bukkitRunnable\Runnable.class
-ga\ganma\foofledrive\command\Subplan.class
-ga\ganma\foofledrive\Listener\GetEvent.class
ga\ganma\foofledrive\plan.class
diff --git "a/target/original-foofledrive-0.7.9\316\262.jar" "b/target/original-foofledrive-0.7.9\316\262.jar"
index 26869f3..8b7db2d 100644
Binary files "a/target/original-foofledrive-0.7.9\316\262.jar" and "b/target/original-foofledrive-0.7.9\316\262.jar" differ