Skip to content

Commit

Permalink
null
Browse files Browse the repository at this point in the history
  • Loading branch information
nullaqua committed Apr 15, 2022
1 parent a9192ea commit 4b8d124
Show file tree
Hide file tree
Showing 10 changed files with 306 additions and 52 deletions.
27 changes: 25 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.lanzhi</groupId>
<artifactId>BluestarGame</artifactId>
<version>2.4.0-R1</version>
<version>2.5.0</version>
<packaging>jar</packaging>

<name>BluestarGame</name>
Expand Down Expand Up @@ -113,5 +113,28 @@
<version>1.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/Vault.jar</systemPath>
</dependency>
<!--
<dependency>
<groupId>com.github.lanzhi6</groupId>
<artifactId>BlggguestarTpsControl</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/purpur-1.18.2.jar</systemPath>
</dependency>
<dependency>
<groupId>com.github.lanzhi6</groupId>
<artifactId>BlggguestaasdrTpsControl</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/spigot-1.18.2-R0.1-SNAPSHOT.jar</systemPath>
</dependency>
-->
</dependencies>
</project>
</project>
11 changes: 8 additions & 3 deletions src/main/java/me/lanzhi/bluestargame/BluestarGame.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package me.lanzhi.bluestargame;


import me.lanzhi.bluestargame.Ctrls.CTRL;
import me.lanzhi.bluestargame.Ctrls.CtrlSponge;
import me.lanzhi.bluestargame.Type.Public;
Expand All @@ -11,11 +10,12 @@
import me.lanzhi.bluestargame.register.RegisterListeners;
import me.lanzhi.bluestargame.register.RegisterRecipe;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.serialization.ConfigurationSerialization;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitTask;
import me.lanzhi.bluestarapi.Api.YamlFile;
import net.milkbowl.vault.economy.Economy;

import java.io.File;
import java.util.List;
Expand All @@ -27,7 +27,10 @@ public final class BluestarGame extends org.bukkit.plugin.java.JavaPlugin
public static File PlayerData;
public static YamlFile PlayerMap;
public static YamlFile Data;
BukkitTask task;
public static Economy econ=null;
public static String messageHead=ChatColor.GOLD+"["+ChatColor.DARK_AQUA+"BluestarGame"+ChatColor.GOLD+"]";

private BukkitTask task;

@Override
public void onEnable()
Expand Down Expand Up @@ -58,6 +61,7 @@ public void onEnable()
getCommand("chat").setExecutor(new chat());
getCommand("bluestaritem").setExecutor(new bluestaritem());
getCommand("elevator").setExecutor(new elevatorCommand());
getCommand("xiaomobank").setExecutor(new XiaoMoBank());

if (config.getBoolean("auto"))
{
Expand All @@ -66,6 +70,7 @@ public void onEnable()

CtrlSponge.set((List<superSponge>) Data.getList("superSponges"));
this.task = CtrlSponge.ctrlsponge.runTaskTimer(plugin, 0L, 2L);
econ=getServer().getServicesManager().getRegistration(Economy.class).getProvider();

System.out.println("BluestarGame已加载");
}
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/me/lanzhi/bluestargame/Type/superSponge.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
import de.tr7zw.nbtapi.NBTCompound;
import de.tr7zw.nbtapi.NBTItem;
import me.lanzhi.bluestargame.BluestarGame;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

Expand Down Expand Up @@ -48,7 +46,7 @@ public superSponge(int age, Location loc, String player,boolean islava,boolean i
this.iswater = iswater;
}

