initial commit

This commit is contained in:
Bea 2020-04-09 18:24:21 +02:00
commit f3358bb2d0
16 changed files with 585 additions and 0 deletions

View File

@ -0,0 +1,8 @@
<component name="ArtifactManager">
<artifact type="jar" name="ultratools:jar">
<output-path>$PROJECT_DIR$/../../</output-path>
<root id="archive" name="ultratools.jar">
<element id="module-output" name="UltraTools" />
</root>
</artifact>
</component>

0
.idea/description.html Normal file
View File

View File

@ -0,0 +1,8 @@
<component name="ProjectDictionaryState">
<dictionary name="Lorenzo">
<words>
<w>minecraft</w>
<w>ultratools</w>
</words>
</dictionary>
</component>

6
.idea/encodings.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

6
.idea/misc.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/UltraTools.iml" filepath="$PROJECT_DIR$/UltraTools.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,3 @@
<template>
<input-field default="net.mindoverflow.spigotplugin">IJ_BASE_PACKAGE</input-field>
</template>

5
.idea/template-meta.xml Normal file
View File

@ -0,0 +1,5 @@
<template unencoded="false">
<roots>
<root index="0" path="" />
</roots>
</template>

77
.idea/workspace.xml Normal file
View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AnalysisUIOptions">
<option name="SCOPE_TYPE" value="3" />
</component>
<component name="ArtifactsWorkspaceSettings">
<artifacts-to-build>
<artifact name="ultratools:jar" />
</artifacts-to-build>
</component>
<component name="ChangeListManager">
<list default="true" id="7ae004cd-3a5f-4760-8c8e-00891734ecb5" name="Default Changelist" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
</list>
</option>
</component>
<component name="ProjectId" id="1WZgR6lA5DNdb5uAqXbcuvrrtce" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showExcludedFiles" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="last_opened_file_path" value="$PROJECT_DIR$/../../../spigot-1.15.jar!/" />
<property name="project.structure.last.edited" value="Artifacts" />
<property name="project.structure.proportion" value="0.15" />
<property name="project.structure.side.proportion" value="0.2" />
<property name="settings.editor.selected.configurable" value="MTConfigurable" />
</component>
<component name="ServiceViewManager">
<option name="viewStates">
<list>
<serviceView>
<treeState>
<expand />
<select />
</treeState>
</serviceView>
</list>
</option>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="7ae004cd-3a5f-4760-8c8e-00891734ecb5" name="Default Changelist" comment="" />
<created>1579362519493</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1579362519493</updated>
</task>
<servers />
</component>
<component name="WindowStateProjectService">
<state x="961" y="425" key="#com.intellij.openapi.updateSettings.impl.PluginUpdateInfoDialog" timestamp="1579367904933">
<screen x="0" y="0" width="2560" height="1400" />
</state>
<state x="961" y="425" key="#com.intellij.openapi.updateSettings.impl.PluginUpdateInfoDialog/0.0.2560.1400/3840.1065.1600.860@0.0.2560.1400" timestamp="1579367904933" />
<state x="782" y="342" key="SettingsEditor" timestamp="1579367995139">
<screen x="0" y="0" width="2560" height="1400" />
</state>
<state x="782" y="342" key="SettingsEditor/0.0.2560.1400/3840.1065.1600.860@0.0.2560.1400" timestamp="1579367995139" />
<state x="731" y="424" key="new project wizard" timestamp="1579427467158">
<screen x="0" y="0" width="2560" height="1400" />
</state>
<state x="731" y="424" key="new project wizard/0.0.2560.1400/3840.1065.1600.860@0.0.2560.1400" timestamp="1579427467158" />
</component>
</project>

22
UltraTools.iml Normal file
View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library" scope="PROVIDED">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../../spigot-1.15.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MODULE_DIR$/../../../spigot-1.15.jar!/" />
</SOURCES>
</library>
</orderEntry>
</component>
</module>

View File

@ -0,0 +1,42 @@
package net.mindoverflow.ultratools;
import net.mindoverflow.ultratools.commands.CommandInfo;
import net.mindoverflow.ultratools.commands.GetInventory;
import net.mindoverflow.ultratools.inventories.Inventories;
import net.mindoverflow.ultratools.listeners.PlayerJoinListener;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Main extends JavaPlugin
{
// Initializing needed variables.
public static double version = 0.4;
YamlConfiguration config;
private Logger logger = Logger.getLogger("Minecraft");
public static ArrayList<String> vanished = new ArrayList<String>();
// Method called when the plugin is being loaded.
@Override
public void onEnable() {
logger = getLogger();
logger.log(Level.INFO, "========= !ULTRATOOLS " + version + " ENABLED! =========");
getCommand("getinv").setExecutor(new GetInventory());
getCommand("ultratools").setExecutor(new CommandInfo());
getServer().getPluginManager().registerEvents(new Inventories(this), this);
getServer().getPluginManager().registerEvents(new PlayerJoinListener(this), this);
getServer().getPluginManager().registerEvents(new GetInventory(), this);
}
// Method called when the plugin is being unloaded.
@Override
public void onDisable() {
logger.log(Level.INFO, "========= !ULTRATOOLS " + version + " DISABLED! =========");
}
}

