Skip to content

Commit

Permalink
New version 2.7 (added: lunar waypoints, lunar disabled mods)
Browse files Browse the repository at this point in the history
  • Loading branch information
czQery committed Sep 18, 2021
1 parent 3787c6c commit 1b133f9
Show file tree
Hide file tree
Showing 10 changed files with 196 additions and 25 deletions.
74 changes: 71 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<img src="https://github.com/czQery/ToolKit/blob/master/banner.png?raw=true">
</p>

[![Version](https://img.shields.io/badge/version-v2.6-informational.svg)](https://github.com/czQery/ToolKit/releases)
[![Releases](https://img.shields.io/badge/download-1.17-brightgreen.svg)](https://github.com/czQery/ToolKit/releases/latest/download/ToolKit-2.6.jar)
[![Version](https://img.shields.io/badge/version-v2.7-informational.svg)](https://github.com/czQery/ToolKit/releases)
[![Releases](https://img.shields.io/badge/download-1.17-brightgreen.svg)](https://github.com/czQery/ToolKit/releases/latest/download/ToolKit-2.7.jar)

## Commands

Expand All @@ -21,6 +21,13 @@
| /gms | toolkit.gms | null | Switch player's gamemode to SURVIVAL |
| /gma | toolkit.gma | null | Switch player's gamemode to ADVENTURE |
| /gmsp | toolkit.gmsp | null | Switch player's gamemode to SPECTATOR |
| /lunar | toolkit.lunar | null | Lunar tools |

## Lunar

- Waypoints
- Disabled mods
- Automatically kick non lunar players

## Trolls

Expand Down Expand Up @@ -61,11 +68,72 @@ join:
leave:
alert: true
message: '&8[&cSERVER&8]&6 %player%&7 disconnected!'

#custom chat colors
color:
bracket: '&8'
name: '&c'
text: '&7'
highlight: '&6'
lunar:

#kick non lunar players
kick: false
kick_message: '&8[&cSERVER&8]&7 This is lunar only server!'

#lunar waypoints
waypoints:
- Spawn:
name: Spawn
color: '#ba1e0d'
world: world
x: 0
y: 100
z: 0

#disabled lunar mods
disabled_mods:
- "freelook"


# ALL LUNAR MODS
# skyblockAddons - Skyblock Addons
# toggleSneak - Toggle Sneak/Sprint
# hypixel_mod - Hypixel Mods
# armorstatus - Armor Status
# keystrokes - Key Strokes
# coords - Coordinates
# crosshair - Crosshair
# potioneffects - Potion Effects
# directionhud - Direction HUD
# waypoints - Waypoints
# scoreboard - Scoreboard
# potion_counter - Potion Counter
# ping - Ping
# motionBlur - Motion Blur
# chat - Chat
# scrollable_tooltips - Scrollable Tooltips
# uhc_overlay - UHC Overlay
# particleMultiplierMod - Particle Multiplier
# cooldowns - Cooldowns
# worldedit_cui - WorldEdit CUI
# clock - Clock
# stopwatch - Stopwatch
# memory - Memory Usage
# combo - Combo Counter
# range - Reach Display
# time_changer - Time Changer
# serverAddressMod - Server Address
# saturation - Saturation
# itemPhysic - Item Physics
# itemTrackerChild - Item Tracker
# shinyPots - Shiny Pots
# block_outline - Block Outline
# screenshot - Screenshot Uploader
# fov_mod - FOV Mod
# textHotKey - Auto Text Hot Key
# netgraph - Net Graph
# mumble-link - Mumble Link
# bossbar - Boss Bar
# freelook - Freelook
```
10 changes: 8 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -104,5 +104,11 @@
<artifactId>lombok</artifactId>
<version>1.18.20</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.8</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
4 changes: 4 additions & 0 deletions src/main/java/cz/qery/toolkit/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import cz.qery.toolkit.commands.*;
import cz.qery.toolkit.events.*;
import cz.qery.toolkit.lunar.Mod;
import cz.qery.toolkit.lunar.Waypoint;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -66,7 +67,10 @@ public void onEnable() {
Metrics metrics = new Metrics(this, pluginId);

Waypoint.Load();
Mod.Load();
Bukkit.getScheduler().runTaskAsynchronously(this, () -> Scripts.checkForUpdate());
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> Waypoint.Send(), 0, 1200);
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> Mod.Send(), 0, 12000);
}

public void loadConfiguration() {
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/cz/qery/toolkit/Scripts.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package cz.qery.toolkit;

import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.bukkit.*;
import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue;

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;


public class Scripts {
static Main plugin = Main.getPlugin(Main.class);
Expand Down Expand Up @@ -91,4 +99,24 @@ public static void bCheck(Player p) {
}
}
}

public static void checkForUpdate() {
try {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder().GET().uri(URI.create("https://api.github.com/repos/czQery/ToolKit/releases/latest")).build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());

JsonObject json = new JsonParser().parse(response.body()).getAsJsonObject();
String version = Bukkit.getServer().getPluginManager().getPlugin("ToolKit").getDescription().getVersion();
if (!("v"+version).equals(json.get("tag_name").getAsString())) {
Tools.log(b+"-------["+n+"TOOLKIT"+b+"]-------");
Tools.log(b+"- "+t+"Latest version "+h+json.get("tag_name").getAsString().replaceFirst("v", ""));
Tools.log(b+"- "+t+"This version "+h+version);
Tools.log(b+"- "+t+"Download newer version from GitHub "+h+"https://github.com/czQery/ToolKit/releases");
Tools.log(b+"----------------------");
}
} catch (Exception e) {
Tools.log(b+"["+n+"ToolKit"+b+"] &cAPI version check failed");
}
}
}
1 change: 0 additions & 1 deletion src/main/java/cz/qery/toolkit/Tools.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public static void log(String message) {
public static boolean sendLunarPacket(Player player, LCPacket packet) {
if (player.getMetadata("client").toString() != "[]") {
if (player.getMetadata("client").get(0).asString() == "LunarClient") {
player.sendPluginMessage(plugin, "lunarclient:pm", LCPacket.getPacketData(packet));
player.sendPluginMessage(plugin, "lunarclient:pm", LCPacket.getPacketData(packet));
return true;
}
Expand Down
35 changes: 21 additions & 14 deletions src/main/java/cz/qery/toolkit/commands/Lunar.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package cz.qery.toolkit.commands;

import com.lunarclient.bukkitapi.nethandler.shared.LCPacketWaypointAdd;
import com.lunarclient.bukkitapi.nethandler.shared.LCPacketWaypointRemove;
import cz.qery.toolkit.Main;
import cz.qery.toolkit.Scripts;
import cz.qery.toolkit.Tools;
import cz.qery.toolkit.lunar.Waypoint;
import org.bukkit.Bukkit;
Expand All @@ -14,7 +11,6 @@
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;

import java.util.*;

public class Lunar implements CommandExecutor {
Plugin plugin = Main.getPlugin(Main.class);
Expand Down Expand Up @@ -43,8 +39,8 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N
p.sendMessage(Tools.chat(b + "----------------------"));
break;
case "waypoint":
if(args.length < 3) {
p.sendMessage(Tools.chat(b + "[" + n + "LUNAR" + b + "]" + t + " Please use " + h + "/lunar waypoint <add/remove> <name>"));
if(args.length < 2) {
p.sendMessage(Tools.chat(b + "[" + n + "LUNAR" + b + "]" + t + " Please use " + h + "/lunar waypoint <add/remove/list>"));
} else {
switch (args[1].toLowerCase()) {
case "add":
Expand All @@ -68,18 +64,29 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N
}
break;
case "remove":
for (Waypoint waypoint : Waypoint.waypoints) {
if (waypoint.getName().equals(args[2].toString())) {
Waypoint.waypoints.remove(waypoint);
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> Waypoint.Remove(waypoint.getName(), Bukkit.getWorld(waypoint.getWorld()).getUID().toString()));
p.sendMessage(Tools.chat(b + "[" + n + "LUNAR" + b + "]" + t + " Waypoint removed!"));
return false;
if(args.length < 3) {
p.sendMessage(Tools.chat(b + "[" + n + "LUNAR" + b + "]" + t + " Please use " + h + "/lunar waypoint <remove> <name>"));
} else {
for (Waypoint waypoint : Waypoint.waypoints) {
if (waypoint.getName().equals(args[2].toString())) {
Waypoint.waypoints.remove(waypoint);
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> Waypoint.Remove(waypoint.getName(), Bukkit.getWorld(waypoint.getWorld()).getUID().toString()));
p.sendMessage(Tools.chat(b + "[" + n + "LUNAR" + b + "]" + t + " Waypoint removed!"));
return false;
}
}
p.sendMessage(Tools.chat(b + "[" + n + "LUNAR" + b + "]" + t + " Waypoint with this name does not exists!"));
}
break;
case "list":
p.sendMessage(Tools.chat(b + "-------[" + n + "LUNAR-WAYPOINTS" + b + "]--------"));
for (Waypoint waypoint : Waypoint.waypoints) {
p.sendMessage(Tools.chat(b + "- " + t + waypoint.getName()));
}
p.sendMessage(Tools.chat(b + "[" + n + "LUNAR" + b + "]" + t + " Waypoint with this name does not exists!"));
p.sendMessage(Tools.chat(b + "--------------------------------"));
break;
default:
p.sendMessage(Tools.chat(b + "[" + n + "LUNAR" + b + "]" + t + " Please use " + h + "/lunar waypoint <add/remove> <name>"));
p.sendMessage(Tools.chat(b + "[" + n + "LUNAR" + b + "]" + t + " Please use " + h + "/lunar waypoint <add/remove/list>"));
break;
}
}
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/cz/qery/toolkit/events/Join.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package cz.qery.toolkit.events;

import com.lunarclient.bukkitapi.nethandler.client.LCPacketUpdateWorld;
import com.lunarclient.bukkitapi.nethandler.LCPacket;
import com.lunarclient.bukkitapi.nethandler.client.*;
import com.lunarclient.bukkitapi.nethandler.server.LCPacketStaffModStatus;
import com.lunarclient.bukkitapi.nethandler.shared.LCPacketEmoteBroadcast;
import com.lunarclient.bukkitapi.nethandler.shared.LCPacketWaypointAdd;
import cz.qery.toolkit.Scripts;
import cz.qery.toolkit.lunar.Mod;
import cz.qery.toolkit.lunar.Waypoint;
import org.bukkit.Bukkit;
import org.bukkit.Location;
Expand Down Expand Up @@ -43,8 +47,8 @@ public void onJoin(PlayerJoinEvent e) {
}

//LUNAR STAFF
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, () -> Waypoint.SendOne(p), 20);
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, () -> Waypoint.SendOne(p), 40);
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, () -> Waypoint.SendOne(p), 60);
//
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, () -> Mod.SendOne(p), 40);
}
}
12 changes: 12 additions & 0 deletions src/main/java/cz/qery/toolkit/events/Move.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,17 @@ public void onPlayerMove(PlayerMoveEvent e) {
Scripts.bCheck(p);
}
}

//LUNAR
if (plugin.getConfig().getBoolean("lunar.kick")) {
if (p.getPlayer().getMetadata("client").toString() != "[]") {
if (!p.getPlayer().getMetadata("client").get(0).asString().equals("LunarClient")) {
System.out.println(p.getPlayer().getMetadata("client").get(0).asString());
e.getPlayer().kickPlayer(Tools.chat(plugin.getConfig().getString("lunar.kick_message")));
}
} else {
e.getPlayer().kickPlayer(Tools.chat(plugin.getConfig().getString("lunar.kick_message")));
}
}
}
}
39 changes: 39 additions & 0 deletions src/main/java/cz/qery/toolkit/lunar/Mod.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package cz.qery.toolkit.lunar;

import com.lunarclient.bukkitapi.nethandler.client.LCPacketModSettings;
import com.lunarclient.bukkitapi.nethandler.client.LCPacketUpdateWorld;
import com.lunarclient.bukkitapi.nethandler.client.obj.ModSettings;
import com.lunarclient.bukkitapi.nethandler.shared.LCPacketWaypointAdd;
import cz.qery.toolkit.Main;
import cz.qery.toolkit.Tools;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class Mod {

static Main plugin = Main.getPlugin(Main.class);
public static LCPacketModSettings mods = null;

public static void Load() {
ModSettings modSettings = new ModSettings();
for (String modId : plugin.getConfig().getStringList("lunar.disabled_mods")) {
modSettings.addModSetting(modId, new ModSettings.ModSetting(false, new HashMap<>()));
}
mods = new LCPacketModSettings(modSettings);
}

public static void Send() {
List<Player> players = new ArrayList<>(Bukkit.getOnlinePlayers());
for (Player p : players) {
Tools.sendLunarPacket(p, Mod.mods);
}
}

public static void SendOne(Player p) {
Tools.sendLunarPacket(p, Mod.mods);
}
}
8 changes: 6 additions & 2 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ color:
text: '&7'
highlight: '&6'
lunar:
kick: false
kick_message: '&8[&cSERVER&8]&7 This is lunar only server!'
waypoints:
- Spawn:
name: 'Spawn'
name: Spawn
color: '#ba1e0d'
world: 'world'
world: world
x: 0
y: 100
z: 0
disabled_mods:
- "freelook"

0 comments on commit 1b133f9

Please sign in to comment.