Skip to content

Commit 6e3be35

Browse files
committed
First Release: 1.0.1, Done!
1 parent 6c2ceab commit 6e3be35

9 files changed

Lines changed: 247 additions & 16 deletions

File tree

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"java.compile.nullAnalysis.mode": "disabled",
3-
"java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx8G -Xms100m -Xlog:disable"
3+
"java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx8G -Xms100m -Xlog:disable",
4+
"java.configuration.updateBuildConfiguration": "interactive"
45
}

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repositories {
44
}
55

66
dependencies {
7-
compileOnly("io.papermc.paper:paper-api:1.20.2-R0.1-SNAPSHOT")
7+
compileOnly("io.papermc.paper:paper-api:1.20-R0.1-SNAPSHOT")
88
}
99

1010
plugins {

src/main/java/nl/dedouwe/items/Sources.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ public TextColor GetColor() {
3232
this == Sources.Ground ? TextColor.color(153,97,0) :
3333
this == Sources.Air ? NamedTextColor.WHITE :
3434
this == Sources.Water ? NamedTextColor.BLUE :
35-
this == Sources.Unobtainable ? NamedTextColor.LIGHT_PURPLE : NamedTextColor.GRAY;
35+
this == Sources.Unobtainable ? NamedTextColor.DARK_PURPLE : NamedTextColor.GRAY;
3636
}
3737
}

src/main/java/nl/dedouwe/items/scroll/unobtainable/BeaconScroll.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
package nl.dedouwe.items.scroll.unobtainable;
22

3+
import org.bukkit.Color;
4+
import org.bukkit.Location;
5+
import org.bukkit.Material;
36
import org.bukkit.event.player.PlayerInteractEvent;
7+
import org.bukkit.util.Vector;
48

59
import net.kyori.adventure.text.Component;
610
import net.kyori.adventure.text.TextComponent;
711
import net.kyori.adventure.text.format.NamedTextColor;
812
import nl.dedouwe.items.Scroll;
913
import nl.dedouwe.items.Sources;
14+
import nl.dedouwe.utils.ParticleUtil;
15+
import nl.dedouwe.utils.Shape;
1016

1117
public class BeaconScroll extends Scroll {
1218

@@ -20,5 +26,21 @@ public TextComponent GetHelp() {
2026
return Component.text("Shift left-click to make an beam from the sky.").color(NamedTextColor.GRAY);
2127
}
2228

23-
public void onActivate(PlayerInteractEvent e) {}
29+
public void onActivate(PlayerInteractEvent e) {
30+
Vector direction = e.getPlayer().getLocation().getDirection().clone().multiply(.7);
31+
Location position = e.getPlayer().getEyeLocation().clone();
32+
for (int i = 0; i < 30; i++) {
33+
position.add(direction);
34+
if (position.getBlock().getType()!=Material.AIR) {break;}
35+
}
36+
Shape.CreateBeam(2, 25, 10).Make((v)->{
37+
ParticleUtil.createColoredParticle(e.getPlayer().getLocation().clone().add(0, 2, 0).add(v), Color.PURPLE, 1.3f);
38+
39+
});
40+
Shape.CreateBeam(2, 25, 10).Make((v)->{
41+
ParticleUtil.createColoredParticle(position.clone().add(v), Color.PURPLE, 1.3f);
42+
43+
});
44+
position.createExplosion(20, true);
45+
}
2446
}

src/main/java/nl/dedouwe/items/scroll/unobtainable/EndScroll.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package nl.dedouwe.items.scroll.unobtainable;
22

3+
import org.bukkit.Bukkit;
4+
import org.bukkit.entity.Player;
35
import org.bukkit.event.player.PlayerInteractEvent;
46

57
import net.kyori.adventure.text.Component;
68
import net.kyori.adventure.text.TextComponent;
79
import net.kyori.adventure.text.format.NamedTextColor;
10+
import net.kyori.adventure.text.format.TextDecoration;
811
import nl.dedouwe.items.Scroll;
912
import nl.dedouwe.items.Sources;
1013

