mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-09 09:16:34 +00:00
Look ma, no Bukkit API in the core package
This commit is contained in:
36
common/src/main/java/com/dfsek/terra/debug/Debug.java
Normal file
36
common/src/main/java/com/dfsek/terra/debug/Debug.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.dfsek.terra.debug;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class Debug {
|
||||
private static Logger logger;
|
||||
private static boolean debug = false;
|
||||
|
||||
public static boolean isDebug() {
|
||||
return debug;
|
||||
}
|
||||
|
||||
public static void setDebug(boolean debug) {
|
||||
Debug.debug = debug;
|
||||
}
|
||||
|
||||
public static void setLogger(Logger logger) {
|
||||
Debug.logger = logger;
|
||||
}
|
||||
|
||||
public static void info(String message) {
|
||||
if(debug) logger.info(message);
|
||||
}
|
||||
|
||||
public static void warn(String message) {
|
||||
if(debug) logger.warning(message);
|
||||
}
|
||||
|
||||
public static void error(String message) {
|
||||
if(debug) logger.severe(message);
|
||||
}
|
||||
|
||||
public static void stack(Exception e) {
|
||||
if(debug) e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.dfsek.terra.debug.gui;
|
||||
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class DebugFrame extends JFrame implements ActionListener {
|
||||
private static final long serialVersionUID = 9133084939622854303L;
|
||||
private final int x;
|
||||
private final int z;
|
||||
private final BufferedImage img;
|
||||
private final TerraPlugin main;
|
||||
|
||||
public DebugFrame(BufferedImage image, String s, TerraPlugin main) {
|
||||
super(s);
|
||||
this.x = image.getWidth();
|
||||
this.z = image.getHeight();
|
||||
this.img = image;
|
||||
this.main = main;
|
||||
new Timer(500, this).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
super.paintComponents(g);
|
||||
/*
|
||||
for(Player p : Bukkit.getOnlinePlayers()) {
|
||||
int xp = (int) (((double) FastMath.floorMod(p.getLocation().getBlockX() - (img.getWidth() / 2), x) / x) * getWidth());
|
||||
int zp = (int) (((double) FastMath.floorMod(p.getLocation().getBlockZ() - (img.getHeight() / 2), z) / z) * getHeight());
|
||||
ImageLoader loader = main.getWorld(p.getWorld()).getConfig().getTemplate().getImageLoader();
|
||||
if(loader != null && loader.getAlign().equals(ImageLoader.Align.NONE)) {
|
||||
xp = (int) (((double) FastMath.floorMod(p.getLocation().getBlockX(), x) / x) * getWidth());
|
||||
zp = (int) (((double) FastMath.floorMod(p.getLocation().getBlockZ(), z) / z) * getHeight());
|
||||
}
|
||||
String str = ((UserDefinedBiome) main.getWorld(p.getWorld()).getGrid().getBiome(p.getLocation(), GenerationPhase.POPULATE)).getID();
|
||||
g.setColor(new Color(255, 255, 255, 128));
|
||||
g.fillRect(xp + 13, zp - 13, (int) (8 + 8.25 * str.length()), 33);
|
||||
g.setColor(Color.BLACK);
|
||||
g.drawString(p.getName(), xp + 15, zp);
|
||||
g.drawString(str, xp + 15, zp + 15);
|
||||
g.fillOval(xp, zp, 10, 10);
|
||||
g.setColor(Color.RED);
|
||||
g.fillOval(xp + 3, zp + 3, 5, 5);
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
this.repaint();
|
||||
}
|
||||
}
|
||||
34
common/src/main/java/com/dfsek/terra/debug/gui/DebugGUI.java
Normal file
34
common/src/main/java/com/dfsek/terra/debug/gui/DebugGUI.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package com.dfsek.terra.debug.gui;
|
||||
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class DebugGUI extends Thread {
|
||||
|
||||
private final BufferedImage img;
|
||||
private final TerraPlugin main;
|
||||
|
||||
public DebugGUI(BufferedImage img, TerraPlugin main) {
|
||||
this.img = img;
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
DebugFrame frame = new DebugFrame(img, "Image2Map Debug GUI", main);
|
||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
frame.setSize(1000, 1000);
|
||||
frame.setResizable(false);
|
||||
ImageIcon imageIcon = new ImageIcon(img.getScaledInstance(1000, 1000, Image.SCALE_SMOOTH));
|
||||
JLabel jLabel = new JLabel();
|
||||
jLabel.setIcon(imageIcon);
|
||||
frame.getContentPane().add(jLabel, BorderLayout.CENTER);
|
||||
frame.pack();
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user