Skip to content

Commit

Permalink
众多修改
Browse files Browse the repository at this point in the history
  • Loading branch information
nullaqua committed Apr 28, 2022
1 parent c4776e6 commit 77ba55d
Show file tree
Hide file tree
Showing 32 changed files with 859 additions and 327 deletions.
9 changes: 8 additions & 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.7.0</version>
<version>2.8.0</version>
<packaging>jar</packaging>

<name>BluestarGame</name>
Expand Down Expand Up @@ -134,6 +134,13 @@
<scope>system</scope>
<systemPath>${project.basedir}/lib/BluestarTpsControl-spigotPlugin-1.5.jar</systemPath>
</dependency>
<dependency>
<groupId>org.spigot</groupId>
<artifactId>Citizens2</artifactId>
<version>2.0.29</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/Citizens-2.0.29-b2493.jar</systemPath>
</dependency>
<!--
<dependency>
<groupId>com.github.lanzhi6</groupId>
Expand Down
66 changes: 32 additions & 34 deletions src/main/java/me/lanzhi/bluestargame/BluestarGame.java
Original file line number Diff line number Diff line change
@@ -1,87 +1,85 @@
package me.lanzhi.bluestargame;

import me.lanzhi.bluestarapi.Api.YamlFile;
import me.lanzhi.bluestargame.Ctrls.CTRL;
import me.lanzhi.bluestargame.Ctrls.CtrlSponge;
import me.lanzhi.bluestargame.Type.CompressedCoal;
import me.lanzhi.bluestargame.Type.Elevator;
import me.lanzhi.bluestargame.Type.superSponge;
import me.lanzhi.bluestargame.commands.*;
import me.lanzhi.bluestargame.papi.BluestarGamePapi;
import me.lanzhi.bluestargame.register.RegisterListeners;
import me.lanzhi.bluestargame.register.RegisterRecipe;
import me.lanzhi.bluestargame.Type.SuperSponge;
import me.lanzhi.bluestargame.register.*;
import me.lanzhi.bluestargame.listener.breakBedrockListener;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.ChatColor;
import org.bukkit.configuration.serialization.ConfigurationSerialization;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
import me.lanzhi.bluestarapi.Api.YamlFile;
import net.milkbowl.vault.economy.Economy;

import java.io.File;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.List;

public final class BluestarGame extends org.bukkit.plugin.java.JavaPlugin
{
public static Plugin plugin;
public static JavaPlugin plugin;
public static YamlFile config;
public static File PlayerData;
public static YamlFile PlayerMap;
public static YamlFile Data;
public static Economy econ=null;
public static String messageHead=ChatColor.GOLD+"["+ChatColor.DARK_AQUA+"BluestarGame"+ChatColor.GOLD+"]";
public static String errorMessageHead=messageHead+ChatColor.RED;
public static SimpleDateFormat BluestarDataFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public static NumberFormat BluestarNF=NumberFormat.getInstance();

private BukkitTask task;
private BukkitTask spongeTask;
private BukkitTask bedrockTask;

@Override
public void onEnable()
{
plugin = this;
ConfigurationSerialization.registerClass(superSponge.class);
BluestarNF.setGroupingUsed(false);
plugin=this;
ConfigurationSerialization.registerClass(SuperSponge.class);
ConfigurationSerialization.registerClass(Elevator.class);
ConfigurationSerialization.registerClass(CompressedCoal.class);

saveDefaultConfig();

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");
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;
new Metrics(this, pluginId);

RegisterListeners.registerListeners();
RegisterRecipe.registerRecipes();
new Metrics(this,14294);

getCommand("bluestargame").setExecutor(new me.lanzhi.bluestargame.commands.maincommand());
getCommand("bluestargamelist").setExecutor(new bsgamelist());
getCommand("muted").setExecutor(new mutedCommand());
getCommand("chat").setExecutor(new chat());
getCommand("bluestaritem").setExecutor(new bluestaritem());
getCommand("elevator").setExecutor(new elevatorCommand());
getCommand("xiaomobank").setExecutor(new XiaoMoBank());
getCommand("cmdbag").setExecutor(new commandBag());
registerListeners.registerListeners();
registerRecipe.registerRecipes();
registerCommand.registerCommands();
registerConfigurationSection.registerConfigurationSections();

if (config.getBoolean("auto"))
{
CTRL.runAuto(true);
}

CtrlSponge.set((List<superSponge>) Data.getList("superSponges"));
this.task = CtrlSponge.ctrlsponge.runTaskTimer(plugin, 0L, 2L);
CtrlSponge.set((List<SuperSponge>) Data.getList("superSponges"));
this.spongeTask=CtrlSponge.ctrlsponge.runTaskTimer(plugin,0L,2L);
this.bedrockTask=breakBedrockListener.breakBedrock.runTaskTimer(plugin,0L,20L);
econ=getServer().getServicesManager().getRegistration(Economy.class).getProvider();
new BluestarGamePapi();

System.out.println("BluestarGame已加载");
}

@Override
public void onDisable()
{
this.task.cancel();
this.spongeTask.cancel();
this.bedrockTask.cancel();
CTRL.theend();
CTRL.all(false);
RegisterRecipe.cancellationRecipes();
registerRecipe.cancellationRecipes();
Data.set("superSponges",CtrlSponge.get());
Data.save();
PlayerMap.save();
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/me/lanzhi/bluestargame/Ctrls/CtrlSponge.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package me.lanzhi.bluestargame.Ctrls;

import me.lanzhi.bluestarapi.Api.Bluestar;
import me.lanzhi.bluestargame.Type.superSponge;
import me.lanzhi.bluestargame.Type.SuperSponge;
import org.bukkit.Location;
import org.bukkit.Material;

Expand All @@ -10,8 +10,8 @@

public class CtrlSponge
{
private static List<superSponge> nextSponges = new ArrayList<>();
private static List<superSponge> sponges = new ArrayList<>();
private static List<SuperSponge> nextSponges = new ArrayList<>();
private static List<SuperSponge> sponges = new ArrayList<>();
public static org.bukkit.scheduler.BukkitRunnable ctrlsponge = new org.bukkit.scheduler.BukkitRunnable()
{
@Override
Expand All @@ -22,7 +22,7 @@ public void run()
return;
}
nextSponges = new ArrayList();
for (superSponge sponge : sponges)
for (SuperSponge sponge : sponges)
{
Location loc = sponge.getLocation();
int age = sponge.getAge();
Expand All @@ -43,28 +43,28 @@ public void run()
}
};

public static void add(superSponge 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;}
public static void set(List<SuperSponge> spongess){sponges=spongess;}
public static List<SuperSponge> get(){return sponges;}

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);
nextSponges.add(new superSponge(age-1,loc,player,islava,true));
nextSponges.add(new SuperSponge(age-1,loc,player,islava,true));
}
if(loc.getBlock().getType()==Material.LAVA&&islava)
{
Bluestar.setBlock(loc, Material.OBSIDIAN, player);
nextSponges.add(new superSponge(age-1,loc,player,true,iswater));
nextSponges.add(new SuperSponge(age-1,loc,player,true,iswater));
}
}
}
Expand Down
156 changes: 156 additions & 0 deletions src/main/java/me/lanzhi/bluestargame/Type/CompressedCoal.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
package me.lanzhi.bluestargame.Type;

