forked from Limework/RediSkript
Remove unneeded code
This commit is contained in:
parent
ec451d56e5
commit
bfbdd3fabc
5
pom.xml
5
pom.xml
@ -112,10 +112,5 @@
|
|||||||
<version>19.0.0</version>
|
<version>19.0.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.mongodb</groupId>
|
|
||||||
<artifactId>mongodb-driver-sync</artifactId>
|
|
||||||
<version>4.0.4</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
3
src/main/java/META-INF/MANIFEST.MF
Normal file
3
src/main/java/META-INF/MANIFEST.MF
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
Main-Class: net.limework.core.LimeworkSpigotCore
|
||||||
|
|
@ -1,40 +1,27 @@
|
|||||||
package net.limework.core;
|
package net.limework.core;
|
||||||
|
|
||||||
import net.limework.core.guis.ControlGui;
|
|
||||||
import net.limework.core.hooks.SkriptHook;
|
import net.limework.core.hooks.SkriptHook;
|
||||||
import net.limework.core.managers.DataSourcesManager;
|
|
||||||
import net.limework.core.managers.RedisManager;
|
import net.limework.core.managers.RedisManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class LimeworkSpigotCore extends JavaPlugin {
|
public class LimeworkSpigotCore extends JavaPlugin {
|
||||||
|
|
||||||
//Redis manager
|
//Redis manager
|
||||||
private RedisManager rm;
|
private RedisManager rm;
|
||||||
|
|
||||||
//data
|
|
||||||
private DataSourcesManager dsm;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
rm = new RedisManager(this);
|
rm = new RedisManager(this);
|
||||||
getServer().getPluginCommand("reloadredis").setExecutor(rm);
|
Objects.requireNonNull(getServer().getPluginCommand("reloadredis")).setExecutor(rm);
|
||||||
if (getServer().getPluginManager().getPlugin("Skript") != null) {
|
if (getServer().getPluginManager().getPlugin("Skript") != null) {
|
||||||
new SkriptHook(this);
|
new SkriptHook(this);
|
||||||
} else {
|
} else {
|
||||||
getLogger().info("Skript wasn't found.");
|
getLogger().info("Skript wasn't found.");
|
||||||
}
|
}
|
||||||
rm.start();
|
rm.start();
|
||||||
try {
|
|
||||||
ControlGui controlGui = new ControlGui(this);
|
|
||||||
this.getServer().getPluginManager().registerEvents(controlGui, this);
|
|
||||||
this.getCommand("control").setExecutor(controlGui);
|
|
||||||
} catch (NoSuchFieldError e) {
|
|
||||||
getLogger().info("SOMETHING WENT WRONG WHEN LOADING control gui.");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
dsm = new DataSourcesManager(this);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -44,15 +31,10 @@ public class LimeworkSpigotCore extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
rm.shutdown();
|
rm.shutdown();
|
||||||
dsm.shutdown();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public RedisManager getRm() {
|
public RedisManager getRm() {
|
||||||
return rm;
|
return rm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataSourcesManager getDsm() {
|
|
||||||
return dsm;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,69 +0,0 @@
|
|||||||
package net.limework.core.abstraction;
|
|
||||||
|
|
||||||
import ch.njol.skript.Skript;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.bukkit.ChatColor.translateAlternateColorCodes;
|
|
||||||
|
|
||||||
public abstract class Gui {
|
|
||||||
protected Inventory gui;
|
|
||||||
private int rows;
|
|
||||||
private boolean loaded = false;
|
|
||||||
protected String name;
|
|
||||||
|
|
||||||
|
|
||||||
protected void setup(String name, int rows) {
|
|
||||||
if (loaded) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
loaded = true;
|
|
||||||
this.rows = 9 * rows;
|
|
||||||
this.name = ChatColor.translateAlternateColorCodes('&', name);
|
|
||||||
gui = Bukkit.createInventory(null, this.rows, this.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected void makeItem(Material material, int howMany, int slot, String name) {
|
|
||||||
ItemStack item = new ItemStack(material, 1);
|
|
||||||
ItemMeta item_meta = item.getItemMeta();
|
|
||||||
item_meta.setDisplayName(translateAlternateColorCodes('&', name));
|
|
||||||
item.setItemMeta(item_meta);
|
|
||||||
item.setAmount(howMany);
|
|
||||||
this.gui.clear(slot);
|
|
||||||
this.gui.setItem(slot, item);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void makeItem(Material material, int howMany, int slot, String name, String... Lore) {
|
|
||||||
ItemStack item = new ItemStack(material, 1);
|
|
||||||
ItemMeta item_meta = item.getItemMeta();
|
|
||||||
item_meta.setDisplayName(translateAlternateColorCodes('&', name));
|
|
||||||
List<String> lore = new ArrayList<>();
|
|
||||||
for (String s : Lore) {
|
|
||||||
lore.add(translateAlternateColorCodes('&', s));
|
|
||||||
}
|
|
||||||
item_meta.setLore(lore);
|
|
||||||
item.setItemMeta(item_meta);
|
|
||||||
item.setAmount(howMany);
|
|
||||||
this.gui.clear(slot);
|
|
||||||
this.gui.setItem(slot, item);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void fillGUI(Material material) {
|
|
||||||
int slot = -1;
|
|
||||||
while (slot <= (this.rows - 2)) {
|
|
||||||
slot++;
|
|
||||||
makeItem(material, 1, slot , "&1.", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,90 +0,0 @@
|
|||||||
package net.limework.core.guis;
|
|
||||||
|
|
||||||
import net.limework.core.LimeworkSpigotCore;
|
|
||||||
import net.limework.core.abstraction.Gui;
|
|
||||||
import org.bukkit.*;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class ControlGui extends Gui implements Listener, CommandExecutor {
|
|
||||||
private LimeworkSpigotCore plugin;
|
|
||||||
|
|
||||||
public ControlGui(LimeworkSpigotCore plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
setup("&cServer Control", 6);
|
|
||||||
//fillGUI(Material.LIME_STAINED_GLASS_PANE);
|
|
||||||
makeItem(Material.CRAFTING_TABLE, 1, 10, "&eCreative mode", "&cClick this for creative mode.");
|
|
||||||
makeItem(Material.DIAMOND_SWORD, 1, 12, "&eSurvival Mode", "&bClick this for Survival mode.");
|
|
||||||
makeItem(Material.DIAMOND, 1, 14, "&eSpectator Mode", "&eClick this for Spectator mode.");
|
|
||||||
makeItem(Material.PUFFERFISH, 1, 16, "&eAdventure Mode", "&aClick this for Adventure mode.");
|
|
||||||
plugin.getServer().getScheduler().runTaskTimer(plugin, () -> {
|
|
||||||
makeItem(Material.OAK_SIGN, 1, 37, "&eRam: " + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1000000) + "MB/" + (Runtime.getRuntime().totalMemory() / 1000000) + "MB");
|
|
||||||
makeItem(Material.PLAYER_HEAD, 1, 40, "&eOnline Players: " + plugin.getServer().getOnlinePlayers().size() + "/" + plugin.getServer().getMaxPlayers());
|
|
||||||
}, 0, 20);
|
|
||||||
makeItem(Material.RED_WOOL, 1, 53, "&c&lShutdown the server");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, @NotNull String[] args) {
|
|
||||||
if (sender instanceof Player) {
|
|
||||||
Player p = ((Player) sender);
|
|
||||||
p.openInventory(gui);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onInventory(InventoryClickEvent e) {
|
|
||||||
if (e.getInventory() == gui) {
|
|
||||||
e.setCancelled(true);
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
switch (e.getSlot()) {
|
|
||||||
case 10: {
|
|
||||||
p.setGameMode(GameMode.CREATIVE);
|
|
||||||
p.closeInventory();
|
|
||||||
p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 2.0f);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 12: {
|
|
||||||
p.setGameMode(GameMode.SURVIVAL);
|
|
||||||
p.closeInventory();
|
|
||||||
p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 2.0f);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 14: {
|
|
||||||
p.setGameMode(GameMode.SPECTATOR);
|
|
||||||
p.closeInventory();
|
|
||||||
p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 2.0f);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 16: {
|
|
||||||
p.setGameMode(GameMode.ADVENTURE);
|
|
||||||
p.closeInventory();
|
|
||||||
p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 2.0f);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 53: {
|
|
||||||
p.closeInventory();
|
|
||||||
plugin.getServer().shutdown();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
p.playSound(p.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1.0f, 0.0f);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
package net.limework.core.managers;
|
|
||||||
|
|
||||||
import com.mongodb.client.MongoClient;
|
|
||||||
import com.mongodb.client.MongoClients;
|
|
||||||
import net.limework.core.LimeworkSpigotCore;
|
|
||||||
import org.bukkit.configuration.Configuration;
|
|
||||||
|
|
||||||
public class DataSourcesManager {
|
|
||||||
|
|
||||||
private MongoClient mongoClient;
|
|
||||||
|
|
||||||
|
|
||||||
public DataSourcesManager(LimeworkSpigotCore plugin) {
|
|
||||||
Configuration config = plugin .getConfig();
|
|
||||||
if (config.getBoolean("Mongodb.enabled")){
|
|
||||||
mongoClient = MongoClients.create(config.getString("Mongodb.url"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void shutdown(){
|
|
||||||
mongoClient.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public MongoClient getMongoClient() {
|
|
||||||
return mongoClient;
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,18 +4,15 @@ Redis:
|
|||||||
MaxConnections: 20
|
MaxConnections: 20
|
||||||
Threads: 10
|
Threads: 10
|
||||||
Port: 6379
|
Port: 6379
|
||||||
TimeOut: 40000
|
TimeOut: 90000
|
||||||
useSSL: false
|
useSSL: false
|
||||||
#useful if SSL is disabled
|
#useful if SSL is disabled
|
||||||
EncryptMessages: false
|
#also currently EncryptMessages is broken, meaning it must always be true or else it won't work
|
||||||
|
EncryptMessages: true
|
||||||
EncryptionKey: "16CHARACTERS KEY"
|
EncryptionKey: "16CHARACTERS KEY"
|
||||||
MacKey: "16CHARACTERS KEY"
|
MacKey: "16CHARACTERS KEY"
|
||||||
|
|
||||||
Channels:
|
Channels:
|
||||||
- "Channel1"
|
- "Channel1"
|
||||||
- "Channel2"
|
- "Channel2"
|
||||||
- "Channel3"
|
- "Channel3"
|
||||||
|
|
||||||
Mongodb:
|
|
||||||
enabled: false
|
|
||||||
url: ""
|
|
@ -6,9 +6,6 @@ api-version: 1.13
|
|||||||
softdepend:
|
softdepend:
|
||||||
- Skript
|
- Skript
|
||||||
commands:
|
commands:
|
||||||
control:
|
|
||||||
description: "server control"
|
|
||||||
permission: "admin.use"
|
|
||||||
reloadredis:
|
reloadredis:
|
||||||
description: "server control"
|
description: "Restart redis connection"
|
||||||
permission: "admin.use"
|
permission: "admin.use"
|
Loading…
Reference in New Issue
Block a user