- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 21
GH-971 Migrate jail feature from Position to Location with LocationPersister. Rename config section. #1141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            igoyek
  wants to merge
  18
  commits into
  master
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
jail-system-refactor
  
      
      
   
  
    
  
  
  
 
  
      
    base: master
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    GH-971 Migrate jail feature from Position to Location with LocationPersister. Rename config section. #1141
Changes from 11 commits
      Commits
    
    
            Show all changes
          
          
            18 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      4a1734c
              
                Add jail command restriction type and refactor config
              
              
                igoyek ad0b8c2
              
                The prison system has been improved
              
              
                igoyek 656b7be
              
                Refactor jail release logic and update config comments
              
              
                igoyek 5bf5d52
              
                Need tests
              
              
                igoyek 526e344
              
                detainPrivate -> detained
              
              
                Jakubk15 67c0735
              
                Refactor jail feature to use Bukkit Location
              
              
                igoyek ef0a5cb
              
                Location -> Position refactor
              
              
                igoyek c3bb59a
              
                Remove PositionArgument and related messages
              
              
                igoyek d640f4c
              
                Ensure home location uses sender's world and orientation
              
              
                igoyek e09ca18
              
                Refactor jail section migration and improve Position handling
              
              
                igoyek 6c38f6f
              
                Remove unused import
              
              
                igoyek c2768cc
              
                Follow instructions
              
              
                igoyek 5a76360
              
                Merge branch 'master' into jail-system-refactor
              
              
                igoyek 9015129
              
                Merge branch 'master' into jail-system-refactor
              
              
                vLuckyyy b88917d
              
                Merge.
              
              
                vLuckyyy 5da106e
              
                Remove useless migration.
              
              
                vLuckyyy feb4c9e
              
                Revert not-related to issue changes.
              
              
                vLuckyyy e31948e
              
                Review.
              
              
                vLuckyyy File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
          
            5 changes: 3 additions & 2 deletions
          
          5 
        
  eternalcore-api/src/main/java/com/eternalcode/core/feature/home/Home.java
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
          
            13 changes: 13 additions & 0 deletions
          
          13 
        
  ...e/configuration/migrations/Migration_0009_Rename_allowed_to_restricted_jail_commands.java
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package com.eternalcode.core.configuration.migrations; | ||
|  | ||
| import static eu.okaeri.configs.migrate.ConfigMigrationDsl.move; | ||
| import eu.okaeri.configs.migrate.builtin.NamedMigration; | ||
|  | ||
| class Migration_0009_Rename_allowed_to_restricted_jail_commands extends NamedMigration { | ||
|  | ||
| Migration_0009_Rename_allowed_to_restricted_jail_commands() { | ||
| super("Rename allowed to restricted jail commands", | ||
| move("jail.allowedCommands", "jail.restrictedCommands") | ||
|         
                  igoyek marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| ); | ||
| } | ||
| } | ||
        
          
          
            37 changes: 37 additions & 0 deletions
          
          37 
        
  ...ava/com/eternalcode/core/configuration/migrations/Migration_0010_Rename_jail_section.java
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package com.eternalcode.core.configuration.migrations; | ||
|  | ||
| import static eu.okaeri.configs.migrate.ConfigMigrationDsl.move; | ||
|  | ||
| import eu.okaeri.configs.migrate.builtin.NamedMigration; | ||
|  | ||
| public class Migration_0010_Rename_jail_section extends NamedMigration { | ||
|  | ||
| Migration_0010_Rename_jail_section() { | ||
| super( | ||
| "Rename jail section", | ||
|  | ||
| move("jailSection.jailLocationSet", "jail.locationSet"), | ||
| move("jailSection.jailLocationRemove", "jail.locationRemove"), | ||
| move("jailSection.jailLocationNotSet", "jail.locationNotSet"), | ||
| move("jailSection.jailLocationOverride", "jail.locationOverride"), | ||
|  | ||
| move("jailSection.jailDetainBroadcast", "jail.detainBroadcast"), | ||
| move("jailSection.jailDetainPrivate", "jail.detained"), | ||
| move("jailSection.jailDetainCountdown", "jail.detainCountdown"), | ||
| move("jailSection.jailDetainOverride", "jail.detainOverride"), | ||
| move("jailSection.jailDetainAdmin", "jail.detainAdmin"), | ||
|  | ||
| move("jailSection.jailReleaseBroadcast", "jail.releaseBroadcast"), | ||
| move("jailSection.jailReleasePrivate", "jail.released"), | ||
| move("jailSection.jailReleaseAll", "jail.releaseAll"), | ||
| move("jailSection.jailReleaseNoPlayers", "jail.releaseNoPlayers"), | ||
| move("jailSection.jailIsNotPrisoner", "jail.isNotPrisoner"), | ||
|  | ||
| move("jailSection.jailListHeader", "jail.listHeader"), | ||
| move("jailSection.jailListEmpty", "jail.listEmpty"), | ||
| move("jailSection.jailListPlayerEntry", "jail.listPlayerEntry"), | ||
|  | ||
| move("jailSection.jailCannotUseCommand", "jail.cannotUseCommand") | ||
| ); | ||
| } | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
  
    
      
          
            70 changes: 70 additions & 0 deletions
          
          70 
        
  ...nalcore-core/src/main/java/com/eternalcode/core/database/persister/PositionPersister.java
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| package com.eternalcode.core.database.persister; | ||
|  | ||
| import com.eternalcode.commons.bukkit.position.Position; | ||
| import com.eternalcode.commons.bukkit.position.PositionAdapter; | ||
| import com.j256.ormlite.field.FieldType; | ||
| import com.j256.ormlite.field.SqlType; | ||
| import com.j256.ormlite.field.types.BaseDataType; | ||
| import com.j256.ormlite.support.DatabaseResults; | ||
|  | ||
| import java.sql.SQLException; | ||
|  | ||
| public class PositionPersister extends BaseDataType { | ||
|  | ||
| private static final PositionPersister instance = new PositionPersister(); | ||
|  | ||
| private PositionPersister() { | ||
| super(SqlType.LONG_STRING, new Class<?>[] {Position.class}); | ||
| } | ||
|  | ||
| @Override | ||
| public Object javaToSqlArg(FieldType fieldType, Object javaObject) { | ||
| if (javaObject == null) { | ||
| return null; | ||
| } | ||
|  | ||
| if (!(javaObject instanceof Position position)) { | ||
| throw new IllegalArgumentException("Invalid object type: " + javaObject.getClass().getName()); | ||
| } | ||
|  | ||
| return position.toString(); | ||
| } | ||
|  | ||
| @Override | ||
| public Object resultToSqlArg(FieldType fieldType, DatabaseResults results, int columnPos) throws SQLException { | ||
| return results.getString(columnPos); | ||
| } | ||
|  | ||
| @Override | ||
| public Object parseDefaultString(FieldType fieldType, String defaultStr) { | ||
| return String.valueOf(defaultStr); | ||
| } | ||
|  | ||
| @Override | ||
| public Object sqlArgToJava(FieldType fieldType, Object sqlArg, int columnPos) { | ||
| String s = (String) sqlArg; | ||
|  | ||
| if (s == null) { | ||
| return null; | ||
| } | ||
|  | ||
| String[] params = s.split("/"); | ||
|  | ||
| if (params.length != 6) { | ||
| throw new IllegalArgumentException("Invalid position format: " + s); | ||
| } | ||
|  | ||
| return new Position( | ||
| Double.parseDouble(params[1]), | ||
| Double.parseDouble(params[2]), | ||
| Double.parseDouble(params[3]), | ||
| Float.parseFloat(params[4]), | ||
| Float.parseFloat(params[5]), | ||
| params[0] | ||
| ); | ||
|         
                  vLuckyyy marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| } | ||
|  | ||
| public static PositionPersister getSingleton() { | ||
| return instance; | ||
| } | ||
| } | ||
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Position usage in API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trochę słabo będzie wystawiać API które jest relokowane