Skip to content

Commit

Permalink
ChestSort integration and tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhincore committed Jun 7, 2022
1 parent b6cdd2d commit c2f55eb
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 130 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

.gradle
/build/
/bin/
/target/

# Ignore Gradle GUI config
Expand Down
32 changes: 15 additions & 17 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
buildscript {
repositories {
jcenter()
}

dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
}
}


plugins {
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'java'
}

apply plugin: 'com.github.johnrengelman.shadow'

repositories {
mavenCentral()
maven {
url = uri('https://papermc.io/repo/repository/maven-public/')
}

maven {
url = uri('https://repo.aikar.co/content/groups/aikar/')
}
maven {
url = uri('https://hub.jeff-media.com/nexus/repository/jeff-media-public/')
}
}

dependencies {
runtimeOnly 'io.papermc.paper:paper-api:1.18.2-R0.1-SNAPSHOT'
compileOnly 'io.papermc.paper:paper-api:1.18.2-R0.1-SNAPSHOT'
compileOnly 'de.jeff_media:ChestSortAPI:13.0.0-SNAPSHOT'
implementation 'co.aikar:taskchain-bukkit:3.7.2'
}

group = 'eu.zhincore.chestNetworks'
group = 'eu.zhincore.chestnetworks'
version = '1.0-SNAPSHOT'
description = 'chest-networks'
java.sourceCompatibility = JavaVersion.VERSION_16
description = 'chestnetworks'

shadowJar {
relocate 'co.aikar.taskchain', 'eu.zhincore.chestNetworks.taskchain'
relocate 'co.aikar.taskchain', 'eu.zhincore.chestnetworks.taskchain'
archiveClassifier = "shadowed"
}

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}

build.dependsOn shadowJar
6 changes: 1 addition & 5 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
/*
* This file was generated by the Gradle 'init' task.
*/

rootProject.name = 'chest-networks'
rootProject.name = 'ChestNetworks'
1 change: 0 additions & 1 deletion src/main/java/eu/zhincore/chestnetworks/ChestNetworks.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package eu.zhincore.chestnetworks;

import java.io.IOException;

import org.bukkit.plugin.java.JavaPlugin;
import org.json.simple.parser.ParseException;

Expand Down
23 changes: 15 additions & 8 deletions src/main/java/eu/zhincore/chestnetworks/CommandChestNet.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package eu.zhincore.chestnetworks;

import java.util.Arrays;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
Expand All @@ -24,8 +23,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
return true;
}

if (args.length < 1)
return false;
if (args.length < 1) return false;

// Sanitize arguments
for (int i = args.length - 1; i != 0; i--) {
Expand All @@ -36,8 +34,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
switch (args[0]) {
case "h":
case "help":
plugin.messenger.send("helpmsg", (Player) sender,
command.getName(), String.join(", ", command.getAliases()));
plugin.messenger.send("helpmsg", (Player) sender, command.getName(), String.join(", ", command.getAliases()));
break;

case "c":
Expand All @@ -49,7 +46,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
networksController.create((Player) sender, args[1]);
break;

case "delete":
case "deleteNetwork":
if (args.length < 2) {
sender.sendMessage(ChatColor.GOLD + "Use: " + ChatColor.RED + "/" + label + " delete <name of network>");
return true;
Expand All @@ -59,8 +56,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St

case "setChest":
case "addChest":
if (args.length < 3
|| !(args[2].equals("storage") || args[2].equals("input"))) {
if (args.length < 3 || !(args[2].equals("storage") || args[2].equals("input"))) {
sender.sendMessage(ChatColor.GOLD + "Use: " + ChatColor.RED + "/" + label
+ " addChest <name of network> <input/storage> [contents...]");
return true;
Expand All @@ -79,6 +75,17 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
// TODO
break;

case "sorting":
if (args.length < 3) {
sender.sendMessage(
ChatColor.GOLD + "Use: " + ChatColor.RED + "/" + label + " sorting <name of network> <on/off>");
return true;
}
var enabled = args[2].equalsIgnoreCase("on");
networksController.setSorting(((Player) sender).getUniqueId().toString(), args[1], enabled);
sender.sendMessage("Sorting changed");
break;

case "check":
case "checkChest":
networksController.startCheckChest((Player) sender);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
Expand All @@ -22,19 +21,20 @@ public List<String> onTabComplete(CommandSender sender, Command command, String
if (networksController.isPlayerSelectQueue((Player) sender)) {
return Arrays.asList(new String[] { "cancelSelect" });
} else if (args.length == 1) {
return Arrays.asList(new String[] {
"help", "create", "delete",
"addChest", "setChest",
"list", "checkChest"
});
return Arrays.asList(
new String[] { "help", "create", "deleteNetwork", "addChest", "setChest", "list", "checkChest", "sorting" });
} else {
switch (args[0]) {
case "create":
case "delete":
case "deleteNetwork":
if (args.length == 2) {
return Arrays.asList(new String[] { "<NetworkName>" });
}
return new ArrayList<>();
case "sorting":
if (args.length == 2) return getNets((Player) sender);
if (args.length == 3) return Arrays.asList(new String[] { "on", "off" });
return new ArrayList<>();
case "setChest":
case "addChest":
if (args.length == 2) {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/eu/zhincore/chestnetworks/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.PrintWriter;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.json.simple.JSONObject;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/eu/zhincore/chestnetworks/EventListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void onBlockBreakEvent(BlockBreakEvent ev) {
}

@EventHandler
public void onInventoryCloseEvent(InventoryCloseEvent ev) {
public void onInventoryCloseEvent(InventoryCloseEvent ev) {
onInventoryUpdate(ev.getInventory());
}

Expand Down
1 change: 0 additions & 1 deletion src/main/java/eu/zhincore/chestnetworks/Messenger.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;

import org.bukkit.command.CommandSender;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
Expand Down
Loading

0 comments on commit c2f55eb

Please sign in to comment.