mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-11-03 02:33:43 +01:00 
			
		
		
		
	Forgot to push this
This commit is contained in:
		@@ -0,0 +1,54 @@
 | 
			
		||||
package com.intellectualcrafters.plot.object;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.util.ChatManager;
 | 
			
		||||
 | 
			
		||||
public class PlotMessage {
 | 
			
		||||
    
 | 
			
		||||
    private Object builder;
 | 
			
		||||
 | 
			
		||||
    public PlotMessage() {
 | 
			
		||||
        this.builder = ChatManager.manager.builder();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public <T> T $(ChatManager<T> manager) {
 | 
			
		||||
        return (T) builder;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public PlotMessage(String text) {
 | 
			
		||||
        this();
 | 
			
		||||
        text(text);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public PlotMessage text(String text) {
 | 
			
		||||
        ChatManager.manager.text(this, text);
 | 
			
		||||
        return this;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public PlotMessage tooltip(PlotMessage... tooltip) {
 | 
			
		||||
        ChatManager.manager.tooltip(this, tooltip);
 | 
			
		||||
        return this;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public PlotMessage tooltip(String tooltip) {
 | 
			
		||||
        return tooltip(new PlotMessage(tooltip));
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public PlotMessage command(String command) {
 | 
			
		||||
        ChatManager.manager.command(this, command);
 | 
			
		||||
        return this;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public PlotMessage suggest(String command) {
 | 
			
		||||
        ChatManager.manager.suggest(this, command);
 | 
			
		||||
        return this;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public PlotMessage color(String color) {
 | 
			
		||||
        ChatManager.manager.color(this, color);
 | 
			
		||||
        return this;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void send(PlotPlayer player) {
 | 
			
		||||
        ChatManager.manager.send(this, player);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,22 @@
 | 
			
		||||
package com.intellectualcrafters.plot.util;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotMessage;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
 | 
			
		||||
public abstract class ChatManager<T> {
 | 
			
		||||
    public static ChatManager<?> manager;
 | 
			
		||||
    
 | 
			
		||||
    public abstract T builder();
 | 
			
		||||
    
 | 
			
		||||
    public abstract void color(PlotMessage message, String color);
 | 
			
		||||
    
 | 
			
		||||
    public abstract void tooltip(PlotMessage message, PlotMessage... tooltip);
 | 
			
		||||
    
 | 
			
		||||
    public abstract void command(PlotMessage message, String command);
 | 
			
		||||
    
 | 
			
		||||
    public abstract void text(PlotMessage message, String text);
 | 
			
		||||
 | 
			
		||||
    public abstract void send(PlotMessage plotMessage, PlotPlayer player);
 | 
			
		||||
 | 
			
		||||
    public abstract void suggest(PlotMessage plotMessage, String command);
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,12 @@
 | 
			
		||||
package com.plotsquared.bukkit.listeners.worldedit;
 | 
			
		||||
 | 
			
		||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
 | 
			
		||||
import com.sk89q.worldedit.extent.Extent;
 | 
			
		||||
 | 
			
		||||
public class ExtentWrapper extends AbstractDelegateExtent {
 | 
			
		||||
 | 
			
		||||
    protected ExtentWrapper(Extent extent) {
 | 
			
		||||
        super(extent);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,62 @@
 | 
			
		||||
package com.plotsquared.bukkit.util;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.ChatColor;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotMessage;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.util.ChatManager;
 | 
			
		||||
import com.plotsquared.bukkit.chat.FancyMessage;
 | 
			
		||||
import com.plotsquared.bukkit.object.BukkitPlayer;
 | 
			
		||||
 | 
			
		||||
public class BukkitChatManager extends ChatManager<FancyMessage> {
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public FancyMessage builder() {
 | 
			
		||||
        return new FancyMessage("");
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public void color(PlotMessage m, String color) {
 | 
			
		||||
        m.$(this).color(ChatColor.getByChar(C.color(color).substring(1)));
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public void tooltip(PlotMessage m, PlotMessage... tooltips) {
 | 
			
		||||
        List<FancyMessage> lines = new ArrayList<>();
 | 
			
		||||
        for (PlotMessage tooltip : tooltips) {
 | 
			
		||||
            lines.add(tooltip.$(this));
 | 
			
		||||
        }
 | 
			
		||||
        m.$(this).formattedTooltip(lines);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public void command(PlotMessage m, String command) {
 | 
			
		||||
        m.$(this).command(command);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public void text(PlotMessage m, String text) {
 | 
			
		||||
        m.$(this).then(ChatColor.stripColor(text));
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public void send(PlotMessage m, PlotPlayer player) {
 | 
			
		||||
        if (ConsolePlayer.isConsole(player)) {
 | 
			
		||||
            player.sendMessage(m.$(this).toOldMessageFormat());
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            m.$(this).send(((BukkitPlayer) player).player);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public void suggest(PlotMessage m, String command) {
 | 
			
		||||
        m.$(this).suggest(command);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,52 @@
 | 
			
		||||
package com.plotsquared.bukkit.util;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.ChatColor;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotMessage;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.util.ChatManager;
 | 
			
		||||
import com.plotsquared.bukkit.chat.FancyMessage;
 | 
			
		||||
import com.plotsquared.bukkit.object.BukkitPlayer;
 | 
			
		||||
 | 
			
		||||
public class BukkitPlainChatManager extends ChatManager<List<StringBuilder>> {
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<StringBuilder> builder() {
 | 
			
		||||
        return new ArrayList<StringBuilder>();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public void color(PlotMessage m, String color) {
 | 
			
		||||
        List<StringBuilder> parts = m.$(this);
 | 
			
		||||
        parts.get(parts.size() - 1).insert(0, color);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public void tooltip(PlotMessage m, PlotMessage... tooltips) {}
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public void command(PlotMessage m, String command) {}
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public void text(PlotMessage m, String text) {
 | 
			
		||||
        m.$(this).add(new StringBuilder(ChatColor.stripColor(text)));
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public void send(PlotMessage m, PlotPlayer player) {
 | 
			
		||||
        StringBuilder built = new StringBuilder();
 | 
			
		||||
        for (StringBuilder sb : m.$(this)) {
 | 
			
		||||
            built.append(sb);
 | 
			
		||||
        }
 | 
			
		||||
        player.sendMessage(built.toString());
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public void suggest(PlotMessage m, String command) {}
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
@@ -75,10 +75,13 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager {
 | 
			
		||||
            
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                if (toUpdate.size() == 0) {
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
                int count = 0;
 | 
			
		||||
                ArrayList<Chunk> chunks = new ArrayList<Chunk>();
 | 
			
		||||
                Iterator<Entry<ChunkLoc, Chunk>> i = toUpdate.entrySet().iterator();
 | 
			
		||||
                while (i.hasNext() && count < 1024) {
 | 
			
		||||
                while (i.hasNext() && count < 128) {
 | 
			
		||||
                    chunks.add(i.next().getValue());
 | 
			
		||||
                    i.remove();
 | 
			
		||||
                    count++;
 | 
			
		||||
@@ -88,7 +91,7 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager {
 | 
			
		||||
                }
 | 
			
		||||
                update(chunks);
 | 
			
		||||
            }
 | 
			
		||||
        }, 20);
 | 
			
		||||
        }, 1);
 | 
			
		||||
        this.chunksender = new SendChunk();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,66 @@
 | 
			
		||||
package com.plotsquared.sponge.util;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import org.spongepowered.api.text.TextBuilder;
 | 
			
		||||
import org.spongepowered.api.text.Texts;
 | 
			
		||||
import org.spongepowered.api.text.action.TextActions;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotMessage;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.util.ChatManager;
 | 
			
		||||
import com.plotsquared.sponge.object.SpongePlayer;
 | 
			
		||||
 | 
			
		||||
public class SpongeChatManager extends ChatManager<TextBuilder> {
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public TextBuilder builder() {
 | 
			
		||||
        return Texts.builder();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public void color(PlotMessage m, String color) {
 | 
			
		||||
        m.$(this).color(Texts.of(color).getColor());
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public void tooltip(PlotMessage m, PlotMessage... tooltips) {
 | 
			
		||||
        TextBuilder builder = Texts.builder();
 | 
			
		||||
        boolean lb = false;
 | 
			
		||||
        for (PlotMessage tooltip : tooltips) {
 | 
			
		||||
            if (lb) {
 | 
			
		||||
                builder.append(Texts.of("\n"));
 | 
			
		||||
            }
 | 
			
		||||
            builder.append(tooltip.$(this).build());
 | 
			
		||||
            lb = true;
 | 
			
		||||
        }
 | 
			
		||||
//        AchievementBuilder builder = SpongeMain.THIS.getGame().getRegistry().createAchievementBuilder();
 | 
			
		||||
        m.$(this).onHover(TextActions.showText(builder.toText()));
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public void command(PlotMessage m, String command) {
 | 
			
		||||
        m.$(this).onClick(TextActions.runCommand(command));
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public void text(PlotMessage m, String text) {
 | 
			
		||||
        m.$(this).append(Texts.of(text));
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public void send(PlotMessage m, PlotPlayer player) {
 | 
			
		||||
        if (ConsolePlayer.isConsole(player)) {
 | 
			
		||||
            player.sendMessage(Texts.legacy().to(m.$(this).build()));
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            ((SpongePlayer) player).player.sendMessage(m.$(this).build());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public void suggest(PlotMessage m, String command) {
 | 
			
		||||
        m.$(this).onClick(TextActions.suggestCommand(command));
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user