Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
Remove useless imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Aruvelut-123 committed Jun 5, 2024
1 parent 4186435 commit f9adb26
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 49 deletions.
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>krincraft</groupId>
<artifactId>IDK</artifactId>
<version>1.2-pre3</version>
<version>1.2-pre4</version>
<packaging>jar</packaging>

<name>IDK</name>
Expand Down Expand Up @@ -77,6 +77,11 @@
<artifactId>httpcore</artifactId>
<version>4.4.5</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180130</version>
</dependency>
</dependencies>

<distributionManagement>
Expand Down
44 changes: 22 additions & 22 deletions src/main/java/krincraft/idk/IDKCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ public void save() {
IDK.idk.reloadConfig();
messages.reload(filename);
// 测试是否有空值
config.getString("IDK_Helper_name");
config.getStringList("IDK_Helper_lore");
config.getString("IDK_Workbench_name");
config.getStringList("IDK_Workbench_lore");
config.getString("menu_title");
config.getString("workbench_title");
messages.getString("IDK_Helper_name");
messages.getStringList("IDK_Helper_lore");
messages.getString("IDK_Workbench_name");
messages.getStringList("IDK_Workbench_lore");
messages.getString("menu_title");
messages.getString("workbench_title");
messages.getString("failed");
messages.getString("failed_p");
messages.getString("survival");
Expand Down Expand Up @@ -148,16 +148,16 @@ public void save() {
return true;
}
if(strings.length == 1 && strings[0].equals("menu")) {
Inventory inv = Bukkit.createInventory(null, 9, config.getString("menu_title")); //创建一个大小为9格(必须为9或9的倍数)的背包,标题设置为IDK Chest
Inventory inv = Bukkit.createInventory(null, 9, messages.getString("menu_title")); //创建一个大小为9格(必须为9或9的倍数)的背包,标题设置为IDK Chest
int left = inv.getSize(); //获取背包大小并赋值到left上
int slot = 0; //设置slot的值为0
int i = 0;
List<String> slot_used = new ArrayList<>();

ItemStack idk_helper = new ItemStack(Material.DIAMOND, 1); //创建一个物品,材质为钻石,数量为1个
ItemMeta idk_helper_meta = idk_helper.getItemMeta(); //获取物品meta
idk_helper_meta.setDisplayName(config.getString("IDK_Helper_name"));
idk_helper_meta.setLore(config.getStringList("IDK_Helper_lore"));
idk_helper_meta.setDisplayName(messages.getString("IDK_Helper_name"));
idk_helper_meta.setLore(messages.getStringList("IDK_Helper_lore"));
idk_helper.setItemMeta(idk_helper_meta); //设置物品meta
inv.setItem(1, idk_helper); //添加物品到背包中

Expand All @@ -166,8 +166,8 @@ public void save() {

ItemStack idk_workbench = new ItemStack(Material.LEGACY_WORKBENCH, 1);
ItemMeta idk_workbench_meta = idk_workbench.getItemMeta();
idk_workbench_meta.setDisplayName(config.getString("IDK_Workbench_name"));
idk_workbench_meta.setLore(config.getStringList("IDK_Workbench_lore"));
idk_workbench_meta.setDisplayName(messages.getString("IDK_Workbench_name"));
idk_workbench_meta.setLore(messages.getStringList("IDK_Workbench_lore"));
idk_workbench.setItemMeta(idk_workbench_meta);
inv.setItem(7, idk_workbench);

Expand All @@ -176,8 +176,8 @@ public void save() {

ItemStack other = new ItemStack(Material.BLUE_STAINED_GLASS_PANE, 1); //创建一个物品,材质为蓝色玻璃板,数量为1个
ItemMeta other_meta = other.getItemMeta(); //获取物品meta
other_meta.setDisplayName(config.getString("Information_name")); //设置物品显示名称为Infomation
other_meta.setLore(config.getStringList("Information_lore"));
other_meta.setDisplayName(messages.getString("Information_name")); //设置物品显示名称为Infomation
other_meta.setLore(messages.getStringList("Information_lore"));
other.setItemMeta(other_meta); //设置物品meta

while(left > 0) { //如果left大于0则循环
Expand All @@ -200,13 +200,13 @@ public void save() {
}
if(strings.length == 2 && strings[0].equals("open")) { //检测参数长度是否为二并且第一个参数是否为open
if(strings[1].equals("workbench")) { //检测第二个参数是否为workbench
Inventory inv = Bukkit.createInventory(null, InventoryType.WORKBENCH, config.getString("workbench_title")); //创建一个背包,标题为IDK Workbench,类型为工作台
Inventory inv = Bukkit.createInventory(null, InventoryType.WORKBENCH, messages.getString("workbench_title")); //创建一个背包,标题为IDK Workbench,类型为工作台
player.openInventory(inv); //使指定玩家打开背包
return true;
}
}
if(strings.length == 1 && strings[0].equals("help")) { //检测参数长度是否为1并且第一个参数是否为help
List<String> help_msg = config.getStringList("Help");
List<String> help_msg = messages.getStringList("Help");
String help_msg_string = help_msg.toString().replace("[", "");
String help_msg_fix = help_msg_string.replace("]", "");
String help_msg_fix2 = help_msg_fix.replace(",", "");
Expand All @@ -226,12 +226,12 @@ public void save() {
IDK.idk.reloadConfig();
messages.reload(filename);
// 测试是否有空值
config.getString("IDK_Helper_name");
config.getStringList("IDK_Helper_lore");
config.getString("IDK_Workbench_name");
config.getStringList("IDK_Workbench_lore");
config.getString("menu_title");
config.getString("workbench_title");
messages.getString("IDK_Helper_name");
messages.getStringList("IDK_Helper_lore");
messages.getString("IDK_Workbench_name");
messages.getStringList("IDK_Workbench_lore");
messages.getString("menu_title");
messages.getString("workbench_title");
messages.getString("failed");
messages.getString("failed_p");
messages.getString("survival");
Expand Down Expand Up @@ -315,7 +315,7 @@ public void save() {
return true;
}
if(strings.length == 1 && strings[0].equals("help")) {
List<String> help_msg = config.getStringList("Help");
List<String> help_msg = messages.getStringList("Help");
String help_msg_string = help_msg.toString().replace("[", "");
String help_msg_fix = help_msg_string.replace("]", "");
String help_msg_fix2 = help_msg_fix.replace(",", "");
Expand Down
32 changes: 31 additions & 1 deletion src/main/java/krincraft/idk/IDKMessageConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Collections;
import java.util.List;

public abstract class IDKMessageConfig {
protected IDK idk;
Expand Down Expand Up @@ -35,7 +37,31 @@ public IDKMessageConfig(IDK idk, String fileName) {
"plugin-enabled: \"Plugin [plugin_name] enabled!\"\n" +
"plugin-not-found: \"Plugin not found!\"\n" +
"plugin-disable-egg: \"I cannot disable myself. Like you cannot make your heart stop.\"\n" +
"plugin-enable-egg: \"I cannot enable myself. Like you cannot make dead alive.\"");
"plugin-enable-egg: \"I cannot enable myself. Like you cannot make dead alive.\"" +
"IDK_Helper_name: \"IDK Help\"\n" +
"IDK_Helper_lore:\n" +
" - \"\"\n" +
"IDK_Workbench_name: \"IDK Workbench\"\n" +
"IDK_Workbench_lore:\n" +
" - \"\"\n" +
"menu_title: \"IDK Menu\"\n" +
"workbench_title: \"IDK Workbench\"\n" +
"Information_name: \"Information\"\n" +
"Information_lore:\n" +
" - \"Author: MinecraftBaymax\"\n" +
" - \"Add by IDK plugin.\"\n" +
"Help:\n" +
" - \"IDK plugin help:\"\n" +
" - \"\\n/IDK help - This help message\"\n" +
" - \"\\n/IDK gm <number of gamemodes> - Change your gamemode\"\n" +
" - \"\\n/IDK open workbench - Open a chest or a workbench\"\n" +
" - \"\\n/IDK plugins - Check plugin list\"\n" +
" - \"\\n/IDK load <plugin_name> - Load a plugin\"\n" +
" - \"\\n/IDK disable <plugin_name> - Disable a plugin\"\n" +
" - \"\\n/IDK enable <plugin_name> - Enable a plugin\"\n" +
" - \"\\n/IDK menu - open IDK menu\"\n" +
" - \"\\n/IDK ping - check your ping in game\"\n" +
" - \"\\n/IDK reload - reload config file\"");
fw.close();
} catch (IOException e) {
e.printStackTrace();
Expand Down Expand Up @@ -65,4 +91,8 @@ public void save() {
e.printStackTrace();
}
}

public List<String> getStringList(String str) {
return this.config.getStringList(str);
}
}
4 changes: 4 additions & 0 deletions src/main/java/krincraft/idk/JSON/decoder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package krincraft.idk.JSON;

public class decoder {
}
54 changes: 54 additions & 0 deletions src/main/java/krincraft/idk/network/IDKnetHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package krincraft.idk.network;

import org.apache.http.HttpEntity;
import org.apache.http.ParseException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.bukkit.Bukkit;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

public class IDKnetHandler {
private static final CloseableHttpClient httpclient = HttpClients.createDefault();
public static void get_projects() {
String url = "https://api.modrinth.com/v2/search?";
String categories = "spigot";
String versions = Bukkit.getServer().getMinecraftVersion();
String arg = "facets=[[\"categories:"+categories+"\"],[\"versions:"+versions+"\"],[\"project_type:plugin\"]]";
try {
URI uri = new URI(url+"limit=10&"+arg);
} catch (URISyntaxException ignored) {
}
}

public static String sendGet(String url) {
HttpGet httpGet = new HttpGet(url);
CloseableHttpResponse response = null;
try {
response = httpclient.execute(httpGet);
} catch (IOException e) {
e.printStackTrace();
}
String result = null;
try {
HttpEntity entity = response.getEntity();
if (entity != null) {
result = EntityUtils.toString(entity);
}
} catch (ParseException | IOException e) {
e.printStackTrace();
} finally {
try {
response.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return result;
}
}
24 changes: 0 additions & 24 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1 @@
config-version: 1
IDK_Helper_name: "IDK Help"
IDK_Helper_lore:
- ""
IDK_Workbench_name: "IDK Workbench"
IDK_Workbench_lore:
- ""
menu_title: "IDK Menu"
workbench_title: "IDK Workbench"
Information_name: "Information"
Information_lore:
- "Author: MinecraftBaymax"
- "Add by IDK plugin."
Help:
- "IDK plugin help:"
- "\n/IDK help - This help message"
- "\n/IDK gm <number of gamemodes> - Change your gamemode"
- "\n/IDK open workbench - Open a chest or a workbench"
- "\n/IDK plugins - Check plugin list"
- "\n/IDK load <plugin_name> - Load a plugin"
- "\n/IDK disable <plugin_name> - Disable a plugin"
- "\n/IDK enable <plugin_name> - Enable a plugin"
- "\n/IDK menu - open IDK menu"
- "\n/IDK ping - check your ping in game"
- "\n/IDK reload - reload config file"
26 changes: 25 additions & 1 deletion src/main/resources/messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,28 @@ plugin-enable-error: "Cannot enable this plugin or already enabled!"
plugin-enabled: "Plugin [plugin_name] enabled!"
plugin-not-found: "Plugin not found!"
plugin-disable-egg: "I cannot disable myself. Like you cannot make your heart stop."
plugin-enable-egg: "I cannot enable myself. Like you cannot make dead alive."
plugin-enable-egg: "I cannot enable myself. Like you cannot make dead alive."
IDK_Helper_name: "IDK Help"
IDK_Helper_lore:
- ""
IDK_Workbench_name: "IDK Workbench"
IDK_Workbench_lore:
- ""
menu_title: "IDK Menu"
workbench_title: "IDK Workbench"
Information_name: "Information"
Information_lore:
- "Author: MinecraftBaymax"
- "Add by IDK plugin."
Help:
- "IDK plugin help:"
- "\n/IDK help - This help message"
- "\n/IDK gm <number of gamemodes> - Change your gamemode"
- "\n/IDK open workbench - Open a chest or a workbench"
- "\n/IDK plugins - Check plugin list"
- "\n/IDK load <plugin_name> - Load a plugin"
- "\n/IDK disable <plugin_name> - Disable a plugin"
- "\n/IDK enable <plugin_name> - Enable a plugin"
- "\n/IDK menu - open IDK menu"
- "\n/IDK ping - check your ping in game"
- "\n/IDK reload - reload config file"

0 comments on commit f9adb26

Please sign in to comment.