import de.tr7zw.nbtapi.NBTCompound;
import de.tr7zw.nbtapi.NBTItem;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

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

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

public enum CompressedCoal implements ConfigurationSerializable
{
/**
* 烧制过的煤炭块
*/
FIRED_COAL_BLOCK(1),
/**
* 压缩煤炭
*/
COMPRESSED_COAL(2),
/**
* 烧制过的压缩煤炭
*/
FIRED_COMPRESSED_COAL(3);
private final NBTItem item;
private final int id;
private final List<NamespacedKey> allowRecipe;

CompressedCoal(int id)
{
ItemStack itemm=new ItemStack(Material.COAL_BLOCK);
ItemMeta meta=itemm.getItemMeta();
switch (id)
{
case 1:
{
meta.setDisplayName(ChatColor.GOLD+"烧制煤炭");
allowRecipe=Collections.singletonList(new NamespacedKey(plugin,"compressed_coal"));
itemm.setItemMeta(meta);
item=new NBTItem(itemm);
item.addCompound("BluestarGame").setInteger("coal",id);
this.id=id;
break;
}
case 2:
{
meta.setDisplayName(ChatColor.GOLD+"压缩煤炭");
allowRecipe=Collections.singletonList(new NamespacedKey(plugin,"fired_compressed_coal"));
itemm.setItemMeta(meta);
item=new NBTItem(itemm);
item.addCompound("BluestarGame").setInteger("coal",id);
this.id=id;
break;
}
case 3:
{
meta.setDisplayName(ChatColor.GOLD+"烧制压缩煤炭");
allowRecipe=Collections.singletonList(new NamespacedKey(plugin,"coal_diamond"));
itemm.setItemMeta(meta);
item=new NBTItem(itemm);
item.addCompound("BluestarGame").setInteger("coal",id);
this.id=id;
break;
}
default:
{
this.allowRecipe=null;
this.id=0;
this.item=null;
}
}
}

public NBTItem getNbtItem()
{
return item;
}

public ItemStack getItem()
{
return item.getItem();
}

public int getId()
{
return id;
}

public boolean canUseInRecipe(NamespacedKey key)
{
return allowRecipe.contains(key);
}

public static CompressedCoal getFromId(int id)
{
switch (id)
{
case 1:
{
return FIRED_COAL_BLOCK;
}
case 2:
{
return COMPRESSED_COAL;
}
case 3:
{
return FIRED_COMPRESSED_COAL;
}
default:
{
return null;
}
}
}

public static CompressedCoal getFromItemStack(@Nullable ItemStack itemStack)
{
return itemStack==null?null:getFromNbtItem(new NBTItem(itemStack));
}

@Nullable
public static CompressedCoal getFromNbtItem(@Nullable NBTItem item)
{
if (item==null)
{
return null;
}
NBTCompound compound=item.getCompound("BluestarGame");
return compound==null?null:getFromId(compound.getInteger("coal"));
}

@NotNull
@Override
public Map<String, Object> serialize()
{
Map<String, Object> map=new HashMap<>();
map.put("id",getId());
return map;
}

public static CompressedCoal deserialize(Map<String, Object> map)
{
return getFromId((int) map.get("id"));
}
}
12 changes: 1 addition & 11 deletions src/main/java/me/lanzhi/bluestargame/Type/Elevator.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,9 @@
import java.util.Map;
import java.util.Set;

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

public class Elevator implements ConfigurationSerializable
{
public static ConfigurationSection elevators=Data.getConfigurationSection("elevators");
static
{
if (elevators==null)
{
Data.set("elevators",new HashMap<>());
elevators=Data.getConfigurationSection("elevators");
}
}
public static ConfigurationSection elevators;
private final long minX, maxX, minZ, maxZ, maxY, minY;

public Elevator(long minX,long maxX,long minZ,long maxZ,long minY,long maxY)
Expand Down
Loading

0 comments on commit 77ba55d

Please sign in to comment.