Skip to content

Commit

Permalink
[3.3.2]庆祝github恢复能直接访问!
Browse files Browse the repository at this point in the history
  • Loading branch information
nullaqua committed Aug 11, 2022
1 parent cb9d2fa commit 1fb9252
Show file tree
Hide file tree
Showing 12 changed files with 202 additions and 141 deletions.
20 changes: 16 additions & 4 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>3.3.1</version>
<version>3.3.2</version>
<packaging>jar</packaging>

<name>BluestarGame</name>
Expand Down Expand Up @@ -78,14 +78,18 @@
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>dmulloy2-repo</id>
<url>https://repo.dmulloy2.net/repository/public/</url>
</repository>
</repositories>

<dependencies>
<!--
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<version>1.19.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
-->
Expand All @@ -99,6 +103,7 @@
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.11.0</version>
<scope>provided</scope>
</dependency>

<dependency>
Expand All @@ -110,7 +115,7 @@
<dependency>
<groupId>com.github.lanzhi6</groupId>
<artifactId>BluestarAPI</artifactId>
<version>2.5.2</version>
<version>2.6.3</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -151,14 +156,14 @@
<scope>system</scope>
<systemPath>${project.basedir}/lib/purpur-1.19.jar</systemPath>
</dependency>
<!--
<dependency>
<groupId>org.purpur</groupId>
<artifactId>purpur8</artifactId>
<version>1.18</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/purpur-1.18.2.jar</systemPath>
</dependency>
<!--
<dependency>
<groupId>org.purpur</groupId>
<artifactId>citizens</artifactId>
Expand All @@ -180,6 +185,13 @@
<scope>system</scope>
<systemPath>${project.basedir}/lib/spigot-1.18.2-R0.1-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>com.github.lanzhi6</groupId>
<artifactId>asdasdasdasdasd</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/EssentialsX-2.19.4.jar</systemPath>
</dependency>
-->
</dependencies>
</project>
6 changes: 4 additions & 2 deletions src/main/java/me/lanzhi/bluestargame/BluestarGamePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import org.bukkit.ChatColor;
import org.bukkit.command.PluginCommand;
import org.bukkit.configuration.serialization.ConfigurationSerialization;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.ServicePriority;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
Expand Down Expand Up @@ -106,10 +108,10 @@ public void onEnable()
@Override
public void onDisable()
{
Bukkit.getScheduler().cancelTasks(this);
this.spongeTask.cancel();
this.bedrockTask.cancel();
getBluestarGameManager().getRandomEventManger().end();
getBluestarGameManager().getRandomEventManger().all(false);
getBluestarGameManager().stop();
recipeRegister.cancellationRecipes();
Data.set("superSponges",getBluestarGameManager().getSuperSpongeManager().getSponges());
Data.save();
Expand Down
119 changes: 108 additions & 11 deletions src/main/java/me/lanzhi/bluestargame/commands/BluestarItemCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import de.tr7zw.nbtapi.NBTCompound;
import de.tr7zw.nbtapi.NBTItem;
import de.tr7zw.nbtapi.NBTReflectionUtil;
import de.tr7zw.nbtapi.NBTType;
import me.lanzhi.bluestarapi.api.GradientColor;
import me.lanzhi.bluestarapi.api.RGBColor;
import me.lanzhi.bluestargame.BluestarGamePlugin;
Expand All @@ -18,7 +20,6 @@
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.*;

Expand Down Expand Up @@ -76,7 +77,7 @@ public BluestarItemCommand(BluestarGamePlugin plugin)
@Override
public boolean onCommand(@NotNull CommandSender sender,@NotNull Command command,@NotNull String label,@NotNull String[] args)
{
if (!(sender instanceof Player))
if (!(sender instanceof Player player))
{
sender.sendMessage(ChatColor.RED+"此命令仅允许玩家输入!");
return false;
Expand All @@ -86,7 +87,6 @@ public boolean onCommand(@NotNull CommandSender sender,@NotNull Command command,
sender.sendMessage(ChatColor.RED+"格式错误!");
return false;
}
Player player=(Player) sender;
switch (args[0])
{
case "watersponge":
Expand Down Expand Up @@ -356,8 +356,7 @@ public boolean onCommand(@NotNull CommandSender sender,@NotNull Command command,
}
else
{
NBTCompound nbtCompound=item.addCompound("BluestarGame").addCompound(mod.name()).addCompound(
type.getName());
NBTCompound nbtCompound=item.addCompound("BluestarGame").addCompound(mod.name()).addCompound(type.getName());
nbtCompound.setInteger("s",l);
nbtCompound.setInteger("time",time*20);
}
Expand Down Expand Up @@ -434,6 +433,23 @@ public boolean onCommand(@NotNull CommandSender sender,@NotNull Command command,
player.getInventory().setItemInMainHand(itemStack);
return true;
}
case "getnbt":
{
ItemStack itemStack=player.getInventory().getItemInMainHand();
if (itemStack==null||itemStack.getType().isAir())
{
player.sendMessage(plugin.getErrorMessageHead()+"请手持任意物品");
return true;
}
NBTItem nbtItem=new NBTItem(itemStack);
player.sendMessage(plugin.getMessageHead()+"物品NBT:");
List<String> ls=getNBT(nbtItem,ChatColor.GOLD.toString());
for (String s: ls)
{
player.sendMessage(s);
}
return true;
}
default:
{
player.sendMessage(plugin.getErrorMessageHead()+"格式错误");
Expand All @@ -448,8 +464,18 @@ public List<String> onTabComplete(@NotNull CommandSender sender,@NotNull Command
{
if (args.length==1)
{
return Arrays.asList("watersponge","lavasponge","usedwatersponge","usedlavasponge","effect","effectEvent",
"sword","bow","setname","addlore","clearlore");
return Arrays.asList("watersponge",
"lavasponge",
"usedwatersponge",
"usedlavasponge",
"effect",
"effectEvent",
"sword",
"bow",
"setname",
"addlore",
"clearlore",
"getnbt");
}
if ("bow".equals(args[0]))
{
Expand Down Expand Up @@ -518,8 +544,8 @@ private ItemStack setLore(ItemStack itemStack)
NBTCompound compound=bluestarGame.getCompound("effect");
for (String i: compound.getKeys())
{
lore.add(ChatColor.GRAY+effectLang.getString(i.toLowerCase(),i.toLowerCase())+" "+compound.getInteger(
i));
lore.add(ChatColor.GRAY+effectLang.getString(i.toLowerCase(),
i.toLowerCase())+" "+compound.getInteger(i));
}
}
for (effectEventType i: effectEventType.values())
Expand All @@ -531,8 +557,8 @@ private ItemStack setLore(ItemStack itemStack)
for (String j: compound.getKeys())
{
lore.add(ChatColor.GRAY+effectLang.getString(j.toLowerCase(),
j.toLowerCase())+" "+compound.addCompound(
j).getInteger("s")+" 时间: "+(compound.addCompound(j).getInteger("time")/20));
j.toLowerCase())+" "+compound.addCompound(j).getInteger(
"s")+" 时间: "+(compound.addCompound(j).getInteger("time")/20));
}
}
}
Expand Down Expand Up @@ -568,4 +594,75 @@ private ItemStack setLore(ItemStack itemStack)
itemStack.setItemMeta(meta);
return itemStack;
}

private List<String> getNBT(Object object,String prefix)
{
List<String> list=new ArrayList<>();
if (object instanceof List<?> ls)
{
for (Object o: ls)
{
if (!(o instanceof List<?>)&&!(o instanceof NBTCompound))
{
list.add(prefix+"- "+ChatColor.AQUA+getToString(o));
continue;
}
list.add(prefix+"-");
list.addAll(getNBT(o,prefix+" "));
}
return list;
}
if (object instanceof NBTCompound compound)
{
for (String s: compound.getKeys())
{
Object o=null;
switch (compound.getType(s))
{
case NBTTagByte -> o=compound.getByte(s);
case NBTTagInt -> o=compound.getInteger(s);
case NBTTagShort -> o=compound.getShort(s);
case NBTTagLong -> o=compound.getLong(s);
case NBTTagFloat -> o=compound.getFloat(s);
case NBTTagDouble -> o=compound.getDouble(s);
case NBTTagByteArray -> o=compound.getByteArray(s);
case NBTTagString -> o=compound.getString(s);
case NBTTagList -> {
switch (compound.getListType(s))
{
case NBTTagCompound -> o=compound.getCompoundList(s);
case NBTTagLong -> o=compound.getLongList(s);
case NBTTagInt -> o=compound.getIntegerList(s);
case NBTTagDouble -> o=compound.getDoubleList(s);
case NBTTagFloat -> o=compound.getFloatList(s);
case NBTTagString -> o=compound.getStringList(s);
case NBTTagIntArray -> o=compound.getIntArrayList(s);
}
}
case NBTTagCompound -> o=compound.getCompound(s);
case NBTTagIntArray -> o=compound.getIntArray(s);
case NBTTagEnd -> o=compound.getObject(s,Object.class);
}
if (!(o instanceof List<?>)&&!(o instanceof NBTCompound))
{
list.add(prefix+s+": "+ChatColor.AQUA+getToString(o));
continue;
}
int[] is=new int[100];
Arrays.toString(is);
list.add(prefix+s+":");
list.addAll(getNBT(o,prefix+" "));
}
return list;
}
return Collections.singletonList(prefix+object);
}
private String getToString(Object object)
{
if (object instanceof Object[])
{
return Arrays.toString((Object[])object);
}
return object.toString();
}
}
55 changes: 46 additions & 9 deletions src/main/java/me/lanzhi/bluestargame/commands/setNickCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import me.lanzhi.bluestarapi.api.GradientColor;
import me.lanzhi.bluestarapi.api.RGBColor;
import me.lanzhi.bluestarapi.api.player.input.PlayerChatInput;
import me.lanzhi.bluestargame.BluestarGamePlugin;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
Expand All @@ -22,12 +24,20 @@ public class setNickCommand implements CommandExecutor, TabExecutor
private final BluestarGamePlugin plugin;
private final Chat chat;
private final Economy economy;
private final PlayerChatInput.Builder<String> setNickInput;

public setNickCommand(BluestarGamePlugin plugin)
{
this.plugin=plugin;
chat=plugin.getChat();
economy=plugin.getEcon();

setNickInput=PlayerChatInput.builder();
setNickInput.sendValueMessage(ChatColor.GREEN+"请在聊天区域输入昵称,输入"+ChatColor.RED+"cancel"+ChatColor.GREEN+"取消")
.setValue((player1,s)->s)
.onCancel(p->p.sendMessage(plugin.getMessageHead()+"你已取消设置昵称"))
.plugin(plugin)
.onFinish(this::setNick);
}

@Override
Expand All @@ -38,24 +48,24 @@ public boolean onCommand(@NotNull CommandSender sender,@NotNull Command command,
sender.sendMessage(plugin.getErrorMessageHead()+"此指令仅允许玩家输入!");
return true;
}
List<Player> players=plugin.getBluestarGameManager().getSettingNickPlayer();
if (players.remove(player))
if (PlayerChatInput.isInputing(player.getUniqueId()))
{
player.sendMessage(plugin.getMessageHead()+"已取消设置昵称");
player.sendMessage(plugin.getErrorMessageHead()+"您正在进行其他输入,请完成后再试");
return true;
}
if (!economy.has(player,1000))
{
player.sendMessage(plugin.getErrorMessageHead()+"错误,你的钱不足1000");
return true;
}
player.sendMessage(plugin.getMessageHead()+"请在聊天区直接发送昵称,支持颜色");
player.sendMessage(
plugin.getMessageHead()+"支持颜色符号:§1&1§2&2§3&3§4&4§5&5§6&6§7&7§8&8§9&9§0&0§a&a§b&b§c&c§d&d§e&e§f&f"+ChatColor.GOLD+",支持RGB:"+RGBColor.setColor(
"#098765")+"#098765"+ChatColor.GOLD+"支持渐变色: #abcdef-654321<"+GradientColor.colorText("abcdef","654321","需要染色的文本")+ChatColor.GOLD+">");
player.sendMessage(plugin.getMessageHead()+"请在 聊天中 直接发送昵称,支持颜色");
player.sendMessage(plugin.getMessageHead()+"支持颜色符号:§1&1§2&2§3&3§4&4§5&5§6&6§7&7§8&8§9&9§0&0§a&a§b&b§c&c§d&d§e&e§f&f"+ChatColor.GOLD+",支持RGB:"+RGBColor.setColor(
"#098765")+"#098765"+ChatColor.GOLD+"支持渐变色: #abcdef-654321<"+GradientColor.colorText("abcdef",
"654321",
"需要染色的文本")+ChatColor.GOLD+">");
player.sendMessage(plugin.getErrorMessageHead()+"设置昵称将花费1000,在聊天区发送需要的昵称后立即生效,概不退款。再次设置昵称可以覆盖,需要重新付款");
player.sendMessage(plugin.getErrorMessageHead()+"若想取消此操作,请再次输入指令");
players.add(player);

setNickInput.open(player);
return false;
}

Expand All @@ -65,4 +75,31 @@ public List<String> onTabComplete(@NotNull CommandSender commandSender,@NotNull
{
return Collections.emptyList();
}

private void setNick(Player player,String nick)
{
if (!plugin.getEcon().has(player,1000))
{
player.sendMessage(plugin.getErrorMessageHead()+"你的钱不足1000");
return;
}
if (plugin.getEcon()
.withdrawPlayer(player,1000).type!=EconomyResponse.ResponseType.SUCCESS)
{
player.sendMessage(plugin.getErrorMessageHead()+"出现错误,请重试,或通知腐竹");
return;
}
if (nick.indexOf(' ')>=0)
{
player.sendMessage(plugin.getErrorMessageHead()+"错误!,名称中不能饱和空格");
return;
}
if (ChatColor.stripColor(nick).length()>10)
{
player.sendMessage(plugin.getErrorMessageHead()+"错误.昵称长度(去除颜色符号后)不应超过10");
return;
}
chat.setPlayerPrefix(player,nick);
player.sendMessage(plugin.getMessageHead()+"设置成功");
}
}
Loading

0 comments on commit 1fb9252

Please sign in to comment.