@@ -20,5 +23,10 @@ public TextComponent GetHelp() {
2023
return Component.text("Just left-click to end the world...").color(NamedTextColor.GRAY);
2124
}
2225

23-
public void onUse(PlayerInteractEvent e) {}
26+
public void onHit(PlayerInteractEvent e) {
27+
for (Player player : Bukkit.getOnlinePlayers()) {
28+
player.kick(Component.text(e.getPlayer().getName()).color(NamedTextColor.GOLD).append(Component.text(" ended the world using:").color(NamedTextColor.WHITE)).appendNewline()
29+
.append(Component.text("The End Scroll").color(NamedTextColor.DARK_PURPLE).decorate(TextDecoration.BOLD)));
30+
}
31+
}
2432
}
Lines changed: 83 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,105 @@
11
package nl.dedouwe.items.scroll.water;
22

3+
import java.util.UUID;
4+
5+
import org.bukkit.Bukkit;
6+
import org.bukkit.Color;
7+
import org.bukkit.Sound;
8+
import org.bukkit.entity.LivingEntity;
9+
import org.bukkit.entity.Player;
10+
import org.bukkit.event.EventHandler;
11+
import org.bukkit.event.Listener;
12+
import org.bukkit.event.entity.EntityDamageEvent;
313
import org.bukkit.event.player.PlayerInteractEvent;
14+
import org.bukkit.util.Vector;
415

516
import net.kyori.adventure.text.Component;
617
import net.kyori.adventure.text.TextComponent;
718
import net.kyori.adventure.text.format.NamedTextColor;
19+
import nl.dedouwe.Plugin;
820
import nl.dedouwe.items.Scroll;
21+
import nl.dedouwe.items.SesenItem;
922
import nl.dedouwe.items.Sources;
23+
import nl.dedouwe.utils.ParticleUtil;
24+
import nl.dedouwe.utils.Shape;
1025

