Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
0.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
noahhusby committed Dec 20, 2020
1 parent 59c2465 commit 3b20500
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 33 deletions.
2 changes: 1 addition & 1 deletion sledgehammer-bukkit/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
#

compile_name=sledgehammer-bukkit
version_compile=0.4.1
version_compile=0.4.2
version_minecraft=1.12.2
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
public class Constants
{
public static final String MODID = "sledgehammer";
public static final String VERSION = "0.4.1";
public static final String VERSION = "0.4.2";
public static final double SCALE = 7318261.522857145;
public static final int scanHeight = 1024;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ public void init() {
Warp warp = warps.get(x);

String headId = warp.getHeadID();
if(headId.equals("")) headId = Constants.cyanWoolHead;
if(headId.equals("")) headId = Constants.yellowWoolHead;
ItemStack item = SledgehammerUtil.getSkull(headId, ((warp.getPinnedMode() == Warp.PinnedMode.GLOBAL
|| warp.getPinnedMode() == Warp.PinnedMode.LOCAL) ? ChatColor.GOLD : ChatColor.BLUE)
|| warp.getPinnedMode() == Warp.PinnedMode.LOCAL) ? ChatColor.GOLD : ChatColor.BLUE)
+ "" + ChatColor.BOLD + warp.getName());

ItemMeta meta = item.getItemMeta();
Expand Down Expand Up @@ -167,6 +167,7 @@ public void onInventoryClick(InventoryClickEvent e) {
return;
}


