Skip to content

Commit

Permalink
Multithread the rendering process; Added showname option; Added trimm…
Browse files Browse the repository at this point in the history
…ing of data outside of borders; Added max zoom visibility for towny cursors
  • Loading branch information
BananaPuncher714 committed Jan 5, 2021
1 parent c278dba commit b2a2907
Show file tree
Hide file tree
Showing 48 changed files with 522 additions and 101 deletions.
2 changes: 1 addition & 1 deletion Cartographer2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>io.github.bananapuncher714</groupId>
<artifactId>cartographer2_master</artifactId>
<version>2.14.9</version>
<version>2.14.10</version>
</parent>
<artifactId>cartographer2</artifactId>

Expand Down
2 changes: 1 addition & 1 deletion Cartographer2_API/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.github.bananapuncher714</groupId>
<artifactId>cartographer2_master</artifactId>
<version>2.14.9</version>
<version>2.14.10</version>
</parent>
<artifactId>cartographer2_api</artifactId>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class CartographerSettings {

// Global default for rotation setting
private boolean rotateByDefault = true;
// Global default for showing the player's name
private boolean shownameByDefault = true;
// Print out debug information regarding missing colors and materials in the console
private boolean paletteDebug;
// Catch the drop item packet
Expand Down Expand Up @@ -58,6 +60,14 @@ public void setRotateByDefault( boolean rotate ) {
rotateByDefault = rotate;
}

public boolean isShownameByDefault() {
return shownameByDefault;
}

public void setShownameByDefault( boolean shownameByDefault ) {
this.shownameByDefault = shownameByDefault;
}

public boolean isPaletteDebug() {
return paletteDebug;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public final class LocaleConstants {

// Minimap
public static final String MINIMAP_DEFAULT_ROTATION = "core.minimap.default-rotation";
public static final String MINIMAP_DEFAULT_SHOWNAME = "core.minimap.default-showname";
public static final String MINIMAP_AUTO_UPDATE = "core.minimap.auto-update";
public static final String MINIMAP_ZOOM_CIRCULAR = "core.minimap.circular-zoom";
public static final String MINIMAP_RENDER = "core.minimap.render-out-of-border";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,17 @@ public class MapSettings {

// Default rotation option
protected BooleanOption rotation = BooleanOption.UNSET;
protected BooleanOption showName = BooleanOption.UNSET;

// If the images should be dithered
protected boolean ditherOverlay = false;
protected boolean ditherBackground = false;
protected boolean ditherDisabled = false;

protected String overlayPath;
protected String backgroundPath;
protected String disabledPath;

protected boolean reloadChunks = true;

// Default palette
Expand Down Expand Up @@ -95,6 +100,22 @@ public void setRotation( BooleanOption rotation ) {
this.rotation = rotation;
}

public BooleanOption getShowName() {
return showName;
}

public void setShowName(BooleanOption showName) {
this.showName = showName;
}

public String getOverlayPath() {
return overlayPath;
}

public void setOverlayPath( String overlayPath ) {
this.overlayPath = overlayPath;
}

public boolean isDitherOverlay() {
return ditherOverlay;
}
Expand All @@ -103,6 +124,14 @@ public void setDitherOverlay( boolean ditherOverlay ) {
this.ditherOverlay = ditherOverlay;
}

public String getBackgroundPath() {
return backgroundPath;
}

public void setBackgroundPath( String backgroundPath ) {
this.backgroundPath = backgroundPath;
}

public boolean isDitherBackground() {
return ditherBackground;
}
Expand All @@ -111,6 +140,14 @@ public void setDitherBackground( boolean ditherBackground ) {
this.ditherBackground = ditherBackground;
}

public String getBlacklistedPath() {
return disabledPath;
}

public void getBlacklistedPath( String disabledPath ) {
this.disabledPath = disabledPath;
}

public boolean isDitherBlacklisted() {
return ditherDisabled;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import org.bukkit.configuration.file.FileConfiguration;

import io.github.bananapuncher714.cartographer.core.api.BooleanOption;
import io.github.bananapuncher714.cartographer.core.api.SimpleImage;
import io.github.bananapuncher714.cartographer.core.api.setting.SettingState;
import io.github.bananapuncher714.cartographer.core.api.setting.SettingStateBoolean;
Expand All @@ -19,7 +20,7 @@
* @author BananaPuncher714
*/
public class MapViewer {
public static final SettingStateBoolean SHOWNAME = null;
public static final SettingStateBooleanOption SHOWNAME = null;
public static final SettingStateBoolean CURSOR = null;
public static final SettingStateBooleanOption ROTATE = null;
public static final SettingStateLocale LOCALE = null;
Expand Down
2 changes: 1 addition & 1 deletion Cartographer2_Main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.github.bananapuncher714</groupId>
<artifactId>cartographer2_master</artifactId>
<version>2.14.9</version>
<version>2.14.10</version>
</parent>
<artifactId>cartographer2_main</artifactId>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ private void loadConfig() {
settings.setRenderDelay( config.getInt( "render-delay", 1 ) );
settings.setPaletteDebug( config.getBoolean( "palette-debug", false ) );
settings.setRotateByDefault( config.getBoolean( "rotate-by-default", true ) );

settings.setShownameByDefault( config.getBoolean( "showname-by-default", true ) );

settings.setBlockUpdateDelay( config.getInt( "block-update.tick-delay", 5 ) );
settings.setBlockUpdateAmount( config.getInt( "block-update.update-amount", 20 ) );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class CartographerSettings {

// Global default for rotation setting
private boolean rotateByDefault = true;
// Global default for showing the player's name
private boolean shownameByDefault = true;
// Print out debug information regarding missing colors and materials in the console
private boolean paletteDebug;
// Catch the drop item packet
Expand Down Expand Up @@ -58,6 +60,14 @@ public void setRotateByDefault( boolean rotate ) {
rotateByDefault = rotate;
}

public boolean isShownameByDefault() {
return shownameByDefault;
}

public void setShownameByDefault( boolean shownameByDefault ) {
this.shownameByDefault = shownameByDefault;
}

public boolean isPaletteDebug() {
return paletteDebug;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public final class LocaleConstants {

// Minimap
public static final String MINIMAP_DEFAULT_ROTATION = "core.minimap.default-rotation";
public static final String MINIMAP_DEFAULT_SHOWNAME = "core.minimap.default-showname";
public static final String MINIMAP_AUTO_UPDATE = "core.minimap.auto-update";
public static final String MINIMAP_ZOOM_CIRCULAR = "core.minimap.circular-zoom";
public static final String MINIMAP_RENDER = "core.minimap.render-out-of-border";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.bukkit.map.MapCursor.Type;

import io.github.bananapuncher714.cartographer.core.Cartographer;
import io.github.bananapuncher714.cartographer.core.api.BooleanOption;
import io.github.bananapuncher714.cartographer.core.api.WorldCursor;
import io.github.bananapuncher714.cartographer.core.api.map.WorldCursorProvider;
import io.github.bananapuncher714.cartographer.core.renderer.PlayerSetting;
Expand All @@ -24,7 +25,14 @@ public Collection< WorldCursor > getCursors( Player player, Minimap map, PlayerS

MapViewer viewer = Cartographer.getInstance().getPlayerManager().getViewerFor( player.getUniqueId() );

cursors.add( new WorldCursor( viewer.getSetting( MapViewer.SHOWNAME ) ? player.getName() : null, setting.getLocation(), Type.WHITE_POINTER, true ) );
boolean nameVisible = Cartographer.getInstance().getSettings().isShownameByDefault();
if ( map.getSettings().getShowName() != BooleanOption.UNSET ) {
nameVisible = map.getSettings().getRotation().isTrue();
} else if ( viewer.getSetting( MapViewer.ROTATE ) != BooleanOption.UNSET ) {
nameVisible = viewer.getSetting( MapViewer.ROTATE ).isTrue();
}

cursors.add( new WorldCursor( nameVisible ? player.getName() : null, setting.getLocation(), Type.WHITE_POINTER, true ) );
return cursors;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,17 @@ public class MapSettings {

// Default rotation option
protected BooleanOption rotation = BooleanOption.UNSET;
protected BooleanOption showName = BooleanOption.UNSET;

// If the images should be dithered
protected boolean ditherOverlay = false;
protected boolean ditherBackground = false;
protected boolean ditherDisabled = false;

protected String overlayPath;
protected String backgroundPath;
protected String disabledPath;

protected boolean reloadChunks = true;

// Default palette
Expand All @@ -57,6 +62,7 @@ public MapSettings( FileConfiguration config ) {
circularZoom = config.getBoolean( "circular-zoom", false );
autoUpdate = config.getBoolean( "auto-update", true );
rotation = FailSafe.getEnum( BooleanOption.class, config.getString( "rotate", "UNSET" ).toUpperCase() );
showName = FailSafe.getEnum( BooleanOption.class, config.getString( "showname", "UNSET" ).toUpperCase() );
renderOutOfBorder = config.getBoolean( "render-out-of-border", false );
for ( String string : config.getStringList( "allowed-zooms" ) ) {
double zoomVal = 1;
Expand All @@ -75,6 +81,10 @@ public MapSettings( FileConfiguration config ) {
ditherBackground = config.getBoolean( "images.dither-background", false );
ditherDisabled = config.getBoolean( "images.dither-blacklisted", false );

overlayPath = config.getString( "images.overlay" );
backgroundPath = config.getString( "images.overlay" );
disabledPath = config.getString( "images.overlay" );

reloadChunks = config.getBoolean( "chunks.reload-chunks", true );

palette = Cartographer.getInstance().getPaletteManager().construct( config.getStringList( "palettes" ) );
Expand Down Expand Up @@ -128,6 +138,22 @@ public void setRotation( BooleanOption rotation ) {
this.rotation = rotation;
}

public BooleanOption getShowName() {
return showName;
}

public void setShowName(BooleanOption showName) {
this.showName = showName;
}

public String getOverlayPath() {
return overlayPath;
}

public void setOverlayPath( String overlayPath ) {
this.overlayPath = overlayPath;
}

public boolean isDitherOverlay() {
return ditherOverlay;
}
Expand All @@ -136,6 +162,14 @@ public void setDitherOverlay( boolean ditherOverlay ) {
this.ditherOverlay = ditherOverlay;
}

public String getBackgroundPath() {
return backgroundPath;
}

public void setBackgroundPath( String backgroundPath ) {
this.backgroundPath = backgroundPath;
}

public boolean isDitherBackground() {
return ditherBackground;
}
Expand All @@ -144,6 +178,14 @@ public void setDitherBackground( boolean ditherBackground ) {
this.ditherBackground = ditherBackground;
}

public String getBlacklistedPath() {
return disabledPath;
}

public void getBlacklistedPath( String disabledPath ) {
this.disabledPath = disabledPath;
}

public boolean isDitherBlacklisted() {
return ditherDisabled;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @author BananaPuncher714
*/
public class MapViewer {
public static final SettingStateBoolean SHOWNAME = SettingStateBoolean.of( "showname", false, true );
public static final SettingStateBooleanOption SHOWNAME = SettingStateBooleanOption.of( "showname", false, BooleanOption.UNSET );
public static final SettingStateBoolean CURSOR = SettingStateBoolean.of( "cursor", false, false );
public static final SettingStateBooleanOption ROTATE = SettingStateBooleanOption.of( "rotate", false, BooleanOption.TRUE );
public static final SettingStateLocale LOCALE = new SettingStateLocale( "locale", false );
Expand Down
Loading

0 comments on commit b2a2907

Please sign in to comment.