public static NBTItem getSuperSponge()
public static NBTItem getWaterSponge()
{
if (waterSponge == null)
{
Expand Down Expand Up @@ -88,7 +86,7 @@ public static NBTItem getlavaSponge()
}
return lavaSponge;
}
public static NBTItem getUsedSuperSponge()
public static NBTItem getUsedWaterSponge()
{
if (usedWaterSponge == null)
{
Expand Down
181 changes: 181 additions & 0 deletions src/main/java/me/lanzhi/bluestargame/commands/XiaoMoBank.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
package me.lanzhi.bluestargame.commands;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.text.ParseException;
import java.util.*;
import java.text.SimpleDateFormat;

import static me.lanzhi.bluestargame.BluestarGame.*;

public class XiaoMoBank implements CommandExecutor, TabExecutor
{
@Override
public boolean onCommand(@NotNull CommandSender sender,@NotNull Command command,@NotNull String label,@NotNull String[] args)
{
if (args.length<1)
{
return false;
}
if (!(sender instanceof Player))
{
sender.sendMessage("此指令仅允许玩家输入");
return true;
}
Player player=(Player)sender;
switch (args[0])
{
case "borrow":
{
if (args.length<2)
{
sender.sendMessage(messageHead+ChatColor.RED+"请输入贷款金额");
return true;
}
long money;
try
{
money = Long.parseLong(args[1]);
}
catch (NumberFormatException e)
{
sender.sendMessage(messageHead+ChatColor.RED+"请输入正确的贷款金额");
return true;
}
if (Data.getLong("bank.borrow."+player.getUniqueId()+".money")!=0)
{
sender.sendMessage(messageHead+ChatColor.RED+"您似乎有一笔金额为"+
Data.getLong("bank.borrow."+player.getUniqueId()+".money")+
"的贷款还未偿还,请向偿还再尝试贷款");
return true;
}
econ.depositPlayer(player,money);
Data.set("bank.borrow."+player.getUniqueId()+".money",money);
Calendar calendar = Calendar.getInstance();
Data.set("bank.borrow."+player.getUniqueId()+".time",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime()));
sender.sendMessage(messageHead+ChatColor.GREEN+"您已成功贷款"+money);
break;
}
case "repay":
{
long money=Data.getLong("bank.borrow."+player.getUniqueId()+".money");
if (money==0)
{
sender.sendMessage(messageHead+ChatColor.RED+"你没有需要偿还的贷款");
return true;
}
Date borrowTime;
try
{
borrowTime=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(Data.getString("bank.borrow."+player.getUniqueId()+".time"));
}
catch (ParseException e)
{
sender.sendMessage(messageHead+ChatColor.RED+"出现错误,请重试或联系腐竹");
return true;
}
double borrowTimeMs=borrowTime.getTime();
double nowTimeMs=Calendar.getInstance().getTime().getTime();
double days=Math.ceil((nowTimeMs-borrowTimeMs)/86400000);
double repayMoney=money+0.01*days*money;
if (!econ.has(player,repayMoney))
{
sender.sendMessage(messageHead+ChatColor.RED+"您没有钱偿还贷款,快去赚钱吧");
return true;
}
econ.withdrawPlayer(player,repayMoney);
Data.set("bank.borrow."+player.getUniqueId()+".money",0);
sender.sendMessage(messageHead+ChatColor.GREEN+"你成功还款"+repayMoney);
break;
}
case "save":
{
if (args.length<2)
{
sender.sendMessage(messageHead+ChatColor.RED+"请输入存款金额");
return true;
}
long money;
try
{
money = Long.parseLong(args[1]);
}
catch (NumberFormatException e)
{
sender.sendMessage(messageHead+ChatColor.RED+"请输入正确的存款金额");
return true;
}
if (Data.getLong("bank.save."+player.getUniqueId()+".money")!=0)
{
sender.sendMessage(messageHead+ChatColor.RED+"您似乎有一笔金额为"+
Data.getLong("bank.save."+player.getUniqueId()+".money")+
"的存款还未取出,请向取出再尝试存款");
return true;
}
if (!econ.has(player,money))
{
sender.sendMessage(messageHead+ChatColor.RED+"你没有那么多钱(别做白日梦了!)");
return true;
}
econ.withdrawPlayer(player,money);
Data.set("bank.save."+player.getUniqueId()+".money",money);
Calendar calendar = Calendar.getInstance();
Data.set("bank.save."+player.getUniqueId()+".time",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime()));
sender.sendMessage(messageHead+ChatColor.GREEN+"您已成功存款"+money);
break;
}
case "get":
{
if (Data.getLong("bank.save."+player.getUniqueId()+".money")==0)
{
sender.sendMessage(messageHead+ChatColor.RED+"您还没有存款哦,去努力赚钱吧");
return true;
}
Date saveTime;
try
{
saveTime=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(Data.getString("bank.save."+player.getUniqueId()+".time"));
}
catch (ParseException e)
{
sender.sendMessage(messageHead+ChatColor.RED+"出现错误,请重试或联系腐竹");
return true;
}
double money=Data.getLong("bank.save."+player.getUniqueId()+".money");
double saveTimeMs=saveTime.getTime();
double nowTimeMs=Calendar.getInstance().getTime().getTime();
double days=Math.floor((nowTimeMs-saveTimeMs)/86400000);
double getMoney=money+0.01*days*money;
econ.depositPlayer(player,getMoney);
Data.set("bank.save."+player.getUniqueId()+".money",0);
sender.sendMessage(messageHead+ChatColor.GREEN+"你成功取出存款"+getMoney);
break;
}
default:
{ }
}
return false;
}

@Nullable
@Override
public List<String> onTabComplete(@NotNull CommandSender sender,@NotNull Command command,@NotNull String label,@NotNull String[] args)
{
if (args.length==1)
{
return Arrays.asList("borrow","repay","save","get");
}
else if (args.length==2&&("borrow".equals(args[0])||"save".equals(args[0])))
{
return Arrays.asList("<金额>");
}
return new ArrayList<>();
}
}
Loading

0 comments on commit 4b8d124

Please sign in to comment.