View File

@ -0,0 +1,18 @@
package net.mindoverflow.ultratools.commands;
import net.mindoverflow.ultratools.Main;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class CommandInfo implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
{
sender.sendMessage("§0[§6UT§0] §7UltraTools version §6" + Main.version + " §7for CraftBukkit/SpigotMC §61.13§7-§61.15");
sender.sendMessage("§0[§6UT§0] §7Developed by §6mind_overflow§7.");
return true;
}
}

View File

@ -0,0 +1,83 @@
package net.mindoverflow.ultratools.commands;
import net.mindoverflow.ultratools.inventories.Inventories;
import org.bukkit.Material;
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.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
public class GetInventory implements CommandExecutor, Listener
{
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
{
if(!(sender instanceof Player)) {
sender.sendMessage("§4This command is only for Players!");
return true;
}
Player player = (Player) sender;
if(sender.hasPermission("ultratools.getinv")) {
List<String> ls = new ArrayList<String>();
ls.add("§dRight click to Open the Menu!");
player.getInventory().addItem(setName(new ItemStack(Material.SUGAR, 1), "§5§lUltra§6§lTools", ls));
ls.clear();
} else {
sender.sendMessage("§cYou don't have Permissions!");
}
return true;
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e)
{
Player player = e.getPlayer();
if(player.getInventory().getItemInMainHand().getItemMeta() != null &&
player.getInventory().getItemInMainHand().getType().equals(Material.SUGAR) &&
player.getInventory().getItemInMainHand().getItemMeta().getDisplayName().equals("§5§lUltra§6§lTools"))
{
if(player.hasPermission("ultratools.openinv"))
{
try {
Thread.sleep(1L);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
player.openInventory(Inventories.tools);
}
else
{
player.sendMessage("§cYou don't have Permissions!");
}
}
}
private static ItemStack setName(ItemStack is, String name, List<String> lore)
{
ItemMeta im = is.getItemMeta();
if(name != null && im != null) {
im.setDisplayName(name);
}
if(lore != null && im != null) {
im.setLore(lore);
}
is.setItemMeta(im);
return is;
}
}

View File

@ -0,0 +1,248 @@
package net.mindoverflow.ultratools.inventories;
import net.mindoverflow.ultratools.Main;
import org.bukkit.Bukkit;
import org.bukkit.Difficulty;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
public class Inventories implements Listener {
private static Main plugin;
public Inventories(Main plugin) {
Inventories.plugin = plugin;
}
public static Inventory tools = Bukkit.createInventory(null, 54, "§5§lUltra§6§lTools");
static {
List<String> ls = new ArrayList<String>();
//ls.add("UltraTntProZ!");
//TIME SETTINGS
tools.setItem(0, setName(new ItemStack(Material.CLOCK, 1), "§7§lTime", ls));
ls.add("§7Set the time at Dawn!");
tools.setItem(18, setName(new ItemStack(Material.REDSTONE, 1), "§6Dawn", ls));
ls.clear();
ls.add("§7Set the time at Midday!");
tools.setItem(27, setName(new ItemStack(Material.GLOWSTONE_DUST, 1), "§eMidday", ls));
ls.clear();
ls.add("§7Set the time at Evening!");
tools.setItem(36, setName(new ItemStack(Material.SUGAR, 1), "§7Evening", ls));
ls.clear();
ls.add("§7Set the time at Midnight!");
tools.setItem(45, setName(new ItemStack(Material.GUNPOWDER, 1), "§8Midnight", ls));
ls.clear();
//WEATHER SETTINGS
tools.setItem(2, setName(new ItemStack(Material.BLAZE_POWDER, 1), "§7§lWeather", ls));
ls.clear();
ls.add("§7Change the Weather to Sun!");
tools.setItem(20, setName(new ItemStack(Material.GOLD_NUGGET, 1), "§6Sun", ls));
ls.clear();
ls.add("§7Change the Weather to Rain!");
tools.setItem(29, setName(new ItemStack(Material.GHAST_TEAR, 1), "§7Rain", ls));
ls.clear();
ls.add("§7Change the Weather to Thunder!");
tools.setItem(38, setName(new ItemStack(Material.FLINT, 1), "§8Thunder", ls));
ls.clear();
//GAMEMODE SETTINGS
tools.setItem(4, setName(new ItemStack(Material.EGG, 1), "§7§lGamemode", ls));
ls.clear();
ls.add("§7Change your Gamemode to Creative!");
tools.setItem(22, setName(new ItemStack(Material.GRASS, 1), "§6Creative", ls));
ls.clear();
ls.add("§7Change your Gamemode to Survival!");
tools.setItem(31, setName(new ItemStack(Material.CRAFTING_TABLE, 1), "§cSurvival", ls));
ls.clear();
ls.add("§7Change your Gamemode to Adventure!");
tools.setItem(40, setName(new ItemStack(Material.CHEST, 1), "§9Adventure", ls));
ls.clear();
//DIFFICULTY SETTINGS
tools.setItem(6, setName(new ItemStack(Material.SKELETON_SKULL, 1), "§7§lDifficulty", ls));
ls.clear();
ls.add("§7Change the Difficulty to Peaceful!");
tools.setItem(24, setName(new ItemStack(Material.WOODEN_SWORD, 1), "§2Peaceful", ls));
ls.clear();
ls.add("§7Change the Difficulty to Easy!");
tools.setItem(33, setName(new ItemStack(Material.STONE_SWORD, 1), "§6Easy", ls));
ls.clear();
ls.add("§7Change the Difficulty to Normal!");
tools.setItem(42, setName(new ItemStack(Material.IRON_SWORD, 1), "§cNormal", ls));
ls.clear();
ls.add("§7Change the Difficulty to Hard!");
tools.setItem(51, setName(new ItemStack(Material.DIAMOND_SWORD, 1), "§4Hard", ls));
ls.clear();
//HEAL THE PLAYER
ls.add("§7Heal yourself!");
tools.setItem(26, setName(new ItemStack(Material.COOKED_PORKCHOP, 1), "§aHeal", ls));
ls.clear();
//PERMIT FLY TO THE PLAYER
ls.add("§7Enable the Fly Mode!");
tools.setItem(35, setName(new ItemStack(Material.FEATHER, 1), "§8Fly", ls));
ls.clear();
//ENABLE OR DISABLE VANISH MODE
ls.add("§7Enable the Vanish Mode!");
tools.setItem(44, setName(new ItemStack(Material.POTION, 1), "§9Vanish", ls));
ls.clear();
//CLOSE THE MENU
ls.add("§7Close the Menu!");
tools.setItem(8, setName(new ItemStack(Material.ENDER_PEARL, 1), "§cClose", ls));
ls.clear();
//tools.setItem(8, new ItemStack(Material.GOLD_BLOCK, 1));
}
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
ItemStack clicked = event.getCurrentItem();
Inventory inventory = event.getInventory();
if(event.getView().getTitle().equals("§5§lUltra§6§lTools"))
{
if (clicked.getType() == Material.GLOWSTONE_DUST) {
//Bukkit.getServer().dispatchCommand(player, "time set 6000");
player.getWorld().setTime(6000L);
event.setCancelled(true);
player.closeInventory();
player.sendMessage("§eTime set to Midday!");
} else if (clicked.getType() == Material.REDSTONE) {
player.getWorld().setTime(0L);
event.setCancelled(true);
player.closeInventory();
player.sendMessage("§6Time set to Dawn!");
} else if (clicked.getType() == Material.SUGAR) {
player.getWorld().setTime(13000L);
event.setCancelled(true);
player.closeInventory();
player.sendMessage("§7Time set to Evening!");
} else if (clicked.getType() == Material.GUNPOWDER) {
player.getWorld().setTime(18000L);
event.setCancelled(true);
player.closeInventory();
player.sendMessage("§8Time set to Midnight!");
} else if (clicked.getType() == Material.GOLD_NUGGET) {
player.getWorld().setStorm(false);
player.getWorld().setThundering(false);
event.setCancelled(true);
player.closeInventory();
player.sendMessage("§6It's Sunny now!");
} else if (clicked.getType() == Material.GHAST_TEAR) {
player.getWorld().setStorm(true);
player.getWorld().setThundering(false);
event.setCancelled(true);
player.closeInventory();
player.sendMessage("§9It's Rainy now!");
} else if (clicked.getType() == Material.FLINT) {
player.getWorld().setStorm(true);
player.getWorld().setThundering(true);
event.setCancelled(true);
player.closeInventory();
player.sendMessage("§1It's Thundering!");
} else if (clicked.getType() == Material.GRASS) {
player.setGameMode(GameMode.CREATIVE);
event.setCancelled(true);
player.closeInventory();
player.sendMessage("§6Gamemode changed to Creative!");
} else if (clicked.getType() == Material.CRAFTING_TABLE) {
player.setGameMode(GameMode.SURVIVAL);
event.setCancelled(true);
player.closeInventory();
player.sendMessage("§cGamemode changed to Survival!");
} else if (clicked.getType() == Material.CHEST) {
player.setGameMode(GameMode.ADVENTURE);
event.setCancelled(true);
player.closeInventory();
player.sendMessage("§9Gamemode changed to Adventure!");
//DIFFICULTY SETTINGS
} else if (clicked.getType() == Material.WOODEN_SWORD) {
player.getWorld().setDifficulty(Difficulty.PEACEFUL);
event.setCancelled(true);
player.closeInventory();
player.sendMessage("§2Difficulty changed to Peaceful!");
} else if (clicked.getType() == Material.STONE_SWORD) {
player.getWorld().setDifficulty(Difficulty.EASY);
event.setCancelled(true);
player.closeInventory();
player.sendMessage("§6Difficulty changed to Easy!");
} else if (clicked.getType() == Material.IRON_SWORD) {
player.getWorld().setDifficulty(Difficulty.NORMAL);
event.setCancelled(true);
player.closeInventory();
player.sendMessage("§cDifficulty changed to Normal!");
} else if (clicked.getType() == Material.DIAMOND_SWORD) {
player.getWorld().setDifficulty(Difficulty.HARD);
event.setCancelled(true);
player.closeInventory();
player.sendMessage("§4Difficulty changed to Hard!");
} else if (clicked.getType() == Material.COOKED_PORKCHOP) {
player.setHealth(20L);
player.setFoodLevel(20);
event.setCancelled(true);
player.closeInventory();
player.sendMessage("§aYou have been Healed!");
} else if (clicked.getType() == Material.FEATHER) {
event.setCancelled(true);
player.closeInventory();
if(player.getAllowFlight()) {
player.setAllowFlight(false);
player.setFlying(false);
player.sendMessage("§8Fly Mode disabled!");
} else {
player.setAllowFlight(true);
player.sendMessage("§8Fly Mode enabled!");
}
} else if (clicked.getType() == Material.POTION) {
if(Main.vanished.contains(player.getName())) {
for (Player p : Bukkit.getServer().getOnlinePlayers())
{
p.showPlayer(plugin, player);
}
player.sendMessage("§cVanish Mode Disabled!");
Main.vanished.remove(player.getName());
} else {for (Player p : Bukkit.getServer().getOnlinePlayers())
{
p.hidePlayer(plugin, player);
}
player.sendMessage("§9Vanish Mode Enabled!");
player.sendMessage("§7You will continue seeing yourself, but nobody else will see you!");
Main.vanished.add(player.getName());
}
event.setCancelled(true);
player.closeInventory();
} else if (clicked.getType() == Material.ENDER_PEARL) {
event.setCancelled(true);
player.closeInventory();
}
else {
event.setCancelled(true);
}
}
}
private static ItemStack setName(ItemStack is, String name, List<String> lore) {
ItemMeta im = is.getItemMeta();
if(name != null && im != null) {
im.setDisplayName(name);
}
if(lore != null && im != null) {
im.setLore(lore);
}
is.setItemMeta(im);
return is;
}
}

View File

@ -0,0 +1,41 @@
package net.mindoverflow.ultratools.listeners;
import net.mindoverflow.ultratools.Main;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerJoinListener implements Listener
{
private Main plugin;
public PlayerJoinListener(Main plugin)
{
this.plugin = plugin;
}
@EventHandler
void onPlayerJoin(PlayerJoinEvent e)
{
Player p = e.getPlayer();
for(String vanishedPlayerName : Main.vanished)
{
Player vanishedPlayer = plugin.getServer().getPlayer(vanishedPlayerName);
if(vanishedPlayer != null)
{
p.hidePlayer(plugin, vanishedPlayer);
}
}
}
@EventHandler
void onPlayerQuit(PlayerQuitEvent e)
{
Player p = e.getPlayer();
Main.vanished.remove(p.getName());
}
}

10
src/plugin.yml Normal file
View File

@ -0,0 +1,10 @@
name: UltraTools
version: 0.4
author: mind_overflow
main: net.mindoverflow.ultratools.Main
api-version: 1.13
commands:
ultratools:
description: Main command for UltraTools!
getinv:
description: Get the Inventory Item!