mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-27 19:24:43 +02:00
Nothing is implemented, but it can compile and "run" on sponge now.
This commit is contained in:
@ -33,6 +33,7 @@ import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.InventoryUtil;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.PlayerManager;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
@ -42,7 +43,6 @@ import com.plotsquared.bukkit.database.plotme.LikePlotMeConverter;
|
||||
import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017;
|
||||
import com.plotsquared.bukkit.generator.BukkitGeneratorWrapper;
|
||||
import com.plotsquared.bukkit.generator.HybridGen;
|
||||
import com.plotsquared.bukkit.listeners.APlotListener;
|
||||
import com.plotsquared.bukkit.listeners.ChunkListener;
|
||||
import com.plotsquared.bukkit.listeners.ForceFieldListener;
|
||||
import com.plotsquared.bukkit.listeners.PlayerEvents;
|
||||
@ -57,7 +57,6 @@ import com.plotsquared.bukkit.listeners.worldedit.WESubscriber;
|
||||
import com.plotsquared.bukkit.titles.AbstractTitle;
|
||||
import com.plotsquared.bukkit.titles.DefaultTitle;
|
||||
import com.plotsquared.bukkit.util.BukkitHybridUtils;
|
||||
import com.plotsquared.bukkit.util.SetupUtils;
|
||||
import com.plotsquared.bukkit.util.bukkit.BukkitChunkManager;
|
||||
import com.plotsquared.bukkit.util.bukkit.BukkitEconHandler;
|
||||
import com.plotsquared.bukkit.util.bukkit.BukkitEventUtil;
|
||||
@ -78,6 +77,7 @@ import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler;
|
||||
import com.plotsquared.bukkit.uuid.DefaultUUIDWrapper;
|
||||
import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
|
||||
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
|
||||
import com.plotsquared.listener.APlotListener;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
|
||||
|
@ -5,6 +5,8 @@ import com.intellectualcrafters.plot.generator.PlotGenerator;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.SetupObject;
|
||||
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
public class BukkitGeneratorWrapper extends PlotGenerator<ChunkGenerator> {
|
||||
@ -13,7 +15,7 @@ public class BukkitGeneratorWrapper extends PlotGenerator<ChunkGenerator> {
|
||||
|
||||
public BukkitGeneratorWrapper(String world, ChunkGenerator generator) {
|
||||
super(world, generator);
|
||||
full = generator != null;
|
||||
full = (generator instanceof BukkitPlotGenerator);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -76,5 +78,12 @@ public class BukkitGeneratorWrapper extends PlotGenerator<ChunkGenerator> {
|
||||
}
|
||||
return generator.getClass().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processSetup(SetupObject object) {
|
||||
if (generator instanceof BukkitPlotGenerator) {
|
||||
((BukkitPlotGenerator) generator).processSetup(object);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,8 +31,9 @@ import com.intellectualcrafters.plot.util.*;
|
||||
import com.plotsquared.bukkit.events.PlayerEnterPlotEvent;
|
||||
import com.plotsquared.bukkit.events.PlayerLeavePlotEvent;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
import com.plotsquared.bukkit.object.comment.CommentManager;
|
||||
import com.plotsquared.bukkit.titles.AbstractTitle;
|
||||
import com.plotsquared.listener.APlotListener;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -205,7 +206,7 @@ public class PlotListener extends APlotListener {
|
||||
replacements.put("%s", getName(plot.owner));
|
||||
String main = StringMan.replaceFromMap(C.TITLE_ENTERED_PLOT.s(), replacements);
|
||||
String sub = StringMan.replaceFromMap(C.TITLE_ENTERED_PLOT_SUB.s(), replacements);
|
||||
AbstractTitle.sendTitle(pp, main, sub, ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()), ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s()));
|
||||
AbstractTitle.sendTitle(pp, main, sub);
|
||||
}
|
||||
}
|
||||
}, 20);
|
||||
|
@ -21,12 +21,12 @@ import java.util.UUID;
|
||||
public class BukkitPlayer implements PlotPlayer {
|
||||
|
||||
public final Player player;
|
||||
UUID uuid;
|
||||
String name;
|
||||
private UUID uuid;
|
||||
private String name;
|
||||
private int op = 0;
|
||||
private long last = 0;
|
||||
public HashSet<String> hasPerm = new HashSet<>();
|
||||
public HashSet<String> noPerm = new HashSet<>();
|
||||
private HashSet<String> hasPerm = new HashSet<>();
|
||||
private HashSet<String> noPerm = new HashSet<>();
|
||||
|
||||
private HashMap<String, Object> meta;
|
||||
|
||||
|
@ -1,79 +0,0 @@
|
||||
package com.plotsquared.bukkit.object.comment;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.comment.*;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.bukkit.titles.AbstractTitle;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
||||
public class CommentManager {
|
||||
public static HashMap<String, CommentInbox> inboxes = new HashMap<>();
|
||||
|
||||
public static void sendTitle(final PlotPlayer player, final Plot plot) {
|
||||
if (!Settings.COMMENT_NOTIFICATIONS) {
|
||||
return;
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID())) {
|
||||
return;
|
||||
}
|
||||
TaskManager.runTaskLaterAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Collection<CommentInbox> boxes = CommentManager.inboxes.values();
|
||||
final AtomicInteger count = new AtomicInteger(0);
|
||||
final AtomicInteger size = new AtomicInteger(boxes.size());
|
||||
for (final CommentInbox inbox : inboxes.values()) {
|
||||
inbox.getComments(plot, new RunnableVal() {
|
||||
@Override
|
||||
public void run() {
|
||||
int total;
|
||||
if (value != null) {
|
||||
int num = 0;
|
||||
for (PlotComment comment : (ArrayList<PlotComment>) value) {
|
||||
if (comment.timestamp > getTimestamp(player, inbox.toString())) {
|
||||
num++;
|
||||
}
|
||||
}
|
||||
total = count.addAndGet(num);
|
||||
}
|
||||
else {
|
||||
total = count.get();
|
||||
}
|
||||
if (size.decrementAndGet() == 0 && total > 0) {
|
||||
AbstractTitle.sendTitle(player, "", C.INBOX_NOTIFICATION.s().replaceAll("%s", "" + total), ChatColor.GOLD, ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}, 20);
|
||||
}
|
||||
|
||||
public static long getTimestamp(PlotPlayer player, String inbox) {
|
||||
Object meta = player.getMeta("inbox:"+inbox);
|
||||
if (meta == null) {
|
||||
return player.getPreviousLogin();
|
||||
}
|
||||
return (Long) meta;
|
||||
}
|
||||
|
||||
public static void addInbox(CommentInbox inbox) {
|
||||
inboxes.put(inbox.toString().toLowerCase(), inbox);
|
||||
}
|
||||
|
||||
public static void registerDefaultInboxes() {
|
||||
addInbox(new InboxReport());
|
||||
addInbox(new InboxPublic());
|
||||
addInbox(new InboxOwner());
|
||||
}
|
||||
}
|
@ -6,11 +6,11 @@ import org.bukkit.ChatColor;
|
||||
public abstract class AbstractTitle {
|
||||
public static AbstractTitle TITLE_CLASS;
|
||||
|
||||
public static void sendTitle(PlotPlayer player, String head, String sub, ChatColor head_color, ChatColor sub_color) {
|
||||
public static void sendTitle(PlotPlayer player, String head, String sub) {
|
||||
if (TITLE_CLASS != null && !player.getAttribute("disabletitles")) {
|
||||
TITLE_CLASS.sendTitle(player, head, sub, head_color, sub_color, 1, 2, 1);
|
||||
TITLE_CLASS.sendTitle(player, head, sub, 1, 2, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void sendTitle(PlotPlayer player, String head, String sub, ChatColor head_color, ChatColor sub_color, int in, int delay, int out);
|
||||
public abstract void sendTitle(PlotPlayer player, String head, String sub, int in, int delay, int out);
|
||||
}
|
||||
|
@ -6,15 +6,13 @@ import org.bukkit.ChatColor;
|
||||
|
||||
public class DefaultTitle extends AbstractTitle {
|
||||
@Override
|
||||
public void sendTitle(final PlotPlayer player, final String head, final String sub, final ChatColor head_color, final ChatColor sub_color, int in, int delay, int out) {
|
||||
public void sendTitle(final PlotPlayer player, final String head, final String sub, int in, int delay, int out) {
|
||||
try {
|
||||
final DefaultTitleManager title = new DefaultTitleManager(head, sub, in, delay, out);
|
||||
title.setTitleColor(head_color);
|
||||
title.setSubtitleColor(sub_color);
|
||||
title.send(((BukkitPlayer) player).player);
|
||||
} catch (final Throwable e) {
|
||||
AbstractTitle.TITLE_CLASS = new DefaultTitle_183();
|
||||
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, head_color, sub_color, in, delay, out);
|
||||
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,15 +6,13 @@ import org.bukkit.ChatColor;
|
||||
|
||||
public class DefaultTitle_183 extends AbstractTitle {
|
||||
@Override
|
||||
public void sendTitle(final PlotPlayer player, final String head, final String sub, final ChatColor head_color, final ChatColor sub_color, int in, int delay, int out) {
|
||||
public void sendTitle(final PlotPlayer player, final String head, final String sub, int in, int delay, int out) {
|
||||
try {
|
||||
final DefaultTitleManager_183 title = new DefaultTitleManager_183(head, sub, in, delay, out);
|
||||
title.setTitleColor(head_color);
|
||||
title.setSubtitleColor(sub_color);
|
||||
title.send(((BukkitPlayer) player).player);
|
||||
} catch (final Throwable e) {
|
||||
AbstractTitle.TITLE_CLASS = new HackTitle();
|
||||
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, head_color, sub_color, in, delay, out);
|
||||
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,11 +8,9 @@ import org.bukkit.ChatColor;
|
||||
|
||||
public class HackTitle extends AbstractTitle {
|
||||
@Override
|
||||
public void sendTitle(final PlotPlayer player, final String head, final String sub, final ChatColor head_color, final ChatColor sub_color, int in, int delay, int out) {
|
||||
public void sendTitle(final PlotPlayer player, final String head, final String sub, int in, int delay, int out) {
|
||||
try {
|
||||
final HackTitleManager title = new HackTitleManager(head, sub, in, delay, out);
|
||||
title.setTitleColor(head_color);
|
||||
title.setSubtitleColor(sub_color);
|
||||
title.send(((BukkitPlayer) player).player);
|
||||
} catch (final Throwable e) {
|
||||
PS.log("&cYour server version does not support titles!");
|
||||
|
@ -1,22 +0,0 @@
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.SetupObject;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class SetupUtils {
|
||||
|
||||
public static SetupUtils manager;
|
||||
|
||||
public final static Map<String, SetupObject> setupMap = new HashMap<>();
|
||||
public static HashMap<String, ChunkGenerator> generators = new HashMap<>();
|
||||
|
||||
public abstract void updateGenerators();
|
||||
|
||||
public abstract String getGenerator(PlotWorld plotworld);
|
||||
|
||||
public abstract String setupWorld(final SetupObject object);
|
||||
}
|
@ -2,10 +2,13 @@ package com.plotsquared.bukkit.util.bukkit;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.SetupObject;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import com.plotsquared.bukkit.generator.BukkitGeneratorWrapper;
|
||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||
import com.plotsquared.bukkit.util.SetupUtils;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
@ -32,7 +35,7 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
final String name = plugin.getDescription().getName();
|
||||
// final PlotGenerator pgen = (PlotGenerator) generator;
|
||||
// if (pgen.getPlotManager() instanceof SquarePlotManager) {
|
||||
SetupUtils.generators.put(name, generator);
|
||||
SetupUtils.generators.put(name, new BukkitGeneratorWrapper("CheckingPlotSquaredGenerator", generator));
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@ -55,8 +58,8 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
if (object.setupGenerator != null && !object.setupGenerator.equals(object.plotManager)) {
|
||||
PS.get().config.set("worlds." + world + "." + "generator.init", object.setupGenerator);
|
||||
}
|
||||
ChunkGenerator gen = generators.get(object.setupGenerator);
|
||||
if (gen instanceof BukkitPlotGenerator) {
|
||||
PlotGenerator<ChunkGenerator> gen = (PlotGenerator<ChunkGenerator>) generators.get(object.setupGenerator);
|
||||
if (gen.generator instanceof BukkitPlotGenerator) {
|
||||
object.setupGenerator = null;
|
||||
}
|
||||
}
|
||||
@ -105,8 +108,8 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
if (!(generator instanceof BukkitPlotGenerator)) {
|
||||
return null;
|
||||
}
|
||||
for (Entry<String, ChunkGenerator> entry : generators.entrySet()) {
|
||||
if (entry.getValue().getClass().getName().equals(generator.getClass().getName())) {
|
||||
for (Entry<String, PlotGenerator<?>> entry : generators.entrySet()) {
|
||||
if (entry.getValue().generator.getClass().getName().equals(generator.getClass().getName())) {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.plotsquared.bukkit.util.bukkit;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import com.plotsquared.bukkit.generator.AugmentedPopulator;
|
||||
import com.plotsquared.bukkit.util.SetupUtils;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
@ -22,7 +24,8 @@ public class SetGenCB {
|
||||
}
|
||||
String name = gen.getClass().getCanonicalName();
|
||||
boolean set = false;
|
||||
for (ChunkGenerator newGen : SetupUtils.generators.values()) {
|
||||
for (PlotGenerator<?> wrapper : SetupUtils.generators.values()) {
|
||||
ChunkGenerator newGen = (ChunkGenerator) wrapper.generator;
|
||||
if (newGen.getClass().getCanonicalName().equals(name)) {
|
||||
// set generator
|
||||
Field generator = world.getClass().getDeclaredField("generator");
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.plotsquared.bukkit.listeners;
|
||||
package com.plotsquared.listener;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
@ -4,6 +4,8 @@ import com.intellectualcrafters.plot.generator.PlotGenerator;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.SetupObject;
|
||||
|
||||
import org.spongepowered.api.world.gen.WorldGenerator;
|
||||
|
||||
public class SpongeGeneratorWrapper extends PlotGenerator<WorldGenerator>{
|
||||
@ -54,5 +56,10 @@ public class SpongeGeneratorWrapper extends PlotGenerator<WorldGenerator>{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processSetup(SetupObject object) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,93 @@
|
||||
package com.plotsquared.sponge;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import org.spongepowered.api.GameProfile;
|
||||
import org.spongepowered.api.entity.player.Player;
|
||||
import org.spongepowered.api.service.profile.GameProfileResolver;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.inject.Inject;
|
||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
|
||||
public class SpongeLowerOfflineUUIDWrapper extends UUIDWrapper {
|
||||
|
||||
public SpongeLowerOfflineUUIDWrapper() {
|
||||
// Anything?
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID(final PlotPlayer player) {
|
||||
return getUUID(player.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID(final OfflinePlotPlayer player) {
|
||||
return getUUID(player.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfflinePlotPlayer getOfflinePlayer(final UUID uuid) {
|
||||
String name = UUIDHandler.getName(uuid);
|
||||
if (name == null) {
|
||||
try {
|
||||
GameProfile profile = SpongeMain.THIS.getResolver().get(uuid).get();
|
||||
if (profile != null) {
|
||||
name = profile.getName();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (name == null) {
|
||||
for (GameProfile profile : SpongeMain.THIS.getResolver().getCachedProfiles()) {
|
||||
if (getUUID(profile.getName()).equals(uuid)) {
|
||||
name = profile.getName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
final String username = name;
|
||||
return new OfflinePlotPlayer() {
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
return UUIDHandler.getPlayer(uuid) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastPlayed() {
|
||||
// TODO FIXME
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public Player[] getOnlinePlayers() {
|
||||
return SpongeMain.THIS.getServer().getOnlinePlayers().toArray(new Player[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID(final String name) {
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfflinePlotPlayer[] getOfflinePlayers() {
|
||||
// TODO FIXME
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
}
|
||||
}
|
@ -9,11 +9,13 @@ import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.plotsquared.bukkit.listeners.APlotListener;
|
||||
import com.plotsquared.bukkit.util.SetupUtils;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
import com.plotsquared.listener.APlotListener;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.spongepowered.api.Game;
|
||||
import org.spongepowered.api.GameRegistry;
|
||||
import org.spongepowered.api.MinecraftVersion;
|
||||
import org.spongepowered.api.Server;
|
||||
import org.spongepowered.api.entity.player.Player;
|
||||
import org.spongepowered.api.entity.player.gamemode.GameModes;
|
||||
@ -23,6 +25,7 @@ import org.spongepowered.api.event.state.PreInitializationEvent;
|
||||
import org.spongepowered.api.event.state.ServerAboutToStartEvent;
|
||||
import org.spongepowered.api.plugin.Plugin;
|
||||
import org.spongepowered.api.plugin.PluginContainer;
|
||||
import org.spongepowered.api.service.profile.GameProfileResolver;
|
||||
import org.spongepowered.api.world.DimensionTypes;
|
||||
import org.spongepowered.api.world.GeneratorTypes;
|
||||
import org.spongepowered.api.world.World;
|
||||
@ -43,7 +46,33 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
||||
@Inject private Game game;
|
||||
private Server server;
|
||||
|
||||
private GameProfileResolver resolver;
|
||||
|
||||
private WorldModify modify;
|
||||
|
||||
private Object plugin;
|
||||
|
||||
// stuff //
|
||||
public Logger getLogger() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
public Game getGame() {
|
||||
return game;
|
||||
}
|
||||
|
||||
public Server getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
public GameProfileResolver getResolver() {
|
||||
return resolver;
|
||||
}
|
||||
|
||||
public Object getPlugin() {
|
||||
return this.plugin;
|
||||
}
|
||||
/////////
|
||||
|
||||
////////////////////// SPONGE PLUGIN REGISTRATION ////////////////////
|
||||
@Override
|
||||
@ -84,27 +113,18 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
||||
public void onServerAboutToStart(ServerAboutToStartEvent event) {
|
||||
log("INIT");
|
||||
THIS = this;
|
||||
PS.instance = new PS(this);
|
||||
|
||||
// Setup metrics
|
||||
if (Settings.METRICS) {
|
||||
try {
|
||||
final SpongeMetrics metrics = new SpongeMetrics(game, this);
|
||||
metrics.start();
|
||||
log(C.PREFIX.s() + "&6Metrics enabled.");
|
||||
} catch (final Exception e) {
|
||||
log(C.PREFIX.s() + "&cFailed to load up metrics.");
|
||||
}
|
||||
} else {
|
||||
log("&dUsing metrics will allow us to improve the plugin, please consider it :)");
|
||||
}
|
||||
// resolver
|
||||
resolver = game.getServiceManager().provide(GameProfileResolver.class).get();
|
||||
plugin = game.getPluginManager().getPlugin("PlotSquared").get().getInstance();
|
||||
|
||||
PS.instance = new PS(this);
|
||||
|
||||
// Set the generators for each world...
|
||||
server = game.getServer();
|
||||
Collection<World> worlds = server.getWorlds();
|
||||
if (worlds.size() > 0) {
|
||||
log("INJECTING WORLDS!!!!!!!");
|
||||
UUIDHandler.startCaching(null);
|
||||
for (World world : server.getWorlds()) {
|
||||
log("INJECTING WORLD: " + world.getName());
|
||||
world.setWorldGenerator(new SpongePlotGenerator(world.getName()));
|
||||
@ -112,31 +132,25 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
||||
}
|
||||
|
||||
ConfigurationSection worldSection = PS.get().config.getConfigurationSection("worlds");
|
||||
for (String world : worldSection.getKeys(false)) {
|
||||
this.modify = new WorldModify(this);
|
||||
Game game = event.getGame();
|
||||
game.getRegistry().registerWorldGeneratorModifier(modify);
|
||||
game.getRegistry().getWorldBuilder()
|
||||
.name(world)
|
||||
.enabled(true)
|
||||
.loadsOnStartup(true)
|
||||
.keepsSpawnLoaded(true)
|
||||
.dimensionType(DimensionTypes.OVERWORLD)
|
||||
.generator(GeneratorTypes.DEBUG)
|
||||
.gameMode(GameModes.CREATIVE)
|
||||
.generatorModifiers(modify)
|
||||
.build();
|
||||
if (worldSection != null) {
|
||||
for (String world : worldSection.getKeys(false)) {
|
||||
this.modify = new WorldModify(this);
|
||||
Game game = event.getGame();
|
||||
game.getRegistry().registerWorldGeneratorModifier(modify);
|
||||
game.getRegistry().getWorldBuilder()
|
||||
.name(world)
|
||||
.enabled(true)
|
||||
.loadsOnStartup(true)
|
||||
.keepsSpawnLoaded(true)
|
||||
.dimensionType(DimensionTypes.OVERWORLD)
|
||||
.generator(GeneratorTypes.DEBUG)
|
||||
.gameMode(GameModes.CREATIVE)
|
||||
.generatorModifiers(modify)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Logger getLogger() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
public Game getGame() {
|
||||
return game;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPlayerChat(PlayerChatEvent event) {
|
||||
// This is how events sort of work?
|
||||
@ -163,68 +177,72 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
||||
|
||||
@Override
|
||||
public int[] getPluginVersion() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
PluginContainer plugin = game.getPluginManager().getPlugin("PlotSquared").get();
|
||||
String version = plugin.getVersion();
|
||||
log("Checking plugin version: PlotSquared: ");
|
||||
String[] split = version.split("\\.");
|
||||
return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), (split.length == 3) ? Integer.parseInt(split[2]) : 0 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getServerVersion() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
log("Checking minecraft version: Sponge: ");
|
||||
String version = game.getPlatform().getMinecraftVersion().getName();
|
||||
String[] split = version.split("\\.");
|
||||
return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), (split.length == 3) ? Integer.parseInt(split[2]) : 0 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskManager getTaskManager() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return new SpongeTaskManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runEntityTask() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
log("runEntityTask is not implemented!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCommands() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
log("registerCommands is not implemented!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPlayerEvents() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
log("registerPlayerEvents is not implemented!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerInventoryEvents() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
log("registerInventoryEvents is not implemented!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPlotPlusEvents() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
log("registerPlotPlusEvents is not implemented!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerForceFieldEvents() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
log("registerForceFieldEvents is not implemented!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerWorldEditEvents() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
log("registerWorldEditEvents is not implemented!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTNTListener() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
log("registerTNTListener is not implemented!");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -265,8 +283,14 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
||||
|
||||
@Override
|
||||
public UUIDHandlerImplementation initUUIDHandler() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
UUIDWrapper wrapper;
|
||||
if (Settings.OFFLINE_MODE || !PS.get().checkVersion(this.getServerVersion(), 1, 7, 6)) {
|
||||
wrapper = new SpongeLowerOfflineUUIDWrapper();
|
||||
}
|
||||
else {
|
||||
wrapper = new SpongeOnlineUUIDWrapper();
|
||||
}
|
||||
return new SpongeUUIDHandler(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -319,14 +343,19 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
||||
|
||||
@Override
|
||||
public String getServerName() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
// TODO FIXME
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startMetrics() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
try {
|
||||
final SpongeMetrics metrics = new SpongeMetrics(game, this);
|
||||
metrics.start();
|
||||
log(C.PREFIX.s() + "&6Metrics enabled.");
|
||||
} catch (final Exception e) {
|
||||
log(C.PREFIX.s() + "&cFailed to load up metrics.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,72 @@
|
||||
package com.plotsquared.sponge;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
|
||||
public class SpongeOnlineUUIDWrapper extends UUIDWrapper {
|
||||
|
||||
@Override
|
||||
public UUID getUUID(PlotPlayer player) {
|
||||
return ((SpongePlayer) player).player.getUniqueId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID(OfflinePlotPlayer player) {
|
||||
return player.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID(String name) {
|
||||
try {
|
||||
return SpongeMain.THIS.getResolver().get(name, true).get().getUniqueId();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfflinePlotPlayer getOfflinePlayer(final UUID uuid) {
|
||||
String name;
|
||||
try {
|
||||
name = SpongeMain.THIS.getResolver().get(uuid, true).get().getName();
|
||||
}
|
||||
catch (Exception e) {
|
||||
name = null;
|
||||
}
|
||||
final String username = name;
|
||||
return new OfflinePlotPlayer() {
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
return UUIDHandler.getPlayer(uuid) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastPlayed() {
|
||||
// TODO FIXME
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfflinePlotPlayer[] getOfflinePlayers() {
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
}
|
||||
|
||||
}
|
205
src/main/java/com/plotsquared/sponge/SpongePlayer.java
Normal file
205
src/main/java/com/plotsquared/sponge/SpongePlayer.java
Normal file
@ -0,0 +1,205 @@
|
||||
package com.plotsquared.sponge;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.spongepowered.api.entity.player.Player;
|
||||
import org.spongepowered.api.text.chat.ChatTypes;
|
||||
|
||||
import com.flowpowered.math.vector.Vector3d;
|
||||
import com.intellectualcrafters.plot.commands.RequiredType;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
|
||||
public class SpongePlayer implements PlotPlayer {
|
||||
|
||||
public final Player player;
|
||||
private UUID uuid;
|
||||
private String name;
|
||||
private int op = 0;
|
||||
private long last = 0;
|
||||
private HashSet<String> hasPerm = new HashSet<>();
|
||||
private HashSet<String> noPerm = new HashSet<>();
|
||||
|
||||
private HashMap<String, Object> meta;
|
||||
|
||||
public SpongePlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(C c, String... args) {
|
||||
MainUtil.sendMessage(this, c, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequiredType getSuperCaller() {
|
||||
return RequiredType.PLAYER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPreviousLogin() {
|
||||
return (long) (player.getJoinData().getLastPlayed().getSeconds()) * 1000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return SpongeUtil.getLocation(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocationFull() {
|
||||
return SpongeUtil.getLocationFull(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
if (this.uuid == null) {
|
||||
this.uuid = UUIDHandler.getUUID(this);
|
||||
}
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String perm) {
|
||||
if (Settings.PERMISSION_CACHING) {
|
||||
if (this.noPerm.contains(perm)) {
|
||||
return false;
|
||||
}
|
||||
if (this.hasPerm.contains(perm)) {
|
||||
return true;
|
||||
}
|
||||
final boolean result = this.player.hasPermission(perm);
|
||||
if (!result) {
|
||||
this.noPerm.add(perm);
|
||||
return false;
|
||||
}
|
||||
this.hasPerm.add(perm);
|
||||
return true;
|
||||
}
|
||||
return this.player.hasPermission(perm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
player.sendMessage(ChatTypes.CHAT, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(Location loc) {
|
||||
String world = player.getWorld().getName();
|
||||
if (world != loc.getWorld()) {
|
||||
player.transferToWorld(world, new Vector3d(loc.getX(), loc.getY(), loc.getZ()));
|
||||
}
|
||||
else {
|
||||
org.spongepowered.api.world.Location current = player.getLocation();
|
||||
player.setLocationSafely(current.setPosition(new Vector3d(loc.getX(), loc.getY(), loc.getZ())));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOp() {
|
||||
if (this.op != 0) {
|
||||
return this.op != 1;
|
||||
}
|
||||
final boolean result = this.player.hasPermission("*");
|
||||
if (!result) {
|
||||
this.op = 1;
|
||||
return false;
|
||||
}
|
||||
this.op = 2;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
return player.isOnline();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
if (this.name == null) {
|
||||
this.name = this.player.getName();
|
||||
}
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCompassTarget(Location loc) {
|
||||
// TODO set compass target
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadData() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveData() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMeta(String key, Object value) {
|
||||
if (this.meta == null) {
|
||||
this.meta = new HashMap<String, Object>();
|
||||
}
|
||||
this.meta.put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMeta(String key) {
|
||||
if (this.meta != null) {
|
||||
return this.meta.get(key);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteMeta(String key) {
|
||||
if (this.meta != null) {
|
||||
this.meta.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String key) {
|
||||
key = "plotsquared_user_attributes." + key;
|
||||
EconHandler.manager.setPermission(this, key, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAttribute(String key) {
|
||||
key = "plotsquared_user_attributes." + key;
|
||||
Permission perm = Bukkit.getServer().getPluginManager().getPermission(key);
|
||||
if (perm == null) {
|
||||
perm = new Permission(key, PermissionDefault.FALSE);
|
||||
Bukkit.getServer().getPluginManager().addPermission(perm);
|
||||
Bukkit.getServer().getPluginManager().recalculatePermissionDefaults(perm);
|
||||
}
|
||||
return player.hasPermission(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute(String key) {
|
||||
key = "plotsquared_user_attributes." + key;
|
||||
EconHandler.manager.setPermission(this, key, false);
|
||||
}
|
||||
}
|
59
src/main/java/com/plotsquared/sponge/SpongeTaskManager.java
Normal file
59
src/main/java/com/plotsquared/sponge/SpongeTaskManager.java
Normal file
@ -0,0 +1,59 @@
|
||||
package com.plotsquared.sponge;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.spongepowered.api.service.scheduler.Task;
|
||||
import org.spongepowered.api.service.scheduler.TaskBuilder;
|
||||
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
|
||||
public class SpongeTaskManager extends TaskManager {
|
||||
|
||||
private AtomicInteger i = new AtomicInteger();
|
||||
|
||||
private HashMap<Integer, Task> tasks = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public int taskRepeat(Runnable r, int interval) {
|
||||
int val = i.incrementAndGet();
|
||||
TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().getTaskBuilder();
|
||||
TaskBuilder built = builder.delay(interval).interval(interval).execute(r);
|
||||
Task task = built.submit(SpongeMain.THIS.getPlugin());
|
||||
tasks.put(val, task);
|
||||
return val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void taskAsync(Runnable r) {
|
||||
TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().getTaskBuilder();
|
||||
builder.async().execute(r);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void task(Runnable r) {
|
||||
TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().getTaskBuilder();
|
||||
builder.execute(r);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void taskLater(Runnable r, int delay) {
|
||||
TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().getTaskBuilder();
|
||||
builder.delay(delay).execute(r);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void taskLaterAsync(Runnable r, int delay) {
|
||||
TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().getTaskBuilder();
|
||||
builder.async().delay(delay).execute(r);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelTask(int i) {
|
||||
Task task = tasks.remove(i);
|
||||
if (task != null) {
|
||||
task.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
53
src/main/java/com/plotsquared/sponge/SpongeUUIDHandler.java
Normal file
53
src/main/java/com/plotsquared/sponge/SpongeUUIDHandler.java
Normal file
@ -0,0 +1,53 @@
|
||||
package com.plotsquared.sponge;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.spongepowered.api.GameProfile;
|
||||
import org.spongepowered.api.service.profile.GameProfileResolver;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
|
||||
public class SpongeUUIDHandler extends UUIDHandlerImplementation {
|
||||
|
||||
public SpongeUUIDHandler(UUIDWrapper wrapper) {
|
||||
super(wrapper);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startCaching(Runnable whenDone) {
|
||||
if (!super.startCaching(whenDone)) {
|
||||
return false;
|
||||
}
|
||||
return cache(whenDone);
|
||||
}
|
||||
|
||||
public boolean cache(Runnable whenDone) {
|
||||
// TODO cache UUIDS
|
||||
// SpongeMain.THIS.getRegistry().get
|
||||
add(new StringWrapper("*"), DBFunc.everyone);
|
||||
for (GameProfile profile : SpongeMain.THIS.getResolver().getCachedProfiles()) {
|
||||
add(new StringWrapper(profile.getName()), profile.getUniqueId());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fetchUUID(final String name, final RunnableVal<UUID> ifFetch) {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ifFetch.value = uuidWrapper.getUUID(name);
|
||||
TaskManager.runTask(ifFetch);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
28
src/main/java/com/plotsquared/sponge/SpongeUtil.java
Normal file
28
src/main/java/com/plotsquared/sponge/SpongeUtil.java
Normal file
@ -0,0 +1,28 @@
|
||||
package com.plotsquared.sponge;
|
||||
|
||||
import org.spongepowered.api.entity.Entity;
|
||||
|
||||
import com.flowpowered.math.vector.Vector3d;
|
||||
import com.flowpowered.math.vector.Vector3i;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
|
||||
public class SpongeUtil {
|
||||
|
||||
public static Location getLocation(Entity player) {
|
||||
String world = player.getWorld().getName();
|
||||
org.spongepowered.api.world.Location loc = player.getLocation();
|
||||
Vector3i pos = loc.getBlockPosition();
|
||||
return new Location(world, pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
public static Location getLocationFull(Entity player) {
|
||||
String world = player.getWorld().getName();
|
||||
Vector3d rot = player.getRotation();
|
||||
float[] pitchYaw = MathMan.getPitchAndYaw((float) rot.getX(), (float) rot.getY(), (float) rot.getZ());
|
||||
org.spongepowered.api.world.Location loc = player.getLocation();
|
||||
Vector3i pos = loc.getBlockPosition();
|
||||
return new Location(world, pos.getX(), pos.getY(), pos.getZ(), pitchYaw[1], pitchYaw[0]);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user