Skip to content

Commit

Permalink
null
Browse files Browse the repository at this point in the history
  • Loading branch information
nullaqua committed Mar 4, 2022
1 parent 8bcc604 commit e81a191
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 34 deletions.
12 changes: 11 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories>

<dependencies>
Expand All @@ -87,7 +91,13 @@
<dependency>
<groupId>com.github.lanzhi6</groupId>
<artifactId>BluestarAPI</artifactId>
<version>1.2</version>
<version>1.5</version>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
35 changes: 8 additions & 27 deletions src/main/java/me/lanzhi/bluestargame/BluestarGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import me.lanzhi.bluestargame.Type.superSponge;
import me.lanzhi.bluestargame.Type.muted;
import me.lanzhi.bluestargame.commands.bsgamelist;
import me.lanzhi.bluestargame.commands.chat;
import me.lanzhi.bluestargame.commands.mutedCommand;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
Expand All @@ -15,14 +16,14 @@
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitTask;
import me.lanzhi.bluestarapi.Api.yamlConfig;
import me.lanzhi.bluestarapi.Api.YamlFile;

import java.io.File;

public final class BluestarGame extends org.bukkit.plugin.java.JavaPlugin
{
public static Plugin plugin;
public static yamlConfig config;
public static YamlFile config;
BukkitTask task;

@Override
Expand All @@ -32,34 +33,14 @@ public void onEnable()
ConfigurationSerialization.registerClass(superSponge.class);
saveDefaultConfig();
plugin = getProvidingPlugin(BluestarGame.class);
config = new yamlConfig(new File(plugin.getDataFolder(),"config.yml"));
config = new YamlFile(new File(plugin.getDataFolder(),"config.yml"));
int pluginId = 14294;
Metrics metrics = new Metrics(this, pluginId);
Bukkit.getPluginManager().registerEvents(new listener(), this);
if (getCommand("bluestargame") != null)
{
getCommand("bluestargame").setExecutor(new me.lanzhi.bluestargame.commands.maincommand());
}
else
{
System.out.println(ChatColor.RED + "错误!");
}
if (getCommand("bluestargamelist") != null)
{
getCommand("bluestargamelist").setExecutor(new bsgamelist());
}
else
{
System.out.println(ChatColor.RED + "错误!");
}
if (getCommand("muted") != null)
{
getCommand("muted").setExecutor(new mutedCommand());
}
else
{
System.out.println(ChatColor.RED + "错误!");
}
getCommand("bluestargame").setExecutor(new me.lanzhi.bluestargame.commands.maincommand());
getCommand("bluestargamelist").setExecutor(new bsgamelist());
getCommand("muted").setExecutor(new mutedCommand());
getCommand("chat").setExecutor(new chat());
if (config.getBoolean("auto"))
{
CTRL.runAuto(true);
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/me/lanzhi/bluestargame/Metrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@
import java.util.stream.Collectors;
import java.util.zip.GZIPOutputStream;
import javax.net.ssl.HttpsURLConnection;

import me.lanzhi.bluestarapi.Api.YamlFile;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import me.lanzhi.bluestarapi.Api.yamlConfig;

public class Metrics
{
Expand All @@ -66,7 +65,7 @@ public class Metrics
public Metrics(JavaPlugin plugin, int serviceId) {
this.plugin = plugin;
// Get the config file
yamlConfig config = BluestarGame.config;
YamlFile config = BluestarGame.config;
if (!config.isSet("bStats.serverUuid")) {
config.addDefault("bStats.enabled", true);
config.addDefault("bStats.serverUuid", UUID.randomUUID().toString());
Expand Down
50 changes: 50 additions & 0 deletions src/main/java/me/lanzhi/bluestargame/commands/chat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package me.lanzhi.bluestargame.commands;

import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.Bukkit;
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 java.util.ArrayList;
import java.util.List;

public class chat implements CommandExecutor, TabExecutor
{
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
if (args.length < 2)
{
sender.sendMessage(ChatColor.RED+"错误!");
return false;
}
Player player= Bukkit.getPlayer(args[0]);
if (player == null)
{
sender.sendMessage(ChatColor.RED+"玩家不存在");
}
StringBuilder builder = new StringBuilder();
for (int i=1;i<args.length;i++)
{
builder.append(args[i]+" ");
}
player.chat(PlaceholderAPI.setPlaceholders(player, builder.toString()));
return false;
}

@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args)
{
if (args.length >= 2)
{
List<String> tablist=new ArrayList<>();
tablist.add("message");
return tablist;
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.ArrayList;
import java.util.List;
import me.lanzhi.bluestargame.BluestarGame;
import me.lanzhi.bluestargame.Ctrls.CTRL;
import me.lanzhi.bluestargame.Type.superSponge;
import org.bukkit.ChatColor;
Expand Down
6 changes: 5 additions & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ commands:
muted:
description: 禁言
permission: bluestargame.use
chat:
description: 让别的玩家发送消息
permission: bluestargame.lanzhi
permissions:
bluestargame.*:
description: 所有权限
Expand All @@ -28,4 +31,5 @@ permissions:
default: false
depend:
- BluestarAPI
- NBTAPI
- NBTAPI
- PlaceholderAPI

0 comments on commit e81a191

Please sign in to comment.