if(e.getSlot() > 8 && e.getSlot() < 36) {
ItemMeta meta = e.getCurrentItem().getItemMeta();
int id = -1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020 Noah Husby
* sledgehammer - WarpInventoryController.java
* sledgehammer - AllWarpInventoryController.java
*
* Sledgehammer is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -22,7 +22,6 @@
import com.noahhusby.sledgehammer.data.warp.WarpGroup;
import com.noahhusby.sledgehammer.data.warp.WarpPayload;
import com.noahhusby.sledgehammer.gui.inventories.general.GUIController;
import com.noahhusby.sledgehammer.gui.inventories.general.GUIRegistry;
import com.noahhusby.sledgehammer.gui.inventories.general.IGUIChild;
import org.bukkit.entity.Player;

Expand All @@ -49,9 +48,11 @@ public AllWarpInventoryController(GUIController controller, WarpPayload payload)
public void init() {
List<Warp> warps = new ArrayList<>();
for(WarpGroup wg : payload.getGroups())
warps.addAll(wg.getWarps());
for(Warp w : wg.getWarps())
warps.add(w);

int total_pages = (int) Math.ceil(warps.size() / 27.0);
if(total_pages == 0) total_pages = 1;
for(int x = 0; x < total_pages; x++) {
AllWarpInventory w = new AllWarpInventory(x, warps);
w.initFromController(this, getPlayer(), getInventory());
Expand All @@ -72,8 +73,4 @@ public IGUIChild getChildByPage(int page) {
public WarpPayload getPayload() {
return payload;
}

public void switchToPinned() {
GUIRegistry.register(new PinnedWarpInventoryController(this, null));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public void onMessage(PacketInfo info, SmartObject data) {
}

WarpPayload payload = WarpPayload.fromPayload(data);
if(payload.getGroups().isEmpty()) payload.setDefaultPage("pinned");

switch (payload.getDefaultPage()) {
default:
Expand Down
2 changes: 1 addition & 1 deletion sledgehammer-bukkit/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Sledgehammer
version: 0.4.1
version: 0.4.2
main: com.noahhusby.sledgehammer.Sledgehammer
prefix: Sledgehammer
authors: [ noahhusby ]
Expand Down
4 changes: 1 addition & 3 deletions sledgehammer-bungeecord/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.noahhusby</groupId>
<artifactId>sledgehammer</artifactId>
<version>0.4.1-bungeecord</version>
<version>0.4.2-bungeecord</version>
<repositories>
<repository>
<id>bungeecord-repo</id>
Expand Down Expand Up @@ -109,6 +109,4 @@
<scope>compile</scope>
</dependency>
</dependencies>


</project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

public class Constants {
public static final String PLUGINID = "sledgehammer";
public static final String VERSION = "0.4.1";
public static final String VERSION = "0.4.2";
public static final double SCALE = 7318261.522857145;

public static final String nominatimAPI = "https://nominatim.openstreetmap.org/reverse.php?osm_type=N&format=json&zoom={zoom}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.noahhusby.sledgehammer.datasets;

import com.google.common.collect.Maps;
import com.google.gson2.Gson;
import com.noahhusby.sledgehammer.Constants;
import com.noahhusby.sledgehammer.config.ConfigHandler;
import com.noahhusby.sledgehammer.config.ServerConfig;
Expand Down Expand Up @@ -75,10 +76,12 @@ public ServerInfo getServerFromLocation(double lon, double lat) {
*/
public ServerInfo getServerFromLocation(double lon, double lat, boolean offline) {
Location location = offline ? getOfflineLocation(lon, lat) : getLocation(lon, lat);
if(location == null) return null;
Map<Location.detail, ServerInfo> serverInfoMap = Maps.newHashMap();

for (SledgehammerServer s : ServerConfig.getInstance().getServers()) {
if (!s.isEarthServer()) continue;
if(s.getLocations() == null || s.getLocations().isEmpty()) continue;
for (Location l : s.getLocations()) {
switch (l.detailType) {
case city:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public void onMessage(PacketInfo info, SmartObject data) {
point.getString("z"), point.getString("yaw"), point.getString("pitch"));

SledgehammerPlayer player = SledgehammerPlayer.getPlayer(info.getSender());
if(player == null) return;
player.setLocation(p);
player.setGameMode(GameMode.valueOf(data.getString("gameMode")));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,5 @@ public void onMessage(PacketInfo info, SmartObject data) {

player.sendMessage(ChatHelper.makeTitleTextComponent(new TextElement("Warping to ", ChatColor.GRAY), new TextElement(warp.getName(), ChatColor.RED)));
SledgehammerNetworkManager.getInstance().send(new P2STeleportPacket(player.getName(), warp.getServer(), warp.getPoint()));

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void send(IP2SPacket packet) {
e.printStackTrace();
}

ProxyServer.getInstance().getServerInfo(packet.getPacketInfo().getServer()).sendData("sledgehammer:channel", stream.toByteArray());
ProxyServer.getInstance().getServerInfo(packet.getPacketInfo().getServer()).sendData("sledgehammer:channel", stream.toByteArray(), true);
}

/**
Expand All @@ -113,7 +113,7 @@ public void onIncomingPacket(PluginMessageEvent e) {
}
} catch (ParseException ex) {
ex.printStackTrace();
}
} catch (Exception ignored) { }
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.noahhusby.lib.data.storage.StorageList;
import com.noahhusby.sledgehammer.Sledgehammer;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.event.PostLoginEvent;
Expand Down Expand Up @@ -52,19 +53,28 @@ private PlayerManager() {
*/
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerJoin(PostLoginEvent e) {
ProxiedPlayer player = e.getPlayer();
onPlayerDisconnect(new PlayerDisconnectEvent(player));
SledgehammerPlayer newPlayer = new SledgehammerPlayer(player);
onPlayerJoin(e.getPlayer());
}

/**
* Creates a new SledgehammerPlayer and sets attributes from storage upon player joining
* @param p {@link ProxiedPlayer}
*/
private SledgehammerPlayer onPlayerJoin(ProxiedPlayer p) {
onPlayerDisconnect(new PlayerDisconnectEvent(p));
SledgehammerPlayer newPlayer = new SledgehammerPlayer(p);

Attribute attribute = null;
for(Attribute a : attributes)
if(a.getUuid().toString().equals(player.getUniqueId().toString())) attribute = a;
if(a.getUuid().toString().equals(p.getUniqueId().toString())) attribute = a;

if(attribute != null) {
newPlayer.setAttributes(attribute.getAttributes());
}

players.add(newPlayer);

return newPlayer;
}

/**
Expand All @@ -73,7 +83,14 @@ public void onPlayerJoin(PostLoginEvent e) {
*/
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerDisconnect(PlayerDisconnectEvent e) {
ProxiedPlayer player = e.getPlayer();
onPlayerDisconnect(e.getPlayer());
}

/**
* Removes the SledgehammerPlayer and saves the attributes to storage upon player leaving
* @param player {@link ProxiedPlayer}
*/
private void onPlayerDisconnect(ProxiedPlayer player) {
List<SledgehammerPlayer> remove = new ArrayList<>();
for(SledgehammerPlayer p : players) {
if(p.getName().equalsIgnoreCase(player.getName())) {
Expand Down Expand Up @@ -123,6 +140,10 @@ public SledgehammerPlayer getPlayer(String s) {
}
}

for(ProxiedPlayer p : ProxyServer.getInstance().getPlayers())
if(p.getName().equalsIgnoreCase(s))
return onPlayerJoin(p);

return null;
}

Expand All @@ -132,14 +153,7 @@ public SledgehammerPlayer getPlayer(String s) {
* @return {@link SledgehammerPlayer}
*/
public SledgehammerPlayer getPlayer(CommandSender s) {
for(SledgehammerPlayer p : players) {
if(p.getName().equalsIgnoreCase(s.getName())) {
p.update();
return p;
}
}

return null;
return getPlayer(s.getName());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion sledgehammer-bungeecord/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Sledgehammer
main: com.noahhusby.sledgehammer.Sledgehammer
version: 0.4.1
version: 0.4.2
author: noahhusby

0 comments on commit 3b20500

Please sign in to comment.