Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,17 @@
import com.lunarclient.apollo.example.common.commands.module.CombatCommand;
import com.lunarclient.apollo.example.common.commands.module.CooldownCommand;
import com.lunarclient.apollo.example.common.commands.module.EntityCommand;
import com.lunarclient.apollo.example.common.commands.module.GlintCommand;
import com.lunarclient.apollo.example.common.commands.module.GlowCommand;
import com.lunarclient.apollo.example.common.commands.module.HologramCommand;
import com.lunarclient.apollo.example.common.commands.module.InventoryCommand;
import com.lunarclient.apollo.example.common.commands.module.LimbCommand;
import com.lunarclient.apollo.example.common.commands.module.ModSettingsCommand;
import com.lunarclient.apollo.example.common.commands.module.NametagCommand;
import com.lunarclient.apollo.example.common.commands.module.NickHiderCommand;
import com.lunarclient.apollo.example.common.commands.module.NotificationCommand;
import com.lunarclient.apollo.example.common.commands.module.RichPresenceCommand;
import com.lunarclient.apollo.example.common.commands.module.SaturationCommand;
import com.lunarclient.apollo.example.common.commands.module.ServerRuleCommand;
import com.lunarclient.apollo.example.common.commands.module.StaffModCommand;
import com.lunarclient.apollo.example.common.commands.module.StopwatchCommand;
Expand All @@ -84,14 +87,17 @@
import com.lunarclient.apollo.example.common.modules.impl.CombatExample;
import com.lunarclient.apollo.example.common.modules.impl.CooldownExample;
import com.lunarclient.apollo.example.common.modules.impl.EntityExample;
import com.lunarclient.apollo.example.common.modules.impl.GlintExample;
import com.lunarclient.apollo.example.common.modules.impl.GlowExample;
import com.lunarclient.apollo.example.common.modules.impl.HologramExample;
import com.lunarclient.apollo.example.common.modules.impl.InventoryExample;
import com.lunarclient.apollo.example.common.modules.impl.LimbExample;
import com.lunarclient.apollo.example.common.modules.impl.ModSettingsExample;
import com.lunarclient.apollo.example.common.modules.impl.NametagExample;
import com.lunarclient.apollo.example.common.modules.impl.NickHiderExample;
import com.lunarclient.apollo.example.common.modules.impl.NotificationExample;
import com.lunarclient.apollo.example.common.modules.impl.RichPresenceExample;
import com.lunarclient.apollo.example.common.modules.impl.SaturationExample;
import com.lunarclient.apollo.example.common.modules.impl.ServerRuleExample;
import com.lunarclient.apollo.example.common.modules.impl.StaffModExample;
import com.lunarclient.apollo.example.common.modules.impl.StopwatchExample;
Expand Down Expand Up @@ -177,14 +183,17 @@ public class ApolloExamplePlugin extends JavaPlugin {
private CombatExample combatExample;
private CooldownExample cooldownExample;
private EntityExample entityExample;
private GlintExample glintExample;
private GlowExample glowExample;
private HologramExample hologramExample;
private InventoryExample inventoryExample;
private LimbExample limbExample;
private ModSettingsExample modSettingsExample;
private NametagExample nametagExample;
private NickHiderExample nickHiderExample;
private NotificationExample notificationExample;
private RichPresenceExample richPresenceExample;
private SaturationExample saturationExample;
private ServerRuleExample serverRuleExample;
private StaffModExample staffModExample;
private StopwatchExample stopwatchExample;
Expand Down Expand Up @@ -222,14 +231,17 @@ private void registerCommands() {
this.getCommand("combat").setExecutor(new CombatCommand());
this.getCommand("cooldown").setExecutor(new CooldownCommand());
this.getCommand("entity").setExecutor(new EntityCommand());
this.getCommand("glint").setExecutor(new GlintCommand());
this.getCommand("glow").setExecutor(new GlowCommand());
this.getCommand("hologram").setExecutor(new HologramCommand());
this.getCommand("inventory").setExecutor(new InventoryCommand());
this.getCommand("limb").setExecutor(new LimbCommand());
this.getCommand("modsettings").setExecutor(new ModSettingsCommand());
this.getCommand("nametag").setExecutor(new NametagCommand());
this.getCommand("nickhider").setExecutor(new NickHiderCommand());
this.getCommand("notification").setExecutor(new NotificationCommand());
this.getCommand("richpresence").setExecutor(new RichPresenceCommand());
this.getCommand("saturation").setExecutor(new SaturationCommand());
this.getCommand("serverrule").setExecutor(new ServerRuleCommand());
this.getCommand("staffmod").setExecutor(new StaffModCommand());
this.getCommand("stopwatch").setExecutor(new StopwatchCommand());
Expand Down Expand Up @@ -267,6 +279,10 @@ public void changeImplementationType(ApolloExampleType type) {
private void registerModuleExamples() {
this.spamPacketDebug = new SpamPacketDebug();

this.glintExample = new GlintExample();
this.inventoryExample = new InventoryExample();
this.saturationExample = new SaturationExample();

switch (TYPE) {
case API: {
this.beamExample = new BeamApiExample();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* This file is part of Apollo, licensed under the MIT License.
*
* Copyright (c) 2023 Moonsworth
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.lunarclient.apollo.example.common;

import net.minecraft.server.v1_8_R3.NBTTagCompound;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

public final class ItemUtil {

public static ItemStack itemWithName(Material material, String name) {
ItemStack item = new ItemStack(material);

ItemMeta itemMeta = item.getItemMeta();
itemMeta.setDisplayName(name);

item.setItemMeta(itemMeta);
return item;
}

public static ItemStack addTag(ItemStack item, String key, Object value) {
net.minecraft.server.v1_8_R3.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
NBTTagCompound tag = nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound();

NBTTagCompound lunarTag = tag.getCompound("lunar");
if (lunarTag == null) {
lunarTag = new NBTTagCompound();
}

if (value instanceof Integer) {
lunarTag.setInt(key, (Integer) value);
} else if (value instanceof Double) {
lunarTag.setDouble(key, (Double) value);
} else if (value instanceof Float) {
lunarTag.setFloat(key, (Float) value);
} else if (value instanceof Boolean) {
lunarTag.setBoolean(key, (Boolean) value);
} else if (value instanceof String) {
lunarTag.setString(key, (String) value);
}

tag.set("lunar", lunarTag);
nmsItem.setTag(tag);

return CraftItemStack.asBukkitCopy(nmsItem);
}

private ItemUtil() {
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* This file is part of Apollo, licensed under the MIT License.
*
* Copyright (c) 2023 Moonsworth
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.lunarclient.apollo.example.common.commands.module;

import com.lunarclient.apollo.example.ApolloExamplePlugin;
import com.lunarclient.apollo.example.common.modules.impl.GlintExample;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

public class GlintCommand implements CommandExecutor {

@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("Player only!");
return true;
}

Player player = (Player) sender;
GlintExample glintExample = ApolloExamplePlugin.getPlugin().getGlintExample();

if (glintExample.glintModuleExample(player)) {
player.sendMessage("Giving items...");
} else {
player.sendMessage("Displaying menu...");
}

return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* This file is part of Apollo, licensed under the MIT License.
*
* Copyright (c) 2023 Moonsworth
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.lunarclient.apollo.example.common.commands.module;

import com.lunarclient.apollo.example.ApolloExamplePlugin;
import com.lunarclient.apollo.example.common.modules.impl.InventoryExample;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

public class InventoryCommand implements CommandExecutor {

@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("Player only!");
return true;
}

Player player = (Player) sender;
InventoryExample inventoryExample = ApolloExamplePlugin.getPlugin().getInventoryExample();

if (inventoryExample.inventoryModuleExample(player)) {
player.sendMessage("Giving items...");
} else {
player.sendMessage("Displaying menu...");
}

return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* This file is part of Apollo, licensed under the MIT License.
*
* Copyright (c) 2023 Moonsworth
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.lunarclient.apollo.example.common.commands.module;

import com.lunarclient.apollo.example.ApolloExamplePlugin;
import com.lunarclient.apollo.example.common.modules.impl.SaturationExample;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

public class SaturationCommand implements CommandExecutor {

@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("Player only!");
return true;
}

Player player = (Player) sender;
SaturationExample saturationExample = ApolloExamplePlugin.getPlugin().getSaturationExample();

if (saturationExample.saturationModuleExample(player)) {
player.sendMessage("Giving items...");
} else {
player.sendMessage("Displaying menu...");
}

return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* This file is part of Apollo, licensed under the MIT License.
*
* Copyright (c) 2023 Moonsworth
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.lunarclient.apollo.example.common.modules.impl;

import com.lunarclient.apollo.example.common.ItemUtil;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;

public class GlintExample extends NMSExample {

public boolean glintModuleExample(Player player) {
if (this.isOneEight()) {
this.glintModuleNMSExample(player);
return false;
} else {
this.glintModuleCommandExample(player);
return true;
}
}

public void glintModuleCommandExample(Player player) {
player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:diamond_helmet\",Count:1b,tag:{lunar:{glint:\"#FF5733\"}}}}");
player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:diamond_helmet\",Count:1b,tag:{lunar:{glint:\"#33FF57\"}}}}");
player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:diamond_helmet\",Count:1b,tag:{lunar:{glint:\"#3357FF\"}}}}");
player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:diamond_helmet\",Count:1b,tag:{lunar:{glint:\"#FFD700\"}}}}");
player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:diamond_helmet\",Count:1b,tag:{lunar:{glint:\"-16711936\"}}}}");
}

public void glintModuleNMSExample(Player player) {
Inventory inventory = Bukkit.createInventory(player, 5 * 9);

inventory.setItem(11, ItemUtil.addTag(new ItemStack(Material.DIAMOND_HELMET), "glint", "#FF5733"));
inventory.setItem(14, ItemUtil.addTag(new ItemStack(Material.DIAMOND_HELMET), "glint", "#33FF57"));
inventory.setItem(17, ItemUtil.addTag(new ItemStack(Material.DIAMOND_HELMET), "glint", "#3357FF"));
inventory.setItem(29, ItemUtil.addTag(new ItemStack(Material.DIAMOND_HELMET), "glint", "#FFD700"));
inventory.setItem(33, ItemUtil.addTag(new ItemStack(Material.DIAMOND_HELMET), "glint", -16711936));

player.openInventory(inventory);
}

}
Loading