Skip to content

Commit

Permalink
null
Browse files Browse the repository at this point in the history
  • Loading branch information
nullaqua committed Apr 4, 2022
1 parent 6d57c55 commit a9192ea
Show file tree
Hide file tree
Showing 12 changed files with 256 additions and 101 deletions.
2 changes: 1 addition & 1 deletion 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.3.4</version>
<version>2.4.0-R1</version>
<packaging>jar</packaging>

<name>BluestarGame</name>
Expand Down
26 changes: 6 additions & 20 deletions src/main/java/me/lanzhi/bluestargame/BluestarGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
import me.lanzhi.bluestargame.Type.superSponge;
import me.lanzhi.bluestargame.Type.muted;
import me.lanzhi.bluestargame.commands.*;
import me.lanzhi.bluestargame.listener.HealthFix;
import me.lanzhi.bluestargame.register.RegisterListeners;
import me.lanzhi.bluestargame.register.RegisterRecipe;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.configuration.serialization.ConfigurationSerialization;
import org.bukkit.inventory.RecipeChoice;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.ShapelessRecipe;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitTask;
import me.lanzhi.bluestarapi.Api.YamlFile;
Expand All @@ -34,24 +32,25 @@ public final class BluestarGame extends org.bukkit.plugin.java.JavaPlugin
@Override
public void onEnable()
{
plugin = this;
ConfigurationSerialization.registerClass(muted.class);
ConfigurationSerialization.registerClass(superSponge.class);
ConfigurationSerialization.registerClass(elevator.class);
ConfigurationSerialization.registerClass(Public.class);

saveDefaultConfig();

plugin = this;
config = new YamlFile(new File(plugin.getDataFolder(),"config.yml"));
PlayerMap = new YamlFile(new File(plugin.getDataFolder(),"playerMap.yml"));
Data = new YamlFile(new File(plugin.getDataFolder(),"data.yml"));
PlayerData = new File(plugin.getDataFolder(),"PlayerData");
PlayerData.mkdirs();

int pluginId = 14294;
Metrics metrics = new Metrics(this, pluginId);
new Metrics(this, pluginId);

RegisterListeners.registerListeners();
RegisterRecipe.registerRecipes();

getCommand("bluestargame").setExecutor(new me.lanzhi.bluestargame.commands.maincommand());
getCommand("bluestargamelist").setExecutor(new bsgamelist());
Expand All @@ -65,19 +64,6 @@ public void onEnable()
CTRL.runAuto(true);
}

ShapelessRecipe bluestarsponge = new ShapelessRecipe(new org.bukkit.NamespacedKey(this, "supersponge"), superSponge.getSuperSponge().getItem());
bluestarsponge = bluestarsponge.addIngredient(9, Material.SPONGE);
Bukkit.addRecipe(bluestarsponge);

ShapedRecipe supersponge = new ShapedRecipe(new org.bukkit.NamespacedKey(this, "watersponge"), superSponge.getSuperSponge().getItem());
supersponge = supersponge.shape("a");
supersponge = supersponge.setIngredient('a', new RecipeChoice.ExactChoice(superSponge.getlavaSponge().getItem()));
Bukkit.addRecipe(supersponge);

ShapedRecipe lavasponge = new ShapedRecipe(new org.bukkit.NamespacedKey(this, "lavasponge"), superSponge.getlavaSponge().getItem());
lavasponge = lavasponge.shape("a");
lavasponge = lavasponge.setIngredient('a', new RecipeChoice.ExactChoice(superSponge.getSuperSponge().getItem()));
Bukkit.addRecipe(lavasponge);
CtrlSponge.set((List<superSponge>) Data.getList("superSponges"));
this.task = CtrlSponge.ctrlsponge.runTaskTimer(plugin, 0L, 2L);

Expand Down
17 changes: 12 additions & 5 deletions src/main/java/me/lanzhi/bluestargame/Ctrls/CtrlSponge.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void run()
{
Location loc = sponge.getLocation();
int age = sponge.getAge();
Bluestar.setBlock(loc, Material.AIR, sponge.getPlayer().getName());
Bluestar.setBlock(loc, Material.AIR, sponge.getPlayer());
boolean iswater=sponge.getIswater();
boolean islava=sponge.getIslava();
if (age>1)
Expand All @@ -45,20 +45,27 @@ public void run()
}
};

