Skip to content

Commit 0c71444

Browse files
committed
Initial Commit
0 parents  commit 0c71444

18 files changed

+756
-0
lines changed

.idea/.gitignore

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AetherPotions.iml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module version="4">
3+
<component name="FacetManager">
4+
<facet type="minecraft" name="Minecraft">
5+
<configuration>
6+
<autoDetectTypes>
7+
<platformType>SPIGOT</platformType>
8+
</autoDetectTypes>
9+
</configuration>
10+
</facet>
11+
</component>
12+
</module>

SnowPotions.iml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module version="4">
3+
<component name="FacetManager">
4+
<facet type="minecraft" name="Minecraft">
5+
<configuration>
6+
<autoDetectTypes>
7+
<platformType>SPIGOT</platformType>
8+
</autoDetectTypes>
9+
</configuration>
10+
</facet>
11+
</component>
12+
</module>

pom.xml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.kardasland</groupId>
8+
<artifactId>AetherPotions</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
<packaging>jar</packaging>
11+
12+
<name>AetherPotions</name>
13+
14+
<description>A customizable potion plugin.</description>
15+
<properties>
16+
<java.version>1.8</java.version>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
</properties>
19+
<url>www.kardasland.com</url>
20+
21+
<build>
22+
<plugins>
23+
<plugin>
24+
<groupId>org.apache.maven.plugins</groupId>
25+
<artifactId>maven-compiler-plugin</artifactId>
26+
<version>3.8.1</version>
27+
<configuration>
28+
<source>11</source>
29+
<target>11</target>
30+
</configuration>
31+
</plugin>
32+
<plugin>
33+
<groupId>org.apache.maven.plugins</groupId>
34+
<artifactId>maven-shade-plugin</artifactId>
35+
<version>3.2.4</version>
36+
<executions>
37+
<execution>
38+
<phase>package</phase>
39+
<goals>
40+
<goal>shade</goal>
41+
</goals>
42+
<configuration>
43+
<createDependencyReducedPom>false</createDependencyReducedPom>
44+
</configuration>
45+
</execution>
46+
</executions>
47+
</plugin>
48+
</plugins>
49+
<resources>
50+
<resource>
51+
<directory>src/main/resources</directory>
52+
<filtering>true</filtering>
53+
</resource>
54+
</resources>
55+
</build>
56+
57+
<repositories>
58+
<repository>
59+
<id>spigotmc-repo</id>
60+
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
61+
</repository>
62+
<repository>
63+
<id>sonatype</id>
64+
<url>https://oss.sonatype.org/content/groups/public/</url>
65+
</repository>
66+
<repository>
67+
<id>CodeMC</id>
68+
<url>https://repo.codemc.org/repository/maven-public/</url>
69+
</repository>
70+
</repositories>
71+
72+
<dependencies>
73+
<dependency>
74+
<groupId>org.spigotmc</groupId>
75+
<artifactId>spigot-api</artifactId>
76+
<version>1.15.2-R0.1-SNAPSHOT</version>
77+
<scope>provided</scope>
78+
</dependency>
79+
<dependency>
80+
<groupId>org.projectlombok</groupId>
81+
<artifactId>lombok</artifactId>
82+
<version>1.18.26</version>
83+
</dependency>
84+
<dependency>
85+
<groupId>io.github.bananapuncher714</groupId>
86+
<artifactId>nbteditor</artifactId>
87+
<version>7.18.5</version>
88+
</dependency>
89+
<dependency>
90+
<groupId>org.jetbrains</groupId>
91+
<artifactId>annotations</artifactId>
92+
<version>13.0</version>
93+
</dependency>
94+
</dependencies>
95+
</project>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.kardasland.snowpotions;
2+
3+
import org.bukkit.plugin.Plugin;
4+
import org.bukkit.plugin.java.JavaPlugin;
5+
6+
public final class AetherPotions extends JavaPlugin {
7+
8+
public static AetherPotions instance;
9+
10+
@Override
11+
public void onEnable() {
12+
instance = this;
13+
// Plugin startup logic
14+
15+
}
16+
17+
@Override
18+
public void onDisable() {
19+
// Plugin shutdown logic
20+
}
21+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package com.kardasland.snowpotions.commands;
2+
3+
import com.kardasland.snowpotions.potion.CustomPotionItem;
4+
import org.bukkit.Bukkit;
5+
import org.bukkit.command.Command;
6+
import org.bukkit.command.CommandExecutor;
7+
import org.bukkit.command.CommandSender;
8+
import org.bukkit.entity.Player;
9+
import org.bukkit.inventory.ItemStack;
10+
import org.jetbrains.annotations.NotNull;
11+
12+
import java.util.Objects;
13+
14+
public class MainCommand implements CommandExecutor {
15+
16+
//snowpotions give kardasland kumar 5
17+
@Override
18+
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
19+
if (sender instanceof Player){
20+
Player player = (Player) sender;
21+
switch (args[0]){
22+
case "give":{
23+
String targetName = args[1];
24+
Player target = Bukkit.getPlayer(targetName);
25+
if (target != null && target.isOnline()){
26+
CustomPotionItem potionItem = new CustomPotionItem(args[2]);
27+
if (potionItem.getCustomPotion().getId().isEmpty() || potionItem.getCustomPotion().getId().isBlank()){
28+
// POTION ID NOT FOUND
29+
return true;
30+
}
31+
ItemStack potion = potionItem.build();
32+
int amount = Integer.parseInt(args[3]);
33+
for (int i = 0; i < amount; i++){
34+
if (target.getInventory().firstEmpty() == -1){
35+
Objects.requireNonNull(target.getLocation().getWorld()).dropItemNaturally(target.getLocation(), potion);
36+
}else {
37+
target.getInventory().addItem(potion);
38+
}
39+
}
40+
break;
41+
}
42+
break;
43+
}
44+
default:{
45+
helpScreen();
46+
break;
47+
}
48+
}
49+
}
50+
return true;
51+
}
52+
53+
private void helpScreen() {
54+
55+
}
56+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.kardasland.snowpotions.events;
2+
3+
import com.kardasland.snowpotions.potion.CustomPotion;
4+
import io.github.bananapuncher714.nbteditor.NBTEditor;
5+
import org.bukkit.entity.Player;
6+
import org.bukkit.event.EventHandler;
7+
import org.bukkit.event.Listener;
8+
import org.bukkit.event.player.PlayerItemConsumeEvent;
9+
import org.bukkit.inventory.meta.PotionMeta;
10+
11+
public class DrinkEvent implements Listener {
12+
13+
@EventHandler(ignoreCancelled = true)
14+
public void check(PlayerItemConsumeEvent event){
15+
if(event.getItem().hasItemMeta() && event.getItem().getItemMeta() instanceof PotionMeta){
16+
if (NBTEditor.contains(event.getItem(), "potionid")) {
17+
Player p = event.getPlayer();
18+
String id = NBTEditor.getString(event.getItem(), "potionid");
19+
CustomPotion potion = new CustomPotion(id);
20+
if (potion.getData() != null){
21+
event.setCancelled(true);
22+
potion.apply(p, event);
23+
}
24+
}
25+
}
26+
}
27+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.kardasland.snowpotions.events;
2+
3+
import com.kardasland.snowpotions.AetherPotions;
4+
import com.kardasland.snowpotions.potion.CustomPotion;
5+
import io.github.bananapuncher714.nbteditor.NBTEditor;
6+
import org.bukkit.entity.Entity;
7+
import org.bukkit.entity.Player;
8+
import org.bukkit.entity.ThrownPotion;
9+
import org.bukkit.event.EventHandler;
10+
import org.bukkit.event.Listener;
11+
import org.bukkit.event.entity.PotionSplashEvent;
12+
import org.bukkit.event.entity.ProjectileLaunchEvent;
13+
import org.bukkit.inventory.ItemStack;
14+
import org.bukkit.metadata.FixedMetadataValue;
15+
import org.bukkit.metadata.MetadataValue;
16+
import org.bukkit.potion.PotionEffect;
17+
import org.bukkit.potion.PotionEffectType;
18+
19+
import java.util.Objects;
20+
21+
public class SplashEvent implements Listener {
22+
// COPIED CODE, WILL BE EDITED LATER
23+
@EventHandler
24+
public void onProjectileLaunch(ProjectileLaunchEvent event) {
25+
if (event.getEntity().getShooter() instanceof Player) {
26+
if (event.getEntity() instanceof ThrownPotion) {
27+
Player player = (Player) event.getEntity().getShooter();
28+
ItemStack item = player.getInventory().getItemInMainHand();
29+
if (item.getItemMeta() != null && NBTEditor.contains(item, "potionid")){
30+
event.getEntity().setMetadata("aetherpotion", new FixedMetadataValue(AetherPotions.instance, NBTEditor.getString(item, "potionid")));
31+
}
32+
}
33+
}
34+
}
35+
36+
@EventHandler
37+
public void splash(PotionSplashEvent event) {
38+
if (event.getPotion().hasMetadata("aetherpotion")) {
39+
String id = String.valueOf(event.getPotion().getMetadata("aetherpotion").get(0).value());
40+
CustomPotion potion = new CustomPotion(id);
41+
for (Entity e : event.getAffectedEntities()){
42+
if (e instanceof Player){
43+
// we can safely do null because it cannot and will not use the event cause of the splash feature
44+
potion.apply(Objects.requireNonNull(((Player) e).getPlayer()), null);
45+
}
46+
}
47+
}
48+
}
49+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.kardasland.snowpotions.potion;
2+
3+
import com.kardasland.snowpotions.utility.ConfigManager;
4+
import lombok.Getter;
5+
import lombok.Setter;
6+
import org.bukkit.configuration.file.FileConfiguration;
7+
8+
import java.util.List;
9+
10+
public class CustomCommandList {
11+
12+
@Getter @Setter
13+
private List<String> drinkingCommandList;
14+
@Getter @Setter
15+
private List<String> splashCommandList;
16+
@Getter @Setter
17+
public boolean isSplash;
18+
@Getter @Setter AfterEffect afterEffect;
19+
20+
public CustomCommandList(String id, boolean isSplash) {
21+
FileConfiguration cf = ConfigManager.get("potions.yml");
22+
this.isSplash = isSplash;
23+
String shortcut = "potions."+id+".commands.";
24+
if (isSplash){
25+
this.splashCommandList = cf.getStringList(shortcut + "splashCommandList");
26+
}else {
27+
this.drinkingCommandList = cf.getStringList(shortcut + "drinkingCommandList");
28+
}
29+
this.afterEffect = new AfterEffect(id);
30+
}
31+
32+
public static class AfterEffect{
33+
@Getter @Setter
34+
private boolean enabled;
35+
@Getter @Setter
36+
private int time;
37+
@Getter @Setter
38+
private List<String> commands;
39+
40+
public AfterEffect(String id) {
41+
FileConfiguration cf = ConfigManager.get("potions.yml");
42+
String shortcut = "potions."+id+".commands.afterEffect.";
43+
this.enabled = cf.getBoolean(shortcut + "enabled");
44+
this.time = cf.getInt(shortcut + "time");
45+
this.commands = cf.getStringList(shortcut + "commands");
46+
}
47+
}
48+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.kardasland.snowpotions.potion;
2+
3+
import com.kardasland.snowpotions.utility.ConfigManager;
4+
import lombok.Getter;
5+
import lombok.Setter;
6+
import org.bukkit.configuration.file.FileConfiguration;
7+
8+
public class CustomParticle {
9+
@Getter @Setter
10+
private boolean enabled;
11+
@Getter @Setter
12+
private String type;
13+
@Getter @Setter
14+
private int time;
15+
@Getter @Setter
16+
private int amount;
17+
18+
public CustomParticle(String id) {
19+
FileConfiguration cf = ConfigManager.get("potions.yml");
20+
String shortcut = "potions."+id+".particle.";
21+
this.enabled = cf.getBoolean(shortcut + "enabled");
22+
this.type = cf.getString(shortcut + "type");
23+
this.time = cf.getInt(shortcut + "time");
24+
this.amount = cf.getInt(shortcut + "amount");
25+
}
26+
}

0 commit comments

Comments
 (0)