11-
public class ShieldScroll extends Scroll {
26+
public class ShieldScroll extends Scroll implements Listener {
1227

1328
public ShieldScroll() {
1429
super(Sources.Water, "Shield", Component.text("You need a cover?").color(NamedTextColor.GRAY),
1530
Component.text("Gotchu.").color(NamedTextColor.GRAY));
31+
Plugin.instance.getServer().getPluginManager().registerEvents(this, Plugin.instance);
1632
}
1733

1834
@Override
1935
public TextComponent GetHelp() {
2036
return Component.text("Shift right-click for a longer shield, and right-click for a slower one.").color(NamedTextColor.GRAY);
2137
}
38+
private double Lerp(double a, double b, double i) {
39+
return i * (b - a);
40+
}
41+
private Vector GetVelocity (Vector from, Vector to) {
42+
Vector out = new Vector(Lerp(from.getX(), to.getX(), 0.5), Lerp(from.getY(), to.getY(), 0.5), Lerp(from.getZ(), to.getZ(), 0.5));
43+
return out;
44+
}
45+
public UUID CurrentProtected = null;
2246

23-
public void onDeactivate(PlayerInteractEvent e) {}
24-
public void onUse(PlayerInteractEvent e) {}
47+
public void onDeactivate(PlayerInteractEvent e) {
48+
if (!Test(e.getPlayer(), 4, 0.05, 100)) {return;}
49+
CurrentProtected=e.getPlayer().getUniqueId();
50+
int id = Bukkit.getScheduler().scheduleSyncRepeatingTask(Plugin.instance, ()->{
51+
Shape.CreateSphere(4, 15).Make((v)->{
52+
ParticleUtil.createColoredParticle(e.getPlayer().getLocation().clone().add(v), Color.fromRGB(104, 126, 255), 1.6f);
53+
});
54+
for (LivingEntity entity : e.getPlayer().getLocation().getNearbyLivingEntities(4,4,4)) {
55+
if (entity instanceof Player) {
56+
if (((Player)entity).getUniqueId().equals(CurrentProtected)) {
57+
continue;
58+
}
59+
}
60+
entity.setVelocity(GetVelocity(e.getPlayer().getLocation().toVector(), entity.getLocation().toVector()));
61+
}
62+
e.getPlayer().getWorld().playSound(e.getPlayer().getLocation(), Sound.ENTITY_ARROW_SHOOT, 1, 1);
63+
}, 0l, 5);
64+
Bukkit.getScheduler().scheduleSyncDelayedTask(Plugin.instance, () -> {
65+
Bukkit.getScheduler().cancelTask(id);
66+
CurrentProtected=null;
67+
}, 100);
68+
}
69+
public void onUse(PlayerInteractEvent e) {
70+
if (!Test(e.getPlayer(), 2, 0.05, 70)) {return;}
71+
CurrentProtected=e.getPlayer().getUniqueId();
72+
int id = Bukkit.getScheduler().scheduleSyncRepeatingTask(Plugin.instance, ()->{
73+
Shape.CreateSphere(2.2, 15).Make((v)->{
74+
ParticleUtil.createColoredParticle(e.getPlayer().getLocation().clone().add(v), Color.fromRGB(104, 126, 255), 1.6f);
75+
});
76+
for (LivingEntity entity : e.getPlayer().getLocation().getNearbyLivingEntities(2.2,2.2,2.2)) {
77+
if (entity instanceof Player) {
78+
if (((Player)entity).getUniqueId().equals(CurrentProtected)) {
79+
continue;
80+
}
81+
}
82+
entity.setVelocity(GetVelocity(e.getPlayer().getLocation().toVector(), entity.getLocation().toVector()));
83+
}
84+
e.getPlayer().getWorld().playSound(e.getPlayer().getLocation(), Sound.ENTITY_ARROW_SHOOT, 1, 1.8f);
85+
}, 0, 5);
86+
Bukkit.getScheduler().scheduleSyncDelayedTask(Plugin.instance, () -> {
87+
Bukkit.getScheduler().cancelTask(id);
88+
CurrentProtected=null;
89+
}, 70);
90+
}
91+
public void onDamage(EntityDamageEvent e) {
92+
if (!(e.getEntity() instanceof Player)) {return;}
93+
if (((Player)e.getEntity()).getUniqueId().equals(CurrentProtected)) {
94+
e.setCancelled(true);
95+
}
96+
}
97+
@EventHandler
98+
static void onDamageObserver(EntityDamageEvent e) {
99+
if (!(e.getEntity() instanceof Player)) {return;}
100+
SesenItem target = CustomEvent(((Player)e.getEntity()).getInventory().getItemInMainHand());
101+
if (target==null) {return;}
102+
if (!(target instanceof ShieldScroll)) {return;}
103+
((ShieldScroll)target).onDamage(e);
104+
}
25105
}
Lines changed: 125 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,146 @@
11
package nl.dedouwe.items.scroll.water;
22

3+
import java.util.HashMap;
4+
import java.util.Map.Entry;
5+
6+
import org.bukkit.Bukkit;
7+
import org.bukkit.Location;
8+
import org.bukkit.Material;
9+
import org.bukkit.event.EventHandler;
10+
import org.bukkit.event.Listener;
11+
import org.bukkit.event.block.BlockFromToEvent;
312
import org.bukkit.event.player.PlayerDropItemEvent;
413
import org.bukkit.event.player.PlayerInteractEvent;
14+
import org.bukkit.util.Vector;
515

616
import net.kyori.adventure.text.Component;
717
import net.kyori.adventure.text.TextComponent;
818
import net.kyori.adventure.text.format.NamedTextColor;
19+
import nl.dedouwe.Plugin;
920
import nl.dedouwe.items.Scroll;
1021
import nl.dedouwe.items.Sources;
1122

12-
public class TsunamiScroll extends Scroll {
23+
public class TsunamiScroll extends Scroll implements Listener {
1324

1425
public TsunamiScroll() {
1526
super(Sources.Water, "Tsunami", Component.text("Everything gone, guaranteed...").color(NamedTextColor.GRAY),
16-
Component.text("(No insurance)").color(NamedTextColor.DARK_GRAY));
27+
Component.text("(No insurance)").color(NamedTextColor.DARK_GRAY));
28+
Plugin.instance.getServer().getPluginManager().registerEvents(this, Plugin.instance);
1729
}
1830

1931
@Override
2032
public TextComponent GetHelp() {
2133
return Component.text("Shift left-click for a tsunami, drop the item for a water splash.").color(NamedTextColor.GRAY);
2234
}
23-
24-
public void onActivate(PlayerInteractEvent e) {}
25-
public void onDrop(PlayerDropItemEvent e) {}
35+
public Location NoWaterFlowPlace=null;
36+
private HashMap<Location, Material> previousBlocks = new HashMap<>();
37+
private void SetFlooded(Location l) {
38+
previousBlocks.put(l, l.getBlock().getType());
39+
Plugin.instance.getLogger().info("add");
40+
l.getBlock().setType(Material.WATER);
41+
}
42+
private int tsunamiCount = 0;
43+
private void AddTsunami(Location l) {
44+
if (tsunamiCount>=200) {return;}
45+
Plugin.instance.getLogger().info(l.getBlock().getType().toString());
46+
if(l.getBlock().getType()==Material.WATER) {return;}
47+
SetFlooded(l);
48+
tsunamiCount++;
49+
Bukkit.getScheduler().scheduleSyncDelayedTask(Plugin.instance, ()->{
50+
AddTsunami(l.clone().add(1, 0, 0));
51+
});
52+
Bukkit.getScheduler().scheduleSyncDelayedTask(Plugin.instance, ()->{
53+
AddTsunami(l.clone().add(-1, 0, 0));
54+
});
55+
Bukkit.getScheduler().scheduleSyncDelayedTask(Plugin.instance, ()->{
56+
AddTsunami(l.clone().add(0, 0, 1));
57+
});
58+
Bukkit.getScheduler().scheduleSyncDelayedTask(Plugin.instance, ()->{
59+
AddTsunami(l.clone().add(0, 0, -1));
60+
});
61+
}
62+
public void onActivate(PlayerInteractEvent e) {
63+
if (!Test(e.getPlayer(), 8, 0.05, 200)) {return;}
64+
65+
AddTsunami(e.getPlayer().getLocation().clone().add(0, 5, 0));
66+
Bukkit.getScheduler().scheduleSyncDelayedTask(Plugin.instance, ()->{
67+
Plugin.instance.getLogger().info((String.valueOf(previousBlocks.size())));
68+
for (Entry<Location, Material> pos : previousBlocks.entrySet()) {
69+
pos.getKey().getBlock().setType(pos.getValue());
70+
}
71+
previousBlocks.clear();
72+
tsunamiCount=0;
73+
}, 100);
74+
}
75+
public void onDrop(PlayerDropItemEvent e) {
76+
if (!Test(e.getPlayer(), 5, 0.08, 80)) {return;}
77+
e.setCancelled(true);
78+
Vector direction = e.getPlayer().getLocation().getDirection().clone().multiply(.7);
79+
Location position = e.getPlayer().getEyeLocation().clone();
80+
for (int i = 0; i < 26; i++) {
81+
position.add(direction);
82+
if (position.getBlock().getType()!=Material.AIR) {break;}
83+
}
84+
85+
NoWaterFlowPlace = position;
86+
Bukkit.getScheduler().scheduleSyncDelayedTask(Plugin.instance, ()->{
87+
position.add(0, 1, 0);
88+
SetFlooded(position);
89+
}, 5);
90+
Bukkit.getScheduler().scheduleSyncDelayedTask(Plugin.instance, ()->{
91+
SetFlooded(position.clone().add(0, 1, 0));
92+
}, 10);
93+
Bukkit.getScheduler().scheduleSyncDelayedTask(Plugin.instance, ()->{
94+
SetFlooded(position.clone().add(0, 2, 0));
95+
}, 15);
96+
Bukkit.getScheduler().scheduleSyncDelayedTask(Plugin.instance, ()->{
97+
SetFlooded(position.clone().add(0, 3, 0));
98+
SetFlooded(position.clone().add(1, 3, 0));
99+
SetFlooded(position.clone().add(-1, 3, 0));
100+
SetFlooded(position.clone().add(0, 3, 1));
101+
SetFlooded(position.clone().add(0, 3, -1));
102+
}, 20);
103+
Bukkit.getScheduler().scheduleSyncDelayedTask(Plugin.instance, ()->{
104+
SetFlooded(position.clone().add(0, 4, 0));
105+
SetFlooded(position.clone().add(1, 4, 0));
106+
SetFlooded(position.clone().add(-1, 4, 0));
107+
SetFlooded(position.clone().add(0, 4, 1));
108+
SetFlooded(position.clone().add(0, 4, -1));
109+
110+
SetFlooded(position.clone().add(2, 4, 0));
111+
SetFlooded(position.clone().add(-2, 4, 0));
112+
SetFlooded(position.clone().add(0, 4, 2));
113+
SetFlooded(position.clone().add(0, 4, -2));
114+
115+
SetFlooded(position.clone().add(-1, 4, -1));
116+
SetFlooded(position.clone().add(1, 4, -1));
117+
SetFlooded(position.clone().add(-1, 4, 1));
118+
SetFlooded(position.clone().add(1, 4, 1));
119+
SetFlooded(position.clone().add(-2, 4, -1));
120+
}, 25);
121+
Bukkit.getScheduler().scheduleSyncDelayedTask(Plugin.instance, ()->{
122+
SetFlooded(position.clone().add(0, 5, 0));
123+
}, 30);
124+
int Cooldown = 30;
125+
for (Entry<Location, Material> pos : previousBlocks.entrySet()) {
126+
Plugin.instance.getLogger().info("a");
127+
Bukkit.getScheduler().scheduleSyncDelayedTask(Plugin.instance, ()->{
128+
pos.getKey().getBlock().setType(pos.getValue());
129+
}, Cooldown);
130+
Cooldown+=2;
131+
}
132+
Bukkit.getScheduler().scheduleSyncDelayedTask(Plugin.instance, ()->{
133+
previousBlocks.clear();
134+
NoWaterFlowPlace=null;
135+
}, 75);
136+
}
137+
@EventHandler
138+
void onWaterFlow(BlockFromToEvent e) {
139+
if (e.getBlock().getType()!=Material.WATER) {return;}
140+
if (NoWaterFlowPlace==null) {return;}
141+
double dist = Math.sqrt(Math.pow(e.getBlock().getLocation().getX()-NoWaterFlowPlace.getX(), 2)+Math.pow(e.getBlock().getLocation().getY()-NoWaterFlowPlace.getY(), 2)+Math.pow(e.getBlock().getLocation().getZ()-NoWaterFlowPlace.getZ(), 2));
142+
if (dist <= 10) {
143+
e.setCancelled(true);
144+
}
145+
}
26146
}

src/main/java/nl/dedouwe/utils/ParticleUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ public static void createColoredParticle (Location l, Color c, float size) {
2020
.spawn();
2121
}
2222
public static void createBlockParticle (Location l, Block b) {
23-
new ParticleBuilder(Particle.BLOCK_DUST)
23+
new ParticleBuilder(Particle.BLOCK_CRACK)
2424
.location(l)
2525
.data(b.getBlockData())
2626
.force(true)
2727
.spawn();
2828
}
2929
public static void createBlockParticle (Location l, Material b) {
30-
new ParticleBuilder(Particle.BLOCK_DUST)
30+
new ParticleBuilder(Particle.BLOCK_CRACK)
3131
.location(l)
3232
.data(b.createBlockData())
3333
.force(true)

src/main/resources/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: "Sesens"
22
main: "nl.dedouwe.Plugin"
3-
version: "1.0-SNAPSHOT"
3+
version: "1.0.1"
44
api-version: '1.20'
55
description: "This is a plugin that adds the power to cast powerful spells called 'Sesens' scattered around the world."
66
author: "dedouwe"

0 commit comments

Comments
 (0)