public static void add(superSponge sponge){sponges.add(sponge);}
public static void add(superSponge sponge)
{
if (sponges==null)
{
sponges=new ArrayList<>();
}
sponges.add(sponge);
}
public static void set(List<superSponge> spongess){sponges=spongess;}
public static List<superSponge> get(){return sponges;}

private static void decide(Location loc, int age, Player player,boolean iswater,boolean islava)
private static void decide(Location loc, int age, String player,boolean iswater,boolean islava)
{
if (loc.getBlock().getType()==Material.WATER&&iswater)
{
Bluestar.setBlock(loc, Material.END_STONE, player.getName());
Bluestar.setBlock(loc, Material.END_STONE, player);
nextSponges.add(new superSponge(age-1,loc,player,islava,true));
}
if(loc.getBlock().getType()==Material.LAVA&&islava)
{
Bluestar.setBlock(loc, Material.OBSIDIAN, player.getName());
Bluestar.setBlock(loc, Material.OBSIDIAN, player);
nextSponges.add(new superSponge(age-1,loc,player,true,iswater));
}
}
Expand Down
94 changes: 71 additions & 23 deletions src/main/java/me/lanzhi/bluestargame/Type/superSponge.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,36 @@
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public final class superSponge implements ConfigurationSerializable
{
private static NBTItem lavaSponge = null;
private static NBTItem usedLavaSponge = null;
private static NBTItem waterSponge = null;
private static NBTItem usedWaterSponge = null;

private final int age;
private final Location location;
private final Player player;
private final String player;
private boolean islava=false;
private boolean iswater=false;

public superSponge(Map<String, Object> map)
{
this.age = (int)map.get("age");
this.location = ((Location) map.get("location"));
this.player = Bukkit.getPlayer((String) map.get("player"));
this.player = (String) map.get("player");
this.islava = (boolean)map.get("islava");
this.iswater = (boolean)map.get("iswater");
}

public superSponge(int age, Location loc, Player player,boolean islava,boolean iswater)
public superSponge(int age, Location loc, String player,boolean islava,boolean iswater)
{
this.age = age;
this.location = loc;
Expand All @@ -48,44 +52,88 @@ public static NBTItem getSuperSponge()
{
if (waterSponge == null)
{
waterSponge = new NBTItem(new ItemStack(Material.END_STONE));
ItemStack itemStack=new ItemStack(Material.END_STONE);
ItemMeta itemMeta=itemStack.getItemMeta();
itemMeta.setDisplayName(ChatColor.GOLD+"超级海绵");
List<String> list=new ArrayList<>();
list.add(ChatColor.AQUA+"放在"+ChatColor.GOLD+"水"+ChatColor.AQUA+"中或"+ChatColor.GOLD+"水"+ChatColor.AQUA+"旁边");
list.add(ChatColor.AQUA+"即可吸干附近"+BluestarGame.config.getInt("spongeR")+"格的"+ChatColor.GOLD+"水");
list.add(ChatColor.RED+"放在没"+ChatColor.GOLD+"水"+ChatColor.RED+"的地方会直接变成"+ChatColor.GOLD+"湿超级海绵"+ChatColor.RED+"哦!");
itemMeta.setLore(list);
itemStack.setItemMeta(itemMeta);
waterSponge=new NBTItem(itemStack);
NBTCompound bluestargame = waterSponge.addCompound("BluestarGame");
bluestargame.setBoolean("lavaSponge",false);
bluestargame.setBoolean("waterSponge",true);
NBTCompound display = waterSponge.addCompound("display");
display.setString("Name", "\"" + ChatColor.GOLD + "超级海绵(吸水版)\"");
List<String> list = display.getStringList("Lore");
list.add("\"" + ChatColor.AQUA + "放在 水/岩浆 中或 水/岩浆 旁边\"");
list.add("\"" + ChatColor.AQUA + "即可吸干附近" + BluestarGame.config.getInt("spongeR") + "格的 水/岩浆\"");
list.add("\"" + ChatColor.RED + "放在没 水/岩浆 的地方会直接消失哦!\"");
bluestargame.setInteger("lavaSponge",0);
bluestargame.setInteger("waterSponge",1);
}
return waterSponge;
}
public static NBTItem getlavaSponge()
{
if (lavaSponge == null)
{
lavaSponge = new NBTItem(new ItemStack(Material.OBSIDIAN));
ItemStack itemStack=new ItemStack(Material.OBSIDIAN);
ItemMeta itemMeta=itemStack.getItemMeta();
itemMeta.setDisplayName(ChatColor.GOLD+"岩浆海绵");
List<String> list=new ArrayList<>();
list.add(ChatColor.AQUA+"放在"+ChatColor.GOLD+"岩浆"+ChatColor.AQUA+"中或"+ChatColor.GOLD+"岩浆"+ChatColor.AQUA+"旁边");
list.add(ChatColor.AQUA+"即可吸干附近"+BluestarGame.config.getInt("spongeR")+"格的"+ChatColor.GOLD+"岩浆");
list.add(ChatColor.RED+"放在没"+ChatColor.GOLD+"岩浆"+ChatColor.RED+"的地方会直接变成"+ChatColor.GOLD+"湿岩浆海绵"+ChatColor.RED+"哦!");
itemMeta.setLore(list);
itemStack.setItemMeta(itemMeta);
lavaSponge = new NBTItem(itemStack);
NBTCompound bluestargame = lavaSponge.addCompound("BluestarGame");
bluestargame.setBoolean("lavaSponge",true);
bluestargame.setBoolean("waterSponge",false);
NBTCompound display = lavaSponge.addCompound("display");
display.setString("Name", "\"" + ChatColor.GOLD + "超级海绵(吸岩浆版)\"");
List<String> list = display.getStringList("Lore");
list.add("\"" + ChatColor.AQUA + "放在 水/岩浆 中或 水/岩浆 旁边\"");
list.add("\"" + ChatColor.AQUA + "即可吸干附近" + BluestarGame.config.getInt("spongeR") + "格的 水/岩浆\"");
list.add("\"" + ChatColor.RED + "放在没 水/岩浆 的地方会直接消失哦!\"");
bluestargame.setInteger("lavaSponge",1);
bluestargame.setInteger("waterSponge",0);
}
return lavaSponge;
}
public static NBTItem getUsedSuperSponge()
{
if (usedWaterSponge == null)
{
ItemStack itemStack=new ItemStack(Material.PRISMARINE);
ItemMeta itemMeta=itemStack.getItemMeta();
itemMeta.setDisplayName(ChatColor.GOLD+"湿超级海绵");
List<String> list=new ArrayList<>();
list.add(ChatColor.AQUA+"湿超级海绵,可放入熔炉变回"+ChatColor.GOLD+"超级海绵");
list.add(ChatColor.GOLD+"湿超级海绵"+ChatColor.RED+"无法放置或使用哦");
itemMeta.setLore(list);
itemStack.setItemMeta(itemMeta);
usedWaterSponge = new NBTItem(itemStack);
NBTCompound bluestargame = usedWaterSponge.addCompound("BluestarGame");
bluestargame.setInteger("lavaSponge",0);
bluestargame.setInteger("waterSponge",-1);
}
return usedWaterSponge;
}
public static NBTItem getUsedLavaSponge()
{
if (usedLavaSponge == null)
{
ItemStack itemStack=new ItemStack(Material.MAGMA_BLOCK);
ItemMeta itemMeta=itemStack.getItemMeta();
itemMeta.setDisplayName(ChatColor.GOLD+"湿岩浆海绵");
List<String> list=new ArrayList<>();
list.add(ChatColor.AQUA+"湿岩浆海绵,可放入熔炉变回"+ChatColor.GOLD+"湿岩浆海绵");
list.add(ChatColor.GOLD+"湿岩浆海绵"+ChatColor.RED+"无法放置或使用哦");
itemMeta.setLore(list);
itemStack.setItemMeta(itemMeta);
usedLavaSponge = new NBTItem(itemStack);
NBTCompound bluestargame = usedLavaSponge.addCompound("BluestarGame");
bluestargame.setInteger("lavaSponge",-1);
bluestargame.setInteger("waterSponge",0);
}
return usedLavaSponge;
}

@Override
public Map<String, Object> serialize()
{
Map<String, Object> map = new HashMap<>();
map.put("age",this.age);
map.put("location", this.location);
map.put("player", this.player.getName());
map.put("player", this.player);
map.put("islava", this.islava);
map.put("iswater", this.iswater);
return map;
Expand All @@ -101,7 +149,7 @@ public Location getLocation()
return this.location;
}

public Player getPlayer()
public String getPlayer()
{
return this.player;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package me.lanzhi.bluestargame.commands;

import de.tr7zw.nbtapi.NBTItem;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import me.lanzhi.bluestarapi.Api.Bluestar;
import org.bukkit.*;
import org.bukkit.block.data.type.NoteBlock;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
Expand Down
45 changes: 40 additions & 5 deletions src/main/java/me/lanzhi/bluestargame/commands/maincommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
import me.lanzhi.bluestargame.Ctrls.CTRL;
import me.lanzhi.bluestargame.Ctrls.CtrlSponge;
import me.lanzhi.bluestargame.Type.superSponge;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.chat.hover.content.Text;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.attribute.Attribute;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
Expand Down Expand Up @@ -276,24 +279,56 @@ else if (args.length==2&&sender instanceof Player)
}
if (args[0].equals("newsponge")&&sender.hasPermission("bluestargame.lanzhi"))
{
if (!(sender instanceof Player)){return false;}
int r;
r=Integer.parseInt(args[1]);
Location locc=((Player)(sender)).getLocation();
Location loc=new Location(locc.getWorld(),locc.getBlockX(),locc.getBlockY(),locc.getBlockZ());
CtrlSponge.add(new superSponge(r,loc,(Player)sender,true,true));
CtrlSponge.add(new superSponge(r,loc,sender.getName(),true,true));
return true;
}
if ("boom".equals(args[0])&&sender.hasPermission("bluestargame.lanzhi"))
if ("makeboom".equals(args[0]))
{
Location location=((Player)sender).getLocation();
long r;
try
{
location.getWorld().createExplosion(location,Integer.parseInt(args[1]),true,true);
r=Integer.parseInt(args[1]);
}
catch (NumberFormatException e)
{return false;}
if (r>50||r<0)
{
return false;
}
location.getWorld().createExplosion(location,Integer.parseInt(args[1]),true,true);
return true;
}
if ("boom".equals(args[0]))
{
long r;
try
{
r=Integer.parseInt(args[1]);
}
catch (NumberFormatException e)
{
sender.sendMessage(ChatColor.RED + "错误!");
return false;
}
if (r>50||r<0)
{
sender.sendMessage(ChatColor.RED + "错误,范围应在0-50之间");
}
TextComponent component=new TextComponent("[点击爆炸]");
component.setColor(net.md_5.bungee.api.ChatColor.RED);
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,new Text("爆炸范围:"+r)));
component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,"/bsgame makeboom "+r));
TextComponent component1=new TextComponent("爆炸:");
component1.setColor(net.md_5.bungee.api.ChatColor.GOLD);
sender.sendMessage(ChatColor.GOLD+"--------------");
sender.spigot().sendMessage(component1,component);
sender.sendMessage(ChatColor.GOLD+"--------------");
return true;
}
sender.sendMessage(ChatColor.RED + "格式错误!");
Expand Down Expand Up @@ -322,10 +357,10 @@ public List<String> onTabComplete(CommandSender sender, Command command, String
tablist.add("all");
tablist.add("auto");
tablist.add("spongeR");
tablist.add("boom");
if(sender.hasPermission("bluestargame.lanzhi"))
{
tablist.add("newsponge");
tablist.add("boom");
tablist.add("maxhealth");
tablist.add("reload");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Sound;
Expand Down
Loading

0 comments on commit a9192ea

Please sign in to comment.