mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
More Refactoring
This commit is contained in:
parent
a1193781cb
commit
8b55a4cd26
@ -41,7 +41,7 @@ public class RitualAnimation implements Runnable {
|
||||
this.output = output;
|
||||
this.pedestals = pedestals;
|
||||
this.items = items;
|
||||
this.particles = new ArrayList<Location>();
|
||||
this.particles = new ArrayList<>();
|
||||
|
||||
this.running = true;
|
||||
this.stage = 0;
|
||||
@ -54,26 +54,31 @@ public class RitualAnimation implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
idle();
|
||||
|
||||
if(!checkLockedItems()) {
|
||||
abort();
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.stage == 36) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.stage > 0 && this.stage % 4 == 0) {
|
||||
checkPedestal(pedestals.get(this.stage / 4 - 1));
|
||||
}
|
||||
|
||||
this.stage += 1;
|
||||
SlimefunStartup.instance.getServer().getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, this, 8);
|
||||
}
|
||||
|
||||
private boolean checkLockedItems() {
|
||||
|
||||
for(Item itm:this.itemLock.keySet())
|
||||
if(itm.getLocation().distance(this.itemLock.get(itm)) > 0.3)
|
||||
for (Item item : this.itemLock.keySet()) {
|
||||
if (item.getLocation().distance(this.itemLock.get(item)) > 0.3) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -82,6 +87,7 @@ public class RitualAnimation implements Runnable {
|
||||
try {
|
||||
l.getWorld().spawnParticle(Particle.SPELL_WITCH, l,16, 1.2F, 0F, 1.2F);
|
||||
l.getWorld().spawnParticle(Particle.FIREWORKS_SPARK,l,8, 0.2F, 0F, 0.2F);
|
||||
|
||||
for (Location l2: particles) {
|
||||
l.getWorld().spawnParticle(Particle.ENCHANTMENT_TABLE, l2,16, 0.3F, 0.2F, 0.3F);
|
||||
l.getWorld().spawnParticle(Particle.CRIT_MAGIC,l2,8, 0.3F, 0.2F, 0.3F);
|
||||
@ -94,11 +100,9 @@ public class RitualAnimation implements Runnable {
|
||||
private void checkPedestal(Block pedestal) {
|
||||
Item item = AncientAltarListener.findItem(pedestal);
|
||||
|
||||
|
||||
if(item == null || itemLock.remove(item) == null) {
|
||||
abort();
|
||||
}
|
||||
|
||||
else {
|
||||
particles.add(pedestal.getLocation().add(0.5, 1.5, 0.5));
|
||||
items.add(AncientAltarListener.fixItemStack(item.getItemStack(), item.getCustomName()));
|
||||
@ -121,7 +125,7 @@ public class RitualAnimation implements Runnable {
|
||||
private void abort() {
|
||||
running = false;
|
||||
|
||||
pedestals.forEach((pblock)->{
|
||||
pedestals.forEach((pblock)-> {
|
||||
Variables.altarinuse.remove(pblock.getLocation());
|
||||
});
|
||||
|
||||
|
@ -2,7 +2,8 @@ package me.mrCookieSlime.Slimefun.Objects;
|
||||
|
||||
public class Charge {
|
||||
|
||||
double charge, capacity;
|
||||
private double charge;
|
||||
private double capacity;
|
||||
|
||||
public Charge(double charge, double capacity) {
|
||||
this.charge = charge;
|
||||
|
@ -11,7 +11,7 @@ import org.bukkit.Material;
|
||||
|
||||
public class MultiBlock {
|
||||
|
||||
public static List<MultiBlock> list = new ArrayList<MultiBlock>();
|
||||
public static List<MultiBlock> list = new ArrayList<>();
|
||||
|
||||
Material[] blocks;
|
||||
Material trigger;
|
||||
|
@ -8,6 +8,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -424,7 +425,7 @@ public class SlimefunGuide {
|
||||
);
|
||||
|
||||
List<Category> categories = Slimefun.current_categories;
|
||||
List<GuideHandler> handlers = Slimefun.guide_handlers2;
|
||||
List<GuideHandler> handlers = Slimefun.guide_handlers.values().stream().flatMap(list -> list.stream()).collect(Collectors.toList());
|
||||
|
||||
int index = 9;
|
||||
int pages = 1;
|
||||
|
@ -51,14 +51,28 @@ public class PlayerProfile {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns whether the Player has logged off.
|
||||
* If this is true, then the Profile can be removed from RAM.
|
||||
*
|
||||
* @return Whether the Profile is marked for deletion
|
||||
*/
|
||||
public boolean isMarkedForDeletion() {
|
||||
return markedForDeletion;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns whether the Profile has unsaved changes
|
||||
*
|
||||
* @return Whether there are unsaved changes
|
||||
*/
|
||||
public boolean isDirty() {
|
||||
return dirty;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will save the Player's Researches and Backpacks to the hard drive
|
||||
*/
|
||||
public void save() {
|
||||
for (BackpackInventory backpack: backpacks.values()) {
|
||||
backpack.save();
|
||||
@ -68,6 +82,13 @@ public class PlayerProfile {
|
||||
dirty = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets the Player's "researched" status for this Research.
|
||||
* Use the boolean to unlock or lock the Research
|
||||
*
|
||||
* @param research The Research that should be unlocked or locked
|
||||
* @param unlock Whether the Research should be unlocked or locked
|
||||
*/
|
||||
public void setResearched(Research research, boolean unlock) {
|
||||
dirty = true;
|
||||
|
||||
@ -81,6 +102,12 @@ public class PlayerProfile {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns whether the Player has unlocked the given Research
|
||||
*
|
||||
* @param research The Research that is being queried
|
||||
* @return Whether this Research has been unlocked
|
||||
*/
|
||||
public boolean hasUnlocked(Research research) {
|
||||
return !research.isEnabled() || researches.contains(research);
|
||||
}
|
||||
|
@ -27,16 +27,17 @@ import me.mrCookieSlime.Slimefun.Setup.Messages;
|
||||
public class Slimefun {
|
||||
|
||||
public static Map<Integer, List<GuideHandler>> guide_handlers = new HashMap<>();
|
||||
public static List<GuideHandler> guide_handlers2 = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Instance of the GPSNetwork.
|
||||
*/
|
||||
private static GPSNetwork gps = new GPSNetwork();
|
||||
|
||||
/**
|
||||
* Whether EmeraldEnchants is enabled or not.
|
||||
*/
|
||||
public static boolean emeraldenchants = false;
|
||||
|
||||
/**
|
||||
* Lists all the registered categories.
|
||||
*/
|
||||
@ -47,7 +48,6 @@ public class Slimefun {
|
||||
if (guide_handlers.containsKey(handler.getTier())) handlers = guide_handlers.get(handler.getTier());
|
||||
handlers.add(handler);
|
||||
guide_handlers.put(handler.getTier(), handlers);
|
||||
guide_handlers2.add(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user