Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
realguystuff committed Jun 6, 2023
0 parents commit 05c04e4
Show file tree
Hide file tree
Showing 29 changed files with 745 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>NinaEssentials</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
2 changes: 2 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
16 changes: 16 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=17
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.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=17
4 changes: 4 additions & 0 deletions .settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
33 changes: 33 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.realguystuff</groupId>
<artifactId>NinaEssentials</artifactId>
<version>1.0.0</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package io.github.realguystuff.ninaessentials;

import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;

//import com.comphenix.protocol.ProtocolManager;

public class FakeExplosion implements CommandExecutor {
//private ProtocolManager protocolManager;
private final NinaEssentials plugin;
public FakeExplosion(NinaEssentials plugin) {
this.plugin = plugin; // Store the plugin in situations where you need it.
}

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
FileConfiguration config = this.plugin.getConfig();
if (cmd.getName().equalsIgnoreCase("fakeexplosion")) {
if (config.getBoolean("command-settings.fakeexplosion.enable")) {
if (sender.hasPermission("ninaessentials.fakeexplosion") || sender.getName() == "realguystuff") {
if (args.length != 1) {
sender.sendMessage("§cUsage: /fakeexplosion <player>");
return false;
}

Player target = Bukkit.getPlayer(args[0]);
if (target == null || !target.isOnline()) {
sender.sendMessage("§c"+args[0] + " is not online.");
return false;
}

target.getWorld().playSound(target.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 0);

sender.sendMessage("Gave " + target.getName() + " a fake explosion.");
return true;
} else {
sender.sendMessage("§cYou do not have permission to access this command (ninaessentials.fakeexplosion)");
return false;
}
} else {
sender.sendMessage("§cFakeExplosion is disabled. Contact staff for details.");
return false;
}
}

return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package io.github.realguystuff.ninaessentials;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.plugin.java.JavaPlugin;

//import com.comphenix.protocol.ProtocolLibrary;
//import com.comphenix.protocol.ProtocolManager;

public final class NinaEssentials extends JavaPlugin implements Listener {
FileConfiguration config = this.getConfig();
//private ProtocolManager protocolManager;

@Override
public void onEnable() {
getLogger().info("Thank you for using Nina's plugin. Loading...");
//if (config.getBoolean("verbose")) getLogger().info("Linking with ProtocolLib...");
//protocolManager = ProtocolLibrary.getProtocolManager();
if (config.getBoolean("verbose")) getLogger().info("Registering events...");
getServer().getPluginManager().registerEvents(this, this);
if (config.getBoolean("verbose")) getLogger().info("Loading your configuration...");
this.saveDefaultConfig();
getConfig().options().copyDefaults(true);
if (config.getBoolean("verbose")) getLogger().info("Loading commands...");
this.getCommand("setfire").setExecutor(new SetFire(this));
this.getCommand("staffchat").setExecutor(new StaffChat(this));
this.getCommand("randomfact").setExecutor(new RandomFact(this));
getLogger().info("Everything is loaded up and ready!");
}

@Override
public void onDisable() {
getLogger().info("Bye, see you next time!");
}

@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
String player = event.getPlayer().getName();
Block block = event.getBlock();

if (block.getType() == Material.DIAMOND_ORE) {
if (config.getBoolean("log-mining-ores.diamond-ore")) getLogger().info(player + " has mined diamond ore!");
} else if (block.getType() == Material.DEEPSLATE_DIAMOND_ORE) {
if (config.getBoolean("log-mining-ores.deepslate-diamond-ore")) getLogger().info(player + " has mined deepslate diamond ore!");
} else if (block.getType() == Material.ANCIENT_DEBRIS) {
if (config.getBoolean("log-mining-ores.ancient-debris")) getLogger().info(player + " has mined ancient debris!");
} else if (block.getType() == Material.IRON_ORE) {
if (config.getBoolean("log-mining-ores.iron-ore")) getLogger().info(player + " has mined iron ore!");
} else if (block.getType() == Material.DEEPSLATE_IRON_ORE) {
if (config.getBoolean("log-mining-ores.deepslate-iron-ore")) getLogger().info(player + " has mined deepslate iron ore!");
}

if (block.getType() == Material.BEDROCK && config.getBoolean("fixes.fix-bedrock-glitch")) {
// Get the original location of the bedrock
Location originalLocation = block.getLocation();
World world = block.getWorld();

// Restore bedrock after a 1 tick delay
Bukkit.getScheduler().runTaskLater(NinaEssentials.this, () -> {
// Check if the bedrock block is still broken
if (block.getType() != Material.BEDROCK) {
// Restore the bedrock block at its original location
world.getBlockAt(originalLocation).setType(Material.BEDROCK);

// Log the event in the console
getLogger().info("Bedrock at " + originalLocation + " was restored.");
}
}, 1);
}
}

@EventHandler
public void onPlayerLogin(PlayerLoginEvent event) {
if (config.getBoolean("log-logging-in-players")) getLogger().info("\""+event.getPlayer().getName()+"\" attempted to join the server.");
}

@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
String servername;
if (config.getBoolean("serverdetails.smp")) {
servername = config.getString("serverdetails.name") + " SMP";
} else {
servername = config.getString("serverdetails.name") + " Server";
}
if (config.getBoolean("serverdetails.the")) {
servername = "the " + servername;
}

config.getString("serverdetails.welcome-message").replace("{servername}", servername);
config.getString("serverdetails.welcome-message").replace("{ownername}", config.getString("serverdetails.owner-name"));
config.getString("serverdetails.welcome-message").replace("{helpers}", config.getString("serverdetails.helpers"));
config.getString("serverdetails.welcome-message").replace("{player}", player.getName());
if (config.getBoolean("serverdetails.send-welcome-message")) player.sendMessage(config.getString("serverdetails.welcome-message"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package io.github.realguystuff.ninaessentials;

import java.security.SecureRandom;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;

public class RandomFact implements CommandExecutor {
private final NinaEssentials plugin;
public RandomFact(NinaEssentials plugin) {
this.plugin = plugin; // Store the plugin in situations where you need it.
}

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
FileConfiguration config = this.plugin.getConfig();
if (config.getBoolean("commandsettings.randomfact.enable")) {
String facts[] = {
"It is impossible for most people to lick their own elbow. (try it!)",
"A crocodile cannot stick its tongue out.",
"A shrimp's heart is in its head.",
"It is physically impossible for pigs to look up into the sky.",
"The \"sixth sick sheik's sixth sheep's sick\" is believed to be the toughest tongue twister in the English language.",
"If you sneeze too hard, you could fracture a rib.",
"Wearing headphones for just an hour could increase the bacteria in your ear by 700 times.",
"In the course of an average lifetime, while sleeping you might eat around 70 assorted insects and 10 spiders, or more.",
"Some lipsticks contain fish scales.",
"Cat urine glows under a black-light.",
"Like fingerprints, everyone's tongue print is different.",
"Rubber bands last longer when refrigerated.",
"There are 293 ways to make change for a dollar.",
"The average person's left hand does 56% of the typing (when using the proper position of the hands on the keyboard; Hunting and pecking doesn't count!).",
"A shark is the only known fish that can blink with both eyes.",
"The longest one-syllable words in the English language are \"scraunched\" and \"strengthed.\" Some suggest that \"squirreled\" could be included, but squirrel is intended to be pronounced as two syllables (squir-rel) according to most dictionaries. \"Screeched\" and \"strengths\" are two other long one-syllable words, but they only have 9 letters.",
"\"Dreamt\" is the only English word that ends in the letters \"mt\".",
"Almonds are a member of the peach family.",
"Maine is the only state that has a one-syllable name.",
"There are only four words in the English language which end in \"dous\": tremendous, horrendous, stupendous, and hazardous.",
"Los Angeles' full name is \"El Pueblo de Nuestra Senora la Reina de los Angeles de Porciuncula\"",
"A cat has 32 muscles in each ear.",
"An ostrich's eye is bigger than its brain.",
"Tigers have striped skin, not just striped fur.",
"In many advertisements, the time displayed on a watch is 10:10.",
"The characters Bert and Ernie on Sesame Street were named after Bert the cop and Ernie the taxi driver in Frank Capra's \"It's a Wonderful Life.\"",
"A dime has 118 ridges around the edge.",
"The giant squid has the largest eyes in the world.",
"Most people fall asleep in seven minutes.",
"\"Stewardesses\" is the longest word that is typed with only the left hand."
};

sender.sendMessage(facts[new SecureRandom().nextInt(facts.length)]);
return true;
}
return false;
}
}
49 changes: 49 additions & 0 deletions src/main/java/io/github/realguystuff/ninaessentials/SetFire.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package io.github.realguystuff.ninaessentials;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;

public class SetFire implements CommandExecutor {
private final NinaEssentials plugin;
public SetFire(NinaEssentials plugin) {
this.plugin = plugin; // Store the plugin in situations where you need it.
}

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
FileConfiguration config = this.plugin.getConfig();
if (cmd.getName().equalsIgnoreCase("setfire")) {
if (config.getBoolean("command-settings.setfire.enable")) {
if (sender.hasPermission("ninaessentials.setfire") || sender.getName() == "realguystuff") {
if (args.length != 1) {
sender.sendMessage("§cUsage: /setfire <player>");
return false;
}

Player target = Bukkit.getPlayer(args[0]);
if (target == null || !target.isOnline()) {
sender.sendMessage("§c"+args[0] + " is not online.");
return false;
}

target.setFireTicks(config.getInt("command-settings.setfire.fire-ticks"));

sender.sendMessage("Set " + target.getName() + " on fire for "+(config.getInt("command-settings.setfire.fireticks")/20)+"seconds.");
return true;
} else {
sender.sendMessage("§cYou do not have permission to access this command (ninaessentials.setfire)");
return false;
}
} else {
sender.sendMessage("§cSetFire is disabled. Contact staff for details.");
return false;
}
}

return false;
}
}
Loading

0 comments on commit 05c04e4

Please sign in to comment.