Skip to content

Commit

Permalink
[CORE] Ground Work for PlayerEditor and PlayerEditorManager. Make sur…
Browse files Browse the repository at this point in the history
…e that MetricsHandler uses the ASE Instance.

Signed-off-by: Wolfieheart <[email protected]>
  • Loading branch information
Wolfieheart committed Jan 4, 2025
1 parent 3c6fa6e commit c2b2855
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public final class ArmorStandEditorPlugin extends JavaPlugin {
private static ArmorStandEditorPlugin instance;
private Debug debug = new Debug(this);
MetricsHandler metricsHandler;
protected PlayerEditorManager editorManager;

// Server Software Check True/False
boolean isFolia;
Expand Down Expand Up @@ -145,7 +146,8 @@ public void onEnable() {
getLogger().log(Level.INFO, SEPARATOR_FIELD);

// Do all the Metrics for BStats
metricsHandler = new MetricsHandler();
metricsHandler = new MetricsHandler(this);
editorManager = new PlayerEditorManager(this);

}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package io.github.rypofalem.armorstandeditor;

import io.github.rypofalem.armorstandeditor.devtools.Debug;
import io.github.rypofalem.armorstandeditor.modes.AdjustmentMode;
import io.github.rypofalem.armorstandeditor.modes.Axis;
import io.github.rypofalem.armorstandeditor.modes.CopySlots;
import io.github.rypofalem.armorstandeditor.modes.EditMode;
import lombok.Getter;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;

import java.util.ArrayList;
import java.util.UUID;

public class PlayerEditor {
public ArmorStandEditorPlugin plugin;
private Debug debug;
private UUID uuid;
private long lastOpened = Integer.MIN_VALUE;

@Getter EditMode eMode;
@Getter AdjustmentMode adjMode;
CopySlots copySlots;
@Getter Axis axis;
double eulerAngleChange;
double degreeAngleChange;
double movChange;
//TODO: Add Menu Here once that is reimplemented
ArmorStand targeted;
ArrayList<ArmorStand> targetList = null;
int targetIndex = 0;
long lastCancelled = 0;

public PlayerEditor(UUID uuid, ArmorStandEditorPlugin plugin){
this.uuid = uuid;
this.plugin = plugin;
eMode = EditMode.NONE;
adjMode = AdjustmentMode.COARSE;
axis = Axis.X;
copySlots = new CopySlots();
eulerAngleChange = getManager().coarseAdj;
degreeAngleChange = eulerAngleChange / Math.PI * 180;
movChange = getManager().coarseMov;
}

public PlayerEditorManager getManager() {
return plugin.editorManager;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package io.github.rypofalem.armorstandeditor;

import org.bukkit.Bukkit;
import org.bukkit.event.Listener;
import io.github.rypofalem.armorstandeditor.util.Util;

import java.util.HashMap;
import java.util.UUID;

public class PlayerEditorManager implements Listener {
private ArmorStandEditorPlugin plugin;
private HashMap<UUID, PlayerEditor> players;
double coarseAdj;
double fineAdj;
double coarseMov;
double fineMov;
private boolean ignoreNextInteract = false;
private TickCounter counter;

PlayerEditorManager(final ArmorStandEditorPlugin plugin) {
this.plugin = plugin;
players = new HashMap<>();
coarseAdj = Util.FULL_CIRCLE / plugin.getCoarseConfig();
fineAdj = Util.FULL_CIRCLE / plugin.getFineConfig();
coarseMov = 1;
fineMov = .03125; // 1/32
counter = new TickCounter();
Bukkit.getServer().getScheduler().runTaskTimer(plugin, counter, 0, 1);
}

class TickCounter implements Runnable {
long ticks = 0; //I am optimistic

@Override
public void run() {
ticks++;
}

public long getTime() {
return ticks;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public class MetricsHandler {
private static final int PLUGIN_ID = 12668;
public ArmorStandEditorPlugin plugin;

public MetricsHandler(){
public MetricsHandler(ArmorStandEditorPlugin plugin){
this.plugin = plugin;
Metrics metrics = new Metrics(plugin, PLUGIN_ID);
metrics.addCustomChart(new Metrics.SimplePie("dev_flag_enabled", () -> valueOf(plugin.isDebug())));
metrics.addCustomChart(new Metrics.SimplePie("require_sneaking", () -> valueOf(plugin.getRequireSneakingConfig())));
Expand Down

0 comments on commit c2b2855

Please sign in to comment.