big push
This commit is contained in:
11
GUI Report/.classpath
Normal file
11
GUI Report/.classpath
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="lib" path="C:/Users/jmsdesk/Documents/Minecraft Plugins/MC-Plugins/bukkit/spigot-1.13.2.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
1
GUI Report/.gitignore
vendored
Normal file
1
GUI Report/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/bin/
|
||||
17
GUI Report/.project
Normal file
17
GUI Report/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>GUI Report</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
11
GUI Report/.settings/org.eclipse.jdt.core.prefs
Normal file
11
GUI Report/.settings/org.eclipse.jdt.core.prefs
Normal file
@@ -0,0 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
18
GUI Report/src/com/jslightham/guireport/Main.java
Normal file
18
GUI Report/src/com/jslightham/guireport/Main.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.jslightham.guireport;
|
||||
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.jslightham.guireport.commands.TestCommand;
|
||||
import com.jslightham.guireport.listeners.InventoryClickListener;
|
||||
import com.jslightham.guireport.ui.TestUI;
|
||||
|
||||
public class Main extends JavaPlugin{
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
new TestCommand(this);
|
||||
new InventoryClickListener(this);
|
||||
TestUI.initialize();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.jslightham.guireport.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.jslightham.guireport.Main;
|
||||
import com.jslightham.guireport.ui.TestUI;
|
||||
|
||||
public class TestCommand implements CommandExecutor{
|
||||
|
||||
private Main plugin;
|
||||
|
||||
public TestCommand(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
plugin.getCommand("test").setExecutor(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
if(!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player p = (Player) sender;
|
||||
|
||||
if(p.hasPermission("guireport.opentest")) {
|
||||
p.openInventory(TestUI.GUI(p));
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.jslightham.guireport.listeners;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
||||
import com.jslightham.guireport.Main;
|
||||
import com.jslightham.guireport.ui.TestUI;
|
||||
|
||||
public class InventoryClickListener implements Listener {
|
||||
|
||||
private Main plugin;
|
||||
public InventoryClickListener(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
String title = e.getInventory().getTitle();
|
||||
if(title.equals(TestUI.inventory_name)) {
|
||||
e.setCancelled(true);
|
||||
if(e.getCurrentItem() == null) {
|
||||
return;
|
||||
}
|
||||
if(title.equals(TestUI.inventory_name)) {
|
||||
TestUI.clicked((Player) e.getWhoClicked(), e.getSlot(), e.getCurrentItem(), e.getInventory());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
36
GUI Report/src/com/jslightham/guireport/ui/TestUI.java
Normal file
36
GUI Report/src/com/jslightham/guireport/ui/TestUI.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.jslightham.guireport.ui;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.jslightham.guireport.utils.Utils;
|
||||
|
||||
public class TestUI {
|
||||
|
||||
public static Inventory inv;
|
||||
public static String inventory_name;
|
||||
public static int inv_rows = 4 * 9;
|
||||
|
||||
public static void initialize() {
|
||||
inventory_name = Utils.chat("&6&lTest GUI");
|
||||
inv = Bukkit.createInventory(null, inv_rows);
|
||||
}
|
||||
|
||||
public static Inventory GUI (Player p) {
|
||||
Inventory toReturn = Bukkit.createInventory(null, inv_rows, inventory_name);
|
||||
|
||||
Utils.createItem(toReturn, "BIRCH_BOAT", 1, 1, "&cTest Item", "&7This is a lore line 1", "&bSecond line", "&3Third line");
|
||||
|
||||
toReturn.setContents(inv.getContents());
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static void clicked(Player p, int slot, ItemStack clicked, Inventory inv) {
|
||||
if(clicked.getItemMeta().getDisplayName().equalsIgnoreCase(Utils.chat("&cTest Item"))) {
|
||||
p.setDisplayName(Utils.chat("It works!"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
54
GUI Report/src/com/jslightham/guireport/utils/Utils.java
Normal file
54
GUI Report/src/com/jslightham/guireport/utils/Utils.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package com.jslightham.guireport.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class Utils {
|
||||
|
||||
public static String chat(String s) {
|
||||
return ChatColor.translateAlternateColorCodes('&', s);
|
||||
}
|
||||
|
||||
public static ItemStack createItem(Inventory inv, String materialId, int amount, int invSlot, String displayName, String... loreString) {
|
||||
ItemStack item;
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
|
||||
item = new ItemStack(Material.ACACIA_BOAT, amount);
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(Utils.chat(displayName));
|
||||
for(String s : loreString) {
|
||||
lore.add(Utils.chat(s));
|
||||
}
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
|
||||
inv.setItem(invSlot, item);
|
||||
return item;
|
||||
}
|
||||
|
||||
public static ItemStack createItemByte(Inventory inv, String materialId, int byteId, int amount, int invSlot, String displayName, String... loreString) {
|
||||
ItemStack item;
|
||||
ArrayList<String> lore = new ArrayList();
|
||||
|
||||
item = new ItemStack(Material.getMaterial(materialId), amount, (short) byteId);
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(Utils.chat(displayName));
|
||||
for(String s : loreString) {
|
||||
lore.add(Utils.chat(s));
|
||||
}
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
|
||||
inv.setItem(invSlot, item);
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
8
GUI Report/src/plugin.yml
Normal file
8
GUI Report/src/plugin.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
name: GUIReport
|
||||
main: com.jslightham.guireport.Main
|
||||
description: A simple easy to use, player reporting system with a GUI
|
||||
version: 1.0.0
|
||||
author: jslightham
|
||||
|
||||
commands:
|
||||
test:
|
||||
Reference in New Issue
Block a user