-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f3d123
commit 2d0f31e
Showing
6 changed files
with
220 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/**/target/ | ||
!**/src/test/**/target/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea/modules.xml | ||
.idea/jarRepositories.xml | ||
.idea/compiler.xml | ||
.idea/libraries/ | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### Eclipse ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?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.github.PatrykCholewa</groupId> | ||
<artifactId>FoxKiller</artifactId> | ||
<version>1.0.0-1.21.3-SNAPSHOT</version> | ||
|
||
<properties> | ||
<maven.compiler.source>21</maven.compiler.source> | ||
<maven.compiler.target>21</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<repositories> | ||
<repository> | ||
<id>spigot-repo</id> | ||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.spigotmc</groupId> | ||
<artifactId>spigot-api</artifactId> | ||
<version>1.21.1-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
|
||
</project> |
46 changes: 46 additions & 0 deletions
46
src/main/java/com/github/PatrykCholewa/FoxKiller/FoxKillerPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.github.PatrykCholewa.FoxKiller; | ||
|
||
import com.github.PatrykCholewa.FoxKiller.listeners.FoxKillListener; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.event.HandlerList; | ||
import org.bukkit.plugin.Plugin; | ||
import org.bukkit.plugin.PluginDescriptionFile; | ||
import org.bukkit.plugin.PluginManager; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
import org.bukkit.plugin.java.JavaPluginLoader; | ||
|
||
import java.io.File; | ||
|
||
public class FoxKillerPlugin extends JavaPlugin { | ||
|
||
private static Plugin instance; | ||
|
||
public static Plugin getInstance() { | ||
return instance; | ||
} | ||
|
||
public FoxKillerPlugin() { | ||
|
||
} | ||
|
||
public FoxKillerPlugin(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file) { | ||
super(loader, description, dataFolder, file); | ||
} | ||
|
||
@Override | ||
public void onEnable() { | ||
super.onEnable(); | ||
instance = this; | ||
|
||
PluginManager pluginManager = Bukkit.getPluginManager(); | ||
pluginManager.registerEvents(new FoxKillListener(), instance); | ||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
super.onDisable(); | ||
instance = null; | ||
HandlerList.unregisterAll(this); | ||
} | ||
|
||
} |
66 changes: 66 additions & 0 deletions
66
src/main/java/com/github/PatrykCholewa/FoxKiller/listeners/FoxKillListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.github.PatrykCholewa.FoxKiller.listeners; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.Material; | ||
import org.bukkit.WeatherType; | ||
import org.bukkit.damage.DamageType; | ||
import org.bukkit.entity.EntityType; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.entity.EntityDeathEvent; | ||
import org.bukkit.event.weather.WeatherChangeEvent; | ||
import org.bukkit.event.weather.WeatherEvent; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.inventory.meta.SkullMeta; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Random; | ||
|
||
public class FoxKillListener implements Listener { | ||
|
||
@EventHandler | ||
public static void onEvent(EntityDeathEvent event) { | ||
if (event.getEntity().getType() != EntityType.FOX) { | ||
return; | ||
} | ||
|
||
if (event.getDamageSource().getDamageType() != DamageType.PLAYER_ATTACK) { | ||
return; | ||
} | ||
|
||
event.getDrops().addAll(createRandomDrop()); | ||
event.setDroppedExp(7); | ||
} | ||
|
||
private static List<ItemStack> createRandomDrop() { | ||
List<ItemStack> list = new ArrayList<>(); | ||
ItemStack is; | ||
|
||
int rand = new Random().nextInt(); | ||
if ((rand % 3) == 0) { | ||
is = new ItemStack(Material.CAKE); | ||
list.add(is); | ||
} | ||
if ((rand % 7) == 0) { | ||
is = new ItemStack(Material.INFESTED_STONE_BRICKS); | ||
list.add(is); | ||
} | ||
|
||
if ((rand % 31) == 0) { | ||
is = new ItemStack(Material.OMINOUS_BOTTLE); | ||
list.add(is); | ||
} | ||
|
||
if ((rand % 47) == 0) { | ||
is = new ItemStack(Material.PLAYER_HEAD); | ||
SkullMeta skullMeta = (SkullMeta) is.getItemMeta(); | ||
skullMeta.setOwningPlayer(Bukkit.getOfflinePlayer("Zirekall")); | ||
is.setItemMeta(skullMeta); | ||
list.add(is); | ||
} | ||
|
||
return list; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
name: FoxKiller | ||
version: 1.0.0 | ||
main: com.github.PatrykCholewa.FoxKiller.FoxKillerPlugin | ||
api-version: 1.21 |