├── .gitignore
├── .idea
├── .name
├── artifacts
│ └── placemc_jar.xml
├── kotlinc.xml
├── misc.xml
├── modules.xml
└── vcs.xml
├── LICENSE
├── README.md
├── placemc.iml
└── src
├── com
└── kwiius
│ └── placemc
│ ├── BlockPlacement.java
│ ├── Config.java
│ ├── GenerateCommand.java
│ ├── GetBitmapTask.java
│ ├── GotoCommand.java
│ ├── PlaceBlocksTask.java
│ └── PluginMain.java
└── plugin.yml
/.gitignore:
--------------------------------------------------------------------------------
1 | *.class
2 |
3 | # Mobile Tools for Java (J2ME)
4 | .mtj.tmp/
5 |
6 | # Package Files #
7 | *.jar
8 | *.war
9 | *.ear
10 |
11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
12 | hs_err_pid*
13 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
14 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
15 |
16 | # User-specific stuff:
17 | .idea/**/workspace.xml
18 | .idea/**/tasks.xml
19 | .idea/dictionaries
20 |
21 | # Sensitive or high-churn files:
22 | .idea/**/dataSources/
23 | .idea/**/dataSources.ids
24 | .idea/**/dataSources.xml
25 | .idea/**/dataSources.local.xml
26 | .idea/**/sqlDataSources.xml
27 | .idea/**/dynamic.xml
28 | .idea/**/uiDesigner.xml
29 |
30 | # Gradle:
31 | .idea/**/gradle.xml
32 | .idea/**/libraries
33 |
34 | # Mongo Explorer plugin:
35 | .idea/**/mongoSettings.xml
36 |
37 | ## File-based project format:
38 | *.iws
39 |
40 | ## Plugin-specific files:
41 |
42 | # IntelliJ
43 | /out/
44 |
45 | # mpeltonen/sbt-idea plugin
46 | .idea_modules/
47 |
48 | # JIRA plugin
49 | atlassian-ide-plugin.xml
50 |
51 | # Cursive Clojure plugin
52 | .idea/replstate.xml
53 |
54 | # Crashlytics plugin (for Android Studio and IntelliJ)
55 | com_crashlytics_export_strings.xml
56 | crashlytics.properties
57 | crashlytics-build.properties
58 | fabric.properties
59 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | placemc
--------------------------------------------------------------------------------
/.idea/artifacts/placemc_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/../server/plugins
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # placemc
2 | Mirrors Place into Minecraft - reddit.place:25565
3 |
4 | ## I'm a noob, I just want to join!
5 |
6 | Join us! The IP is: `reddit.place`
7 |
8 | ## Building
9 |
10 | Spigot requires a jar containing plugin.yml plus the classes.
11 |
12 | Ensure that all of org.apache.httpcomponents:fluent-hc:jar:4.5.3's (and its dependencies's) classes are in the jar too.
13 |
14 | ## Server setup
15 |
16 | Use spigot. Add plugin VoidGenerator, plus this one.
17 |
18 | Add to `bukkit.yml`:
19 |
20 | worlds:
21 | world:
22 | generator: VoidGenerator
23 |
24 | ## License
25 |
26 | Copyright 2017 JJJollyjim
27 |
28 | Available under the terms of the MIT license, except for Apache HTTPClient Fluent and its dependencies which are provided by Apache under their license
29 |
--------------------------------------------------------------------------------
/placemc.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/com/kwiius/placemc/BlockPlacement.java:
--------------------------------------------------------------------------------
1 | package com.kwiius.placemc;
2 |
3 | public class BlockPlacement {
4 | private static final byte[] colours = {
5 | 0,
6 | 8,
7 | 7,
8 | 15,
9 | 6,
10 | 14,
11 | 1,
12 | 12,
13 | 4,
14 | 5,
15 | 13,
16 | 3,
17 | 9,
18 | 11,
19 | 2,
20 | 10
21 | };
22 |
23 | int x;
24 | int y;
25 | byte blockType;
26 | boolean definitelyNew;
27 |
28 | public BlockPlacement(int x, int y, byte colour, boolean definitelyNew) {
29 | this.x = x;
30 | this.y = y;
31 | this.blockType = colours[colour];
32 | this.definitelyNew = definitelyNew;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/com/kwiius/placemc/Config.java:
--------------------------------------------------------------------------------
1 | package com.kwiius.placemc;
2 |
3 | /**
4 | * Created by jamie on 4/2/17.
5 | */
6 | public class Config {
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/src/com/kwiius/placemc/GenerateCommand.java:
--------------------------------------------------------------------------------
1 | package com.kwiius.placemc;
2 |
3 | import org.bukkit.Material;
4 | import org.bukkit.World;
5 | import org.bukkit.command.Command;
6 | import org.bukkit.command.CommandExecutor;
7 | import org.bukkit.command.CommandSender;
8 |
9 | public class GenerateCommand implements CommandExecutor{
10 |
11 | private World w;
12 |
13 | GenerateCommand(World w){
14 | this.w = w;
15 | }
16 |
17 | @Override
18 | public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
19 | if(!commandSender.hasPermission("placemc.generate")) return false;
20 |
21 | for (int x = 0; x < 1000; x++) {
22 | for (int z = 0; z < 1000; z++) {
23 | w.getBlockAt(x, 30, z).setType(Material.WOOL);
24 | }
25 | }
26 | return true;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/com/kwiius/placemc/GetBitmapTask.java:
--------------------------------------------------------------------------------
1 | package com.kwiius.placemc;
2 |
3 | import org.apache.http.client.fluent.Request;
4 | import org.bukkit.plugin.java.JavaPlugin;
5 | import org.bukkit.scheduler.BukkitRunnable;
6 |
7 | import java.util.Queue;
8 |
9 | public class GetBitmapTask extends BukkitRunnable {
10 | Queue queue;
11 | JavaPlugin plugin;
12 |
13 | public GetBitmapTask(JavaPlugin plugin, Queue queue) {
14 | this.plugin = plugin;
15 | this.queue = queue;
16 | }
17 |
18 | @Override
19 | public void run() {
20 | try {
21 | plugin.getLogger().info("Fetching bitmap...");
22 |
23 | byte[] bs = Request.Get("https://www.reddit.com/api/place/board-bitmap")
24 | .userAgent("PlaceMC 0.0.1 by /u/JJJollyjim")
25 | .execute()
26 | .returnContent()
27 | .asBytes();
28 |
29 | plugin.getLogger().info("New bitmap!");
30 |
31 | for (int halfX = 0; halfX < 500; halfX++) {
32 | for (int y = 0; y < 1000; y++) {
33 | byte b = bs[4 + (500*y + halfX)];
34 |
35 | queue.add(new BlockPlacement(halfX * 2, y, (byte) ((b & 0xF0) >> 4), false));
36 | queue.add(new BlockPlacement(halfX * 2 + 1, y, (byte) (b & 0x0F), false));
37 | }
38 | }
39 |
40 | plugin.getLogger().info("Enqueued: " + queue.size());
41 |
42 | } catch (Exception e) {
43 | e.printStackTrace();
44 | plugin.getLogger().info("Error fetching bitmap :(");
45 | } finally {
46 | // runTaskLaterAsynchronously(plugin, 200);
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/com/kwiius/placemc/GotoCommand.java:
--------------------------------------------------------------------------------
1 | package com.kwiius.placemc;
2 |
3 | import org.bukkit.Location;
4 | import org.bukkit.command.Command;
5 | import org.bukkit.command.CommandExecutor;
6 | import org.bukkit.command.CommandSender;
7 | import org.bukkit.entity.Player;
8 |
9 | public class GotoCommand implements CommandExecutor {
10 |
11 | @Override
12 | public boolean onCommand(CommandSender commandSender, Command command, String cmd, String[] args) {
13 | if (args.length == 2 && commandSender instanceof Player) {
14 | Player p = (Player) commandSender;
15 | int x, z;
16 | try {
17 | x = Integer.parseInt(args[0]);
18 | z = Integer.parseInt(args[1]);
19 | } catch (Exception e) {
20 | return false;
21 | }
22 |
23 | if (x >= 0 && x <= 1000 && z >= 0 && z <= 1000) {
24 | Location l = new Location(p.getWorld(), x, 120, z);
25 | l.setDirection(p.getLocation().getDirection());
26 | p.teleport(l);
27 | return true;
28 | } else {
29 | commandSender.sendMessage("x and y should be between 0 and 1000");
30 | return false;
31 | }
32 |
33 | }
34 | return false;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/com/kwiius/placemc/PlaceBlocksTask.java:
--------------------------------------------------------------------------------
1 | package com.kwiius.placemc;
2 |
3 | import org.bukkit.*;
4 | import org.bukkit.block.Block;
5 | import org.bukkit.entity.Firework;
6 | import org.bukkit.inventory.meta.FireworkMeta;
7 | import org.bukkit.plugin.java.JavaPlugin;
8 | import org.bukkit.scheduler.BukkitRunnable;
9 |
10 | import java.util.Queue;
11 |
12 | public class PlaceBlocksTask extends BukkitRunnable {
13 | private final JavaPlugin plugin;
14 | private final Queue queue;
15 | private final World world;
16 |
17 |
18 |
19 | public PlaceBlocksTask(JavaPlugin plugin, Queue queue, World world) {
20 | this.plugin = plugin;
21 | this.queue = queue;
22 | this.world = world;
23 | }
24 |
25 |
26 | @Override
27 | public void run() {
28 | int updated = 0;
29 |
30 | while (!queue.isEmpty()) {
31 | BlockPlacement p = queue.remove();
32 |
33 | Block b = world.getBlockAt(p.x, 30, p.y);
34 |
35 | if (p.definitelyNew || b.getData() != p.blockType) {
36 | b.setData(p.blockType);
37 | updated++;
38 | Firework f = (Firework) world.spawn(new Location(world, p.x, 30, p.y), Firework.class);
39 | FireworkMeta fm = f.getFireworkMeta();
40 | fm.addEffect(FireworkEffect.builder()
41 | .flicker(false)
42 | .trail(true)
43 | .with(FireworkEffect.Type.BALL)
44 | .withColor(DyeColor.getByWoolData(p.blockType).getColor())
45 | .withFade(DyeColor.getByWoolData(p.blockType).getColor())
46 | .build());
47 | fm.setPower(0);
48 | f.setFireworkMeta(fm);
49 | }
50 | }
51 |
52 | if (updated > 0) {
53 | plugin.getServer().broadcastMessage(ChatColor.DARK_GREEN + "Updated " + ChatColor.GREEN + updated + ChatColor.DARK_GREEN + " blocks!");
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/com/kwiius/placemc/PluginMain.java:
--------------------------------------------------------------------------------
1 | package com.kwiius.placemc;
2 |
3 | import org.bukkit.Material;
4 | import org.bukkit.World;
5 | import org.bukkit.plugin.java.JavaPlugin;
6 |
7 | import java.util.Queue;
8 | import java.util.concurrent.ConcurrentLinkedQueue;
9 |
10 | public class PluginMain extends JavaPlugin {
11 | private Queue placementsQueue = new ConcurrentLinkedQueue();
12 |
13 | @Override
14 | public void onEnable() {
15 | World w = getServer().getWorld("world");
16 |
17 | new PlaceBlocksTask(this, placementsQueue, w).runTaskTimer(this, 20, 20);
18 |
19 | new GetBitmapTask(this, placementsQueue).runTaskTimerAsynchronously(this, 20, 20*10);
20 |
21 | getCommand("goto").setExecutor(new GotoCommand());
22 | getCommand("generate").setExecutor(new GenerateCommand(w));
23 | }
24 |
25 | @Override
26 | public void onDisable() {
27 |
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/plugin.yml:
--------------------------------------------------------------------------------
1 | name: PlaceMC
2 | version: 0.0.1
3 | author: JJJollyjim
4 | main: com.kwiius.placemc.PluginMain
5 | commands:
6 | goto:
7 | description: Teleport to a position
8 | usage: /goto x y
9 | generate:
10 | description: Places the background square of white wool
11 | usage: /generate
12 | permission: placemc.generate
13 | permission-message: You don't have
14 | permissions:
15 | placemc.generate:
16 | description: Access to generate wool
17 | default: op
--------------------------------------------------------------------------------