Skip to content

Commit 4aee174

Browse files
committed
Version message changes; fixed some errors
1 parent 0d8a821 commit 4aee174

83 files changed

Lines changed: 108 additions & 6645 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ allprojects {
44
apply plugin: 'idea'
55

66
group = 'be.isach'
7-
version = '2.6-RELEASE'
7+
version = '2.6-DEV-b1'
88

99
compileJava.options.encoding = 'UTF-8'
1010

core/src/main/java/be/isach/ultracosmetics/UltraCosmetics.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ public void onLoad() {
153153
*/
154154
@Override
155155
public void onEnable() {
156+
// if loading failed...
157+
if (UltraCosmeticsData.get().getServerVersion() == null) {
158+
getSmartLogger().write(LogLevel.ERROR, "Plugin load has failed, please check earlier in the log for details.");
159+
Bukkit.getPluginManager().disablePlugin(this);
160+
return;
161+
}
156162
// Create UltraPlayer Manager.
157163
this.playerManager = new UltraPlayerManager(this);
158164

@@ -279,27 +285,22 @@ public void run() {
279285
*/
280286
@Override
281287
public void onDisable() {
288+
// when the plugin is disabled from onEnable, skip cleanup
289+
if (UltraCosmeticsData.get().getServerVersion() == null) {
290+
return;
291+
}
282292
// TODO Purge Pet Names. (and Treasure Chests bugged holograms).
283293
// TODO Use Metadatas for that!
284294

285-
try {
295+
if (cosmeticsProfileManager != null) {
286296
for (CosmeticsProfile cp : cosmeticsProfileManager.getCosmeticsProfiles().values()) {
287297
cp.save();
288298
}
299+
}
289300

290-
if (playerManager != null) {
291-
// make sure pets are properly removed on server shutdown
292-
for (UltraPlayer player : playerManager.getUltraPlayers()) {
293-
player.clear();
294-
}
301+
playerManager.dispose();
295302

296-
playerManager.dispose();
297-
}
298-
299-
UltraCosmeticsData.get().getVersionManager().getModule().disable();
300-
} catch (Exception exc) {
301-
// Can't do much if this happens.
302-
}
303+
UltraCosmeticsData.get().getVersionManager().getModule().disable();
303304
}
304305

305306
/**

core/src/main/java/be/isach/ultracosmetics/UltraCosmeticsData.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.lang.reflect.InvocationTargetException;
1111
import java.lang.reflect.Method;
1212
import java.util.List;
13+
import java.util.StringJoiner;
1314
import java.util.UUID;
1415

1516
/**
@@ -160,8 +161,17 @@ boolean checkServerVersion() {
160161
serverVersion = ServerVersion.valueOf(mcVersion);
161162
} catch (IllegalArgumentException exc) {
162163
ultraCosmetics.getSmartLogger().write("This NMS version isn't supported. (" + mcVersion + ")!");
163-
System.out.println("----------------------------\n\nULTRACOSMETICS CAN ONLY RUN ON " + ServerVersion.earliest().getName() + " or " + ServerVersion.v1_12_R1.getName() + " through " + ServerVersion.latest().getName() + "!\n\n----------------------------");
164-
Bukkit.getPluginManager().disablePlugin(ultraCosmetics);
164+
StringJoiner sj = new StringJoiner(", ");
165+
for (ServerVersion version : ServerVersion.values()) {
166+
if (version == ServerVersion.latest()) continue;
167+
sj.add(version.getName());
168+
}
169+
ultraCosmetics.getSmartLogger().write(LogLevel.ERROR, "----------------------------");
170+
ultraCosmetics.getSmartLogger().write(LogLevel.ERROR, "");
171+
ultraCosmetics.getSmartLogger().write(LogLevel.ERROR, "ULTRACOSMETICS CAN ONLY RUN ON " + sj.toString() + ", OR " + ServerVersion.latest().getName() + "!");
172+
ultraCosmetics.getSmartLogger().write(LogLevel.ERROR, "");
173+
ultraCosmetics.getSmartLogger().write(LogLevel.ERROR, "----------------------------");
174+
// plugin can't be disabled at load time since it hasn't been enabled yet?
165175
return false;
166176
}
167177

core/src/main/java/be/isach/ultracosmetics/cosmetics/gadgets/GadgetRocket.java

Lines changed: 72 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.bukkit.Location;
1313
import org.bukkit.Material;
1414
import org.bukkit.block.Block;
15+
import org.bukkit.block.BlockFace;
1516
import org.bukkit.entity.ArmorStand;
1617
import org.bukkit.entity.Entity;
1718
import org.bukkit.entity.FallingBlock;
@@ -20,7 +21,9 @@
2021
import org.bukkit.util.Vector;
2122

2223
import java.util.ArrayList;
24+
import java.util.HashSet;
2325
import java.util.List;
26+
import java.util.Set;
2427

2528
/**
2629
* Represents an instance of a rocket gadget summoned by a player.
@@ -30,11 +33,14 @@
3033
*/
3134
public class GadgetRocket extends Gadget {
3235

33-
public static final List<Block> BLOCKS = new ArrayList<>();
36+
private static final BlockFace[] CARDINAL = new BlockFace[] {BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST};
37+
private static final Material FENCE = BlockUtils.getOldMaterial("FENCE");
38+
public static final Set<GadgetRocket> ROCKETS_WITH_BLOCKS = new HashSet<>();
3439

35-
boolean launching;
36-
ArmorStand armorStand;
37-
List<FallingBlock> fallingBlocks = new ArrayList<>();
40+
private boolean launching;
41+
private ArmorStand armorStand;
42+
private List<Block> blocks = new ArrayList<>();
43+
private List<FallingBlock> fallingBlocks = new ArrayList<>();
3844

3945
public GadgetRocket(UltraPlayer owner, UltraCosmetics ultraCosmetics) {
4046
super(owner, GadgetType.valueOf("rocket"), ultraCosmetics);
@@ -48,45 +54,30 @@ void onRightClick() {
4854
loc.setY(loc.getBlockY());
4955
loc.setZ(loc.getBlockZ() + 0.5);
5056
Bukkit.getScheduler().runTaskLater(getUltraCosmetics(), () -> {
57+
ROCKETS_WITH_BLOCKS.add(this);
5158
for (int i = 0; i < 2; i++) {
52-
Block b1 = loc.clone().add(1, i, 0).getBlock();
53-
Block b2 = loc.clone().add(-1, i, 0).getBlock();
54-
Block b3 = loc.clone().add(0, i, 1).getBlock();
55-
Block b4 = loc.clone().add(0, i, -1).getBlock();
56-
Block b5 = loc.clone().add(0, i + 1, 0).getBlock();
57-
b1.setType(BlockUtils.getOldMaterial("FENCE"));
58-
b2.setType(BlockUtils.getOldMaterial("FENCE"));
59-
b3.setType(BlockUtils.getOldMaterial("FENCE"));
60-
b4.setType(BlockUtils.getOldMaterial("FENCE"));
61-
b5.setType(Material.QUARTZ_BLOCK);
62-
BLOCKS.add(b1);
63-
BLOCKS.add(b2);
64-
BLOCKS.add(b3);
65-
BLOCKS.add(b4);
66-
BLOCKS.add(b5);
59+
Block center = loc.clone().add(0, i, 0).getBlock();
60+
for (BlockFace face : CARDINAL) {
61+
Block side = center.getRelative(face);
62+
side.setType(FENCE);
63+
blocks.add(side);
64+
}
65+
Block quartz = center.getRelative(BlockFace.UP);
66+
quartz.setType(Material.QUARTZ_BLOCK);
67+
blocks.add(quartz);
6768
}
6869
armorStand = loc.getWorld().spawn(loc.add(0, 1.5, 0), ArmorStand.class);
6970
armorStand.setVisible(false);
7071
armorStand.setGravity(false);
7172
}, 10);
7273
Bukkit.getScheduler().runTaskLater(UltraCosmeticsData.get().getPlugin(), () -> {
7374
armorStand.setPassenger(getPlayer());
74-
BukkitRunnable runnable = new BukkitRunnable() {
75+
new BukkitRunnable() {
7576
int i = 5;
7677

7778
@Override
7879
public void run() {
79-
if (getOwner() == null) {
80-
cancel();
81-
return;
82-
}
83-
84-
if (getPlayer() == null) {
85-
cancel();
86-
return;
87-
}
88-
89-
if (!getPlayer().isOnline()) {
80+
if (getOwner() == null || getPlayer() == null || !getPlayer().isOnline()) {
9081
cancel();
9182
return;
9283
}
@@ -99,61 +90,57 @@ public void run() {
9990
getPlayer().sendTitle(ChatColor.RED + "" + ChatColor.BOLD + i, "");
10091
SoundUtil.playSound(getPlayer(), Sounds.NOTE_BASS_DRUM, 1.0f, 1.0f);
10192
i--;
102-
} else {
103-
if (!isStillCurrentGadget()) {
104-
cancel();
105-
return;
106-
}
93+
return;
94+
}
95+
if (!isStillCurrentGadget()) {
96+
cancel();
97+
return;
98+
}
10799

108-
getPlayer().sendTitle(MessageManager.getMessage("Gadgets.Rocket.Takeoff"), "");
109-
SoundUtil.playSound(getPlayer().getLocation(), Sounds.EXPLODE, 1.0f, 1.0f);
110-
armorStand.remove();
111-
armorStand = null;
100+
getPlayer().sendTitle(MessageManager.getMessage("Gadgets.Rocket.Takeoff"), "");
101+
SoundUtil.playSound(getPlayer().getLocation(), Sounds.EXPLODE, 1.0f, 1.0f);
102+
armorStand.remove();
103+
armorStand = null;
112104

113105

114-
for (Block block : BLOCKS) {
115-
block.setType(Material.AIR);
116-
}
106+
for (Block block : blocks) {
107+
block.setType(Material.AIR);
108+
}
117109

118-
BLOCKS.clear();
119-
120-
final FallingBlock top = getPlayer().getWorld().spawnFallingBlock(getPlayer().getLocation().add(0, 3, 0), Material.QUARTZ_BLOCK, (byte) 0);
121-
FallingBlock base = getPlayer().getWorld().spawnFallingBlock(getPlayer().getLocation().add(0, 2, 0), Material.QUARTZ_BLOCK, (byte) 0);
122-
for (int i = 0; i < 2; i++) {
123-
FallingBlock fence1 = getPlayer().getWorld().spawnFallingBlock(getPlayer().getLocation().add(0, 1 + i, 1), BlockUtils.getOldMaterial("FENCE"), (byte) 0);
124-
FallingBlock fence2 = getPlayer().getWorld().spawnFallingBlock(getPlayer().getLocation().add(0, 1 + i, -1), BlockUtils.getOldMaterial("FENCE"), (byte) 0);
125-
FallingBlock fence3 = getPlayer().getWorld().spawnFallingBlock(getPlayer().getLocation().add(1, 1 + i, 0), BlockUtils.getOldMaterial("FENCE"), (byte) 0);
126-
FallingBlock fence4 = getPlayer().getWorld().spawnFallingBlock(getPlayer().getLocation().add(-1, 1 + i, 0), BlockUtils.getOldMaterial("FENCE"), (byte) 0);
127-
fallingBlocks.add(fence1);
128-
fallingBlocks.add(fence2);
129-
fallingBlocks.add(fence3);
130-
fallingBlocks.add(fence4);
131-
}
110+
blocks.clear();
111+
ROCKETS_WITH_BLOCKS.remove(GadgetRocket.this);
132112

133-
fallingBlocks.add(top);
134-
fallingBlocks.add(base);
135-
if (fallingBlocks.get(8).getPassenger() == null) {
136-
fallingBlocks.get(8).setPassenger(getPlayer());
137-
}
138-
top.setPassenger(getPlayer());
139-
launching = true;
140-
Bukkit.getScheduler().runTaskLater(getUltraCosmetics(), () -> {
141-
if (!isStillCurrentGadget()) {
142-
cancel();
143-
return;
144-
}
145-
fallingBlocks.forEach(Entity::remove);
146-
fallingBlocks.clear();
147-
FallDamageManager.addNoFall(getPlayer());
148-
SoundUtil.playSound(getPlayer().getLocation(), Sounds.EXPLODE, 1.0f, 1.0f);
149-
UtilParticles.display(Particles.EXPLOSION_HUGE, getPlayer().getLocation());
150-
launching = false;
151-
}, 80);
152-
cancel();
113+
final FallingBlock top = getPlayer().getWorld().spawnFallingBlock(getPlayer().getLocation().add(0, 3, 0), Material.QUARTZ_BLOCK, (byte) 0);
114+
FallingBlock base = getPlayer().getWorld().spawnFallingBlock(getPlayer().getLocation().add(0, 2, 0), Material.QUARTZ_BLOCK, (byte) 0);
115+
for (int i = 0; i < 2; i++) {
116+
fallingBlocks.add(getPlayer().getWorld().spawnFallingBlock(getPlayer().getLocation().add(0, 1 + i, 1), FENCE, (byte) 0));
117+
fallingBlocks.add(getPlayer().getWorld().spawnFallingBlock(getPlayer().getLocation().add(0, 1 + i, -1), FENCE, (byte) 0));
118+
fallingBlocks.add(getPlayer().getWorld().spawnFallingBlock(getPlayer().getLocation().add(1, 1 + i, 0), FENCE, (byte) 0));
119+
fallingBlocks.add(getPlayer().getWorld().spawnFallingBlock(getPlayer().getLocation().add(-1, 1 + i, 0), FENCE, (byte) 0));
153120
}
121+
122+
fallingBlocks.add(top);
123+
fallingBlocks.add(base);
124+
if (fallingBlocks.get(8).getPassenger() == null) {
125+
fallingBlocks.get(8).setPassenger(getPlayer());
126+
}
127+
top.setPassenger(getPlayer());
128+
launching = true;
129+
Bukkit.getScheduler().runTaskLater(getUltraCosmetics(), () -> {
130+
if (!isStillCurrentGadget()) {
131+
cancel();
132+
return;
133+
}
134+
fallingBlocks.forEach(Entity::remove);
135+
fallingBlocks.clear();
136+
FallDamageManager.addNoFall(getPlayer());
137+
SoundUtil.playSound(getPlayer().getLocation(), Sounds.EXPLODE, 1.0f, 1.0f);
138+
UtilParticles.display(Particles.EXPLOSION_HUGE, getPlayer().getLocation());
139+
launching = false;
140+
}, 80);
141+
cancel();
154142
}
155-
};
156-
runnable.runTaskTimer(getUltraCosmetics(), 0, 20);
143+
}.runTaskTimer(getUltraCosmetics(), 0, 20);
157144
}, 12);
158145
}
159146

@@ -206,13 +193,13 @@ public void run() {
206193

207194
@Override
208195
public void onClear() {
209-
for (Block block : BLOCKS) {
196+
for (Block block : blocks) {
210197
block.setType(Material.AIR);
211198
}
212199
for (FallingBlock fallingBlock : fallingBlocks) {
213200
fallingBlock.remove();
214201
}
215-
BLOCKS.clear();
202+
blocks.clear();
216203
fallingBlocks.clear();
217204
if (armorStand != null) {
218205
armorStand.remove();
@@ -225,6 +212,9 @@ public void onClear() {
225212
}
226213

227214
@Override
228-
void onLeftClick() {
215+
void onLeftClick() {}
216+
217+
public List<Block> getBlocks() {
218+
return blocks;
229219
}
230220
}

core/src/main/java/be/isach/ultracosmetics/cosmetics/gadgets/GadgetSmashDown.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public void onBlockChangeState(EntityChangeBlockEvent event) {
157157
event.setCancelled(true);
158158
fallingBlocks.remove(event.getEntity());
159159
FallingBlock fb = (FallingBlock) event.getEntity();
160-
if (UltraCosmeticsData.get().getServerVersion().isAtLeast(ServerVersion.v1_16_R1)) {
160+
if (UltraCosmeticsData.get().getServerVersion().isAtLeast(ServerVersion.v1_16_R3)) {
161161
BlockData data = fb.getBlockData();
162162
fb.getWorld().spawnParticle(Particle.BLOCK_CRACK, fb.getLocation(), 50, 0, 0, 0, 0.4d, data);
163163
} else {

core/src/main/java/be/isach/ultracosmetics/util/BlockUtils.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,12 @@ public static boolean isOnGround(Entity entity) {
122122
* @return {@code true} if the block is part of a rocket, otherwise {@code false}.
123123
*/
124124
public static boolean isRocketBlock(Block b) {
125-
return GadgetRocket.BLOCKS.contains(b);
125+
for (GadgetRocket rocket : GadgetRocket.ROCKETS_WITH_BLOCKS) {
126+
if (rocket.getBlocks().contains(b)) {
127+
return true;
128+
}
129+
}
130+
return false;
126131
}
127132

128133
/**

core/src/main/java/be/isach/ultracosmetics/util/ServerVersion.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ public enum ServerVersion {
1010
v1_13_R2("1.13.2", "7dd4b3ec31629620c41553e5c142e454"),
1111
v1_14_R1("1.14.4", "11ae498d9cf909730659b6357e7c2afa"),
1212
v1_15_R1("1.15.2", "5684afcc1835d966e1b6eb0ed3f72edb"),
13-
v1_16_R1("1.16.1", "25afc67716a170ea965092c1067ff439"),
14-
v1_16_R2("1.16.3", "09f04031f41cb54f1077c6ac348cc220"),
1513
v1_16_R3("1.16.5", "d4b392244df170796f8779ef0fc1f2e9"),
1614
v1_17_R1("1.17.1", "f0e3dfc7390de285a4693518dd5bd126"),
1715
v1_18_R1("1.18.1", "20b026e774dbf715e40a0b2afe114792"),

core/src/main/java/be/isach/ultracosmetics/version/SpawnEggs.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static ItemStack getEggFromData(byte b) {
5151
case (byte) 56:
5252
return new ItemStack(Material.GHAST_SPAWN_EGG);
5353
case (byte) 57:
54-
return new ItemStack(UltraCosmeticsData.get().getServerVersion().isAtLeast(ServerVersion.v1_16_R1) ? Material.ZOMBIFIED_PIGLIN_SPAWN_EGG : Material.valueOf("ZOMBIE_PIGMAN_SPAWN_EGG"));
54+
return new ItemStack(UltraCosmeticsData.get().getServerVersion().isAtLeast(ServerVersion.v1_16_R3) ? Material.ZOMBIFIED_PIGLIN_SPAWN_EGG : Material.valueOf("ZOMBIE_PIGMAN_SPAWN_EGG"));
5555
case (byte) 58:
5656
return new ItemStack(Material.ENDERMAN_SPAWN_EGG);
5757
case (byte) 59:

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
include 'v1_8_R3', 'v1_12_R1', 'v1_13_R2', 'v1_14_R1', 'v1_15_R1', 'v1_16_R1', 'v1_16_R2', 'v1_16_R3', 'v1_17_R1', 'v1_18_R1', 'core'
1+
include 'v1_8_R3', 'v1_12_R1', 'v1_13_R2', 'v1_14_R1', 'v1_15_R1', 'v1_16_R3', 'v1_17_R1', 'v1_18_R1', 'core'
22
rootProject.name = 'UltraCosmetics'

v1_16_R1/build.gradle

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)