summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-09-27 19:59:24 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-09-27 19:59:24 +0100
commit1a938011fbd9ddf4e9ce843d0db967ed573ca2a3 (patch)
tree6383e63c44f5a668d70a96c1c0c592d5642b03ce
initial commit
-rw-r--r--.gitignore113
-rw-r--r--pom.xml74
-rw-r--r--src/main/java/com/yulqen/test/EventListening.java74
-rw-r--r--src/main/java/com/yulqen/test/Test.java26
-rw-r--r--src/main/resources/plugin.yml4
5 files changed, 291 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..4788b4b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,113 @@
+# User-specific stuff
+.idea/
+
+*.iml
+*.ipr
+*.iws
+
+# IntelliJ
+out/
+
+# Compiled class file
+*.class
+
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
+
+# Package Files #
+*.jar
+*.war
+*.nar
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+*~
+
+# temporary files which can be created if a process still has a handle open of a deleted file
+.fuse_hidden*
+
+# KDE directory preferences
+.directory
+
+# Linux trash folder which might appear on any partition or disk
+.Trash-*
+
+# .nfs files are created when an open file is removed but is still being accessed
+.nfs*
+
+# General
+.DS_Store
+.AppleDouble
+.LSOverride
+
+# Icon must end with two \r
+Icon
+
+# Thumbnails
+._*
+
+# Files that might appear in the root of a volume
+.DocumentRevisions-V100
+.fseventsd
+.Spotlight-V100
+.TemporaryItems
+.Trashes
+.VolumeIcon.icns
+.com.apple.timemachine.donotpresent
+
+# Directories potentially created on remote AFP share
+.AppleDB
+.AppleDesktop
+Network Trash Folder
+Temporary Items
+.apdisk
+
+# Windows thumbnail cache files
+Thumbs.db
+Thumbs.db:encryptable
+ehthumbs.db
+ehthumbs_vista.db
+
+# Dump file
+*.stackdump
+
+# Folder config file
+[Dd]esktop.ini
+
+# Recycle Bin used on file shares
+$RECYCLE.BIN/
+
+# Windows Installer files
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# Windows shortcuts
+*.lnk
+
+target/
+
+pom.xml.tag
+pom.xml.releaseBackup
+pom.xml.versionsBackup
+pom.xml.next
+
+release.properties
+dependency-reduced-pom.xml
+buildNumber.properties
+.mvn/timing.properties
+.mvn/wrapper/maven-wrapper.jar
+.flattened-pom.xml
+
+# Common working directory
+run/
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..d299e18
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>com.yulqen</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>Test</name>
+
+ <properties>
+ <java.version>1.8</java.version>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.8.1</version>
+ <configuration>
+ <source>${java.version}</source>
+ <target>${java.version}</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>3.2.4</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <createDependencyReducedPom>false</createDependencyReducedPom>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>spigotmc-repo</id>
+ <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
+ </repository>
+ <repository>
+ <id>sonatype</id>
+ <url>https://oss.sonatype.org/content/groups/public/</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.spigotmc</groupId>
+ <artifactId>spigot-api</artifactId>
+ <version>1.16.3-R0.1-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/src/main/java/com/yulqen/test/EventListening.java b/src/main/java/com/yulqen/test/EventListening.java
new file mode 100644
index 0000000..67c42f0
--- /dev/null
+++ b/src/main/java/com/yulqen/test/EventListening.java
@@ -0,0 +1,74 @@
+package com.yulqen.test;
+
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.World;
+import org.bukkit.block.Block;
+import org.bukkit.entity.*;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
+import org.bukkit.event.entity.EntityPickupItemEvent;
+import org.bukkit.event.player.PlayerJoinEvent;
+import org.bukkit.inventory.ItemStack;
+
+
+public class EventListening implements Listener {
+
+// @EventHandler
+// public void treeGenOnPickUp(EntityPickupItemEvent event) {
+// LivingEntity entity = event.getEntity();
+// String name = entity.getName();
+//
+// World world = event.getEntity().getWorld();
+// Location loc = entity.getLocation();
+// world.generateTree(new Location(world, loc.getX() +1.0, loc.getY() +1.0, loc.getZ()), TreeType.BIG_TREE);
+// }
+
+ @EventHandler
+ public void joinMessage(PlayerJoinEvent event) {
+ event.setJoinMessage("Welcome to the Server! Please behave and fun! (By the way, we have plugins and strange things might " +
+ "happen");
+ }
+
+ @EventHandler
+ public void chickenDefender(EntityDamageByEntityEvent e) {
+ Entity damager = e.getDamager();
+ if (damager instanceof Player && e.getEntity().getType().equals(EntityType.CHICKEN)) {
+ Entity chicken = e.getEntity();
+ Location loc = damager.getLocation();
+ damager.sendMessage("You damaged " + e.getEntity().getName());
+ damager.sendMessage(e.getEntity().getName() + " will be defended!");
+ World world = damager.getWorld();
+ Zombie zombie = world.spawn(new Location(world, loc.getX()+2.0, loc.getY(), loc.getZ()), Zombie.class);
+// zombie.setBaby();
+// zombie.setInvulnerable(true);
+ zombie.setCustomName("Chicken Defender");
+ world.dropItemNaturally(loc, new ItemStack(Material.DIAMOND));
+ }
+ }
+
+ @EventHandler
+ public void boomIfPickupOak(EntityPickupItemEvent e) {
+ LivingEntity player = e.getEntity();
+ Location loc = player.getLocation();
+ World world = player.getWorld();
+// Block block = world.getBlockAt(loc);
+// block.setType(Material.STONE);
+ if (e.getItem().getItemStack().getType().equals(Material.OAK_LOG)) {
+ player.sendMessage("Clank! Be careful collecting oak logs.");
+// world.createExplosion(new Location(world, loc.getX(), loc.getY(), loc.getZ()-5.0), 4f);
+ world.spawn(new Location(world, loc.getX() + 16, loc.getY(), loc.getZ()), Skeleton.class);
+ }
+ if (e.getItem().getItemStack().getType().equals(Material.DIRT)) {
+ player.sendMessage("Collecting dirt is a bad thing...");
+ world.spawn(new Location(world, loc.getX(), loc.getY(), loc.getZ() + 2.0), Wolf.class);
+ }
+// e.getItem().getItemStack().setType(Material.ANVIL);
+// double playerHealth = player.getHealth();
+// player.setHealth(playerHealth / 1.2);
+// player.sendMessage("You have lost some health.... ");
+ }
+
+}
diff --git a/src/main/java/com/yulqen/test/Test.java b/src/main/java/com/yulqen/test/Test.java
new file mode 100644
index 0000000..52fe7e0
--- /dev/null
+++ b/src/main/java/com/yulqen/test/Test.java
@@ -0,0 +1,26 @@
+package com.yulqen.test;
+
+import org.bukkit.Location;
+import org.bukkit.World;
+import org.bukkit.entity.EntityType;
+import org.bukkit.plugin.java.JavaPlugin;
+
+public final class Test extends JavaPlugin {
+
+ @Override
+ public void onEnable() {
+ System.out.println("Test MC Plugin Loaded");
+ World world = getServer().getWorld("mad_march_hare");
+// for (int i = 0; i < 20; i++) {
+// System.out.println("Spawning " + EntityType.CHICKEN);
+// world.spawnEntity(new Location(world, 64.0, 64.0 + (double)(i), 208.0), EntityType.CHICKEN);
+// }
+ getServer().getWorld("mad_march_hare").setFullTime(1000);
+ getServer().getPluginManager().registerEvents(new EventListening(), this);
+ }
+
+ @Override
+ public void onDisable() {
+ // Plugin shutdown logic
+ }
+}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
new file mode 100644
index 0000000..5f48e02
--- /dev/null
+++ b/src/main/resources/plugin.yml
@@ -0,0 +1,4 @@
+name: Test
+version: ${project.version}
+main: com.yulqen.test.Test
+api-version: 1.16