Skip to content

Commit

Permalink
Merge pull request #796 from VolmitSoftware/Development
Browse files Browse the repository at this point in the history
**Changelog**

- Fixed a Memory Leak (There might be more, keep reports coming)
 - Fixed Iris wand selections (WE)
 - Added Iris Wand Worldedit compatibility [Make selection using Worldedit, then /Iris object want worldedit (/ir o w we) to then set your selection to a new iris wand]
  • Loading branch information
NextdoorPsycho authored May 27, 2022
2 parents fff650b + 9cd5c39 commit e3d4c32
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 26 deletions.
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins {
id "de.undercouch.download" version "5.0.1"
}

version '2.1.1-1.18.2' // Needs to be version specific
version '2.1.2-1.18.2' // Needs to be version specific
def nmsVersion = "1.18.2"
def apiVersion = '1.18'
def spigotJarVersion = '1.18.2-R0.1-SNAPSHOT'
Expand Down Expand Up @@ -74,6 +74,7 @@ repositories {
}
}
maven { url "https://dl.cloudsmith.io/public/arcane/archive/maven/" }
maven { url "https://maven.enginehub.org/repo/" }
mavenCentral()
mavenLocal()
maven { url "https://jitpack.io"}
Expand Down Expand Up @@ -128,6 +129,7 @@ dependencies {
implementation 'io.th0rgal:oraxen:1.94.0'
implementation 'org.bukkit:craftbukkit:1.18.2-R0.1-SNAPSHOT:remapped-mojang'
implementation 'com.github.LoneDev6:api-itemsadder:3.1.0b'
implementation 'com.sk89q.worldedit:worldedit-bukkit:7.2.9'

// Shaded
implementation 'com.dfsek:Paralithic:0.4.0'
Expand Down
27 changes: 21 additions & 6 deletions src/main/java/com/volmit/iris/core/commands/CommandObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

package com.volmit.iris.core.commands;

import com.mojang.datafixers.util.Pair;
import com.volmit.iris.Iris;
import com.volmit.iris.core.link.WorldEditLink;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.service.ObjectSVC;
import com.volmit.iris.core.service.StudioSVC;
Expand All @@ -41,12 +43,7 @@
import com.volmit.iris.util.math.Direction;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.scheduling.Queue;
import org.bukkit.ChatColor;
import org.bukkit.HeightMap;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.TileState;
Expand Down Expand Up @@ -426,6 +423,24 @@ public void undo(
sender().sendMessage("Reverted " + actualReverts + " pastes!");
}

@Decree(description = "Gets an object wand and grabs the current WorldEdit selection.", aliases = "we", origin = DecreeOrigin.PLAYER, studio = true)
public void we() {
if(!Bukkit.getPluginManager().isPluginEnabled("WorldEdit")) {
sender().sendMessage(C.RED + "You can't get a WorldEdit selection without WorldEdit, you know.");
return;
}

Pair<Location, Location> locs = WorldEditLink.getSelection(sender().player());
if(locs.getFirst() == null)
sender().sendMessage(C.RED + "You don't have a WorldEdit selection!");
else if(locs.getSecond() == null)
sender().sendMessage(C.RED + "You need a valid WorldRegion selection in the current world!");
else {
sender().player().getInventory().addItem(WandSVC.createWand(locs.getFirst(), locs.getSecond()));
sender().sendMessage(C.GREEN + "A fresh wand with your current WorldEdit selection on it!");
}
}

@Decree(description = "Get an object wand", sync = true)
public void wand() {
player().getInventory().addItem(WandSVC.createWand());
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/com/volmit/iris/core/link/WorldEditLink.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.volmit.iris.core.link;

import com.mojang.datafixers.util.Pair;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.MissingSessionException;
import org.bukkit.Location;
import org.bukkit.entity.Player;

public class WorldEditLink {

public static Pair<Location, Location> getSelection(Player p) {
LocalSession session = WorldEdit.getInstance().getSessionManager().getIfPresent(BukkitAdapter.adapt(p));
try {
if(session == null)
throw new MissingSessionException();
Region r = session.getSelection(BukkitAdapter.adapt(p.getWorld()));
BlockVector3 p1 = r.getMinimumPoint();
BlockVector3 p2 = r.getMaximumPoint();
return new Pair<>(new Location(p.getWorld(), p1.getX(), p1.getY(), p1.getZ()), new Location(p.getWorld(), p2.getX(), p2.getY(), p2.getZ()));
} catch(MissingSessionException e) {
return new Pair<>(null, new Location(null, 0, 0, 0));
} catch(IncompleteRegionException e) {
return new Pair<>(new Location(null, 0, 0, 0), null);
}

}
}
9 changes: 3 additions & 6 deletions src/main/java/com/volmit/iris/core/tools/IrisToolbelt.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,20 +233,17 @@ public static boolean isStudio(World i) {
return isIrisWorld(i) && access(i).isStudio();
}

public static void retainMantleDataForSlice(String className)
{
public static void retainMantleDataForSlice(String className) {
toolbeltConfiguration.put("retain.mantle." + className, true);
}

public static <T> T getMantleData(World world, int x, int y, int z, Class<T> of)
{
public static <T> T getMantleData(World world, int x, int y, int z, Class<T> of) {
PlatformChunkGenerator e = access(world);
if(e == null) {return null;}
return e.getEngine().getMantle().getMantle().get(x, y - world.getMinHeight(), z, of);
}

public static <T> void deleteMantleData(World world, int x, int y, int z, Class<T> of)
{
public static <T> void deleteMantleData(World world, int x, int y, int z, Class<T> of) {
PlatformChunkGenerator e = access(world);
if(e == null) {return;}
e.getEngine().getMantle().getMantle().remove(x, y - world.getMinHeight(), z, of);
Expand Down
12 changes: 0 additions & 12 deletions src/main/java/com/volmit/iris/engine/IrisWorldManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
public class IrisWorldManager extends EngineAssignedWorldManager {
private final Looper looper;
private final int id;
private final KMap<Long, Long> chunkCooldowns;
private final KList<Runnable> updateQueue = new KList<>();
private final ChronoLatch cl;
private final ChronoLatch clw;
Expand All @@ -99,7 +98,6 @@ public IrisWorldManager() {
ecl = null;
cln = null;
clw = null;
chunkCooldowns = null;
looper = null;
chunkUpdater = null;
id = -1;
Expand All @@ -112,7 +110,6 @@ public IrisWorldManager(Engine engine) {
cl = new ChronoLatch(3000);
ecl = new ChronoLatch(250);
clw = new ChronoLatch(1000, true);
chunkCooldowns = new KMap<>();
id = engine.getCacheID();
energy = 25;
looper = new Looper() {
Expand Down Expand Up @@ -255,14 +252,6 @@ private boolean onAsyncTick() {
}
}

int chunkCooldownSeconds = 60;

for(Long i : chunkCooldowns.k()) {
if(M.ms() - chunkCooldowns.get(i) > TimeUnit.SECONDS.toMillis(chunkCooldownSeconds)) {
chunkCooldowns.remove(i);
}
}

int spawnBuffer = RNG.r.i(2, 12);

Chunk[] cc = getEngine().getWorld().realWorld().getLoadedChunks();
Expand All @@ -279,7 +268,6 @@ private boolean onAsyncTick() {
}

spawnIn(c, false);
chunkCooldowns.put(Cache.key(c), M.ms());
}

energy -= (actuallySpawned / 2D);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ commands:
aliases: [ ir, irs ]
api-version: ${apiversion}
hotload-dependencies: false
softdepend: [ "Oraxen", "ItemsAdder", "IrisFeller"]
softdepend: [ "Oraxen", "ItemsAdder", "IrisFeller", "WorldEdit"]

0 comments on commit e3d4c32

Please sign in to comment.